@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
@@ -1,34 +1,50 @@
1
- import "../Construct-DCMuYOox.mjs";
2
- import { FunctionBuilder, FunctionHandler } from "../index-DP6fqv0I.mjs";
3
- import { AWSScheduledFunction, Cron, CronExpression, RateExpression, ScheduleExpression } from "../AWSScheduledFunction-ysaCsdWx.mjs";
4
- import { Service as Service$1 } from "@geekmidas/services";
1
+ import "../Construct-B-xc0SE9.mjs";
2
+ import { FunctionBuilder, FunctionHandler } from "../index-CPeqtKgq.mjs";
3
+ import { AWSScheduledFunction, Cron, CronExpression, RateExpression, ScheduleExpression } from "../AWSScheduledFunction-CVccZO-L.mjs";
4
+ import { Consumable, ServicesOf } from "../construct-interface-BqwRNYA2.mjs";
5
+ import * as _geekmidas_services13 from "@geekmidas/services";
6
+ import { Service } from "@geekmidas/services";
5
7
  import { EventPublisher } from "@geekmidas/events";
6
- import { Logger as Logger$1 } from "@geekmidas/logger";
7
- import { ComposableStandardSchema as ComposableStandardSchema$1 } from "@geekmidas/schema";
8
+ import * as _geekmidas_logger14 from "@geekmidas/logger";
9
+ import { Logger } from "@geekmidas/logger";
10
+ import * as _geekmidas_schema12 from "@geekmidas/schema";
11
+ import { ComposableStandardSchema } from "@geekmidas/schema";
8
12
  import { StandardSchemaV1 } from "@standard-schema/spec";
9
13
 
10
14
  //#region src/crons/CronBuilder.d.ts
