@forwardimpact/librpc 0.1.109 → 0.1.111

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/README.md CHANGED
@@ -12,3 +12,12 @@ transport.
12
12
  ```js
13
13
  import { Server, Client, createClient, createTracer } from '@forwardimpact/librpc';
14
14
  ```
15
+
16
+ ## Documentation
17
+
18
+ - [Ship a Service Endpoint](https://www.forwardimpact.team/docs/libraries/typed-contracts/ship-endpoint/index.md)
19
+ — ship and consume a gRPC service with typed contracts, authentication,
20
+ retries, and health checks; `fit-unary` is the command-line client for it.
21
+ - [Keep Types Synced with Proto Definitions](https://www.forwardimpact.team/docs/libraries/typed-contracts/index.md)
22
+ — the full workflow for defining proto contracts and generating typed base
23
+ classes and clients.
package/bin/fit-unary.js CHANGED
@@ -18,6 +18,20 @@ const definition = {
18
18
  json: { type: "boolean", description: "Output help as JSON" },
19
19
  },
20
20
  examples: ['fit-unary memory GetWindow \'{"resource_id":"..."}\''],
21
+ documentation: [
22
+ {
23
+ title: "Ship a Service Endpoint",
24
+ url: "https://www.forwardimpact.team/docs/libraries/typed-contracts/ship-endpoint/index.md",
25
+ description:
26
+ "Ship and consume a gRPC service with typed contracts, authentication, retries, and health checks; fit-unary is the command-line client for it.",
27
+ },
28
+ {
29
+ title: "Keep Types Synced with Proto Definitions",
30
+ url: "https://www.forwardimpact.team/docs/libraries/typed-contracts/index.md",
31
+ description:
32
+ "The full workflow for defining proto contracts and generating typed base classes and clients.",
33
+ },
34
+ ],
21
35
  };
22
36
 
23
37
  const cli = createCli(definition, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forwardimpact/librpc",
3
- "version": "0.1.109",
3
+ "version": "0.1.111",
4
4
  "description": "gRPC server and client framework — ship service endpoints without reimplementing transport.",
5
5
  "keywords": [
6
6
  "grpc",
@@ -9,8 +9,8 @@ export { GhuserServiceDefinition } from "./ghuser.js";
9
9
  export { GraphServiceDefinition } from "./graph.js";
10
10
  export { MapServiceDefinition } from "./map.js";
11
11
  export { PathwayServiceDefinition } from "./pathway.js";
12
+ export { SpanServiceDefinition } from "./span.js";
12
13
  export { TenancyServiceDefinition } from "./tenancy.js";
13
- export { TraceServiceDefinition } from "./trace.js";
14
14
  export { VectorServiceDefinition } from "./vector.js";
15
15
 
16
16
  // Import service definitions to make them available for aggregation
@@ -21,8 +21,8 @@ import { GhuserServiceDefinition } from "./ghuser.js";
21
21
  import { GraphServiceDefinition } from "./graph.js";
22
22
  import { MapServiceDefinition } from "./map.js";
23
23
  import { PathwayServiceDefinition } from "./pathway.js";
24
+ import { SpanServiceDefinition } from "./span.js";
24
25
  import { TenancyServiceDefinition } from "./tenancy.js";
25
- import { TraceServiceDefinition } from "./trace.js";
26
26
  import { VectorServiceDefinition } from "./vector.js";
27
27
 
28
28
  // Aggregate exports for convenience
@@ -34,8 +34,8 @@ export const definitions = {
34
34
  graph: GraphServiceDefinition,
35
35
  map: MapServiceDefinition,
36
36
  pathway: PathwayServiceDefinition,
37
+ span: SpanServiceDefinition,
37
38
  tenancy: TenancyServiceDefinition,
38
- trace: TraceServiceDefinition,
39
39
  vector: VectorServiceDefinition,
40
40
  };
41
41
 
@@ -0,0 +1,50 @@
1
+ import { span } from "@forwardimpact/libtype";
2
+
3
+ /**
4
+ * Pre-compiled gRPC service definition for Span
5
+ * Generated at build time
6
+ */
7
+ export const SpanServiceDefinition = {
8
+ RecordSpan: {
9
+ path: '/span.Span/RecordSpan',
10
+ requestStream: false,
11
+ responseStream: false,
12
+ requestSerialize: (value) => {
13
+ return Buffer.from(span.SpanItem.encode(value).finish());
14
+ },
15
+ requestDeserialize: (value) => {
16
+ return span.SpanItem.toObject(
17
+ span.SpanItem.decode(value)
18
+ );
19
+ },
20
+ responseSerialize: (value) => {
21
+ return Buffer.from(span.RecordResponse.encode(value).finish());
22
+ },
23
+ responseDeserialize: (value) => {
24
+ return span.RecordResponse.toObject(
25
+ span.RecordResponse.decode(value)
26
+ );
27
+ },
28
+ },
29
+ QuerySpans: {
30
+ path: '/span.Span/QuerySpans',
31
+ requestStream: false,
32
+ responseStream: false,
33
+ requestSerialize: (value) => {
34
+ return Buffer.from(span.QueryRequest.encode(value).finish());
35
+ },
36
+ requestDeserialize: (value) => {
37
+ return span.QueryRequest.toObject(
38
+ span.QueryRequest.decode(value)
39
+ );
40
+ },
41
+ responseSerialize: (value) => {
42
+ return Buffer.from(span.QueryResponse.encode(value).finish());
43
+ },
44
+ responseDeserialize: (value) => {
45
+ return span.QueryResponse.toObject(
46
+ span.QueryResponse.decode(value)
47
+ );
48
+ },
49
+ },
50
+ };
@@ -9,8 +9,8 @@ export { GhuserBase } from "./ghuser/service.js";
9
9
  export { GraphBase } from "./graph/service.js";
10
10
  export { MapBase } from "./map/service.js";
11
11
  export { PathwayBase } from "./pathway/service.js";
12
+ export { SpanBase } from "./span/service.js";
12
13
  export { TenancyBase } from "./tenancy/service.js";
13
- export { TraceBase } from "./trace/service.js";
14
14
  export { VectorBase } from "./vector/service.js";
15
15
 
16
16
  // Client Classes
@@ -21,8 +21,8 @@ export { GhuserClient } from "./ghuser/client.js";
21
21
  export { GraphClient } from "./graph/client.js";
22
22
  export { MapClient } from "./map/client.js";
23
23
  export { PathwayClient } from "./pathway/client.js";
24
+ export { SpanClient } from "./span/client.js";
24
25
  export { TenancyClient } from "./tenancy/client.js";
25
- export { TraceClient } from "./trace/client.js";
26
26
  export { VectorClient } from "./vector/client.js";
27
27
 
28
28
  // Import service base classes to make them available for aggregation
@@ -33,8 +33,8 @@ import { GhuserBase } from "./ghuser/service.js";
33
33
  import { GraphBase } from "./graph/service.js";
34
34
  import { MapBase } from "./map/service.js";
35
35
  import { PathwayBase } from "./pathway/service.js";
36
+ import { SpanBase } from "./span/service.js";
36
37
  import { TenancyBase } from "./tenancy/service.js";
37
- import { TraceBase } from "./trace/service.js";
38
38
  import { VectorBase } from "./vector/service.js";
39
39
 
40
40
  // Import client classes to make them available for aggregation
@@ -45,8 +45,8 @@ import { GhuserClient } from "./ghuser/client.js";
45
45
  import { GraphClient } from "./graph/client.js";
46
46
  import { MapClient } from "./map/client.js";
47
47
  import { PathwayClient } from "./pathway/client.js";
48
+ import { SpanClient } from "./span/client.js";
48
49
  import { TenancyClient } from "./tenancy/client.js";
49
- import { TraceClient } from "./trace/client.js";
50
50
  import { VectorClient } from "./vector/client.js";
51
51
 
52
52
  // Aggregate exports for convenience
@@ -58,8 +58,8 @@ export const services = {
58
58
  GraphBase,
59
59
  MapBase,
60
60
  PathwayBase,
61
+ SpanBase,
61
62
  TenancyBase,
62
- TraceBase,
63
63
  VectorBase,
64
64
  };
65
65
 
@@ -71,8 +71,8 @@ export const clients = {
71
71
  GraphClient,
72
72
  MapClient,
73
73
  PathwayClient,
74
+ SpanClient,
74
75
  TenancyClient,
75
- TraceClient,
76
76
  VectorClient,
77
77
  };
78
78
 
@@ -87,8 +87,8 @@ export default {
87
87
  GraphBase,
88
88
  MapBase,
89
89
  PathwayBase,
90
+ SpanBase,
90
91
  TenancyBase,
91
- TraceBase,
92
92
  VectorBase,
93
93
  BridgeClient,
94
94
  EmbeddingClient,
@@ -97,7 +97,7 @@ export default {
97
97
  GraphClient,
98
98
  MapClient,
99
99
  PathwayClient,
100
+ SpanClient,
100
101
  TenancyClient,
101
- TraceClient,
102
102
  VectorClient,
103
103
  };
@@ -3,15 +3,15 @@
3
3
  import { Client } from "@forwardimpact/librpc/client.js";
4
4
  import { createAuth, createGrpc } from "@forwardimpact/librpc/base.js";
5
5
  import { createObserver } from "@forwardimpact/libtelemetry";
6
- import { trace } from "@forwardimpact/libtype";
6
+ import { span } from "@forwardimpact/libtype";
7
7
 
8
8
  /**
9
- * Typed client for the Trace gRPC service.
9
+ * Typed client for the Span gRPC service.
10
10
  * Extends the `Client` class for shared gRPC client functionality.
11
11
  */
12
- export class TraceClient extends Client {
12
+ export class SpanClient extends Client {
13
13
  /**
14
- * Creates a new Trace client instance
14
+ * Creates a new Span client instance
15
15
  * @param {object} config - Service configuration
16
16
  * @param {import("@forwardimpact/libutil/runtime").Runtime} runtime - Injected runtime bag (required; the default auth factory reads SERVICE_SECRET from it)
17
17
  * @param {import("@forwardimpact/libtelemetry").Logger} [logger] - Optional logger instance
@@ -24,35 +24,35 @@ export class TraceClient extends Client {
24
24
 
25
25
  /**
26
26
  * Call the `RecordSpan` RPC with request/response type conversion.
27
- * @param { trace.Span } req - Typed request message.
28
- * @returns { Promise<trace.RecordResponse> } Typed response message.
27
+ * @param { span.SpanItem } req - Typed request message.
28
+ * @returns { Promise<span.RecordResponse> } Typed response message.
29
29
  */
30
30
  async RecordSpan(req) {
31
31
  // Accept a typed message or a plain init object (coerced to the typed type).
32
32
  const message =
33
- req instanceof trace.Span
33
+ req instanceof span.SpanItem
34
34
  ? req
35
- : new trace.Span(req);
36
- const request = trace.Span.toObject(message);
35
+ : new span.SpanItem(req);
36
+ const request = span.SpanItem.toObject(message);
37
37
 
38
38
  // Make gRPC call (tracing handled by base Client class)
39
- return this.callUnary("RecordSpan", request, (res) => trace.RecordResponse.fromObject(res));
39
+ return this.callUnary("RecordSpan", request, (res) => span.RecordResponse.fromObject(res));
40
40
  }
41
41
 
42
42
  /**
43
43
  * Call the `QuerySpans` RPC with request/response type conversion.
44
- * @param { trace.QueryRequest } req - Typed request message.
45
- * @returns { Promise<trace.QueryResponse> } Typed response message.
44
+ * @param { span.QueryRequest } req - Typed request message.
45
+ * @returns { Promise<span.QueryResponse> } Typed response message.
46
46
  */
47
47
  async QuerySpans(req) {
48
48
  // Accept a typed message or a plain init object (coerced to the typed type).
49
49
  const message =
50
- req instanceof trace.QueryRequest
50
+ req instanceof span.QueryRequest
51
51
  ? req
52
- : new trace.QueryRequest(req);
53
- const request = trace.QueryRequest.toObject(message);
52
+ : new span.QueryRequest(req);
53
+ const request = span.QueryRequest.toObject(message);
54
54
 
55
55
  // Make gRPC call (tracing handled by base Client class)
56
- return this.callUnary("QuerySpans", request, (res) => trace.QueryResponse.fromObject(res));
56
+ return this.callUnary("QuerySpans", request, (res) => span.QueryResponse.fromObject(res));
57
57
  }
58
58
  }
@@ -1,15 +1,15 @@
1
1
  /* eslint no-unused-vars: "off" */
2
2
 
3
- import { trace } from "@forwardimpact/libtype";
3
+ import { span } from "@forwardimpact/libtype";
4
4
 
5
5
  /**
6
- * Base class for Trace service implementation
6
+ * Base class for Span service implementation
7
7
  */
8
- export class TraceBase {
8
+ export class SpanBase {
9
9
  config;
10
10
 
11
11
  /**
12
- * Creates a new Trace service instance
12
+ * Creates a new Span service instance
13
13
  * @param {object} config - Service configuration
14
14
  */
15
15
  constructor(config) {
@@ -19,8 +19,8 @@ export class TraceBase {
19
19
 
20
20
  /**
21
21
  * Must be implemented by subclass
22
- * @param { trace.Span } req - Request parameters
23
- * @returns { Promise<trace.RecordResponse> } Response object
22
+ * @param { span.SpanItem } req - Request parameters
23
+ * @returns { Promise<span.RecordResponse> } Response object
24
24
  */
25
25
  async RecordSpan(req) {
26
26
  throw new Error("RecordSpan not implemented");
@@ -28,8 +28,8 @@ export class TraceBase {
28
28
 
29
29
  /**
30
30
  * Must be implemented by subclass
31
- * @param { trace.QueryRequest } req - Request parameters
32
- * @returns { Promise<trace.QueryResponse> } Response object
31
+ * @param { span.QueryRequest } req - Request parameters
32
+ * @returns { Promise<span.QueryResponse> } Response object
33
33
  */
34
34
  async QuerySpans(req) {
35
35
  throw new Error("QuerySpans not implemented");
@@ -43,18 +43,18 @@ export class TraceBase {
43
43
  return {
44
44
  RecordSpan: async (call) => {
45
45
  // Validate and convert request
46
- const error = trace.Span.verify(call.request);
46
+ const error = span.SpanItem.verify(call.request);
47
47
  if (error) throw new Error(`RecordSpan: ${error}`);
48
- const req = trace.Span.fromObject(call.request);
48
+ const req = span.SpanItem.fromObject(call.request);
49
49
 
50
50
  // Call implementation
51
51
  return await this.RecordSpan(req);
52
52
  },
53
53
  QuerySpans: async (call) => {
54
54
  // Validate and convert request
55
- const error = trace.QueryRequest.verify(call.request);
55
+ const error = span.QueryRequest.verify(call.request);
56
56
  if (error) throw new Error(`QuerySpans: ${error}`);
57
- const req = trace.QueryRequest.fromObject(call.request);
57
+ const req = span.QueryRequest.fromObject(call.request);
58
58
 
59
59
  // Call implementation
60
60
  return await this.QuerySpans(req);