@forwardimpact/librpc 0.1.105 → 0.1.107
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/bin/fit-unary.js +5 -15
- package/package.json +3 -1
- package/src/base.js +20 -10
- package/src/client.js +4 -2
- package/src/generated/definitions/bridge.js +260 -0
- package/src/generated/definitions/embedding.js +29 -0
- package/src/generated/definitions/exports.js +43 -0
- package/src/generated/definitions/ghserver.js +29 -0
- package/src/generated/definitions/ghuser.js +113 -0
- package/src/generated/definitions/graph.js +71 -0
- package/src/generated/definitions/map.js +92 -0
- package/src/generated/definitions/pathway.js +155 -0
- package/src/generated/definitions/tenancy.js +155 -0
- package/src/generated/definitions/trace.js +50 -0
- package/src/generated/definitions/vector.js +29 -0
- package/src/generated/services/bridge/client.js +264 -0
- package/src/generated/services/bridge/service.js +244 -0
- package/src/generated/services/embedding/client.js +44 -0
- package/src/generated/services/embedding/service.js +46 -0
- package/src/generated/services/exports.js +103 -0
- package/src/generated/services/ghserver/client.js +44 -0
- package/src/generated/services/ghserver/service.js +46 -0
- package/src/generated/services/ghuser/client.js +124 -0
- package/src/generated/services/ghuser/service.js +118 -0
- package/src/generated/services/graph/client.js +84 -0
- package/src/generated/services/graph/service.js +82 -0
- package/src/generated/services/map/client.js +104 -0
- package/src/generated/services/map/service.js +100 -0
- package/src/generated/services/pathway/client.js +164 -0
- package/src/generated/services/pathway/service.js +154 -0
- package/src/generated/services/tenancy/client.js +164 -0
- package/src/generated/services/tenancy/service.js +154 -0
- package/src/generated/services/trace/client.js +64 -0
- package/src/generated/services/trace/service.js +64 -0
- package/src/generated/services/vector/client.js +44 -0
- package/src/generated/services/vector/service.js +46 -0
- package/src/generated/types/metadata.js +994 -0
- package/src/generated/types/types.js +20852 -0
- package/src/index.js +14 -3
- package/src/server.js +20 -21
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/* eslint no-unused-vars: "off" */
|
|
2
|
+
|
|
3
|
+
import { Client } from "@forwardimpact/librpc/client.js";
|
|
4
|
+
import { createAuth, createGrpc } from "@forwardimpact/librpc/base.js";
|
|
5
|
+
import { createObserver } from "@forwardimpact/libtelemetry";
|
|
6
|
+
import { bridge, common } from "@forwardimpact/libtype";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Typed client for the Bridge gRPC service.
|
|
10
|
+
* Extends the `Client` class for shared gRPC client functionality.
|
|
11
|
+
*/
|
|
12
|
+
export class BridgeClient extends Client {
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new Bridge client instance
|
|
15
|
+
* @param {object} config - Service configuration
|
|
16
|
+
* @param {import("@forwardimpact/libutil/runtime").Runtime} runtime - Injected runtime bag (required; the default auth factory reads SERVICE_SECRET from it)
|
|
17
|
+
* @param {import("@forwardimpact/libtelemetry").Logger} [logger] - Optional logger instance
|
|
18
|
+
* @param {import("@forwardimpact/libtelemetry").Tracer} [tracer] - Optional tracer for distributed tracing
|
|
19
|
+
* @param {Function} [authFn] - Optional authentication function
|
|
20
|
+
*/
|
|
21
|
+
constructor(config, runtime, logger = null, tracer = null, authFn = createAuth) {
|
|
22
|
+
super(config, runtime, logger, tracer, createObserver, createGrpc, authFn);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Call the `LoadDiscussion` RPC with request/response type conversion.
|
|
27
|
+
* @param { bridge.LoadDiscussionRequest } req - Typed request message.
|
|
28
|
+
* @returns { Promise<bridge.Discussion> } Typed response message.
|
|
29
|
+
*/
|
|
30
|
+
async LoadDiscussion(req) {
|
|
31
|
+
// Type validation
|
|
32
|
+
if (!(req instanceof bridge.LoadDiscussionRequest)) {
|
|
33
|
+
throw new TypeError(
|
|
34
|
+
`LoadDiscussion: Expected parameter to be instanceof bridge.LoadDiscussionRequest`,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Convert to plain object
|
|
39
|
+
const request = bridge.LoadDiscussionRequest.toObject(req);
|
|
40
|
+
|
|
41
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
42
|
+
return this.callUnary("LoadDiscussion", request, (res) => bridge.Discussion.fromObject(res));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Call the `LoadDiscussionByCorrelation` RPC with request/response type conversion.
|
|
47
|
+
* @param { bridge.LoadByCorrelationRequest } req - Typed request message.
|
|
48
|
+
* @returns { Promise<bridge.Discussion> } Typed response message.
|
|
49
|
+
*/
|
|
50
|
+
async LoadDiscussionByCorrelation(req) {
|
|
51
|
+
// Type validation
|
|
52
|
+
if (!(req instanceof bridge.LoadByCorrelationRequest)) {
|
|
53
|
+
throw new TypeError(
|
|
54
|
+
`LoadDiscussionByCorrelation: Expected parameter to be instanceof bridge.LoadByCorrelationRequest`,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Convert to plain object
|
|
59
|
+
const request = bridge.LoadByCorrelationRequest.toObject(req);
|
|
60
|
+
|
|
61
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
62
|
+
return this.callUnary("LoadDiscussionByCorrelation", request, (res) => bridge.Discussion.fromObject(res));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Call the `ListOpenRecesses` RPC with request/response type conversion.
|
|
67
|
+
* @param { bridge.ListOpenRecessesRequest } req - Typed request message.
|
|
68
|
+
* @returns { Promise<bridge.OpenRecessList> } Typed response message.
|
|
69
|
+
*/
|
|
70
|
+
async ListOpenRecesses(req) {
|
|
71
|
+
// Type validation
|
|
72
|
+
if (!(req instanceof bridge.ListOpenRecessesRequest)) {
|
|
73
|
+
throw new TypeError(
|
|
74
|
+
`ListOpenRecesses: Expected parameter to be instanceof bridge.ListOpenRecessesRequest`,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Convert to plain object
|
|
79
|
+
const request = bridge.ListOpenRecessesRequest.toObject(req);
|
|
80
|
+
|
|
81
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
82
|
+
return this.callUnary("ListOpenRecesses", request, (res) => bridge.OpenRecessList.fromObject(res));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Call the `SaveDiscussion` RPC with request/response type conversion.
|
|
87
|
+
* @param { bridge.Discussion } req - Typed request message.
|
|
88
|
+
* @returns { Promise<common.Empty> } Typed response message.
|
|
89
|
+
*/
|
|
90
|
+
async SaveDiscussion(req) {
|
|
91
|
+
// Type validation
|
|
92
|
+
if (!(req instanceof bridge.Discussion)) {
|
|
93
|
+
throw new TypeError(
|
|
94
|
+
`SaveDiscussion: Expected parameter to be instanceof bridge.Discussion`,
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Convert to plain object
|
|
99
|
+
const request = bridge.Discussion.toObject(req);
|
|
100
|
+
|
|
101
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
102
|
+
return this.callUnary("SaveDiscussion", request, (res) => common.Empty.fromObject(res));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Call the `HasOrigin` RPC with request/response type conversion.
|
|
107
|
+
* @param { bridge.OriginKey } req - Typed request message.
|
|
108
|
+
* @returns { Promise<bridge.HasOriginResponse> } Typed response message.
|
|
109
|
+
*/
|
|
110
|
+
async HasOrigin(req) {
|
|
111
|
+
// Type validation
|
|
112
|
+
if (!(req instanceof bridge.OriginKey)) {
|
|
113
|
+
throw new TypeError(
|
|
114
|
+
`HasOrigin: Expected parameter to be instanceof bridge.OriginKey`,
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Convert to plain object
|
|
119
|
+
const request = bridge.OriginKey.toObject(req);
|
|
120
|
+
|
|
121
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
122
|
+
return this.callUnary("HasOrigin", request, (res) => bridge.HasOriginResponse.fromObject(res));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Call the `RecordOrigin` RPC with request/response type conversion.
|
|
127
|
+
* @param { bridge.Origin } req - Typed request message.
|
|
128
|
+
* @returns { Promise<common.Empty> } Typed response message.
|
|
129
|
+
*/
|
|
130
|
+
async RecordOrigin(req) {
|
|
131
|
+
// Type validation
|
|
132
|
+
if (!(req instanceof bridge.Origin)) {
|
|
133
|
+
throw new TypeError(
|
|
134
|
+
`RecordOrigin: Expected parameter to be instanceof bridge.Origin`,
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Convert to plain object
|
|
139
|
+
const request = bridge.Origin.toObject(req);
|
|
140
|
+
|
|
141
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
142
|
+
return this.callUnary("RecordOrigin", request, (res) => common.Empty.fromObject(res));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Call the `Sweep` RPC with request/response type conversion.
|
|
147
|
+
* @param { bridge.SweepRequest } req - Typed request message.
|
|
148
|
+
* @returns { Promise<bridge.SweepResponse> } Typed response message.
|
|
149
|
+
*/
|
|
150
|
+
async Sweep(req) {
|
|
151
|
+
// Type validation
|
|
152
|
+
if (!(req instanceof bridge.SweepRequest)) {
|
|
153
|
+
throw new TypeError(
|
|
154
|
+
`Sweep: Expected parameter to be instanceof bridge.SweepRequest`,
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Convert to plain object
|
|
159
|
+
const request = bridge.SweepRequest.toObject(req);
|
|
160
|
+
|
|
161
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
162
|
+
return this.callUnary("Sweep", request, (res) => bridge.SweepResponse.fromObject(res));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Call the `PutPendingDispatch` RPC with request/response type conversion.
|
|
167
|
+
* @param { bridge.PutPendingDispatchRequest } req - Typed request message.
|
|
168
|
+
* @returns { Promise<common.Empty> } Typed response message.
|
|
169
|
+
*/
|
|
170
|
+
async PutPendingDispatch(req) {
|
|
171
|
+
// Type validation
|
|
172
|
+
if (!(req instanceof bridge.PutPendingDispatchRequest)) {
|
|
173
|
+
throw new TypeError(
|
|
174
|
+
`PutPendingDispatch: Expected parameter to be instanceof bridge.PutPendingDispatchRequest`,
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Convert to plain object
|
|
179
|
+
const request = bridge.PutPendingDispatchRequest.toObject(req);
|
|
180
|
+
|
|
181
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
182
|
+
return this.callUnary("PutPendingDispatch", request, (res) => common.Empty.fromObject(res));
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Call the `ResolvePendingDispatch` RPC with request/response type conversion.
|
|
187
|
+
* @param { bridge.ResolvePendingDispatchRequest } req - Typed request message.
|
|
188
|
+
* @returns { Promise<bridge.PendingDispatch> } Typed response message.
|
|
189
|
+
*/
|
|
190
|
+
async ResolvePendingDispatch(req) {
|
|
191
|
+
// Type validation
|
|
192
|
+
if (!(req instanceof bridge.ResolvePendingDispatchRequest)) {
|
|
193
|
+
throw new TypeError(
|
|
194
|
+
`ResolvePendingDispatch: Expected parameter to be instanceof bridge.ResolvePendingDispatchRequest`,
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Convert to plain object
|
|
199
|
+
const request = bridge.ResolvePendingDispatchRequest.toObject(req);
|
|
200
|
+
|
|
201
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
202
|
+
return this.callUnary("ResolvePendingDispatch", request, (res) => bridge.PendingDispatch.fromObject(res));
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Call the `VerifyPendingDispatch` RPC with request/response type conversion.
|
|
207
|
+
* @param { bridge.VerifyPendingDispatchRequest } req - Typed request message.
|
|
208
|
+
* @returns { Promise<common.Empty> } Typed response message.
|
|
209
|
+
*/
|
|
210
|
+
async VerifyPendingDispatch(req) {
|
|
211
|
+
// Type validation
|
|
212
|
+
if (!(req instanceof bridge.VerifyPendingDispatchRequest)) {
|
|
213
|
+
throw new TypeError(
|
|
214
|
+
`VerifyPendingDispatch: Expected parameter to be instanceof bridge.VerifyPendingDispatchRequest`,
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Convert to plain object
|
|
219
|
+
const request = bridge.VerifyPendingDispatchRequest.toObject(req);
|
|
220
|
+
|
|
221
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
222
|
+
return this.callUnary("VerifyPendingDispatch", request, (res) => common.Empty.fromObject(res));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Call the `EnqueueInbox` RPC with request/response type conversion.
|
|
227
|
+
* @param { bridge.EnqueueInboxRequest } req - Typed request message.
|
|
228
|
+
* @returns { Promise<common.Empty> } Typed response message.
|
|
229
|
+
*/
|
|
230
|
+
async EnqueueInbox(req) {
|
|
231
|
+
// Type validation
|
|
232
|
+
if (!(req instanceof bridge.EnqueueInboxRequest)) {
|
|
233
|
+
throw new TypeError(
|
|
234
|
+
`EnqueueInbox: Expected parameter to be instanceof bridge.EnqueueInboxRequest`,
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Convert to plain object
|
|
239
|
+
const request = bridge.EnqueueInboxRequest.toObject(req);
|
|
240
|
+
|
|
241
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
242
|
+
return this.callUnary("EnqueueInbox", request, (res) => common.Empty.fromObject(res));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Call the `DrainInbox` RPC with request/response type conversion.
|
|
247
|
+
* @param { bridge.DrainInboxRequest } req - Typed request message.
|
|
248
|
+
* @returns { Promise<bridge.InboxMessages> } Typed response message.
|
|
249
|
+
*/
|
|
250
|
+
async DrainInbox(req) {
|
|
251
|
+
// Type validation
|
|
252
|
+
if (!(req instanceof bridge.DrainInboxRequest)) {
|
|
253
|
+
throw new TypeError(
|
|
254
|
+
`DrainInbox: Expected parameter to be instanceof bridge.DrainInboxRequest`,
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Convert to plain object
|
|
259
|
+
const request = bridge.DrainInboxRequest.toObject(req);
|
|
260
|
+
|
|
261
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
262
|
+
return this.callUnary("DrainInbox", request, (res) => bridge.InboxMessages.fromObject(res));
|
|
263
|
+
}
|
|
264
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/* eslint no-unused-vars: "off" */
|
|
2
|
+
|
|
3
|
+
import { bridge, common } from "@forwardimpact/libtype";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Base class for Bridge service implementation
|
|
7
|
+
*/
|
|
8
|
+
export class BridgeBase {
|
|
9
|
+
config;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new Bridge service instance
|
|
13
|
+
* @param {object} config - Service configuration
|
|
14
|
+
*/
|
|
15
|
+
constructor(config) {
|
|
16
|
+
if (!config) throw new Error("config is required");
|
|
17
|
+
this.config = config;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Must be implemented by subclass
|
|
22
|
+
* @param { bridge.LoadDiscussionRequest } req - Request parameters
|
|
23
|
+
* @returns { Promise<bridge.Discussion> } Response object
|
|
24
|
+
*/
|
|
25
|
+
async LoadDiscussion(req) {
|
|
26
|
+
throw new Error("LoadDiscussion not implemented");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Must be implemented by subclass
|
|
31
|
+
* @param { bridge.LoadByCorrelationRequest } req - Request parameters
|
|
32
|
+
* @returns { Promise<bridge.Discussion> } Response object
|
|
33
|
+
*/
|
|
34
|
+
async LoadDiscussionByCorrelation(req) {
|
|
35
|
+
throw new Error("LoadDiscussionByCorrelation not implemented");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Must be implemented by subclass
|
|
40
|
+
* @param { bridge.ListOpenRecessesRequest } req - Request parameters
|
|
41
|
+
* @returns { Promise<bridge.OpenRecessList> } Response object
|
|
42
|
+
*/
|
|
43
|
+
async ListOpenRecesses(req) {
|
|
44
|
+
throw new Error("ListOpenRecesses not implemented");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Must be implemented by subclass
|
|
49
|
+
* @param { bridge.Discussion } req - Request parameters
|
|
50
|
+
* @returns { Promise<common.Empty> } Response object
|
|
51
|
+
*/
|
|
52
|
+
async SaveDiscussion(req) {
|
|
53
|
+
throw new Error("SaveDiscussion not implemented");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Must be implemented by subclass
|
|
58
|
+
* @param { bridge.OriginKey } req - Request parameters
|
|
59
|
+
* @returns { Promise<bridge.HasOriginResponse> } Response object
|
|
60
|
+
*/
|
|
61
|
+
async HasOrigin(req) {
|
|
62
|
+
throw new Error("HasOrigin not implemented");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Must be implemented by subclass
|
|
67
|
+
* @param { bridge.Origin } req - Request parameters
|
|
68
|
+
* @returns { Promise<common.Empty> } Response object
|
|
69
|
+
*/
|
|
70
|
+
async RecordOrigin(req) {
|
|
71
|
+
throw new Error("RecordOrigin not implemented");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Must be implemented by subclass
|
|
76
|
+
* @param { bridge.SweepRequest } req - Request parameters
|
|
77
|
+
* @returns { Promise<bridge.SweepResponse> } Response object
|
|
78
|
+
*/
|
|
79
|
+
async Sweep(req) {
|
|
80
|
+
throw new Error("Sweep not implemented");
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Must be implemented by subclass
|
|
85
|
+
* @param { bridge.PutPendingDispatchRequest } req - Request parameters
|
|
86
|
+
* @returns { Promise<common.Empty> } Response object
|
|
87
|
+
*/
|
|
88
|
+
async PutPendingDispatch(req) {
|
|
89
|
+
throw new Error("PutPendingDispatch not implemented");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Must be implemented by subclass
|
|
94
|
+
* @param { bridge.ResolvePendingDispatchRequest } req - Request parameters
|
|
95
|
+
* @returns { Promise<bridge.PendingDispatch> } Response object
|
|
96
|
+
*/
|
|
97
|
+
async ResolvePendingDispatch(req) {
|
|
98
|
+
throw new Error("ResolvePendingDispatch not implemented");
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Must be implemented by subclass
|
|
103
|
+
* @param { bridge.VerifyPendingDispatchRequest } req - Request parameters
|
|
104
|
+
* @returns { Promise<common.Empty> } Response object
|
|
105
|
+
*/
|
|
106
|
+
async VerifyPendingDispatch(req) {
|
|
107
|
+
throw new Error("VerifyPendingDispatch not implemented");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Must be implemented by subclass
|
|
112
|
+
* @param { bridge.EnqueueInboxRequest } req - Request parameters
|
|
113
|
+
* @returns { Promise<common.Empty> } Response object
|
|
114
|
+
*/
|
|
115
|
+
async EnqueueInbox(req) {
|
|
116
|
+
throw new Error("EnqueueInbox not implemented");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Must be implemented by subclass
|
|
121
|
+
* @param { bridge.DrainInboxRequest } req - Request parameters
|
|
122
|
+
* @returns { Promise<bridge.InboxMessages> } Response object
|
|
123
|
+
*/
|
|
124
|
+
async DrainInbox(req) {
|
|
125
|
+
throw new Error("DrainInbox not implemented");
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Creates gRPC handlers for this service instance
|
|
130
|
+
* @returns { object } Map of method names to handler functions
|
|
131
|
+
*/
|
|
132
|
+
getHandlers() {
|
|
133
|
+
return {
|
|
134
|
+
LoadDiscussion: async (call) => {
|
|
135
|
+
// Validate and convert request
|
|
136
|
+
const error = bridge.LoadDiscussionRequest.verify(call.request);
|
|
137
|
+
if (error) throw new Error(`LoadDiscussion: ${error}`);
|
|
138
|
+
const req = bridge.LoadDiscussionRequest.fromObject(call.request);
|
|
139
|
+
|
|
140
|
+
// Call implementation
|
|
141
|
+
return await this.LoadDiscussion(req);
|
|
142
|
+
},
|
|
143
|
+
LoadDiscussionByCorrelation: async (call) => {
|
|
144
|
+
// Validate and convert request
|
|
145
|
+
const error = bridge.LoadByCorrelationRequest.verify(call.request);
|
|
146
|
+
if (error) throw new Error(`LoadDiscussionByCorrelation: ${error}`);
|
|
147
|
+
const req = bridge.LoadByCorrelationRequest.fromObject(call.request);
|
|
148
|
+
|
|
149
|
+
// Call implementation
|
|
150
|
+
return await this.LoadDiscussionByCorrelation(req);
|
|
151
|
+
},
|
|
152
|
+
ListOpenRecesses: async (call) => {
|
|
153
|
+
// Validate and convert request
|
|
154
|
+
const error = bridge.ListOpenRecessesRequest.verify(call.request);
|
|
155
|
+
if (error) throw new Error(`ListOpenRecesses: ${error}`);
|
|
156
|
+
const req = bridge.ListOpenRecessesRequest.fromObject(call.request);
|
|
157
|
+
|
|
158
|
+
// Call implementation
|
|
159
|
+
return await this.ListOpenRecesses(req);
|
|
160
|
+
},
|
|
161
|
+
SaveDiscussion: async (call) => {
|
|
162
|
+
// Validate and convert request
|
|
163
|
+
const error = bridge.Discussion.verify(call.request);
|
|
164
|
+
if (error) throw new Error(`SaveDiscussion: ${error}`);
|
|
165
|
+
const req = bridge.Discussion.fromObject(call.request);
|
|
166
|
+
|
|
167
|
+
// Call implementation
|
|
168
|
+
return await this.SaveDiscussion(req);
|
|
169
|
+
},
|
|
170
|
+
HasOrigin: async (call) => {
|
|
171
|
+
// Validate and convert request
|
|
172
|
+
const error = bridge.OriginKey.verify(call.request);
|
|
173
|
+
if (error) throw new Error(`HasOrigin: ${error}`);
|
|
174
|
+
const req = bridge.OriginKey.fromObject(call.request);
|
|
175
|
+
|
|
176
|
+
// Call implementation
|
|
177
|
+
return await this.HasOrigin(req);
|
|
178
|
+
},
|
|
179
|
+
RecordOrigin: async (call) => {
|
|
180
|
+
// Validate and convert request
|
|
181
|
+
const error = bridge.Origin.verify(call.request);
|
|
182
|
+
if (error) throw new Error(`RecordOrigin: ${error}`);
|
|
183
|
+
const req = bridge.Origin.fromObject(call.request);
|
|
184
|
+
|
|
185
|
+
// Call implementation
|
|
186
|
+
return await this.RecordOrigin(req);
|
|
187
|
+
},
|
|
188
|
+
Sweep: async (call) => {
|
|
189
|
+
// Validate and convert request
|
|
190
|
+
const error = bridge.SweepRequest.verify(call.request);
|
|
191
|
+
if (error) throw new Error(`Sweep: ${error}`);
|
|
192
|
+
const req = bridge.SweepRequest.fromObject(call.request);
|
|
193
|
+
|
|
194
|
+
// Call implementation
|
|
195
|
+
return await this.Sweep(req);
|
|
196
|
+
},
|
|
197
|
+
PutPendingDispatch: async (call) => {
|
|
198
|
+
// Validate and convert request
|
|
199
|
+
const error = bridge.PutPendingDispatchRequest.verify(call.request);
|
|
200
|
+
if (error) throw new Error(`PutPendingDispatch: ${error}`);
|
|
201
|
+
const req = bridge.PutPendingDispatchRequest.fromObject(call.request);
|
|
202
|
+
|
|
203
|
+
// Call implementation
|
|
204
|
+
return await this.PutPendingDispatch(req);
|
|
205
|
+
},
|
|
206
|
+
ResolvePendingDispatch: async (call) => {
|
|
207
|
+
// Validate and convert request
|
|
208
|
+
const error = bridge.ResolvePendingDispatchRequest.verify(call.request);
|
|
209
|
+
if (error) throw new Error(`ResolvePendingDispatch: ${error}`);
|
|
210
|
+
const req = bridge.ResolvePendingDispatchRequest.fromObject(call.request);
|
|
211
|
+
|
|
212
|
+
// Call implementation
|
|
213
|
+
return await this.ResolvePendingDispatch(req);
|
|
214
|
+
},
|
|
215
|
+
VerifyPendingDispatch: async (call) => {
|
|
216
|
+
// Validate and convert request
|
|
217
|
+
const error = bridge.VerifyPendingDispatchRequest.verify(call.request);
|
|
218
|
+
if (error) throw new Error(`VerifyPendingDispatch: ${error}`);
|
|
219
|
+
const req = bridge.VerifyPendingDispatchRequest.fromObject(call.request);
|
|
220
|
+
|
|
221
|
+
// Call implementation
|
|
222
|
+
return await this.VerifyPendingDispatch(req);
|
|
223
|
+
},
|
|
224
|
+
EnqueueInbox: async (call) => {
|
|
225
|
+
// Validate and convert request
|
|
226
|
+
const error = bridge.EnqueueInboxRequest.verify(call.request);
|
|
227
|
+
if (error) throw new Error(`EnqueueInbox: ${error}`);
|
|
228
|
+
const req = bridge.EnqueueInboxRequest.fromObject(call.request);
|
|
229
|
+
|
|
230
|
+
// Call implementation
|
|
231
|
+
return await this.EnqueueInbox(req);
|
|
232
|
+
},
|
|
233
|
+
DrainInbox: async (call) => {
|
|
234
|
+
// Validate and convert request
|
|
235
|
+
const error = bridge.DrainInboxRequest.verify(call.request);
|
|
236
|
+
if (error) throw new Error(`DrainInbox: ${error}`);
|
|
237
|
+
const req = bridge.DrainInboxRequest.fromObject(call.request);
|
|
238
|
+
|
|
239
|
+
// Call implementation
|
|
240
|
+
return await this.DrainInbox(req);
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/* eslint no-unused-vars: "off" */
|
|
2
|
+
|
|
3
|
+
import { Client } from "@forwardimpact/librpc/client.js";
|
|
4
|
+
import { createAuth, createGrpc } from "@forwardimpact/librpc/base.js";
|
|
5
|
+
import { createObserver } from "@forwardimpact/libtelemetry";
|
|
6
|
+
import { embedding } from "@forwardimpact/libtype";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Typed client for the Embedding gRPC service.
|
|
10
|
+
* Extends the `Client` class for shared gRPC client functionality.
|
|
11
|
+
*/
|
|
12
|
+
export class EmbeddingClient extends Client {
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new Embedding client instance
|
|
15
|
+
* @param {object} config - Service configuration
|
|
16
|
+
* @param {import("@forwardimpact/libutil/runtime").Runtime} runtime - Injected runtime bag (required; the default auth factory reads SERVICE_SECRET from it)
|
|
17
|
+
* @param {import("@forwardimpact/libtelemetry").Logger} [logger] - Optional logger instance
|
|
18
|
+
* @param {import("@forwardimpact/libtelemetry").Tracer} [tracer] - Optional tracer for distributed tracing
|
|
19
|
+
* @param {Function} [authFn] - Optional authentication function
|
|
20
|
+
*/
|
|
21
|
+
constructor(config, runtime, logger = null, tracer = null, authFn = createAuth) {
|
|
22
|
+
super(config, runtime, logger, tracer, createObserver, createGrpc, authFn);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Call the `CreateEmbeddings` RPC with request/response type conversion.
|
|
27
|
+
* @param { embedding.EmbeddingsRequest } req - Typed request message.
|
|
28
|
+
* @returns { Promise<embedding.EmbeddingsResponse> } Typed response message.
|
|
29
|
+
*/
|
|
30
|
+
async CreateEmbeddings(req) {
|
|
31
|
+
// Type validation
|
|
32
|
+
if (!(req instanceof embedding.EmbeddingsRequest)) {
|
|
33
|
+
throw new TypeError(
|
|
34
|
+
`CreateEmbeddings: Expected parameter to be instanceof embedding.EmbeddingsRequest`,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Convert to plain object
|
|
39
|
+
const request = embedding.EmbeddingsRequest.toObject(req);
|
|
40
|
+
|
|
41
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
42
|
+
return this.callUnary("CreateEmbeddings", request, (res) => embedding.EmbeddingsResponse.fromObject(res));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/* eslint no-unused-vars: "off" */
|
|
2
|
+
|
|
3
|
+
import { embedding } from "@forwardimpact/libtype";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Base class for Embedding service implementation
|
|
7
|
+
*/
|
|
8
|
+
export class EmbeddingBase {
|
|
9
|
+
config;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new Embedding service instance
|
|
13
|
+
* @param {object} config - Service configuration
|
|
14
|
+
*/
|
|
15
|
+
constructor(config) {
|
|
16
|
+
if (!config) throw new Error("config is required");
|
|
17
|
+
this.config = config;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Must be implemented by subclass
|
|
22
|
+
* @param { embedding.EmbeddingsRequest } req - Request parameters
|
|
23
|
+
* @returns { Promise<embedding.EmbeddingsResponse> } Response object
|
|
24
|
+
*/
|
|
25
|
+
async CreateEmbeddings(req) {
|
|
26
|
+
throw new Error("CreateEmbeddings not implemented");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Creates gRPC handlers for this service instance
|
|
31
|
+
* @returns { object } Map of method names to handler functions
|
|
32
|
+
*/
|
|
33
|
+
getHandlers() {
|
|
34
|
+
return {
|
|
35
|
+
CreateEmbeddings: async (call) => {
|
|
36
|
+
// Validate and convert request
|
|
37
|
+
const error = embedding.EmbeddingsRequest.verify(call.request);
|
|
38
|
+
if (error) throw new Error(`CreateEmbeddings: ${error}`);
|
|
39
|
+
const req = embedding.EmbeddingsRequest.fromObject(call.request);
|
|
40
|
+
|
|
41
|
+
// Call implementation
|
|
42
|
+
return await this.CreateEmbeddings(req);
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|