@geekmidas/constructs 9.0.2 → 10.0.0-alpha.0

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 (385) hide show
  1. package/README.md +71 -44
  2. package/dist/{AWSScheduledFunction-Bn99MceY.d.cts → AWSScheduledFunction-BvFvBsBN.d.cts} +8 -3
  3. package/dist/{AWSScheduledFunction-ysaCsdWx.d.mts.map → AWSScheduledFunction-BvFvBsBN.d.cts.map} +1 -1
  4. package/dist/{AWSScheduledFunction-ysaCsdWx.d.mts → AWSScheduledFunction-CVccZO-L.d.mts} +9 -4
  5. package/dist/{AWSScheduledFunction-Bn99MceY.d.cts.map → AWSScheduledFunction-CVccZO-L.d.mts.map} +1 -1
  6. package/dist/{AWSScheduledFunction-CufMMhGB.mjs → AWSScheduledFunction-Db1lttJH.mjs} +3 -3
  7. package/dist/{AWSScheduledFunction-CufMMhGB.mjs.map → AWSScheduledFunction-Db1lttJH.mjs.map} +1 -1
  8. package/dist/{AWSScheduledFunction-DbkDr8CA.cjs → AWSScheduledFunction-qu4ieRZR.cjs} +9 -9
  9. package/dist/{AWSScheduledFunction-DbkDr8CA.cjs.map → AWSScheduledFunction-qu4ieRZR.cjs.map} +1 -1
  10. package/dist/{Construct-_1wX7p_Y.d.cts → Construct-B-xc0SE9.d.mts} +27 -5
  11. package/dist/Construct-B-xc0SE9.d.mts.map +1 -0
  12. package/dist/{Construct-r0U2zBwW.mjs → Construct-HmWM6YYu.mjs} +4 -3
  13. package/dist/Construct-HmWM6YYu.mjs.map +1 -0
  14. package/dist/{Construct-DCMuYOox.d.mts → Construct-WhCXIOPV.d.cts} +29 -7
  15. package/dist/Construct-WhCXIOPV.d.cts.map +1 -0
  16. package/dist/{Construct-vXMZJgRp.cjs → Construct-roId57cU.cjs} +7 -43
  17. package/dist/Construct-roId57cU.cjs.map +1 -0
  18. package/dist/{lazyAccessors-DmTG8sQH.cjs → Endpoint-BBkV6l0k.cjs} +869 -1079
  19. package/dist/Endpoint-BBkV6l0k.cjs.map +1 -0
  20. package/dist/{lazyAccessors-DfqZR6C4.mjs → Endpoint-BGwpNEX4.mjs} +840 -1003
  21. package/dist/Endpoint-BGwpNEX4.mjs.map +1 -0
  22. package/dist/{Endpoint-DgfRslct.d.cts → Endpoint-BnxZqIX-.d.cts} +53 -4
  23. package/dist/Endpoint-BnxZqIX-.d.cts.map +1 -0
  24. package/dist/{Endpoint-CLPSIl6S.d.mts → Endpoint-ROcXU-eH.d.mts} +55 -6
  25. package/dist/Endpoint-ROcXU-eH.d.mts.map +1 -0
  26. package/dist/EndpointFactory-DYoGLaIT.cjs +850 -0
  27. package/dist/EndpointFactory-DYoGLaIT.cjs.map +1 -0
  28. package/dist/EndpointFactory-Di0X9AWp.mjs +808 -0
  29. package/dist/EndpointFactory-Di0X9AWp.mjs.map +1 -0
  30. package/dist/{HonoEndpointAdaptor-DJDT3PMx.mjs → HonoEndpointAdaptor-DFKIIG2o.mjs} +5 -4
  31. package/dist/HonoEndpointAdaptor-DFKIIG2o.mjs.map +1 -0
  32. package/dist/{HonoEndpointAdaptor-CkJENANP.cjs → HonoEndpointAdaptor-wMsCyMgt.cjs} +24 -23
  33. package/dist/HonoEndpointAdaptor-wMsCyMgt.cjs.map +1 -0
  34. package/dist/{Queue-DaxjwmOQ.d.cts → Queue-D6WeziRD.d.cts} +43 -4
  35. package/dist/Queue-D6WeziRD.d.cts.map +1 -0
  36. package/dist/{Queue-HBDf0fqz.d.mts → Queue-DpUeqdC8.d.mts} +43 -4
  37. package/dist/Queue-DpUeqdC8.d.mts.map +1 -0
  38. package/dist/{Subscriber-B69ngPwl.d.cts → Subscriber-4rBJgDKI.d.mts} +9 -4
  39. package/dist/{Subscriber-B69ngPwl.d.cts.map → Subscriber-4rBJgDKI.d.mts.map} +1 -1
  40. package/dist/{Subscriber-D8Xm-86W.d.mts → Subscriber-DVQowdyj.d.cts} +11 -6
  41. package/dist/Subscriber-DVQowdyj.d.cts.map +1 -0
  42. package/dist/{Topic-C5ZMfveW.d.cts → Topic-Ohx9dvWr.d.cts} +33 -2
  43. package/dist/Topic-Ohx9dvWr.d.cts.map +1 -0
  44. package/dist/{Topic-DT10AqHk.d.mts → Topic-cmy2jOUy.d.mts} +33 -2
  45. package/dist/Topic-cmy2jOUy.d.mts.map +1 -0
  46. package/dist/adaptors/aws.cjs +39 -26
  47. package/dist/adaptors/aws.cjs.map +1 -1
  48. package/dist/adaptors/aws.d.cts +24 -16
  49. package/dist/adaptors/aws.d.cts.map +1 -1
  50. package/dist/adaptors/aws.d.mts +25 -17
  51. package/dist/adaptors/aws.d.mts.map +1 -1
  52. package/dist/adaptors/aws.mjs +26 -14
  53. package/dist/adaptors/aws.mjs.map +1 -1
  54. package/dist/adaptors/hono.cjs +9 -6
  55. package/dist/adaptors/hono.d.cts +7 -6
  56. package/dist/adaptors/hono.d.cts.map +1 -1
  57. package/dist/adaptors/hono.d.mts +8 -7
  58. package/dist/adaptors/hono.d.mts.map +1 -1
  59. package/dist/adaptors/hono.mjs +9 -6
  60. package/dist/adaptors/testing.cjs +18 -14
  61. package/dist/adaptors/testing.cjs.map +1 -1
  62. package/dist/adaptors/testing.d.cts +7 -6
  63. package/dist/adaptors/testing.d.cts.map +1 -1
  64. package/dist/adaptors/testing.d.mts +11 -10
  65. package/dist/adaptors/testing.d.mts.map +1 -1
  66. package/dist/adaptors/testing.mjs +10 -7
  67. package/dist/adaptors/testing.mjs.map +1 -1
  68. package/dist/auth.cjs +165 -0
  69. package/dist/auth.cjs.map +1 -0
  70. package/dist/auth.d.cts +108 -0
  71. package/dist/auth.d.cts.map +1 -0
  72. package/dist/auth.d.mts +108 -0
  73. package/dist/auth.d.mts.map +1 -0
  74. package/dist/auth.mjs +164 -0
  75. package/dist/auth.mjs.map +1 -0
  76. package/dist/cache-0ANvRQnD.mjs +51 -0
  77. package/dist/cache-0ANvRQnD.mjs.map +1 -0
  78. package/dist/cache-3WSvAulx.cjs +57 -0
  79. package/dist/cache-3WSvAulx.cjs.map +1 -0
  80. package/dist/cache-CdQ7OLpR.d.cts +47 -0
  81. package/dist/cache-CdQ7OLpR.d.cts.map +1 -0
  82. package/dist/cache-DYoJFcfd.d.mts +47 -0
  83. package/dist/cache-DYoJFcfd.d.mts.map +1 -0
  84. package/dist/cache.cjs +3 -0
  85. package/dist/cache.d.cts +3 -0
  86. package/dist/cache.d.mts +3 -0
  87. package/dist/cache.mjs +3 -0
  88. package/dist/chunk-DWy1uDak.cjs +39 -0
  89. package/dist/clone-DblgEZZa.mjs +39 -0
  90. package/dist/clone-DblgEZZa.mjs.map +1 -0
  91. package/dist/clone-Dy0cR2SZ.cjs +45 -0
  92. package/dist/clone-Dy0cR2SZ.cjs.map +1 -0
  93. package/dist/construct-interface-BfjcOD_E.cjs +117 -0
  94. package/dist/construct-interface-BfjcOD_E.cjs.map +1 -0
  95. package/dist/construct-interface-BqwRNYA2.d.mts +131 -0
  96. package/dist/construct-interface-BqwRNYA2.d.mts.map +1 -0
  97. package/dist/construct-interface-D2nNkHUN.d.cts +131 -0
  98. package/dist/construct-interface-D2nNkHUN.d.cts.map +1 -0
  99. package/dist/construct-interface-Z4CpS8tK.mjs +81 -0
  100. package/dist/construct-interface-Z4CpS8tK.mjs.map +1 -0
  101. package/dist/construct-interface.cjs +8 -0
  102. package/dist/construct-interface.d.cts +2 -0
  103. package/dist/construct-interface.d.mts +2 -0
  104. package/dist/construct-interface.mjs +3 -0
  105. package/dist/credential.cjs +96 -0
  106. package/dist/credential.cjs.map +1 -0
  107. package/dist/credential.d.cts +61 -0
  108. package/dist/credential.d.cts.map +1 -0
  109. package/dist/credential.d.mts +61 -0
  110. package/dist/credential.d.mts.map +1 -0
  111. package/dist/credential.mjs +94 -0
  112. package/dist/credential.mjs.map +1 -0
  113. package/dist/crons/index.cjs +39 -37
  114. package/dist/crons/index.cjs.map +1 -1
  115. package/dist/crons/index.d.cts +21 -8
  116. package/dist/crons/index.d.cts.map +1 -1
  117. package/dist/crons/index.d.mts +29 -13
  118. package/dist/crons/index.d.mts.map +1 -1
  119. package/dist/crons/index.mjs +37 -36
  120. package/dist/crons/index.mjs.map +1 -1
  121. package/dist/database/kysely.cjs +181 -0
  122. package/dist/database/kysely.cjs.map +1 -0
  123. package/dist/database/kysely.d.cts +152 -0
  124. package/dist/database/kysely.d.cts.map +1 -0
  125. package/dist/database/kysely.d.mts +152 -0
  126. package/dist/database/kysely.d.mts.map +1 -0
  127. package/dist/database/kysely.mjs +180 -0
  128. package/dist/database/kysely.mjs.map +1 -0
  129. package/dist/email.cjs +59 -0
  130. package/dist/email.cjs.map +1 -0
  131. package/dist/email.d.cts +50 -0
  132. package/dist/email.d.cts.map +1 -0
  133. package/dist/email.d.mts +50 -0
  134. package/dist/email.d.mts.map +1 -0
  135. package/dist/email.mjs +58 -0
  136. package/dist/email.mjs.map +1 -0
  137. package/dist/endpoints/index.cjs +21 -747
  138. package/dist/endpoints/index.d.cts +7 -343
  139. package/dist/endpoints/index.d.mts +7 -342
  140. package/dist/endpoints/index.mjs +11 -738
  141. package/dist/file-server.cjs +154 -0
  142. package/dist/file-server.cjs.map +1 -0
  143. package/dist/file-server.d.cts +156 -0
  144. package/dist/file-server.d.cts.map +1 -0
  145. package/dist/file-server.d.mts +156 -0
  146. package/dist/file-server.d.mts.map +1 -0
  147. package/dist/file-server.mjs +152 -0
  148. package/dist/file-server.mjs.map +1 -0
  149. package/dist/functions/index.cjs +4 -2
  150. package/dist/functions/index.d.cts +3 -2
  151. package/dist/functions/index.d.mts +3 -2
  152. package/dist/functions/index.mjs +4 -2
  153. package/dist/{functions-B-qt91O7.mjs → functions-CvT_q7Y4.mjs} +55 -51
  154. package/dist/functions-CvT_q7Y4.mjs.map +1 -0
  155. package/dist/{functions-C8i1kCMM.cjs → functions-DukjG8ov.cjs} +62 -57
  156. package/dist/functions-DukjG8ov.cjs.map +1 -0
  157. package/dist/index-7OcOWe75.d.cts +419 -0
  158. package/dist/index-7OcOWe75.d.cts.map +1 -0
  159. package/dist/index-Bt-F7u8L.d.mts +419 -0
  160. package/dist/index-Bt-F7u8L.d.mts.map +1 -0
  161. package/dist/{index-DP6fqv0I.d.mts → index-CPeqtKgq.d.mts} +48 -19
  162. package/dist/index-CPeqtKgq.d.mts.map +1 -0
  163. package/dist/{index-BVs9DvIj.d.cts → index-Dadljnh_.d.cts} +36 -9
  164. package/dist/index-Dadljnh_.d.cts.map +1 -0
  165. package/dist/index.cjs +1 -1
  166. package/dist/index.d.cts +3 -3
  167. package/dist/index.d.mts +3 -3
  168. package/dist/index.mjs +1 -1
  169. package/dist/lazyAccessors-DM6HcXQk.mjs +175 -0
  170. package/dist/lazyAccessors-DM6HcXQk.mjs.map +1 -0
  171. package/dist/lazyAccessors-DrJj8NpA.cjs +223 -0
  172. package/dist/lazyAccessors-DrJj8NpA.cjs.map +1 -0
  173. package/dist/object-storage.cjs +48 -0
  174. package/dist/object-storage.cjs.map +1 -0
  175. package/dist/object-storage.d.cts +36 -0
  176. package/dist/object-storage.d.cts.map +1 -0
  177. package/dist/object-storage.d.mts +36 -0
  178. package/dist/object-storage.d.mts.map +1 -0
  179. package/dist/object-storage.mjs +47 -0
  180. package/dist/object-storage.mjs.map +1 -0
  181. package/dist/{processAudits-CKjjivyz.cjs → processAudits-Bc8rz6Ev.cjs} +3 -3
  182. package/dist/{processAudits-CKjjivyz.cjs.map → processAudits-Bc8rz6Ev.cjs.map} +1 -1
  183. package/dist/{processAudits-ySnizdMG.mjs → processAudits-D89tICM4.mjs} +1 -1
  184. package/dist/{processAudits-ySnizdMG.mjs.map → processAudits-D89tICM4.mjs.map} +1 -1
  185. package/dist/{publisher-BrFOF847.mjs → publisher-CGEo8UKD.mjs} +1 -1
  186. package/dist/{publisher-BrFOF847.mjs.map → publisher-CGEo8UKD.mjs.map} +1 -1
  187. package/dist/{publisher-lFQleddL.cjs → publisher-CqGsXB2X.cjs} +1 -1
  188. package/dist/{publisher-lFQleddL.cjs.map → publisher-CqGsXB2X.cjs.map} +1 -1
  189. package/dist/queue/index.cjs +92 -30
  190. package/dist/queue/index.cjs.map +1 -1
  191. package/dist/queue/index.d.cts +19 -4
  192. package/dist/queue/index.d.cts.map +1 -1
  193. package/dist/queue/index.d.mts +22 -6
  194. package/dist/queue/index.d.mts.map +1 -1
  195. package/dist/queue/index.mjs +90 -29
  196. package/dist/queue/index.mjs.map +1 -1
  197. package/dist/rest-api.cjs +187 -0
  198. package/dist/rest-api.cjs.map +1 -0
  199. package/dist/rest-api.d.cts +221 -0
  200. package/dist/rest-api.d.cts.map +1 -0
  201. package/dist/rest-api.d.mts +221 -0
  202. package/dist/rest-api.d.mts.map +1 -0
  203. package/dist/rest-api.mjs +186 -0
  204. package/dist/rest-api.mjs.map +1 -0
  205. package/dist/site.cjs +48 -0
  206. package/dist/site.cjs.map +1 -0
  207. package/dist/site.d.cts +101 -0
  208. package/dist/site.d.cts.map +1 -0
  209. package/dist/site.d.mts +101 -0
  210. package/dist/site.d.mts.map +1 -0
  211. package/dist/site.mjs +47 -0
  212. package/dist/site.mjs.map +1 -0
  213. package/dist/subscribers/index.cjs +35 -27
  214. package/dist/subscribers/index.cjs.map +1 -1
  215. package/dist/subscribers/index.d.cts +20 -5
  216. package/dist/subscribers/index.d.cts.map +1 -1
  217. package/dist/subscribers/index.d.mts +23 -7
  218. package/dist/subscribers/index.d.mts.map +1 -1
  219. package/dist/subscribers/index.mjs +34 -27
  220. package/dist/subscribers/index.mjs.map +1 -1
  221. package/dist/surfaceEnv-BFXEms2f.cjs +39 -0
  222. package/dist/surfaceEnv-BFXEms2f.cjs.map +1 -0
  223. package/dist/surfaceEnv-C3Ktahea.mjs +27 -0
  224. package/dist/surfaceEnv-C3Ktahea.mjs.map +1 -0
  225. package/dist/{telemetry-3vdxGn4q.d.mts → telemetry-C3L0iS28.d.cts} +2 -2
  226. package/dist/{telemetry-3vdxGn4q.d.mts.map → telemetry-C3L0iS28.d.cts.map} +1 -1
  227. package/dist/{telemetry-Dqx-D3F7.d.cts → telemetry-D7bVFLGi.d.mts} +2 -2
  228. package/dist/{telemetry-Dqx-D3F7.d.cts.map → telemetry-D7bVFLGi.d.mts.map} +1 -1
  229. package/dist/topic/index.cjs +56 -13
  230. package/dist/topic/index.cjs.map +1 -1
  231. package/dist/topic/index.d.cts +2 -2
  232. package/dist/topic/index.d.cts.map +1 -1
  233. package/dist/topic/index.d.mts +2 -2
  234. package/dist/topic/index.d.mts.map +1 -1
  235. package/dist/topic/index.mjs +54 -12
  236. package/dist/topic/index.mjs.map +1 -1
  237. package/dist/{types-BDNGr7pv.d.mts → types-BlAkSuGI.d.cts} +1 -1
  238. package/dist/{types-BDNGr7pv.d.mts.map → types-BlAkSuGI.d.cts.map} +1 -1
  239. package/dist/{types-BdAaYDvd.d.cts → types-aKksMEWL.d.mts} +1 -1
  240. package/dist/{types-BdAaYDvd.d.cts.map → types-aKksMEWL.d.mts.map} +1 -1
  241. package/dist/types.d.cts +1 -1
  242. package/dist/types.d.mts +1 -1
  243. package/package.json +155 -23
  244. package/CHANGELOG.md +0 -396
  245. package/dist/Construct-DCMuYOox.d.mts.map +0 -1
  246. package/dist/Construct-_1wX7p_Y.d.cts.map +0 -1
  247. package/dist/Construct-r0U2zBwW.mjs.map +0 -1
  248. package/dist/Construct-vXMZJgRp.cjs.map +0 -1
  249. package/dist/Endpoint-CLPSIl6S.d.mts.map +0 -1
  250. package/dist/Endpoint-DgfRslct.d.cts.map +0 -1
  251. package/dist/HonoEndpointAdaptor-CkJENANP.cjs.map +0 -1
  252. package/dist/HonoEndpointAdaptor-DJDT3PMx.mjs.map +0 -1
  253. package/dist/Queue-DaxjwmOQ.d.cts.map +0 -1
  254. package/dist/Queue-HBDf0fqz.d.mts.map +0 -1
  255. package/dist/Subscriber-D8Xm-86W.d.mts.map +0 -1
  256. package/dist/Topic-C5ZMfveW.d.cts.map +0 -1
  257. package/dist/Topic-DT10AqHk.d.mts.map +0 -1
  258. package/dist/endpoints/index.cjs.map +0 -1
  259. package/dist/endpoints/index.d.cts.map +0 -1
  260. package/dist/endpoints/index.d.mts.map +0 -1
  261. package/dist/endpoints/index.mjs.map +0 -1
  262. package/dist/functions-B-qt91O7.mjs.map +0 -1
  263. package/dist/functions-C8i1kCMM.cjs.map +0 -1
  264. package/dist/index-BVs9DvIj.d.cts.map +0 -1
  265. package/dist/index-DP6fqv0I.d.mts.map +0 -1
  266. package/dist/lazyAccessors-DfqZR6C4.mjs.map +0 -1
  267. package/dist/lazyAccessors-DmTG8sQH.cjs.map +0 -1
  268. package/src/Construct.ts +0 -204
  269. package/src/__benchmarks__/build-time-optimization.bench.ts +0 -274
  270. package/src/__benchmarks__/endpoint.bench.ts +0 -494
  271. package/src/__benchmarks__/fixtures.ts +0 -241
  272. package/src/__benchmarks__/hono-adaptor.bench.ts +0 -533
  273. package/src/__benchmarks__/hono-server.bench.ts +0 -249
  274. package/src/__benchmarks__/response-builder.bench.ts +0 -428
  275. package/src/__benchmarks__/strategies/strategy-a-lazy-services.ts +0 -319
  276. package/src/__benchmarks__/strategies/strategy-c-middleware.ts +0 -530
  277. package/src/__benchmarks__/strategies/strategy-d-opt-in-events.ts +0 -567
  278. package/src/__tests__/Construct.environment.spec.ts +0 -704
  279. package/src/__tests__/publisher.setting.spec.ts +0 -508
  280. package/src/__tests__/publisher.spec.ts +0 -452
  281. package/src/adaptors/aws.ts +0 -6
  282. package/src/adaptors/hono.ts +0 -1
  283. package/src/adaptors/testing.ts +0 -11
  284. package/src/crons/AWSScheduledFunction.ts +0 -73
  285. package/src/crons/Cron.ts +0 -149
  286. package/src/crons/CronBuilder.ts +0 -271
  287. package/src/crons/__tests__/AWSScheduledFunction.spec.ts +0 -152
  288. package/src/crons/__tests__/Cron.spec.ts +0 -464
  289. package/src/crons/__tests__/CronBuilder.state-isolation.spec.ts +0 -227
  290. package/src/crons/index.ts +0 -12
  291. package/src/endpoints/AmazonApiGatewayEndpointAdaptor.ts +0 -677
  292. package/src/endpoints/AmazonApiGatewayV1EndpointAdaptor.ts +0 -105
  293. package/src/endpoints/AmazonApiGatewayV2EndpointAdaptor.ts +0 -97
  294. package/src/endpoints/Authorizer.ts +0 -152
  295. package/src/endpoints/Endpoint.ts +0 -1287
  296. package/src/endpoints/EndpointBuilder.ts +0 -758
  297. package/src/endpoints/EndpointFactory.ts +0 -1148
  298. package/src/endpoints/HonoEndpointAdaptor.ts +0 -677
  299. package/src/endpoints/MswEndpointAdaptor.ts +0 -226
  300. package/src/endpoints/TestEndpointAdaptor.ts +0 -422
  301. package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.audits.spec.ts +0 -499
  302. package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.events.spec.ts +0 -560
  303. package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.spec.ts +0 -1304
  304. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.audits.spec.ts +0 -626
  305. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.events.spec.ts +0 -732
  306. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.factory-publisher.spec.ts +0 -296
  307. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.kysely-audit.integration.spec.ts +0 -951
  308. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.responseType.spec.ts +0 -111
  309. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.rls.spec.ts +0 -307
  310. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.spec.ts +0 -629
  311. package/src/endpoints/__tests__/Authorizer.spec.ts +0 -286
  312. package/src/endpoints/__tests__/Endpoint.cookies.spec.ts +0 -207
  313. package/src/endpoints/__tests__/Endpoint.headers.spec.ts +0 -187
  314. package/src/endpoints/__tests__/Endpoint.manifest.spec.ts +0 -175
  315. package/src/endpoints/__tests__/Endpoint.spec.ts +0 -857
  316. package/src/endpoints/__tests__/EndpointBuilder.audit.spec.ts +0 -448
  317. package/src/endpoints/__tests__/EndpointBuilder.responseType.spec.ts +0 -47
  318. package/src/endpoints/__tests__/EndpointBuilder.spec.ts +0 -523
  319. package/src/endpoints/__tests__/EndpointFactory.authorizers.spec.ts +0 -492
  320. package/src/endpoints/__tests__/EndpointFactory.database-auditor.spec.ts +0 -509
  321. package/src/endpoints/__tests__/EndpointFactory.reference-audit.spec.ts +0 -190
  322. package/src/endpoints/__tests__/EndpointFactory.spec.ts +0 -479
  323. package/src/endpoints/__tests__/EndpointFactory.state-isolation.spec.ts +0 -155
  324. package/src/endpoints/__tests__/HonoEndpointAdaptor.audit-transactions.spec.ts +0 -703
  325. package/src/endpoints/__tests__/HonoEndpointAdaptor.audits.spec.ts +0 -632
  326. package/src/endpoints/__tests__/HonoEndpointAdaptor.events.spec.ts +0 -577
  327. package/src/endpoints/__tests__/HonoEndpointAdaptor.kysely-audit.integration.spec.ts +0 -1067
  328. package/src/endpoints/__tests__/HonoEndpointAdaptor.openapi.spec.ts +0 -317
  329. package/src/endpoints/__tests__/HonoEndpointAdaptor.pgboss-publisher.spec.ts +0 -289
  330. package/src/endpoints/__tests__/HonoEndpointAdaptor.responseType.spec.ts +0 -128
  331. package/src/endpoints/__tests__/HonoEndpointAdaptor.spec.ts +0 -1207
  332. package/src/endpoints/__tests__/MswEndpointAdaptor.spec.ts +0 -211
  333. package/src/endpoints/__tests__/ResponseBuilder.spec.ts +0 -235
  334. package/src/endpoints/__tests__/TestEndpointAdaptor.audits.spec.ts +0 -602
  335. package/src/endpoints/__tests__/TestEndpointAdaptor.spec.ts +0 -1044
  336. package/src/endpoints/__tests__/__snapshots__/HonoEndpointAdaptor.spec.ts.snap +0 -54
  337. package/src/endpoints/__tests__/endpoint-types.test.ts +0 -88
  338. package/src/endpoints/__tests__/helpers.spec.ts +0 -37
  339. package/src/endpoints/__tests__/lazyAccessors.spec.ts +0 -330
  340. package/src/endpoints/__tests__/processAudits.spec.ts +0 -631
  341. package/src/endpoints/audit.ts +0 -87
  342. package/src/endpoints/helpers.ts +0 -98
  343. package/src/endpoints/index.ts +0 -42
  344. package/src/endpoints/lazyAccessors.ts +0 -241
  345. package/src/endpoints/parseHonoQuery.ts +0 -16
  346. package/src/endpoints/parseQueryParams.ts +0 -32
  347. package/src/endpoints/processAudits.ts +0 -371
  348. package/src/endpoints/rls.ts +0 -67
  349. package/src/functions/AWSLambdaFunction.ts +0 -348
  350. package/src/functions/BaseFunctionBuilder.ts +0 -201
  351. package/src/functions/Function.ts +0 -238
  352. package/src/functions/FunctionBuilder.ts +0 -391
  353. package/src/functions/FunctionExecutionWrapper.ts +0 -216
  354. package/src/functions/TestFunctionAdaptor.ts +0 -217
  355. package/src/functions/__tests__/AWSLambdaFunctionAdaptor.spec.ts +0 -513
  356. package/src/functions/__tests__/Function.audits.spec.ts +0 -393
  357. package/src/functions/__tests__/Function.spec.ts +0 -477
  358. package/src/functions/__tests__/FunctionBuilder.state-isolation.spec.ts +0 -207
  359. package/src/functions/__tests__/TestFunctionAdaptor.spec.ts +0 -480
  360. package/src/functions/index.ts +0 -12
  361. package/src/index.ts +0 -23
  362. package/src/publisher.ts +0 -93
  363. package/src/queue/AWSLambdaQueueAdaptor.ts +0 -162
  364. package/src/queue/Queue.ts +0 -128
  365. package/src/queue/QueueBuilder.ts +0 -115
  366. package/src/queue/TestQueueAdaptor.ts +0 -63
  367. package/src/queue/__tests__/QueueBuilder.spec.ts +0 -137
  368. package/src/queue/index.ts +0 -12
  369. package/src/subscribers/AWSLambdaSubscriberAdaptor.ts +0 -342
  370. package/src/subscribers/Subscriber.ts +0 -117
  371. package/src/subscribers/SubscriberBuilder.ts +0 -186
  372. package/src/subscribers/TestSubscriberAdaptor.ts +0 -133
  373. package/src/subscribers/__tests__/AWSLambdaSubscriberAdaptor.spec.ts +0 -1018
  374. package/src/subscribers/__tests__/Subscriber.spec.ts +0 -430
  375. package/src/subscribers/__tests__/TestSubscriberAdaptor.spec.ts +0 -652
  376. package/src/subscribers/index.ts +0 -6
  377. package/src/telemetry.ts +0 -103
  378. package/src/topic/Topic.ts +0 -103
  379. package/src/topic/TopicBuilder.ts +0 -51
  380. package/src/topic/__tests__/TopicBuilder.spec.ts +0 -82
  381. package/src/topic/index.ts +0 -11
  382. package/src/types.ts +0 -13
  383. package/test.ts +0 -91
  384. package/tsconfig.json +0 -9
  385. package/tsdown.config.ts +0 -34
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kysely.d.cts","names":[],"sources":["../../src/database/kysely.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;AAqGM,UA7DW,qBAAA,SAA8B,IA6DzC,CA7D8C,YA6D9C,EAAA,SAAA,CAAA,CAAA;EAAa;;;;;;;EAyGoB,MACnB,CAAA,EAAA,MAAA;EAAM;;;;;;;EAoBC,KAAE,CAAA,EAAA,OAAA;EAAO;;;;;;;AA9If;AA4OrB;;EAA4B,OACZ,CAAA,EA/PL,eA+PK;;;UA3PN,WAAA,CA0P+C;EAAI,IAAA,EAAA,iBAAA,GAAA,iBAAA;;;;;;;;;;;cA7OhD,uEACD,UAAU,OAAO,OAAO;;eAEtB;oBACK,QAAQ,aAAa,QAAQ,OAAO;;;;;;;;;;kBAajD,cAAc,kBACQ,qCACZ;aAyBJ;;;;;;;;;;;;;YAqDD,iBAAiB,OAAO;;;;;;;;;;;;;;;;;;mCAyBD,mBAC5B,cAAc;;MAEhB,MAAM;;;;;;;;;+CAgBJ,cAAc,oBACT,wBACP,eAAe,UAAU;;;;;;;;;;;;;eAoBf,WAAW,aAAa,eAAe,OAAO;;;;;;;;;;;;;;;;;;;;KA0EhD,6CAA6C,KACxD,eAAe,IAAI"}
@@ -0,0 +1,152 @@
1
+ import { Construct } from "../construct-interface-BqwRNYA2.mjs";
2
+ import { Cache } from "../cache-DYoJFcfd.mjs";
3
+ import { ConstructName, Declaration, PostgresVersion } from "@geekmidas/manifest";
4
+ import { Service } from "@geekmidas/services";
5
+ import { Kysely, KyselyConfig } from "kysely";
6
+
7
+ //#region src/database/kysely.d.ts
8
+
9
+ /**
10
+ * Everything Kysely takes, plus what this construct declares.
11
+ *
12
+ * `dialect` is omitted because the construct owns it — it is built from the one
13
+ * URL the adapter supplied, which is the whole point of the construct. The rest
14
+ * of `KyselyConfig` (`plugins`, `log`) is the app's business and passes
15
+ * straight through, so anything Kysely adds later arrives without being
16
+ * tracked here.
17
+ */
18
+ interface KyselyDatabaseOptions extends Omit<KyselyConfig, 'dialect'> {
19
+ /**
20
+ * The schema, pinned on both roles' `search_path`.
21
+ *
22
+ * Defaults to `app` — the role the schema plays, rather than a restatement
23
+ * of the database's own name, which reads correctly beside `auth` and
24
+ * `pgboss` and keeps the application off `public`.
25
+ */
26
+ schema?: string;
27
+ /**
28
+ * Provision the owner/runtime role split. Defaults to on.
29
+ *
30
+ * Off falls back to the cluster's master credential in both URLs, giving up
31
+ * the DDL/DML split and putting credentials that can drop a table into the
32
+ * function's environment. A deliberate downgrade, not a default.
33
+ */
34
+ roles?: boolean;
35
+ /**
36
+ * The Postgres major version to provision.
37
+ *
38
+ * Declared here so one statement reaches both targets. It was previously
39
+ * set in two unrelated places — a container tag locally, nothing at all on
40
+ * AWS (so Aurora chose) — which is how local came to run 18 while deployed
41
+ * ran 17.7 with nothing recording the difference.
42
+ *
43
+ * Defaults to {@link DEFAULT_POSTGRES_VERSION}.
44
+ */
45
+ version?: PostgresVersion;
46
+ }
47
+ /** What makes a construct derived rather than a database in its own right. */
48
+ interface DerivedFrom {
49
+ kind: 'database-reader' | 'database-schema';
50
+ of: string;
51
+ schema?: string;
52
+ }
53
+ /**
54
+ * @typeParam DB - the database's schema.
55
+ * @typeParam TName - the canonical id. TypeScript has no partial
56
+ * type-argument inference, so `new KyselyDatabase<OrdersDB>('orders')` leaves
57
+ * this at its default and the service key widens to `string`. `db` still types
58
+ * through `.database()`, which infers from the service.
59
+ */
60
+ declare class KyselyDatabase<DB = unknown, TName extends string = string> implements Construct<TName, Kysely<DB>> {
61
+ private readonly options;
62
+ readonly id: TName;
63
+ readonly service: Service<Uncapitalize<TName>, Kysely<DB>>;
64
+ /**
65
+ * Declared once and read by both `declare()` and `connect()`, so the key the
66
+ * build publishes and the key the client reads cannot drift.
67
+ */
68
+ private readonly config;
69
+ private readonly schemaName;
70
+ private readonly roles;
71
+ private readonly version;
72
+ private readonly derivedFrom?;
73
+ constructor(id: ConstructName<TName>, options?: KyselyDatabaseOptions, derivedFrom?: DerivedFrom);
74
+ declare(): Declaration[];
75
+ /**
76
+ * A read-only endpoint on this database.
77
+ *
78
+ * Read-only is enforced by the reader role's grants rather than by which
79
+ * endpoint it resolves to, so falling back to the writer where no replica
80
+ * exists is safe rather than a silently writable connection behind a name
81
+ * that says reader. There is no `writer()`: the database *is* the writer, so
82
+ * a replica can never be reached by accident.
83
+ *
84
+ * The return type is narrower than this class on purpose — see
85
+ * {@link ReadOnlyDatabase}.
86
+ */
87
+ reader(): ReadOnlyDatabase<DB, `${TName}Reader`>;
88
+ /**
89
+ * A cache that lives in this database.
90
+ *
91
+ * The same strengthening `schema()` is over a second database: `new
92
+ * Cache('Sessions')` says the app caches and leaves where to the deployment,
93
+ * while this says it caches *here* — which is a fact about the application
94
+ * and so belongs in its code.
95
+ *
96
+ * What it buys beyond being explicit: the table's schema and the role that
97
+ * reaches it come from this database rather than from a second convention,
98
+ * and the backend no longer has to guess which database "the database" meant
99
+ * when an app declares two.
100
+ *
101
+ * A cache is not a `KyselyDatabase`, so this returns a `Cache` — the client
102
+ * is a key/value store, not a query builder, and typing it as the parent
103
+ * would be a convenience that lies.
104
+ */
105
+ cache<TCache extends string = `${TName}Cache`>(id?: ConstructName<TCache>, options?: {
106
+ table?: string;
107
+ }): Cache<TCache>;
108
+ /**
109
+ * A second schema in this database, with its own role(s) and its own URL —
110
+ * so this database's role holds no grant on those tables at all.
111
+ *
112
+ * Typed separately because a tenant has its own tables: the point is that
113
+ * `auth.selectFrom('sessions')` type-checks and
114
+ * `orders.selectFrom('sessions')` does not.
115
+ */
116
+ schema<TenantDB, TTenant extends string>(id: ConstructName<TTenant>, options?: KyselyDatabaseOptions): KyselyDatabase<TenantDB, TTenant>;
117
+ /**
118
+ * A connection as the *owner* role — the one that may create, alter and drop.
119
+ *
120
+ * A `Service` rather than part of the construct, and deliberately so: a
121
+ * construct is what `.dependsOn()` accepts, and nothing should be able to
122
+ * depend on this. A migrator asks for it by name; a handler cannot ask at
123
+ * all, which is the security property the role split exists for.
124
+ *
125
+ * Falls back to the runtime URL where no owner URL was published — the
126
+ * `roles: false` downgrade, where there is only one credential and it is the
127
+ * cluster master's.
128
+ */
129
+ get owner(): Service<`${Uncapitalize<TName>}Owner`, Kysely<DB>>;
130
+ private connect;
131
+ }
132
+ /**
133
+ * A database you may read through, and derive nothing from.
134
+ *
135
+ * A reader is terminal in the graph, and this is that fact in the type system.
136
+ * `DERIVES_FROM` gives `cache` and `database-schema` no `database-reader`
137
+ * parent, and there is no reader of a reader — so `orders.reader().cache(…)`
138
+ * has always been illegal, but it type-checked and failed later at
139
+ * `assertDerivations`. That is a long way round to learn that a read-only
140
+ * endpoint cannot own a table something writes to.
141
+ *
142
+ * Omitting the three deriving methods rather than making them throw keeps the
143
+ * failure where it costs least: the editor, on the line that wrote it.
144
+ *
145
+ * The result is deliberately not assignable back to `KyselyDatabase` — a
146
+ * reader is not one, and anything that genuinely needs the writer should say
147
+ * so.
148
+ */
149
+ type ReadOnlyDatabase<DB, TName extends string> = Omit<KyselyDatabase<DB, TName>, 'reader' | 'cache' | 'schema'>;
150
+ //#endregion
151
+ export { KyselyDatabase, KyselyDatabaseOptions, ReadOnlyDatabase };
152
+ //# sourceMappingURL=kysely.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kysely.d.mts","names":[],"sources":["../../src/database/kysely.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;AAqGM,UA7DW,qBAAA,SAA8B,IA6DzC,CA7D8C,YA6D9C,EAAA,SAAA,CAAA,CAAA;EAAa;;;;;;;EAyGoB,MACnB,CAAA,EAAA,MAAA;EAAM;;;;;;;EAoBC,KAAE,CAAA,EAAA,OAAA;EAAO;;;;;;;AA9If;AA4OrB;;EAA4B,OACZ,CAAA,EA/PL,eA+PK;;;UA3PN,WAAA,CA0P+C;EAAI,IAAA,EAAA,iBAAA,GAAA,iBAAA;;;;;;;;;;;cA7OhD,uEACD,UAAU,OAAO,OAAO;;eAEtB;oBACK,QAAQ,aAAa,QAAQ,OAAO;;;;;;;;;;kBAajD,cAAc,kBACQ,qCACZ;aAyBJ;;;;;;;;;;;;;YAqDD,iBAAiB,OAAO;;;;;;;;;;;;;;;;;;mCAyBD,mBAC5B,cAAc;;MAEhB,MAAM;;;;;;;;;+CAgBJ,cAAc,oBACT,wBACP,eAAe,UAAU;;;;;;;;;;;;;eAoBf,WAAW,aAAa,eAAe,OAAO;;;;;;;;;;;;;;;;;;;;KA0EhD,6CAA6C,KACxD,eAAe,IAAI"}
@@ -0,0 +1,180 @@
1
+ import { Cache } from "../cache-0ANvRQnD.mjs";
2
+ import { DEFAULT_POSTGRES_VERSION, canonicalId, provideKey, serviceKey } from "@geekmidas/manifest";
3
+ import { Kysely, PostgresDialect } from "kysely";
4
+ import pg from "pg";
5
+
6
+ //#region src/database/kysely.ts
7
+ /** The schema a database uses when it does not say otherwise. */
8
+ const DEFAULT_SCHEMA = "app";
9
+ /**
10
+ * @typeParam DB - the database's schema.
11
+ * @typeParam TName - the canonical id. TypeScript has no partial
12
+ * type-argument inference, so `new KyselyDatabase<OrdersDB>('orders')` leaves
13
+ * this at its default and the service key widens to `string`. `db` still types
14
+ * through `.database()`, which infers from the service.
15
+ */
16
+ var KyselyDatabase = class KyselyDatabase {
17
+ id;
18
+ service;
19
+ /**
20
+ * Declared once and read by both `declare()` and `connect()`, so the key the
21
+ * build publishes and the key the client reads cannot drift.
22
+ */
23
+ config;
24
+ schemaName;
25
+ roles;
26
+ version;
27
+ derivedFrom;
28
+ constructor(id, options = {}, derivedFrom) {
29
+ this.options = options;
30
+ const canonical = canonicalId(id);
31
+ this.id = canonical;
32
+ this.config = {
33
+ url: provideKey(canonical, "url"),
34
+ ownerUrl: provideKey(canonical, "ownerUrl")
35
+ };
36
+ this.schemaName = options.schema ?? DEFAULT_SCHEMA;
37
+ this.roles = options.roles ?? true;
38
+ this.version = options.version ?? DEFAULT_POSTGRES_VERSION;
39
+ this.derivedFrom = derivedFrom;
40
+ this.service = {
41
+ serviceName: serviceKey(canonical),
42
+ register: (registerOptions) => this.connect(registerOptions)
43
+ };
44
+ }
45
+ declare() {
46
+ if (this.derivedFrom) {
47
+ const { kind, of, schema } = this.derivedFrom;
48
+ return [kind === "database-schema" ? {
49
+ kind,
50
+ id: this.id,
51
+ of,
52
+ schema: schema ?? this.schemaName,
53
+ provides: [this.config.url]
54
+ } : {
55
+ kind,
56
+ id: this.id,
57
+ of,
58
+ provides: [this.config.url]
59
+ }];
60
+ }
61
+ return [{
62
+ kind: "database",
63
+ id: this.id,
64
+ engine: "postgres",
65
+ schema: this.schemaName,
66
+ version: this.version,
67
+ provides: [this.config.url],
68
+ ...this.roles ? {} : { roles: false }
69
+ }];
70
+ }
71
+ /**
72
+ * A read-only endpoint on this database.
73
+ *
74
+ * Read-only is enforced by the reader role's grants rather than by which
75
+ * endpoint it resolves to, so falling back to the writer where no replica
76
+ * exists is safe rather than a silently writable connection behind a name
77
+ * that says reader. There is no `writer()`: the database *is* the writer, so
78
+ * a replica can never be reached by accident.
79
+ *
80
+ * The return type is narrower than this class on purpose — see
81
+ * {@link ReadOnlyDatabase}.
82
+ */
83
+ reader() {
84
+ return new KyselyDatabase(`${this.id}Reader`, this.options, {
85
+ kind: "database-reader",
86
+ of: this.id
87
+ });
88
+ }
89
+ /**
90
+ * A cache that lives in this database.
91
+ *
92
+ * The same strengthening `schema()` is over a second database: `new
93
+ * Cache('Sessions')` says the app caches and leaves where to the deployment,
94
+ * while this says it caches *here* — which is a fact about the application
95
+ * and so belongs in its code.
96
+ *
97
+ * What it buys beyond being explicit: the table's schema and the role that
98
+ * reaches it come from this database rather than from a second convention,
99
+ * and the backend no longer has to guess which database "the database" meant
100
+ * when an app declares two.
101
+ *
102
+ * A cache is not a `KyselyDatabase`, so this returns a `Cache` — the client
103
+ * is a key/value store, not a query builder, and typing it as the parent
104
+ * would be a convenience that lies.
105
+ */
106
+ cache(id = `${this.id}Cache`, options = {}) {
107
+ return new Cache(id, {
108
+ of: this.id,
109
+ ...options.table ? { table: options.table } : {}
110
+ });
111
+ }
112
+ /**
113
+ * A second schema in this database, with its own role(s) and its own URL —
114
+ * so this database's role holds no grant on those tables at all.
115
+ *
116
+ * Typed separately because a tenant has its own tables: the point is that
117
+ * `auth.selectFrom('sessions')` type-checks and
118
+ * `orders.selectFrom('sessions')` does not.
119
+ */
120
+ schema(id, options = {}) {
121
+ return new KyselyDatabase(id, options, {
122
+ kind: "database-schema",
123
+ of: this.id,
124
+ schema: options.schema ?? id.toLowerCase()
125
+ });
126
+ }
127
+ /**
128
+ * A connection as the *owner* role — the one that may create, alter and drop.
129
+ *
130
+ * A `Service` rather than part of the construct, and deliberately so: a
131
+ * construct is what `.dependsOn()` accepts, and nothing should be able to
132
+ * depend on this. A migrator asks for it by name; a handler cannot ask at
133
+ * all, which is the security property the role split exists for.
134
+ *
135
+ * Falls back to the runtime URL where no owner URL was published — the
136
+ * `roles: false` downgrade, where there is only one credential and it is the
137
+ * cluster master's.
138
+ */
139
+ get owner() {
140
+ return {
141
+ serviceName: `${serviceKey(this.id)}Owner`,
142
+ register: (options) => this.connect(options, { owner: true })
143
+ };
144
+ }
145
+ async connect(options, as = {}) {
146
+ const { url, ownerUrl } = options.envParser.create((get) => ({
147
+ url: get(this.config.url).string(),
148
+ ownerUrl: get(this.config.ownerUrl).string().optional()
149
+ })).parse();
150
+ const { schema: _schema, roles: _roles,...kysely } = this.options;
151
+ return new Kysely({
152
+ ...kysely,
153
+ dialect: new PostgresDialect({ pool: pool(as.owner ? ownerUrl ?? url : url) })
154
+ });
155
+ }
156
+ };
157
+ /**
158
+ * A pool for one URL, with its schema actually on the search path.
159
+ *
160
+ * `?search_path=` is not a libpq parameter — a URL carrying it connects
161
+ * happily and then resolves every unqualified name against `public`, which is
162
+ * how a schema tenant silently writes its tables into the database it was
163
+ * separated from. Postgres takes it as a startup option instead, so the URL
164
+ * keeps the readable form the target derives and this turns it into the thing
165
+ * the server understands.
166
+ */
167
+ function pool(url) {
168
+ const parsed = new URL(url);
169
+ const searchPath = parsed.searchParams.get("search_path");
170
+ if (!searchPath) return new pg.Pool({ connectionString: url });
171
+ parsed.searchParams.delete("search_path");
172
+ return new pg.Pool({
173
+ connectionString: parsed.toString(),
174
+ options: `-c search_path=${searchPath}`
175
+ });
176
+ }
177
+
178
+ //#endregion
179
+ export { KyselyDatabase };
180
+ //# sourceMappingURL=kysely.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kysely.mjs","names":["id: ConstructName<TName>","options: KyselyDatabaseOptions","derivedFrom?: DerivedFrom","id: ConstructName<TCache>","options: { table?: string }","id: ConstructName<TTenant>","options: ServiceRegisterOptions","as: { owner?: boolean }","url: string"],"sources":["../../src/database/kysely.ts"],"sourcesContent":["/**\n * `KyselyDatabase` — a declared Postgres database, typed by its schema.\n *\n * It declares a logical database, a schema, and the roles that reach it, and\n * hands back a Kysely client built from the one URL the adapter supplied. It\n * names no cloud: `--target=aws` fills that URL from RDS, local dev from the\n * Postgres container.\n *\n * Transactions and RLS context are the execution wrapper's job — it opens the\n * transaction and puts it in `ctx.db`. This construct does not resolve\n * connections per request.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\tDEFAULT_POSTGRES_VERSION,\n\ttype Declaration,\n\ttype PostgresVersion,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport { Kysely, type KyselyConfig, PostgresDialect } from 'kysely';\nimport pg from 'pg';\nimport { Cache } from '../cache';\nimport type { Construct } from '../construct-interface';\n\n/** The schema a database uses when it does not say otherwise. */\nconst DEFAULT_SCHEMA = 'app';\n\n/**\n * Everything Kysely takes, plus what this construct declares.\n *\n * `dialect` is omitted because the construct owns it — it is built from the one\n * URL the adapter supplied, which is the whole point of the construct. The rest\n * of `KyselyConfig` (`plugins`, `log`) is the app's business and passes\n * straight through, so anything Kysely adds later arrives without being\n * tracked here.\n */\nexport interface KyselyDatabaseOptions extends Omit<KyselyConfig, 'dialect'> {\n\t/**\n\t * The schema, pinned on both roles' `search_path`.\n\t *\n\t * Defaults to `app` — the role the schema plays, rather than a restatement\n\t * of the database's own name, which reads correctly beside `auth` and\n\t * `pgboss` and keeps the application off `public`.\n\t */\n\tschema?: string;\n\t/**\n\t * Provision the owner/runtime role split. Defaults to on.\n\t *\n\t * Off falls back to the cluster's master credential in both URLs, giving up\n\t * the DDL/DML split and putting credentials that can drop a table into the\n\t * function's environment. A deliberate downgrade, not a default.\n\t */\n\troles?: boolean;\n\t/**\n\t * The Postgres major version to provision.\n\t *\n\t * Declared here so one statement reaches both targets. It was previously\n\t * set in two unrelated places — a container tag locally, nothing at all on\n\t * AWS (so Aurora chose) — which is how local came to run 18 while deployed\n\t * ran 17.7 with nothing recording the difference.\n\t *\n\t * Defaults to {@link DEFAULT_POSTGRES_VERSION}.\n\t */\n\tversion?: PostgresVersion;\n}\n\n/** What makes a construct derived rather than a database in its own right. */\ninterface DerivedFrom {\n\tkind: 'database-reader' | 'database-schema';\n\tof: string;\n\tschema?: string;\n}\n\n/**\n * @typeParam DB - the database's schema.\n * @typeParam TName - the canonical id. TypeScript has no partial\n * type-argument inference, so `new KyselyDatabase<OrdersDB>('orders')` leaves\n * this at its default and the service key widens to `string`. `db` still types\n * through `.database()`, which infers from the service.\n */\nexport class KyselyDatabase<DB = unknown, TName extends string = string>\n\timplements Construct<TName, Kysely<DB>>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, Kysely<DB>>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * build publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly config: { url: string; ownerUrl: string };\n\tprivate readonly schemaName: string;\n\tprivate readonly roles: boolean;\n\tprivate readonly version: PostgresVersion;\n\tprivate readonly derivedFrom?: DerivedFrom;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: KyselyDatabaseOptions = {},\n\t\tderivedFrom?: DerivedFrom,\n\t) {\n\t\t// Canonicalises, so `orders` and `Orders` are one construct rather than\n\t\t// two that collide. Throws on anything that cannot become a valid id.\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.config = {\n\t\t\turl: provideKey(canonical, 'url'),\n\t\t\townerUrl: provideKey(canonical, 'ownerUrl'),\n\t\t};\n\t\tthis.schemaName = options.schema ?? DEFAULT_SCHEMA;\n\t\tthis.roles = options.roles ?? true;\n\t\tthis.version = options.version ?? DEFAULT_POSTGRES_VERSION;\n\t\tthis.derivedFrom = derivedFrom;\n\n\t\t// A field, not a getter: service discovery caches by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\t// Forwards the whole options object — cherry-picking `envParser` strips\n\t\t\t// `context` and with it the request-scoped logger.\n\t\t\tregister: (registerOptions) => this.connect(registerOptions),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\tif (this.derivedFrom) {\n\t\t\tconst { kind, of, schema } = this.derivedFrom;\n\n\t\t\treturn [\n\t\t\t\tkind === 'database-schema'\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tid: this.id,\n\t\t\t\t\t\t\tof,\n\t\t\t\t\t\t\tschema: schema ?? this.schemaName,\n\t\t\t\t\t\t\t// The runtime key alone — see the note below on the parent.\n\t\t\t\t\t\t\tprovides: [this.config.url],\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tid: this.id,\n\t\t\t\t\t\t\tof,\n\t\t\t\t\t\t\t// A reader has no owner URL of its own — nothing migrates\n\t\t\t\t\t\t\t// through a read-only endpoint — so this is the one key.\n\t\t\t\t\t\t\tprovides: [this.config.url],\n\t\t\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'database',\n\t\t\t\tid: this.id,\n\t\t\t\tengine: 'postgres',\n\t\t\t\tschema: this.schemaName,\n\t\t\t\tversion: this.version,\n\t\t\t\t// One key, the runtime role's. `config` also holds the owner key and\n\t\t\t\t// it is deliberately absent here: a key in `provides` is a key an\n\t\t\t\t// edge can name, and nothing should be able to depend on DDL rights.\n\t\t\t\tprovides: [this.config.url],\n\t\t\t\t...(this.roles ? {} : { roles: false }),\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * A read-only endpoint on this database.\n\t *\n\t * Read-only is enforced by the reader role's grants rather than by which\n\t * endpoint it resolves to, so falling back to the writer where no replica\n\t * exists is safe rather than a silently writable connection behind a name\n\t * that says reader. There is no `writer()`: the database *is* the writer, so\n\t * a replica can never be reached by accident.\n\t *\n\t * The return type is narrower than this class on purpose — see\n\t * {@link ReadOnlyDatabase}.\n\t */\n\treader(): ReadOnlyDatabase<DB, `${TName}Reader`> {\n\t\treturn new KyselyDatabase<DB, `${TName}Reader`>(\n\t\t\t`${this.id}Reader` as ConstructName<`${TName}Reader`>,\n\t\t\tthis.options,\n\t\t\t{ kind: 'database-reader', of: this.id },\n\t\t);\n\t}\n\n\t/**\n\t * A cache that lives in this database.\n\t *\n\t * The same strengthening `schema()` is over a second database: `new\n\t * Cache('Sessions')` says the app caches and leaves where to the deployment,\n\t * while this says it caches *here* — which is a fact about the application\n\t * and so belongs in its code.\n\t *\n\t * What it buys beyond being explicit: the table's schema and the role that\n\t * reaches it come from this database rather than from a second convention,\n\t * and the backend no longer has to guess which database \"the database\" meant\n\t * when an app declares two.\n\t *\n\t * A cache is not a `KyselyDatabase`, so this returns a `Cache` — the client\n\t * is a key/value store, not a query builder, and typing it as the parent\n\t * would be a convenience that lies.\n\t */\n\tcache<TCache extends string = `${TName}Cache`>(\n\t\tid: ConstructName<TCache> = `${this.id}Cache` as ConstructName<TCache>,\n\t\toptions: { table?: string } = {},\n\t): Cache<TCache> {\n\t\treturn new Cache<TCache>(id, {\n\t\t\tof: this.id,\n\t\t\t...(options.table ? { table: options.table } : {}),\n\t\t});\n\t}\n\n\t/**\n\t * A second schema in this database, with its own role(s) and its own URL —\n\t * so this database's role holds no grant on those tables at all.\n\t *\n\t * Typed separately because a tenant has its own tables: the point is that\n\t * `auth.selectFrom('sessions')` type-checks and\n\t * `orders.selectFrom('sessions')` does not.\n\t */\n\tschema<TenantDB, TTenant extends string>(\n\t\tid: ConstructName<TTenant>,\n\t\toptions: KyselyDatabaseOptions = {},\n\t): KyselyDatabase<TenantDB, TTenant> {\n\t\treturn new KyselyDatabase<TenantDB, TTenant>(id, options, {\n\t\t\tkind: 'database-schema',\n\t\t\tof: this.id,\n\t\t\tschema: options.schema ?? (id as string).toLowerCase(),\n\t\t});\n\t}\n\n\t/**\n\t * A connection as the *owner* role — the one that may create, alter and drop.\n\t *\n\t * A `Service` rather than part of the construct, and deliberately so: a\n\t * construct is what `.dependsOn()` accepts, and nothing should be able to\n\t * depend on this. A migrator asks for it by name; a handler cannot ask at\n\t * all, which is the security property the role split exists for.\n\t *\n\t * Falls back to the runtime URL where no owner URL was published — the\n\t * `roles: false` downgrade, where there is only one credential and it is the\n\t * cluster master's.\n\t */\n\tget owner(): Service<`${Uncapitalize<TName>}Owner`, Kysely<DB>> {\n\t\treturn {\n\t\t\tserviceName:\n\t\t\t\t`${serviceKey(this.id)}Owner` as `${Uncapitalize<TName>}Owner`,\n\t\t\tregister: (options) => this.connect(options, { owner: true }),\n\t\t};\n\t}\n\n\tprivate async connect(\n\t\toptions: ServiceRegisterOptions,\n\t\tas: { owner?: boolean } = {},\n\t): Promise<Kysely<DB>> {\n\t\tconst { url, ownerUrl } = options.envParser\n\t\t\t.create((get) => ({\n\t\t\t\turl: get(this.config.url).string(),\n\t\t\t\townerUrl: get(this.config.ownerUrl).string().optional(),\n\t\t\t}))\n\t\t\t.parse();\n\n\t\t// Split what the manifest declared from what Kysely takes, so neither\n\t\t// leaks into the other: `schema` and `roles` describe infrastructure and\n\t\t// mean nothing to a client.\n\t\tconst { schema: _schema, roles: _roles, ...kysely } = this.options;\n\n\t\treturn new Kysely<DB>({\n\t\t\t...kysely,\n\t\t\tdialect: new PostgresDialect({\n\t\t\t\tpool: pool(as.owner ? (ownerUrl ?? url) : url),\n\t\t\t}),\n\t\t});\n\t}\n}\n\n/**\n * A pool for one URL, with its schema actually on the search path.\n *\n * `?search_path=` is not a libpq parameter — a URL carrying it connects\n * happily and then resolves every unqualified name against `public`, which is\n * how a schema tenant silently writes its tables into the database it was\n * separated from. Postgres takes it as a startup option instead, so the URL\n * keeps the readable form the target derives and this turns it into the thing\n * the server understands.\n */\nfunction pool(url: string): pg.Pool {\n\tconst parsed = new URL(url);\n\tconst searchPath = parsed.searchParams.get('search_path');\n\n\tif (!searchPath) return new pg.Pool({ connectionString: url });\n\n\tparsed.searchParams.delete('search_path');\n\n\treturn new pg.Pool({\n\t\tconnectionString: parsed.toString(),\n\t\toptions: `-c search_path=${searchPath}`,\n\t});\n}\n\n/**\n * A database you may read through, and derive nothing from.\n *\n * A reader is terminal in the graph, and this is that fact in the type system.\n * `DERIVES_FROM` gives `cache` and `database-schema` no `database-reader`\n * parent, and there is no reader of a reader — so `orders.reader().cache(…)`\n * has always been illegal, but it type-checked and failed later at\n * `assertDerivations`. That is a long way round to learn that a read-only\n * endpoint cannot own a table something writes to.\n *\n * Omitting the three deriving methods rather than making them throw keeps the\n * failure where it costs least: the editor, on the line that wrote it.\n *\n * The result is deliberately not assignable back to `KyselyDatabase` — a\n * reader is not one, and anything that genuinely needs the writer should say\n * so.\n */\nexport type ReadOnlyDatabase<DB, TName extends string> = Omit<\n\tKyselyDatabase<DB, TName>,\n\t'reader' | 'cache' | 'schema'\n>;\n"],"mappings":";;;;;;;AA6BA,MAAM,iBAAiB;;;;;;;;AAuDvB,IAAa,iBAAb,MAAa,eAEb;CACC,AAAS;CACT,AAAS;;;;;CAMT,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CAEjB,YACCA,IACiBC,UAAiC,CAAE,GACpDC,aACC;EAFgB;EAKjB,MAAM,YAAY,YAAY,GAAa;AAE3C,OAAK,KAAK;AACV,OAAK,SAAS;GACb,KAAK,WAAW,WAAW,MAAM;GACjC,UAAU,WAAW,WAAW,WAAW;EAC3C;AACD,OAAK,aAAa,QAAQ,UAAU;AACpC,OAAK,QAAQ,QAAQ,SAAS;AAC9B,OAAK,UAAU,QAAQ,WAAW;AAClC,OAAK,cAAc;AAGnB,OAAK,UAAU;GACd,aAAa,WAAW,UAAU;GAGlC,UAAU,CAAC,oBAAoB,KAAK,QAAQ,gBAAgB;EAC5D;CACD;CAED,UAAyB;AACxB,MAAI,KAAK,aAAa;GACrB,MAAM,EAAE,MAAM,IAAI,QAAQ,GAAG,KAAK;AAElC,UAAO,CACN,SAAS,oBACN;IACA;IACA,IAAI,KAAK;IACT;IACA,QAAQ,UAAU,KAAK;IAEvB,UAAU,CAAC,KAAK,OAAO,GAAI;GAC3B,IACA;IACA;IACA,IAAI,KAAK;IACT;IAGA,UAAU,CAAC,KAAK,OAAO,GAAI;GAC3B,CACH;EACD;AAED,SAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,QAAQ;GACR,QAAQ,KAAK;GACb,SAAS,KAAK;GAId,UAAU,CAAC,KAAK,OAAO,GAAI;GAC3B,GAAI,KAAK,QAAQ,CAAE,IAAG,EAAE,OAAO,MAAO;EACtC,CACD;CACD;;;;;;;;;;;;;CAcD,SAAiD;AAChD,SAAO,IAAI,gBACT,EAAE,KAAK,GAAG,SACX,KAAK,SACL;GAAE,MAAM;GAAmB,IAAI,KAAK;EAAI;CAEzC;;;;;;;;;;;;;;;;;;CAmBD,MACCC,MAA6B,EAAE,KAAK,GAAG,QACvCC,UAA8B,CAAE,GAChB;AAChB,SAAO,IAAI,MAAc,IAAI;GAC5B,IAAI,KAAK;GACT,GAAI,QAAQ,QAAQ,EAAE,OAAO,QAAQ,MAAO,IAAG,CAAE;EACjD;CACD;;;;;;;;;CAUD,OACCC,IACAJ,UAAiC,CAAE,GACC;AACpC,SAAO,IAAI,eAAkC,IAAI,SAAS;GACzD,MAAM;GACN,IAAI,KAAK;GACT,QAAQ,QAAQ,UAAU,AAAC,GAAc,aAAa;EACtD;CACD;;;;;;;;;;;;;CAcD,IAAI,QAA4D;AAC/D,SAAO;GACN,cACE,EAAE,WAAW,KAAK,GAAG,CAAC;GACxB,UAAU,CAAC,YAAY,KAAK,QAAQ,SAAS,EAAE,OAAO,KAAM,EAAC;EAC7D;CACD;CAED,MAAc,QACbK,SACAC,KAA0B,CAAE,GACN;EACtB,MAAM,EAAE,KAAK,UAAU,GAAG,QAAQ,UAChC,OAAO,CAAC,SAAS;GACjB,KAAK,IAAI,KAAK,OAAO,IAAI,CAAC,QAAQ;GAClC,UAAU,IAAI,KAAK,OAAO,SAAS,CAAC,QAAQ,CAAC,UAAU;EACvD,GAAE,CACF,OAAO;EAKT,MAAM,EAAE,QAAQ,SAAS,OAAO,OAAQ,GAAG,QAAQ,GAAG,KAAK;AAE3D,SAAO,IAAI,OAAW;GACrB,GAAG;GACH,SAAS,IAAI,gBAAgB,EAC5B,MAAM,KAAK,GAAG,QAAS,YAAY,MAAO,IAAI,CAC9C;EACD;CACD;AACD;;;;;;;;;;;AAYD,SAAS,KAAKC,KAAsB;CACnC,MAAM,SAAS,IAAI,IAAI;CACvB,MAAM,aAAa,OAAO,aAAa,IAAI,cAAc;AAEzD,MAAK,WAAY,QAAO,IAAI,GAAG,KAAK,EAAE,kBAAkB,IAAK;AAE7D,QAAO,aAAa,OAAO,cAAc;AAEzC,QAAO,IAAI,GAAG,KAAK;EAClB,kBAAkB,OAAO,UAAU;EACnC,UAAU,iBAAiB,WAAW;CACtC;AACD"}
package/dist/email.cjs ADDED
@@ -0,0 +1,59 @@
1
+ const require_chunk = require('./chunk-DWy1uDak.cjs');
2
+ const __geekmidas_manifest = require_chunk.__toESM(require("@geekmidas/manifest"));
3
+ const __geekmidas_emailkit = require_chunk.__toESM(require("@geekmidas/emailkit"));
4
+
5
+ //#region src/email.ts
6
+ var Email = class {
7
+ id;
8
+ service;
9
+ /**
10
+ * Declared once and read by both `declare()` and `connect()`, so the key the
11
+ * build publishes and the key the client reads cannot drift.
12
+ */
13
+ keys;
14
+ constructor(id, options) {
15
+ this.options = options;
16
+ const canonical = (0, __geekmidas_manifest.canonicalId)(id);
17
+ this.id = canonical;
18
+ this.keys = {
19
+ url: (0, __geekmidas_manifest.provideKey)(canonical, "url"),
20
+ from: (0, __geekmidas_manifest.provideKey)(canonical, "from")
21
+ };
22
+ this.service = {
23
+ serviceName: (0, __geekmidas_manifest.serviceKey)(canonical),
24
+ register: (options$1) => this.connect(options$1)
25
+ };
26
+ }
27
+ declare() {
28
+ return [{
29
+ kind: "email",
30
+ id: this.id,
31
+ provides: [this.keys.url, this.keys.from]
32
+ }];
33
+ }
34
+ /**
35
+ * Builds the client from the URL the adapter supplied.
36
+ *
37
+ * No provider branch and no driver lookup — `parseEmailUrl` turns any of
38
+ * Mailpit, SES, or Resend into the same transport config, which is the whole
39
+ * reason the scheme is always `smtp://`.
40
+ */
41
+ async connect({ envParser }) {
42
+ const { url, from } = envParser.create((get) => ({
43
+ url: get(this.keys.url).string(),
44
+ from: get(this.keys.from).string()
45
+ })).parse();
46
+ return (0, __geekmidas_emailkit.createEmailClient)({
47
+ smtp: (0, __geekmidas_emailkit.parseEmailUrl)(url),
48
+ templates: this.options.templates,
49
+ defaults: {
50
+ from,
51
+ ...this.options.replyTo ? { replyTo: this.options.replyTo } : {}
52
+ }
53
+ });
54
+ }
55
+ };
56
+
57
+ //#endregion
58
+ exports.Email = Email;
59
+ //# sourceMappingURL=email.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email.cjs","names":["id: ConstructName<TName>","options: EmailOptions<TTemplates>","options"],"sources":["../src/email.ts"],"sourcesContent":["/**\n * `Email` — declared outbound mail.\n *\n * The same three-package meeting point as `ObjectStorage`: it implements the\n * construct contract, derives its env key through `@geekmidas/manifest`, and\n * hands back an `@geekmidas/emailkit` client. It names no provider — locally the\n * injected URL points at Mailpit, deployed it points at SES or whichever service\n * config selected.\n *\n * Where object storage needs a driver per provider, this needs none: mail is\n * delivered over SMTP whoever delivers it, so there is one client and one URL\n * shape, and the provider survives only as a host and a credential.\n */\n\nimport {\n\tcreateEmailClient,\n\ttype EmailClient,\n\tparseEmailUrl,\n\ttype TemplateRecord,\n} from '@geekmidas/emailkit';\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport type { Construct } from './construct-interface';\n\nexport interface EmailOptions<TTemplates extends TemplateRecord> {\n\t/**\n\t * The React templates this app can send.\n\t *\n\t * Structural — they are code, they ship with the handler, and which ones\n\t * exist cannot differ between stages. They are also what types\n\t * `sendTemplate`, so passing them here is what makes the client's call sites\n\t * checkable.\n\t */\n\ttemplates: TTemplates;\n\t/**\n\t * A reply-to address for every send.\n\t *\n\t * `from` is deliberately absent: it belongs to the verified sending domain,\n\t * which is `myapp.test` locally and the real domain deployed, so it arrives\n\t * as stage config rather than being written here.\n\t */\n\treplyTo?: string;\n}\n\nexport class Email<\n\tTName extends string = string,\n\tTTemplates extends TemplateRecord = TemplateRecord,\n> implements Construct<TName, EmailClient<TTemplates>>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, EmailClient<TTemplates>>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * build publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly keys: { url: string; from: string };\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: EmailOptions<TTemplates>,\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.keys = {\n\t\t\turl: provideKey(canonical, 'url'),\n\t\t\t// The sending identity travels with the URL rather than being a second\n\t\t\t// construct option, for the same reason the URL does: it is the one\n\t\t\t// thing about mail that differs per stage.\n\t\t\tfrom: provideKey(canonical, 'from'),\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: (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: 'email',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.keys.url, this.keys.from],\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * Builds the client from the URL the adapter supplied.\n\t *\n\t * No provider branch and no driver lookup — `parseEmailUrl` turns any of\n\t * Mailpit, SES, or Resend into the same transport config, which is the whole\n\t * reason the scheme is always `smtp://`.\n\t */\n\tprivate async connect({\n\t\tenvParser,\n\t}: ServiceRegisterOptions): Promise<EmailClient<TTemplates>> {\n\t\tconst { url, from } = envParser\n\t\t\t.create((get) => ({\n\t\t\t\turl: get(this.keys.url).string(),\n\t\t\t\tfrom: get(this.keys.from).string(),\n\t\t\t}))\n\t\t\t.parse();\n\n\t\treturn createEmailClient({\n\t\t\tsmtp: parseEmailUrl(url),\n\t\t\ttemplates: this.options.templates,\n\t\t\tdefaults: {\n\t\t\t\tfrom,\n\t\t\t\t...(this.options.replyTo ? { replyTo: this.options.replyTo } : {}),\n\t\t\t},\n\t\t});\n\t}\n}\n"],"mappings":";;;;;AAkDA,IAAa,QAAb,MAIA;CACC,AAAS;CACT,AAAS;;;;;CAMT,AAAiB;CAEjB,YACCA,IACiBC,SAChB;EADgB;EAEjB,MAAM,YAAY,sCAAY,GAAa;AAE3C,OAAK,KAAK;AACV,OAAK,OAAO;GACX,KAAK,qCAAW,WAAW,MAAM;GAIjC,MAAM,qCAAW,WAAW,OAAO;EACnC;AAGD,OAAK,UAAU;GACd,aAAa,qCAAW,UAAU;GAClC,UAAU,CAACC,cAAY,KAAK,QAAQA,UAAQ;EAC5C;CACD;CAED,UAAyB;AACxB,SAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,UAAU,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,IAAK;EACzC,CACD;CACD;;;;;;;;CASD,MAAc,QAAQ,EACrB,WACwB,EAAoC;EAC5D,MAAM,EAAE,KAAK,MAAM,GAAG,UACpB,OAAO,CAAC,SAAS;GACjB,KAAK,IAAI,KAAK,KAAK,IAAI,CAAC,QAAQ;GAChC,MAAM,IAAI,KAAK,KAAK,KAAK,CAAC,QAAQ;EAClC,GAAE,CACF,OAAO;AAET,SAAO,4CAAkB;GACxB,MAAM,wCAAc,IAAI;GACxB,WAAW,KAAK,QAAQ;GACxB,UAAU;IACT;IACA,GAAI,KAAK,QAAQ,UAAU,EAAE,SAAS,KAAK,QAAQ,QAAS,IAAG,CAAE;GACjE;EACD,EAAC;CACF;AACD"}
@@ -0,0 +1,50 @@
1
+ import { Construct } from "./construct-interface-D2nNkHUN.cjs";
2
+ import { Service } from "@geekmidas/services";
3
+ import { ConstructName, Declaration } from "@geekmidas/manifest";
4
+ import { EmailClient, TemplateRecord } from "@geekmidas/emailkit";
5
+
6
+ //#region src/email.d.ts
7
+
8
+ interface EmailOptions<TTemplates extends TemplateRecord> {
9
+ /**
10
+ * The React templates this app can send.
11
+ *
12
+ * Structural — they are code, they ship with the handler, and which ones
13
+ * exist cannot differ between stages. They are also what types
14
+ * `sendTemplate`, so passing them here is what makes the client's call sites
15
+ * checkable.
16
+ */
17
+ templates: TTemplates;
18
+ /**
19
+ * A reply-to address for every send.
20
+ *
21
+ * `from` is deliberately absent: it belongs to the verified sending domain,
22
+ * which is `myapp.test` locally and the real domain deployed, so it arrives
23
+ * as stage config rather than being written here.
24
+ */
25
+ replyTo?: string;
26
+ }
27
+ declare class Email<TName extends string = string, TTemplates extends TemplateRecord = TemplateRecord> implements Construct<TName, EmailClient<TTemplates>> {
28
+ private readonly options;
29
+ readonly id: TName;
30
+ readonly service: Service<Uncapitalize<TName>, EmailClient<TTemplates>>;
31
+ /**
32
+ * Declared once and read by both `declare()` and `connect()`, so the key the
33
+ * build publishes and the key the client reads cannot drift.
34
+ */
35
+ private readonly keys;
36
+ constructor(id: ConstructName<TName>, options: EmailOptions<TTemplates>);
37
+ declare(): Declaration[];
38
+ /**
39
+ * Builds the client from the URL the adapter supplied.
40
+ *
41
+ * No provider branch and no driver lookup — `parseEmailUrl` turns any of
42
+ * Mailpit, SES, or Resend into the same transport config, which is the whole
43
+ * reason the scheme is always `smtp://`.
44
+ */
45
+ private connect;
46
+ }
47
+ //# sourceMappingURL=email.d.ts.map
48
+ //#endregion
49
+ export { Email, EmailOptions };
50
+ //# sourceMappingURL=email.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email.d.cts","names":[],"sources":["../src/email.ts"],"sourcesContent":[],"mappings":";;;;;;;AAqD8B,UAvBb,YAuBa,CAAA,mBAvBmB,cAuBnB,CAAA,CAAA;EAAW;;;;;;;;EAYtB,SACsB,EA3B7B,UA2B6B;EAAU;;;AAb7B;;;;;;cAHT,wDAEO,iBAAiB,2BACxB,UAAU,OAAO,YAAY;;eAE5B;oBACK,QAAQ,aAAa,QAAQ,YAAY;;;;;;kBAStD,cAAc,iBACQ,aAAa;aAoB7B"}
@@ -0,0 +1,50 @@
1
+ import { Construct } from "./construct-interface-BqwRNYA2.mjs";
2
+ import { ConstructName, Declaration } from "@geekmidas/manifest";
3
+ import { EmailClient, TemplateRecord } from "@geekmidas/emailkit";
4
+ import { Service } from "@geekmidas/services";
5
+
6
+ //#region src/email.d.ts
7
+
8
+ interface EmailOptions<TTemplates extends TemplateRecord> {
9
+ /**
10
+ * The React templates this app can send.
11
+ *
12
+ * Structural — they are code, they ship with the handler, and which ones
13
+ * exist cannot differ between stages. They are also what types
14
+ * `sendTemplate`, so passing them here is what makes the client's call sites
15
+ * checkable.
16
+ */
17
+ templates: TTemplates;
18
+ /**
19
+ * A reply-to address for every send.
20
+ *
21
+ * `from` is deliberately absent: it belongs to the verified sending domain,
22
+ * which is `myapp.test` locally and the real domain deployed, so it arrives
23
+ * as stage config rather than being written here.
24
+ */
25
+ replyTo?: string;
26
+ }
27
+ declare class Email<TName extends string = string, TTemplates extends TemplateRecord = TemplateRecord> implements Construct<TName, EmailClient<TTemplates>> {
28
+ private readonly options;
29
+ readonly id: TName;
30
+ readonly service: Service<Uncapitalize<TName>, EmailClient<TTemplates>>;
31
+ /**
32
+ * Declared once and read by both `declare()` and `connect()`, so the key the
33
+ * build publishes and the key the client reads cannot drift.
34
+ */
35
+ private readonly keys;
36
+ constructor(id: ConstructName<TName>, options: EmailOptions<TTemplates>);
37
+ declare(): Declaration[];
38
+ /**
39
+ * Builds the client from the URL the adapter supplied.
40
+ *
41
+ * No provider branch and no driver lookup — `parseEmailUrl` turns any of
42
+ * Mailpit, SES, or Resend into the same transport config, which is the whole
43
+ * reason the scheme is always `smtp://`.
44
+ */
45
+ private connect;
46
+ }
47
+ //# sourceMappingURL=email.d.ts.map
48
+ //#endregion
49
+ export { Email, EmailOptions };
50
+ //# sourceMappingURL=email.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email.d.mts","names":[],"sources":["../src/email.ts"],"sourcesContent":[],"mappings":";;;;;;;AAqD8B,UAvBb,YAuBa,CAAA,mBAvBmB,cAuBnB,CAAA,CAAA;EAAW;;;;;;;;EAYtB,SACsB,EA3B7B,UA2B6B;EAAU;;;AAb7B;;;;;;cAHT,wDAEO,iBAAiB,2BACxB,UAAU,OAAO,YAAY;;eAE5B;oBACK,QAAQ,aAAa,QAAQ,YAAY;;;;;;kBAStD,cAAc,iBACQ,aAAa;aAoB7B"}
package/dist/email.mjs ADDED
@@ -0,0 +1,58 @@
1
+ import { canonicalId, provideKey, serviceKey } from "@geekmidas/manifest";
2
+ import { createEmailClient, parseEmailUrl } from "@geekmidas/emailkit";
3
+
4
+ //#region src/email.ts
5
+ var Email = class {
6
+ id;
7
+ service;
8
+ /**
9
+ * Declared once and read by both `declare()` and `connect()`, so the key the
10
+ * build publishes and the key the client reads cannot drift.
11
+ */
12
+ keys;
13
+ constructor(id, options) {
14
+ this.options = options;
15
+ const canonical = canonicalId(id);
16
+ this.id = canonical;
17
+ this.keys = {
18
+ url: provideKey(canonical, "url"),
19
+ from: provideKey(canonical, "from")
20
+ };
21
+ this.service = {
22
+ serviceName: serviceKey(canonical),
23
+ register: (options$1) => this.connect(options$1)
24
+ };
25
+ }
26
+ declare() {
27
+ return [{
28
+ kind: "email",
29
+ id: this.id,
30
+ provides: [this.keys.url, this.keys.from]
31
+ }];
32
+ }
33
+ /**
34
+ * Builds the client from the URL the adapter supplied.
35
+ *
36
+ * No provider branch and no driver lookup — `parseEmailUrl` turns any of
37
+ * Mailpit, SES, or Resend into the same transport config, which is the whole
38
+ * reason the scheme is always `smtp://`.
39
+ */
40
+ async connect({ envParser }) {
41
+ const { url, from } = envParser.create((get) => ({
42
+ url: get(this.keys.url).string(),
43
+ from: get(this.keys.from).string()
44
+ })).parse();
45
+ return createEmailClient({
46
+ smtp: parseEmailUrl(url),
47
+ templates: this.options.templates,
48
+ defaults: {
49
+ from,
50
+ ...this.options.replyTo ? { replyTo: this.options.replyTo } : {}
51
+ }
52
+ });
53
+ }
54
+ };
55
+
56
+ //#endregion
57
+ export { Email };
58
+ //# sourceMappingURL=email.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email.mjs","names":["id: ConstructName<TName>","options: EmailOptions<TTemplates>","options"],"sources":["../src/email.ts"],"sourcesContent":["/**\n * `Email` — declared outbound mail.\n *\n * The same three-package meeting point as `ObjectStorage`: it implements the\n * construct contract, derives its env key through `@geekmidas/manifest`, and\n * hands back an `@geekmidas/emailkit` client. It names no provider — locally the\n * injected URL points at Mailpit, deployed it points at SES or whichever service\n * config selected.\n *\n * Where object storage needs a driver per provider, this needs none: mail is\n * delivered over SMTP whoever delivers it, so there is one client and one URL\n * shape, and the provider survives only as a host and a credential.\n */\n\nimport {\n\tcreateEmailClient,\n\ttype EmailClient,\n\tparseEmailUrl,\n\ttype TemplateRecord,\n} from '@geekmidas/emailkit';\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport type { Construct } from './construct-interface';\n\nexport interface EmailOptions<TTemplates extends TemplateRecord> {\n\t/**\n\t * The React templates this app can send.\n\t *\n\t * Structural — they are code, they ship with the handler, and which ones\n\t * exist cannot differ between stages. They are also what types\n\t * `sendTemplate`, so passing them here is what makes the client's call sites\n\t * checkable.\n\t */\n\ttemplates: TTemplates;\n\t/**\n\t * A reply-to address for every send.\n\t *\n\t * `from` is deliberately absent: it belongs to the verified sending domain,\n\t * which is `myapp.test` locally and the real domain deployed, so it arrives\n\t * as stage config rather than being written here.\n\t */\n\treplyTo?: string;\n}\n\nexport class Email<\n\tTName extends string = string,\n\tTTemplates extends TemplateRecord = TemplateRecord,\n> implements Construct<TName, EmailClient<TTemplates>>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, EmailClient<TTemplates>>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * build publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly keys: { url: string; from: string };\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: EmailOptions<TTemplates>,\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.keys = {\n\t\t\turl: provideKey(canonical, 'url'),\n\t\t\t// The sending identity travels with the URL rather than being a second\n\t\t\t// construct option, for the same reason the URL does: it is the one\n\t\t\t// thing about mail that differs per stage.\n\t\t\tfrom: provideKey(canonical, 'from'),\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: (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: 'email',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.keys.url, this.keys.from],\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * Builds the client from the URL the adapter supplied.\n\t *\n\t * No provider branch and no driver lookup — `parseEmailUrl` turns any of\n\t * Mailpit, SES, or Resend into the same transport config, which is the whole\n\t * reason the scheme is always `smtp://`.\n\t */\n\tprivate async connect({\n\t\tenvParser,\n\t}: ServiceRegisterOptions): Promise<EmailClient<TTemplates>> {\n\t\tconst { url, from } = envParser\n\t\t\t.create((get) => ({\n\t\t\t\turl: get(this.keys.url).string(),\n\t\t\t\tfrom: get(this.keys.from).string(),\n\t\t\t}))\n\t\t\t.parse();\n\n\t\treturn createEmailClient({\n\t\t\tsmtp: parseEmailUrl(url),\n\t\t\ttemplates: this.options.templates,\n\t\t\tdefaults: {\n\t\t\t\tfrom,\n\t\t\t\t...(this.options.replyTo ? { replyTo: this.options.replyTo } : {}),\n\t\t\t},\n\t\t});\n\t}\n}\n"],"mappings":";;;;AAkDA,IAAa,QAAb,MAIA;CACC,AAAS;CACT,AAAS;;;;;CAMT,AAAiB;CAEjB,YACCA,IACiBC,SAChB;EADgB;EAEjB,MAAM,YAAY,YAAY,GAAa;AAE3C,OAAK,KAAK;AACV,OAAK,OAAO;GACX,KAAK,WAAW,WAAW,MAAM;GAIjC,MAAM,WAAW,WAAW,OAAO;EACnC;AAGD,OAAK,UAAU;GACd,aAAa,WAAW,UAAU;GAClC,UAAU,CAACC,cAAY,KAAK,QAAQA,UAAQ;EAC5C;CACD;CAED,UAAyB;AACxB,SAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,UAAU,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,IAAK;EACzC,CACD;CACD;;;;;;;;CASD,MAAc,QAAQ,EACrB,WACwB,EAAoC;EAC5D,MAAM,EAAE,KAAK,MAAM,GAAG,UACpB,OAAO,CAAC,SAAS;GACjB,KAAK,IAAI,KAAK,KAAK,IAAI,CAAC,QAAQ;GAChC,MAAM,IAAI,KAAK,KAAK,KAAK,CAAC,QAAQ;EAClC,GAAE,CACF,OAAO;AAET,SAAO,kBAAkB;GACxB,MAAM,cAAc,IAAI;GACxB,WAAW,KAAK,QAAQ;GACxB,UAAU;IACT;IACA,GAAI,KAAK,QAAQ,UAAU,EAAE,SAAS,KAAK,QAAQ,QAAS,IAAG,CAAE;GACjE;EACD,EAAC;CACF;AACD"}