@forwardimpact/librpc 0.1.106 → 0.1.108
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/package.json +4 -1
- 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 +21734 -0
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
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 { map, tool } from "@forwardimpact/libtype";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Typed client for the Map gRPC service.
|
|
10
|
+
* Extends the `Client` class for shared gRPC client functionality.
|
|
11
|
+
*/
|
|
12
|
+
export class MapClient extends Client {
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new Map 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 `GetUnscoredArtifacts` RPC with request/response type conversion.
|
|
27
|
+
* @param { map.GetUnscoredArtifactsRequest } req - Typed request message.
|
|
28
|
+
* @returns { Promise<tool.ToolCallResult> } Typed response message.
|
|
29
|
+
*/
|
|
30
|
+
async GetUnscoredArtifacts(req) {
|
|
31
|
+
// Type validation
|
|
32
|
+
if (!(req instanceof map.GetUnscoredArtifactsRequest)) {
|
|
33
|
+
throw new TypeError(
|
|
34
|
+
`GetUnscoredArtifacts: Expected parameter to be instanceof map.GetUnscoredArtifactsRequest`,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Convert to plain object
|
|
39
|
+
const request = map.GetUnscoredArtifactsRequest.toObject(req);
|
|
40
|
+
|
|
41
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
42
|
+
return this.callUnary("GetUnscoredArtifacts", request, (res) => tool.ToolCallResult.fromObject(res));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Call the `GetArtifact` RPC with request/response type conversion.
|
|
47
|
+
* @param { map.GetArtifactRequest } req - Typed request message.
|
|
48
|
+
* @returns { Promise<tool.ToolCallResult> } Typed response message.
|
|
49
|
+
*/
|
|
50
|
+
async GetArtifact(req) {
|
|
51
|
+
// Type validation
|
|
52
|
+
if (!(req instanceof map.GetArtifactRequest)) {
|
|
53
|
+
throw new TypeError(
|
|
54
|
+
`GetArtifact: Expected parameter to be instanceof map.GetArtifactRequest`,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Convert to plain object
|
|
59
|
+
const request = map.GetArtifactRequest.toObject(req);
|
|
60
|
+
|
|
61
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
62
|
+
return this.callUnary("GetArtifact", request, (res) => tool.ToolCallResult.fromObject(res));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Call the `WriteEvidence` RPC with request/response type conversion.
|
|
67
|
+
* @param { map.WriteEvidenceRequest } req - Typed request message.
|
|
68
|
+
* @returns { Promise<tool.ToolCallResult> } Typed response message.
|
|
69
|
+
*/
|
|
70
|
+
async WriteEvidence(req) {
|
|
71
|
+
// Type validation
|
|
72
|
+
if (!(req instanceof map.WriteEvidenceRequest)) {
|
|
73
|
+
throw new TypeError(
|
|
74
|
+
`WriteEvidence: Expected parameter to be instanceof map.WriteEvidenceRequest`,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Convert to plain object
|
|
79
|
+
const request = map.WriteEvidenceRequest.toObject(req);
|
|
80
|
+
|
|
81
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
82
|
+
return this.callUnary("WriteEvidence", request, (res) => tool.ToolCallResult.fromObject(res));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Call the `GetPerson` RPC with request/response type conversion.
|
|
87
|
+
* @param { map.GetPersonRequest } req - Typed request message.
|
|
88
|
+
* @returns { Promise<tool.ToolCallResult> } Typed response message.
|
|
89
|
+
*/
|
|
90
|
+
async GetPerson(req) {
|
|
91
|
+
// Type validation
|
|
92
|
+
if (!(req instanceof map.GetPersonRequest)) {
|
|
93
|
+
throw new TypeError(
|
|
94
|
+
`GetPerson: Expected parameter to be instanceof map.GetPersonRequest`,
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Convert to plain object
|
|
99
|
+
const request = map.GetPersonRequest.toObject(req);
|
|
100
|
+
|
|
101
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
102
|
+
return this.callUnary("GetPerson", request, (res) => tool.ToolCallResult.fromObject(res));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/* eslint no-unused-vars: "off" */
|
|
2
|
+
|
|
3
|
+
import { map, tool } from "@forwardimpact/libtype";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Base class for Map service implementation
|
|
7
|
+
*/
|
|
8
|
+
export class MapBase {
|
|
9
|
+
config;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new Map 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 { map.GetUnscoredArtifactsRequest } req - Request parameters
|
|
23
|
+
* @returns { Promise<tool.ToolCallResult> } Response object
|
|
24
|
+
*/
|
|
25
|
+
async GetUnscoredArtifacts(req) {
|
|
26
|
+
throw new Error("GetUnscoredArtifacts not implemented");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Must be implemented by subclass
|
|
31
|
+
* @param { map.GetArtifactRequest } req - Request parameters
|
|
32
|
+
* @returns { Promise<tool.ToolCallResult> } Response object
|
|
33
|
+
*/
|
|
34
|
+
async GetArtifact(req) {
|
|
35
|
+
throw new Error("GetArtifact not implemented");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Must be implemented by subclass
|
|
40
|
+
* @param { map.WriteEvidenceRequest } req - Request parameters
|
|
41
|
+
* @returns { Promise<tool.ToolCallResult> } Response object
|
|
42
|
+
*/
|
|
43
|
+
async WriteEvidence(req) {
|
|
44
|
+
throw new Error("WriteEvidence not implemented");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Must be implemented by subclass
|
|
49
|
+
* @param { map.GetPersonRequest } req - Request parameters
|
|
50
|
+
* @returns { Promise<tool.ToolCallResult> } Response object
|
|
51
|
+
*/
|
|
52
|
+
async GetPerson(req) {
|
|
53
|
+
throw new Error("GetPerson not implemented");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Creates gRPC handlers for this service instance
|
|
58
|
+
* @returns { object } Map of method names to handler functions
|
|
59
|
+
*/
|
|
60
|
+
getHandlers() {
|
|
61
|
+
return {
|
|
62
|
+
GetUnscoredArtifacts: async (call) => {
|
|
63
|
+
// Validate and convert request
|
|
64
|
+
const error = map.GetUnscoredArtifactsRequest.verify(call.request);
|
|
65
|
+
if (error) throw new Error(`GetUnscoredArtifacts: ${error}`);
|
|
66
|
+
const req = map.GetUnscoredArtifactsRequest.fromObject(call.request);
|
|
67
|
+
|
|
68
|
+
// Call implementation
|
|
69
|
+
return await this.GetUnscoredArtifacts(req);
|
|
70
|
+
},
|
|
71
|
+
GetArtifact: async (call) => {
|
|
72
|
+
// Validate and convert request
|
|
73
|
+
const error = map.GetArtifactRequest.verify(call.request);
|
|
74
|
+
if (error) throw new Error(`GetArtifact: ${error}`);
|
|
75
|
+
const req = map.GetArtifactRequest.fromObject(call.request);
|
|
76
|
+
|
|
77
|
+
// Call implementation
|
|
78
|
+
return await this.GetArtifact(req);
|
|
79
|
+
},
|
|
80
|
+
WriteEvidence: async (call) => {
|
|
81
|
+
// Validate and convert request
|
|
82
|
+
const error = map.WriteEvidenceRequest.verify(call.request);
|
|
83
|
+
if (error) throw new Error(`WriteEvidence: ${error}`);
|
|
84
|
+
const req = map.WriteEvidenceRequest.fromObject(call.request);
|
|
85
|
+
|
|
86
|
+
// Call implementation
|
|
87
|
+
return await this.WriteEvidence(req);
|
|
88
|
+
},
|
|
89
|
+
GetPerson: async (call) => {
|
|
90
|
+
// Validate and convert request
|
|
91
|
+
const error = map.GetPersonRequest.verify(call.request);
|
|
92
|
+
if (error) throw new Error(`GetPerson: ${error}`);
|
|
93
|
+
const req = map.GetPersonRequest.fromObject(call.request);
|
|
94
|
+
|
|
95
|
+
// Call implementation
|
|
96
|
+
return await this.GetPerson(req);
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
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 { pathway, tool } from "@forwardimpact/libtype";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Typed client for the Pathway gRPC service.
|
|
10
|
+
* Extends the `Client` class for shared gRPC client functionality.
|
|
11
|
+
*/
|
|
12
|
+
export class PathwayClient extends Client {
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new Pathway 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 `ListJobs` RPC with request/response type conversion.
|
|
27
|
+
* @param { pathway.ListJobsRequest } req - Typed request message.
|
|
28
|
+
* @returns { Promise<tool.ToolCallResult> } Typed response message.
|
|
29
|
+
*/
|
|
30
|
+
async ListJobs(req) {
|
|
31
|
+
// Type validation
|
|
32
|
+
if (!(req instanceof pathway.ListJobsRequest)) {
|
|
33
|
+
throw new TypeError(
|
|
34
|
+
`ListJobs: Expected parameter to be instanceof pathway.ListJobsRequest`,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Convert to plain object
|
|
39
|
+
const request = pathway.ListJobsRequest.toObject(req);
|
|
40
|
+
|
|
41
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
42
|
+
return this.callUnary("ListJobs", request, (res) => tool.ToolCallResult.fromObject(res));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Call the `DescribeJob` RPC with request/response type conversion.
|
|
47
|
+
* @param { pathway.DescribeJobRequest } req - Typed request message.
|
|
48
|
+
* @returns { Promise<tool.ToolCallResult> } Typed response message.
|
|
49
|
+
*/
|
|
50
|
+
async DescribeJob(req) {
|
|
51
|
+
// Type validation
|
|
52
|
+
if (!(req instanceof pathway.DescribeJobRequest)) {
|
|
53
|
+
throw new TypeError(
|
|
54
|
+
`DescribeJob: Expected parameter to be instanceof pathway.DescribeJobRequest`,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Convert to plain object
|
|
59
|
+
const request = pathway.DescribeJobRequest.toObject(req);
|
|
60
|
+
|
|
61
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
62
|
+
return this.callUnary("DescribeJob", request, (res) => tool.ToolCallResult.fromObject(res));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Call the `ListAgentProfiles` RPC with request/response type conversion.
|
|
67
|
+
* @param { pathway.ListAgentProfilesRequest } req - Typed request message.
|
|
68
|
+
* @returns { Promise<tool.ToolCallResult> } Typed response message.
|
|
69
|
+
*/
|
|
70
|
+
async ListAgentProfiles(req) {
|
|
71
|
+
// Type validation
|
|
72
|
+
if (!(req instanceof pathway.ListAgentProfilesRequest)) {
|
|
73
|
+
throw new TypeError(
|
|
74
|
+
`ListAgentProfiles: Expected parameter to be instanceof pathway.ListAgentProfilesRequest`,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Convert to plain object
|
|
79
|
+
const request = pathway.ListAgentProfilesRequest.toObject(req);
|
|
80
|
+
|
|
81
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
82
|
+
return this.callUnary("ListAgentProfiles", request, (res) => tool.ToolCallResult.fromObject(res));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Call the `DescribeAgentProfile` RPC with request/response type conversion.
|
|
87
|
+
* @param { pathway.DescribeAgentProfileRequest } req - Typed request message.
|
|
88
|
+
* @returns { Promise<tool.ToolCallResult> } Typed response message.
|
|
89
|
+
*/
|
|
90
|
+
async DescribeAgentProfile(req) {
|
|
91
|
+
// Type validation
|
|
92
|
+
if (!(req instanceof pathway.DescribeAgentProfileRequest)) {
|
|
93
|
+
throw new TypeError(
|
|
94
|
+
`DescribeAgentProfile: Expected parameter to be instanceof pathway.DescribeAgentProfileRequest`,
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Convert to plain object
|
|
99
|
+
const request = pathway.DescribeAgentProfileRequest.toObject(req);
|
|
100
|
+
|
|
101
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
102
|
+
return this.callUnary("DescribeAgentProfile", request, (res) => tool.ToolCallResult.fromObject(res));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Call the `DescribeProgression` RPC with request/response type conversion.
|
|
107
|
+
* @param { pathway.DescribeProgressionRequest } req - Typed request message.
|
|
108
|
+
* @returns { Promise<tool.ToolCallResult> } Typed response message.
|
|
109
|
+
*/
|
|
110
|
+
async DescribeProgression(req) {
|
|
111
|
+
// Type validation
|
|
112
|
+
if (!(req instanceof pathway.DescribeProgressionRequest)) {
|
|
113
|
+
throw new TypeError(
|
|
114
|
+
`DescribeProgression: Expected parameter to be instanceof pathway.DescribeProgressionRequest`,
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Convert to plain object
|
|
119
|
+
const request = pathway.DescribeProgressionRequest.toObject(req);
|
|
120
|
+
|
|
121
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
122
|
+
return this.callUnary("DescribeProgression", request, (res) => tool.ToolCallResult.fromObject(res));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Call the `ListJobSoftware` RPC with request/response type conversion.
|
|
127
|
+
* @param { pathway.ListJobSoftwareRequest } req - Typed request message.
|
|
128
|
+
* @returns { Promise<tool.ToolCallResult> } Typed response message.
|
|
129
|
+
*/
|
|
130
|
+
async ListJobSoftware(req) {
|
|
131
|
+
// Type validation
|
|
132
|
+
if (!(req instanceof pathway.ListJobSoftwareRequest)) {
|
|
133
|
+
throw new TypeError(
|
|
134
|
+
`ListJobSoftware: Expected parameter to be instanceof pathway.ListJobSoftwareRequest`,
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Convert to plain object
|
|
139
|
+
const request = pathway.ListJobSoftwareRequest.toObject(req);
|
|
140
|
+
|
|
141
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
142
|
+
return this.callUnary("ListJobSoftware", request, (res) => tool.ToolCallResult.fromObject(res));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Call the `GetMarkersForProfile` RPC with request/response type conversion.
|
|
147
|
+
* @param { pathway.GetMarkersForProfileRequest } req - Typed request message.
|
|
148
|
+
* @returns { Promise<tool.ToolCallResult> } Typed response message.
|
|
149
|
+
*/
|
|
150
|
+
async GetMarkersForProfile(req) {
|
|
151
|
+
// Type validation
|
|
152
|
+
if (!(req instanceof pathway.GetMarkersForProfileRequest)) {
|
|
153
|
+
throw new TypeError(
|
|
154
|
+
`GetMarkersForProfile: Expected parameter to be instanceof pathway.GetMarkersForProfileRequest`,
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Convert to plain object
|
|
159
|
+
const request = pathway.GetMarkersForProfileRequest.toObject(req);
|
|
160
|
+
|
|
161
|
+
// Make gRPC call (tracing handled by base Client class)
|
|
162
|
+
return this.callUnary("GetMarkersForProfile", request, (res) => tool.ToolCallResult.fromObject(res));
|
|
163
|
+
}
|
|
164
|
+
}
|