doover-js 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (389) hide show
  1. package/README.md +106 -0
  2. package/dist/apis/_args.js +5 -5
  3. package/dist/apis/agents-api.d.ts +4 -4
  4. package/dist/apis/agents-api.js +2 -2
  5. package/dist/apis/aggregates-api.d.ts +4 -4
  6. package/dist/apis/aggregates-api.js +5 -5
  7. package/dist/apis/alarms-api.d.ts +2 -2
  8. package/dist/apis/alarms-api.js +3 -3
  9. package/dist/apis/channels-api.d.ts +3 -3
  10. package/dist/apis/channels-api.js +6 -6
  11. package/dist/apis/connections-api.d.ts +2 -2
  12. package/dist/apis/connections-api.js +6 -6
  13. package/dist/apis/messages-api.d.ts +4 -4
  14. package/dist/apis/messages-api.js +11 -11
  15. package/dist/apis/notifications-api.d.ts +2 -2
  16. package/dist/apis/notifications-api.js +4 -4
  17. package/dist/apis/organisations-api.d.ts +2 -2
  18. package/dist/apis/permissions-api.d.ts +2 -2
  19. package/dist/apis/permissions-api.js +3 -3
  20. package/dist/apis/processors-api.d.ts +2 -2
  21. package/dist/apis/turn-api.d.ts +2 -2
  22. package/dist/apis/users-api.d.ts +2 -2
  23. package/dist/auth/auth-store.d.ts +1 -1
  24. package/dist/auth/build-auth.d.ts +3 -3
  25. package/dist/auth/build-auth.js +8 -8
  26. package/dist/auth/cookie-auth.d.ts +1 -1
  27. package/dist/auth/cookie-auth.js +2 -2
  28. package/dist/auth/doover-auth.d.ts +2 -2
  29. package/dist/auth/doover-token-auth.d.ts +3 -3
  30. package/dist/auth/doover-token-auth.js +13 -13
  31. package/dist/auth/index.d.ts +10 -0
  32. package/dist/auth/index.js +15 -0
  33. package/dist/client/data-client.d.ts +17 -14
  34. package/dist/client/doover-client.d.ts +9 -7
  35. package/dist/client/doover-client.js +44 -42
  36. package/dist/client/errors.d.ts +2 -2
  37. package/dist/client/errors.js +4 -4
  38. package/dist/client/index.d.ts +6 -0
  39. package/dist/client/index.js +12 -0
  40. package/dist/client/local-agent-client.d.ts +3 -3
  41. package/dist/client/local-agent-client.js +19 -19
  42. package/dist/client/multiplex-client.d.ts +5 -5
  43. package/dist/client/multiplex-client.js +25 -25
  44. package/dist/client/multiplex-gateway.d.ts +3 -3
  45. package/dist/client/multiplex-merge.d.ts +1 -1
  46. package/dist/client/network-status.d.ts +17 -0
  47. package/dist/client/network-status.js +70 -0
  48. package/dist/client/offline-cache.d.ts +9 -4
  49. package/dist/client/offline-cache.js +34 -22
  50. package/dist/client/provenance.d.ts +1 -1
  51. package/dist/client/request-options.d.ts +1 -1
  52. package/dist/client/singleton.d.ts +2 -2
  53. package/dist/client/singleton.js +2 -2
  54. package/dist/client/status-tracker.d.ts +1 -1
  55. package/dist/esm/apis/_args.d.ts +16 -0
  56. package/dist/esm/apis/_args.js +27 -0
  57. package/dist/esm/apis/agents-api.d.ts +196 -0
  58. package/dist/esm/apis/agents-api.js +327 -0
  59. package/dist/esm/apis/aggregates-api.d.ts +67 -0
  60. package/dist/esm/apis/aggregates-api.js +64 -0
  61. package/dist/esm/apis/alarms-api.d.ts +48 -0
  62. package/dist/esm/apis/alarms-api.js +75 -0
  63. package/dist/esm/apis/channels-api.d.ts +83 -0
  64. package/dist/esm/apis/channels-api.js +65 -0
  65. package/dist/esm/apis/connections-api.d.ts +45 -0
  66. package/dist/esm/apis/connections-api.js +44 -0
  67. package/dist/esm/apis/messages-api.d.ts +128 -0
  68. package/dist/esm/apis/messages-api.js +179 -0
  69. package/dist/esm/apis/notifications-api.d.ts +94 -0
  70. package/dist/esm/apis/notifications-api.js +153 -0
  71. package/dist/esm/apis/organisations-api.d.ts +26 -0
  72. package/dist/esm/apis/organisations-api.js +41 -0
  73. package/dist/esm/apis/permissions-api.d.ts +17 -0
  74. package/dist/esm/apis/permissions-api.js +23 -0
  75. package/dist/esm/apis/processors-api.d.ts +56 -0
  76. package/dist/esm/apis/processors-api.js +97 -0
  77. package/dist/esm/apis/turn-api.d.ts +7 -0
  78. package/dist/esm/apis/turn-api.js +8 -0
  79. package/dist/esm/apis/users-api.d.ts +8 -0
  80. package/dist/esm/apis/users-api.js +9 -0
  81. package/dist/esm/auth/auth-profile.d.ts +45 -0
  82. package/dist/esm/auth/auth-profile.js +68 -0
  83. package/dist/esm/auth/auth-store.d.ts +14 -0
  84. package/dist/esm/auth/build-auth.d.ts +38 -0
  85. package/dist/esm/auth/build-auth.js +92 -0
  86. package/dist/esm/auth/cookie-auth.d.ts +91 -0
  87. package/dist/esm/auth/cookie-auth.js +196 -0
  88. package/dist/esm/auth/doover-auth.d.ts +52 -0
  89. package/dist/esm/auth/doover-auth.js +28 -0
  90. package/dist/esm/auth/doover-token-auth.d.ts +39 -0
  91. package/dist/esm/auth/doover-token-auth.js +217 -0
  92. package/dist/esm/auth/errors.d.ts +3 -0
  93. package/dist/esm/auth/errors.js +6 -0
  94. package/dist/esm/auth/index.d.ts +10 -0
  95. package/dist/esm/auth/index.js +6 -0
  96. package/dist/esm/auth/jwt.d.ts +6 -0
  97. package/dist/esm/auth/jwt.js +26 -0
  98. package/dist/esm/client/capabilities.d.ts +10 -0
  99. package/dist/esm/client/capabilities.js +42 -0
  100. package/dist/esm/client/data-client.d.ts +107 -0
  101. package/dist/esm/client/doover-client.d.ts +48 -0
  102. package/dist/esm/client/doover-client.js +96 -0
  103. package/dist/esm/client/errors.d.ts +32 -0
  104. package/dist/esm/client/errors.js +64 -0
  105. package/dist/esm/client/index.d.ts +6 -0
  106. package/dist/esm/client/index.js +3 -0
  107. package/dist/esm/client/local-agent-client.d.ts +65 -0
  108. package/dist/esm/client/local-agent-client.js +225 -0
  109. package/dist/esm/client/multiplex-client.d.ts +165 -0
  110. package/dist/esm/client/multiplex-client.js +842 -0
  111. package/dist/esm/client/multiplex-gateway.d.ts +49 -0
  112. package/dist/esm/client/multiplex-gateway.js +110 -0
  113. package/dist/esm/client/multiplex-merge.d.ts +12 -0
  114. package/dist/esm/client/multiplex-merge.js +38 -0
  115. package/dist/esm/client/network-status.d.ts +17 -0
  116. package/dist/esm/client/network-status.js +66 -0
  117. package/dist/esm/client/offline-cache.d.ts +167 -0
  118. package/dist/esm/client/offline-cache.js +769 -0
  119. package/dist/esm/client/provenance.d.ts +60 -0
  120. package/dist/esm/client/provenance.js +108 -0
  121. package/dist/esm/client/request-options.d.ts +23 -0
  122. package/dist/esm/client/request-options.js +23 -0
  123. package/dist/esm/client/singleton.d.ts +26 -0
  124. package/dist/esm/client/singleton.js +54 -0
  125. package/dist/esm/client/stats.d.ts +79 -0
  126. package/dist/esm/client/stats.js +155 -0
  127. package/dist/esm/client/status-tracker.d.ts +24 -0
  128. package/dist/esm/client/status-tracker.js +86 -0
  129. package/dist/esm/gateway/gateway-client.d.ts +86 -0
  130. package/dist/esm/gateway/gateway-client.js +463 -0
  131. package/dist/esm/gateway/index.d.ts +3 -0
  132. package/dist/esm/gateway/index.js +1 -0
  133. package/dist/esm/gateway/types.d.ts +142 -0
  134. package/dist/esm/http/errors.d.ts +19 -0
  135. package/dist/esm/http/errors.js +22 -0
  136. package/dist/esm/http/index.d.ts +3 -0
  137. package/dist/esm/http/index.js +2 -0
  138. package/dist/esm/http/rest-client.d.ts +64 -0
  139. package/dist/esm/http/rest-client.js +181 -0
  140. package/dist/esm/index.d.ts +64 -0
  141. package/dist/esm/index.js +38 -0
  142. package/dist/esm/node/config-manager.d.ts +34 -0
  143. package/dist/esm/node/config-manager.js +140 -0
  144. package/dist/esm/node/index.d.ts +1 -0
  145. package/dist/esm/node/index.js +1 -0
  146. package/dist/esm/package.json +1 -0
  147. package/dist/esm/react/context.d.ts +23 -0
  148. package/dist/esm/react/context.js +28 -0
  149. package/dist/esm/react/index.d.ts +38 -0
  150. package/dist/esm/react/index.js +21 -0
  151. package/dist/esm/react/messageRangeStore.d.ts +93 -0
  152. package/dist/esm/react/messageRangeStore.js +140 -0
  153. package/dist/esm/react/sharedQueryClient.d.ts +21 -0
  154. package/dist/esm/react/sharedQueryClient.js +35 -0
  155. package/dist/esm/react/useAgentChannel.d.ts +8 -0
  156. package/dist/esm/react/useAgentChannel.js +9 -0
  157. package/dist/esm/react/useAgentConnections.d.ts +8 -0
  158. package/dist/esm/react/useAgentConnections.js +20 -0
  159. package/dist/esm/react/useAgentTokenState.d.ts +70 -0
  160. package/dist/esm/react/useAgentTokenState.js +127 -0
  161. package/dist/esm/react/useChannelAggregate.d.ts +64 -0
  162. package/dist/esm/react/useChannelAggregate.js +77 -0
  163. package/dist/esm/react/useChannelMessage.d.ts +45 -0
  164. package/dist/esm/react/useChannelMessage.js +79 -0
  165. package/dist/esm/react/useChannelMessages.d.ts +83 -0
  166. package/dist/esm/react/useChannelMessages.js +214 -0
  167. package/dist/esm/react/useChannelSubscription.d.ts +27 -0
  168. package/dist/esm/react/useChannelSubscription.js +30 -0
  169. package/dist/esm/react/useClientStatus.d.ts +10 -0
  170. package/dist/esm/react/useClientStatus.js +19 -0
  171. package/dist/esm/react/useConnectionState.d.ts +26 -0
  172. package/dist/esm/react/useConnectionState.js +45 -0
  173. package/dist/esm/react/useDeviceMap.d.ts +109 -0
  174. package/dist/esm/react/useDeviceMap.js +59 -0
  175. package/dist/esm/react/useInvocationLogs.d.ts +23 -0
  176. package/dist/esm/react/useInvocationLogs.js +37 -0
  177. package/dist/esm/react/useMultiAgentAggregates.d.ts +38 -0
  178. package/dist/esm/react/useMultiAgentAggregates.js +104 -0
  179. package/dist/esm/react/useMultiAgentChannelMessages.d.ts +79 -0
  180. package/dist/esm/react/useMultiAgentChannelMessages.js +169 -0
  181. package/dist/esm/react/useOfflineStatus.d.ts +8 -0
  182. package/dist/esm/react/useOfflineStatus.js +37 -0
  183. package/dist/esm/react/useSendMessage.d.ts +16 -0
  184. package/dist/esm/react/useSendMessage.js +26 -0
  185. package/dist/esm/react/useSendRpc.d.ts +68 -0
  186. package/dist/esm/react/useSendRpc.js +164 -0
  187. package/dist/esm/react/useTurnCredentials.d.ts +12 -0
  188. package/dist/esm/react/useTurnCredentials.js +22 -0
  189. package/dist/esm/react/useUpdateAggregate.d.ts +27 -0
  190. package/dist/esm/react/useUpdateAggregate.js +39 -0
  191. package/dist/esm/react/useUpdateMessage.d.ts +38 -0
  192. package/dist/esm/react/useUpdateMessage.js +36 -0
  193. package/dist/esm/refine/index.d.ts +72 -0
  194. package/dist/esm/refine/index.js +215 -0
  195. package/dist/esm/rpc/errors.d.ts +10 -0
  196. package/dist/esm/rpc/errors.js +19 -0
  197. package/dist/esm/rpc/index.d.ts +3 -0
  198. package/dist/esm/rpc/index.js +2 -0
  199. package/dist/esm/rpc/rpc-dispatcher.d.ts +41 -0
  200. package/dist/esm/rpc/rpc-dispatcher.js +141 -0
  201. package/dist/esm/types/audit.d.ts +53 -0
  202. package/dist/esm/types/audit.js +11 -0
  203. package/dist/esm/types/batch.d.ts +85 -0
  204. package/dist/esm/types/batch.js +42 -0
  205. package/dist/esm/types/common.d.ts +250 -0
  206. package/dist/esm/types/connection.d.ts +72 -0
  207. package/dist/esm/types/connection.js +7 -0
  208. package/dist/esm/types/index.d.ts +9 -0
  209. package/dist/esm/types/openapi.d.ts +195 -0
  210. package/dist/esm/types/provenance.d.ts +45 -0
  211. package/dist/esm/types/viewer.d.ts +122 -0
  212. package/dist/esm/utils/snowflake.d.ts +21 -0
  213. package/dist/esm/utils/snowflake.js +33 -0
  214. package/dist/esm/viewer/doover-data-provider.d.ts +90 -0
  215. package/dist/esm/viewer/doover-data-provider.js +189 -0
  216. package/dist/esm/viewer/path-parsing.d.ts +5 -0
  217. package/dist/esm/viewer/path-parsing.js +35 -0
  218. package/dist/gateway/gateway-client.d.ts +5 -5
  219. package/dist/gateway/gateway-client.js +5 -5
  220. package/dist/gateway/index.d.ts +3 -0
  221. package/dist/gateway/index.js +5 -0
  222. package/dist/gateway/types.d.ts +1 -1
  223. package/dist/http/index.d.ts +3 -0
  224. package/dist/http/index.js +9 -0
  225. package/dist/http/rest-client.d.ts +5 -3
  226. package/dist/http/rest-client.js +2 -2
  227. package/dist/index.d.ts +64 -62
  228. package/dist/index.js +92 -89
  229. package/dist/node/config-manager.d.ts +2 -2
  230. package/dist/node/config-manager.js +5 -5
  231. package/dist/node/index.d.ts +1 -1
  232. package/dist/node/index.js +2 -2
  233. package/dist/react/context.d.ts +1 -1
  234. package/dist/react/index.d.ts +38 -38
  235. package/dist/react/index.js +59 -59
  236. package/dist/react/messageRangeStore.d.ts +1 -1
  237. package/dist/react/useAgentChannel.d.ts +3 -3
  238. package/dist/react/useAgentChannel.js +2 -2
  239. package/dist/react/useAgentConnections.d.ts +1 -1
  240. package/dist/react/useAgentConnections.js +2 -2
  241. package/dist/react/useAgentTokenState.d.ts +3 -3
  242. package/dist/react/useAgentTokenState.js +8 -8
  243. package/dist/react/useChannelAggregate.d.ts +3 -3
  244. package/dist/react/useChannelAggregate.js +8 -8
  245. package/dist/react/useChannelMessage.d.ts +2 -2
  246. package/dist/react/useChannelMessage.js +4 -4
  247. package/dist/react/useChannelMessages.d.ts +3 -3
  248. package/dist/react/useChannelMessages.js +10 -10
  249. package/dist/react/useChannelSubscription.d.ts +2 -2
  250. package/dist/react/useChannelSubscription.js +2 -2
  251. package/dist/react/useClientStatus.d.ts +1 -1
  252. package/dist/react/useClientStatus.js +2 -2
  253. package/dist/react/useConnectionState.js +2 -2
  254. package/dist/react/useDeviceMap.js +2 -2
  255. package/dist/react/useInvocationLogs.d.ts +1 -1
  256. package/dist/react/useInvocationLogs.js +2 -2
  257. package/dist/react/useMultiAgentAggregates.d.ts +1 -1
  258. package/dist/react/useMultiAgentAggregates.js +5 -5
  259. package/dist/react/useMultiAgentChannelMessages.d.ts +1 -1
  260. package/dist/react/useMultiAgentChannelMessages.js +2 -2
  261. package/dist/react/useOfflineStatus.d.ts +2 -2
  262. package/dist/react/useOfflineStatus.js +31 -17
  263. package/dist/react/useSendMessage.d.ts +2 -2
  264. package/dist/react/useSendMessage.js +2 -2
  265. package/dist/react/useSendRpc.d.ts +2 -2
  266. package/dist/react/useSendRpc.js +2 -2
  267. package/dist/react/useTurnCredentials.d.ts +2 -2
  268. package/dist/react/useTurnCredentials.js +2 -2
  269. package/dist/react/useUpdateAggregate.d.ts +3 -3
  270. package/dist/react/useUpdateAggregate.js +4 -4
  271. package/dist/react/useUpdateMessage.d.ts +2 -2
  272. package/dist/react/useUpdateMessage.js +2 -2
  273. package/dist/refine/index.d.ts +1 -1
  274. package/dist/rpc/errors.d.ts +1 -1
  275. package/dist/rpc/index.d.ts +3 -0
  276. package/dist/rpc/index.js +7 -0
  277. package/dist/rpc/rpc-dispatcher.d.ts +4 -4
  278. package/dist/rpc/rpc-dispatcher.js +2 -2
  279. package/dist/types/common.d.ts +1 -1
  280. package/dist/types/index.d.ts +9 -0
  281. package/dist/types/index.js +2 -0
  282. package/dist/types/openapi.d.ts +1 -1
  283. package/dist/types/viewer.d.ts +2 -2
  284. package/dist/viewer/doover-data-provider.d.ts +10 -10
  285. package/dist/viewer/doover-data-provider.js +25 -25
  286. package/dist/viewer/path-parsing.d.ts +1 -1
  287. package/package.json +795 -8
  288. package/dist/test/api-args.test.js +0 -48
  289. package/dist/test/api-overloads.test.d.ts +0 -9
  290. package/dist/test/api-overloads.test.js +0 -330
  291. package/dist/test/apis.test.js +0 -408
  292. package/dist/test/auth.test.js +0 -708
  293. package/dist/test/batch-apis.test.js +0 -183
  294. package/dist/test/capabilities.test.js +0 -27
  295. package/dist/test/config-manager.test.js +0 -160
  296. package/dist/test/data-client-errors.test.js +0 -24
  297. package/dist/test/data-client-shape.test.js +0 -28
  298. package/dist/test/doover-client-dataclient.test.d.ts +0 -1
  299. package/dist/test/doover-client-dataclient.test.js +0 -58
  300. package/dist/test/doover-client-provenance.test.d.ts +0 -1
  301. package/dist/test/doover-client-provenance.test.js +0 -32
  302. package/dist/test/doover-client.test.d.ts +0 -1
  303. package/dist/test/doover-client.test.js +0 -42
  304. package/dist/test/doover-data-provider.test.d.ts +0 -1
  305. package/dist/test/doover-data-provider.test.js +0 -657
  306. package/dist/test/exports.test.d.ts +0 -1
  307. package/dist/test/exports.test.js +0 -80
  308. package/dist/test/gateway-client.test.d.ts +0 -1
  309. package/dist/test/gateway-client.test.js +0 -474
  310. package/dist/test/gateway-provenance.test.d.ts +0 -1
  311. package/dist/test/gateway-provenance.test.js +0 -29
  312. package/dist/test/gateway-subscriptions.test.d.ts +0 -1
  313. package/dist/test/gateway-subscriptions.test.js +0 -95
  314. package/dist/test/helpers.d.ts +0 -32
  315. package/dist/test/helpers.js +0 -115
  316. package/dist/test/local-agent-client.test.d.ts +0 -1
  317. package/dist/test/local-agent-client.test.js +0 -202
  318. package/dist/test/message-range-store.test.d.ts +0 -1
  319. package/dist/test/message-range-store.test.js +0 -183
  320. package/dist/test/multiplex-capabilities.test.d.ts +0 -1
  321. package/dist/test/multiplex-capabilities.test.js +0 -37
  322. package/dist/test/multiplex-conflicts.test.d.ts +0 -1
  323. package/dist/test/multiplex-conflicts.test.js +0 -35
  324. package/dist/test/multiplex-gateway.test.d.ts +0 -1
  325. package/dist/test/multiplex-gateway.test.js +0 -103
  326. package/dist/test/multiplex-merge.test.d.ts +0 -1
  327. package/dist/test/multiplex-merge.test.js +0 -19
  328. package/dist/test/multiplex-noncore.test.d.ts +0 -1
  329. package/dist/test/multiplex-noncore.test.js +0 -82
  330. package/dist/test/multiplex-passthrough.test.d.ts +0 -1
  331. package/dist/test/multiplex-passthrough.test.js +0 -35
  332. package/dist/test/multiplex-reads.test.d.ts +0 -1
  333. package/dist/test/multiplex-reads.test.js +0 -87
  334. package/dist/test/multiplex-registry.test.d.ts +0 -1
  335. package/dist/test/multiplex-registry.test.js +0 -81
  336. package/dist/test/multiplex-routing.test.d.ts +0 -1
  337. package/dist/test/multiplex-routing.test.js +0 -45
  338. package/dist/test/multiplex-status.test.d.ts +0 -1
  339. package/dist/test/multiplex-status.test.js +0 -63
  340. package/dist/test/multiplex-writes.test.d.ts +0 -1
  341. package/dist/test/multiplex-writes.test.js +0 -93
  342. package/dist/test/offline-cache.test.d.ts +0 -1
  343. package/dist/test/offline-cache.test.js +0 -289
  344. package/dist/test/provenance-regression.test.d.ts +0 -1
  345. package/dist/test/provenance-regression.test.js +0 -45
  346. package/dist/test/provenance-stamper.test.d.ts +0 -1
  347. package/dist/test/provenance-stamper.test.js +0 -41
  348. package/dist/test/provenance-type.test.d.ts +0 -1
  349. package/dist/test/provenance-type.test.js +0 -15
  350. package/dist/test/react-channel-messages-forward.test.d.ts +0 -1
  351. package/dist/test/react-channel-messages-forward.test.js +0 -139
  352. package/dist/test/react-channel-messages-range.test.d.ts +0 -1
  353. package/dist/test/react-channel-messages-range.test.js +0 -109
  354. package/dist/test/react-client-status.test.d.ts +0 -1
  355. package/dist/test/react-client-status.test.js +0 -35
  356. package/dist/test/react-dataclient.test.d.ts +0 -1
  357. package/dist/test/react-dataclient.test.js +0 -28
  358. package/dist/test/react-exports.test.d.ts +0 -1
  359. package/dist/test/react-exports.test.js +0 -46
  360. package/dist/test/react-multiagent-messages.test.d.ts +0 -1
  361. package/dist/test/react-multiagent-messages.test.js +0 -113
  362. package/dist/test/react-sources-option.test.d.ts +0 -1
  363. package/dist/test/react-sources-option.test.js +0 -41
  364. package/dist/test/react.test.d.ts +0 -1
  365. package/dist/test/react.test.js +0 -482
  366. package/dist/test/refine.test.d.ts +0 -1
  367. package/dist/test/refine.test.js +0 -71
  368. package/dist/test/rest-client.test.d.ts +0 -1
  369. package/dist/test/rest-client.test.js +0 -197
  370. package/dist/test/rpc-dispatcher.test.d.ts +0 -1
  371. package/dist/test/rpc-dispatcher.test.js +0 -251
  372. package/dist/test/singleton.test.d.ts +0 -1
  373. package/dist/test/singleton.test.js +0 -62
  374. package/dist/test/stats-rpc.test.d.ts +0 -1
  375. package/dist/test/stats-rpc.test.js +0 -69
  376. package/dist/test/status-tracker.test.d.ts +0 -1
  377. package/dist/test/status-tracker.test.js +0 -85
  378. package/dist/test/users-api.test.d.ts +0 -1
  379. package/dist/test/users-api.test.js +0 -19
  380. package/dist/test/utils.test.d.ts +0 -1
  381. package/dist/test/utils.test.js +0 -64
  382. /package/dist/{test/api-args.test.d.ts → esm/auth/auth-store.js} +0 -0
  383. /package/dist/{test/apis.test.d.ts → esm/client/data-client.js} +0 -0
  384. /package/dist/{test/auth.test.d.ts → esm/gateway/types.js} +0 -0
  385. /package/dist/{test/batch-apis.test.d.ts → esm/types/common.js} +0 -0
  386. /package/dist/{test/capabilities.test.d.ts → esm/types/index.js} +0 -0
  387. /package/dist/{test/config-manager.test.d.ts → esm/types/openapi.js} +0 -0
  388. /package/dist/{test/data-client-errors.test.d.ts → esm/types/provenance.js} +0 -0
  389. /package/dist/{test/data-client-shape.test.d.ts → esm/types/viewer.js} +0 -0
