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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. package/dist/Construct-127M7yrl.d.cts.map +1 -1
  2. package/dist/Construct-BMk_CRSD.d.mts.map +1 -1
  3. package/dist/{Cron-D_sfaMGz.d.cts → Cron-Ca_qHQu2.d.cts} +2 -2
  4. package/dist/{Cron-D6Y7BBt3.d.mts.map → Cron-Ca_qHQu2.d.cts.map} +1 -1
  5. package/dist/{Cron-D6Y7BBt3.d.mts → Cron-DPJiR7Lt.d.mts} +2 -2
  6. package/dist/{Cron-D_sfaMGz.d.cts.map → Cron-DPJiR7Lt.d.mts.map} +1 -1
  7. package/dist/{CronBuilder-4BZhkChG.d.mts → CronBuilder-BC4za5Bx.d.mts} +4 -4
  8. package/dist/{CronBuilder-4BZhkChG.d.mts.map → CronBuilder-BC4za5Bx.d.mts.map} +1 -1
  9. package/dist/{CronBuilder-C91MVLSr.d.cts → CronBuilder-C3RrAF1-.d.cts} +4 -4
  10. package/dist/{CronBuilder-C91MVLSr.d.cts.map → CronBuilder-C3RrAF1-.d.cts.map} +1 -1
  11. package/dist/{Endpoint-YYwjqtS1.d.cts → Endpoint-BlIZLsBQ.d.cts} +5 -5
  12. package/dist/{Endpoint-BUoDD96P.d.mts.map → Endpoint-BlIZLsBQ.d.cts.map} +1 -1
  13. package/dist/{Endpoint-BUoDD96P.d.mts → Endpoint-DC7mreOr.d.mts} +5 -5
  14. package/dist/{Endpoint-YYwjqtS1.d.cts.map → Endpoint-DC7mreOr.d.mts.map} +1 -1
  15. package/dist/{EndpointFactory-BbVOeryo.d.mts → EndpointFactory-DCmnCmkX.d.mts} +5 -5
  16. package/dist/{EndpointFactory-BbVOeryo.d.mts.map → EndpointFactory-DCmnCmkX.d.mts.map} +1 -1
  17. package/dist/{EndpointFactory-Hh1r6J_C.d.cts → EndpointFactory-cVTb8kCc.d.cts} +5 -5
  18. package/dist/{EndpointFactory-Hh1r6J_C.d.cts.map → EndpointFactory-cVTb8kCc.d.cts.map} +1 -1
  19. package/dist/{ObjectSubscriberBuilder-DfzXQEKW.d.mts → ObjectSubscriberBuilder-AwGKoUKy.d.mts} +2 -2
  20. package/dist/{ObjectSubscriberBuilder-DfzXQEKW.d.mts.map → ObjectSubscriberBuilder-AwGKoUKy.d.mts.map} +1 -1
  21. package/dist/{ObjectSubscriberBuilder-LWkey_oq.d.cts → ObjectSubscriberBuilder-CB6imsX4.d.cts} +2 -2
  22. package/dist/{ObjectSubscriberBuilder-LWkey_oq.d.cts.map → ObjectSubscriberBuilder-CB6imsX4.d.cts.map} +1 -1
  23. package/dist/{ProcessorBuilder-_jdZlbfW.d.cts → ProcessorBuilder-CeEZ2vCx.d.cts} +2 -2
  24. package/dist/{ProcessorBuilder-D4oYvZeG.d.mts.map → ProcessorBuilder-CeEZ2vCx.d.cts.map} +1 -1
  25. package/dist/{ProcessorBuilder-D4oYvZeG.d.mts → ProcessorBuilder-CwIlm75W.d.mts} +2 -2
  26. package/dist/{ProcessorBuilder-_jdZlbfW.d.cts.map → ProcessorBuilder-CwIlm75W.d.mts.map} +1 -1
  27. package/dist/{Queue-u8w8_HpE.mjs → Queue-9Hh20ZCk.mjs} +3 -3
  28. package/dist/Queue-9Hh20ZCk.mjs.map +1 -0
  29. package/dist/Queue-B8HGg439.d.mts.map +1 -1
  30. package/dist/Queue-C4rijiM7.d.cts.map +1 -1
  31. package/dist/{Queue-D4Iaidrs.cjs → Queue-W1wueijP.cjs} +2 -2
  32. package/dist/Queue-W1wueijP.cjs.map +1 -0
  33. package/dist/{QueueBuilder-BxsZ9o5z.cjs → QueueBuilder-BDcv9B71.cjs} +2 -2
  34. package/dist/{QueueBuilder-BxsZ9o5z.cjs.map → QueueBuilder-BDcv9B71.cjs.map} +1 -1
  35. package/dist/{QueueBuilder-CVS_qPuo.d.mts → QueueBuilder-CUERv8jt.d.mts} +2 -2
  36. package/dist/{QueueBuilder-CVS_qPuo.d.mts.map → QueueBuilder-CUERv8jt.d.mts.map} +1 -1
  37. package/dist/{QueueBuilder-SQli59An.d.cts → QueueBuilder-CmB1vOgn.d.cts} +2 -2
  38. package/dist/{QueueBuilder-SQli59An.d.cts.map → QueueBuilder-CmB1vOgn.d.cts.map} +1 -1
  39. package/dist/{QueueBuilder-2wP5lEC8.mjs → QueueBuilder-CrZL8HHs.mjs} +2 -2
  40. package/dist/{QueueBuilder-2wP5lEC8.mjs.map → QueueBuilder-CrZL8HHs.mjs.map} +1 -1
  41. package/dist/{Topic-DN2gYJ-p.mjs → Topic-BGoOeCT6.mjs} +3 -3
  42. package/dist/Topic-BGoOeCT6.mjs.map +1 -0
  43. package/dist/{Topic-Dp9Q7Lj2.cjs → Topic-DLCZBNwK.cjs} +2 -2
  44. package/dist/Topic-DLCZBNwK.cjs.map +1 -0
  45. package/dist/adaptors/aws.d.cts +2 -2
  46. package/dist/adaptors/aws.d.mts +2 -2
  47. package/dist/adaptors/awsWebsocket.d.cts +1 -1
  48. package/dist/adaptors/awsWebsocket.d.mts +1 -1
  49. package/dist/adaptors/hono.d.cts +1 -1
  50. package/dist/adaptors/hono.d.mts +1 -1
  51. package/dist/adaptors/testing.cjs +15 -15
  52. package/dist/adaptors/testing.cjs.map +1 -1
  53. package/dist/adaptors/testing.d.cts +5 -5
  54. package/dist/adaptors/testing.d.cts.map +1 -1
  55. package/dist/adaptors/testing.d.mts +5 -5
  56. package/dist/adaptors/testing.d.mts.map +1 -1
  57. package/dist/adaptors/testing.mjs +16 -16
  58. package/dist/adaptors/testing.mjs.map +1 -1
  59. package/dist/{auth-DnB9H9KL.d.mts → auth-1yI2wR-4.d.cts} +6 -6
  60. package/dist/{auth-BqWz2JxC.d.cts.map → auth-1yI2wR-4.d.cts.map} +1 -1
  61. package/dist/{auth-BqWz2JxC.d.cts → auth-D4NMXgLt.d.mts} +6 -6
  62. package/dist/{auth-DnB9H9KL.d.mts.map → auth-D4NMXgLt.d.mts.map} +1 -1
  63. package/dist/auth.cjs +5 -5
  64. package/dist/auth.cjs.map +1 -1
  65. package/dist/auth.d.cts +1 -1
  66. package/dist/auth.d.mts +1 -1
  67. package/dist/auth.mjs +6 -6
  68. package/dist/auth.mjs.map +1 -1
  69. package/dist/{cache-CCHcO9Oo.d.mts → cache-0VoeOTF9.d.mts} +2 -2
  70. package/dist/{cache-CCHcO9Oo.d.mts.map → cache-0VoeOTF9.d.mts.map} +1 -1
  71. package/dist/{cache-CQjMNPrC.d.cts → cache-CW-sArzS.d.cts} +2 -2
  72. package/dist/{cache-CQjMNPrC.d.cts.map → cache-CW-sArzS.d.cts.map} +1 -1
  73. package/dist/cache.cjs +1 -1
  74. package/dist/cache.cjs.map +1 -1
  75. package/dist/cache.d.cts +1 -1
  76. package/dist/cache.d.mts +1 -1
  77. package/dist/cache.mjs +2 -2
  78. package/dist/cache.mjs.map +1 -1
  79. package/dist/{construct-interface-CSA9VeWM.d.mts → construct-interface-DhbaONW2.d.cts} +20 -4
  80. package/dist/construct-interface-DhbaONW2.d.cts.map +1 -0
  81. package/dist/{construct-interface-DugP0E5q.d.cts → construct-interface-DxfkFxkl.d.mts} +20 -4
  82. package/dist/construct-interface-DxfkFxkl.d.mts.map +1 -0
  83. package/dist/construct-interface.cjs +9 -0
  84. package/dist/construct-interface.cjs.map +1 -1
  85. package/dist/construct-interface.d.cts +2 -2
  86. package/dist/construct-interface.d.mts +2 -2
  87. package/dist/construct-interface.mjs +9 -1
  88. package/dist/construct-interface.mjs.map +1 -1
  89. package/dist/{credential-DfSAOOdY.mjs → credential-B80mOxwT.mjs} +3 -3
  90. package/dist/credential-B80mOxwT.mjs.map +1 -0
  91. package/dist/{credential-DYymbp_7.cjs → credential-RlgbzZAc.cjs} +2 -2
  92. package/dist/credential-RlgbzZAc.cjs.map +1 -0
  93. package/dist/credential.cjs +1 -1
  94. package/dist/credential.d.cts +1 -1
  95. package/dist/credential.d.mts +1 -1
  96. package/dist/credential.mjs +1 -1
  97. package/dist/crons/index.d.cts +2 -2
  98. package/dist/crons/index.d.mts +2 -2
  99. package/dist/database/kysely.cjs +1 -1
  100. package/dist/database/kysely.d.cts +1 -1
  101. package/dist/database/kysely.d.mts +1 -1
  102. package/dist/database/kysely.mjs +1 -1
  103. package/dist/email.cjs +2 -2
  104. package/dist/email.cjs.map +1 -1
  105. package/dist/email.d.cts +1 -1
  106. package/dist/email.d.mts +1 -1
  107. package/dist/email.mjs +3 -3
  108. package/dist/email.mjs.map +1 -1
  109. package/dist/encryption.cjs +1 -1
  110. package/dist/encryption.cjs.map +1 -1
  111. package/dist/encryption.d.cts +1 -1
  112. package/dist/encryption.d.mts +1 -1
  113. package/dist/encryption.mjs +2 -2
  114. package/dist/encryption.mjs.map +1 -1
  115. package/dist/endpoints/index.d.cts +2 -2
  116. package/dist/endpoints/index.d.mts +2 -2
  117. package/dist/external-api.cjs +3 -3
  118. package/dist/external-api.cjs.map +1 -1
  119. package/dist/external-api.d.cts +1 -1
  120. package/dist/external-api.d.mts +1 -1
  121. package/dist/external-api.mjs +4 -4
  122. package/dist/external-api.mjs.map +1 -1
  123. package/dist/{fake-BqhP8RRQ.d.mts → fake-BvOXkZmj.d.mts} +2 -2
  124. package/dist/{fake-BqhP8RRQ.d.mts.map → fake-BvOXkZmj.d.mts.map} +1 -1
  125. package/dist/{fake-DqieDYYA.d.cts → fake-Djx8E0o1.d.cts} +2 -2
  126. package/dist/{fake-DqieDYYA.d.cts.map → fake-Djx8E0o1.d.cts.map} +1 -1
  127. package/dist/file-server.cjs +79 -20
  128. package/dist/file-server.cjs.map +1 -1
  129. package/dist/file-server.d.cts +35 -17
  130. package/dist/file-server.d.cts.map +1 -1
  131. package/dist/file-server.d.mts +35 -17
  132. package/dist/file-server.d.mts.map +1 -1
  133. package/dist/file-server.mjs +80 -22
  134. package/dist/file-server.mjs.map +1 -1
  135. package/dist/functions/index.d.cts +1 -1
  136. package/dist/functions/index.d.mts +1 -1
  137. package/dist/{inbox-CR3L1fOI.d.cts → inbox-BjvMs7EJ.d.cts} +2 -2
  138. package/dist/{inbox-CR3L1fOI.d.cts.map → inbox-BjvMs7EJ.d.cts.map} +1 -1
  139. package/dist/{inbox-YOdxlyfj.d.mts → inbox-C8bOR9UL.d.mts} +2 -2
  140. package/dist/{inbox-YOdxlyfj.d.mts.map → inbox-C8bOR9UL.d.mts.map} +1 -1
  141. package/dist/inbox.cjs +3 -3
  142. package/dist/inbox.cjs.map +1 -1
  143. package/dist/inbox.d.cts +1 -1
  144. package/dist/inbox.d.mts +1 -1
  145. package/dist/inbox.mjs +4 -4
  146. package/dist/inbox.mjs.map +1 -1
  147. package/dist/{index-DPTHa6Ud.d.cts → index-DaK-C7N3.d.cts} +2 -2
  148. package/dist/{index-BoQ3-M-K.d.mts.map → index-DaK-C7N3.d.cts.map} +1 -1
  149. package/dist/{index-BoQ3-M-K.d.mts → index-vCS4HBEG.d.mts} +2 -2
  150. package/dist/{index-DPTHa6Ud.d.cts.map → index-vCS4HBEG.d.mts.map} +1 -1
  151. package/dist/{kysely-CebjCWTl.d.cts → kysely-2HqIQ2fC.d.cts} +3 -3
  152. package/dist/{kysely-CebjCWTl.d.cts.map → kysely-2HqIQ2fC.d.cts.map} +1 -1
  153. package/dist/{kysely-De5rAC-E.d.mts → kysely-BGvpd_ZH.d.mts} +3 -3
  154. package/dist/{kysely-De5rAC-E.d.mts.map → kysely-BGvpd_ZH.d.mts.map} +1 -1
  155. package/dist/{kysely-Cs4uPO8k.mjs → kysely-Bc9xzaik.mjs} +4 -4
  156. package/dist/kysely-Bc9xzaik.mjs.map +1 -0
  157. package/dist/{kysely-CukArHJ0.cjs → kysely-D7f6J2lh.cjs} +3 -3
  158. package/dist/kysely-D7f6J2lh.cjs.map +1 -0
  159. package/dist/mobile-app.cjs +6 -2
  160. package/dist/mobile-app.cjs.map +1 -1
  161. package/dist/mobile-app.d.cts +5 -1
  162. package/dist/mobile-app.d.cts.map +1 -1
  163. package/dist/mobile-app.d.mts +5 -1
  164. package/dist/mobile-app.d.mts.map +1 -1
  165. package/dist/mobile-app.mjs +8 -4
  166. package/dist/mobile-app.mjs.map +1 -1
  167. package/dist/object-storage.cjs +6 -6
  168. package/dist/object-storage.cjs.map +1 -1
  169. package/dist/object-storage.d.cts +3 -3
  170. package/dist/object-storage.d.cts.map +1 -1
  171. package/dist/object-storage.d.mts +3 -3
  172. package/dist/object-storage.d.mts.map +1 -1
  173. package/dist/object-storage.mjs +7 -7
  174. package/dist/object-storage.mjs.map +1 -1
  175. package/dist/processors/index.d.cts +1 -1
  176. package/dist/processors/index.d.mts +1 -1
  177. package/dist/queue/index.cjs +2 -2
  178. package/dist/queue/index.d.cts +1 -1
  179. package/dist/queue/index.d.mts +1 -1
  180. package/dist/queue/index.mjs +2 -2
  181. package/dist/random-password.d.cts +1 -1
  182. package/dist/random-password.d.mts +1 -1
  183. package/dist/rest-api.cjs +3 -3
  184. package/dist/rest-api.cjs.map +1 -1
  185. package/dist/rest-api.d.cts +4 -4
  186. package/dist/rest-api.d.mts +4 -4
  187. package/dist/rest-api.mjs +4 -4
  188. package/dist/rest-api.mjs.map +1 -1
  189. package/dist/site.cjs +8 -3
  190. package/dist/site.cjs.map +1 -1
  191. package/dist/site.d.cts +7 -2
  192. package/dist/site.d.cts.map +1 -1
  193. package/dist/site.d.mts +7 -2
  194. package/dist/site.d.mts.map +1 -1
  195. package/dist/site.mjs +10 -5
  196. package/dist/site.mjs.map +1 -1
  197. package/dist/subscribers/index.d.cts +1 -1
  198. package/dist/subscribers/index.d.mts +1 -1
  199. package/dist/{telemetry-CObow3Dn.d.mts → telemetry-BirKau0X.d.mts} +2 -2
  200. package/dist/{telemetry-C1oqncFY.d.cts.map → telemetry-BirKau0X.d.mts.map} +1 -1
  201. package/dist/{telemetry-C1oqncFY.d.cts → telemetry-DjJgtQ_N.d.cts} +2 -2
  202. package/dist/{telemetry-CObow3Dn.d.mts.map → telemetry-DjJgtQ_N.d.cts.map} +1 -1
  203. package/dist/telemetry.d.cts +1 -1
  204. package/dist/telemetry.d.mts +1 -1
  205. package/dist/topic/index.cjs +1 -1
  206. package/dist/topic/index.mjs +1 -1
  207. package/dist/{websocket-api-DkF8Hva-.d.cts → websocket-api-B1Wl3tg4.d.cts} +3 -3
  208. package/dist/{websocket-api-CPEzJyDt.d.mts.map → websocket-api-B1Wl3tg4.d.cts.map} +1 -1
  209. package/dist/{websocket-api-CPEzJyDt.d.mts → websocket-api-CvnPDSZB.d.mts} +3 -3
  210. package/dist/{websocket-api-DkF8Hva-.d.cts.map → websocket-api-CvnPDSZB.d.mts.map} +1 -1
  211. package/dist/{websocket-api-czxhekGG.cjs → websocket-api-Zy2U-Qyh.cjs} +4 -4
  212. package/dist/websocket-api-Zy2U-Qyh.cjs.map +1 -0
  213. package/dist/{websocket-api-Bg9SowJ5.mjs → websocket-api-svBCnOAE.mjs} +5 -5
  214. package/dist/{websocket-api-Bg9SowJ5.mjs.map → websocket-api-svBCnOAE.mjs.map} +1 -1
  215. package/dist/websocket-api.cjs +1 -1
  216. package/dist/websocket-api.d.cts +1 -1
  217. package/dist/websocket-api.d.mts +1 -1
  218. package/dist/websocket-api.mjs +1 -1
  219. package/dist/worker.cjs +1 -1
  220. package/dist/worker.d.cts +8 -8
  221. package/dist/worker.d.mts +8 -8
  222. package/dist/worker.mjs +1 -1
  223. package/package.json +31 -31
  224. package/dist/Queue-D4Iaidrs.cjs.map +0 -1
  225. package/dist/Queue-u8w8_HpE.mjs.map +0 -1
  226. package/dist/Topic-DN2gYJ-p.mjs.map +0 -1
  227. package/dist/Topic-Dp9Q7Lj2.cjs.map +0 -1
  228. package/dist/construct-interface-CSA9VeWM.d.mts.map +0 -1
  229. package/dist/construct-interface-DugP0E5q.d.cts.map +0 -1
  230. package/dist/credential-DYymbp_7.cjs.map +0 -1
  231. package/dist/credential-DfSAOOdY.mjs.map +0 -1
  232. package/dist/kysely-Cs4uPO8k.mjs.map +0 -1
  233. package/dist/kysely-CukArHJ0.cjs.map +0 -1
  234. package/dist/websocket-api-czxhekGG.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"QueueBuilder-BxsZ9o5z.cjs","names":["DEFAULT_LOGGER","cloneWith","servicesOf","idsOf","serviceOf","databaseEdges","Queue"],"sources":["../src/queue/QueueBuilder.ts"],"sourcesContent":["import type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { cloneWith } from '../clone';\nimport {\n\ttype Consumable,\n\tdatabaseEdges,\n\tidsOf,\n\ttype ServicesOf,\n\tserviceOf,\n\tservicesOf,\n} from '../construct-interface';\nimport { Queue, type QueueHandler } from './Queue';\n\n/**\n * Builds a {@link Queue} and its one consumer. Reached through\n * `worker.queue('orders')`, never constructed by hand: the worker stamps itself\n * as the owner. `message` is the typed job payload and `handle` the consumer.\n * The queue name is captured as a literal so `queue.service` publishes\n * `{ type: '<name>', payload }`. The handler's `db` is the worker's database\n * unless `.database(other)` names another.\n */\nexport class QueueBuilder<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> {\n\tprivate _name?: string;\n\tprivate _messageSchema?: TMessage;\n\tprivate _timeout = 30000;\n\tprivate _batchSize?: number;\n\tprivate _fifo?: boolean;\n\tprivate _services: TServices = [] as Service[] as TServices;\n\t/** The construct ids `.dependsOn()` named — what the manifest records. */\n\tpublic _constructs: string[] = [];\n\tprivate _logger: TLogger = DEFAULT_LOGGER as TLogger;\n\t/** The worker that runs this queue's consumer — stamped by `worker.queue()`. */\n\tpublic _owner?: string;\n\t/** What the handler's `db` comes from — the worker's, unless overridden. */\n\tprivate _databaseService?: Service<TDatabaseServiceName, TDatabase>;\n\t/** The edge `.database()` added, so the next one can replace it. */\n\tprivate _databaseEdge?: string;\n\n\t/** The queue name — drives the infra queue and its `<NAME>_*` env vars. */\n\tqueue<T extends string>(\n\t\tname: T,\n\t): QueueBuilder<\n\t\tT,\n\t\tTMessage,\n\t\tTServices,\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, { _name: name }) as unknown as QueueBuilder<\n\t\t\tT,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\ttimeout(timeout: number): this {\n\t\treturn cloneWith(this, { _timeout: timeout });\n\t}\n\n\t/** SQS event-source batch size (deployed). */\n\tbatchSize(batchSize: number): this {\n\t\treturn cloneWith(this, { _batchSize: batchSize });\n\t}\n\n\t/** Mark the queue as FIFO (deployed). */\n\tfifo(fifo = true): this {\n\t\treturn cloneWith(this, { _fifo: fifo });\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\tdependsOn<const T extends readonly Consumable[]>(\n\t\tconstructs: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tTMessage,\n\t\t[...TServices, ...ServicesOf<T>],\n\t\tTLogger,\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: [...this._services, ...services],\n\t\t\t_constructs: idsOf(constructs, this._constructs),\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...ServicesOf<T>],\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\tservices<T extends Service[]>(\n\t\tservices: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tTMessage,\n\t\t[...TServices, ...T],\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_services: [...this._services, ...services] as unknown as TServices,\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...T],\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\tlogger<T extends Logger>(\n\t\tlogger: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tTMessage,\n\t\tTServices,\n\t\tT,\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 QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tT,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\t/**\n\t * The database the handler receives as `db`.\n\t *\n\t * A queue built from a worker already has the worker's, when the worker\n\t * named one with `.database(db)`; this replaces it — the edge as well as\n\t * the client — for a consumer that works against a different database.\n\t */\n\tdatabase<T, TDbName extends string>(\n\t\tsource: Consumable<TDbName, T> | Service<TDbName, T>,\n\t): QueueBuilder<TName, TMessage, TServices, TLogger, T, TDbName> {\n\t\treturn cloneWith(this, {\n\t\t\t_databaseService: serviceOf(source),\n\t\t\t...databaseEdges(\n\t\t\t\t{\n\t\t\t\t\tconstructs: this._constructs,\n\t\t\t\t\tedge: this._databaseEdge,\n\t\t\t\t\tservice: this._databaseService as Service | undefined,\n\t\t\t\t\tservices: this._services,\n\t\t\t\t},\n\t\t\t\tsource,\n\t\t\t),\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tT,\n\t\t\tTDbName\n\t\t>;\n\t}\n\n\t/** The typed message (job) payload the queue carries. */\n\tmessage<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tT,\n\t\tTServices,\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_messageSchema: schema as unknown as TMessage,\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tT,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\thandle(\n\t\tfn: QueueHandler<NonNullable<TMessage>, TServices, TLogger, TDatabase>,\n\t): Queue<\n\t\tTName,\n\t\tNonNullable<TMessage>,\n\t\tTServices,\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\tif (!this._name) throw new QueueNeedsName();\n\t\tif (!this._messageSchema) throw new QueueNeedsMessage(this._name);\n\n\t\tconst queue = new Queue<\n\t\t\tTName,\n\t\t\tNonNullable<TMessage>,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>(\n\t\t\tthis._name as TName,\n\t\t\tfn,\n\t\t\tthis._messageSchema as NonNullable<TMessage>,\n\t\t\tthis._timeout,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._batchSize,\n\t\t\tthis._fifo,\n\t\t\tthis._constructs,\n\t\t\tthis._databaseService,\n\t\t);\n\t\t// Which process runs the consumer: the worker it was built from.\n\t\tqueue.owner = this._owner;\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 queue;\n\t}\n}\n\n/** A queue built without a name — only reachable by building one by hand. */\nexport class QueueNeedsName extends Error {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"A queue needs a name: build it from a worker, worker.queue('Emails').\",\n\t\t);\n\t\tthis.name = 'QueueNeedsName';\n\t}\n}\n\n/** A queue whose message was never described. */\nexport class QueueNeedsMessage extends Error {\n\tconstructor(readonly queue: string) {\n\t\tsuper(\n\t\t\t`Queue '${queue}' has no message: call .message(schema) before .handle(), ` +\n\t\t\t\t'so its producers and its consumer agree on what it carries.',\n\t\t);\n\t\tthis.name = 'QueueNeedsMessage';\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAuBA,IAAa,eAAb,MAOE;CACD;CACA;CACA,WAAmB;CACnB;CACA;CACA,YAA+B,CAAC;;CAEhC,cAA+B,CAAC;CAChC,UAA2BA,0BAAAA;;CAE3B;;CAEA;;CAEA;;CAGA,MACC,MAQC;EACD,OAAOC,cAAAA,UAAU,MAAM,EAAE,OAAO,KAAK,CAAC;CAQvC;CAEA,QAAQ,SAAuB;EAC9B,OAAOA,cAAAA,UAAU,MAAM,EAAE,UAAU,QAAQ,CAAC;CAC7C;;CAGA,UAAU,WAAyB;EAClC,OAAOA,cAAAA,UAAU,MAAM,EAAE,YAAY,UAAU,CAAC;CACjD;;CAGA,KAAK,OAAO,MAAY;EACvB,OAAOA,cAAAA,UAAU,MAAM,EAAE,OAAO,KAAK,CAAC;CACvC;;;;;;;;;;;;CAaA,UACC,YAQC;EAQD,MAAM,WAAWC,4BAAAA,WAAW,UAAU;EAEtC,OAAOD,cAAAA,UAAU,MAAM;GACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAQ;GAC1C,aAAaE,4BAAAA,MAAM,YAAY,KAAK,WAAW;EAChD,CAAC;CAQF;CAEA,SACC,UAQC;EACD,OAAOF,cAAAA,UAAU,MAAM,EACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAQ,EAC3C,CAAC;CAQF;CAEA,OACC,QAQC;EACD,OAAOA,cAAAA,UAAU,MAAM,EACtB,SAAS,OACV,CAAC;CAQF;;;;;;;;CASA,SACC,QACgE;EAChE,OAAOA,cAAAA,UAAU,MAAM;GACtB,kBAAkBG,4BAAAA,UAAU,MAAM;GAClC,GAAGC,4BAAAA,cACF;IACC,YAAY,KAAK;IACjB,MAAM,KAAK;IACX,SAAS,KAAK;IACd,UAAU,KAAK;GAChB,GACA,MACD;EACD,CAAC;CAQF;;CAGA,QACC,QAQC;EACD,OAAOJ,cAAAA,UAAU,MAAM,EACtB,gBAAgB,OACjB,CAAC;CAQF;CAEA,OACC,IAQC;EACD,IAAI,CAAC,KAAK,OAAO,MAAM,IAAI,eAAe;EAC1C,IAAI,CAAC,KAAK,gBAAgB,MAAM,IAAI,kBAAkB,KAAK,KAAK;EAEhE,MAAM,QAAQ,IAAIK,cAAAA,MAQjB,KAAK,OACL,IACA,KAAK,gBACL,KAAK,UACL,KAAK,WACL,KAAK,SACL,KAAK,YACL,KAAK,OACL,KAAK,aACL,KAAK,gBACN;EAEA,MAAM,QAAQ,KAAK;EAQnB,OAAO;CACR;AACD;;AAGA,IAAa,iBAAb,cAAoC,MAAM;CACzC,cAAc;EACb,MACC,uEACD;EACA,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,oBAAb,cAAuC,MAAM;CACvB;CAArB,YAAY,OAAwB;EACnC,MACC,UAAU,MAAM,sHAEjB;EAJoB,KAAA,QAAA;EAKpB,KAAK,OAAO;CACb;AACD"}
