@forwardimpact/librpc 0.1.110 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forwardimpact/librpc",
3
- "version": "0.1.110",
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);
@@ -755,28 +755,23 @@ export const metadata = {
755
755
  }
756
756
  }
757
757
  },
758
- "tenancy.Tenancy": {
759
- "ResolveByChannelKey": {
760
- "requestType": "tenancy.ChannelTenantKey",
758
+ "span.Span": {
759
+ "RecordSpan": {
760
+ "requestType": "span.SpanItem",
761
761
  "fields": {
762
- "channel": {
762
+ "trace_id": {
763
763
  "type": "string",
764
764
  "optional": false,
765
765
  "repeated": false,
766
766
  "description": null
767
767
  },
768
- "key": {
768
+ "span_id": {
769
769
  "type": "string",
770
770
  "optional": false,
771
771
  "repeated": false,
772
772
  "description": null
773
- }
774
- }
775
- },
776
- "ResolveByRepo": {
777
- "requestType": "tenancy.RepoKey",
778
- "fields": {
779
- "owner": {
773
+ },
774
+ "parent_span_id": {
780
775
  "type": "string",
781
776
  "optional": false,
782
777
  "repeated": false,
@@ -787,185 +782,190 @@ export const metadata = {
787
782
  "optional": false,
788
783
  "repeated": false,
789
784
  "description": null
790
- }
791
- }
792
- },
793
- "ResolveByTenantId": {
794
- "requestType": "tenancy.TenantIdKey",
795
- "fields": {
796
- "tenant_id": {
797
- "type": "string",
785
+ },
786
+ "kind": {
787
+ "type": "message",
798
788
  "optional": false,
799
789
  "repeated": false,
800
790
  "description": null
801
- }
802
- }
803
- },
804
- "UpsertByChannelKey": {
805
- "requestType": "tenancy.UpsertChannelKeyRequest",
806
- "fields": {
807
- "channel": {
808
- "type": "string",
791
+ },
792
+ "start_time_unix_nano": {
793
+ "type": "int64",
809
794
  "optional": false,
810
795
  "repeated": false,
811
796
  "description": null
812
797
  },
813
- "channel_tenant_key": {
814
- "type": "string",
798
+ "end_time_unix_nano": {
799
+ "type": "int64",
815
800
  "optional": false,
816
801
  "repeated": false,
817
802
  "description": null
818
803
  },
819
- "state": {
804
+ "attributes": {
820
805
  "type": "string",
821
806
  "optional": false,
822
807
  "repeated": false,
823
808
  "description": null
824
- }
825
- }
826
- },
827
- "UpsertByPair": {
828
- "requestType": "tenancy.UpsertPairRequest",
829
- "fields": {
830
- "installation_id": {
831
- "type": "string",
809
+ },
810
+ "events": {
811
+ "type": "message",
832
812
  "optional": false,
833
- "repeated": false,
813
+ "repeated": true,
834
814
  "description": null
835
815
  },
836
- "owner": {
837
- "type": "string",
816
+ "status": {
817
+ "type": "message",
838
818
  "optional": false,
839
819
  "repeated": false,
840
820
  "description": null
841
821
  },
842
- "name": {
843
- "type": "string",
822
+ "resource": {
823
+ "type": "message",
844
824
  "optional": false,
845
825
  "repeated": false,
846
826
  "description": null
847
827
  }
848
828
  }
849
829
  },
850
- "SetState": {
851
- "requestType": "tenancy.SetStateRequest",
830
+ "QuerySpans": {
831
+ "requestType": "span.QueryRequest",
852
832
  "fields": {
853
- "tenant_id": {
833
+ "query": {
854
834
  "type": "string",
855
- "optional": false,
835
+ "optional": true,
856
836
  "repeated": false,
857
837
  "description": null
858
838
  },
859
- "state": {
860
- "type": "string",
861
- "optional": false,
839
+ "filter": {
840
+ "type": "message",
841
+ "optional": true,
862
842
  "repeated": false,
863
843
  "description": null
864
844
  }
865
845
  }
866
- },
867
- "SetRepo": {
868
- "requestType": "tenancy.SetRepoRequest",
846
+ }
847
+ },
848
+ "tenancy.Tenancy": {
849
+ "ResolveByChannelKey": {
850
+ "requestType": "tenancy.ChannelTenantKey",
869
851
  "fields": {
870
- "tenant_id": {
852
+ "channel": {
871
853
  "type": "string",
872
854
  "optional": false,
873
855
  "repeated": false,
874
856
  "description": null
875
857
  },
876
- "repo": {
877
- "type": "message",
858
+ "key": {
859
+ "type": "string",
878
860
  "optional": false,
879
861
  "repeated": false,
880
862
  "description": null
881
863
  }
882
864
  }
883
- }
884
- },
885
- "trace.Trace": {
886
- "RecordSpan": {
887
- "requestType": "trace.Span",
865
+ },
866
+ "ResolveByRepo": {
867
+ "requestType": "tenancy.RepoKey",
888
868
  "fields": {
889
- "trace_id": {
869
+ "owner": {
890
870
  "type": "string",
891
871
  "optional": false,
892
872
  "repeated": false,
893
873
  "description": null
894
874
  },
895
- "span_id": {
875
+ "name": {
896
876
  "type": "string",
897
877
  "optional": false,
898
878
  "repeated": false,
899
879
  "description": null
900
- },
901
- "parent_span_id": {
880
+ }
881
+ }
882
+ },
883
+ "ResolveByTenantId": {
884
+ "requestType": "tenancy.TenantIdKey",
885
+ "fields": {
886
+ "tenant_id": {
902
887
  "type": "string",
903
888
  "optional": false,
904
889
  "repeated": false,
905
890
  "description": null
906
- },
907
- "name": {
891
+ }
892
+ }
893
+ },
894
+ "UpsertByChannelKey": {
895
+ "requestType": "tenancy.UpsertChannelKeyRequest",
896
+ "fields": {
897
+ "channel": {
908
898
  "type": "string",
909
899
  "optional": false,
910
900
  "repeated": false,
911
901
  "description": null
912
902
  },
913
- "kind": {
914
- "type": "message",
903
+ "channel_tenant_key": {
904
+ "type": "string",
915
905
  "optional": false,
916
906
  "repeated": false,
917
907
  "description": null
918
908
  },
919
- "start_time_unix_nano": {
920
- "type": "int64",
909
+ "state": {
910
+ "type": "string",
921
911
  "optional": false,
922
912
  "repeated": false,
923
913
  "description": null
924
- },
925
- "end_time_unix_nano": {
926
- "type": "int64",
914
+ }
915
+ }
916
+ },
917
+ "UpsertByPair": {
918
+ "requestType": "tenancy.UpsertPairRequest",
919
+ "fields": {
920
+ "installation_id": {
921
+ "type": "string",
927
922
  "optional": false,
928
923
  "repeated": false,
929
924
  "description": null
930
925
  },
931
- "attributes": {
926
+ "owner": {
932
927
  "type": "string",
933
928
  "optional": false,
934
929
  "repeated": false,
935
930
  "description": null
936
931
  },
937
- "events": {
938
- "type": "message",
932
+ "name": {
933
+ "type": "string",
939
934
  "optional": false,
940
- "repeated": true,
935
+ "repeated": false,
941
936
  "description": null
942
- },
943
- "status": {
944
- "type": "message",
937
+ }
938
+ }
939
+ },
940
+ "SetState": {
941
+ "requestType": "tenancy.SetStateRequest",
942
+ "fields": {
943
+ "tenant_id": {
944
+ "type": "string",
945
945
  "optional": false,
946
946
  "repeated": false,
947
947
  "description": null
948
948
  },
949
- "resource": {
950
- "type": "message",
949
+ "state": {
950
+ "type": "string",
951
951
  "optional": false,
952
952
  "repeated": false,
953
953
  "description": null
954
954
  }
955
955
  }
956
956
  },
957
- "QuerySpans": {
958
- "requestType": "trace.QueryRequest",
957
+ "SetRepo": {
958
+ "requestType": "tenancy.SetRepoRequest",
959
959
  "fields": {
960
- "query": {
960
+ "tenant_id": {
961
961
  "type": "string",
962
- "optional": true,
962
+ "optional": false,
963
963
  "repeated": false,
964
964
  "description": null
965
965
  },
966
- "filter": {
966
+ "repo": {
967
967
  "type": "message",
968
- "optional": true,
968
+ "optional": false,
969
969
  "repeated": false,
970
970
  "description": null
971
971
  }