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