11
- declare class CronBuilder<TInput extends ComposableStandardSchema$1, TServices extends Service$1[], TLogger extends Logger$1 = Logger$1, OutSchema extends StandardSchemaV1 | undefined = undefined, TEventPublisher extends EventPublisher<any> | undefined = undefined, TEventPublisherServiceName extends string = string, TDatabase = undefined, TDatabaseServiceName extends string = string> extends FunctionBuilder<TInput, OutSchema, TServices, TLogger, TEventPublisher, TEventPublisherServiceName, undefined, string, TDatabase, TDatabaseServiceName> {
15
+ declare class CronBuilder<TInput extends ComposableStandardSchema, TServices extends Service[], TLogger extends Logger = Logger, OutSchema extends StandardSchemaV1 | undefined = undefined, TEventPublisher extends EventPublisher<any> | undefined = undefined, TEventPublisherServiceName extends string = string, TDatabase = undefined, TDatabaseServiceName extends string = string> extends FunctionBuilder<TInput, OutSchema, TServices, TLogger, TEventPublisher, TEventPublisherServiceName, undefined, string, TDatabase, TDatabaseServiceName> {
12
16
  private _schedule?;
13
17
  constructor();
14
18
  memorySize(memorySize: number): this;
15
19
  schedule(_expression: ScheduleExpression): CronBuilder<TInput, TServices, TLogger, OutSchema, TEventPublisher, TEventPublisherServiceName, TDatabase, TDatabaseServiceName>;
16
- input<T extends ComposableStandardSchema$1>(schema: T): CronBuilder<T, TServices, TLogger, OutSchema, TEventPublisher, TEventPublisherServiceName, TDatabase, TDatabaseServiceName>;
20
+ input<T extends ComposableStandardSchema>(schema: T): CronBuilder<T, TServices, TLogger, OutSchema, TEventPublisher, TEventPublisherServiceName, TDatabase, TDatabaseServiceName>;
17
21
  output<T extends StandardSchemaV1>(schema: T): CronBuilder<TInput, TServices, TLogger, T, TEventPublisher, TEventPublisherServiceName, TDatabase, TDatabaseServiceName>;
18
- services<T extends Service$1[]>(services: T): CronBuilder<TInput, [...TServices, ...T], TLogger, OutSchema, TEventPublisher, TEventPublisherServiceName, TDatabase, TDatabaseServiceName>;
19
- logger<T extends Logger$1>(logger: T): CronBuilder<TInput, TServices, T, OutSchema, TEventPublisher, TEventPublisherServiceName, TDatabase, TDatabaseServiceName>;
20
- publisher<T extends EventPublisher<any>, TName extends string>(publisher: Service$1<TName, T>): CronBuilder<TInput, TServices, TLogger, OutSchema, T, TName, TDatabase, TDatabaseServiceName>;
22
+ /**
23
+ * Depend on constructs — a database, a bucket, a mail sender, a queue, a
24
+ * topic.
25
+ *
26
+ * It records the edge and dissolves each construct's client into the
27
+ * handler's service record under the construct's own id, so
28
+ * `.dependsOn([uploads])` is what makes `services.uploads` exist and type.
29
+ *
30
+ * Constructs only. A `Service` does not match the shape, which is what keeps
31
+ * env sniffing confined to `.services()` and the explicit lift.
32
+ */
33
+ dependsOn<const T extends readonly Consumable[]>(constructs: T): CronBuilder<TInput, [...TServices, ...ServicesOf<T>], TLogger, OutSchema, TEventPublisher, TEventPublisherServiceName, TDatabase, TDatabaseServiceName>;
34
+ services<T extends Service[]>(services: T): CronBuilder<TInput, [...TServices, ...T], TLogger, OutSchema, TEventPublisher, TEventPublisherServiceName, TDatabase, TDatabaseServiceName>;
35
+ logger<T extends Logger>(logger: T): CronBuilder<TInput, TServices, T, OutSchema, TEventPublisher, TEventPublisherServiceName, TDatabase, TDatabaseServiceName>;
36
+ publisher<T extends EventPublisher<any>, TName extends string>(publisher: Service<TName, T>): CronBuilder<TInput, TServices, TLogger, OutSchema, T, TName, TDatabase, TDatabaseServiceName>;
21
37
  /**
22
38
  * Set the database service for this cron job.
23
39
  * The database will be available in the handler context as `db`.
24
40
  */
25
- database<T, TName extends string>(service: Service$1<TName, T>): CronBuilder<TInput, TServices, TLogger, OutSchema, TEventPublisher, TEventPublisherServiceName, T, TName>;
41
+ database<T, TName extends string>(source: Consumable<TName, T> | Service<TName, T>): CronBuilder<TInput, TServices, TLogger, OutSchema, TEventPublisher, TEventPublisherServiceName, T, TName>;
26
42
  handle(fn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>): Cron<TInput, TServices, TLogger, OutSchema, TEventPublisher, TEventPublisherServiceName, TDatabase, TDatabaseServiceName>;
27
43
  }
28
44
  //# sourceMappingURL=CronBuilder.d.ts.map
29
45
  //#endregion
30
46
  //#region src/crons/index.d.ts
31
- declare const c: CronBuilder<ComposableStandardSchema, Service[], Logger, undefined, undefined, string, undefined, string>;
47
+ declare const c: CronBuilder<_geekmidas_schema12.ComposableStandardSchema, _geekmidas_services13.Service<string, unknown>[], _geekmidas_logger14.Logger, undefined, undefined, string, undefined, string>;
32
48
  //# sourceMappingURL=index.d.ts.map
33
49
 
34
50
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/crons/CronBuilder.ts","../../src/crons/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAaa,2BACG,8CACG,6BACF,WAAS,4BACP,kEACM,8KAIf,gBACT,QACA,WACA,WACA,SACA,iBACA,+CAGA,WACA;;;EAnBY,UAAA,CAAA,UAAW,EAAA,MAAA,CAAA,EAAA,IAAA;EAAA,QAAA,CAAA,WAAA,EAiCT,kBAjCS,CAAA,EAkCpB,WAlCoB,CAmCtB,MAnCsB,EAoCtB,SApCsB,EAqCtB,OArCsB,EAsCtB,SAtCsB,EAuCtB,eAvCsB,EAwCtB,0BAxCsB,EAyCtB,SAzCsB,EA0CtB,oBA1CsB,CAAA;EAAA,KACR,CAAA,UA+CU,0BA/CV,CAAA,CAAA,MAAA,EAgDN,CAhDM,CAAA,EAiDZ,WAjDY,CAkDd,CAlDc,EAmDd,SAnDc,EAoDd,OApDc,EAqDd,SArDc,EAsDd,eAtDc,EAuDd,0BAvDc,EAwDd,SAxDc,EAyDd,oBAzDc,CAAA;EAAwB,MACrB,CAAA,UAwEQ,gBAxER,CAAA,CAAA,MAAA,EAyET,CAzES,CAAA,EA0Ef,WA1Ee,CA2EjB,MA3EiB,EA4EjB,SA5EiB,EA6EjB,OA7EiB,EA8EjB,CA9EiB,EA+EjB,eA/EiB,EAgFjB,0BAhFiB,EAiFjB,SAjFiB,EAkFjB,oBAlFiB,CAAA;EAAO,QACT,CAAA,UAiGY,SAjGZ,EAAA,CAAA,CAAA,QAAA,EAkGL,CAlGK,CAAA,EAmGb,WAnGa,CAoGf,MApGe,EAAA,CAAS,GAqGpB,SArGoB,EACP,GAoGC,CApGD,CAAgB,EAqGjC,OApGuB,EAqGvB,SArGuB,EAsGvB,eAtGuB,EAuGvB,0BAvGuB,EAwGvB,SAxGuB,EAyGvB,oBAzGuB,CAAA;EAAc,MAKtC,CAAA,UAuH0B,QAvH1B,CAAA,CAAA,MAAA,EAwHS,CAxHT,CAAA,EAyHG,WAzHH,CA0HC,MA1HD,EA2HC,SA3HD,EA4HC,CA5HD,EA6HC,SA7HD,EA8HC,eA9HD,EA+HC,0BA/HD,EAgIC,SAhID,EAiIC,oBAjID,CAAA;EAAM,SACN,CAAA,UAgJ6B,cAhJ7B,CAAA,GAAA,CAAA,EAAA,cAAA,MAAA,CAAA,CAAA,SAAA,EAiJY,SAjJZ,CAiJoB,KAjJpB,EAiJ2B,CAjJ3B,CAAA,CAAA,EAkJG,WAlJH,CAmJC,MAnJD,EAoJC,SApJD,EAqJC,OArJD,EAsJC,SAtJD,EAuJC,CAvJD,EAwJC,KAxJD,EAyJC,SAzJD,EA0JC,oBA1JD,CAAA;EAAS;;;;EAIiB,QAG1B,CAAA,CAAA,EAAA,cAAA,MAAA,CAAA,CAAA,OAAA,EA2KU,SA3KV,CA2KkB,KA3KlB,EA2KyB,CA3KzB,CAAA,CAAA,EA4KG,WA5KH,CA6KC,MA7KD,EA8KC,SA9KD,EA+KC,OA/KD,EAgLC,SAhLD,EAiLC,eAjLD,EAkLC,0BAlLD,EAmLC,CAnLD,EAoLC,KApLD,CAAA;EAAS,MACT,CAAA,EAAA,EAuMK,eAvML,CAuMqB,MAvMrB,EAuM6B,SAvM7B,EAuMwC,OAvMxC,EAuMiD,SAvMjD,EAuM4D,SAvM5D,CAAA,CAAA,EAwMG,IAxMH,CAyMC,MAzMD,EA0MC,SA1MD,EA2MC,OA3MD,EA4MC,SA5MD,EA6MC,eA7MD,EA8MC,0BA9MD,EA+MC,SA/MD,EAgNC,oBAhND,CAAA;;;;;cCrBY,GAAC,YAAA,0BAAA,WAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/crons/CronBuilder.ts","../../src/crons/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;cAkBa,2BACG,4CACG,2BACF,SAAS,0BACP,kEACM,8KAIf,gBACT,QACA,WACA,WACA,SACA,iBACA,+CAGA,WACA;;;;wBAac,qBACX,YACF,QACA,WACA,SACA,WACA,iBACA,4BACA,WACA;kBAKwB,kCAChB,IACN,YACF,GACA,WACA,SACA,WACA,iBACA,4BACA,WACA;EAxDW,MAAA,CAAA,UAwEc,gBAxEH,CAAA,CAAA,MAAA,EAyEd,CAzEc,CAAA,EA0EpB,WA1EoB,CA2EtB,MA3EsB,EA4EtB,SA5EsB,EA6EtB,OA7EsB,EA8EtB,CA9EsB,EA+EtB,eA/EsB,EAgFtB,0BAhFsB,EAiFtB,SAjFsB,EAkFtB,oBAlFsB,CAAA;EAAA;;;;;;;;;;;EAahB,SACP,CAAA,gBAAA,SA+F4C,UA/F5C,EAAA,CAAA,CAAA,UAAA,EAgGa,CAhGb,CAAA,EAiGG,WAjGH,CAkGC,MAlGD,EAAA,CACA,GAkGK,SAlGL,EAGA,GA+FmB,UA/FnB,CA+F8B,CA/F9B,CAAA,CAAS,EAgGR,OA/FD,EAgGC,SAhGD,EAiGC,eAjGD,EAkGC,0BAlGD,EAmGC,SAnGD,EAoGC,oBApGD,CAAA;EAAoB,QAaN,CAAA,UAoHc,OApHd,EAAA,CAAA,CAAA,QAAA,EAqHH,CArHG,CAAA,EAsHX,WAtHW,CAuHb,MAvHa,EAAA,CAEb,GAsHI,SAtHJ,EACA,GAqHkB,CArHlB,CAAS,EAsHT,OArHA,EAsHA,SAtHA,EAuHA,eAvHA,EAwHA,0BAxHA,EAyHA,SAzHA,EA0HA,oBA1HA,CAAA;EAAO,MACP,CAAA,UA4IyB,MA5IzB,CAAA,CAAA,MAAA,EA6IQ,CA7IR,CAAA,EA8IE,WA9IF,CA+IA,MA/IA,EAgJA,SAhJA,EAiJA,CAjJA,EAkJA,SAlJA,EAmJA,eAnJA,EAoJA,0BApJA,EAqJA,SArJA,EAsJA,oBAtJA,CAAA;EAAS,SACT,CAAA,UAqK4B,cArK5B,CAAA,GAAA,CAAA,EAAA,cAAA,MAAA,CAAA,CAAA,SAAA,EAsKW,OAtKX,CAsKmB,KAtKnB,EAsK0B,CAtK1B,CAAA,CAAA,EAuKE,WAvKF,CAwKA,MAxKA,EAyKA,SAzKA,EA0KA,OA1KA,EA2KA,SA3KA,EA4KA,CA5KA,EA6KA,KA7KA,EA8KA,SA9KA,EA+KA,oBA/KA,CAAA;EAAe;;;;EALF,QAaW,CAAA,CAAA,EAAA,cAAA,MAAA,CAAA,CAAA,MAAA,EA+LhB,UA/LgB,CA+LL,KA/LK,EA+LE,CA/LF,CAAA,GA+LO,OA/LP,CA+Le,KA/Lf,EA+LsB,CA/LtB,CAAA,CAAA,EAgMtB,WAhMsB,CAiMxB,MAjMwB,EAkMxB,SAlMwB,EAmMxB,OAnMwB,EAoMxB,SApMwB,EAqMxB,eArMwB,EAsMxB,0BAtMwB,EAuMxB,CAvMwB,EAwMxB,KAxMwB,CAAA;EAAwB,MACxC,CAAA,EAAA,EA6NJ,eA7NI,CA6NY,MA7NZ,EA6NoB,SA7NpB,EA6N+B,OA7N/B,EA6NwC,SA7NxC,EA6NmD,SA7NnD,CAAA,CAAA,EA8NN,IA9NM,CA+NR,MA/NQ,EAgOR,SAhOQ,EAiOR,OAjOQ,EAkOR,SAlOQ,EAmOR,eAnOQ,EAoOR,0BApOQ,EAqOR,SArOQ,EAsOR,oBAtOQ,CAAA;;;;;cCtDG,GAAC,YAAoB,mBAAA,CAApB,wBAAA,EAAA,qBAAA,CAAA,4BAAA,mBAAA,CAAA,MAAA"}
@@ -1,16 +1,17 @@
1
- import { ConstructType, __toESM } from "../Construct-r0U2zBwW.mjs";
2
- import { Function, FunctionBuilder, require_lodash } from "../functions-B-qt91O7.mjs";
3
- import "../publisher-BrFOF847.mjs";
4
- import { AWSScheduledFunction } from "../AWSScheduledFunction-CufMMhGB.mjs";
5
- import { ConsoleLogger } from "@geekmidas/logger/console";
1
+ import { ConstructType, __toESM } from "../Construct-HmWM6YYu.mjs";
2
+ import { idsOf, serviceOf, servicesOf } from "../construct-interface-Z4CpS8tK.mjs";
3
+ import { Function, FunctionBuilder, require_lodash } from "../functions-CvT_q7Y4.mjs";
4
+ import { cloneWith } from "../clone-DblgEZZa.mjs";
5
+ import "../publisher-CGEo8UKD.mjs";
6
+ import { AWSScheduledFunction } from "../AWSScheduledFunction-Db1lttJH.mjs";
6
7
 
7
8
  //#region src/crons/Cron.ts
8
9
  var Cron = class extends Function {
9
10
  static isCron(obj) {
10
11
  return Boolean(obj && obj.__IS_FUNCTION__ === true && obj.type === ConstructType.Cron);
11
12
  }
12
- constructor(fn, timeout, _schedule, input, outputSchema, services = [], logger, publisherService, events = [], memorySize, databaseService) {
13
- super(fn, timeout, ConstructType.Cron, input, outputSchema, services, logger, publisherService, events, memorySize, void 0, databaseService);
13
+ constructor(fn, timeout, _schedule, input, outputSchema, services = [], logger, publisherService, events = [], memorySize, databaseService, constructs = []) {
14
+ super(fn, timeout, ConstructType.Cron, input, outputSchema, services, logger, publisherService, events, memorySize, void 0, databaseService, constructs);
14
15
  this._schedule = _schedule;
15
16
  }
16
17
  get schedule() {
@@ -21,60 +22,60 @@ var Cron = class extends Function {
21
22
  //#endregion
22
23
  //#region src/crons/CronBuilder.ts
23
24
  var import_lodash = __toESM(require_lodash(), 1);
24
- const DEFAULT_LOGGER$1 = new ConsoleLogger();
25
25
  var CronBuilder = class extends FunctionBuilder {
26
26
  _schedule;
27
27
  constructor() {
28
28
  super(ConstructType.Cron);
29
29
  }
30
30
  memorySize(memorySize) {
31
- this._memorySize = memorySize;
32
- return this;
31
+ return cloneWith(this, { _memorySize: memorySize });
33
32
  }
34
33
  schedule(_expression) {
35
- this._schedule = _expression;
36
- return this;
34
+ return cloneWith(this, { _schedule: _expression });
37
35
  }
38
36
  input(schema) {
39
- this.inputSchema = schema;
40
- return this;
37
+ return cloneWith(this, { inputSchema: schema });
41
38
  }
42
39
  output(schema) {
43
- this.outputSchema = schema;
44
- return this;
40
+ return cloneWith(this, { outputSchema: schema });
41
+ }
42
+ /**
43
+ * Depend on constructs — a database, a bucket, a mail sender, a queue, a
44
+ * topic.
45
+ *
46
+ * It records the edge and dissolves each construct's client into the
47
+ * handler's service record under the construct's own id, so
48
+ * `.dependsOn([uploads])` is what makes `services.uploads` exist and type.
49
+ *
50
+ * Constructs only. A `Service` does not match the shape, which is what keeps
51
+ * env sniffing confined to `.services()` and the explicit lift.
52
+ */
53
+ dependsOn(constructs) {
54
+ const services = servicesOf(constructs);
55
+ return cloneWith(this, {
56
+ _services: (0, import_lodash.default)([...this._services, ...services], (s) => s.serviceName),
57
+ _constructs: idsOf(constructs, this._constructs)
58
+ });
45
59
  }
46
60
  services(services) {
47
- this._services = (0, import_lodash.default)([...this._services, ...services], (s) => s.serviceName);
48
- return this;
61
+ return cloneWith(this, { _services: (0, import_lodash.default)([...this._services, ...services], (s) => s.serviceName) });
49
62
  }
50
63
  logger(logger) {
51
- this._logger = logger;
52
- return this;
64
+ return cloneWith(this, { _logger: logger });
53
65
  }
54
66
  publisher(publisher) {
55
- this._publisher = publisher;
56
- return this;
67
+ return cloneWith(this, { _publisher: publisher });
57
68
  }
58
69
  /**
59
70
  * Set the database service for this cron job.
60
71
  * The database will be available in the handler context as `db`.
61
72
  */
62
- database(service) {
63
- this._databaseService = service;
64
- return this;
73
+ database(source) {
74
+ const service = serviceOf(source);
75
+ return cloneWith(this, { _databaseService: service });
65
76
  }
66
77
  handle(fn) {
67
- const cron = new Cron(fn, this._timeout, this._schedule, this.inputSchema, this.outputSchema, this._services, this._logger, this._publisher, this._events, this._memorySize, this._databaseService);
68
- this._services = [];
69
- this._logger = DEFAULT_LOGGER$1;
70
- this._events = [];
71
- this._publisher = void 0;
72
- this._databaseService = void 0;
73
- this._schedule = void 0;
74
- this.inputSchema = void 0;
75
- this.outputSchema = void 0;
76
- this._timeout = void 0;
77
- this._memorySize = void 0;
78
+ const cron = new Cron(fn, this._timeout, this._schedule, this.inputSchema, this.outputSchema, this._services, this._logger, this._publisher, this._events, this._memorySize, this._databaseService, this._constructs);
78
79
  return cron;
79
80
  }
80
81
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["obj: any","fn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>","timeout?: number","_schedule?: ScheduleExpression","input?: TInput","outputSchema?: OutSchema","services: TServices","logger?: TLogger","publisherService?: Service<TEventPublisherServiceName, TEventPublisher>","events: any[]","memorySize?: number","databaseService?: Service<TDatabaseServiceName, TDatabase>","DEFAULT_LOGGER","memorySize: number","_expression: ScheduleExpression","schema: T","services: T","logger: T","publisher: Service<TName, T>","service: Service<TName, T>","fn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>"],"sources":["../../src/crons/Cron.ts","../../src/crons/CronBuilder.ts","../../src/crons/index.ts"],"sourcesContent":["import type { AuditableAction } from '@geekmidas/audit';\nimport type { EventPublisher } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { ComposableStandardSchema } from '@geekmidas/schema';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\n\nimport { ConstructType } from '../Construct';\nimport { Function, type FunctionHandler } from '../functions';\n\nexport class Cron<\n\tTInput extends ComposableStandardSchema | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n\tTEventPublisherServiceName extends string = string,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> extends Function<\n\tTInput,\n\tTServices,\n\tTLogger,\n\tOutSchema,\n\tTEventPublisher,\n\tTEventPublisherServiceName,\n\tundefined,\n\tstring,\n\tTDatabase,\n\tTDatabaseServiceName,\n\tAuditableAction<string, unknown>,\n\tFunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>\n> {\n\tstatic isCron(obj: any): obj is Cron<any, any, any, any> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as Function).__IS_FUNCTION__ === true &&\n\t\t\t\tobj.type === ConstructType.Cron,\n\t\t);\n\t}\n\n\tconstructor(\n\t\tfn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>,\n\t\ttimeout?: number,\n\t\tprotected _schedule?: ScheduleExpression,\n\t\tinput?: TInput,\n\t\toutputSchema?: OutSchema,\n\t\tservices: TServices = [] as unknown as TServices,\n\t\tlogger?: TLogger,\n\t\tpublisherService?: Service<TEventPublisherServiceName, TEventPublisher>,\n\t\tevents: any[] = [],\n\t\tmemorySize?: number,\n\t\tdatabaseService?: Service<TDatabaseServiceName, TDatabase>,\n\t) {\n\t\tsuper(\n\t\t\tfn,\n\t\t\ttimeout,\n\t\t\tConstructType.Cron,\n\t\t\tinput,\n\t\t\toutputSchema,\n\t\t\tservices,\n\t\t\tlogger,\n\t\t\tpublisherService,\n\t\t\tevents,\n\t\t\tmemorySize,\n\t\t\tundefined, // auditorStorageService\n\t\t\tdatabaseService,\n\t\t);\n\t}\n\n\tget schedule(): ScheduleExpression | undefined {\n\t\treturn this._schedule;\n\t}\n}\n\nexport type RateExpression = `rate(${string})`;\n\ntype CronMinute =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| `${number},${number}`\n\t| string; // Allow more complex patterns\n\ntype CronHour =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| `${number},${number}`\n\t| string; // Allow more complex patterns\n\ntype CronDay =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| `${number},${number}`\n\t| string; // Allow more complex patterns\n\ntype CronMonth =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| 'JAN'\n\t| 'FEB'\n\t| 'MAR'\n\t| 'APR'\n\t| 'MAY'\n\t| 'JUN'\n\t| 'JUL'\n\t| 'AUG'\n\t| 'SEP'\n\t| 'OCT'\n\t| 'NOV'\n\t| 'DEC'\n\t| string; // Allow more complex patterns\n\ntype CronWeekday =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| 'SUN'\n\t| 'MON'\n\t| 'TUE'\n\t| 'WED'\n\t| 'THU'\n\t| 'FRI'\n\t| 'SAT'\n\t| `${string}-${string}` // Allow patterns like MON-FRI\n\t| string; // Allow more complex patterns\n\nexport type CronExpression =\n\t`cron(${CronMinute} ${CronHour} ${CronDay} ${CronMonth} ${CronWeekday})`;\n\nexport type ScheduleExpression = RateExpression | CronExpression;\n","import type { EventPublisher } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport { ConsoleLogger } from '@geekmidas/logger/console';\nimport type { ComposableStandardSchema } from '@geekmidas/schema';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport uniqBy from 'lodash.uniqby';\nimport { ConstructType } from '../Construct';\nimport { FunctionBuilder, type FunctionHandler } from '../functions';\nimport { Cron, type ScheduleExpression } from './Cron';\n\nconst DEFAULT_LOGGER = new ConsoleLogger() as any;\n\nexport class CronBuilder<\n\tTInput extends ComposableStandardSchema,\n\tTServices extends Service[],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n\tTEventPublisherServiceName extends string = string,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> extends FunctionBuilder<\n\tTInput,\n\tOutSchema,\n\tTServices,\n\tTLogger,\n\tTEventPublisher,\n\tTEventPublisherServiceName,\n\tundefined,\n\tstring,\n\tTDatabase,\n\tTDatabaseServiceName\n> {\n\tprivate _schedule?: ScheduleExpression;\n\n\tconstructor() {\n\t\tsuper(ConstructType.Cron);\n\t}\n\n\toverride memorySize(memorySize: number): this {\n\t\tthis._memorySize = memorySize;\n\t\treturn this;\n\t}\n\n\tschedule(\n\t\t_expression: ScheduleExpression,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\tthis._schedule = _expression;\n\t\treturn this;\n\t}\n\n\toverride input<T extends ComposableStandardSchema>(\n\t\tschema: T,\n\t): CronBuilder<\n\t\tT,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\tthis.inputSchema = schema as unknown as TInput;\n\n\t\treturn this as unknown as CronBuilder<\n\t\t\tT,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride output<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tT,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\tthis.outputSchema = schema as unknown as OutSchema;\n\n\t\treturn this as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tT,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride services<T extends Service[]>(\n\t\tservices: T,\n\t): CronBuilder<\n\t\tTInput,\n\t\t[...TServices, ...T],\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\tthis._services = uniqBy(\n\t\t\t[...this._services, ...services],\n\t\t\t(s) => s.serviceName,\n\t\t) as TServices;\n\n\t\treturn this as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\t[...TServices, ...T],\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride logger<T extends Logger>(\n\t\tlogger: T,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tT,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\tthis._logger = logger as unknown as TLogger;\n\n\t\treturn this as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tT,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride publisher<T extends EventPublisher<any>, TName extends string>(\n\t\tpublisher: Service<TName, T>,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tT,\n\t\tTName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\tthis._publisher = publisher as unknown as Service<\n\t\t\tTEventPublisherServiceName,\n\t\t\tTEventPublisher\n\t\t>;\n\n\t\treturn this as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tT,\n\t\t\tTName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\t/**\n\t * Set the database service for this cron job.\n\t * The database will be available in the handler context as `db`.\n\t */\n\toverride database<T, TName extends string>(\n\t\tservice: Service<TName, T>,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tT,\n\t\tTName\n\t> {\n\t\tthis._databaseService = service as unknown as Service<\n\t\t\tTDatabaseServiceName,\n\t\t\tTDatabase\n\t\t>;\n\n\t\treturn this as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tT,\n\t\t\tTName\n\t\t>;\n\t}\n\n\toverride handle(\n\t\tfn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>,\n\t): Cron<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\tconst cron = new Cron(\n\t\t\tfn,\n\t\t\tthis._timeout,\n\t\t\tthis._schedule,\n\t\t\tthis.inputSchema,\n\t\t\tthis.outputSchema,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._publisher,\n\t\t\tthis._events,\n\t\t\tthis._memorySize,\n\t\t\tthis._databaseService,\n\t\t);\n\n\t\t// Reset builder state after creating the cron to prevent pollution\n\t\tthis._services = [] as Service[] as TServices;\n\t\tthis._logger = DEFAULT_LOGGER;\n\t\tthis._events = [];\n\t\tthis._publisher = undefined;\n\t\tthis._databaseService = undefined;\n\t\tthis._schedule = undefined;\n\t\tthis.inputSchema = undefined;\n\t\tthis.outputSchema = undefined;\n\t\tthis._timeout = undefined;\n\t\tthis._memorySize = undefined;\n\n\t\treturn cron;\n\t}\n}\n","export { AWSScheduledFunction } from './AWSScheduledFunction';\nexport {\n\tCron,\n\ttype CronExpression,\n\ttype RateExpression,\n\ttype ScheduleExpression,\n} from './Cron';\nexport { CronBuilder } from './CronBuilder';\n\nimport { CronBuilder } from './CronBuilder';\n\nexport const c = new CronBuilder();\n"],"mappings":";;;;;;;AAUA,IAAa,OAAb,cASU,SAaR;CACD,OAAO,OAAOA,KAA2C;AACxD,SAAO,QACN,OACE,IAAiB,oBAAoB,QACtC,IAAI,SAAS,cAAc,KAC5B;CACD;CAED,YACCC,IACAC,SACUC,WACVC,OACAC,cACAC,WAAsB,CAAE,GACxBC,QACAC,kBACAC,SAAgB,CAAE,GAClBC,YACAC,iBACC;AACD,QACC,IACA,SACA,cAAc,MACd,OACA,cACA,UACA,QACA,kBACA,QACA,oBAEA,gBACA;EAvBS;CAwBV;CAED,IAAI,WAA2C;AAC9C,SAAO,KAAK;CACZ;AACD;;;;;AC9DD,MAAMC,mBAAiB,IAAI;AAE3B,IAAa,cAAb,cASU,gBAWR;CACD,AAAQ;CAER,cAAc;AACb,QAAM,cAAc,KAAK;CACzB;CAED,AAAS,WAAWC,YAA0B;AAC7C,OAAK,cAAc;AACnB,SAAO;CACP;CAED,SACCC,aAUC;AACD,OAAK,YAAY;AACjB,SAAO;CACP;CAED,AAAS,MACRC,QAUC;AACD,OAAK,cAAc;AAEnB,SAAO;CAUP;CAED,AAAS,OACRA,QAUC;AACD,OAAK,eAAe;AAEpB,SAAO;CAUP;CAED,AAAS,SACRC,UAUC;AACD,OAAK,YAAY,2BAChB,CAAC,GAAG,KAAK,WAAW,GAAG,QAAS,GAChC,CAAC,MAAM,EAAE,YACT;AAED,SAAO;CAUP;CAED,AAAS,OACRC,QAUC;AACD,OAAK,UAAU;AAEf,SAAO;CAUP;CAED,AAAS,UACRC,WAUC;AACD,OAAK,aAAa;AAKlB,SAAO;CAUP;;;;;CAMD,AAAS,SACRC,SAUC;AACD,OAAK,mBAAmB;AAKxB,SAAO;CAUP;CAED,AAAS,OACRC,IAUC;EACD,MAAM,OAAO,IAAI,KAChB,IACA,KAAK,UACL,KAAK,WACL,KAAK,aACL,KAAK,cACL,KAAK,WACL,KAAK,SACL,KAAK,YACL,KAAK,SACL,KAAK,aACL,KAAK;AAIN,OAAK,YAAY,CAAE;AACnB,OAAK,UAAUR;AACf,OAAK,UAAU,CAAE;AACjB,OAAK;AACL,OAAK;AACL,OAAK;AACL,OAAK;AACL,OAAK;AACL,OAAK;AACL,OAAK;AAEL,SAAO;CACP;AACD;;;;ACnQD,MAAa,IAAI,IAAI"}
1
+ {"version":3,"file":"index.mjs","names":["obj: any","fn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>","timeout?: number","_schedule?: ScheduleExpression","input?: TInput","outputSchema?: OutSchema","services: TServices","logger?: TLogger","publisherService?: Service<TEventPublisherServiceName, TEventPublisher>","events: any[]","memorySize?: number","databaseService?: Service<TDatabaseServiceName, TDatabase>","constructs: string[]","memorySize: number","_expression: ScheduleExpression","schema: T","constructs: T","s: Service","services: T","logger: T","publisher: Service<TName, T>","source: Consumable<TName, T> | Service<TName, T>","fn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>"],"sources":["../../src/crons/Cron.ts","../../src/crons/CronBuilder.ts","../../src/crons/index.ts"],"sourcesContent":["import type { AuditableAction } from '@geekmidas/audit';\nimport type { EventPublisher } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { ComposableStandardSchema } from '@geekmidas/schema';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\n\nimport { ConstructType } from '../Construct';\nimport { Function, type FunctionHandler } from '../functions';\n\nexport class Cron<\n\tTInput extends ComposableStandardSchema | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n\tTEventPublisherServiceName extends string = string,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> extends Function<\n\tTInput,\n\tTServices,\n\tTLogger,\n\tOutSchema,\n\tTEventPublisher,\n\tTEventPublisherServiceName,\n\tundefined,\n\tstring,\n\tTDatabase,\n\tTDatabaseServiceName,\n\tAuditableAction<string, unknown>,\n\tFunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>\n> {\n\tstatic isCron(obj: any): obj is Cron<any, any, any, any> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as Function).__IS_FUNCTION__ === true &&\n\t\t\t\tobj.type === ConstructType.Cron,\n\t\t);\n\t}\n\n\tconstructor(\n\t\tfn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>,\n\t\ttimeout?: number,\n\t\tprotected _schedule?: ScheduleExpression,\n\t\tinput?: TInput,\n\t\toutputSchema?: OutSchema,\n\t\tservices: TServices = [] as unknown as TServices,\n\t\tlogger?: TLogger,\n\t\tpublisherService?: Service<TEventPublisherServiceName, TEventPublisher>,\n\t\tevents: any[] = [],\n\t\tmemorySize?: number,\n\t\tdatabaseService?: Service<TDatabaseServiceName, TDatabase>,\n\t\t/**\n\t\t * The construct ids `.dependsOn()` named — last, so no existing positional\n\t\t * argument moves.\n\t\t */\n\t\tconstructs: string[] = [],\n\t) {\n\t\tsuper(\n\t\t\tfn,\n\t\t\ttimeout,\n\t\t\tConstructType.Cron,\n\t\t\tinput,\n\t\t\toutputSchema,\n\t\t\tservices,\n\t\t\tlogger,\n\t\t\tpublisherService,\n\t\t\tevents,\n\t\t\tmemorySize,\n\t\t\tundefined, // auditorStorageService\n\t\t\tdatabaseService,\n\t\t\tconstructs,\n\t\t);\n\t}\n\n\tget schedule(): ScheduleExpression | undefined {\n\t\treturn this._schedule;\n\t}\n}\n\nexport type RateExpression = `rate(${string})`;\n\ntype CronMinute =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| `${number},${number}`\n\t| string; // Allow more complex patterns\n\ntype CronHour =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| `${number},${number}`\n\t| string; // Allow more complex patterns\n\ntype CronDay =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| `${number},${number}`\n\t| string; // Allow more complex patterns\n\ntype CronMonth =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| 'JAN'\n\t| 'FEB'\n\t| 'MAR'\n\t| 'APR'\n\t| 'MAY'\n\t| 'JUN'\n\t| 'JUL'\n\t| 'AUG'\n\t| 'SEP'\n\t| 'OCT'\n\t| 'NOV'\n\t| 'DEC'\n\t| string; // Allow more complex patterns\n\ntype CronWeekday =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| 'SUN'\n\t| 'MON'\n\t| 'TUE'\n\t| 'WED'\n\t| 'THU'\n\t| 'FRI'\n\t| 'SAT'\n\t| `${string}-${string}` // Allow patterns like MON-FRI\n\t| string; // Allow more complex patterns\n\nexport type CronExpression =\n\t`cron(${CronMinute} ${CronHour} ${CronDay} ${CronMonth} ${CronWeekday})`;\n\nexport type ScheduleExpression = RateExpression | CronExpression;\n","import type { EventPublisher } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { ComposableStandardSchema } from '@geekmidas/schema';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport uniqBy from 'lodash.uniqby';\nimport { ConstructType } from '../Construct';\nimport { cloneWith } from '../clone';\nimport {\n\ttype Consumable,\n\tidsOf,\n\ttype ServicesOf,\n\tserviceOf,\n\tservicesOf,\n} from '../construct-interface';\nimport { FunctionBuilder, type FunctionHandler } from '../functions';\nimport { Cron, type ScheduleExpression } from './Cron';\n\nexport class CronBuilder<\n\tTInput extends ComposableStandardSchema,\n\tTServices extends Service[],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n\tTEventPublisherServiceName extends string = string,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> extends FunctionBuilder<\n\tTInput,\n\tOutSchema,\n\tTServices,\n\tTLogger,\n\tTEventPublisher,\n\tTEventPublisherServiceName,\n\tundefined,\n\tstring,\n\tTDatabase,\n\tTDatabaseServiceName\n> {\n\tprivate _schedule?: ScheduleExpression;\n\n\tconstructor() {\n\t\tsuper(ConstructType.Cron);\n\t}\n\n\toverride memorySize(memorySize: number): this {\n\t\treturn cloneWith(this, { _memorySize: memorySize });\n\t}\n\n\tschedule(\n\t\t_expression: ScheduleExpression,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, { _schedule: _expression });\n\t}\n\n\toverride input<T extends ComposableStandardSchema>(\n\t\tschema: T,\n\t): CronBuilder<\n\t\tT,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\tinputSchema: schema as unknown as TInput,\n\t\t}) as unknown as CronBuilder<\n\t\t\tT,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride output<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tT,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\toutputSchema: schema as unknown as OutSchema,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tT,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\t/**\n\t * Depend on constructs — a database, a bucket, a mail sender, a queue, a\n\t * topic.\n\t *\n\t * It records the edge and dissolves each construct's client into the\n\t * handler's service record under the construct's own id, so\n\t * `.dependsOn([uploads])` is what makes `services.uploads` exist and type.\n\t *\n\t * Constructs only. A `Service` does not match the shape, which is what keeps\n\t * env sniffing confined to `.services()` and the explicit lift.\n\t */\n\toverride dependsOn<const T extends readonly Consumable[]>(\n\t\tconstructs: T,\n\t): CronBuilder<\n\t\tTInput,\n\t\t[...TServices, ...ServicesOf<T>],\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\t// Both halves of the edge, from one call and one clone: the services the\n\t\t// handler runs with, and the ids the manifest records. Recording them\n\t\t// separately is what let them drift apart.\n\t\t//\n\t\t// `servicesOf` is the half that validates, so it runs first — recording\n\t\t// ids ahead of it left a caught `NotAConstruct` with `undefined` already\n\t\t// on a `string[]`.\n\t\tconst services = servicesOf(constructs) as unknown as Service[];\n\n\t\treturn cloneWith(this, {\n\t\t\t_services: uniqBy(\n\t\t\t\t[...this._services, ...services],\n\t\t\t\t(s: Service) => s.serviceName,\n\t\t\t),\n\t\t\t_constructs: idsOf(constructs, this._constructs),\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\t[...TServices, ...ServicesOf<T>],\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride services<T extends Service[]>(\n\t\tservices: T,\n\t): CronBuilder<\n\t\tTInput,\n\t\t[...TServices, ...T],\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_services: uniqBy(\n\t\t\t\t[...this._services, ...services],\n\t\t\t\t(s) => s.serviceName,\n\t\t\t) as TServices,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\t[...TServices, ...T],\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride logger<T extends Logger>(\n\t\tlogger: T,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tT,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_logger: logger as unknown as TLogger,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tT,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride publisher<T extends EventPublisher<any>, TName extends string>(\n\t\tpublisher: Service<TName, T>,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tT,\n\t\tTName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_publisher: publisher as unknown as Service<\n\t\t\t\tTEventPublisherServiceName,\n\t\t\t\tTEventPublisher\n\t\t\t>,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tT,\n\t\t\tTName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\t/**\n\t * Set the database service for this cron job.\n\t * The database will be available in the handler context as `db`.\n\t */\n\toverride database<T, TName extends string>(\n\t\tsource: Consumable<TName, T> | Service<TName, T>,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tT,\n\t\tTName\n\t> {\n\t\tconst service = serviceOf(source);\n\n\t\treturn cloneWith(this, {\n\t\t\t_databaseService: service as unknown as Service<\n\t\t\t\tTDatabaseServiceName,\n\t\t\t\tTDatabase\n\t\t\t>,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tT,\n\t\t\tTName\n\t\t>;\n\t}\n\n\toverride handle(\n\t\tfn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>,\n\t): Cron<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\tconst cron = new Cron(\n\t\t\tfn,\n\t\t\tthis._timeout,\n\t\t\tthis._schedule,\n\t\t\tthis.inputSchema,\n\t\t\tthis.outputSchema,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._publisher,\n\t\t\tthis._events,\n\t\t\tthis._memorySize,\n\t\t\tthis._databaseService,\n\t\t\tthis._constructs,\n\t\t);\n\n\t\t// No reset. `.handle()` reads this builder and leaves it alone, so a\n\t\t// configured base — `const fn = f.logger(log).timeout(60_000)` — keeps\n\t\t// its configuration for every construct built from it. The reset that\n\t\t// used to be here wiped the base on first use, which made a base usable\n\t\t// exactly once, and quietly reverted the logger to the default.\n\n\t\treturn cron;\n\t}\n}\n","export { AWSScheduledFunction } from './AWSScheduledFunction';\nexport {\n\tCron,\n\ttype CronExpression,\n\ttype RateExpression,\n\ttype ScheduleExpression,\n} from './Cron';\nexport { CronBuilder } from './CronBuilder';\n\nimport { CronBuilder } from './CronBuilder';\n\nexport const c = new CronBuilder();\n"],"mappings":";;;;;;;;AAUA,IAAa,OAAb,cASU,SAaR;CACD,OAAO,OAAOA,KAA2C;AACxD,SAAO,QACN,OACE,IAAiB,oBAAoB,QACtC,IAAI,SAAS,cAAc,KAC5B;CACD;CAED,YACCC,IACAC,SACUC,WACVC,OACAC,cACAC,WAAsB,CAAE,GACxBC,QACAC,kBACAC,SAAgB,CAAE,GAClBC,YACAC,iBAKAC,aAAuB,CAAE,GACxB;AACD,QACC,IACA,SACA,cAAc,MACd,OACA,cACA,UACA,QACA,kBACA,QACA,oBAEA,iBACA,WACA;EA7BS;CA8BV;CAED,IAAI,WAA2C;AAC9C,SAAO,KAAK;CACZ;AACD;;;;;AC7DD,IAAa,cAAb,cASU,gBAWR;CACD,AAAQ;CAER,cAAc;AACb,QAAM,cAAc,KAAK;CACzB;CAED,AAAS,WAAWC,YAA0B;AAC7C,SAAO,UAAU,MAAM,EAAE,aAAa,WAAY,EAAC;CACnD;CAED,SACCC,aAUC;AACD,SAAO,UAAU,MAAM,EAAE,WAAW,YAAa,EAAC;CAClD;CAED,AAAS,MACRC,QAUC;AACD,SAAO,UAAU,MAAM,EACtB,aAAa,OACb,EAAC;CAUF;CAED,AAAS,OACRA,QAUC;AACD,SAAO,UAAU,MAAM,EACtB,cAAc,OACd,EAAC;CAUF;;;;;;;;;;;;CAaD,AAAS,UACRC,YAUC;EAQD,MAAM,WAAW,WAAW,WAAW;AAEvC,SAAO,UAAU,MAAM;GACtB,WAAW,2BACV,CAAC,GAAG,KAAK,WAAW,GAAG,QAAS,GAChC,CAACC,MAAe,EAAE,YAClB;GACD,aAAa,MAAM,YAAY,KAAK,YAAY;EAChD,EAAC;CAUF;CAED,AAAS,SACRC,UAUC;AACD,SAAO,UAAU,MAAM,EACtB,WAAW,2BACV,CAAC,GAAG,KAAK,WAAW,GAAG,QAAS,GAChC,CAAC,MAAM,EAAE,YACT,CACD,EAAC;CAUF;CAED,AAAS,OACRC,QAUC;AACD,SAAO,UAAU,MAAM,EACtB,SAAS,OACT,EAAC;CAUF;CAED,AAAS,UACRC,WAUC;AACD,SAAO,UAAU,MAAM,EACtB,YAAY,UAIZ,EAAC;CAUF;;;;;CAMD,AAAS,SACRC,QAUC;EACD,MAAM,UAAU,UAAU,OAAO;AAEjC,SAAO,UAAU,MAAM,EACtB,kBAAkB,QAIlB,EAAC;CAUF;CAED,AAAS,OACRC,IAUC;EACD,MAAM,OAAO,IAAI,KAChB,IACA,KAAK,UACL,KAAK,WACL,KAAK,aACL,KAAK,cACL,KAAK,WACL,KAAK,SACL,KAAK,YACL,KAAK,SACL,KAAK,aACL,KAAK,kBACL,KAAK;AASN,SAAO;CACP;AACD;;;;ACrTD,MAAa,IAAI,IAAI"}
@@ -0,0 +1,181 @@
1
+ const require_chunk = require('../chunk-DWy1uDak.cjs');
2
+ const require_cache = require('../cache-3WSvAulx.cjs');
3
+ const __geekmidas_manifest = require_chunk.__toESM(require("@geekmidas/manifest"));
4
+ const kysely = require_chunk.__toESM(require("kysely"));
5
+ const pg = require_chunk.__toESM(require("pg"));
6
+
7
+ //#region src/database/kysely.ts
8
+ /** The schema a database uses when it does not say otherwise. */
9
+ const DEFAULT_SCHEMA = "app";
10
+ /**
11
+ * @typeParam DB - the database's schema.
12
+ * @typeParam TName - the canonical id. TypeScript has no partial
13
+ * type-argument inference, so `new KyselyDatabase<OrdersDB>('orders')` leaves
14
+ * this at its default and the service key widens to `string`. `db` still types
15
+ * through `.database()`, which infers from the service.
16
+ */
17
+ var KyselyDatabase = class KyselyDatabase {
18
+ id;
19
+ service;
20
+ /**
21
+ * Declared once and read by both `declare()` and `connect()`, so the key the
22
+ * build publishes and the key the client reads cannot drift.
23
+ */
24
+ config;
25
+ schemaName;
26
+ roles;
27
+ version;
28
+ derivedFrom;
29
+ constructor(id, options = {}, derivedFrom) {
30
+ this.options = options;
31
+ const canonical = (0, __geekmidas_manifest.canonicalId)(id);
32
+ this.id = canonical;
33
+ this.config = {
34
+ url: (0, __geekmidas_manifest.provideKey)(canonical, "url"),
35
+ ownerUrl: (0, __geekmidas_manifest.provideKey)(canonical, "ownerUrl")
36
+ };
37
+ this.schemaName = options.schema ?? DEFAULT_SCHEMA;
38
+ this.roles = options.roles ?? true;
39
+ this.version = options.version ?? __geekmidas_manifest.DEFAULT_POSTGRES_VERSION;
40
+ this.derivedFrom = derivedFrom;
41
+ this.service = {
42
+ serviceName: (0, __geekmidas_manifest.serviceKey)(canonical),
43
+ register: (registerOptions) => this.connect(registerOptions)
44
+ };
45
+ }
46
+ declare() {
47
+ if (this.derivedFrom) {
48
+ const { kind, of, schema } = this.derivedFrom;
49
+ return [kind === "database-schema" ? {
50
+ kind,
51
+ id: this.id,
52
+ of,
53
+ schema: schema ?? this.schemaName,
54
+ provides: [this.config.url]
55
+ } : {
56
+ kind,
57
+ id: this.id,
58
+ of,
59
+ provides: [this.config.url]
60
+ }];
61
+ }
62
+ return [{
63
+ kind: "database",
64
+ id: this.id,
65
+ engine: "postgres",
66
+ schema: this.schemaName,
67
+ version: this.version,
68
+ provides: [this.config.url],
69
+ ...this.roles ? {} : { roles: false }
70
+ }];
71
+ }
72
+ /**
73
+ * A read-only endpoint on this database.
74
+ *
75
+ * Read-only is enforced by the reader role's grants rather than by which
76
+ * endpoint it resolves to, so falling back to the writer where no replica
77
+ * exists is safe rather than a silently writable connection behind a name
78
+ * that says reader. There is no `writer()`: the database *is* the writer, so
79
+ * a replica can never be reached by accident.
80
+ *
81
+ * The return type is narrower than this class on purpose — see
82
+ * {@link ReadOnlyDatabase}.
83
+ */
84
+ reader() {
85
+ return new KyselyDatabase(`${this.id}Reader`, this.options, {
86
+ kind: "database-reader",
87
+ of: this.id
88
+ });
89
+ }
90
+ /**
91
+ * A cache that lives in this database.
92
+ *
93
+ * The same strengthening `schema()` is over a second database: `new
94
+ * Cache('Sessions')` says the app caches and leaves where to the deployment,
95
+ * while this says it caches *here* — which is a fact about the application
96
+ * and so belongs in its code.
97
+ *
98
+ * What it buys beyond being explicit: the table's schema and the role that
99
+ * reaches it come from this database rather than from a second convention,
100
+ * and the backend no longer has to guess which database "the database" meant
101
+ * when an app declares two.
102
+ *
103
+ * A cache is not a `KyselyDatabase`, so this returns a `Cache` — the client
104
+ * is a key/value store, not a query builder, and typing it as the parent
105
+ * would be a convenience that lies.
106
+ */
107
+ cache(id = `${this.id}Cache`, options = {}) {
108
+ return new require_cache.Cache(id, {
109
+ of: this.id,
110
+ ...options.table ? { table: options.table } : {}
111
+ });
112
+ }
113
+ /**
114
+ * A second schema in this database, with its own role(s) and its own URL —
115
+ * so this database's role holds no grant on those tables at all.
116
+ *
117
+ * Typed separately because a tenant has its own tables: the point is that
118
+ * `auth.selectFrom('sessions')` type-checks and
119
+ * `orders.selectFrom('sessions')` does not.
120
+ */
121
+ schema(id, options = {}) {
122
+ return new KyselyDatabase(id, options, {
123
+ kind: "database-schema",
124
+ of: this.id,
125
+ schema: options.schema ?? id.toLowerCase()
126
+ });
127
+ }
128
+ /**
129
+ * A connection as the *owner* role — the one that may create, alter and drop.
130
+ *
131
+ * A `Service` rather than part of the construct, and deliberately so: a
132
+ * construct is what `.dependsOn()` accepts, and nothing should be able to
133
+ * depend on this. A migrator asks for it by name; a handler cannot ask at
134
+ * all, which is the security property the role split exists for.
135
+ *
136
+ * Falls back to the runtime URL where no owner URL was published — the
137
+ * `roles: false` downgrade, where there is only one credential and it is the
138
+ * cluster master's.
139
+ */
140
+ get owner() {
141
+ return {
142
+ serviceName: `${(0, __geekmidas_manifest.serviceKey)(this.id)}Owner`,
143
+ register: (options) => this.connect(options, { owner: true })
144
+ };
145
+ }
146
+ async connect(options, as = {}) {
147
+ const { url, ownerUrl } = options.envParser.create((get) => ({
148
+ url: get(this.config.url).string(),
149
+ ownerUrl: get(this.config.ownerUrl).string().optional()
150
+ })).parse();
151
+ const { schema: _schema, roles: _roles,...kysely$1 } = this.options;
152
+ return new kysely.Kysely({
153
+ ...kysely$1,
154
+ dialect: new kysely.PostgresDialect({ pool: pool(as.owner ? ownerUrl ?? url : url) })
155
+ });
156
+ }
157
+ };
158
+ /**
159
+ * A pool for one URL, with its schema actually on the search path.
160
+ *
161
+ * `?search_path=` is not a libpq parameter — a URL carrying it connects
162
+ * happily and then resolves every unqualified name against `public`, which is
163
+ * how a schema tenant silently writes its tables into the database it was
164
+ * separated from. Postgres takes it as a startup option instead, so the URL
165
+ * keeps the readable form the target derives and this turns it into the thing
166
+ * the server understands.
167
+ */
168
+ function pool(url) {
169
+ const parsed = new URL(url);
170
+ const searchPath = parsed.searchParams.get("search_path");
171
+ if (!searchPath) return new pg.default.Pool({ connectionString: url });
172
+ parsed.searchParams.delete("search_path");
173
+ return new pg.default.Pool({
174
+ connectionString: parsed.toString(),
175
+ options: `-c search_path=${searchPath}`
176
+ });
177
+ }
178
+
179
+ //#endregion
180
+ exports.KyselyDatabase = KyselyDatabase;
181
+ //# sourceMappingURL=kysely.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kysely.cjs","names":["id: ConstructName<TName>","options: KyselyDatabaseOptions","derivedFrom?: DerivedFrom","DEFAULT_POSTGRES_VERSION","id: ConstructName<TCache>","options: { table?: string }","Cache","id: ConstructName<TTenant>","options: ServiceRegisterOptions","as: { owner?: boolean }","kysely","Kysely","PostgresDialect","url: string"],"sources":["../../src/database/kysely.ts"],"sourcesContent":["/**\n * `KyselyDatabase` — a declared Postgres database, typed by its schema.\n *\n * It declares a logical database, a schema, and the roles that reach it, and\n * hands back a Kysely client built from the one URL the adapter supplied. It\n * names no cloud: `--target=aws` fills that URL from RDS, local dev from the\n * Postgres container.\n *\n * Transactions and RLS context are the execution wrapper's job — it opens the\n * transaction and puts it in `ctx.db`. This construct does not resolve\n * connections per request.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\tDEFAULT_POSTGRES_VERSION,\n\ttype Declaration,\n\ttype PostgresVersion,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport { Kysely, type KyselyConfig, PostgresDialect } from 'kysely';\nimport pg from 'pg';\nimport { Cache } from '../cache';\nimport type { Construct } from '../construct-interface';\n\n/** The schema a database uses when it does not say otherwise. */\nconst DEFAULT_SCHEMA = 'app';\n\n/**\n * Everything Kysely takes, plus what this construct declares.\n *\n * `dialect` is omitted because the construct owns it — it is built from the one\n * URL the adapter supplied, which is the whole point of the construct. The rest\n * of `KyselyConfig` (`plugins`, `log`) is the app's business and passes\n * straight through, so anything Kysely adds later arrives without being\n * tracked here.\n */\nexport interface KyselyDatabaseOptions extends Omit<KyselyConfig, 'dialect'> {\n\t/**\n\t * The schema, pinned on both roles' `search_path`.\n\t *\n\t * Defaults to `app` — the role the schema plays, rather than a restatement\n\t * of the database's own name, which reads correctly beside `auth` and\n\t * `pgboss` and keeps the application off `public`.\n\t */\n\tschema?: string;\n\t/**\n\t * Provision the owner/runtime role split. Defaults to on.\n\t *\n\t * Off falls back to the cluster's master credential in both URLs, giving up\n\t * the DDL/DML split and putting credentials that can drop a table into the\n\t * function's environment. A deliberate downgrade, not a default.\n\t */\n\troles?: boolean;\n\t/**\n\t * The Postgres major version to provision.\n\t *\n\t * Declared here so one statement reaches both targets. It was previously\n\t * set in two unrelated places — a container tag locally, nothing at all on\n\t * AWS (so Aurora chose) — which is how local came to run 18 while deployed\n\t * ran 17.7 with nothing recording the difference.\n\t *\n\t * Defaults to {@link DEFAULT_POSTGRES_VERSION}.\n\t */\n\tversion?: PostgresVersion;\n}\n\n/** What makes a construct derived rather than a database in its own right. */\ninterface DerivedFrom {\n\tkind: 'database-reader' | 'database-schema';\n\tof: string;\n\tschema?: string;\n}\n\n/**\n * @typeParam DB - the database's schema.\n * @typeParam TName - the canonical id. TypeScript has no partial\n * type-argument inference, so `new KyselyDatabase<OrdersDB>('orders')` leaves\n * this at its default and the service key widens to `string`. `db` still types\n * through `.database()`, which infers from the service.\n */\nexport class KyselyDatabase<DB = unknown, TName extends string = string>\n\timplements Construct<TName, Kysely<DB>>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, Kysely<DB>>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * build publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly config: { url: string; ownerUrl: string };\n\tprivate readonly schemaName: string;\n\tprivate readonly roles: boolean;\n\tprivate readonly version: PostgresVersion;\n\tprivate readonly derivedFrom?: DerivedFrom;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: KyselyDatabaseOptions = {},\n\t\tderivedFrom?: DerivedFrom,\n\t) {\n\t\t// Canonicalises, so `orders` and `Orders` are one construct rather than\n\t\t// two that collide. Throws on anything that cannot become a valid id.\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.config = {\n\t\t\turl: provideKey(canonical, 'url'),\n\t\t\townerUrl: provideKey(canonical, 'ownerUrl'),\n\t\t};\n\t\tthis.schemaName = options.schema ?? DEFAULT_SCHEMA;\n\t\tthis.roles = options.roles ?? true;\n\t\tthis.version = options.version ?? DEFAULT_POSTGRES_VERSION;\n\t\tthis.derivedFrom = derivedFrom;\n\n\t\t// A field, not a getter: service discovery caches by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\t// Forwards the whole options object — cherry-picking `envParser` strips\n\t\t\t// `context` and with it the request-scoped logger.\n\t\t\tregister: (registerOptions) => this.connect(registerOptions),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\tif (this.derivedFrom) {\n\t\t\tconst { kind, of, schema } = this.derivedFrom;\n\n\t\t\treturn [\n\t\t\t\tkind === 'database-schema'\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tid: this.id,\n\t\t\t\t\t\t\tof,\n\t\t\t\t\t\t\tschema: schema ?? this.schemaName,\n\t\t\t\t\t\t\t// The runtime key alone — see the note below on the parent.\n\t\t\t\t\t\t\tprovides: [this.config.url],\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tid: this.id,\n\t\t\t\t\t\t\tof,\n\t\t\t\t\t\t\t// A reader has no owner URL of its own — nothing migrates\n\t\t\t\t\t\t\t// through a read-only endpoint — so this is the one key.\n\t\t\t\t\t\t\tprovides: [this.config.url],\n\t\t\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'database',\n\t\t\t\tid: this.id,\n\t\t\t\tengine: 'postgres',\n\t\t\t\tschema: this.schemaName,\n\t\t\t\tversion: this.version,\n\t\t\t\t// One key, the runtime role's. `config` also holds the owner key and\n\t\t\t\t// it is deliberately absent here: a key in `provides` is a key an\n\t\t\t\t// edge can name, and nothing should be able to depend on DDL rights.\n\t\t\t\tprovides: [this.config.url],\n\t\t\t\t...(this.roles ? {} : { roles: false }),\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * A read-only endpoint on this database.\n\t *\n\t * Read-only is enforced by the reader role's grants rather than by which\n\t * endpoint it resolves to, so falling back to the writer where no replica\n\t * exists is safe rather than a silently writable connection behind a name\n\t * that says reader. There is no `writer()`: the database *is* the writer, so\n\t * a replica can never be reached by accident.\n\t *\n\t * The return type is narrower than this class on purpose — see\n\t * {@link ReadOnlyDatabase}.\n\t */\n\treader(): ReadOnlyDatabase<DB, `${TName}Reader`> {\n\t\treturn new KyselyDatabase<DB, `${TName}Reader`>(\n\t\t\t`${this.id}Reader` as ConstructName<`${TName}Reader`>,\n\t\t\tthis.options,\n\t\t\t{ kind: 'database-reader', of: this.id },\n\t\t);\n\t}\n\n\t/**\n\t * A cache that lives in this database.\n\t *\n\t * The same strengthening `schema()` is over a second database: `new\n\t * Cache('Sessions')` says the app caches and leaves where to the deployment,\n\t * while this says it caches *here* — which is a fact about the application\n\t * and so belongs in its code.\n\t *\n\t * What it buys beyond being explicit: the table's schema and the role that\n\t * reaches it come from this database rather than from a second convention,\n\t * and the backend no longer has to guess which database \"the database\" meant\n\t * when an app declares two.\n\t *\n\t * A cache is not a `KyselyDatabase`, so this returns a `Cache` — the client\n\t * is a key/value store, not a query builder, and typing it as the parent\n\t * would be a convenience that lies.\n\t */\n\tcache<TCache extends string = `${TName}Cache`>(\n\t\tid: ConstructName<TCache> = `${this.id}Cache` as ConstructName<TCache>,\n\t\toptions: { table?: string } = {},\n\t): Cache<TCache> {\n\t\treturn new Cache<TCache>(id, {\n\t\t\tof: this.id,\n\t\t\t...(options.table ? { table: options.table } : {}),\n\t\t});\n\t}\n\n\t/**\n\t * A second schema in this database, with its own role(s) and its own URL —\n\t * so this database's role holds no grant on those tables at all.\n\t *\n\t * Typed separately because a tenant has its own tables: the point is that\n\t * `auth.selectFrom('sessions')` type-checks and\n\t * `orders.selectFrom('sessions')` does not.\n\t */\n\tschema<TenantDB, TTenant extends string>(\n\t\tid: ConstructName<TTenant>,\n\t\toptions: KyselyDatabaseOptions = {},\n\t): KyselyDatabase<TenantDB, TTenant> {\n\t\treturn new KyselyDatabase<TenantDB, TTenant>(id, options, {\n\t\t\tkind: 'database-schema',\n\t\t\tof: this.id,\n\t\t\tschema: options.schema ?? (id as string).toLowerCase(),\n\t\t});\n\t}\n\n\t/**\n\t * A connection as the *owner* role — the one that may create, alter and drop.\n\t *\n\t * A `Service` rather than part of the construct, and deliberately so: a\n\t * construct is what `.dependsOn()` accepts, and nothing should be able to\n\t * depend on this. A migrator asks for it by name; a handler cannot ask at\n\t * all, which is the security property the role split exists for.\n\t *\n\t * Falls back to the runtime URL where no owner URL was published — the\n\t * `roles: false` downgrade, where there is only one credential and it is the\n\t * cluster master's.\n\t */\n\tget owner(): Service<`${Uncapitalize<TName>}Owner`, Kysely<DB>> {\n\t\treturn {\n\t\t\tserviceName:\n\t\t\t\t`${serviceKey(this.id)}Owner` as `${Uncapitalize<TName>}Owner`,\n\t\t\tregister: (options) => this.connect(options, { owner: true }),\n\t\t};\n\t}\n\n\tprivate async connect(\n\t\toptions: ServiceRegisterOptions,\n\t\tas: { owner?: boolean } = {},\n\t): Promise<Kysely<DB>> {\n\t\tconst { url, ownerUrl } = options.envParser\n\t\t\t.create((get) => ({\n\t\t\t\turl: get(this.config.url).string(),\n\t\t\t\townerUrl: get(this.config.ownerUrl).string().optional(),\n\t\t\t}))\n\t\t\t.parse();\n\n\t\t// Split what the manifest declared from what Kysely takes, so neither\n\t\t// leaks into the other: `schema` and `roles` describe infrastructure and\n\t\t// mean nothing to a client.\n\t\tconst { schema: _schema, roles: _roles, ...kysely } = this.options;\n\n\t\treturn new Kysely<DB>({\n\t\t\t...kysely,\n\t\t\tdialect: new PostgresDialect({\n\t\t\t\tpool: pool(as.owner ? (ownerUrl ?? url) : url),\n\t\t\t}),\n\t\t});\n\t}\n}\n\n/**\n * A pool for one URL, with its schema actually on the search path.\n *\n * `?search_path=` is not a libpq parameter — a URL carrying it connects\n * happily and then resolves every unqualified name against `public`, which is\n * how a schema tenant silently writes its tables into the database it was\n * separated from. Postgres takes it as a startup option instead, so the URL\n * keeps the readable form the target derives and this turns it into the thing\n * the server understands.\n */\nfunction pool(url: string): pg.Pool {\n\tconst parsed = new URL(url);\n\tconst searchPath = parsed.searchParams.get('search_path');\n\n\tif (!searchPath) return new pg.Pool({ connectionString: url });\n\n\tparsed.searchParams.delete('search_path');\n\n\treturn new pg.Pool({\n\t\tconnectionString: parsed.toString(),\n\t\toptions: `-c search_path=${searchPath}`,\n\t});\n}\n\n/**\n * A database you may read through, and derive nothing from.\n *\n * A reader is terminal in the graph, and this is that fact in the type system.\n * `DERIVES_FROM` gives `cache` and `database-schema` no `database-reader`\n * parent, and there is no reader of a reader — so `orders.reader().cache(…)`\n * has always been illegal, but it type-checked and failed later at\n * `assertDerivations`. That is a long way round to learn that a read-only\n * endpoint cannot own a table something writes to.\n *\n * Omitting the three deriving methods rather than making them throw keeps the\n * failure where it costs least: the editor, on the line that wrote it.\n *\n * The result is deliberately not assignable back to `KyselyDatabase` — a\n * reader is not one, and anything that genuinely needs the writer should say\n * so.\n */\nexport type ReadOnlyDatabase<DB, TName extends string> = Omit<\n\tKyselyDatabase<DB, TName>,\n\t'reader' | 'cache' | 'schema'\n>;\n"],"mappings":";;;;;;;;AA6BA,MAAM,iBAAiB;;;;;;;;AAuDvB,IAAa,iBAAb,MAAa,eAEb;CACC,AAAS;CACT,AAAS;;;;;CAMT,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CAEjB,YACCA,IACiBC,UAAiC,CAAE,GACpDC,aACC;EAFgB;EAKjB,MAAM,YAAY,sCAAY,GAAa;AAE3C,OAAK,KAAK;AACV,OAAK,SAAS;GACb,KAAK,qCAAW,WAAW,MAAM;GACjC,UAAU,qCAAW,WAAW,WAAW;EAC3C;AACD,OAAK,aAAa,QAAQ,UAAU;AACpC,OAAK,QAAQ,QAAQ,SAAS;AAC9B,OAAK,UAAU,QAAQ,WAAWC;AAClC,OAAK,cAAc;AAGnB,OAAK,UAAU;GACd,aAAa,qCAAW,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,IAAIC,oBAAc,IAAI;GAC5B,IAAI,KAAK;GACT,GAAI,QAAQ,QAAQ,EAAE,OAAO,QAAQ,MAAO,IAAG,CAAE;EACjD;CACD;;;;;;;;;CAUD,OACCC,IACAN,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,qCAAW,KAAK,GAAG,CAAC;GACxB,UAAU,CAAC,YAAY,KAAK,QAAQ,SAAS,EAAE,OAAO,KAAM,EAAC;EAC7D;CACD;CAED,MAAc,QACbO,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,GAAGC,UAAQ,GAAG,KAAK;AAE3D,SAAO,IAAIC,cAAW;GACrB,GAAGD;GACH,SAAS,IAAIE,uBAAgB,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,WAAG,KAAK,EAAE,kBAAkB,IAAK;AAE7D,QAAO,aAAa,OAAO,cAAc;AAEzC,QAAO,IAAI,WAAG,KAAK;EAClB,kBAAkB,OAAO,UAAU;EACnC,UAAU,iBAAiB,WAAW;CACtC;AACD"}
@@ -0,0 +1,152 @@
1
+ import { Construct } from "../construct-interface-D2nNkHUN.cjs";
2
+ import { Cache } from "../cache-CdQ7OLpR.cjs";
3
+ import { Service } from "@geekmidas/services";
4
+ import { ConstructName, Declaration, PostgresVersion } from "@geekmidas/manifest";
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.cts.map