@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,650 @@
1
+ import { CodecError, InvalidError } from "../client/errors.js";
2
+ import { expectArray, expectBoolean, expectMap, expectString, expectU32, expectU64, field, singleVariantTag } from "./cbor.js";
3
+ import { KV_OP_VERSION } from "./codes.js";
4
+ import { decodeSourceRef, encodeSourceRef } from "./graph.js";
5
+ import { MAX_NAMESPACE_BYTES } from "./limits.js";
6
+ export function encodeMemoryRowScope(scope) {
7
+ const map = new Map();
8
+ if (scope.kind !== undefined)
9
+ map.set("kind", scope.kind);
10
+ if (scope.agent !== undefined)
11
+ map.set("agent", scope.agent);
12
+ if (scope.user !== undefined)
13
+ map.set("user", scope.user);
14
+ if (scope.app !== undefined)
15
+ map.set("app", scope.app);
16
+ if (scope.conversation !== undefined)
17
+ map.set("conversation", scope.conversation);
18
+ if (scope.source !== undefined)
19
+ map.set("source", encodeSourceRef(scope.source));
20
+ return map;
21
+ }
22
+ export function decodeMemoryRowScope(map, context) {
23
+ const kind = field.optionalString(map, "kind", context);
24
+ const agent = field.optionalString(map, "agent", context);
25
+ const user = field.optionalString(map, "user", context);
26
+ const app = field.optionalString(map, "app", context);
27
+ const conversation = field.optionalString(map, "conversation", context);
28
+ return {
29
+ ...(kind !== undefined ? { kind } : {}),
30
+ ...(agent !== undefined ? { agent } : {}),
31
+ ...(user !== undefined ? { user } : {}),
32
+ ...(app !== undefined ? { app } : {}),
33
+ ...(conversation !== undefined ? { conversation } : {}),
34
+ ...(map.has("source")
35
+ ? { source: decodeSourceRef(map.get("source"), `${context}.source`) }
36
+ : {})
37
+ };
38
+ }
39
+ export function encodeKvEntry(entry) {
40
+ const map = new Map();
41
+ map.set("key", entry.key);
42
+ map.set("value", entry.value);
43
+ if (entry.expiresAtMicros !== undefined)
44
+ map.set("expires_at_micros", entry.expiresAtMicros);
45
+ if (entry.version !== 0n)
46
+ map.set("version", entry.version);
47
+ if (entry.scope !== undefined)
48
+ map.set("scope", encodeMemoryRowScope(entry.scope));
49
+ if (entry.source !== undefined)
50
+ map.set("source", encodeSourceRef(entry.source));
51
+ return map;
52
+ }
53
+ export function decodeKvEntry(map, context) {
54
+ const expiresAtMicros = field.optionalU64(map, "expires_at_micros", context);
55
+ const version = field.optionalU64(map, "version", context);
56
+ const scopeMap = field.optionalMap(map, "scope", context);
57
+ return {
58
+ key: field.requiredBytes(map, "key", context),
59
+ value: field.requiredBytes(map, "value", context),
60
+ ...(expiresAtMicros !== undefined ? { expiresAtMicros } : {}),
61
+ version: version ?? 0n,
62
+ ...(scopeMap !== undefined
63
+ ? { scope: decodeMemoryRowScope(scopeMap, `${context}.scope`) }
64
+ : {}),
65
+ ...(map.has("source")
66
+ ? { source: decodeSourceRef(map.get("source"), `${context}.source`) }
67
+ : {})
68
+ };
69
+ }
70
+ export function kvEntryKeyString(entry) {
71
+ try {
72
+ return new TextDecoder("utf-8", { fatal: true }).decode(entry.key);
73
+ }
74
+ catch {
75
+ return undefined;
76
+ }
77
+ }
78
+ export function encodeKvPage(page) {
79
+ const map = new Map();
80
+ map.set("entries", page.entries.map((entry) => encodeKvEntry(entry)));
81
+ if (page.cursor !== undefined)
82
+ map.set("cursor", page.cursor);
83
+ return map;
84
+ }
85
+ export function decodeKvPage(map, context) {
86
+ const cursor = field.optionalBytes(map, "cursor", context);
87
+ return {
88
+ entries: field.requiredArray(map, "entries", context, (item, index) => decodeKvEntry(expectMap(item, `${context}.entries[${String(index)}]`), `${context}.entries[${String(index)}]`)),
89
+ ...(cursor !== undefined ? { cursor } : {})
90
+ };
91
+ }
92
+ export function encodeKvGet(get) {
93
+ const map = new Map();
94
+ map.set("v", KV_OP_VERSION);
95
+ map.set("namespace", get.namespace);
96
+ map.set("key", get.key);
97
+ if (get.ifNoneMatch !== undefined)
98
+ map.set("if_none_match", get.ifNoneMatch);
99
+ return map;
100
+ }
101
+ export function decodeKvGet(map, context) {
102
+ const ifNoneMatch = field.optionalU64(map, "if_none_match", context);
103
+ return {
104
+ namespace: field.requiredString(map, "namespace", context),
105
+ key: field.requiredBytes(map, "key", context),
106
+ ...(ifNoneMatch !== undefined ? { ifNoneMatch } : {})
107
+ };
108
+ }
109
+ export function encodeKvSet(set) {
110
+ const map = new Map();
111
+ map.set("v", KV_OP_VERSION);
112
+ map.set("namespace", set.namespace);
113
+ map.set("key", set.key);
114
+ map.set("value", set.value);
115
+ if (set.expiresAtMicros !== undefined)
116
+ map.set("expires_at_micros", set.expiresAtMicros);
117
+ return map;
118
+ }
119
+ export function decodeKvSet(map, context) {
120
+ const expiresAtMicros = field.optionalU64(map, "expires_at_micros", context);
121
+ return {
122
+ namespace: field.requiredString(map, "namespace", context),
123
+ key: field.requiredBytes(map, "key", context),
124
+ value: field.requiredBytes(map, "value", context),
125
+ ...(expiresAtMicros !== undefined ? { expiresAtMicros } : {})
126
+ };
127
+ }
128
+ export function encodeCasExpect(expect) {
129
+ return expect.kind === "match" ? new Map([["Match", expect.version]]) : "Absent";
130
+ }
131
+ export function decodeCasExpect(value, context) {
132
+ if (typeof value === "string") {
133
+ if (value === "Absent")
134
+ return { kind: "absent" };
135
+ throw new CodecError(`\`${value}\` is not a recognized cas expectation`, context, "expect");
136
+ }
137
+ const [tag, inner] = singleVariantTag(value, context);
138
+ if (tag === "Match") {
139
+ return { kind: "match", version: expectU64(inner, context) };
140
+ }
141
+ throw new CodecError(`\`${tag}\` is not a recognized cas expectation`, context, "expect");
142
+ }
143
+ export function encodeKvCas(cas) {
144
+ const map = new Map();
145
+ map.set("v", KV_OP_VERSION);
146
+ map.set("namespace", cas.namespace);
147
+ map.set("key", cas.key);
148
+ map.set("value", cas.value);
149
+ if (cas.expiresAtMicros !== undefined)
150
+ map.set("expires_at_micros", cas.expiresAtMicros);
151
+ map.set("expect", encodeCasExpect(cas.expect));
152
+ return map;
153
+ }
154
+ export function decodeKvCas(map, context) {
155
+ const expiresAtMicros = field.optionalU64(map, "expires_at_micros", context);
156
+ return {
157
+ namespace: field.requiredString(map, "namespace", context),
158
+ key: field.requiredBytes(map, "key", context),
159
+ value: field.requiredBytes(map, "value", context),
160
+ ...(expiresAtMicros !== undefined ? { expiresAtMicros } : {}),
161
+ expect: decodeCasExpect(map.get("expect"), context)
162
+ };
163
+ }
164
+ export function encodeKvCasFenced(cas) {
165
+ const map = new Map();
166
+ map.set("v", KV_OP_VERSION);
167
+ map.set("namespace", cas.namespace);
168
+ map.set("key", cas.key);
169
+ map.set("value", cas.value);
170
+ if (cas.expiresAtMicros !== undefined)
171
+ map.set("expires_at_micros", cas.expiresAtMicros);
172
+ map.set("expect", encodeCasExpect(cas.expect));
173
+ map.set("fence_key", cas.fenceKey);
174
+ map.set("fence_token", cas.fenceToken);
175
+ return map;
176
+ }
177
+ export function decodeKvCasFenced(map, context) {
178
+ const expiresAtMicros = field.optionalU64(map, "expires_at_micros", context);
179
+ return {
180
+ namespace: field.requiredString(map, "namespace", context),
181
+ key: field.requiredBytes(map, "key", context),
182
+ value: field.requiredBytes(map, "value", context),
183
+ ...(expiresAtMicros !== undefined ? { expiresAtMicros } : {}),
184
+ expect: decodeCasExpect(map.get("expect"), context),
185
+ fenceKey: field.requiredBytes(map, "fence_key", context),
186
+ fenceToken: field.requiredU64(map, "fence_token", context)
187
+ };
188
+ }
189
+ export function encodeKvDelete(del) {
190
+ const map = new Map();
191
+ map.set("v", KV_OP_VERSION);
192
+ map.set("namespace", del.namespace);
193
+ map.set("key", del.key);
194
+ if (del.ifMatch !== undefined)
195
+ map.set("if_match", del.ifMatch);
196
+ return map;
197
+ }
198
+ export function decodeKvDelete(map, context) {
199
+ const ifMatch = field.optionalU64(map, "if_match", context);
200
+ return {
201
+ namespace: field.requiredString(map, "namespace", context),
202
+ key: field.requiredBytes(map, "key", context),
203
+ ...(ifMatch !== undefined ? { ifMatch } : {})
204
+ };
205
+ }
206
+ export function encodeKvExists(exists) {
207
+ return new Map([
208
+ ["v", KV_OP_VERSION],
209
+ ["namespace", exists.namespace],
210
+ ["key", exists.key]
211
+ ]);
212
+ }
213
+ export function decodeKvExists(map, context) {
214
+ return {
215
+ namespace: field.requiredString(map, "namespace", context),
216
+ key: field.requiredBytes(map, "key", context)
217
+ };
218
+ }
219
+ export function encodeKvExpire(expire) {
220
+ const map = new Map();
221
+ map.set("v", KV_OP_VERSION);
222
+ map.set("namespace", expire.namespace);
223
+ map.set("key", expire.key);
224
+ if (expire.expiresAtMicros !== undefined)
225
+ map.set("expires_at_micros", expire.expiresAtMicros);
226
+ return map;
227
+ }
228
+ export function decodeKvExpire(map, context) {
229
+ const expiresAtMicros = field.optionalU64(map, "expires_at_micros", context);
230
+ return {
231
+ namespace: field.requiredString(map, "namespace", context),
232
+ key: field.requiredBytes(map, "key", context),
233
+ ...(expiresAtMicros !== undefined ? { expiresAtMicros } : {})
234
+ };
235
+ }
236
+ export function encodeKvPatch(patch) {
237
+ const map = new Map();
238
+ map.set("v", KV_OP_VERSION);
239
+ map.set("namespace", patch.namespace);
240
+ map.set("key", patch.key);
241
+ map.set("patch", patch.patch);
242
+ if (patch.ifMatch !== undefined)
243
+ map.set("if_match", patch.ifMatch);
244
+ return map;
245
+ }
246
+ export function decodeKvPatch(map, context) {
247
+ const ifMatch = field.optionalU64(map, "if_match", context);
248
+ return {
249
+ namespace: field.requiredString(map, "namespace", context),
250
+ key: field.requiredBytes(map, "key", context),
251
+ patch: field.requiredBytes(map, "patch", context),
252
+ ...(ifMatch !== undefined ? { ifMatch } : {})
253
+ };
254
+ }
255
+ export function encodeKvCopy(copy) {
256
+ const map = new Map();
257
+ map.set("v", KV_OP_VERSION);
258
+ map.set("namespace", copy.namespace);
259
+ map.set("key", copy.key);
260
+ if (copy.toNamespace !== undefined)
261
+ map.set("to_namespace", copy.toNamespace);
262
+ map.set("to_key", copy.toKey);
263
+ return map;
264
+ }
265
+ export function decodeKvCopy(map, context) {
266
+ const toNamespace = field.optionalString(map, "to_namespace", context);
267
+ return {
268
+ namespace: field.requiredString(map, "namespace", context),
269
+ key: field.requiredBytes(map, "key", context),
270
+ ...(toNamespace !== undefined ? { toNamespace } : {}),
271
+ toKey: field.requiredBytes(map, "to_key", context)
272
+ };
273
+ }
274
+ export function encodeKvMove(move) {
275
+ const map = new Map();
276
+ map.set("v", KV_OP_VERSION);
277
+ map.set("namespace", move.namespace);
278
+ map.set("key", move.key);
279
+ if (move.toNamespace !== undefined)
280
+ map.set("to_namespace", move.toNamespace);
281
+ map.set("to_key", move.toKey);
282
+ return map;
283
+ }
284
+ export function decodeKvMove(map, context) {
285
+ const toNamespace = field.optionalString(map, "to_namespace", context);
286
+ return {
287
+ namespace: field.requiredString(map, "namespace", context),
288
+ key: field.requiredBytes(map, "key", context),
289
+ ...(toNamespace !== undefined ? { toNamespace } : {}),
290
+ toKey: field.requiredBytes(map, "to_key", context)
291
+ };
292
+ }
293
+ export function encodeKvLease(lease) {
294
+ return new Map([
295
+ ["v", KV_OP_VERSION],
296
+ ["namespace", lease.namespace],
297
+ ["key", lease.key],
298
+ ["lease_ttl_micros", lease.leaseTtlMicros]
299
+ ]);
300
+ }
301
+ export function decodeKvLease(map, context) {
302
+ return {
303
+ namespace: field.requiredString(map, "namespace", context),
304
+ key: field.requiredBytes(map, "key", context),
305
+ leaseTtlMicros: field.requiredU64(map, "lease_ttl_micros", context)
306
+ };
307
+ }
308
+ export function encodeKvRelease(release) {
309
+ return new Map([
310
+ ["v", KV_OP_VERSION],
311
+ ["namespace", release.namespace],
312
+ ["key", release.key],
313
+ ["lease_token", release.leaseToken]
314
+ ]);
315
+ }
316
+ export function decodeKvRelease(map, context) {
317
+ return {
318
+ namespace: field.requiredString(map, "namespace", context),
319
+ key: field.requiredBytes(map, "key", context),
320
+ leaseToken: field.requiredU64(map, "lease_token", context)
321
+ };
322
+ }
323
+ export function encodeKvMetadata(meta) {
324
+ const map = new Map();
325
+ map.set("version", meta.version);
326
+ if (meta.expiresAtMicros !== undefined)
327
+ map.set("expires_at_micros", meta.expiresAtMicros);
328
+ map.set("size_bytes", meta.sizeBytes);
329
+ return map;
330
+ }
331
+ export function decodeKvMetadata(map, context) {
332
+ const expiresAtMicros = field.optionalU64(map, "expires_at_micros", context);
333
+ return {
334
+ version: field.requiredU64(map, "version", context),
335
+ ...(expiresAtMicros !== undefined ? { expiresAtMicros } : {}),
336
+ sizeBytes: field.requiredU32(map, "size_bytes", context)
337
+ };
338
+ }
339
+ export function encodeKvNamespaces() {
340
+ return new Map([["v", KV_OP_VERSION]]);
341
+ }
342
+ export function encodeKvNamespaceInfo(info) {
343
+ return new Map([
344
+ ["namespace", info.namespace],
345
+ ["entries", info.entries]
346
+ ]);
347
+ }
348
+ export function decodeKvNamespaceInfo(map, context) {
349
+ return {
350
+ namespace: field.requiredString(map, "namespace", context),
351
+ entries: field.requiredU32(map, "entries", context)
352
+ };
353
+ }
354
+ export function encodeKvScan(scan) {
355
+ const map = new Map();
356
+ map.set("v", KV_OP_VERSION);
357
+ map.set("namespace", scan.namespace);
358
+ if (scan.prefix !== undefined)
359
+ map.set("prefix", scan.prefix);
360
+ if (scan.start !== undefined)
361
+ map.set("start", scan.start);
362
+ if (scan.end !== undefined)
363
+ map.set("end", scan.end);
364
+ if (scan.keyContains !== undefined)
365
+ map.set("key_contains", scan.keyContains);
366
+ if (scan.conversation !== undefined)
367
+ map.set("conversation", scan.conversation);
368
+ map.set("limit", scan.limit);
369
+ if (scan.cursor !== undefined)
370
+ map.set("cursor", scan.cursor);
371
+ return map;
372
+ }
373
+ export function decodeKvScan(map, context) {
374
+ const prefix = field.optionalBytes(map, "prefix", context);
375
+ const start = field.optionalBytes(map, "start", context);
376
+ const end = field.optionalBytes(map, "end", context);
377
+ const keyContains = field.optionalString(map, "key_contains", context);
378
+ const conversation = field.optionalString(map, "conversation", context);
379
+ const cursor = field.optionalBytes(map, "cursor", context);
380
+ return {
381
+ namespace: field.requiredString(map, "namespace", context),
382
+ ...(prefix !== undefined ? { prefix } : {}),
383
+ ...(start !== undefined ? { start } : {}),
384
+ ...(end !== undefined ? { end } : {}),
385
+ ...(keyContains !== undefined ? { keyContains } : {}),
386
+ ...(conversation !== undefined ? { conversation } : {}),
387
+ limit: field.requiredU32(map, "limit", context),
388
+ ...(cursor !== undefined ? { cursor } : {})
389
+ };
390
+ }
391
+ export function encodeKvDeleteMany(deleteMany) {
392
+ const map = new Map();
393
+ map.set("v", KV_OP_VERSION);
394
+ map.set("namespace", deleteMany.namespace);
395
+ if (deleteMany.prefix !== undefined)
396
+ map.set("prefix", deleteMany.prefix);
397
+ if (deleteMany.start !== undefined)
398
+ map.set("start", deleteMany.start);
399
+ if (deleteMany.end !== undefined)
400
+ map.set("end", deleteMany.end);
401
+ if (deleteMany.keyContains !== undefined)
402
+ map.set("key_contains", deleteMany.keyContains);
403
+ if (deleteMany.conversation !== undefined)
404
+ map.set("conversation", deleteMany.conversation);
405
+ return map;
406
+ }
407
+ export function decodeKvDeleteMany(map, context) {
408
+ const prefix = field.optionalBytes(map, "prefix", context);
409
+ const start = field.optionalBytes(map, "start", context);
410
+ const end = field.optionalBytes(map, "end", context);
411
+ const keyContains = field.optionalString(map, "key_contains", context);
412
+ const conversation = field.optionalString(map, "conversation", context);
413
+ return {
414
+ namespace: field.requiredString(map, "namespace", context),
415
+ ...(prefix !== undefined ? { prefix } : {}),
416
+ ...(start !== undefined ? { start } : {}),
417
+ ...(end !== undefined ? { end } : {}),
418
+ ...(keyContains !== undefined ? { keyContains } : {}),
419
+ ...(conversation !== undefined ? { conversation } : {})
420
+ };
421
+ }
422
+ export function encodeKvOutcome(outcome) {
423
+ switch (outcome.kind) {
424
+ case "value":
425
+ return new Map([["Value", outcome.entry !== undefined ? encodeKvEntry(outcome.entry) : null]]);
426
+ case "written":
427
+ return "Written";
428
+ case "committed":
429
+ return new Map([["Committed", new Map([["version", outcome.version]])]]);
430
+ case "deleted":
431
+ return new Map([["Deleted", outcome.removed]]);
432
+ case "deletedMany":
433
+ return new Map([["DeletedMany", outcome.count]]);
434
+ case "page":
435
+ return new Map([["Page", encodeKvPage(outcome.page)]]);
436
+ case "namespaces":
437
+ return new Map([
438
+ ["Namespaces", outcome.namespaces.map((info) => encodeKvNamespaceInfo(info))]
439
+ ]);
440
+ case "notModified":
441
+ return "NotModified";
442
+ case "metadata":
443
+ return new Map([
444
+ ["Metadata", outcome.metadata !== undefined ? encodeKvMetadata(outcome.metadata) : null]
445
+ ]);
446
+ case "versioned":
447
+ return new Map([["Versioned", new Map([["version", outcome.version]])]]);
448
+ case "leased":
449
+ return new Map([
450
+ [
451
+ "Leased",
452
+ new Map([
453
+ ["lease_token", outcome.leaseToken],
454
+ ["granted_ttl_micros", outcome.grantedTtlMicros]
455
+ ])
456
+ ]
457
+ ]);
458
+ case "released":
459
+ return new Map([["Released", outcome.wasHeld]]);
460
+ case "unrecognized":
461
+ return new Map([[outcome.tag, outcome.value]]);
462
+ }
463
+ }
464
+ export function decodeKvOutcome(value, context) {
465
+ if (typeof value === "string") {
466
+ if (value === "Written")
467
+ return { kind: "written" };
468
+ if (value === "NotModified")
469
+ return { kind: "notModified" };
470
+ return { kind: "unrecognized", tag: value, value: undefined };
471
+ }
472
+ const [tag, inner] = singleVariantTag(value, context);
473
+ switch (tag) {
474
+ case "Value":
475
+ return {
476
+ kind: "value",
477
+ ...(inner !== null && inner !== undefined
478
+ ? { entry: decodeKvEntry(expectMap(inner, context), context) }
479
+ : {})
480
+ };
481
+ case "Committed":
482
+ return {
483
+ kind: "committed",
484
+ version: field.requiredU64(expectMap(inner, context), "version", context)
485
+ };
486
+ case "Deleted":
487
+ return { kind: "deleted", removed: expectBoolean(inner, context) };
488
+ case "DeletedMany":
489
+ return { kind: "deletedMany", count: expectU32(inner, context) };
490
+ case "Page":
491
+ return { kind: "page", page: decodeKvPage(expectMap(inner, context), context) };
492
+ case "Namespaces":
493
+ return {
494
+ kind: "namespaces",
495
+ namespaces: expectArray(inner, context).map((item, index) => decodeKvNamespaceInfo(expectMap(item, `${context}[${String(index)}]`), `${context}[${String(index)}]`))
496
+ };
497
+ case "Metadata": {
498
+ return {
499
+ kind: "metadata",
500
+ ...(inner !== null && inner !== undefined
501
+ ? { metadata: decodeKvMetadata(expectMap(inner, context), context) }
502
+ : {})
503
+ };
504
+ }
505
+ case "Versioned":
506
+ return {
507
+ kind: "versioned",
508
+ version: field.requiredU64(expectMap(inner, context), "version", context)
509
+ };
510
+ case "Leased": {
511
+ const leasedMap = expectMap(inner, context);
512
+ return {
513
+ kind: "leased",
514
+ leaseToken: field.requiredU64(leasedMap, "lease_token", context),
515
+ grantedTtlMicros: field.requiredU64(leasedMap, "granted_ttl_micros", context)
516
+ };
517
+ }
518
+ case "Released":
519
+ return { kind: "released", wasHeld: expectBoolean(inner, context) };
520
+ default:
521
+ return { kind: "unrecognized", tag, value: inner };
522
+ }
523
+ }
524
+ export function encodeKvError(error) {
525
+ switch (error.kind) {
526
+ case "unsupported":
527
+ return new Map([["Unsupported", error.message]]);
528
+ case "invalidKey":
529
+ return new Map([["InvalidKey", error.message]]);
530
+ case "invalidNamespace":
531
+ return new Map([["InvalidNamespace", error.message]]);
532
+ case "tooLarge":
533
+ return new Map([
534
+ [
535
+ "TooLarge",
536
+ new Map([
537
+ ["what", error.what],
538
+ ["size", error.size],
539
+ ["cap", error.cap]
540
+ ])
541
+ ]
542
+ ]);
543
+ case "backend":
544
+ return new Map([["Backend", error.message]]);
545
+ case "version":
546
+ return new Map([
547
+ [
548
+ "Version",
549
+ new Map([
550
+ ["expected", error.expected],
551
+ ["got", error.got]
552
+ ])
553
+ ]
554
+ ]);
555
+ case "versionConflict":
556
+ return new Map([
557
+ ["VersionConflict", new Map([["current", error.current ?? null]])]
558
+ ]);
559
+ case "leaseLost":
560
+ return "LeaseLost";
561
+ case "notFound":
562
+ return "NotFound";
563
+ case "notLeader":
564
+ return "NotLeader";
565
+ case "unrecognized":
566
+ return new Map([[error.tag, error.value]]);
567
+ }
568
+ }
569
+ export function decodeKvError(value, context) {
570
+ if (typeof value === "string") {
571
+ if (value === "LeaseLost")
572
+ return { kind: "leaseLost" };
573
+ if (value === "NotFound")
574
+ return { kind: "notFound" };
575
+ if (value === "NotLeader")
576
+ return { kind: "notLeader" };
577
+ return { kind: "unrecognized", tag: value, value: undefined };
578
+ }
579
+ const [tag, inner] = singleVariantTag(value, context);
580
+ switch (tag) {
581
+ case "Unsupported":
582
+ return { kind: "unsupported", message: expectString(inner, context) };
583
+ case "InvalidKey":
584
+ return { kind: "invalidKey", message: expectString(inner, context) };
585
+ case "InvalidNamespace":
586
+ return { kind: "invalidNamespace", message: expectString(inner, context) };
587
+ case "TooLarge": {
588
+ const tooLargeMap = expectMap(inner, context);
589
+ return {
590
+ kind: "tooLarge",
591
+ what: field.requiredString(tooLargeMap, "what", context),
592
+ size: field.requiredU32(tooLargeMap, "size", context),
593
+ cap: field.requiredU32(tooLargeMap, "cap", context)
594
+ };
595
+ }
596
+ case "Backend":
597
+ return { kind: "backend", message: expectString(inner, context) };
598
+ case "Version": {
599
+ const versionMap = expectMap(inner, context);
600
+ return {
601
+ kind: "version",
602
+ expected: field.requiredU32(versionMap, "expected", context),
603
+ got: field.requiredU32(versionMap, "got", context)
604
+ };
605
+ }
606
+ case "VersionConflict": {
607
+ const conflictMap = expectMap(inner, context);
608
+ const current = field.optionalU64(conflictMap, "current", context);
609
+ return { kind: "versionConflict", ...(current !== undefined ? { current } : {}) };
610
+ }
611
+ default:
612
+ return { kind: "unrecognized", tag, value: inner };
613
+ }
614
+ }
615
+ export function encodeKvReply(reply) {
616
+ switch (reply.kind) {
617
+ case "ok":
618
+ return new Map([["Ok", encodeKvOutcome(reply.outcome)]]);
619
+ case "err":
620
+ return new Map([["Err", encodeKvError(reply.error)]]);
621
+ case "unrecognized":
622
+ return new Map([[reply.tag, reply.value]]);
623
+ }
624
+ }
625
+ export function decodeKvReply(value, context) {
626
+ const [tag, inner] = singleVariantTag(value, context);
627
+ switch (tag) {
628
+ case "Ok":
629
+ return { kind: "ok", outcome: decodeKvOutcome(inner, context) };
630
+ case "Err":
631
+ return { kind: "err", error: decodeKvError(inner, context) };
632
+ default:
633
+ return { kind: "unrecognized", tag, value: inner };
634
+ }
635
+ }
636
+ export function validateNamespace(namespace) {
637
+ if (namespace.length === 0) {
638
+ throw new InvalidError("namespace must not be empty");
639
+ }
640
+ const bytes = new TextEncoder().encode(namespace);
641
+ if (bytes.length > MAX_NAMESPACE_BYTES) {
642
+ throw new InvalidError(`namespace is ${String(bytes.length)}B, exceeds cap ${String(MAX_NAMESPACE_BYTES)}B`);
643
+ }
644
+ for (const byte of bytes) {
645
+ if (byte < 0x20 || byte === 0x7f) {
646
+ throw new InvalidError("namespace must not contain ASCII control characters");
647
+ }
648
+ }
649
+ }
650
+ //# sourceMappingURL=kv.js.map