@@ -0,0 +1,38 @@
1
+ export { DooverProvider, useDooverClient } from "./context.js";
2
+ export type { DooverProviderProps } from "./context.js";
3
+ export type { DataClientStatus, DataClientConnectionState, AgentScope } from "../client/data-client.js";
4
+ export { useClientStatus } from "./useClientStatus.js";
5
+ export { useOfflineStatus, hasOfflineStatus } from "./useOfflineStatus.js";
6
+ export type { OfflineStatusSnapshot, OfflineStatusClient } from "./useOfflineStatus.js";
7
+ export { useConnectionState } from "./useConnectionState.js";
8
+ export type { ConnectionState, ConnectionStatus } from "./useConnectionState.js";
9
+ export { useAgentConnections, agentConnectionsQueryKey, } from "./useAgentConnections.js";
10
+ export { useChannelSubscription, } from "./useChannelSubscription.js";
11
+ export type { ChannelSubscriptionHandlers } from "./useChannelSubscription.js";
12
+ export { useChannelAggregate, channelAggregateQueryKey, } from "./useChannelAggregate.js";
13
+ export type { UseChannelAggregateOptions, UseChannelAggregateResult, } from "./useChannelAggregate.js";
14
+ export { useAgentChannel } from "./useAgentChannel.js";
15
+ export { useSendMessage } from "./useSendMessage.js";
16
+ export type { UseSendMessageOptions } from "./useSendMessage.js";
17
+ export { useUpdateAggregate } from "./useUpdateAggregate.js";
18
+ export type { UseUpdateAggregateOptions } from "./useUpdateAggregate.js";
19
+ export { useUpdateMessage } from "./useUpdateMessage.js";
20
+ export type { UpdateMessageVariables, UseUpdateMessageOptions, } from "./useUpdateMessage.js";
21
+ export { useChannelMessages, channelMessagesQueryKey, } from "./useChannelMessages.js";
22
+ export type { UseChannelMessagesOptions, UseChannelMessagesResult, } from "./useChannelMessages.js";
23
+ export { useChannelMessage, channelMessageQueryKey, } from "./useChannelMessage.js";
24
+ export type { UseChannelMessageOptions, UseChannelMessageResult, } from "./useChannelMessage.js";
25
+ export { useInvocationLogs, invocationLogsQueryKey, } from "./useInvocationLogs.js";
26
+ export type { UseInvocationLogsOptions } from "./useInvocationLogs.js";
27
+ export { useSendRpc } from "./useSendRpc.js";
28
+ export type { RpcCommandId, RpcStatusEvent, SendRpcVariables, UseSendRpcOptions, UseSendRpcResult, } from "./useSendRpc.js";
29
+ export { useMultiAgentAggregates, multiAgentAggregatesQueryKey, } from "./useMultiAgentAggregates.js";
30
+ export type { UseMultiAgentAggregatesOptions, UseMultiAgentAggregatesResult, } from "./useMultiAgentAggregates.js";
31
+ export { useMultiAgentChannelMessages, multiAgentChannelMessagesQueryKey, } from "./useMultiAgentChannelMessages.js";
32
+ export type { UseMultiAgentChannelMessagesOptions, UseMultiAgentChannelMessagesResult, } from "./useMultiAgentChannelMessages.js";
33
+ export { useDeviceMap } from "./useDeviceMap.js";
34
+ export type { DeviceMapEntry, UseDeviceMapOptions, UseDeviceMapResult, } from "./useDeviceMap.js";
35
+ export { useTurnCredentials } from "./useTurnCredentials.js";
36
+ export { useAgentTokenState, useSetAgentTokenPolicy, useSetAgentAuthLock, useRevokeAgentTokens, useSetRevocationFloor, useCreateAdhocToken, useCreateDeviceToken, agentTokenStateQueryKey, } from "./useAgentTokenState.js";
37
+ export type { UseAgentTokenStateOptions } from "./useAgentTokenState.js";
38
+ export { getSharedQueryClient, resetSharedQueryClient, } from "./sharedQueryClient.js";
@@ -0,0 +1,21 @@
1
+ export { DooverProvider, useDooverClient } from "./context.js";
2
+ export { useClientStatus } from "./useClientStatus.js";
3
+ export { useOfflineStatus, hasOfflineStatus } from "./useOfflineStatus.js";
4
+ export { useConnectionState } from "./useConnectionState.js";
5
+ export { useAgentConnections, agentConnectionsQueryKey, } from "./useAgentConnections.js";
6
+ export { useChannelSubscription, } from "./useChannelSubscription.js";
7
+ export { useChannelAggregate, channelAggregateQueryKey, } from "./useChannelAggregate.js";
8
+ export { useAgentChannel } from "./useAgentChannel.js";
9
+ export { useSendMessage } from "./useSendMessage.js";
10
+ export { useUpdateAggregate } from "./useUpdateAggregate.js";
11
+ export { useUpdateMessage } from "./useUpdateMessage.js";
12
+ export { useChannelMessages, channelMessagesQueryKey, } from "./useChannelMessages.js";
13
+ export { useChannelMessage, channelMessageQueryKey, } from "./useChannelMessage.js";
14
+ export { useInvocationLogs, invocationLogsQueryKey, } from "./useInvocationLogs.js";
15
+ export { useSendRpc } from "./useSendRpc.js";
16
+ export { useMultiAgentAggregates, multiAgentAggregatesQueryKey, } from "./useMultiAgentAggregates.js";
17
+ export { useMultiAgentChannelMessages, multiAgentChannelMessagesQueryKey, } from "./useMultiAgentChannelMessages.js";
18
+ export { useDeviceMap } from "./useDeviceMap.js";
19
+ export { useTurnCredentials } from "./useTurnCredentials.js";
20
+ export { useAgentTokenState, useSetAgentTokenPolicy, useSetAgentAuthLock, useRevokeAgentTokens, useSetRevocationFloor, useCreateAdhocToken, useCreateDeviceToken, agentTokenStateQueryKey, } from "./useAgentTokenState.js";
21
+ export { getSharedQueryClient, resetSharedQueryClient, } from "./sharedQueryClient.js";
@@ -0,0 +1,93 @@
1
+ import type { MessageStructure } from "../types/common.js";
2
+ /**
3
+ * A per-channel cache of *proven-complete* id ranges.
4
+ *
5
+ * `useChannelMessages` models history as a chain of cursors: each page's oldest
6
+ * id is the next page's `before`. That chain is anchored at its first cursor, so
7
+ * two windows over the same channel are two unrelated chains — re-anchoring
8
+ * always refetches, even over data already held.
9
+ *
10
+ * This store keeps the fact the chain throws away. A response to
11
+ * `before=X, limit=N` is "the N newest messages strictly older than X", so a
12
+ * full page proves that *every* message in `[oldest.id, X)` is in hand. History
13
+ * is append-only, so that stays true forever. Overlapping windows then merge
14
+ * into one segment instead of duplicating, and revisiting a range costs nothing.
15
+ *
16
+ * The store sits under the query, not beside it: the chains stay as they are and
17
+ * remain the cache React Query sees, while this layer removes the network calls
18
+ * underneath them.
19
+ *
20
+ * Ids are decimal snowflakes of varying length, so every comparison goes through
21
+ * `BigInt` — string ordering would put "500" after "4000".
22
+ */
23
+ /** A contiguous range of history we can prove we hold in full. */
24
+ export interface RangeSegment {
25
+ /** Id of the oldest message held. Meaningless when `atStart` (coverage runs to -inf). */
26
+ lo: bigint;
27
+ /** Exclusive upper bound of proven coverage. */
28
+ hi: bigint;
29
+ /** No messages exist below `lo` — the channel (or its retention window) starts here. */
30
+ atStart: boolean;
31
+ /**
32
+ * `hi` tracks the live feed. Only true while a fetch has proven coverage up to
33
+ * roughly now AND the socket has not dropped since — see `sealTips`.
34
+ */
35
+ live: boolean;
36
+ /** Ascending by id. */
37
+ messages: MessageStructure[];
38
+ }
39
+ export declare class ChannelRangeStore {
40
+ /** Disjoint, ascending by `lo`. */
41
+ private segments;
42
+ /**
43
+ * Answer "the newest `limit` messages strictly older than `before`" from cache,
44
+ * or `undefined` when the range isn't proven and the caller must fetch.
45
+ *
46
+ * Returns ascending by id, matching `listMessages({ order: "asc" })`.
47
+ */
48
+ read(before: bigint, limit: number): MessageStructure[] | undefined;
49
+ /**
50
+ * Record a fetched page. `before` is the cursor actually sent and `limit` the
51
+ * one actually requested — a short page proves the range bottoms out, which is
52
+ * only sound because the server rejects an over-cap `limit` rather than
53
+ * silently clamping it.
54
+ */
55
+ record(params: {
56
+ before: bigint;
57
+ limit: number;
58
+ page: MessageStructure[];
59
+ /** Epoch ms the request was issued, for deciding whether this segment is live. */
60
+ at?: number;
61
+ }): void;
62
+ /**
63
+ * Extend the live segment with a pushed message. Ignored unless a segment is
64
+ * currently live: outside that, the message and the segment may have a gap
65
+ * between them, and claiming coverage across it would hide messages forever.
66
+ */
67
+ recordLive(message: MessageStructure): void;
68
+ /**
69
+ * Replace a message already held by one or more proven ranges. MessageUpdate
70
+ * carries the complete server representation, so both data and attachments
71
+ * supersede the cached create-time copy without changing range coverage.
72
+ */
73
+ recordUpdate(message: MessageStructure): void;
74
+ /**
75
+ * Stop trusting the live feed to extend coverage — call when the socket drops.
76
+ * Messages sent while disconnected would leave a hole, so segments go back to
77
+ * proving coverage by fetching.
78
+ */
79
+ sealTips(): void;
80
+ /** Test/debug view. */
81
+ snapshot(): RangeSegment[];
82
+ clear(): void;
83
+ /** Union `incoming` with every segment it overlaps or merely touches. */
84
+ private merge;
85
+ }
86
+ /**
87
+ * Stores are per *stream* — agent, channel, and any `fields` filter, which
88
+ * returns a different set of messages. Deliberately NOT per anchor: sharing
89
+ * across anchors is the entire point.
90
+ */
91
+ export declare function getChannelRangeStore(key: string): ChannelRangeStore;
92
+ /** Drop every store. Tests only — there is no eviction in normal operation. */
93
+ export declare function resetChannelRangeStores(): void;
@@ -0,0 +1,140 @@
1
+ /**
2
+ * How close to "now" a fetch's `before` must be for its segment to accept live
3
+ * pushes. Beyond this the feed and the segment may not be contiguous.
4
+ */
5
+ const LIVE_PROOF_TOLERANCE_MS = 60000;
6
+ const idOf = (message) => BigInt(message.id);
7
+ function sortById(messages) {
8
+ return [...messages].sort((a, b) => (idOf(a) < idOf(b) ? -1 : idOf(a) > idOf(b) ? 1 : 0));
9
+ }
10
+ function dedupeById(messages) {
11
+ const seen = new Map();
12
+ // Later wins: a live push or a refetch supersedes an older copy
13
+ for (const message of messages)
14
+ seen.set(message.id, message);
15
+ return sortById([...seen.values()]);
16
+ }
17
+ export class ChannelRangeStore {
18
+ constructor() {
19
+ /** Disjoint, ascending by `lo`. */
20
+ this.segments = [];
21
+ }
22
+ /**
23
+ * Answer "the newest `limit` messages strictly older than `before`" from cache,
24
+ * or `undefined` when the range isn't proven and the caller must fetch.
25
+ *
26
+ * Returns ascending by id, matching `listMessages({ order: "asc" })`.
27
+ */
28
+ read(before, limit) {
29
+ const segment = this.segments.find((s) => before <= s.hi && (s.atStart || before >= s.lo));
30
+ if (!segment)
31
+ return undefined;
32
+ const older = segment.messages.filter((m) => idOf(m) < before);
33
+ if (older.length >= limit)
34
+ return older.slice(older.length - limit);
35
+ // Short of `limit` only tells us the range is exhausted if nothing precedes it
36
+ return segment.atStart ? older : undefined;
37
+ }
38
+ /**
39
+ * Record a fetched page. `before` is the cursor actually sent and `limit` the
40
+ * one actually requested — a short page proves the range bottoms out, which is
41
+ * only sound because the server rejects an over-cap `limit` rather than
42
+ * silently clamping it.
43
+ */
44
+ record(params) {
45
+ const { before, limit, page } = params;
46
+ const at = params.at ?? Date.now();
47
+ const messages = sortById(page);
48
+ const atStart = messages.length < limit;
49
+ const lo = messages.length > 0 ? idOf(messages[0]) : before;
50
+ const live = timestampOf(before) >= at - LIVE_PROOF_TOLERANCE_MS;
51
+ this.merge({ lo, hi: before, atStart, live, messages });
52
+ }
53
+ /**
54
+ * Extend the live segment with a pushed message. Ignored unless a segment is
55
+ * currently live: outside that, the message and the segment may have a gap
56
+ * between them, and claiming coverage across it would hide messages forever.
57
+ */
58
+ recordLive(message) {
59
+ const id = idOf(message);
60
+ const tip = this.segments.find((s) => s.live);
61
+ if (!tip || id < tip.lo)
62
+ return;
63
+ tip.messages = dedupeById([...tip.messages, message]);
64
+ if (id >= tip.hi)
65
+ tip.hi = id + 1n;
66
+ }
67
+ /**
68
+ * Replace a message already held by one or more proven ranges. MessageUpdate
69
+ * carries the complete server representation, so both data and attachments
70
+ * supersede the cached create-time copy without changing range coverage.
71
+ */
72
+ recordUpdate(message) {
73
+ for (const segment of this.segments) {
74
+ const index = segment.messages.findIndex((item) => item.id === message.id);
75
+ if (index >= 0)
76
+ segment.messages[index] = message;
77
+ }
78
+ }
79
+ /**
80
+ * Stop trusting the live feed to extend coverage — call when the socket drops.
81
+ * Messages sent while disconnected would leave a hole, so segments go back to
82
+ * proving coverage by fetching.
83
+ */
84
+ sealTips() {
85
+ for (const segment of this.segments)
86
+ segment.live = false;
87
+ }
88
+ /** Test/debug view. */
89
+ snapshot() {
90
+ return this.segments.map((s) => ({ ...s, messages: [...s.messages] }));
91
+ }
92
+ clear() {
93
+ this.segments = [];
94
+ }
95
+ /** Union `incoming` with every segment it overlaps or merely touches. */
96
+ merge(incoming) {
97
+ const overlapping = [];
98
+ const rest = [];
99
+ for (const segment of this.segments) {
100
+ // Touching counts: [a,b) and [b,c) are both proven, so [a,c) is too
101
+ const disjoint = segment.hi < incoming.lo || segment.lo > incoming.hi;
102
+ (disjoint ? rest : overlapping).push(segment);
103
+ }
104
+ const merged = overlapping.reduce((acc, s) => ({
105
+ lo: s.lo < acc.lo ? s.lo : acc.lo,
106
+ hi: s.hi > acc.hi ? s.hi : acc.hi,
107
+ atStart: acc.atStart || s.atStart,
108
+ live: acc.live || s.live,
109
+ messages: [...acc.messages, ...s.messages],
110
+ }), incoming);
111
+ merged.messages = dedupeById(merged.messages);
112
+ if (merged.atStart && merged.messages.length > 0) {
113
+ merged.lo = idOf(merged.messages[0]);
114
+ }
115
+ this.segments = [...rest, merged].sort((a, b) => (a.lo < b.lo ? -1 : a.lo > b.lo ? 1 : 0));
116
+ }
117
+ }
118
+ const SNOWFLAKE_EPOCH_MS = 1735689600000n;
119
+ /** Epoch ms encoded in a snowflake, without going through the string round-trip. */
120
+ function timestampOf(id) {
121
+ return Number((id >> 22n) + SNOWFLAKE_EPOCH_MS);
122
+ }
123
+ const stores = new Map();
124
+ /**
125
+ * Stores are per *stream* — agent, channel, and any `fields` filter, which
126
+ * returns a different set of messages. Deliberately NOT per anchor: sharing
127
+ * across anchors is the entire point.
128
+ */
129
+ export function getChannelRangeStore(key) {
130
+ let store = stores.get(key);
131
+ if (!store) {
132
+ store = new ChannelRangeStore();
133
+ stores.set(key, store);
134
+ }
135
+ return store;
136
+ }
137
+ /** Drop every store. Tests only — there is no eviction in normal operation. */
138
+ export function resetChannelRangeStores() {
139
+ stores.clear();
140
+ }
@@ -0,0 +1,21 @@
1
+ import { QueryClient, type QueryClientConfig } from "@tanstack/react-query";
2
+ /**
3
+ * Get a process-wide `QueryClient` instance, creating it on first call.
4
+ *
5
+ * Uses `globalThis.__doover_js_query_client__` so that every app + remote
6
+ * in a module-federation setup ends up with the same `QueryClient` — and
7
+ * therefore the same cache — even if they each load their own copy of the
8
+ * react-query library. The first caller's `config` wins.
9
+ *
10
+ * Wrap your tree once at the app root:
11
+ *
12
+ * ```tsx
13
+ * import { QueryClientProvider } from "@tanstack/react-query";
14
+ * import { getSharedQueryClient } from "doover-js/react";
15
+ *
16
+ * <QueryClientProvider client={getSharedQueryClient()}>…</QueryClientProvider>
17
+ * ```
18
+ */
19
+ export declare function getSharedQueryClient(config?: QueryClientConfig): QueryClient;
20
+ /** Test-only: clear the shared `QueryClient`. */
21
+ export declare function resetSharedQueryClient(): void;
@@ -0,0 +1,35 @@
1
+ import { QueryClient, } from "@tanstack/react-query";
2
+ const GLOBAL_KEY = "__doover_js_query_client__";
3
+ function globalBag() {
4
+ return globalThis;
5
+ }
6
+ /**
7
+ * Get a process-wide `QueryClient` instance, creating it on first call.
8
+ *
9
+ * Uses `globalThis.__doover_js_query_client__` so that every app + remote
10
+ * in a module-federation setup ends up with the same `QueryClient` — and
11
+ * therefore the same cache — even if they each load their own copy of the
12
+ * react-query library. The first caller's `config` wins.
13
+ *
14
+ * Wrap your tree once at the app root:
15
+ *
16
+ * ```tsx
17
+ * import { QueryClientProvider } from "@tanstack/react-query";
18
+ * import { getSharedQueryClient } from "doover-js/react";
19
+ *
20
+ * <QueryClientProvider client={getSharedQueryClient()}>…</QueryClientProvider>
21
+ * ```
22
+ */
23
+ export function getSharedQueryClient(config) {
24
+ const bag = globalBag();
25
+ const existing = bag[GLOBAL_KEY];
26
+ if (existing)
27
+ return existing;
28
+ const client = new QueryClient(config);
29
+ bag[GLOBAL_KEY] = client;
30
+ return client;
31
+ }
32
+ /** Test-only: clear the shared `QueryClient`. */
33
+ export function resetSharedQueryClient() {
34
+ delete globalBag()[GLOBAL_KEY];
35
+ }
@@ -0,0 +1,8 @@
1
+ import type { Aggregate } from "../types/common.js";
2
+ import { type UseChannelAggregateOptions } from "./useChannelAggregate.js";
3
+ /**
4
+ * Convenience wrapper around `useChannelAggregate` that accepts an agent id
5
+ * and channel name as separate arguments — the most common shape at call
6
+ * sites where the identifier isn't already a `ChannelIdentifier`.
7
+ */
8
+ export declare function useAgentChannel<TData = Aggregate["data"]>(agentId: string | undefined, channelName: string, options?: UseChannelAggregateOptions): import("./useChannelAggregate.js").UseChannelAggregateResult<TData>;
@@ -0,0 +1,9 @@
1
+ import { useChannelAggregate, } from "./useChannelAggregate.js";
2
+ /**
3
+ * Convenience wrapper around `useChannelAggregate` that accepts an agent id
4
+ * and channel name as separate arguments — the most common shape at call
5
+ * sites where the identifier isn't already a `ChannelIdentifier`.
6
+ */
7
+ export function useAgentChannel(agentId, channelName, options) {
8
+ return useChannelAggregate({ agentId, channelName }, options);
9
+ }
@@ -0,0 +1,8 @@
1
+ import { type UseQueryResult } from "@tanstack/react-query";
2
+ import type { ConnectionDetails } from "../types/common.js";
3
+ export declare function agentConnectionsQueryKey(agentId: string | undefined): readonly ["doover", "agent", string | undefined, "connections"];
4
+ /**
5
+ * Fetch the list of active WSS connections for an agent. Query key:
6
+ * `["doover", "agent", agentId, "connections"]`.
7
+ */
8
+ export declare function useAgentConnections(agentId: string | undefined): UseQueryResult<ConnectionDetails[]>;
@@ -0,0 +1,20 @@
1
+ import { useQuery } from "@tanstack/react-query";
2
+ import { useDooverClient } from "./context.js";
3
+ export function agentConnectionsQueryKey(agentId) {
4
+ return ["doover", "agent", agentId, "connections"];
5
+ }
6
+ /**
7
+ * Fetch the list of active WSS connections for an agent. Query key:
8
+ * `["doover", "agent", agentId, "connections"]`.
9
+ */
10
+ export function useAgentConnections(agentId) {
11
+ const client = useDooverClient();
12
+ return useQuery({
13
+ queryKey: agentConnectionsQueryKey(agentId),
14
+ enabled: !!agentId,
15
+ staleTime: 30000,
16
+ queryFn: () => agentId
17
+ ? client.connections.getAgentConnections(agentId)
18
+ : Promise.resolve([]),
19
+ });
20
+ }
@@ -0,0 +1,70 @@
1
+ import { type UseQueryResult } from "@tanstack/react-query";
2
+ import type { AgentTokenPolicy, AgentTokenState, ResourcePermission } from "../apis/agents-api.js";
3
+ export declare function agentTokenStateQueryKey(agentId: string | undefined): readonly ["doover", "agent", string | null, "tokenState"];
4
+ export interface UseAgentTokenStateOptions {
5
+ enabled?: boolean;
6
+ staleTime?: number;
7
+ }
8
+ /**
9
+ * Read an agent's credential state — revocation floor, auth kill-switch, and the
10
+ * token posture resolved across the per-agent override and organisation default.
11
+ *
12
+ * Deliberately short `staleTime`: `auth_locked` can be flipped by doover-data
13
+ * itself (automatic lockout on suspected token reuse), so this value changes
14
+ * without any action from this client. Showing a stale "not locked" on the one
15
+ * screen someone opens *because* their device went offline would be worse than
16
+ * an extra fetch.
17
+ */
18
+ export declare function useAgentTokenState(agentId: string | undefined, options?: UseAgentTokenStateOptions): UseQueryResult<AgentTokenState>;
19
+ /**
20
+ * Write an agent's token-posture override. Full replacement — a null field means
21
+ * "inherit the organisation default".
22
+ *
23
+ * Invalidates the token-state query on success so the inherited-vs-overridden
24
+ * display reflects the write without the caller wiring that up.
25
+ */
26
+ export declare function useSetAgentTokenPolicy(agentId: string | undefined): import("@tanstack/react-query").UseMutationResult<{
27
+ effective: AgentTokenPolicy;
28
+ }, Error, AgentTokenPolicy, unknown>;
29
+ /** Set or clear the auth kill-switch. */
30
+ export declare function useSetAgentAuthLock(agentId: string | undefined): import("@tanstack/react-query").UseMutationResult<void, Error, boolean, unknown>;
31
+ /**
32
+ * Mint a short-lived scoped token for ad-hoc access to an agent.
33
+ *
34
+ * Does not invalidate the token-state query: an ad-hoc token is a JWT with its
35
+ * own expiry and doesn't touch the revocation floor or the agent's posture, so
36
+ * there is nothing in that query for it to change.
37
+ *
38
+ * The resulting token is returned once and is not retrievable afterwards — hand
39
+ * it straight to the user and don't cache it.
40
+ */
41
+ export declare function useCreateAdhocToken(agentId: string | undefined): import("@tanstack/react-query").UseMutationResult<import("../apis/agents-api.js").AdhocTokenResponse, Error, {
42
+ permissions?: ResourcePermission[];
43
+ timeout?: number;
44
+ }, unknown>;
45
+ /**
46
+ * Set the revocation floor to an explicit point; pass `0` or `null` to clear it.
47
+ *
48
+ * Lowering it reverses a revocation, so this is for undoing one made by mistake
49
+ * rather than for recovering a device whose credentials leaked.
50
+ */
51
+ export declare function useSetRevocationFloor(agentId: string | undefined): import("@tanstack/react-query").UseMutationResult<{
52
+ tokens_valid_from: number | null;
53
+ }, Error, number | null, unknown>;
54
+ /**
55
+ * Mint the device's long-lived credential for manual provisioning, returned once.
56
+ *
57
+ * Invalidates the token-state query so the revocation floor display stays honest
58
+ * — the mint itself is additive and doesn't move the floor, but refetching keeps
59
+ * this in step with anything else that has changed since the panel loaded.
60
+ */
61
+ export declare function useCreateDeviceToken(agentId: string | undefined): import("@tanstack/react-query").UseMutationResult<import("../apis/agents-api.js").DeviceTokenResponse, Error, void, unknown>;
62
+ /**
63
+ * Revoke every outstanding long-lived credential for an agent.
64
+ *
65
+ * Break-glass: the device stays offline until it is re-provisioned. Confirm with
66
+ * the user before calling.
67
+ */
68
+ export declare function useRevokeAgentTokens(agentId: string | undefined): import("@tanstack/react-query").UseMutationResult<{
69
+ tokens_valid_from: number;
70
+ }, Error, void, unknown>;
@@ -0,0 +1,127 @@
1
+ import { useMutation, useQuery, useQueryClient, } from "@tanstack/react-query";
2
+ import { useDooverClient } from "./context.js";
3
+ export function agentTokenStateQueryKey(agentId) {
4
+ return ["doover", "agent", agentId ?? null, "tokenState"];
5
+ }
6
+ /**
7
+ * Read an agent's credential state — revocation floor, auth kill-switch, and the
8
+ * token posture resolved across the per-agent override and organisation default.
9
+ *
10
+ * Deliberately short `staleTime`: `auth_locked` can be flipped by doover-data
11
+ * itself (automatic lockout on suspected token reuse), so this value changes
12
+ * without any action from this client. Showing a stale "not locked" on the one
13
+ * screen someone opens *because* their device went offline would be worse than
14
+ * an extra fetch.
15
+ */
16
+ export function useAgentTokenState(agentId, options) {
17
+ const client = useDooverClient();
18
+ return useQuery({
19
+ queryKey: agentTokenStateQueryKey(agentId),
20
+ enabled: (options?.enabled ?? true) && Boolean(agentId),
21
+ staleTime: options?.staleTime ?? 15 * 1000,
22
+ queryFn: () => client.agents.getTokenState(agentId),
23
+ });
24
+ }
25
+ /**
26
+ * Write an agent's token-posture override. Full replacement — a null field means
27
+ * "inherit the organisation default".
28
+ *
29
+ * Invalidates the token-state query on success so the inherited-vs-overridden
30
+ * display reflects the write without the caller wiring that up.
31
+ */
32
+ export function useSetAgentTokenPolicy(agentId) {
33
+ const client = useDooverClient();
34
+ const queryClient = useQueryClient();
35
+ return useMutation({
36
+ mutationFn: (policy) => client.agents.setTokenPolicy(agentId, policy),
37
+ onSuccess: () => {
38
+ void queryClient.invalidateQueries({
39
+ queryKey: agentTokenStateQueryKey(agentId),
40
+ });
41
+ },
42
+ });
43
+ }
44
+ /** Set or clear the auth kill-switch. */
45
+ export function useSetAgentAuthLock(agentId) {
46
+ const client = useDooverClient();
47
+ const queryClient = useQueryClient();
48
+ return useMutation({
49
+ mutationFn: (locked) => client.agents.setAuthLock(agentId, locked),
50
+ onSuccess: () => {
51
+ void queryClient.invalidateQueries({
52
+ queryKey: agentTokenStateQueryKey(agentId),
53
+ });
54
+ },
55
+ });
56
+ }
57
+ /**
58
+ * Mint a short-lived scoped token for ad-hoc access to an agent.
59
+ *
60
+ * Does not invalidate the token-state query: an ad-hoc token is a JWT with its
61
+ * own expiry and doesn't touch the revocation floor or the agent's posture, so
62
+ * there is nothing in that query for it to change.
63
+ *
64
+ * The resulting token is returned once and is not retrievable afterwards — hand
65
+ * it straight to the user and don't cache it.
66
+ */
67
+ export function useCreateAdhocToken(agentId) {
68
+ const client = useDooverClient();
69
+ return useMutation({
70
+ mutationFn: (options) => client.agents.createAdhocToken(agentId, options),
71
+ });
72
+ }
73
+ /**
74
+ * Set the revocation floor to an explicit point; pass `0` or `null` to clear it.
75
+ *
76
+ * Lowering it reverses a revocation, so this is for undoing one made by mistake
77
+ * rather than for recovering a device whose credentials leaked.
78
+ */
79
+ export function useSetRevocationFloor(agentId) {
80
+ const client = useDooverClient();
81
+ const queryClient = useQueryClient();
82
+ return useMutation({
83
+ mutationFn: (tokensValidFrom) => client.agents.setRevocationFloor(agentId, tokensValidFrom),
84
+ onSuccess: () => {
85
+ void queryClient.invalidateQueries({
86
+ queryKey: agentTokenStateQueryKey(agentId),
87
+ });
88
+ },
89
+ });
90
+ }
91
+ /**
92
+ * Mint the device's long-lived credential for manual provisioning, returned once.
93
+ *
94
+ * Invalidates the token-state query so the revocation floor display stays honest
95
+ * — the mint itself is additive and doesn't move the floor, but refetching keeps
96
+ * this in step with anything else that has changed since the panel loaded.
97
+ */
98
+ export function useCreateDeviceToken(agentId) {
99
+ const client = useDooverClient();
100
+ const queryClient = useQueryClient();
101
+ return useMutation({
102
+ mutationFn: () => client.agents.createDeviceToken(agentId),
103
+ onSuccess: () => {
104
+ void queryClient.invalidateQueries({
105
+ queryKey: agentTokenStateQueryKey(agentId),
106
+ });
107
+ },
108
+ });
109
+ }
110
+ /**
111
+ * Revoke every outstanding long-lived credential for an agent.
112
+ *
113
+ * Break-glass: the device stays offline until it is re-provisioned. Confirm with
114
+ * the user before calling.
115
+ */
116
+ export function useRevokeAgentTokens(agentId) {
117
+ const client = useDooverClient();
118
+ const queryClient = useQueryClient();
119
+ return useMutation({
120
+ mutationFn: () => client.agents.revokeAllTokens(agentId),
121
+ onSuccess: () => {
122
+ void queryClient.invalidateQueries({
123
+ queryKey: agentTokenStateQueryKey(agentId),
124
+ });
125
+ },
126
+ });
127
+ }