1
+ {"version":3,"file":"QueueBuilder-BDcv9B71.cjs","names":["DEFAULT_LOGGER","cloneWith","servicesOf","idsOf","serviceOf","databaseEdges","Queue"],"sources":["../src/queue/QueueBuilder.ts"],"sourcesContent":["import type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { cloneWith } from '../clone';\nimport {\n\ttype Consumable,\n\tdatabaseEdges,\n\tidsOf,\n\ttype ServicesOf,\n\tserviceOf,\n\tservicesOf,\n} from '../construct-interface';\nimport { Queue, type QueueHandler } from './Queue';\n\n/**\n * Builds a {@link Queue} and its one consumer. Reached through\n * `worker.queue('orders')`, never constructed by hand: the worker stamps itself\n * as the owner. `message` is the typed job payload and `handle` the consumer.\n * The queue name is captured as a literal so `queue.service` publishes\n * `{ type: '<name>', payload }`. The handler's `db` is the worker's database\n * unless `.database(other)` names another.\n */\nexport class QueueBuilder<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> {\n\tprivate _name?: string;\n\tprivate _messageSchema?: TMessage;\n\tprivate _timeout = 30000;\n\tprivate _batchSize?: number;\n\tprivate _fifo?: boolean;\n\tprivate _services: TServices = [] as Service[] as TServices;\n\t/** The construct ids `.dependsOn()` named — what the manifest records. */\n\tpublic _constructs: string[] = [];\n\tprivate _logger: TLogger = DEFAULT_LOGGER as TLogger;\n\t/** The worker that runs this queue's consumer — stamped by `worker.queue()`. */\n\tpublic _owner?: string;\n\t/** What the handler's `db` comes from — the worker's, unless overridden. */\n\tprivate _databaseService?: Service<TDatabaseServiceName, TDatabase>;\n\t/** The edge `.database()` added, so the next one can replace it. */\n\tprivate _databaseEdge?: string;\n\n\t/** The queue name — drives the infra queue and its `<NAME>_*` env vars. */\n\tqueue<T extends string>(\n\t\tname: T,\n\t): QueueBuilder<\n\t\tT,\n\t\tTMessage,\n\t\tTServices,\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, { _name: name }) as unknown as QueueBuilder<\n\t\t\tT,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\ttimeout(timeout: number): this {\n\t\treturn cloneWith(this, { _timeout: timeout });\n\t}\n\n\t/** SQS event-source batch size (deployed). */\n\tbatchSize(batchSize: number): this {\n\t\treturn cloneWith(this, { _batchSize: batchSize });\n\t}\n\n\t/** Mark the queue as FIFO (deployed). */\n\tfifo(fifo = true): this {\n\t\treturn cloneWith(this, { _fifo: fifo });\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\tdependsOn<const T extends readonly Consumable[]>(\n\t\tconstructs: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tTMessage,\n\t\t[...TServices, ...ServicesOf<T>],\n\t\tTLogger,\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: [...this._services, ...services],\n\t\t\t_constructs: idsOf(constructs, this._constructs),\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...ServicesOf<T>],\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\tservices<T extends Service[]>(\n\t\tservices: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tTMessage,\n\t\t[...TServices, ...T],\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_services: [...this._services, ...services] as unknown as TServices,\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...T],\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\tlogger<T extends Logger>(\n\t\tlogger: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tTMessage,\n\t\tTServices,\n\t\tT,\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 QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tT,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\t/**\n\t * The database the handler receives as `db`.\n\t *\n\t * A queue built from a worker already has the worker's, when the worker\n\t * named one with `.database(db)`; this replaces it — the edge as well as\n\t * the client — for a consumer that works against a different database.\n\t */\n\tdatabase<T, TDbName extends string>(\n\t\tsource: Consumable<TDbName, T> | Service<TDbName, T>,\n\t): QueueBuilder<TName, TMessage, TServices, TLogger, T, TDbName> {\n\t\treturn cloneWith(this, {\n\t\t\t_databaseService: serviceOf(source),\n\t\t\t...databaseEdges(\n\t\t\t\t{\n\t\t\t\t\tconstructs: this._constructs,\n\t\t\t\t\tedge: this._databaseEdge,\n\t\t\t\t\tservice: this._databaseService as Service | undefined,\n\t\t\t\t\tservices: this._services,\n\t\t\t\t},\n\t\t\t\tsource,\n\t\t\t),\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tT,\n\t\t\tTDbName\n\t\t>;\n\t}\n\n\t/** The typed message (job) payload the queue carries. */\n\tmessage<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tT,\n\t\tTServices,\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_messageSchema: schema as unknown as TMessage,\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tT,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\thandle(\n\t\tfn: QueueHandler<NonNullable<TMessage>, TServices, TLogger, TDatabase>,\n\t): Queue<\n\t\tTName,\n\t\tNonNullable<TMessage>,\n\t\tTServices,\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\tif (!this._name) throw new QueueNeedsName();\n\t\tif (!this._messageSchema) throw new QueueNeedsMessage(this._name);\n\n\t\tconst queue = new Queue<\n\t\t\tTName,\n\t\t\tNonNullable<TMessage>,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>(\n\t\t\tthis._name as TName,\n\t\t\tfn,\n\t\t\tthis._messageSchema as NonNullable<TMessage>,\n\t\t\tthis._timeout,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._batchSize,\n\t\t\tthis._fifo,\n\t\t\tthis._constructs,\n\t\t\tthis._databaseService,\n\t\t);\n\t\t// Which process runs the consumer: the worker it was built from.\n\t\tqueue.owner = this._owner;\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 queue;\n\t}\n}\n\n/** A queue built without a name — only reachable by building one by hand. */\nexport class QueueNeedsName extends Error {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"A queue needs a name: build it from a worker, worker.queue('Emails').\",\n\t\t);\n\t\tthis.name = 'QueueNeedsName';\n\t}\n}\n\n/** A queue whose message was never described. */\nexport class QueueNeedsMessage extends Error {\n\tconstructor(readonly queue: string) {\n\t\tsuper(\n\t\t\t`Queue '${queue}' has no message: call .message(schema) before .handle(), ` +\n\t\t\t\t'so its producers and its consumer agree on what it carries.',\n\t\t);\n\t\tthis.name = 'QueueNeedsMessage';\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAuBA,IAAa,eAAb,MAOE;CACD;CACA;CACA,WAAmB;CACnB;CACA;CACA,YAA+B,CAAC;;CAEhC,cAA+B,CAAC;CAChC,UAA2BA,0BAAAA;;CAE3B;;CAEA;;CAEA;;CAGA,MACC,MAQC;EACD,OAAOC,cAAAA,UAAU,MAAM,EAAE,OAAO,KAAK,CAAC;CAQvC;CAEA,QAAQ,SAAuB;EAC9B,OAAOA,cAAAA,UAAU,MAAM,EAAE,UAAU,QAAQ,CAAC;CAC7C;;CAGA,UAAU,WAAyB;EAClC,OAAOA,cAAAA,UAAU,MAAM,EAAE,YAAY,UAAU,CAAC;CACjD;;CAGA,KAAK,OAAO,MAAY;EACvB,OAAOA,cAAAA,UAAU,MAAM,EAAE,OAAO,KAAK,CAAC;CACvC;;;;;;;;;;;;CAaA,UACC,YAQC;EAQD,MAAM,WAAWC,4BAAAA,WAAW,UAAU;EAEtC,OAAOD,cAAAA,UAAU,MAAM;GACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAQ;GAC1C,aAAaE,4BAAAA,MAAM,YAAY,KAAK,WAAW;EAChD,CAAC;CAQF;CAEA,SACC,UAQC;EACD,OAAOF,cAAAA,UAAU,MAAM,EACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAQ,EAC3C,CAAC;CAQF;CAEA,OACC,QAQC;EACD,OAAOA,cAAAA,UAAU,MAAM,EACtB,SAAS,OACV,CAAC;CAQF;;;;;;;;CASA,SACC,QACgE;EAChE,OAAOA,cAAAA,UAAU,MAAM;GACtB,kBAAkBG,4BAAAA,UAAU,MAAM;GAClC,GAAGC,4BAAAA,cACF;IACC,YAAY,KAAK;IACjB,MAAM,KAAK;IACX,SAAS,KAAK;IACd,UAAU,KAAK;GAChB,GACA,MACD;EACD,CAAC;CAQF;;CAGA,QACC,QAQC;EACD,OAAOJ,cAAAA,UAAU,MAAM,EACtB,gBAAgB,OACjB,CAAC;CAQF;CAEA,OACC,IAQC;EACD,IAAI,CAAC,KAAK,OAAO,MAAM,IAAI,eAAe;EAC1C,IAAI,CAAC,KAAK,gBAAgB,MAAM,IAAI,kBAAkB,KAAK,KAAK;EAEhE,MAAM,QAAQ,IAAIK,cAAAA,MAQjB,KAAK,OACL,IACA,KAAK,gBACL,KAAK,UACL,KAAK,WACL,KAAK,SACL,KAAK,YACL,KAAK,OACL,KAAK,aACL,KAAK,gBACN;EAEA,MAAM,QAAQ,KAAK;EAQnB,OAAO;CACR;AACD;;AAGA,IAAa,iBAAb,cAAoC,MAAM;CACzC,cAAc;EACb,MACC,uEACD;EACA,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,oBAAb,cAAuC,MAAM;CACvB;CAArB,YAAY,OAAwB;EACnC,MACC,UAAU,MAAM,sHAEjB;EAJoB,KAAA,QAAA;EAKpB,KAAK,OAAO;CACb;AACD"}
@@ -1,5 +1,5 @@
1
1
  import { n as StandardSchemaV1 } from "./index-DdRjYhiJ.mjs";
2
- import { c as ServicesOf, r as Consumable } from "./construct-interface-CSA9VeWM.mjs";
2
+ import { l as ServicesOf, r as Consumable } from "./construct-interface-DxfkFxkl.mjs";
3
3
  import { r as QueueHandler, t as Queue } from "./Queue-B8HGg439.mjs";
4
4
  import { Service } from "@geekmidas/services";
5
5
  import { Logger } from "@geekmidas/logger";
@@ -72,4 +72,4 @@ declare class QueueNeedsMessage extends Error {
72
72
  }
73
73
  //#endregion
74
74
  export { QueueNeedsMessage as n, QueueNeedsName as r, QueueBuilder as t };
75
- //# sourceMappingURL=QueueBuilder-CVS_qPuo.d.mts.map
75
+ //# sourceMappingURL=QueueBuilder-CUERv8jt.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"QueueBuilder-CVS_qPuo.d.mts","names":[],"sources":["../src/queue/QueueBuilder.ts"],"mappings":";;;;;;;;;;;;;;cAuBa,aACZ,+BACA,iBAAiB,0CACjB,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB,uBACA;UAEQ;UACA;UACA;UACA;UACA;UACA;;EAED;UACC;;EAED;;UAEC;;UAEA;;EAGR,MAAM,kBACL,MAAM,IACJ,aACF,GACA,UACA,WACA,SACA,WACA;EAYD,QAAQ;;EAKR,UAAU;;EAKV,KAAK;;;;;;;;;;;;EAeL,gBAAgB,mBAAmB,cAClC,YAAY,IACV,aACF,OACA,cACI,cAAc,WAAW,KAC7B,SACA,WACA;EAwBD,SAAS,UAAU,WAClB,UAAU,IACR,aACF,OACA,cACI,cAAc,IAClB,SACA,WACA;EAcD,OAAO,UAAU,QAChB,QAAQ,IACN,aACF,OACA,UACA,WACA,GACA,WACA;;;;;;;;EAqBD,SAAS,GAAG,wBACX,QAAQ,WAAW,SAAS,KAAK,QAAQ,SAAS,KAChD,aAAa,OAAO,UAAU,WAAW,SAAS,GAAG;;EAuBxD,QAAQ,UAAU,kBACjB,QAAQ,IACN,aACF,OACA,GACA,WACA,SACA,WACA;EAcD,OACC,IAAI,aAAa,YAAY,WAAW,WAAW,SAAS,aAC1D,MACF,OACA,YAAY,WACZ,WACA,SACA,WACA;;;cAsCW,uBAAuB;EACnC;;;cASY,0BAA0B;WACjB;EAArB,YAAqB"}
1
+ {"version":3,"file":"QueueBuilder-CUERv8jt.d.mts","names":[],"sources":["../src/queue/QueueBuilder.ts"],"mappings":";;;;;;;;;;;;;;cAuBa,aACZ,+BACA,iBAAiB,0CACjB,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB,uBACA;UAEQ;UACA;UACA;UACA;UACA;UACA;;EAED;UACC;;EAED;;UAEC;;UAEA;;EAGR,MAAM,kBACL,MAAM,IACJ,aACF,GACA,UACA,WACA,SACA,WACA;EAYD,QAAQ;;EAKR,UAAU;;EAKV,KAAK;;;;;;;;;;;;EAeL,gBAAgB,mBAAmB,cAClC,YAAY,IACV,aACF,OACA,cACI,cAAc,WAAW,KAC7B,SACA,WACA;EAwBD,SAAS,UAAU,WAClB,UAAU,IACR,aACF,OACA,cACI,cAAc,IAClB,SACA,WACA;EAcD,OAAO,UAAU,QAChB,QAAQ,IACN,aACF,OACA,UACA,WACA,GACA,WACA;;;;;;;;EAqBD,SAAS,GAAG,wBACX,QAAQ,WAAW,SAAS,KAAK,QAAQ,SAAS,KAChD,aAAa,OAAO,UAAU,WAAW,SAAS,GAAG;;EAuBxD,QAAQ,UAAU,kBACjB,QAAQ,IACN,aACF,OACA,GACA,WACA,SACA,WACA;EAcD,OACC,IAAI,aAAa,YAAY,WAAW,WAAW,SAAS,aAC1D,MACF,OACA,YAAY,WACZ,WACA,SACA,WACA;;;cAsCW,uBAAuB;EACnC;;;cASY,0BAA0B;WACjB;EAArB,YAAqB"}
@@ -1,5 +1,5 @@
1
1
  import { n as StandardSchemaV1 } from "./index-DdRjYhiJ.cjs";
2
- import { c as ServicesOf, r as Consumable } from "./construct-interface-DugP0E5q.cjs";
2
+ import { l as ServicesOf, r as Consumable } from "./construct-interface-DhbaONW2.cjs";
3
3
  import { r as QueueHandler, t as Queue } from "./Queue-C4rijiM7.cjs";
4
4
  import { Logger } from "@geekmidas/logger";
5
5
  import { Service } from "@geekmidas/services";
@@ -72,4 +72,4 @@ declare class QueueNeedsMessage extends Error {
72
72
  }
73
73
  //#endregion
74
74
  export { QueueNeedsMessage as n, QueueNeedsName as r, QueueBuilder as t };
75
- //# sourceMappingURL=QueueBuilder-SQli59An.d.cts.map
75
+ //# sourceMappingURL=QueueBuilder-CmB1vOgn.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"QueueBuilder-SQli59An.d.cts","names":[],"sources":["../src/queue/QueueBuilder.ts"],"mappings":";;;;;;;;;;;;;;cAuBa,aACZ,+BACA,iBAAiB,0CACjB,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB,uBACA;UAEQ;UACA;UACA;UACA;UACA;UACA;;EAED;UACC;;EAED;;UAEC;;UAEA;;EAGR,MAAM,kBACL,MAAM,IACJ,aACF,GACA,UACA,WACA,SACA,WACA;EAYD,QAAQ;;EAKR,UAAU;;EAKV,KAAK;;;;;;;;;;;;EAeL,gBAAgB,mBAAmB,cAClC,YAAY,IACV,aACF,OACA,cACI,cAAc,WAAW,KAC7B,SACA,WACA;EAwBD,SAAS,UAAU,WAClB,UAAU,IACR,aACF,OACA,cACI,cAAc,IAClB,SACA,WACA;EAcD,OAAO,UAAU,QAChB,QAAQ,IACN,aACF,OACA,UACA,WACA,GACA,WACA;;;;;;;;EAqBD,SAAS,GAAG,wBACX,QAAQ,WAAW,SAAS,KAAK,QAAQ,SAAS,KAChD,aAAa,OAAO,UAAU,WAAW,SAAS,GAAG;;EAuBxD,QAAQ,UAAU,kBACjB,QAAQ,IACN,aACF,OACA,GACA,WACA,SACA,WACA;EAcD,OACC,IAAI,aAAa,YAAY,WAAW,WAAW,SAAS,aAC1D,MACF,OACA,YAAY,WACZ,WACA,SACA,WACA;;;cAsCW,uBAAuB;EACnC;;;cASY,0BAA0B;WACjB;EAArB,YAAqB"}
1
+ {"version":3,"file":"QueueBuilder-CmB1vOgn.d.cts","names":[],"sources":["../src/queue/QueueBuilder.ts"],"mappings":";;;;;;;;;;;;;;cAuBa,aACZ,+BACA,iBAAiB,0CACjB,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB,uBACA;UAEQ;UACA;UACA;UACA;UACA;UACA;;EAED;UACC;;EAED;;UAEC;;UAEA;;EAGR,MAAM,kBACL,MAAM,IACJ,aACF,GACA,UACA,WACA,SACA,WACA;EAYD,QAAQ;;EAKR,UAAU;;EAKV,KAAK;;;;;;;;;;;;EAeL,gBAAgB,mBAAmB,cAClC,YAAY,IACV,aACF,OACA,cACI,cAAc,WAAW,KAC7B,SACA,WACA;EAwBD,SAAS,UAAU,WAClB,UAAU,IACR,aACF,OACA,cACI,cAAc,IAClB,SACA,WACA;EAcD,OAAO,UAAU,QAChB,QAAQ,IACN,aACF,OACA,UACA,WACA,GACA,WACA;;;;;;;;EAqBD,SAAS,GAAG,wBACX,QAAQ,WAAW,SAAS,KAAK,QAAQ,SAAS,KAChD,aAAa,OAAO,UAAU,WAAW,SAAS,GAAG;;EAuBxD,QAAQ,UAAU,kBACjB,QAAQ,IACN,aACF,OACA,GACA,WACA,SACA,WACA;EAcD,OACC,IAAI,aAAa,YAAY,WAAW,WAAW,SAAS,aAC1D,MACF,OACA,YAAY,WACZ,WACA,SACA,WACA;;;cAsCW,uBAAuB;EACnC;;;cASY,0BAA0B;WACjB;EAArB,YAAqB"}
@@ -1,6 +1,6 @@
1
1
  import { databaseEdges, idsOf, serviceOf, servicesOf } from "./construct-interface.mjs";
2
2
  import { t as cloneWith } from "./clone-EKNovYHu.mjs";
3
- import { t as Queue } from "./Queue-u8w8_HpE.mjs";
3
+ import { t as Queue } from "./Queue-9Hh20ZCk.mjs";
4
4
  import { DEFAULT_LOGGER } from "@geekmidas/logger/console";
5
5
  //#region src/queue/QueueBuilder.ts
6
6
  /**
@@ -115,4 +115,4 @@ var QueueNeedsMessage = class extends Error {
115
115
  //#endregion
116
116
  export { QueueNeedsMessage as n, QueueNeedsName as r, QueueBuilder as t };
117
117
 
118
- //# sourceMappingURL=QueueBuilder-2wP5lEC8.mjs.map
118
+ //# sourceMappingURL=QueueBuilder-CrZL8HHs.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"QueueBuilder-2wP5lEC8.mjs","names":[],"sources":["../src/queue/QueueBuilder.ts"],"sourcesContent":["import type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { cloneWith } from '../clone';\nimport {\n\ttype Consumable,\n\tdatabaseEdges,\n\tidsOf,\n\ttype ServicesOf,\n\tserviceOf,\n\tservicesOf,\n} from '../construct-interface';\nimport { Queue, type QueueHandler } from './Queue';\n\n/**\n * Builds a {@link Queue} and its one consumer. Reached through\n * `worker.queue('orders')`, never constructed by hand: the worker stamps itself\n * as the owner. `message` is the typed job payload and `handle` the consumer.\n * The queue name is captured as a literal so `queue.service` publishes\n * `{ type: '<name>', payload }`. The handler's `db` is the worker's database\n * unless `.database(other)` names another.\n */\nexport class QueueBuilder<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> {\n\tprivate _name?: string;\n\tprivate _messageSchema?: TMessage;\n\tprivate _timeout = 30000;\n\tprivate _batchSize?: number;\n\tprivate _fifo?: boolean;\n\tprivate _services: TServices = [] as Service[] as TServices;\n\t/** The construct ids `.dependsOn()` named — what the manifest records. */\n\tpublic _constructs: string[] = [];\n\tprivate _logger: TLogger = DEFAULT_LOGGER as TLogger;\n\t/** The worker that runs this queue's consumer — stamped by `worker.queue()`. */\n\tpublic _owner?: string;\n\t/** What the handler's `db` comes from — the worker's, unless overridden. */\n\tprivate _databaseService?: Service<TDatabaseServiceName, TDatabase>;\n\t/** The edge `.database()` added, so the next one can replace it. */\n\tprivate _databaseEdge?: string;\n\n\t/** The queue name — drives the infra queue and its `<NAME>_*` env vars. */\n\tqueue<T extends string>(\n\t\tname: T,\n\t): QueueBuilder<\n\t\tT,\n\t\tTMessage,\n\t\tTServices,\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, { _name: name }) as unknown as QueueBuilder<\n\t\t\tT,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\ttimeout(timeout: number): this {\n\t\treturn cloneWith(this, { _timeout: timeout });\n\t}\n\n\t/** SQS event-source batch size (deployed). */\n\tbatchSize(batchSize: number): this {\n\t\treturn cloneWith(this, { _batchSize: batchSize });\n\t}\n\n\t/** Mark the queue as FIFO (deployed). */\n\tfifo(fifo = true): this {\n\t\treturn cloneWith(this, { _fifo: fifo });\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\tdependsOn<const T extends readonly Consumable[]>(\n\t\tconstructs: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tTMessage,\n\t\t[...TServices, ...ServicesOf<T>],\n\t\tTLogger,\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: [...this._services, ...services],\n\t\t\t_constructs: idsOf(constructs, this._constructs),\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...ServicesOf<T>],\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\tservices<T extends Service[]>(\n\t\tservices: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tTMessage,\n\t\t[...TServices, ...T],\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_services: [...this._services, ...services] as unknown as TServices,\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...T],\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\tlogger<T extends Logger>(\n\t\tlogger: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tTMessage,\n\t\tTServices,\n\t\tT,\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 QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tT,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\t/**\n\t * The database the handler receives as `db`.\n\t *\n\t * A queue built from a worker already has the worker's, when the worker\n\t * named one with `.database(db)`; this replaces it — the edge as well as\n\t * the client — for a consumer that works against a different database.\n\t */\n\tdatabase<T, TDbName extends string>(\n\t\tsource: Consumable<TDbName, T> | Service<TDbName, T>,\n\t): QueueBuilder<TName, TMessage, TServices, TLogger, T, TDbName> {\n\t\treturn cloneWith(this, {\n\t\t\t_databaseService: serviceOf(source),\n\t\t\t...databaseEdges(\n\t\t\t\t{\n\t\t\t\t\tconstructs: this._constructs,\n\t\t\t\t\tedge: this._databaseEdge,\n\t\t\t\t\tservice: this._databaseService as Service | undefined,\n\t\t\t\t\tservices: this._services,\n\t\t\t\t},\n\t\t\t\tsource,\n\t\t\t),\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tT,\n\t\t\tTDbName\n\t\t>;\n\t}\n\n\t/** The typed message (job) payload the queue carries. */\n\tmessage<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tT,\n\t\tTServices,\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_messageSchema: schema as unknown as TMessage,\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tT,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\thandle(\n\t\tfn: QueueHandler<NonNullable<TMessage>, TServices, TLogger, TDatabase>,\n\t): Queue<\n\t\tTName,\n\t\tNonNullable<TMessage>,\n\t\tTServices,\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\tif (!this._name) throw new QueueNeedsName();\n\t\tif (!this._messageSchema) throw new QueueNeedsMessage(this._name);\n\n\t\tconst queue = new Queue<\n\t\t\tTName,\n\t\t\tNonNullable<TMessage>,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>(\n\t\t\tthis._name as TName,\n\t\t\tfn,\n\t\t\tthis._messageSchema as NonNullable<TMessage>,\n\t\t\tthis._timeout,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._batchSize,\n\t\t\tthis._fifo,\n\t\t\tthis._constructs,\n\t\t\tthis._databaseService,\n\t\t);\n\t\t// Which process runs the consumer: the worker it was built from.\n\t\tqueue.owner = this._owner;\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 queue;\n\t}\n}\n\n/** A queue built without a name — only reachable by building one by hand. */\nexport class QueueNeedsName extends Error {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"A queue needs a name: build it from a worker, worker.queue('Emails').\",\n\t\t);\n\t\tthis.name = 'QueueNeedsName';\n\t}\n}\n\n/** A queue whose message was never described. */\nexport class QueueNeedsMessage extends Error {\n\tconstructor(readonly queue: string) {\n\t\tsuper(\n\t\t\t`Queue '${queue}' has no message: call .message(schema) before .handle(), ` +\n\t\t\t\t'so its producers and its consumer agree on what it carries.',\n\t\t);\n\t\tthis.name = 'QueueNeedsMessage';\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAuBA,IAAa,eAAb,MAOE;CACD;CACA;CACA,WAAmB;CACnB;CACA;CACA,YAA+B,CAAC;;CAEhC,cAA+B,CAAC;CAChC,UAA2B;;CAE3B;;CAEA;;CAEA;;CAGA,MACC,MAQC;EACD,OAAO,UAAU,MAAM,EAAE,OAAO,KAAK,CAAC;CAQvC;CAEA,QAAQ,SAAuB;EAC9B,OAAO,UAAU,MAAM,EAAE,UAAU,QAAQ,CAAC;CAC7C;;CAGA,UAAU,WAAyB;EAClC,OAAO,UAAU,MAAM,EAAE,YAAY,UAAU,CAAC;CACjD;;CAGA,KAAK,OAAO,MAAY;EACvB,OAAO,UAAU,MAAM,EAAE,OAAO,KAAK,CAAC;CACvC;;;;;;;;;;;;CAaA,UACC,YAQC;EAQD,MAAM,WAAW,WAAW,UAAU;EAEtC,OAAO,UAAU,MAAM;GACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAQ;GAC1C,aAAa,MAAM,YAAY,KAAK,WAAW;EAChD,CAAC;CAQF;CAEA,SACC,UAQC;EACD,OAAO,UAAU,MAAM,EACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAQ,EAC3C,CAAC;CAQF;CAEA,OACC,QAQC;EACD,OAAO,UAAU,MAAM,EACtB,SAAS,OACV,CAAC;CAQF;;;;;;;;CASA,SACC,QACgE;EAChE,OAAO,UAAU,MAAM;GACtB,kBAAkB,UAAU,MAAM;GAClC,GAAG,cACF;IACC,YAAY,KAAK;IACjB,MAAM,KAAK;IACX,SAAS,KAAK;IACd,UAAU,KAAK;GAChB,GACA,MACD;EACD,CAAC;CAQF;;CAGA,QACC,QAQC;EACD,OAAO,UAAU,MAAM,EACtB,gBAAgB,OACjB,CAAC;CAQF;CAEA,OACC,IAQC;EACD,IAAI,CAAC,KAAK,OAAO,MAAM,IAAI,eAAe;EAC1C,IAAI,CAAC,KAAK,gBAAgB,MAAM,IAAI,kBAAkB,KAAK,KAAK;EAEhE,MAAM,QAAQ,IAAI,MAQjB,KAAK,OACL,IACA,KAAK,gBACL,KAAK,UACL,KAAK,WACL,KAAK,SACL,KAAK,YACL,KAAK,OACL,KAAK,aACL,KAAK,gBACN;EAEA,MAAM,QAAQ,KAAK;EAQnB,OAAO;CACR;AACD;;AAGA,IAAa,iBAAb,cAAoC,MAAM;CACzC,cAAc;EACb,MACC,uEACD;EACA,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,oBAAb,cAAuC,MAAM;CACvB;CAArB,YAAY,OAAwB;EACnC,MACC,UAAU,MAAM,sHAEjB;EAJoB,KAAA,QAAA;EAKpB,KAAK,OAAO;CACb;AACD"}
1
+ {"version":3,"file":"QueueBuilder-CrZL8HHs.mjs","names":[],"sources":["../src/queue/QueueBuilder.ts"],"sourcesContent":["import type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { cloneWith } from '../clone';\nimport {\n\ttype Consumable,\n\tdatabaseEdges,\n\tidsOf,\n\ttype ServicesOf,\n\tserviceOf,\n\tservicesOf,\n} from '../construct-interface';\nimport { Queue, type QueueHandler } from './Queue';\n\n/**\n * Builds a {@link Queue} and its one consumer. Reached through\n * `worker.queue('orders')`, never constructed by hand: the worker stamps itself\n * as the owner. `message` is the typed job payload and `handle` the consumer.\n * The queue name is captured as a literal so `queue.service` publishes\n * `{ type: '<name>', payload }`. The handler's `db` is the worker's database\n * unless `.database(other)` names another.\n */\nexport class QueueBuilder<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> {\n\tprivate _name?: string;\n\tprivate _messageSchema?: TMessage;\n\tprivate _timeout = 30000;\n\tprivate _batchSize?: number;\n\tprivate _fifo?: boolean;\n\tprivate _services: TServices = [] as Service[] as TServices;\n\t/** The construct ids `.dependsOn()` named — what the manifest records. */\n\tpublic _constructs: string[] = [];\n\tprivate _logger: TLogger = DEFAULT_LOGGER as TLogger;\n\t/** The worker that runs this queue's consumer — stamped by `worker.queue()`. */\n\tpublic _owner?: string;\n\t/** What the handler's `db` comes from — the worker's, unless overridden. */\n\tprivate _databaseService?: Service<TDatabaseServiceName, TDatabase>;\n\t/** The edge `.database()` added, so the next one can replace it. */\n\tprivate _databaseEdge?: string;\n\n\t/** The queue name — drives the infra queue and its `<NAME>_*` env vars. */\n\tqueue<T extends string>(\n\t\tname: T,\n\t): QueueBuilder<\n\t\tT,\n\t\tTMessage,\n\t\tTServices,\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, { _name: name }) as unknown as QueueBuilder<\n\t\t\tT,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\ttimeout(timeout: number): this {\n\t\treturn cloneWith(this, { _timeout: timeout });\n\t}\n\n\t/** SQS event-source batch size (deployed). */\n\tbatchSize(batchSize: number): this {\n\t\treturn cloneWith(this, { _batchSize: batchSize });\n\t}\n\n\t/** Mark the queue as FIFO (deployed). */\n\tfifo(fifo = true): this {\n\t\treturn cloneWith(this, { _fifo: fifo });\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\tdependsOn<const T extends readonly Consumable[]>(\n\t\tconstructs: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tTMessage,\n\t\t[...TServices, ...ServicesOf<T>],\n\t\tTLogger,\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: [...this._services, ...services],\n\t\t\t_constructs: idsOf(constructs, this._constructs),\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...ServicesOf<T>],\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\tservices<T extends Service[]>(\n\t\tservices: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tTMessage,\n\t\t[...TServices, ...T],\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_services: [...this._services, ...services] as unknown as TServices,\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...T],\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\tlogger<T extends Logger>(\n\t\tlogger: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tTMessage,\n\t\tTServices,\n\t\tT,\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 QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tT,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\t/**\n\t * The database the handler receives as `db`.\n\t *\n\t * A queue built from a worker already has the worker's, when the worker\n\t * named one with `.database(db)`; this replaces it — the edge as well as\n\t * the client — for a consumer that works against a different database.\n\t */\n\tdatabase<T, TDbName extends string>(\n\t\tsource: Consumable<TDbName, T> | Service<TDbName, T>,\n\t): QueueBuilder<TName, TMessage, TServices, TLogger, T, TDbName> {\n\t\treturn cloneWith(this, {\n\t\t\t_databaseService: serviceOf(source),\n\t\t\t...databaseEdges(\n\t\t\t\t{\n\t\t\t\t\tconstructs: this._constructs,\n\t\t\t\t\tedge: this._databaseEdge,\n\t\t\t\t\tservice: this._databaseService as Service | undefined,\n\t\t\t\t\tservices: this._services,\n\t\t\t\t},\n\t\t\t\tsource,\n\t\t\t),\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tT,\n\t\t\tTDbName\n\t\t>;\n\t}\n\n\t/** The typed message (job) payload the queue carries. */\n\tmessage<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tT,\n\t\tTServices,\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_messageSchema: schema as unknown as TMessage,\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tT,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\thandle(\n\t\tfn: QueueHandler<NonNullable<TMessage>, TServices, TLogger, TDatabase>,\n\t): Queue<\n\t\tTName,\n\t\tNonNullable<TMessage>,\n\t\tTServices,\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\tif (!this._name) throw new QueueNeedsName();\n\t\tif (!this._messageSchema) throw new QueueNeedsMessage(this._name);\n\n\t\tconst queue = new Queue<\n\t\t\tTName,\n\t\t\tNonNullable<TMessage>,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>(\n\t\t\tthis._name as TName,\n\t\t\tfn,\n\t\t\tthis._messageSchema as NonNullable<TMessage>,\n\t\t\tthis._timeout,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._batchSize,\n\t\t\tthis._fifo,\n\t\t\tthis._constructs,\n\t\t\tthis._databaseService,\n\t\t);\n\t\t// Which process runs the consumer: the worker it was built from.\n\t\tqueue.owner = this._owner;\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 queue;\n\t}\n}\n\n/** A queue built without a name — only reachable by building one by hand. */\nexport class QueueNeedsName extends Error {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"A queue needs a name: build it from a worker, worker.queue('Emails').\",\n\t\t);\n\t\tthis.name = 'QueueNeedsName';\n\t}\n}\n\n/** A queue whose message was never described. */\nexport class QueueNeedsMessage extends Error {\n\tconstructor(readonly queue: string) {\n\t\tsuper(\n\t\t\t`Queue '${queue}' has no message: call .message(schema) before .handle(), ` +\n\t\t\t\t'so its producers and its consumer agree on what it carries.',\n\t\t);\n\t\tthis.name = 'QueueNeedsMessage';\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAuBA,IAAa,eAAb,MAOE;CACD;CACA;CACA,WAAmB;CACnB;CACA;CACA,YAA+B,CAAC;;CAEhC,cAA+B,CAAC;CAChC,UAA2B;;CAE3B;;CAEA;;CAEA;;CAGA,MACC,MAQC;EACD,OAAO,UAAU,MAAM,EAAE,OAAO,KAAK,CAAC;CAQvC;CAEA,QAAQ,SAAuB;EAC9B,OAAO,UAAU,MAAM,EAAE,UAAU,QAAQ,CAAC;CAC7C;;CAGA,UAAU,WAAyB;EAClC,OAAO,UAAU,MAAM,EAAE,YAAY,UAAU,CAAC;CACjD;;CAGA,KAAK,OAAO,MAAY;EACvB,OAAO,UAAU,MAAM,EAAE,OAAO,KAAK,CAAC;CACvC;;;;;;;;;;;;CAaA,UACC,YAQC;EAQD,MAAM,WAAW,WAAW,UAAU;EAEtC,OAAO,UAAU,MAAM;GACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAQ;GAC1C,aAAa,MAAM,YAAY,KAAK,WAAW;EAChD,CAAC;CAQF;CAEA,SACC,UAQC;EACD,OAAO,UAAU,MAAM,EACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAQ,EAC3C,CAAC;CAQF;CAEA,OACC,QAQC;EACD,OAAO,UAAU,MAAM,EACtB,SAAS,OACV,CAAC;CAQF;;;;;;;;CASA,SACC,QACgE;EAChE,OAAO,UAAU,MAAM;GACtB,kBAAkB,UAAU,MAAM;GAClC,GAAG,cACF;IACC,YAAY,KAAK;IACjB,MAAM,KAAK;IACX,SAAS,KAAK;IACd,UAAU,KAAK;GAChB,GACA,MACD;EACD,CAAC;CAQF;;CAGA,QACC,QAQC;EACD,OAAO,UAAU,MAAM,EACtB,gBAAgB,OACjB,CAAC;CAQF;CAEA,OACC,IAQC;EACD,IAAI,CAAC,KAAK,OAAO,MAAM,IAAI,eAAe;EAC1C,IAAI,CAAC,KAAK,gBAAgB,MAAM,IAAI,kBAAkB,KAAK,KAAK;EAEhE,MAAM,QAAQ,IAAI,MAQjB,KAAK,OACL,IACA,KAAK,gBACL,KAAK,UACL,KAAK,WACL,KAAK,SACL,KAAK,YACL,KAAK,OACL,KAAK,aACL,KAAK,gBACN;EAEA,MAAM,QAAQ,KAAK;EAQnB,OAAO;CACR;AACD;;AAGA,IAAa,iBAAb,cAAoC,MAAM;CACzC,cAAc;EACb,MACC,uEACD;EACA,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,oBAAb,cAAuC,MAAM;CACvB;CAArB,YAAY,OAAwB;EACnC,MACC,UAAU,MAAM,sHAEjB;EAJoB,KAAA,QAAA;EAKpB,KAAK,OAAO;CACb;AACD"}
@@ -1,5 +1,5 @@
1
1
  import { t as Construct } from "./Construct-CGuc_Ijk.mjs";
2
- import { canonicalId, provideKey, serviceKey } from "@geekmidas/manifest";
2
+ import { canonicalId, providedKeyFor, serviceKey } from "@geekmidas/manifest";
3
3
  import { DEFAULT_LOGGER } from "@geekmidas/logger/console";
4
4
  import { Publisher } from "@geekmidas/events";
5
5
  //#region src/topic/Topic.ts
@@ -61,7 +61,7 @@ var Topic = class extends Construct {
61
61
  this.name = name;
62
62
  this.id = canonicalId(name);
63
63
  this.eventSchemas = options.events;
64
- this.connectionKey = provideKey(this.id, "publisherConnectionString");
64
+ this.connectionKey = providedKeyFor(this.id, "topic", "publisherConnectionString");
65
65
  const envVar = this.connectionKey;
66
66
  const topic = this.name;
67
67
  this.service = {
@@ -96,4 +96,4 @@ var Topic = class extends Construct {
96
96
  //#endregion
97
97
  export { Topic as t };
98
98
 
99
- //# sourceMappingURL=Topic-DN2gYJ-p.mjs.map
99
+ //# sourceMappingURL=Topic-BGoOeCT6.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Topic-BGoOeCT6.mjs","names":[],"sources":["../src/topic/Topic.ts"],"sourcesContent":["import {\n\ttype EventPublisher,\n\ttype EventPublisherConnectionString,\n\ttype PublishableMessage,\n\tPublisher,\n} from '@geekmidas/events';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovidedKeyFor,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Construct, ConstructType } from '../Construct';\n\n/** A topic's event contract — a map of event type → payload schema. */\nexport type TopicEvents = Record<string, StandardSchemaV1>;\n\n/**\n * The union of wire messages a topic carries, derived from its event map:\n * `{ type: 'user.created'; payload: … } | { type: 'user.updated'; payload: … }`.\n */\nexport type TopicMessage<TEvents extends TopicEvents> = {\n\t[K in keyof TEvents & string]: PublishableMessage<\n\t\tK,\n\t\tInferStandardSchema<TEvents[K]>\n\t>;\n}[keyof TEvents & string];\n\n/**\n * A topic — pub/sub fan-out. Unlike a `Queue` (point-to-point, one consumer), a\n * topic is a *resource* owned by no single handler: it declares the event\n * contract, and any number of subscribers (`worker.topic(topic)`) bind to it.\n * `gkm build` discovers it into the manifest's `topics` field; infra provisions\n * an SNS topic.\n *\n * A construct publishes with `.event(topic, { type, payload })`, repeatable\n * across topics, each event going through its own topic's publisher. That also\n * puts `services.<topic>` in the handler, as `.dependsOn([topic])` does, for an\n * event the handler decides on itself.\n *\n * ```ts\n * export const users = new Topic('Users', {\n * events: { 'user.created': z.object({ userId: z.string() }) },\n * });\n * ```\n */\nexport class Topic<\n\tTName extends string = string,\n\tTEvents extends TopicEvents = TopicEvents,\n> extends Construct {\n\t__IS_TOPIC__ = true;\n\n\tstatic isTopic(obj: unknown): obj is Topic<string, TopicEvents> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as { __IS_TOPIC__?: boolean }).__IS_TOPIC__ === true &&\n\t\t\t\t(obj as Construct).type === ConstructType.Topic,\n\t\t);\n\t}\n\n\t/**\n\t * The canonical id this topic is declared under.\n\t *\n\t * Derived from the name, so `users` and `Users` are one topic. The name is\n\t * left alone: subscribers bind to it and it is what the broker routes on.\n\t */\n\treadonly id: string;\n\n\t/** The name it was declared with — what the broker routes on. */\n\treadonly name: TName;\n\n\t/**\n\t * The event contract — a map of event type → payload schema. Named\n\t * `eventSchemas` (not `events`) to avoid clashing with `Construct.events`,\n\t * which is the array of `MappedEvent`s a construct *publishes*.\n\t */\n\treadonly eventSchemas: TEvents;\n\n\t/**\n\t * The topic as a dependency — what `.dependsOn([users])` and\n\t * `.event(users, …)` dissolve into, reachable as `services.users`.\n\t *\n\t * The producer, because publishing is the only thing depending on a topic\n\t * can mean: a subscriber binds to the topic instead, and is never handed\n\t * this. It reads `<NAME>_PUBLISHER_CONNECTION_STRING` and picks the\n\t * transport from its protocol — `pgboss://` locally, `sns://` deployed.\n\t *\n\t * A field assigned once, not a getter: services are cached by object\n\t * identity, and a fresh literal on every access never hit that cache.\n\t */\n\treadonly service: Service<\n\t\tUncapitalize<TName>,\n\t\tEventPublisher<TopicMessage<TEvents>>\n\t>;\n\n\t/** The producer's env key, read by both {@link declare} and the service. */\n\tprivate readonly connectionKey: string;\n\n\tconstructor(name: ConstructName<TName>, options: TopicOptions<TEvents>) {\n\t\tsuper(ConstructType.Topic, DEFAULT_LOGGER, [], []);\n\n\t\tthis.name = name as TName;\n\t\tthis.id = canonicalId(name as string);\n\t\tthis.eventSchemas = options.events;\n\t\tthis.connectionKey = providedKeyFor(\n\t\t\tthis.id,\n\t\t\t'topic',\n\t\t\t'publisherConnectionString',\n\t\t);\n\n\t\tconst envVar = this.connectionKey;\n\t\tconst topic = this.name as string;\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(this.id) as Uncapitalize<TName>,\n\t\t\tasync register({ envParser }) {\n\t\t\t\tconst { connectionString } = envParser\n\t\t\t\t\t.create((get) => ({ connectionString: get(envVar).string() }))\n\t\t\t\t\t.parse();\n\n\t\t\t\t// Named as a topic, so a broker with one address for everything\n\t\t\t\t// (pg-boss) fans each message out to every subscriber.\n\t\t\t\treturn Publisher.fromConnectionString<TopicMessage<TEvents>>(\n\t\t\t\t\tconnectionString as EventPublisherConnectionString,\n\t\t\t\t\t{ topic },\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * What this topic is in the manifest.\n\t *\n\t * Only the producer's key: a subscriber is *bound* to a topic rather than\n\t * depending on it, so the binding is an edge the deploy target reads and not\n\t * an env key anyone can hold. Locally both sides meet on the same broker.\n\t */\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'topic',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.connectionKey],\n\t\t\t\t// The contract this topic carries. Structural: which events exist\n\t\t\t\t// is a fact about the application, and a subscriber binding to one\n\t\t\t\t// that does not is a mistake worth catching at build.\n\t\t\t\tevents: this.eventTypes,\n\t\t\t\t// Bound rather than declared here — a subscriber names the topic,\n\t\t\t\t// not the other way round — so the build fills these from what it\n\t\t\t\t// found. Nested when it does, because position is the trigger.\n\t\t\t\tsubscribers: [],\n\t\t\t},\n\t\t];\n\t}\n\n\t/** The event type names this topic carries. */\n\tget eventTypes(): (keyof TEvents & string)[] {\n\t\treturn Object.keys(this.eventSchemas) as (keyof TEvents & string)[];\n\t}\n}\n\nexport interface TopicOptions<TEvents extends TopicEvents> {\n\t/** Each event this topic carries — its type, and its payload's schema. */\n\tevents: TEvents;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAmDA,IAAa,QAAb,cAGU,UAAU;CACnB,eAAe;CAEf,OAAO,QAAQ,KAAiD;EAC/D,OAAO,QACN,OACE,IAAmC,iBAAiB,QACpD,IAAkB,SAAA,8BACrB;CACD;;;;;;;CAQA;;CAGA;;;;;;CAOA;;;;;;;;;;;;;CAcA;;CAMA;CAEA,YAAY,MAA4B,SAAgC;EACvE,MAAA,gCAA2B,gBAAgB,CAAC,GAAG,CAAC,CAAC;EAEjD,KAAK,OAAO;EACZ,KAAK,KAAK,YAAY,IAAc;EACpC,KAAK,eAAe,QAAQ;EAC5B,KAAK,gBAAgB,eACpB,KAAK,IACL,SACA,2BACD;EAEA,MAAM,SAAS,KAAK;EACpB,MAAM,QAAQ,KAAK;EACnB,KAAK,UAAU;GACd,aAAa,WAAW,KAAK,EAAE;GAC/B,MAAM,SAAS,EAAE,aAAa;IAC7B,MAAM,EAAE,qBAAqB,UAC3B,QAAQ,SAAS,EAAE,kBAAkB,IAAI,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAC7D,MAAM;IAIR,OAAO,UAAU,qBAChB,kBACA,EAAE,MAAM,CACT;GACD;EACD;CACD;;;;;;;;CASA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,UAAU,CAAC,KAAK,aAAa;GAI7B,QAAQ,KAAK;GAIb,aAAa,CAAC;EACf,CACD;CACD;;CAGA,IAAI,aAAyC;EAC5C,OAAO,OAAO,KAAK,KAAK,YAAY;CACrC;AACD"}
@@ -61,7 +61,7 @@ var Topic = class extends require_Construct.Construct {
61
61
  this.name = name;
62
62
  this.id = (0, _geekmidas_manifest.canonicalId)(name);
63
63
  this.eventSchemas = options.events;
64
- this.connectionKey = (0, _geekmidas_manifest.provideKey)(this.id, "publisherConnectionString");
64
+ this.connectionKey = (0, _geekmidas_manifest.providedKeyFor)(this.id, "topic", "publisherConnectionString");
65
65
  const envVar = this.connectionKey;
66
66
  const topic = this.name;
67
67
  this.service = {
@@ -101,4 +101,4 @@ Object.defineProperty(exports, "Topic", {
101
101
  }
102
102
  });
103
103
 
104
- //# sourceMappingURL=Topic-Dp9Q7Lj2.cjs.map
104
+ //# sourceMappingURL=Topic-DLCZBNwK.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Topic-DLCZBNwK.cjs","names":["Construct","DEFAULT_LOGGER","canonicalId","providedKeyFor","serviceKey","Publisher"],"sources":["../src/topic/Topic.ts"],"sourcesContent":["import {\n\ttype EventPublisher,\n\ttype EventPublisherConnectionString,\n\ttype PublishableMessage,\n\tPublisher,\n} from '@geekmidas/events';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovidedKeyFor,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Construct, ConstructType } from '../Construct';\n\n/** A topic's event contract — a map of event type → payload schema. */\nexport type TopicEvents = Record<string, StandardSchemaV1>;\n\n/**\n * The union of wire messages a topic carries, derived from its event map:\n * `{ type: 'user.created'; payload: … } | { type: 'user.updated'; payload: … }`.\n */\nexport type TopicMessage<TEvents extends TopicEvents> = {\n\t[K in keyof TEvents & string]: PublishableMessage<\n\t\tK,\n\t\tInferStandardSchema<TEvents[K]>\n\t>;\n}[keyof TEvents & string];\n\n/**\n * A topic — pub/sub fan-out. Unlike a `Queue` (point-to-point, one consumer), a\n * topic is a *resource* owned by no single handler: it declares the event\n * contract, and any number of subscribers (`worker.topic(topic)`) bind to it.\n * `gkm build` discovers it into the manifest's `topics` field; infra provisions\n * an SNS topic.\n *\n * A construct publishes with `.event(topic, { type, payload })`, repeatable\n * across topics, each event going through its own topic's publisher. That also\n * puts `services.<topic>` in the handler, as `.dependsOn([topic])` does, for an\n * event the handler decides on itself.\n *\n * ```ts\n * export const users = new Topic('Users', {\n * events: { 'user.created': z.object({ userId: z.string() }) },\n * });\n * ```\n */\nexport class Topic<\n\tTName extends string = string,\n\tTEvents extends TopicEvents = TopicEvents,\n> extends Construct {\n\t__IS_TOPIC__ = true;\n\n\tstatic isTopic(obj: unknown): obj is Topic<string, TopicEvents> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as { __IS_TOPIC__?: boolean }).__IS_TOPIC__ === true &&\n\t\t\t\t(obj as Construct).type === ConstructType.Topic,\n\t\t);\n\t}\n\n\t/**\n\t * The canonical id this topic is declared under.\n\t *\n\t * Derived from the name, so `users` and `Users` are one topic. The name is\n\t * left alone: subscribers bind to it and it is what the broker routes on.\n\t */\n\treadonly id: string;\n\n\t/** The name it was declared with — what the broker routes on. */\n\treadonly name: TName;\n\n\t/**\n\t * The event contract — a map of event type → payload schema. Named\n\t * `eventSchemas` (not `events`) to avoid clashing with `Construct.events`,\n\t * which is the array of `MappedEvent`s a construct *publishes*.\n\t */\n\treadonly eventSchemas: TEvents;\n\n\t/**\n\t * The topic as a dependency — what `.dependsOn([users])` and\n\t * `.event(users, …)` dissolve into, reachable as `services.users`.\n\t *\n\t * The producer, because publishing is the only thing depending on a topic\n\t * can mean: a subscriber binds to the topic instead, and is never handed\n\t * this. It reads `<NAME>_PUBLISHER_CONNECTION_STRING` and picks the\n\t * transport from its protocol — `pgboss://` locally, `sns://` deployed.\n\t *\n\t * A field assigned once, not a getter: services are cached by object\n\t * identity, and a fresh literal on every access never hit that cache.\n\t */\n\treadonly service: Service<\n\t\tUncapitalize<TName>,\n\t\tEventPublisher<TopicMessage<TEvents>>\n\t>;\n\n\t/** The producer's env key, read by both {@link declare} and the service. */\n\tprivate readonly connectionKey: string;\n\n\tconstructor(name: ConstructName<TName>, options: TopicOptions<TEvents>) {\n\t\tsuper(ConstructType.Topic, DEFAULT_LOGGER, [], []);\n\n\t\tthis.name = name as TName;\n\t\tthis.id = canonicalId(name as string);\n\t\tthis.eventSchemas = options.events;\n\t\tthis.connectionKey = providedKeyFor(\n\t\t\tthis.id,\n\t\t\t'topic',\n\t\t\t'publisherConnectionString',\n\t\t);\n\n\t\tconst envVar = this.connectionKey;\n\t\tconst topic = this.name as string;\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(this.id) as Uncapitalize<TName>,\n\t\t\tasync register({ envParser }) {\n\t\t\t\tconst { connectionString } = envParser\n\t\t\t\t\t.create((get) => ({ connectionString: get(envVar).string() }))\n\t\t\t\t\t.parse();\n\n\t\t\t\t// Named as a topic, so a broker with one address for everything\n\t\t\t\t// (pg-boss) fans each message out to every subscriber.\n\t\t\t\treturn Publisher.fromConnectionString<TopicMessage<TEvents>>(\n\t\t\t\t\tconnectionString as EventPublisherConnectionString,\n\t\t\t\t\t{ topic },\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * What this topic is in the manifest.\n\t *\n\t * Only the producer's key: a subscriber is *bound* to a topic rather than\n\t * depending on it, so the binding is an edge the deploy target reads and not\n\t * an env key anyone can hold. Locally both sides meet on the same broker.\n\t */\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'topic',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.connectionKey],\n\t\t\t\t// The contract this topic carries. Structural: which events exist\n\t\t\t\t// is a fact about the application, and a subscriber binding to one\n\t\t\t\t// that does not is a mistake worth catching at build.\n\t\t\t\tevents: this.eventTypes,\n\t\t\t\t// Bound rather than declared here — a subscriber names the topic,\n\t\t\t\t// not the other way round — so the build fills these from what it\n\t\t\t\t// found. Nested when it does, because position is the trigger.\n\t\t\t\tsubscribers: [],\n\t\t\t},\n\t\t];\n\t}\n\n\t/** The event type names this topic carries. */\n\tget eventTypes(): (keyof TEvents & string)[] {\n\t\treturn Object.keys(this.eventSchemas) as (keyof TEvents & string)[];\n\t}\n}\n\nexport interface TopicOptions<TEvents extends TopicEvents> {\n\t/** Each event this topic carries — its type, and its payload's schema. */\n\tevents: TEvents;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAmDA,IAAa,QAAb,cAGUA,kBAAAA,UAAU;CACnB,eAAe;CAEf,OAAO,QAAQ,KAAiD;EAC/D,OAAO,QACN,OACE,IAAmC,iBAAiB,QACpD,IAAkB,SAAA,8BACrB;CACD;;;;;;;CAQA;;CAGA;;;;;;CAOA;;;;;;;;;;;;;CAcA;;CAMA;CAEA,YAAY,MAA4B,SAAgC;EACvE,MAAA,gCAA2BC,0BAAAA,gBAAgB,CAAC,GAAG,CAAC,CAAC;EAEjD,KAAK,OAAO;EACZ,KAAK,MAAA,GAAKC,oBAAAA,YAAAA,CAAY,IAAc;EACpC,KAAK,eAAe,QAAQ;EAC5B,KAAK,iBAAA,GAAgBC,oBAAAA,eAAAA,CACpB,KAAK,IACL,SACA,2BACD;EAEA,MAAM,SAAS,KAAK;EACpB,MAAM,QAAQ,KAAK;EACnB,KAAK,UAAU;GACd,cAAA,GAAaC,oBAAAA,WAAAA,CAAW,KAAK,EAAE;GAC/B,MAAM,SAAS,EAAE,aAAa;IAC7B,MAAM,EAAE,qBAAqB,UAC3B,QAAQ,SAAS,EAAE,kBAAkB,IAAI,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAC7D,MAAM;IAIR,OAAOC,kBAAAA,UAAU,qBAChB,kBACA,EAAE,MAAM,CACT;GACD;EACD;CACD;;;;;;;;CASA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,UAAU,CAAC,KAAK,aAAa;GAI7B,QAAQ,KAAK;GAIb,aAAa,CAAC;EACf,CACD;CACD;;CAGA,IAAI,aAAyC;EAC5C,OAAO,OAAO,KAAK,KAAK,YAAY;CACrC;AACD"}
@@ -1,8 +1,8 @@
1
1
  import { n as StandardSchemaV1 } from "../index-DdRjYhiJ.cjs";
2
2
  import { i as FunctionHandler, n as Function$1 } from "../Function-BIEsY0Hm.cjs";
3
- import { t as Cron } from "../Cron-D_sfaMGz.cjs";
3
+ import { t as Cron } from "../Cron-Ca_qHQu2.cjs";
4
4
  import { t as HttpMethod } from "../types-DMuSQeLL.cjs";
5
- import { c as EndpointSchemas, i as Endpoint, r as CookieFn } from "../Endpoint-YYwjqtS1.cjs";
5
+ import { c as EndpointSchemas, i as Endpoint, r as CookieFn } from "../Endpoint-BlIZLsBQ.cjs";
6
6
  import { t as Telemetry } from "../lambdaTelemetry-8vnmVZQ5.cjs";
7
7
  import { t as Queue } from "../Queue-C4rijiM7.cjs";
8
8
  import { t as Subscriber } from "../Subscriber-5rCX1Nph.cjs";
@@ -1,8 +1,8 @@
1
1
  import { n as StandardSchemaV1 } from "../index-DdRjYhiJ.mjs";
2
2
  import { i as FunctionHandler, n as Function$1 } from "../Function-BKReud5p.mjs";
3
- import { t as Cron } from "../Cron-D6Y7BBt3.mjs";
3
+ import { t as Cron } from "../Cron-DPJiR7Lt.mjs";
4
4
  import { t as HttpMethod } from "../types-DMuSQeLL.mjs";
5
- import { c as EndpointSchemas, i as Endpoint, r as CookieFn } from "../Endpoint-BUoDD96P.mjs";
5
+ import { c as EndpointSchemas, i as Endpoint, r as CookieFn } from "../Endpoint-DC7mreOr.mjs";
6
6
  import { t as Telemetry } from "../lambdaTelemetry-8vnmVZQ5.mjs";
7
7
  import { t as Queue } from "../Queue-B8HGg439.mjs";
8
8
  import { t as Subscriber } from "../Subscriber-CtQXhcL7.mjs";
@@ -1,4 +1,4 @@
1
- import { L as Connection, _t as WebSocketSink, a as WebSocketSinkDriver, ht as WebSocketMessages, n as WebSocketApi, pt as NoMessages } from "../websocket-api-DkF8Hva-.cjs";
1
+ import { L as Connection, _t as WebSocketSink, a as WebSocketSinkDriver, ht as WebSocketMessages, n as WebSocketApi, pt as NoMessages } from "../websocket-api-B1Wl3tg4.cjs";
2
2
  import { EnvironmentParser } from "@geekmidas/envkit";
3
3
  import { ApiGatewayWebSocketTarget } from "@geekmidas/manifest";
4
4
  import { ApiGatewayManagementApiClient } from "@aws-sdk/client-apigatewaymanagementapi";
@@ -1,4 +1,4 @@
1
- import { L as Connection, _t as WebSocketSink, a as WebSocketSinkDriver, ht as WebSocketMessages, n as WebSocketApi, pt as NoMessages } from "../websocket-api-CPEzJyDt.mjs";
1
+ import { L as Connection, _t as WebSocketSink, a as WebSocketSinkDriver, ht as WebSocketMessages, n as WebSocketApi, pt as NoMessages } from "../websocket-api-CvnPDSZB.mjs";
2
2
  import { ApiGatewayWebSocketTarget } from "@geekmidas/manifest";
3
3
  import { EnvironmentParser } from "@geekmidas/envkit";
4
4
  import { ApiGatewayManagementApiClient } from "@aws-sdk/client-apigatewaymanagementapi";
@@ -1,6 +1,6 @@
1
1
  import { n as StandardSchemaV1 } from "../index-DdRjYhiJ.cjs";
2
2
  import { t as HttpMethod } from "../types-DMuSQeLL.cjs";
3
- import { c as EndpointSchemas, i as Endpoint } from "../Endpoint-YYwjqtS1.cjs";
3
+ import { c as EndpointSchemas, i as Endpoint } from "../Endpoint-BlIZLsBQ.cjs";
4
4
  import { EnvironmentParser } from "@geekmidas/envkit";
5
5
  import { Logger } from "@geekmidas/logger";
6
6
  import { Service, ServiceDiscovery, ServiceRecord } from "@geekmidas/services";
@@ -1,6 +1,6 @@
1
1
  import { n as StandardSchemaV1 } from "../index-DdRjYhiJ.mjs";
2
2
  import { t as HttpMethod } from "../types-DMuSQeLL.mjs";
3
- import { c as EndpointSchemas, i as Endpoint } from "../Endpoint-BUoDD96P.mjs";
3
+ import { c as EndpointSchemas, i as Endpoint } from "../Endpoint-DC7mreOr.mjs";
4
4
  import { Service, ServiceDiscovery, ServiceRecord } from "@geekmidas/services";
5
5
  import { EnvironmentParser } from "@geekmidas/envkit";
6
6
  import { Context, Hono } from "hono";
@@ -5,11 +5,11 @@ const require_optionalPeers = require("../optionalPeers-DuNQXXe1.cjs");
5
5
  const require_auth = require("../auth.cjs");
6
6
  const require_functions = require("../functions-DLF6-IK8.cjs");
7
7
  const require_Endpoint = require("../Endpoint-52z1P0Ue.cjs");
8
- const require_websocket_api = require("../websocket-api-czxhekGG.cjs");
9
- const require_Queue = require("../Queue-D4Iaidrs.cjs");
8
+ const require_websocket_api = require("../websocket-api-Zy2U-Qyh.cjs");
9
+ const require_Queue = require("../Queue-W1wueijP.cjs");
10
10
  const require_email = require("../email.cjs");
11
- const require_Topic = require("../Topic-Dp9Q7Lj2.cjs");
12
- const require_kysely = require("../kysely-CukArHJ0.cjs");
11
+ const require_Topic = require("../Topic-DLCZBNwK.cjs");
12
+ const require_kysely = require("../kysely-D7f6J2lh.cjs");
13
13
  const require_readRequestBody = require("../readRequestBody-CN9GVdeE.cjs");
14
14
  const require_HonoEndpointAdaptor = require("../HonoEndpointAdaptor-BTbqfSaa.cjs");
15
15
  const require_requestLogger = require("../requestLogger-CnoYd-Ah.cjs");
@@ -572,7 +572,7 @@ var NoInboxForAddress = class extends Error {
572
572
  var InboxNotLocal = class extends Error {
573
573
  inbox;
574
574
  constructor(inbox) {
575
- super(`'${inbox}' has no ${(0, _geekmidas_manifest.provideKey)(inbox, "smtpUrl")} in this test's environment, so there is no Mailpit to deliver to. Run it under \`gkm test\`, which resolves it.`);
575
+ super(`'${inbox}' has no ${(0, _geekmidas_manifest.providedKeyFor)(inbox, "inbox", "smtpUrl")} in this test's environment, so there is no Mailpit to deliver to. Run it under \`gkm test\`, which resolves it.`);
576
576
  this.inbox = inbox;
577
577
  this.name = "InboxNotLocal";
578
578
  }
@@ -593,7 +593,7 @@ async function receiveInTest(mail, inboxes, env, publish) {
593
593
  const built = fields.subject !== void 0 || fields.text !== void 0 || fields.html !== void 0 || fields.attachments !== void 0 || fields.headers !== void 0 || fields.headerTo !== void 0 || fields.cc !== void 0 || fields.replyTo !== void 0;
594
594
  if (mail.raw !== void 0 && built) throw new ReceiveFieldsOrRaw("both");
595
595
  const addressed = inboxes.filter((inbox) => {
596
- const domain = env[(0, _geekmidas_manifest.provideKey)(inbox.id, "domain")];
596
+ const domain = env[(0, _geekmidas_manifest.providedKeyFor)(inbox.id, "inbox", "domain")];
597
597
  return domain && (0, _geekmidas_manifest.inboxRecipient)(mail.to, inbox.addressing, domain);
598
598
  });
599
599
  if (addressed.length === 0) throw new NoInboxForAddress(mail.to, inboxes.map((inbox) => inbox.id));
@@ -629,7 +629,7 @@ async function receiveInTest(mail, inboxes, env, publish) {
629
629
  ...fields.headers ? { headers: fields.headers } : {}
630
630
  });
631
631
  }
632
- const smtp = env[(0, _geekmidas_manifest.provideKey)(addressed[0].id, "smtpUrl")];
632
+ const smtp = env[(0, _geekmidas_manifest.providedKeyFor)(addressed[0].id, "inbox", "smtpUrl")];
633
633
  if (!smtp) throw new InboxNotLocal(addressed[0].id);
634
634
  return receiveMail({
635
635
  key: await deliverRaw(smtp, {
@@ -643,7 +643,7 @@ async function receiveInTest(mail, inboxes, env, publish) {
643
643
  }, addressed.map((inbox) => ({
644
644
  id: inbox.id,
645
645
  addressing: inbox.addressing,
646
- domain: env[(0, _geekmidas_manifest.provideKey)(inbox.id, "domain")],
646
+ domain: env[(0, _geekmidas_manifest.providedKeyFor)(inbox.id, "inbox", "domain")],
647
647
  publish: (notification) => publish(inbox, notification)
648
648
  })));
649
649
  }
@@ -848,7 +848,7 @@ async function load(manifest, modules) {
848
848
  const watched = unique(constructs.filter((value) => isBucket(value) && subscribers.some(({ subscriber }) => subscriber.bucketName === value.id)));
849
849
  const inboxes = unique(constructs.filter(isInboxConstruct));
850
850
  const surfaces = unique(constructs.filter((value) => value instanceof require_websocket_api.WebSocketApi));
851
- const inbox = emails.map((email) => manifest.env[(0, _geekmidas_manifest.provideKey)(email.id, "inboxUrl")]).find(Boolean);
851
+ const inbox = emails.map((email) => manifest.env[(0, _geekmidas_manifest.providedKeyFor)(email.id, "email", "inboxUrl")]).find(Boolean);
852
852
  return {
853
853
  envParser,
854
854
  endpoints,
@@ -1050,7 +1050,7 @@ function watchers(app, state) {
1050
1050
  }
1051
1051
  /** The bucket's name as the storage knows it — the host of its URL. */
1052
1052
  function bucketName(bucket, envParser) {
1053
- const { url } = envParser.create((get) => ({ url: get((0, _geekmidas_manifest.provideKey)(bucket.id, "url")).string() })).parse();
1053
+ const { url } = envParser.create((get) => ({ url: get((0, _geekmidas_manifest.providedKeyFor)(bucket.id, "objects", "connectionString")).string() })).parse();
1054
1054
  try {
1055
1055
  return new URL(url).hostname || bucket.id;
1056
1056
  } catch {
@@ -1125,7 +1125,7 @@ function bindToTests(database) {
1125
1125
  };
1126
1126
  }
1127
1127
  function urlOf(database, envParser) {
1128
- return envParser.create((get) => ({ url: get((0, _geekmidas_manifest.provideKey)(database.id, "url")).string() })).parse().url;
1128
+ return envParser.create((get) => ({ url: get((0, _geekmidas_manifest.providedKeyFor)(database.id, "database", "url")).string() })).parse().url;
1129
1129
  }
1130
1130
  /** Each surface's endpoints, served at its URL for the test that asked. */
1131
1131
  function surfaceHandlers(endpoints, env) {
@@ -1136,7 +1136,7 @@ function surfaceHandlers(endpoints, env) {
1136
1136
  bySurface.set(surface, [...bySurface.get(surface) ?? [], endpoint]);
1137
1137
  }
1138
1138
  return [...bySurface].flatMap(([surface, served]) => {
1139
- const base = env[(0, _geekmidas_manifest.provideKey)(surface, "url")];
1139
+ const base = env[(0, _geekmidas_manifest.providedKeyFor)(surface, "rest-api", "url")];
1140
1140
  if (!base) return [];
1141
1141
  return msw.http.all(`${trim(base)}/*`, ({ request }) => serve(request, async (state) => {
1142
1142
  let app = state.surfaces.get(surface);
@@ -1162,7 +1162,7 @@ function surfaceHandlers(endpoints, env) {
1162
1162
  * container answers on localhost, which is let through.
1163
1163
  */
1164
1164
  function fakeHandler(id, fake, env) {
1165
- const base = env[(0, _geekmidas_manifest.provideKey)(id, "url")];
1165
+ const base = env[(0, _geekmidas_manifest.providedKeyFor)(id, "external-api", "url")];
1166
1166
  if (fake.kind !== "app" || !base) return [];
1167
1167
  return [msw.http.all(`${trim(base)}/*`, ({ request }) => fake.handler.fetch(request))];
1168
1168
  }
@@ -1178,7 +1178,7 @@ async function resolveService(app, state, name) {
1178
1178
  }
1179
1179
  /** An auth server, served at its URL, on the transaction of the test that asked. */
1180
1180
  function authHandler(auth, env, envParser) {
1181
- const base = trim(env[(0, _geekmidas_manifest.provideKey)(auth.id, "url")] ?? "");
1181
+ const base = trim(env[(0, _geekmidas_manifest.providedKeyFor)(auth.id, "rest-api", "url")] ?? "");
1182
1182
  return msw.http.all(`${base}/*`, ({ request }) => serve(request, async (state) => {
1183
1183
  let app = state.auth.get(auth);
1184
1184
  if (!app) {
@@ -1212,7 +1212,7 @@ function isLocal(url) {
1212
1212
  function wildcardSiteUrl(manifest) {
1213
1213
  for (const [id, construct] of Object.entries(manifest.constructs)) {
1214
1214
  if (construct.kind !== "site") continue;
1215
- const url = manifest.env[(0, _geekmidas_manifest.provideKey)(id, "url")];
1215
+ const url = manifest.env[(0, _geekmidas_manifest.providedKeyFor)(id, construct.kind, "url")];
1216
1216
  if (url && new URL(url).hostname.startsWith(`${_geekmidas_manifest.WILDCARD_SUBDOMAIN}.`)) return url;
1217
1217
  }
1218
1218
  }