@laserdata/laser-sdk 0.0.1-rc.21 → 0.0.1-rc.22

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 (434) hide show
  1. package/README.md +1 -1
  2. package/dist/agent/agdx.d.ts +55 -0
  3. package/dist/agent/agdx.d.ts.map +1 -0
  4. package/dist/agent/agdx.js +447 -0
  5. package/dist/agent/agdx.js.map +1 -0
  6. package/dist/agent/assembler.d.ts +29 -0
  7. package/dist/agent/assembler.d.ts.map +1 -0
  8. package/dist/agent/assembler.js +69 -0
  9. package/dist/agent/assembler.js.map +1 -0
  10. package/dist/agent/builder.d.ts +114 -0
  11. package/dist/agent/builder.d.ts.map +1 -0
  12. package/dist/agent/builder.js +334 -0
  13. package/dist/agent/builder.js.map +1 -0
  14. package/dist/agent/context.d.ts +68 -0
  15. package/dist/agent/context.d.ts.map +1 -0
  16. package/dist/agent/context.js +212 -0
  17. package/dist/agent/context.js.map +1 -0
  18. package/dist/agent/contract.d.ts +70 -0
  19. package/dist/agent/contract.d.ts.map +1 -0
  20. package/dist/agent/contract.js +275 -0
  21. package/dist/agent/contract.js.map +1 -0
  22. package/dist/agent/registry.d.ts +76 -0
  23. package/dist/agent/registry.d.ts.map +1 -0
  24. package/dist/agent/registry.js +286 -0
  25. package/dist/agent/registry.js.map +1 -0
  26. package/dist/agent/reliable-consumer.d.ts +126 -0
  27. package/dist/agent/reliable-consumer.d.ts.map +1 -0
  28. package/dist/agent/reliable-consumer.js +551 -0
  29. package/dist/agent/reliable-consumer.js.map +1 -0
  30. package/dist/agent/replies.d.ts +28 -0
  31. package/dist/agent/replies.d.ts.map +1 -0
  32. package/dist/agent/replies.js +175 -0
  33. package/dist/agent/replies.js.map +1 -0
  34. package/dist/agent/router.d.ts +72 -0
  35. package/dist/agent/router.d.ts.map +1 -0
  36. package/dist/agent/router.js +172 -0
  37. package/dist/agent/router.js.map +1 -0
  38. package/dist/agent/scope.d.ts +16 -0
  39. package/dist/agent/scope.d.ts.map +1 -0
  40. package/dist/agent/scope.js +34 -0
  41. package/dist/agent/scope.js.map +1 -0
  42. package/dist/agent/workflow.d.ts +85 -0
  43. package/dist/agent/workflow.d.ts.map +1 -0
  44. package/dist/agent/workflow.js +416 -0
  45. package/dist/agent/workflow.js.map +1 -0
  46. package/dist/blob.d.ts +12 -0
  47. package/dist/blob.d.ts.map +1 -0
  48. package/dist/blob.js +34 -0
  49. package/dist/blob.js.map +1 -0
  50. package/dist/bridges/a2a.d.ts +89 -0
  51. package/dist/bridges/a2a.d.ts.map +1 -0
  52. package/dist/bridges/a2a.js +244 -0
  53. package/dist/bridges/a2a.js.map +1 -0
  54. package/dist/bridges/agui.d.ts +66 -0
  55. package/dist/bridges/agui.d.ts.map +1 -0
  56. package/dist/bridges/agui.js +335 -0
  57. package/dist/bridges/agui.js.map +1 -0
  58. package/dist/bridges/edge-auth.d.ts +16 -0
  59. package/dist/bridges/edge-auth.d.ts.map +1 -0
  60. package/dist/bridges/edge-auth.js +19 -0
  61. package/dist/bridges/edge-auth.js.map +1 -0
  62. package/dist/bridges/hops.d.ts +9 -0
  63. package/dist/bridges/hops.d.ts.map +1 -0
  64. package/dist/bridges/hops.js +16 -0
  65. package/dist/bridges/hops.js.map +1 -0
  66. package/dist/bridges/mcp.d.ts +79 -0
  67. package/dist/bridges/mcp.d.ts.map +1 -0
  68. package/dist/bridges/mcp.js +248 -0
  69. package/dist/bridges/mcp.js.map +1 -0
  70. package/dist/client/bytes.d.ts +3 -0
  71. package/dist/client/bytes.d.ts.map +1 -0
  72. package/dist/client/bytes.js +9 -0
  73. package/dist/client/bytes.js.map +1 -0
  74. package/dist/client/capabilities.d.ts +36 -0
  75. package/dist/client/capabilities.d.ts.map +1 -0
  76. package/dist/client/capabilities.js +91 -0
  77. package/dist/client/capabilities.js.map +1 -0
  78. package/dist/client/errors.d.ts +178 -0
  79. package/dist/client/errors.d.ts.map +1 -0
  80. package/dist/client/errors.js +192 -0
  81. package/dist/client/errors.js.map +1 -0
  82. package/dist/client/internals.d.ts +5 -0
  83. package/dist/client/internals.d.ts.map +1 -0
  84. package/dist/client/internals.js +5 -0
  85. package/dist/client/internals.js.map +1 -0
  86. package/dist/client/laser.d.ts +238 -0
  87. package/dist/client/laser.d.ts.map +1 -0
  88. package/dist/client/laser.js +831 -0
  89. package/dist/client/laser.js.map +1 -0
  90. package/dist/client/laserdata-ca.d.ts +2 -0
  91. package/dist/client/laserdata-ca.d.ts.map +1 -0
  92. package/dist/client/laserdata-ca.js +35 -0
  93. package/dist/client/laserdata-ca.js.map +1 -0
  94. package/dist/client/managed.d.ts +6 -0
  95. package/dist/client/managed.d.ts.map +1 -0
  96. package/dist/client/managed.js +19 -0
  97. package/dist/client/managed.js.map +1 -0
  98. package/dist/context-scope.d.ts +40 -0
  99. package/dist/context-scope.d.ts.map +1 -0
  100. package/dist/context-scope.js +73 -0
  101. package/dist/context-scope.js.map +1 -0
  102. package/dist/context.d.ts +64 -0
  103. package/dist/context.d.ts.map +1 -0
  104. package/dist/context.js +149 -0
  105. package/dist/context.js.map +1 -0
  106. package/dist/conversation-state.d.ts +24 -0
  107. package/dist/conversation-state.d.ts.map +1 -0
  108. package/dist/conversation-state.js +29 -0
  109. package/dist/conversation-state.js.map +1 -0
  110. package/dist/crash-context.d.ts +11 -0
  111. package/dist/crash-context.d.ts.map +1 -0
  112. package/dist/crash-context.js +62 -0
  113. package/dist/crash-context.js.map +1 -0
  114. package/dist/full.d.ts +3 -0
  115. package/dist/full.d.ts.map +1 -0
  116. package/dist/full.js +3 -0
  117. package/dist/full.js.map +1 -0
  118. package/dist/govern.d.ts +133 -0
  119. package/dist/govern.d.ts.map +1 -0
  120. package/dist/govern.js +347 -0
  121. package/dist/govern.js.map +1 -0
  122. package/dist/iggy/apache-iggy.d.ts +173 -0
  123. package/dist/iggy/apache-iggy.d.ts.map +1 -0
  124. package/dist/iggy/apache-iggy.js +634 -0
  125. package/dist/iggy/apache-iggy.js.map +1 -0
  126. package/dist/index.d.ts +121 -0
  127. package/dist/index.d.ts.map +1 -0
  128. package/dist/index.js +64 -0
  129. package/dist/index.js.map +1 -0
  130. package/dist/intent.d.ts +75 -0
  131. package/dist/intent.d.ts.map +1 -0
  132. package/dist/intent.js +195 -0
  133. package/dist/intent.js.map +1 -0
  134. package/dist/managed/batch.d.ts +5 -0
  135. package/dist/managed/batch.d.ts.map +1 -0
  136. package/dist/managed/batch.js +32 -0
  137. package/dist/managed/batch.js.map +1 -0
  138. package/dist/managed/forks.d.ts +72 -0
  139. package/dist/managed/forks.d.ts.map +1 -0
  140. package/dist/managed/forks.js +188 -0
  141. package/dist/managed/forks.js.map +1 -0
  142. package/dist/managed/graph.d.ts +58 -0
  143. package/dist/managed/graph.d.ts.map +1 -0
  144. package/dist/managed/graph.js +176 -0
  145. package/dist/managed/graph.js.map +1 -0
  146. package/dist/managed/kv.d.ts +144 -0
  147. package/dist/managed/kv.d.ts.map +1 -0
  148. package/dist/managed/kv.js +502 -0
  149. package/dist/managed/kv.js.map +1 -0
  150. package/dist/managed/projections.d.ts +61 -0
  151. package/dist/managed/projections.d.ts.map +1 -0
  152. package/dist/managed/projections.js +191 -0
  153. package/dist/managed/projections.js.map +1 -0
  154. package/dist/managed/query.d.ts +72 -0
  155. package/dist/managed/query.d.ts.map +1 -0
  156. package/dist/managed/query.js +287 -0
  157. package/dist/managed/query.js.map +1 -0
  158. package/dist/managed/rbac.d.ts +16 -0
  159. package/dist/managed/rbac.d.ts.map +1 -0
  160. package/dist/managed/rbac.js +82 -0
  161. package/dist/managed/rbac.js.map +1 -0
  162. package/dist/managed/runs.d.ts +40 -0
  163. package/dist/managed/runs.d.ts.map +1 -0
  164. package/dist/managed/runs.js +112 -0
  165. package/dist/managed/runs.js.map +1 -0
  166. package/dist/managed/watch.d.ts +21 -0
  167. package/dist/managed/watch.d.ts.map +1 -0
  168. package/dist/managed/watch.js +73 -0
  169. package/dist/managed/watch.js.map +1 -0
  170. package/dist/memory/handle.d.ts +77 -0
  171. package/dist/memory/handle.d.ts.map +1 -0
  172. package/dist/memory/handle.js +234 -0
  173. package/dist/memory/handle.js.map +1 -0
  174. package/dist/memory/log-memory.d.ts +38 -0
  175. package/dist/memory/log-memory.d.ts.map +1 -0
  176. package/dist/memory/log-memory.js +309 -0
  177. package/dist/memory/log-memory.js.map +1 -0
  178. package/dist/memory/topic.d.ts +22 -0
  179. package/dist/memory/topic.d.ts.map +1 -0
  180. package/dist/memory/topic.js +56 -0
  181. package/dist/memory/topic.js.map +1 -0
  182. package/dist/memory/types.d.ts +108 -0
  183. package/dist/memory/types.d.ts.map +1 -0
  184. package/dist/memory/types.js +127 -0
  185. package/dist/memory/types.js.map +1 -0
  186. package/dist/memory/vector-memory.d.ts +20 -0
  187. package/dist/memory/vector-memory.d.ts.map +1 -0
  188. package/dist/memory/vector-memory.js +193 -0
  189. package/dist/memory/vector-memory.js.map +1 -0
  190. package/dist/memory.d.ts +7 -0
  191. package/dist/memory.d.ts.map +1 -0
  192. package/dist/memory.js +6 -0
  193. package/dist/memory.js.map +1 -0
  194. package/dist/observe.d.ts +10 -0
  195. package/dist/observe.d.ts.map +1 -0
  196. package/dist/observe.js +5 -0
  197. package/dist/observe.js.map +1 -0
  198. package/dist/opentelemetry.d.ts +22 -0
  199. package/dist/opentelemetry.d.ts.map +1 -0
  200. package/dist/opentelemetry.js +38 -0
  201. package/dist/opentelemetry.js.map +1 -0
  202. package/dist/provenance/agent-topic.d.ts +14 -0
  203. package/dist/provenance/agent-topic.d.ts.map +1 -0
  204. package/dist/provenance/agent-topic.js +13 -0
  205. package/dist/provenance/agent-topic.js.map +1 -0
  206. package/dist/provenance/provenance.d.ts +24 -0
  207. package/dist/provenance/provenance.d.ts.map +1 -0
  208. package/dist/provenance/provenance.js +186 -0
  209. package/dist/provenance/provenance.js.map +1 -0
  210. package/dist/provenance/session-policy.d.ts +4 -0
  211. package/dist/provenance/session-policy.d.ts.map +1 -0
  212. package/dist/provenance/session-policy.js +5 -0
  213. package/dist/provenance/session-policy.js.map +1 -0
  214. package/dist/runtime/async-once.d.ts +6 -0
  215. package/dist/runtime/async-once.d.ts.map +1 -0
  216. package/dist/runtime/async-once.js +19 -0
  217. package/dist/runtime/async-once.js.map +1 -0
  218. package/dist/runtime/clock.d.ts +14 -0
  219. package/dist/runtime/clock.d.ts.map +1 -0
  220. package/dist/runtime/clock.js +21 -0
  221. package/dist/runtime/clock.js.map +1 -0
  222. package/dist/runtime/mutex.d.ts +5 -0
  223. package/dist/runtime/mutex.d.ts.map +1 -0
  224. package/dist/runtime/mutex.js +23 -0
  225. package/dist/runtime/mutex.js.map +1 -0
  226. package/dist/runtime/ulid.d.ts +7 -0
  227. package/dist/runtime/ulid.d.ts.map +1 -0
  228. package/dist/runtime/ulid.js +17 -0
  229. package/dist/runtime/ulid.js.map +1 -0
  230. package/dist/schema-codecs.d.ts +16 -0
  231. package/dist/schema-codecs.d.ts.map +1 -0
  232. package/dist/schema-codecs.js +174 -0
  233. package/dist/schema-codecs.js.map +1 -0
  234. package/dist/signing.d.ts +63 -0
  235. package/dist/signing.d.ts.map +1 -0
  236. package/dist/signing.js +288 -0
  237. package/dist/signing.js.map +1 -0
  238. package/dist/snapshot.d.ts +24 -0
  239. package/dist/snapshot.d.ts.map +1 -0
  240. package/dist/snapshot.js +80 -0
  241. package/dist/snapshot.js.map +1 -0
  242. package/dist/state-store.d.ts +20 -0
  243. package/dist/state-store.d.ts.map +1 -0
  244. package/dist/state-store.js +70 -0
  245. package/dist/state-store.js.map +1 -0
  246. package/dist/stream/codecs.d.ts +9 -0
  247. package/dist/stream/codecs.d.ts.map +1 -0
  248. package/dist/stream/codecs.js +83 -0
  249. package/dist/stream/codecs.js.map +1 -0
  250. package/dist/stream/consumer.d.ts +50 -0
  251. package/dist/stream/consumer.d.ts.map +1 -0
  252. package/dist/stream/consumer.js +145 -0
  253. package/dist/stream/consumer.js.map +1 -0
  254. package/dist/stream/cursor.d.ts +26 -0
  255. package/dist/stream/cursor.d.ts.map +1 -0
  256. package/dist/stream/cursor.js +83 -0
  257. package/dist/stream/cursor.js.map +1 -0
  258. package/dist/stream/header-value.d.ts +18 -0
  259. package/dist/stream/header-value.d.ts.map +1 -0
  260. package/dist/stream/header-value.js +70 -0
  261. package/dist/stream/header-value.js.map +1 -0
  262. package/dist/stream/polling-strategy.d.ts +14 -0
  263. package/dist/stream/polling-strategy.d.ts.map +1 -0
  264. package/dist/stream/polling-strategy.js +2 -0
  265. package/dist/stream/polling-strategy.js.map +1 -0
  266. package/dist/stream/producer.d.ts +44 -0
  267. package/dist/stream/producer.d.ts.map +1 -0
  268. package/dist/stream/producer.js +125 -0
  269. package/dist/stream/producer.js.map +1 -0
  270. package/dist/stream/publish.d.ts +83 -0
  271. package/dist/stream/publish.d.ts.map +1 -0
  272. package/dist/stream/publish.js +287 -0
  273. package/dist/stream/publish.js.map +1 -0
  274. package/dist/stream/record.d.ts +29 -0
  275. package/dist/stream/record.d.ts.map +1 -0
  276. package/dist/stream/record.js +152 -0
  277. package/dist/stream/record.js.map +1 -0
  278. package/dist/stream/routing.d.ts +10 -0
  279. package/dist/stream/routing.d.ts.map +1 -0
  280. package/dist/stream/routing.js +2 -0
  281. package/dist/stream/routing.js.map +1 -0
  282. package/dist/stream/stream.d.ts +14 -0
  283. package/dist/stream/stream.d.ts.map +1 -0
  284. package/dist/stream/stream.js +26 -0
  285. package/dist/stream/stream.js.map +1 -0
  286. package/dist/stream/topic.d.ts +52 -0
  287. package/dist/stream/topic.d.ts.map +1 -0
  288. package/dist/stream/topic.js +181 -0
  289. package/dist/stream/topic.js.map +1 -0
  290. package/dist/stream/typed-topic.d.ts +59 -0
  291. package/dist/stream/typed-topic.d.ts.map +1 -0
  292. package/dist/stream/typed-topic.js +119 -0
  293. package/dist/stream/typed-topic.js.map +1 -0
  294. package/dist/swarm.d.ts +16 -0
  295. package/dist/swarm.d.ts.map +1 -0
  296. package/dist/swarm.js +40 -0
  297. package/dist/swarm.js.map +1 -0
  298. package/dist/testing.d.ts +16 -0
  299. package/dist/testing.d.ts.map +1 -0
  300. package/dist/testing.js +19 -0
  301. package/dist/testing.js.map +1 -0
  302. package/dist/types/ids.d.ts +48 -0
  303. package/dist/types/ids.d.ts.map +1 -0
  304. package/dist/types/ids.js +161 -0
  305. package/dist/types/ids.js.map +1 -0
  306. package/dist/wire/agent-record.d.ts +24 -0
  307. package/dist/wire/agent-record.d.ts.map +1 -0
  308. package/dist/wire/agent-record.js +99 -0
  309. package/dist/wire/agent-record.js.map +1 -0
  310. package/dist/wire/agent-workflow.d.ts +118 -0
  311. package/dist/wire/agent-workflow.d.ts.map +1 -0
  312. package/dist/wire/agent-workflow.js +290 -0
  313. package/dist/wire/agent-workflow.js.map +1 -0
  314. package/dist/wire/agent.d.ts +255 -0
  315. package/dist/wire/agent.d.ts.map +1 -0
  316. package/dist/wire/agent.js +792 -0
  317. package/dist/wire/agent.js.map +1 -0
  318. package/dist/wire/authz.d.ts +186 -0
  319. package/dist/wire/authz.d.ts.map +1 -0
  320. package/dist/wire/authz.js +545 -0
  321. package/dist/wire/authz.js.map +1 -0
  322. package/dist/wire/batch.d.ts +17 -0
  323. package/dist/wire/batch.d.ts.map +1 -0
  324. package/dist/wire/batch.js +41 -0
  325. package/dist/wire/batch.js.map +1 -0
  326. package/dist/wire/browse.d.ts +96 -0
  327. package/dist/wire/browse.d.ts.map +1 -0
  328. package/dist/wire/browse.js +201 -0
  329. package/dist/wire/browse.js.map +1 -0
  330. package/dist/wire/cbor.d.ts +35 -0
  331. package/dist/wire/cbor.d.ts.map +1 -0
  332. package/dist/wire/cbor.js +231 -0
  333. package/dist/wire/cbor.js.map +1 -0
  334. package/dist/wire/change.d.ts +12 -0
  335. package/dist/wire/change.d.ts.map +1 -0
  336. package/dist/wire/change.js +22 -0
  337. package/dist/wire/change.js.map +1 -0
  338. package/dist/wire/clients.d.ts +27 -0
  339. package/dist/wire/clients.d.ts.map +1 -0
  340. package/dist/wire/clients.js +64 -0
  341. package/dist/wire/clients.js.map +1 -0
  342. package/dist/wire/codes.d.ts +67 -0
  343. package/dist/wire/codes.d.ts.map +1 -0
  344. package/dist/wire/codes.js +67 -0
  345. package/dist/wire/codes.js.map +1 -0
  346. package/dist/wire/commands.d.ts +68 -0
  347. package/dist/wire/commands.d.ts.map +1 -0
  348. package/dist/wire/commands.js +140 -0
  349. package/dist/wire/commands.js.map +1 -0
  350. package/dist/wire/content.d.ts +17 -0
  351. package/dist/wire/content.d.ts.map +1 -0
  352. package/dist/wire/content.js +47 -0
  353. package/dist/wire/content.js.map +1 -0
  354. package/dist/wire/control.d.ts +170 -0
  355. package/dist/wire/control.d.ts.map +1 -0
  356. package/dist/wire/control.js +453 -0
  357. package/dist/wire/control.js.map +1 -0
  358. package/dist/wire/fork.d.ts +112 -0
  359. package/dist/wire/fork.d.ts.map +1 -0
  360. package/dist/wire/fork.js +280 -0
  361. package/dist/wire/fork.js.map +1 -0
  362. package/dist/wire/forward.d.ts +23 -0
  363. package/dist/wire/forward.d.ts.map +1 -0
  364. package/dist/wire/forward.js +72 -0
  365. package/dist/wire/forward.js.map +1 -0
  366. package/dist/wire/graph.d.ts +181 -0
  367. package/dist/wire/graph.d.ts.map +1 -0
  368. package/dist/wire/graph.js +554 -0
  369. package/dist/wire/graph.js.map +1 -0
  370. package/dist/wire/hashing.d.ts +2 -0
  371. package/dist/wire/hashing.d.ts.map +1 -0
  372. package/dist/wire/hashing.js +21 -0
  373. package/dist/wire/hashing.js.map +1 -0
  374. package/dist/wire/headers.d.ts +32 -0
  375. package/dist/wire/headers.d.ts.map +1 -0
  376. package/dist/wire/headers.js +32 -0
  377. package/dist/wire/headers.js.map +1 -0
  378. package/dist/wire/hello.d.ts +50 -0
  379. package/dist/wire/hello.d.ts.map +1 -0
  380. package/dist/wire/hello.js +122 -0
  381. package/dist/wire/hello.js.map +1 -0
  382. package/dist/wire/http.d.ts +95 -0
  383. package/dist/wire/http.d.ts.map +1 -0
  384. package/dist/wire/http.js +282 -0
  385. package/dist/wire/http.js.map +1 -0
  386. package/dist/wire/ids.d.ts +50 -0
  387. package/dist/wire/ids.d.ts.map +1 -0
  388. package/dist/wire/ids.js +198 -0
  389. package/dist/wire/ids.js.map +1 -0
  390. package/dist/wire/index.d.ts +32 -0
  391. package/dist/wire/index.d.ts.map +1 -0
  392. package/dist/wire/index.js +32 -0
  393. package/dist/wire/index.js.map +1 -0
  394. package/dist/wire/kv.d.ts +260 -0
  395. package/dist/wire/kv.d.ts.map +1 -0
  396. package/dist/wire/kv.js +650 -0
  397. package/dist/wire/kv.js.map +1 -0
  398. package/dist/wire/limits.d.ts +36 -0
  399. package/dist/wire/limits.d.ts.map +1 -0
  400. package/dist/wire/limits.js +36 -0
  401. package/dist/wire/limits.js.map +1 -0
  402. package/dist/wire/memory.d.ts +17 -0
  403. package/dist/wire/memory.d.ts.map +1 -0
  404. package/dist/wire/memory.js +65 -0
  405. package/dist/wire/memory.js.map +1 -0
  406. package/dist/wire/mutation.d.ts +10 -0
  407. package/dist/wire/mutation.d.ts.map +1 -0
  408. package/dist/wire/mutation.js +18 -0
  409. package/dist/wire/mutation.js.map +1 -0
  410. package/dist/wire/query.d.ts +210 -0
  411. package/dist/wire/query.d.ts.map +1 -0
  412. package/dist/wire/query.js +594 -0
  413. package/dist/wire/query.js.map +1 -0
  414. package/dist/wire/result.d.ts +25 -0
  415. package/dist/wire/result.d.ts.map +1 -0
  416. package/dist/wire/result.js +52 -0
  417. package/dist/wire/result.js.map +1 -0
  418. package/dist/wire/snapshot.d.ts +11 -0
  419. package/dist/wire/snapshot.d.ts.map +1 -0
  420. package/dist/wire/snapshot.js +50 -0
  421. package/dist/wire/snapshot.js.map +1 -0
  422. package/dist/wire/topics.d.ts +5 -0
  423. package/dist/wire/topics.d.ts.map +1 -0
  424. package/dist/wire/topics.js +5 -0
  425. package/dist/wire/topics.js.map +1 -0
  426. package/dist/wire/topology.d.ts +24 -0
  427. package/dist/wire/topology.d.ts.map +1 -0
  428. package/dist/wire/topology.js +56 -0
  429. package/dist/wire/topology.js.map +1 -0
  430. package/dist/wire/value.d.ts +21 -0
  431. package/dist/wire/value.d.ts.map +1 -0
  432. package/dist/wire/value.js +40 -0
  433. package/dist/wire/value.js.map +1 -0
  434. package/package.json +2 -1
