doover-js 0.4.3 → 0.4.4
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.
- package/dist/react/useMultiAgentAggregates.d.ts +5 -6
- package/dist/react/useMultiAgentChannelMessages.d.ts +6 -6
- package/dist/react/useMultiAgentChannelMessages.js +2 -1
- package/dist/react/useSendMessage.d.ts +1 -1
- package/dist/react/useUpdateAggregate.d.ts +1 -1
- package/dist/react/useUpdateAggregate.js +2 -2
- package/dist/react/useUpdateMessage.d.ts +3 -3
- package/dist/react/useUpdateMessage.js +1 -1
- package/package.json +1 -1
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { type UseQueryResult } from "@tanstack/react-query";
|
|
2
|
-
import type { Aggregate } from "../types/common";
|
|
3
|
-
import type { AgentAggregate } from "../types/openapi";
|
|
2
|
+
import type { Aggregate, JSONValue, AgentAggregate } from "../types/common";
|
|
4
3
|
export declare function multiAgentAggregatesQueryKey(channelName: string, agentIds: string[]): readonly ["doover", "channel", string, "aggregates", string];
|
|
5
4
|
export interface UseMultiAgentAggregatesOptions {
|
|
6
5
|
/** If false, skip per-agent live subscriptions. Defaults true. */
|
|
7
6
|
liveUpdates?: boolean;
|
|
8
7
|
}
|
|
9
|
-
export interface UseMultiAgentAggregatesResult {
|
|
8
|
+
export interface UseMultiAgentAggregatesResult<TData> {
|
|
10
9
|
/** Keyed by `agent_id` for O(1) lookup. */
|
|
11
|
-
aggregatesByAgent: Record<string, Aggregate
|
|
10
|
+
aggregatesByAgent: Record<string, Aggregate<TData>>;
|
|
12
11
|
query: UseQueryResult<{
|
|
13
|
-
results: AgentAggregate[];
|
|
12
|
+
results: AgentAggregate<TData>[];
|
|
14
13
|
count: number;
|
|
15
14
|
}>;
|
|
16
15
|
}
|
|
@@ -19,4 +18,4 @@ export interface UseMultiAgentAggregatesResult {
|
|
|
19
18
|
* agent's slot live via its own gateway subscription. Reconciles per-agent
|
|
20
19
|
* `channelSync`/`aggregateUpdate` events into the batched query cache.
|
|
21
20
|
*/
|
|
22
|
-
export declare function useMultiAgentAggregates(channelName: string, agentIds: string[], options?: UseMultiAgentAggregatesOptions): UseMultiAgentAggregatesResult
|
|
21
|
+
export declare function useMultiAgentAggregates<TData = Record<string, JSONValue>>(channelName: string, agentIds: string[], options?: UseMultiAgentAggregatesOptions): UseMultiAgentAggregatesResult<TData>;
|
|
@@ -13,13 +13,13 @@ export interface UseMultiAgentChannelMessagesOptions {
|
|
|
13
13
|
/** Optional first-page `before` cursor (snowflake id). */
|
|
14
14
|
initialBefore?: string;
|
|
15
15
|
}
|
|
16
|
-
interface Page {
|
|
17
|
-
results: MessageStructure[];
|
|
16
|
+
interface Page<TData> {
|
|
17
|
+
results: MessageStructure<TData>[];
|
|
18
18
|
next?: string;
|
|
19
19
|
}
|
|
20
|
-
export interface UseMultiAgentChannelMessagesResult extends Omit<UseInfiniteQueryResult<InfiniteData<Page
|
|
21
|
-
messages: MessageStructure[];
|
|
22
|
-
data: InfiniteData<Page
|
|
20
|
+
export interface UseMultiAgentChannelMessagesResult<TData> extends Omit<UseInfiniteQueryResult<InfiniteData<Page<TData>>>, "data"> {
|
|
21
|
+
messages: MessageStructure<TData>[];
|
|
22
|
+
data: InfiniteData<Page<TData>> | undefined;
|
|
23
23
|
}
|
|
24
|
-
export declare function useMultiAgentChannelMessages(channelName: string, agentIds: string[], options?: UseMultiAgentChannelMessagesOptions): UseMultiAgentChannelMessagesResult
|
|
24
|
+
export declare function useMultiAgentChannelMessages<TData = unknown>(channelName: string, agentIds: string[], options?: UseMultiAgentChannelMessagesOptions): UseMultiAgentChannelMessagesResult<TData>;
|
|
25
25
|
export {};
|
|
@@ -26,12 +26,13 @@ function useMultiAgentChannelMessages(channelName, agentIds, options) {
|
|
|
26
26
|
queryClient.setQueryData(key, (current) => {
|
|
27
27
|
if (!current)
|
|
28
28
|
return current;
|
|
29
|
+
const typed = message;
|
|
29
30
|
const [firstPage, ...rest] = current.pages;
|
|
30
31
|
const firstResults = firstPage?.results ?? [];
|
|
31
32
|
return {
|
|
32
33
|
...current,
|
|
33
34
|
pages: [
|
|
34
|
-
{ ...firstPage, results: [
|
|
35
|
+
{ ...firstPage, results: [typed, ...firstResults] },
|
|
35
36
|
...rest,
|
|
36
37
|
],
|
|
37
38
|
};
|
|
@@ -6,4 +6,4 @@ import type { ChannelIdentifier } from "../types/viewer";
|
|
|
6
6
|
* to the channel and resolves with the created `MessageStructure` (including
|
|
7
7
|
* its server-assigned `id` and `timestamp`).
|
|
8
8
|
*/
|
|
9
|
-
export declare function useSendMessage(identifier: ChannelIdentifier): UseMutationResult<MessageStructure
|
|
9
|
+
export declare function useSendMessage<TData extends object = object>(identifier: ChannelIdentifier): UseMutationResult<MessageStructure<TData>, Error, TData>;
|
|
@@ -18,4 +18,4 @@ export interface UseUpdateAggregateOptions {
|
|
|
18
18
|
* aggregate into the react-query cache for its channel so consumers of
|
|
19
19
|
* `useChannelAggregate` see the change immediately.
|
|
20
20
|
*/
|
|
21
|
-
export declare function useUpdateAggregate(identifier: ChannelIdentifier, options?: UseUpdateAggregateOptions): UseMutationResult<Aggregate
|
|
21
|
+
export declare function useUpdateAggregate<TData extends object = object>(identifier: ChannelIdentifier, options?: UseUpdateAggregateOptions): UseMutationResult<Aggregate<TData>, Error, TData>;
|
|
@@ -16,9 +16,9 @@ function useUpdateAggregate(identifier, options) {
|
|
|
16
16
|
const replace = options?.replace ?? false;
|
|
17
17
|
const params = options?.params;
|
|
18
18
|
return (0, react_query_1.useMutation)({
|
|
19
|
-
mutationFn: (data) => replace
|
|
19
|
+
mutationFn: (data) => (replace
|
|
20
20
|
? client.viewer.putAggregate(identifier, data, params)
|
|
21
|
-
: client.viewer.updateAggregate(identifier, data, params),
|
|
21
|
+
: client.viewer.updateAggregate(identifier, data, params)),
|
|
22
22
|
onSuccess: (aggregate) => {
|
|
23
23
|
queryClient.setQueryData((0, useChannelAggregate_1.channelAggregateQueryKey)(identifier.agentId, identifier.channelName), aggregate);
|
|
24
24
|
},
|
|
@@ -15,9 +15,9 @@ export interface UpdateMessageCallOptions {
|
|
|
15
15
|
}
|
|
16
16
|
export interface UseUpdateMessageOptions extends UpdateMessageCallOptions {
|
|
17
17
|
}
|
|
18
|
-
export interface UpdateMessageVariables {
|
|
18
|
+
export interface UpdateMessageVariables<TBody extends MessageBody = MessageBody> {
|
|
19
19
|
messageId: string;
|
|
20
|
-
body:
|
|
20
|
+
body: TBody;
|
|
21
21
|
/**
|
|
22
22
|
* Per-call overrides. Extensible — add new knobs here without breaking
|
|
23
23
|
* the variables shape.
|
|
@@ -30,4 +30,4 @@ export interface UpdateMessageVariables {
|
|
|
30
30
|
* invocation can override `replace` / `params` via `variables.options` for
|
|
31
31
|
* mutation sites that sometimes PUT and sometimes PATCH the same channel.
|
|
32
32
|
*/
|
|
33
|
-
export declare function useUpdateMessage(identifier: ChannelIdentifier, options?: UseUpdateMessageOptions): UseMutationResult<unknown, Error, UpdateMessageVariables
|
|
33
|
+
export declare function useUpdateMessage<TBody extends MessageBody = MessageBody>(identifier: ChannelIdentifier, options?: UseUpdateMessageOptions): UseMutationResult<unknown, Error, UpdateMessageVariables<TBody>>;
|
|
@@ -14,7 +14,7 @@ function useUpdateMessage(identifier, options) {
|
|
|
14
14
|
const defaultReplace = options?.replace ?? false;
|
|
15
15
|
const defaultParams = options?.params;
|
|
16
16
|
return (0, react_query_1.useMutation)({
|
|
17
|
-
mutationFn: ({ messageId, body, options: call }) => {
|
|
17
|
+
mutationFn: ({ messageId, body, options: call, }) => {
|
|
18
18
|
if (!identifier.agentId || !identifier.channelName) {
|
|
19
19
|
throw new Error("useUpdateMessage requires both agentId and channelName on the identifier.");
|
|
20
20
|
}
|