@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,103 @@
|
|
|
1
|
+
// THIS FILE IS AUTO-GENERATED - DO NOT EDIT
|
|
2
|
+
// Generated by scripts/codegen.js
|
|
3
|
+
|
|
4
|
+
// Service Base Classes
|
|
5
|
+
export { BridgeBase } from "./bridge/service.js";
|
|
6
|
+
export { EmbeddingBase } from "./embedding/service.js";
|
|
7
|
+
export { GhserverBase } from "./ghserver/service.js";
|
|
8
|
+
export { GhuserBase } from "./ghuser/service.js";
|
|
9
|
+
export { GraphBase } from "./graph/service.js";
|
|
10
|
+
export { MapBase } from "./map/service.js";
|
|
11
|
+
export { PathwayBase } from "./pathway/service.js";
|
|
12
|
+
export { TenancyBase } from "./tenancy/service.js";
|
|
13
|
+
export { TraceBase } from "./trace/service.js";
|
|
14
|
+
export { VectorBase } from "./vector/service.js";
|
|
15
|
+
|
|
16
|
+
// Client Classes
|
|
17
|
+
export { BridgeClient } from "./bridge/client.js";
|
|
18
|
+
export { EmbeddingClient } from "./embedding/client.js";
|
|
19
|
+
export { GhserverClient } from "./ghserver/client.js";
|
|
20
|
+
export { GhuserClient } from "./ghuser/client.js";
|
|
21
|
+
export { GraphClient } from "./graph/client.js";
|
|
22
|
+
export { MapClient } from "./map/client.js";
|
|
23
|
+
export { PathwayClient } from "./pathway/client.js";
|
|
24
|
+
export { TenancyClient } from "./tenancy/client.js";
|
|
25
|
+
export { TraceClient } from "./trace/client.js";
|
|
26
|
+
export { VectorClient } from "./vector/client.js";
|
|
27
|
+
|
|
28
|
+
// Import service base classes to make them available for aggregation
|
|
29
|
+
import { BridgeBase } from "./bridge/service.js";
|
|
30
|
+
import { EmbeddingBase } from "./embedding/service.js";
|
|
31
|
+
import { GhserverBase } from "./ghserver/service.js";
|
|
32
|
+
import { GhuserBase } from "./ghuser/service.js";
|
|
33
|
+
import { GraphBase } from "./graph/service.js";
|
|
34
|
+
import { MapBase } from "./map/service.js";
|
|
35
|
+
import { PathwayBase } from "./pathway/service.js";
|
|
36
|
+
import { TenancyBase } from "./tenancy/service.js";
|
|
37
|
+
import { TraceBase } from "./trace/service.js";
|
|
38
|
+
import { VectorBase } from "./vector/service.js";
|
|
39
|
+
|
|
40
|
+
// Import client classes to make them available for aggregation
|
|
41
|
+
import { BridgeClient } from "./bridge/client.js";
|
|
42
|
+
import { EmbeddingClient } from "./embedding/client.js";
|
|
43
|
+
import { GhserverClient } from "./ghserver/client.js";
|
|
44
|
+
import { GhuserClient } from "./ghuser/client.js";
|
|
45
|
+
import { GraphClient } from "./graph/client.js";
|
|
46
|
+
import { MapClient } from "./map/client.js";
|
|
47
|
+
import { PathwayClient } from "./pathway/client.js";
|
|
48
|
+
import { TenancyClient } from "./tenancy/client.js";
|
|
49
|
+
import { TraceClient } from "./trace/client.js";
|
|
50
|
+
import { VectorClient } from "./vector/client.js";
|
|
51
|
+
|
|
52
|
+
// Aggregate exports for convenience
|
|
53
|
+
export const services = {
|
|
54
|
+
BridgeBase,
|
|
55
|
+
EmbeddingBase,
|
|
56
|
+
GhserverBase,
|
|
57
|
+
GhuserBase,
|
|
58
|
+
GraphBase,
|
|
59
|
+
MapBase,
|
|
60
|
+
PathwayBase,
|
|
61
|
+
TenancyBase,
|
|
62
|
+
TraceBase,
|
|
63
|
+
VectorBase,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const clients = {
|
|
67
|
+
BridgeClient,
|
|
68
|
+
EmbeddingClient,
|
|
69
|
+
GhserverClient,
|
|
70
|
+
GhuserClient,
|
|
71
|
+
GraphClient,
|
|
72
|
+
MapClient,
|
|
73
|
+
PathwayClient,
|
|
74
|
+
TenancyClient,
|
|
75
|
+
TraceClient,
|
|
76
|
+
VectorClient,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// Re-export everything as default for dynamic importing
|
|
80
|
+
export default {
|
|
81
|
+
services,
|
|
82
|
+
clients,
|
|
83
|
+
BridgeBase,
|
|
84
|
+
EmbeddingBase,
|
|
85
|
+
GhserverBase,
|
|
86
|
+
GhuserBase,
|
|
87
|
+
GraphBase,
|
|
88
|
+
MapBase,
|
|
89
|
+
PathwayBase,
|
|
90
|
+
TenancyBase,
|
|
91
|
+
TraceBase,
|
|
92
|
+
VectorBase,
|
|
93
|
+
BridgeClient,
|
|
94
|
+
EmbeddingClient,
|
|
95
|
+
GhserverClient,
|
|
96
|
+
GhuserClient,
|
|
97
|
+
GraphClient,
|
|
98
|
+
MapClient,
|
|
99
|
+
PathwayClient,
|
|
100
|
+
TenancyClient,
|
|
101
|
+
TraceClient,
|
|
102
|
+
VectorClient,
|
|
103
|
+
};
|
|
@@ -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 { ghserver } from "@forwardimpact/libtype";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Typed client for the Ghserver gRPC service.
|
|
10
|
+
* Extends the `Client` class for shared gRPC client functionality.
|
|
11
|
+
*/
|
|
12
|
+
export class GhserverClient extends Client {
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new Ghserver 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 `MintInstallationToken` RPC with request/response type conversion.
|
|
27
|
+
* @param { ghserver.MintRequest } req - Typed request message.
|
|
28
|
+
* @returns { Promise<ghserver.MintResponse> } Typed response message.
|
|
29
|
+
*/
|
|
30
|
+
async MintInstallationToken(req) {
|
|
31
|
+
// Type validation
|
|
32
|
+
if (!(req instanceof ghserver.MintRequest)) {
|
|
33
|
+
throw new TypeError(
|
|
34
|
+
`MintInstallationToken: Expected parameter to be instanceof ghserver.MintRequest`,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Convert to plain object
|
|
39
|
+
const request = ghserver.MintRequest.toObject(req);
|
|
40
|
+
|
|
41
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
42
|
+
return this.callUnary("MintInstallationToken", request, (res) => ghserver.MintResponse.fromObject(res));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/* eslint no-unused-vars: "off" */
|
|
2
|
+
|
|
3
|
+
import { ghserver } from "@forwardimpact/libtype";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Base class for Ghserver service implementation
|
|
7
|
+
*/
|
|
8
|
+
export class GhserverBase {
|
|
9
|
+
config;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new Ghserver 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 { ghserver.MintRequest } req - Request parameters
|
|
23
|
+
* @returns { Promise<ghserver.MintResponse> } Response object
|
|
24
|
+
*/
|
|
25
|
+
async MintInstallationToken(req) {
|
|
26
|
+
throw new Error("MintInstallationToken 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
|
+
MintInstallationToken: async (call) => {
|
|
36
|
+
// Validate and convert request
|
|
37
|
+
const error = ghserver.MintRequest.verify(call.request);
|
|
38
|
+
if (error) throw new Error(`MintInstallationToken: ${error}`);
|
|
39
|
+
const req = ghserver.MintRequest.fromObject(call.request);
|
|
40
|
+
|
|
41
|
+
// Call implementation
|
|
42
|
+
return await this.MintInstallationToken(req);
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
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 { ghuser, common } from "@forwardimpact/libtype";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Typed client for the Ghuser gRPC service.
|
|
10
|
+
* Extends the `Client` class for shared gRPC client functionality.
|
|
11
|
+
*/
|
|
12
|
+
export class GhuserClient extends Client {
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new Ghuser 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 `Begin` RPC with request/response type conversion.
|
|
27
|
+
* @param { ghuser.BeginRequest } req - Typed request message.
|
|
28
|
+
* @returns { Promise<ghuser.BeginResponse> } Typed response message.
|
|
29
|
+
*/
|
|
30
|
+
async Begin(req) {
|
|
31
|
+
// Type validation
|
|
32
|
+
if (!(req instanceof ghuser.BeginRequest)) {
|
|
33
|
+
throw new TypeError(
|
|
34
|
+
`Begin: Expected parameter to be instanceof ghuser.BeginRequest`,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Convert to plain object
|
|
39
|
+
const request = ghuser.BeginRequest.toObject(req);
|
|
40
|
+
|
|
41
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
42
|
+
return this.callUnary("Begin", request, (res) => ghuser.BeginResponse.fromObject(res));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Call the `Complete` RPC with request/response type conversion.
|
|
47
|
+
* @param { ghuser.CompleteRequest } req - Typed request message.
|
|
48
|
+
* @returns { Promise<ghuser.CompleteResponse> } Typed response message.
|
|
49
|
+
*/
|
|
50
|
+
async Complete(req) {
|
|
51
|
+
// Type validation
|
|
52
|
+
if (!(req instanceof ghuser.CompleteRequest)) {
|
|
53
|
+
throw new TypeError(
|
|
54
|
+
`Complete: Expected parameter to be instanceof ghuser.CompleteRequest`,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Convert to plain object
|
|
59
|
+
const request = ghuser.CompleteRequest.toObject(req);
|
|
60
|
+
|
|
61
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
62
|
+
return this.callUnary("Complete", request, (res) => ghuser.CompleteResponse.fromObject(res));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Call the `Redeem` RPC with request/response type conversion.
|
|
67
|
+
* @param { ghuser.RedeemRequest } req - Typed request message.
|
|
68
|
+
* @returns { Promise<ghuser.RedeemResponse> } Typed response message.
|
|
69
|
+
*/
|
|
70
|
+
async Redeem(req) {
|
|
71
|
+
// Type validation
|
|
72
|
+
if (!(req instanceof ghuser.RedeemRequest)) {
|
|
73
|
+
throw new TypeError(
|
|
74
|
+
`Redeem: Expected parameter to be instanceof ghuser.RedeemRequest`,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Convert to plain object
|
|
79
|
+
const request = ghuser.RedeemRequest.toObject(req);
|
|
80
|
+
|
|
81
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
82
|
+
return this.callUnary("Redeem", request, (res) => ghuser.RedeemResponse.fromObject(res));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Call the `GetToken` RPC with request/response type conversion.
|
|
87
|
+
* @param { ghuser.GetTokenRequest } req - Typed request message.
|
|
88
|
+
* @returns { Promise<ghuser.GetTokenResponse> } Typed response message.
|
|
89
|
+
*/
|
|
90
|
+
async GetToken(req) {
|
|
91
|
+
// Type validation
|
|
92
|
+
if (!(req instanceof ghuser.GetTokenRequest)) {
|
|
93
|
+
throw new TypeError(
|
|
94
|
+
`GetToken: Expected parameter to be instanceof ghuser.GetTokenRequest`,
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Convert to plain object
|
|
99
|
+
const request = ghuser.GetTokenRequest.toObject(req);
|
|
100
|
+
|
|
101
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
102
|
+
return this.callUnary("GetToken", request, (res) => ghuser.GetTokenResponse.fromObject(res));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Call the `Revoke` RPC with request/response type conversion.
|
|
107
|
+
* @param { ghuser.RevokeRequest } req - Typed request message.
|
|
108
|
+
* @returns { Promise<common.Empty> } Typed response message.
|
|
109
|
+
*/
|
|
110
|
+
async Revoke(req) {
|
|
111
|
+
// Type validation
|
|
112
|
+
if (!(req instanceof ghuser.RevokeRequest)) {
|
|
113
|
+
throw new TypeError(
|
|
114
|
+
`Revoke: Expected parameter to be instanceof ghuser.RevokeRequest`,
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Convert to plain object
|
|
119
|
+
const request = ghuser.RevokeRequest.toObject(req);
|
|
120
|
+
|
|
121
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
122
|
+
return this.callUnary("Revoke", request, (res) => common.Empty.fromObject(res));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/* eslint no-unused-vars: "off" */
|
|
2
|
+
|
|
3
|
+
import { ghuser, common } from "@forwardimpact/libtype";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Base class for Ghuser service implementation
|
|
7
|
+
*/
|
|
8
|
+
export class GhuserBase {
|
|
9
|
+
config;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new Ghuser 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 { ghuser.BeginRequest } req - Request parameters
|
|
23
|
+
* @returns { Promise<ghuser.BeginResponse> } Response object
|
|
24
|
+
*/
|
|
25
|
+
async Begin(req) {
|
|
26
|
+
throw new Error("Begin not implemented");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Must be implemented by subclass
|
|
31
|
+
* @param { ghuser.CompleteRequest } req - Request parameters
|
|
32
|
+
* @returns { Promise<ghuser.CompleteResponse> } Response object
|
|
33
|
+
*/
|
|
34
|
+
async Complete(req) {
|
|
35
|
+
throw new Error("Complete not implemented");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Must be implemented by subclass
|
|
40
|
+
* @param { ghuser.RedeemRequest } req - Request parameters
|
|
41
|
+
* @returns { Promise<ghuser.RedeemResponse> } Response object
|
|
42
|
+
*/
|
|
43
|
+
async Redeem(req) {
|
|
44
|
+
throw new Error("Redeem not implemented");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Must be implemented by subclass
|
|
49
|
+
* @param { ghuser.GetTokenRequest } req - Request parameters
|
|
50
|
+
* @returns { Promise<ghuser.GetTokenResponse> } Response object
|
|
51
|
+
*/
|
|
52
|
+
async GetToken(req) {
|
|
53
|
+
throw new Error("GetToken not implemented");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Must be implemented by subclass
|
|
58
|
+
* @param { ghuser.RevokeRequest } req - Request parameters
|
|
59
|
+
* @returns { Promise<common.Empty> } Response object
|
|
60
|
+
*/
|
|
61
|
+
async Revoke(req) {
|
|
62
|
+
throw new Error("Revoke not implemented");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Creates gRPC handlers for this service instance
|
|
67
|
+
* @returns { object } Map of method names to handler functions
|
|
68
|
+
*/
|
|
69
|
+
getHandlers() {
|
|
70
|
+
return {
|
|
71
|
+
Begin: async (call) => {
|
|
72
|
+
// Validate and convert request
|
|
73
|
+
const error = ghuser.BeginRequest.verify(call.request);
|
|
74
|
+
if (error) throw new Error(`Begin: ${error}`);
|
|
75
|
+
const req = ghuser.BeginRequest.fromObject(call.request);
|
|
76
|
+
|
|
77
|
+
// Call implementation
|
|
78
|
+
return await this.Begin(req);
|
|
79
|
+
},
|
|
80
|
+
Complete: async (call) => {
|
|
81
|
+
// Validate and convert request
|
|
82
|
+
const error = ghuser.CompleteRequest.verify(call.request);
|
|
83
|
+
if (error) throw new Error(`Complete: ${error}`);
|
|
84
|
+
const req = ghuser.CompleteRequest.fromObject(call.request);
|
|
85
|
+
|
|
86
|
+
// Call implementation
|
|
87
|
+
return await this.Complete(req);
|
|
88
|
+
},
|
|
89
|
+
Redeem: async (call) => {
|
|
90
|
+
// Validate and convert request
|
|
91
|
+
const error = ghuser.RedeemRequest.verify(call.request);
|
|
92
|
+
if (error) throw new Error(`Redeem: ${error}`);
|
|
93
|
+
const req = ghuser.RedeemRequest.fromObject(call.request);
|
|
94
|
+
|
|
95
|
+
// Call implementation
|
|
96
|
+
return await this.Redeem(req);
|
|
97
|
+
},
|
|
98
|
+
GetToken: async (call) => {
|
|
99
|
+
// Validate and convert request
|
|
100
|
+
const error = ghuser.GetTokenRequest.verify(call.request);
|
|
101
|
+
if (error) throw new Error(`GetToken: ${error}`);
|
|
102
|
+
const req = ghuser.GetTokenRequest.fromObject(call.request);
|
|
103
|
+
|
|
104
|
+
// Call implementation
|
|
105
|
+
return await this.GetToken(req);
|
|
106
|
+
},
|
|
107
|
+
Revoke: async (call) => {
|
|
108
|
+
// Validate and convert request
|
|
109
|
+
const error = ghuser.RevokeRequest.verify(call.request);
|
|
110
|
+
if (error) throw new Error(`Revoke: ${error}`);
|
|
111
|
+
const req = ghuser.RevokeRequest.fromObject(call.request);
|
|
112
|
+
|
|
113
|
+
// Call implementation
|
|
114
|
+
return await this.Revoke(req);
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
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 { graph, tool, common } from "@forwardimpact/libtype";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Typed client for the Graph gRPC service.
|
|
10
|
+
* Extends the `Client` class for shared gRPC client functionality.
|
|
11
|
+
*/
|
|
12
|
+
export class GraphClient extends Client {
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new Graph 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 `QueryByPattern` RPC with request/response type conversion.
|
|
27
|
+
* @param { graph.PatternQuery } req - Typed request message.
|
|
28
|
+
* @returns { Promise<tool.ToolCallResult> } Typed response message.
|
|
29
|
+
*/
|
|
30
|
+
async QueryByPattern(req) {
|
|
31
|
+
// Type validation
|
|
32
|
+
if (!(req instanceof graph.PatternQuery)) {
|
|
33
|
+
throw new TypeError(
|
|
34
|
+
`QueryByPattern: Expected parameter to be instanceof graph.PatternQuery`,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Convert to plain object
|
|
39
|
+
const request = graph.PatternQuery.toObject(req);
|
|
40
|
+
|
|
41
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
42
|
+
return this.callUnary("QueryByPattern", request, (res) => tool.ToolCallResult.fromObject(res));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Call the `GetOntology` RPC with request/response type conversion.
|
|
47
|
+
* @param { common.Empty } req - Typed request message.
|
|
48
|
+
* @returns { Promise<tool.ToolCallResult> } Typed response message.
|
|
49
|
+
*/
|
|
50
|
+
async GetOntology(req) {
|
|
51
|
+
// Type validation
|
|
52
|
+
if (!(req instanceof common.Empty)) {
|
|
53
|
+
throw new TypeError(
|
|
54
|
+
`GetOntology: Expected parameter to be instanceof common.Empty`,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Convert to plain object
|
|
59
|
+
const request = common.Empty.toObject(req);
|
|
60
|
+
|
|
61
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
62
|
+
return this.callUnary("GetOntology", request, (res) => tool.ToolCallResult.fromObject(res));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Call the `GetSubjects` RPC with request/response type conversion.
|
|
67
|
+
* @param { graph.SubjectsQuery } req - Typed request message.
|
|
68
|
+
* @returns { Promise<tool.ToolCallResult> } Typed response message.
|
|
69
|
+
*/
|
|
70
|
+
async GetSubjects(req) {
|
|
71
|
+
// Type validation
|
|
72
|
+
if (!(req instanceof graph.SubjectsQuery)) {
|
|
73
|
+
throw new TypeError(
|
|
74
|
+
`GetSubjects: Expected parameter to be instanceof graph.SubjectsQuery`,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Convert to plain object
|
|
79
|
+
const request = graph.SubjectsQuery.toObject(req);
|
|
80
|
+
|
|
81
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
82
|
+
return this.callUnary("GetSubjects", request, (res) => tool.ToolCallResult.fromObject(res));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/* eslint no-unused-vars: "off" */
|
|
2
|
+
|
|
3
|
+
import { graph, tool, common } from "@forwardimpact/libtype";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Base class for Graph service implementation
|
|
7
|
+
*/
|
|
8
|
+
export class GraphBase {
|
|
9
|
+
config;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new Graph 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 { graph.PatternQuery } req - Request parameters
|
|
23
|
+
* @returns { Promise<tool.ToolCallResult> } Response object
|
|
24
|
+
*/
|
|
25
|
+
async QueryByPattern(req) {
|
|
26
|
+
throw new Error("QueryByPattern not implemented");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Must be implemented by subclass
|
|
31
|
+
* @param { common.Empty } req - Request parameters
|
|
32
|
+
* @returns { Promise<tool.ToolCallResult> } Response object
|
|
33
|
+
*/
|
|
34
|
+
async GetOntology(req) {
|
|
35
|
+
throw new Error("GetOntology not implemented");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Must be implemented by subclass
|
|
40
|
+
* @param { graph.SubjectsQuery } req - Request parameters
|
|
41
|
+
* @returns { Promise<tool.ToolCallResult> } Response object
|
|
42
|
+
*/
|
|
43
|
+
async GetSubjects(req) {
|
|
44
|
+
throw new Error("GetSubjects not implemented");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Creates gRPC handlers for this service instance
|
|
49
|
+
* @returns { object } Map of method names to handler functions
|
|
50
|
+
*/
|
|
51
|
+
getHandlers() {
|
|
52
|
+
return {
|
|
53
|
+
QueryByPattern: async (call) => {
|
|
54
|
+
// Validate and convert request
|
|
55
|
+
const error = graph.PatternQuery.verify(call.request);
|
|
56
|
+
if (error) throw new Error(`QueryByPattern: ${error}`);
|
|
57
|
+
const req = graph.PatternQuery.fromObject(call.request);
|
|
58
|
+
|
|
59
|
+
// Call implementation
|
|
60
|
+
return await this.QueryByPattern(req);
|
|
61
|
+
},
|
|
62
|
+
GetOntology: async (call) => {
|
|
63
|
+
// Validate and convert request
|
|
64
|
+
const error = common.Empty.verify(call.request);
|
|
65
|
+
if (error) throw new Error(`GetOntology: ${error}`);
|
|
66
|
+
const req = common.Empty.fromObject(call.request);
|
|
67
|
+
|
|
68
|
+
// Call implementation
|
|
69
|
+
return await this.GetOntology(req);
|
|
70
|
+
},
|
|
71
|
+
GetSubjects: async (call) => {
|
|
72
|
+
// Validate and convert request
|
|
73
|
+
const error = graph.SubjectsQuery.verify(call.request);
|
|
74
|
+
if (error) throw new Error(`GetSubjects: ${error}`);
|
|
75
|
+
const req = graph.SubjectsQuery.fromObject(call.request);
|
|
76
|
+
|
|
77
|
+
// Call implementation
|
|
78
|
+
return await this.GetSubjects(req);
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|