@@ -0,0 +1,634 @@
1
+ import { Consumer, HeaderKeyFactory, HeaderValue as IggyHeaderValueFactory, Partitioning, PollingStrategy as IggyPollingStrategy, SimpleClient, getRawClient } from "apache-iggy";
2
+ import { readFileSync } from "node:fs";
3
+ import { ConfigError, TransportError } from "../client/errors.js";
4
+ import { LASERDATA_ROOT_CA } from "../client/laserdata-ca.js";
5
+ import { Mutex } from "../runtime/mutex.js";
6
+ const DEFAULT_RECONNECT_INTERVAL_MS = 1_000;
7
+ const VSR_HEARTBEAT_INTERVAL_MS = 5_000;
8
+ export function toNodeBuffer(bytes) {
9
+ return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
10
+ }
11
+ function toIggyConsumer(target) {
12
+ return target.kind === "single"
13
+ ? target.name === undefined
14
+ ? Consumer.Single
15
+ : { kind: 1, id: target.name }
16
+ : Consumer.Group(target.name);
17
+ }
18
+ function toIggyOffsetConsumer(target) {
19
+ return target.kind === "group"
20
+ ? Consumer.Group(target.name)
21
+ : { kind: 1, id: target.name };
22
+ }
23
+ function rotateLeft(value, bits) {
24
+ return ((value << bits) | (value >>> (32 - bits))) >>> 0;
25
+ }
26
+ function xxHashRound(accumulator, lane) {
27
+ const added = (accumulator + Math.imul(lane, 0x85ebca77)) >>> 0;
28
+ return Math.imul(rotateLeft(added, 13), 0x9e3779b1) >>> 0;
29
+ }
30
+ export function xxHash32(bytes) {
31
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
32
+ let offset = 0;
33
+ let hash;
34
+ if (bytes.byteLength >= 16) {
35
+ let lane1 = 0x24234428;
36
+ let lane2 = 0x85ebca77;
37
+ let lane3 = 0;
38
+ let lane4 = 0x61c8864f;
39
+ const limit = bytes.byteLength - 16;
40
+ do {
41
+ lane1 = xxHashRound(lane1, view.getUint32(offset, true));
42
+ lane2 = xxHashRound(lane2, view.getUint32(offset + 4, true));
43
+ lane3 = xxHashRound(lane3, view.getUint32(offset + 8, true));
44
+ lane4 = xxHashRound(lane4, view.getUint32(offset + 12, true));
45
+ offset += 16;
46
+ } while (offset <= limit);
47
+ hash =
48
+ (rotateLeft(lane1, 1) +
49
+ rotateLeft(lane2, 7) +
50
+ rotateLeft(lane3, 12) +
51
+ rotateLeft(lane4, 18)) >>>
52
+ 0;
53
+ }
54
+ else {
55
+ hash = 0x165667b1;
56
+ }
57
+ hash = (hash + bytes.byteLength) >>> 0;
58
+ while (offset + 4 <= bytes.byteLength) {
59
+ hash = (hash + Math.imul(view.getUint32(offset, true), 0xc2b2ae3d)) >>> 0;
60
+ hash = Math.imul(rotateLeft(hash, 17), 0x27d4eb2f) >>> 0;
61
+ offset += 4;
62
+ }
63
+ while (offset < bytes.byteLength) {
64
+ hash = (hash + Math.imul(bytes[offset] ?? 0, 0x165667b1)) >>> 0;
65
+ hash = Math.imul(rotateLeft(hash, 11), 0x9e3779b1) >>> 0;
66
+ offset += 1;
67
+ }
68
+ hash ^= hash >>> 15;
69
+ hash = Math.imul(hash, 0x85ebca77) >>> 0;
70
+ hash ^= hash >>> 13;
71
+ hash = Math.imul(hash, 0xc2b2ae3d) >>> 0;
72
+ hash ^= hash >>> 16;
73
+ return hash >>> 0;
74
+ }
75
+ function toIggyPollingStrategy(strategy) {
76
+ switch (strategy.kind) {
77
+ case "first":
78
+ return IggyPollingStrategy.First;
79
+ case "last":
80
+ return IggyPollingStrategy.Last;
81
+ case "next":
82
+ return IggyPollingStrategy.Next;
83
+ case "offset":
84
+ return IggyPollingStrategy.Offset(strategy.value);
85
+ case "timestamp":
86
+ return IggyPollingStrategy.Timestamp(strategy.value);
87
+ }
88
+ }
89
+ function toIggyHeaderValue(value) {
90
+ switch (value.kind) {
91
+ case "raw":
92
+ return IggyHeaderValueFactory.Raw(Buffer.from(value.value));
93
+ case "string":
94
+ return IggyHeaderValueFactory.String(value.value);
95
+ case "bool":
96
+ return IggyHeaderValueFactory.Bool(value.value);
97
+ case "int8":
98
+ return IggyHeaderValueFactory.Int8(value.value);
99
+ case "int16":
100
+ return IggyHeaderValueFactory.Int16(value.value);
101
+ case "int32":
102
+ return IggyHeaderValueFactory.Int32(value.value);
103
+ case "int64":
104
+ return IggyHeaderValueFactory.Int64(value.value);
105
+ case "int128":
106
+ return IggyHeaderValueFactory.Int128(Buffer.from(value.value));
107
+ case "uint8":
108
+ return IggyHeaderValueFactory.Uint8(value.value);
109
+ case "uint16":
110
+ return IggyHeaderValueFactory.Uint16(value.value);
111
+ case "uint32":
112
+ return IggyHeaderValueFactory.Uint32(value.value);
113
+ case "uint64":
114
+ return IggyHeaderValueFactory.Uint64(value.value);
115
+ case "uint128":
116
+ return IggyHeaderValueFactory.Uint128(Buffer.from(value.value));
117
+ case "float":
118
+ return IggyHeaderValueFactory.Float(value.value);
119
+ case "double":
120
+ return IggyHeaderValueFactory.Double(value.value);
121
+ }
122
+ }
123
+ const HEADER_KIND_BY_NUMBER = {
124
+ 1: "raw",
125
+ 2: "string",
126
+ 3: "bool",
127
+ 4: "int8",
128
+ 5: "int16",
129
+ 6: "int32",
130
+ 7: "int64",
131
+ 8: "int128",
132
+ 9: "uint8",
133
+ 10: "uint16",
134
+ 11: "uint32",
135
+ 12: "uint64",
136
+ 13: "uint128",
137
+ 14: "float",
138
+ 15: "double"
139
+ };
140
+ function fromParsedHeaderValue(kind, value) {
141
+ const tag = HEADER_KIND_BY_NUMBER[kind];
142
+ if (tag === undefined)
143
+ return undefined;
144
+ switch (tag) {
145
+ case "raw":
146
+ case "int128":
147
+ case "uint128": {
148
+ if (!(value instanceof Buffer))
149
+ return undefined;
150
+ return { kind: tag, value: new Uint8Array(value) };
151
+ }
152
+ case "string":
153
+ return typeof value === "string" ? { kind: tag, value } : undefined;
154
+ case "bool":
155
+ return typeof value === "boolean" ? { kind: tag, value } : undefined;
156
+ case "int64":
157
+ case "uint64":
158
+ return typeof value === "bigint" ? { kind: tag, value } : undefined;
159
+ case "int8":
160
+ case "int16":
161
+ case "int32":
162
+ case "uint8":
163
+ case "uint16":
164
+ case "uint32":
165
+ case "float":
166
+ case "double":
167
+ return typeof value === "number" ? { kind: tag, value } : undefined;
168
+ }
169
+ }
170
+ function parsedHeadersToMap(entries) {
171
+ const map = new Map();
172
+ for (const entry of entries) {
173
+ if (typeof entry.key.value !== "string")
174
+ continue;
175
+ const value = fromParsedHeaderValue(entry.value.kind, entry.value.value);
176
+ if (value !== undefined)
177
+ map.set(entry.key.value, value);
178
+ }
179
+ return map;
180
+ }
181
+ function laserDataHost(host) {
182
+ const normalized = host.toLowerCase();
183
+ return (normalized === "laserdata.cloud" ||
184
+ normalized.endsWith(".laserdata.cloud") ||
185
+ normalized === "laserdata.com" ||
186
+ normalized.endsWith(".laserdata.com"));
187
+ }
188
+ function parseReconnectInterval(value) {
189
+ if (value === null)
190
+ return DEFAULT_RECONNECT_INTERVAL_MS;
191
+ const match = /^(\d+)(ms|s|m)$/.exec(value);
192
+ if (match === null) {
193
+ throw new ConfigError("reconnection_interval must use ms, s, or m");
194
+ }
195
+ const amount = Number(match[1]);
196
+ const unit = match[2];
197
+ const multiplier = unit === "ms" ? 1 : unit === "s" ? 1_000 : 60_000;
198
+ const intervalMs = amount * multiplier;
199
+ if (!Number.isSafeInteger(intervalMs) || intervalMs < 0) {
200
+ throw new ConfigError("reconnection_interval is outside the supported range");
201
+ }
202
+ return intervalMs;
203
+ }
204
+ function parseReconnectRetries(value) {
205
+ if (value === "unlimited")
206
+ return undefined;
207
+ if (value === null)
208
+ return undefined;
209
+ const retries = Number(value);
210
+ if (!Number.isSafeInteger(retries) || retries < 0) {
211
+ throw new ConfigError("reconnection_retries must be a non-negative integer or unlimited");
212
+ }
213
+ return retries;
214
+ }
215
+ export function parseConnectionString(connectionString, env = process.env) {
216
+ const trimmed = connectionString.trim();
217
+ const withScheme = trimmed.startsWith("iggy://") || trimmed.startsWith("iggy+") ? trimmed : `iggy://${trimmed}`;
218
+ let url;
219
+ try {
220
+ url = new URL(withScheme);
221
+ }
222
+ catch (cause) {
223
+ throw new ConfigError(`invalid connection string: ${connectionString}`, { cause });
224
+ }
225
+ if (url.protocol !== "iggy:" && url.protocol !== "iggy+tcp:") {
226
+ throw new ConfigError(`unsupported connection scheme: ${url.protocol}`);
227
+ }
228
+ if (!url.hostname) {
229
+ throw new ConfigError(`connection string missing host: ${connectionString}`);
230
+ }
231
+ const port = url.port ? Number(url.port) : 8090;
232
+ if (!Number.isInteger(port) || port <= 0 || port > 65535) {
233
+ throw new ConfigError(`connection string has invalid port: ${connectionString}`);
234
+ }
235
+ const username = decodeURIComponent(url.username);
236
+ const password = decodeURIComponent(url.password);
237
+ const credentials = username.length === 0
238
+ ? { username: "iggy", password: "iggy" }
239
+ : password.length === 0
240
+ ? { token: username }
241
+ : { username, password };
242
+ const autoTls = env["LASER_NO_TLS"] === undefined && laserDataHost(url.hostname);
243
+ const tls = url.searchParams.get("tls") === "true" || autoTls;
244
+ const caPath = url.searchParams.get("tls_ca_file") ?? env["LASER_TLS_CERT"];
245
+ let ca;
246
+ if (caPath !== undefined && caPath.length > 0) {
247
+ try {
248
+ ca = readFileSync(caPath, "utf8");
249
+ }
250
+ catch (cause) {
251
+ throw new ConfigError(`failed to read TLS CA file: ${caPath}`, { cause });
252
+ }
253
+ }
254
+ else if (autoTls) {
255
+ ca = LASERDATA_ROOT_CA;
256
+ }
257
+ const reconnection = {
258
+ intervalMs: parseReconnectInterval(url.searchParams.get("reconnection_interval")),
259
+ maxRetries: parseReconnectRetries(url.searchParams.get("reconnection_retries"))
260
+ };
261
+ return {
262
+ host: url.hostname,
263
+ port,
264
+ credentials,
265
+ tls,
266
+ ...(ca !== undefined ? { ca } : {}),
267
+ reconnection
268
+ };
269
+ }
270
+ async function connectSimpleClient(parsed) {
271
+ const config = parsed.tls
272
+ ? {
273
+ protocol: "vsr",
274
+ heartbeatInterval: VSR_HEARTBEAT_INTERVAL_MS,
275
+ transport: "TLS",
276
+ options: {
277
+ port: parsed.port,
278
+ host: parsed.host,
279
+ ...(parsed.ca !== undefined ? { ca: parsed.ca } : {})
280
+ },
281
+ credentials: parsed.credentials,
282
+ reconnect: { enabled: false, interval: 0, maxRetries: 0 }
283
+ }
284
+ : {
285
+ protocol: "vsr",
286
+ heartbeatInterval: VSR_HEARTBEAT_INTERVAL_MS,
287
+ transport: "TCP",
288
+ options: { port: parsed.port, host: parsed.host },
289
+ credentials: parsed.credentials,
290
+ reconnect: { enabled: false, interval: 0, maxRetries: 0 }
291
+ };
292
+ let raw;
293
+ try {
294
+ raw = getRawClient(config);
295
+ const connection = raw.connection;
296
+ const client = new SimpleClient(raw);
297
+ await new Promise((resolve, reject) => {
298
+ const failed = (cause) => {
299
+ reject(cause instanceof Error ? cause : new Error(String(cause)));
300
+ };
301
+ connection.once("error", failed);
302
+ client.client.getMe().then(() => {
303
+ connection.off("error", failed);
304
+ resolve();
305
+ }, reject);
306
+ });
307
+ connection.on("error", () => undefined);
308
+ return { client, raw };
309
+ }
310
+ catch (cause) {
311
+ raw?.destroy();
312
+ throw new TransportError(`failed to connect to ${parsed.host}:${String(parsed.port)}`, false, {
313
+ cause
314
+ });
315
+ }
316
+ }
317
+ function serverResponseError(error) {
318
+ let current = error;
319
+ for (let depth = 0; depth < 8; depth += 1) {
320
+ if (typeof current !== "object" || current === null)
321
+ return undefined;
322
+ if ("errorCode" in current &&
323
+ typeof current.errorCode === "number") {
324
+ return current instanceof Error ? current : new Error("server rejected connection");
325
+ }
326
+ current = "cause" in current ? current.cause : undefined;
327
+ }
328
+ return undefined;
329
+ }
330
+ async function connectWithRetry(parsed) {
331
+ let retries = 0;
332
+ let lastError;
333
+ while (parsed.reconnection.maxRetries === undefined ||
334
+ retries <= parsed.reconnection.maxRetries) {
335
+ try {
336
+ return await connectSimpleClient(parsed);
337
+ }
338
+ catch (error) {
339
+ lastError = error;
340
+ if (serverResponseError(error) !== undefined) {
341
+ break;
342
+ }
343
+ if (parsed.reconnection.maxRetries !== undefined &&
344
+ retries >= parsed.reconnection.maxRetries) {
345
+ break;
346
+ }
347
+ retries += 1;
348
+ await new Promise((resolve) => setTimeout(resolve, parsed.reconnection.intervalMs));
349
+ }
350
+ }
351
+ const responseError = serverResponseError(lastError);
352
+ const message = responseError === undefined
353
+ ? `failed to connect to ${parsed.host}:${String(parsed.port)}`
354
+ : `server rejected connection: ${responseError.message}`;
355
+ throw new TransportError(message, responseError === undefined, { cause: lastError });
356
+ }
357
+ export class ApacheIggyTransport {
358
+ client;
359
+ connection;
360
+ ownership;
361
+ kind = "apache-iggy";
362
+ reconnectLock = new Mutex();
363
+ disconnected = new WeakSet();
364
+ consumerGroups = new Map();
365
+ partitionCounts = new Map();
366
+ balancedCursors = new Map();
367
+ closed = false;
368
+ constructor(client, connection, ownership) {
369
+ this.client = client;
370
+ this.connection = connection;
371
+ this.ownership = ownership;
372
+ }
373
+ get iggyClient() {
374
+ return this.client;
375
+ }
376
+ static async connect(connectionString) {
377
+ const parsed = parseConnectionString(connectionString);
378
+ const connected = await connectWithRetry(parsed);
379
+ const transport = new ApacheIggyTransport(connected.client, parsed, "owned");
380
+ transport.watch(connected);
381
+ return transport;
382
+ }
383
+ static async fromClient(client, ownership = "borrowed") {
384
+ const raw = await client.clientProvider();
385
+ if (raw.protocol !== "vsr") {
386
+ throw new ConfigError("Laser requires an Apache Iggy VSR client");
387
+ }
388
+ return new ApacheIggyTransport(client, undefined, ownership);
389
+ }
390
+ async execute(operation, message) {
391
+ const stale = this.client;
392
+ if (this.disconnected.has(stale)) {
393
+ await this.reconnect(stale);
394
+ return operation(this.client);
395
+ }
396
+ try {
397
+ return await operation(stale);
398
+ }
399
+ catch (firstCause) {
400
+ if (!this.disconnected.has(stale)) {
401
+ throw new TransportError(message, true, { cause: firstCause });
402
+ }
403
+ try {
404
+ await this.reconnect(stale);
405
+ return await operation(this.client);
406
+ }
407
+ catch (cause) {
408
+ throw new TransportError(message, true, { cause: cause ?? firstCause });
409
+ }
410
+ }
411
+ }
412
+ reconnect(stale) {
413
+ return this.reconnectLock.runExclusive(async () => {
414
+ if (this.closed)
415
+ throw new TransportError("transport is closed", false);
416
+ if (this.client !== stale)
417
+ return;
418
+ if (this.connection === undefined) {
419
+ throw new TransportError("an injected client cannot be reconnected by Laser", true);
420
+ }
421
+ await stale.destroy().catch(() => undefined);
422
+ let retries = 0;
423
+ let lastError;
424
+ while (this.connection.reconnection.maxRetries === undefined ||
425
+ retries <= this.connection.reconnection.maxRetries) {
426
+ try {
427
+ const connected = await connectSimpleClient(this.connection);
428
+ try {
429
+ for (const group of this.consumerGroups.values()) {
430
+ await connected.client.group.ensureAndJoin(group.streamId, group.topicId, group.name);
431
+ }
432
+ }
433
+ catch (cause) {
434
+ await connected.client.destroy().catch(() => undefined);
435
+ throw cause;
436
+ }
437
+ this.client = connected.client;
438
+ this.watch(connected);
439
+ return;
440
+ }
441
+ catch (error) {
442
+ lastError = error;
443
+ if (serverResponseError(error) !== undefined) {
444
+ break;
445
+ }
446
+ if (this.connection.reconnection.maxRetries !== undefined &&
447
+ retries >= this.connection.reconnection.maxRetries) {
448
+ break;
449
+ }
450
+ retries += 1;
451
+ await new Promise((resolve) => setTimeout(resolve, this.connection?.reconnection.intervalMs ?? 0));
452
+ }
453
+ }
454
+ const responseError = serverResponseError(lastError);
455
+ const message = responseError === undefined
456
+ ? "reconnect attempts exhausted"
457
+ : `server rejected connection: ${responseError.message}`;
458
+ throw new TransportError(message, responseError === undefined, { cause: lastError });
459
+ });
460
+ }
461
+ watch(connected) {
462
+ const markDisconnected = () => {
463
+ this.disconnected.add(connected.client);
464
+ };
465
+ const stream = connected.raw.getReadStream();
466
+ stream.once("error", markDisconnected);
467
+ stream.once("end", markDisconnected);
468
+ stream.once("close", markDisconnected);
469
+ }
470
+ async sendManaged(code, payload) {
471
+ const buffer = Buffer.from(payload);
472
+ const reply = await this.execute((client) => client.sendBinaryRequest(code, buffer), `managed command ${String(code)} failed`);
473
+ return new Uint8Array(reply.buffer, reply.byteOffset, reply.byteLength);
474
+ }
475
+ async ensureStream(name) {
476
+ await this.execute((client) => client.stream.ensure(name), `failed to ensure stream \`${name}\``);
477
+ }
478
+ async ensureTopic(streamId, topicId, partitions) {
479
+ const topic = await this.execute((client) => client.topic.ensure(streamId, topicId, partitions), `failed to ensure topic \`${topicId}\` on stream \`${streamId}\``);
480
+ this.partitionCounts.set(this.topicKey(streamId, topicId), topic.partitionsCount);
481
+ }
482
+ async ensureTopicWithExpiry(streamId, topicId, partitions, messageExpiryMicros) {
483
+ const partitionCount = await this.execute(async (client) => {
484
+ const topic = await client.topic.ensure(streamId, topicId, partitions);
485
+ if (topic.messageExpiry === messageExpiryMicros)
486
+ return topic.partitionsCount;
487
+ await client.topic.update({
488
+ streamId,
489
+ topicId,
490
+ name: topic.name,
491
+ messageExpiry: messageExpiryMicros
492
+ });
493
+ return topic.partitionsCount;
494
+ }, `failed to ensure topic \`${topicId}\` on stream \`${streamId}\` with message expiry`);
495
+ this.partitionCounts.set(this.topicKey(streamId, topicId), partitionCount);
496
+ }
497
+ async findTopicPartitionCount(streamId, topicId) {
498
+ const topic = await this.execute((client) => client.topic.get({ streamId, topicId }), `failed to read topic \`${topicId}\``);
499
+ if (topic === null)
500
+ return undefined;
501
+ this.partitionCounts.set(this.topicKey(streamId, topicId), topic.partitionsCount);
502
+ return topic.partitionsCount;
503
+ }
504
+ async getTopicPartitionCount(streamId, topicId) {
505
+ const partitions = await this.findTopicPartitionCount(streamId, topicId);
506
+ if (partitions === undefined) {
507
+ throw new TransportError(`topic \`${topicId}\` on stream \`${streamId}\` does not exist`, false);
508
+ }
509
+ return partitions;
510
+ }
511
+ async resolveStreamTopicIds(streamId, topicId) {
512
+ const [stream, topic] = await this.execute((client) => Promise.all([client.stream.get({ streamId }), client.topic.get({ streamId, topicId })]), `failed to resolve topic \`${topicId}\``);
513
+ if (stream === null) {
514
+ throw new TransportError(`stream \`${streamId}\` does not exist`, false);
515
+ }
516
+ if (topic === null) {
517
+ throw new TransportError(`topic \`${topicId}\` on stream \`${streamId}\` does not exist`, false);
518
+ }
519
+ return { streamId: stream.id, topicId: topic.id };
520
+ }
521
+ async resolveStreamTopicNames(streamId, topicId) {
522
+ const stream = await this.execute((client) => client.stream.get({ streamId }), `failed to resolve stream ${String(streamId)}`);
523
+ if (stream === null)
524
+ return undefined;
525
+ const topic = await this.execute((client) => client.topic.get({ streamId, topicId }), `failed to resolve topic ${String(topicId)}`);
526
+ return topic === null ? undefined : { stream: stream.name, topic: topic.name };
527
+ }
528
+ async sendMessages(streamId, topicId, payloads, routing) {
529
+ const partitionId = await this.resolvePartition(streamId, topicId, routing);
530
+ await this.execute((client) => client.message.send({
531
+ streamId,
532
+ topicId,
533
+ messages: payloads.map((payload) => ({ payload: Buffer.from(payload) })),
534
+ partition: Partitioning.PartitionId(partitionId)
535
+ }), `failed to send to topic \`${topicId}\``);
536
+ }
537
+ async sendMessageWithHeaders(streamId, topicId, payload, headers, partitionKey, partitionId) {
538
+ await this.sendMessagesWithHeaders(streamId, topicId, [{ payload, headers }], partitionKey, partitionId);
539
+ }
540
+ async sendMessagesWithHeaders(streamId, topicId, messages, partitionKey, partitionId) {
541
+ const resolvedPartition = await this.resolvePartition(streamId, topicId, partitionId !== undefined
542
+ ? { kind: "partition", partition: partitionId }
543
+ : partitionKey !== undefined
544
+ ? {
545
+ kind: "key",
546
+ key: typeof partitionKey === "string"
547
+ ? new TextEncoder().encode(partitionKey)
548
+ : partitionKey
549
+ }
550
+ : { kind: "balanced" });
551
+ await this.execute((client) => client.message.send({
552
+ streamId,
553
+ topicId,
554
+ messages: messages.map(({ payload, headers }) => ({
555
+ payload: Buffer.from(payload),
556
+ headers: [...headers].map(([key, value]) => ({
557
+ key: HeaderKeyFactory.String(key),
558
+ value: toIggyHeaderValue(value)
559
+ }))
560
+ })),
561
+ partition: Partitioning.PartitionId(resolvedPartition)
562
+ }), `failed to send to topic \`${topicId}\``);
563
+ }
564
+ async pollMessages(streamId, topicId, target, strategy, count, autoCommit) {
565
+ const reply = await this.execute((client) => client.message.poll({
566
+ streamId,
567
+ topicId,
568
+ partitionId: target.kind === "single" ? target.partitionId : null,
569
+ consumer: toIggyConsumer(target),
570
+ pollingStrategy: toIggyPollingStrategy(strategy),
571
+ count,
572
+ autocommit: autoCommit
573
+ }), `failed to poll topic \`${topicId}\``);
574
+ return reply.messages.map((message) => ({
575
+ payload: new Uint8Array(message.payload.buffer, message.payload.byteOffset, message.payload.byteLength),
576
+ partitionId: reply.partitionId,
577
+ offset: message.headers.offset,
578
+ timestampMicros: BigInt(message.headers.timestamp.getTime()) * 1000n,
579
+ headers: parsedHeadersToMap(message.userHeaders)
580
+ }));
581
+ }
582
+ async storeOffset(streamId, topicId, target, partitionId, offset) {
583
+ await this.execute((client) => client.offset.store({
584
+ streamId,
585
+ topicId,
586
+ consumer: toIggyConsumer(target),
587
+ partitionId,
588
+ offset
589
+ }), `failed to store offset for topic \`${topicId}\``);
590
+ }
591
+ async getConsumerOffset(streamId, topicId, target, partitionId) {
592
+ const offset = await this.execute((client) => client.offset.get({
593
+ streamId,
594
+ topicId,
595
+ consumer: toIggyOffsetConsumer(target),
596
+ partitionId
597
+ }), `failed to read offset for topic \`${topicId}\``);
598
+ return offset === null
599
+ ? undefined
600
+ : { storedOffset: offset.storedOffset, currentOffset: offset.currentOffset };
601
+ }
602
+ async joinConsumerGroup(streamId, topicId, name) {
603
+ await this.execute((client) => client.group.ensureAndJoin(streamId, topicId, name), `failed to join consumer group \`${name}\``);
604
+ this.consumerGroups.set(`${streamId}\0${topicId}\0${name}`, { streamId, topicId, name });
605
+ }
606
+ async leaveConsumerGroup(streamId, topicId, name) {
607
+ await this.execute((client) => client.group.leave({ streamId, topicId, groupId: name }), `failed to leave consumer group \`${name}\``);
608
+ this.consumerGroups.delete(`${streamId}\0${topicId}\0${name}`);
609
+ }
610
+ async close() {
611
+ this.closed = true;
612
+ this.consumerGroups.clear();
613
+ if (this.ownership === "owned")
614
+ await this.client.destroy();
615
+ }
616
+ topicKey(streamId, topicId) {
617
+ return `${streamId}\0${topicId}`;
618
+ }
619
+ async resolvePartition(streamId, topicId, routing) {
620
+ if (routing.kind === "partition")
621
+ return routing.partition;
622
+ const key = this.topicKey(streamId, topicId);
623
+ const partitionCount = this.partitionCounts.get(key) ?? (await this.getTopicPartitionCount(streamId, topicId));
624
+ if (partitionCount <= 0) {
625
+ throw new TransportError(`topic \`${topicId}\` on stream \`${streamId}\` has no partitions`, false);
626
+ }
627
+ if (routing.kind === "key")
628
+ return xxHash32(routing.key) % partitionCount;
629
+ const cursor = this.balancedCursors.get(key) ?? 0;
630
+ this.balancedCursors.set(key, (cursor + 1) >>> 0);
631
+ return cursor % partitionCount;
632
+ }
633
+ }
634
+ //# sourceMappingURL=apache-iggy.js.map