Skip to content

Commit 029577f

Browse files
committed
chore: moved rpc handler from agent rpc to client rpc
1 parent 452ce01 commit 029577f

File tree

6 files changed

+35
-21
lines changed

6 files changed

+35
-21
lines changed

src/client/callers/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import nodesFind from './nodesFind.js';
4646
import nodesGetAll from './nodesGetAll.js';
4747
import nodesListConnections from './nodesListConnections.js';
4848
import nodesPing from './nodesPing.js';
49+
import nodesSyncGraph from './nodesSyncGraph.js';
4950
import notificationsInboxClear from './notificationsInboxClear.js';
5051
import notificationsInboxRead from './notificationsInboxRead.js';
5152
import notificationsInboxRemove from './notificationsInboxRemove.js';
@@ -128,6 +129,7 @@ const clientManifest = {
128129
nodesGetAll,
129130
nodesListConnections,
130131
nodesPing,
132+
nodesSyncGraph,
131133
notificationsInboxClear,
132134
notificationsInboxRead,
133135
notificationsInboxRemove,
@@ -209,6 +211,7 @@ export {
209211
nodesGetAll,
210212
nodesListConnections,
211213
nodesPing,
214+
nodesSyncGraph,
212215
notificationsInboxClear,
213216
notificationsInboxRead,
214217
notificationsInboxRemove,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type { HandlerTypes } from '@matrixai/rpc';
2+
import type NodesSyncGraph from '../handlers/NodesSyncGraph.js';
3+
import { UnaryCaller } from '@matrixai/rpc';
4+
5+
type CallerTypes = HandlerTypes<NodesSyncGraph>;
6+
7+
const nodesSyncGraph = new UnaryCaller<
8+
CallerTypes['input'],
9+
CallerTypes['output']
10+
>();
11+
12+
export default nodesSyncGraph;

src/nodes/agent/handlers/NodesSyncGraph.ts renamed to src/client/handlers/NodesSyncGraph.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
import type { ContextTimed } from '@matrixai/contexts';
22
import type { JSONValue } from '@matrixai/rpc';
3-
import type NodeManager from '../../NodeManager.js';
3+
import type NodeManager from '../../nodes/NodeManager.js';
44
import type {
5-
AgentRPCRequestParams,
6-
AgentRPCResponseResult,
5+
ClientRPCRequestParams,
6+
ClientRPCResponseResult,
77
NodesSyncGraphMessage,
88
} from '../types.js';
9-
import type { AgentClientManifest } from '../callers/index.js';
9+
import type { AgentClientManifest } from '../../nodes/agent/callers/index.js';
1010
import { UnaryHandler } from '@matrixai/rpc';
1111

1212
class NodesSyncGraph extends UnaryHandler<
1313
{
1414
nodeManager: NodeManager<AgentClientManifest>;
1515
},
16-
AgentRPCRequestParams<NodesSyncGraphMessage>,
17-
AgentRPCResponseResult
16+
ClientRPCRequestParams<NodesSyncGraphMessage>,
17+
ClientRPCResponseResult
1818
> {
1919
public handle = async (
20-
input: AgentRPCRequestParams<NodesSyncGraphMessage>,
20+
input: ClientRPCRequestParams<NodesSyncGraphMessage>,
2121
_cancel: (reason?: any) => void,
2222
_meta: Record<string, JSONValue> | undefined,
2323
ctx: ContextTimed,
24-
): Promise<AgentRPCResponseResult> => {
24+
): Promise<ClientRPCResponseResult> => {
2525
const {
2626
nodeManager,
2727
}: {

src/client/handlers/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import NodesFind from './NodesFind.js';
6464
import NodesGetAll from './NodesGetAll.js';
6565
import NodesListConnections from './NodesListConnections.js';
6666
import NodesPing from './NodesPing.js';
67+
import NodesSyncGraph from './NodesSyncGraph.js';
6768
import NotificationsInboxClear from './NotificationsInboxClear.js';
6869
import NotificationsInboxRead from './NotificationsInboxRead.js';
6970
import NotificationsInboxRemove from './NotificationsInboxRemove.js';
@@ -169,6 +170,7 @@ const serverManifest = (container: {
169170
nodesGetAll: new NodesGetAll(container),
170171
nodesListConnections: new NodesListConnections(container),
171172
nodesPing: new NodesPing(container),
173+
nodesSyncGraph: new NodesSyncGraph(container),
172174
notificationsInboxClear: new NotificationsInboxClear(container),
173175
notificationsInboxRead: new NotificationsInboxRead(container),
174176
notificationsInboxRemove: new NotificationsInboxRemove(container),
@@ -252,6 +254,7 @@ export {
252254
NodesGetAll,
253255
NodesListConnections,
254256
NodesPing,
257+
NodesSyncGraph,
255258
NotificationsInboxClear,
256259
NotificationsInboxRead,
257260
NotificationsInboxRemove,

src/client/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import type {
2727
NodeContact,
2828
NodeAddress,
2929
NodeContactAddressData,
30+
NodeId,
3031
} from '../nodes/types.js';
3132
import type { AuditEventsGetTypeOverride } from './callers/auditEventsGet.js';
3233

@@ -151,6 +152,12 @@ type NodeConnectionMessage = NodeAddressMessage & {
151152
authenticated: boolean;
152153
};
153154

155+
type NodesSyncGraphMessage = {
156+
network: string;
157+
initialNodes: Array<[NodeId, NodeAddress]>;
158+
connectionTimeout?: number;
159+
};
160+
154161
// Gestalts messages
155162

156163
type ActionsListMessage = {
@@ -428,6 +435,7 @@ export type {
428435
NodeAddressMessage,
429436
NodesFindMessage,
430437
NodeConnectionMessage,
438+
NodesSyncGraphMessage,
431439
ActionsListMessage,
432440
SetIdentityActionMessage,
433441
SetNodeActionMessage,

src/nodes/agent/types.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@ import type {
1313
import type { VaultAction, VaultName } from '../../vaults/types.js';
1414
import type { SignedNotification } from '../../notifications/types.js';
1515
import type { Host, Hostname, Port } from '../../network/types.js';
16-
import type {
17-
NetworkId,
18-
NodeContact,
19-
NodeId,
20-
NodeAddress,
21-
} from '../../nodes/types.js';
16+
import type { NetworkId, NodeContact } from '../../nodes/types.js';
2217
import type { AuditEvent } from '../../audit/types.js';
2318
import type { SignedClaimEncoded } from '../../claims/types.js';
2419

@@ -130,12 +125,6 @@ type NodesAuthenticateConnectionMessageNone = {
130125
type: 'NodesAuthenticateConnectionMessageNone';
131126
};
132127

133-
type NodesSyncGraphMessage = {
134-
network: string;
135-
initialNodes: Array<[NodeId, NodeAddress]>;
136-
connectionTimeout: number;
137-
};
138-
139128
export type {
140129
AgentRPCRequestParams,
141130
AgentRPCResponseResult,
@@ -158,5 +147,4 @@ export type {
158147
NodesAuthenticateConnectionMessagePrivate,
159148
NodesAuthenticateConnectionMessageBasicPublic,
160149
NodesAuthenticateConnectionMessageNone,
161-
NodesSyncGraphMessage,
162150
};

0 commit comments

Comments
 (0)