@otonoma/paranet-client 2.11.0-rc.18

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 (75) hide show
  1. package/README.md +2 -0
  2. package/dist/client.d.ts +168 -0
  3. package/dist/client.d.ts.map +1 -0
  4. package/dist/client.js +497 -0
  5. package/dist/graphql.d.ts +8 -0
  6. package/dist/graphql.d.ts.map +1 -0
  7. package/dist/graphql.js +113 -0
  8. package/dist/index.d.ts +12 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +11 -0
  11. package/dist/pncp.d.ts +129 -0
  12. package/dist/pncp.d.ts.map +1 -0
  13. package/dist/pncp.js +100 -0
  14. package/dist/proto/broker.grpc.client.d.ts +154 -0
  15. package/dist/proto/broker.grpc.client.d.ts.map +1 -0
  16. package/dist/proto/broker.grpc.client.js +102 -0
  17. package/dist/proto/broker.grpc.d.ts +6 -0
  18. package/dist/proto/broker.grpc.d.ts.map +1 -0
  19. package/dist/proto/broker.grpc.js +32 -0
  20. package/dist/proto/broker_api.d.ts +324 -0
  21. package/dist/proto/broker_api.d.ts.map +1 -0
  22. package/dist/proto/broker_api.js +566 -0
  23. package/dist/proto/google/protobuf/descriptor.d.ts +2492 -0
  24. package/dist/proto/google/protobuf/descriptor.d.ts.map +1 -0
  25. package/dist/proto/google/protobuf/descriptor.js +3250 -0
  26. package/dist/proto/google/protobuf/timestamp.d.ts +157 -0
  27. package/dist/proto/google/protobuf/timestamp.d.ts.map +1 -0
  28. package/dist/proto/google/protobuf/timestamp.js +132 -0
  29. package/dist/proto/grpc/health/v1/health.client.d.ts +79 -0
  30. package/dist/proto/grpc/health/v1/health.client.d.ts.map +1 -0
  31. package/dist/proto/grpc/health/v1/health.client.js +46 -0
  32. package/dist/proto/grpc/health/v1/health.d.ts +74 -0
  33. package/dist/proto/grpc/health/v1/health.d.ts.map +1 -0
  34. package/dist/proto/grpc/health/v1/health.js +152 -0
  35. package/dist/proto/identifiers.d.ts +82 -0
  36. package/dist/proto/identifiers.d.ts.map +1 -0
  37. package/dist/proto/identifiers.js +132 -0
  38. package/dist/proto/mediums.d.ts +71 -0
  39. package/dist/proto/mediums.d.ts.map +1 -0
  40. package/dist/proto/mediums.js +120 -0
  41. package/dist/proto/observation.d.ts +287 -0
  42. package/dist/proto/observation.d.ts.map +1 -0
  43. package/dist/proto/observation.js +443 -0
  44. package/dist/proto/otonoma/common/value.d.ts +127 -0
  45. package/dist/proto/otonoma/common/value.d.ts.map +1 -0
  46. package/dist/proto/otonoma/common/value.js +248 -0
  47. package/dist/proto/pncp.d.ts +607 -0
  48. package/dist/proto/pncp.d.ts.map +1 -0
  49. package/dist/proto/pncp.js +936 -0
  50. package/dist/schema/paranet.d.ts +245 -0
  51. package/dist/schema/paranet.d.ts.map +1 -0
  52. package/dist/schema/paranet.js +7 -0
  53. package/dist/util.d.ts +5 -0
  54. package/dist/util.d.ts.map +1 -0
  55. package/dist/util.js +120 -0
  56. package/package.json +39 -0
  57. package/src/client.ts +677 -0
  58. package/src/graphql.ts +103 -0
  59. package/src/index.ts +14 -0
  60. package/src/pncp.ts +236 -0
  61. package/src/proto/broker.grpc.client.ts +193 -0
  62. package/src/proto/broker.grpc.ts +32 -0
  63. package/src/proto/broker_api.ts +778 -0
  64. package/src/proto/google/protobuf/descriptor.ts +4860 -0
  65. package/src/proto/google/protobuf/timestamp.ts +288 -0
  66. package/src/proto/grpc/health/v1/health.client.ts +106 -0
  67. package/src/proto/grpc/health/v1/health.ts +174 -0
  68. package/src/proto/identifiers.ts +176 -0
  69. package/src/proto/mediums.ts +168 -0
  70. package/src/proto/observation.ts +636 -0
  71. package/src/proto/otonoma/common/value.ts +334 -0
  72. package/src/proto/pncp.ts +1333 -0
  73. package/src/schema/paranet.ts +257 -0
  74. package/src/util.ts +129 -0
  75. package/tsconfig.json +27 -0
package/src/graphql.ts ADDED
@@ -0,0 +1,103 @@
1
+ import { PncpMessageBody, PncpMessageObject, PncpRequestObject, PncpPacketObject } from "./pncp";
2
+ import * as schema from "./schema/paranet";
3
+ import * as proto from "./proto/pncp";
4
+ import { ConversationId, ConversationMembership } from "./proto/identifiers";
5
+
6
+ export function gqlSimplifyPncpPacket(req: schema.PncpPacket): PncpPacketObject {
7
+ switch (req.type) {
8
+ case "request": return { type: "request", body: gqlSimplifyPncpRequest(req.body) };
9
+ case "message": return { type: "message", body: gqlSimplifyPncpMessage(req.body) };
10
+ }
11
+ }
12
+
13
+ // Provide conversions from graphql returned objects into the equivalent pncp objects.
14
+ export function gqlSimplifyPncpRequest(req: schema.PncpRequest): PncpRequestObject {
15
+ return {
16
+ body: {
17
+ subject: req.body.subject,
18
+ action: req.body.action,
19
+ body: req.body.body,
20
+ },
21
+ key: req.key,
22
+ author: req.author,
23
+ callback: req.callback,
24
+ parentId: req.parentId ? req.parentId : undefined,
25
+ mediumInfo: req.mediumInfo ? { id: req.mediumInfo.id, userInfo: req.mediumInfo.userInfo } : undefined,
26
+ versionReq: req.versionReq ? req.versionReq : undefined,
27
+ matchStrategy: req.matchStrategy ? simplifyMatchStrategy(req.matchStrategy) : proto.SkillMatchStrategy.BEST,
28
+ };
29
+ }
30
+
31
+ function simplifyMatchStrategy(matchStrategy: schema.SkillMatchStrategy): proto.SkillMatchStrategy {
32
+ switch (matchStrategy) {
33
+ case "BEST": return proto.SkillMatchStrategy.BEST;
34
+ case "FIRST": return proto.SkillMatchStrategy.FIRST;
35
+ case "STRICT": return proto.SkillMatchStrategy.STRICT;
36
+ }
37
+ }
38
+
39
+ export function gqlSimplifyPncpMessage(req: schema.PncpMessage): PncpMessageObject {
40
+ let body: PncpMessageBody;
41
+ let b = req.message.body;
42
+ switch (req.message.type) {
43
+ case "response": body = { type: proto.PncpMessageKind.PNCP_RESPONSE, value: { data: b.data } }; break;
44
+ case "error": body = { type: proto.PncpMessageKind.PNCP_ERROR, value: { data: b.data } }; break;
45
+ case "status": body = { type: proto.PncpMessageKind.PNCP_STATUS, value: { data: b.data } }; break;
46
+ case "cancel": body = { type: proto.PncpMessageKind.PNCP_CANCEL, value: { data: b.data } }; break;
47
+ case "answer": body = { type: proto.PncpMessageKind.PNCP_ANSWER, value: { data: b.data, reply_to: b.replyTo } }; break;
48
+ case "question": body = { type: proto.PncpMessageKind.PNCP_QUESTION, value: { data: b.data, id: b.id, callback: b.callback } }; break;
49
+ }
50
+ return {
51
+ id: splitConversationId(req.id),
52
+ body,
53
+ };
54
+ }
55
+
56
+ export function splitConversationId(convId: string): ConversationId {
57
+ let [id, tag] = convId.split('@');
58
+ let membership: ConversationMembership = ConversationMembership.REQUESTER;
59
+ switch (tag) {
60
+ case "requester": membership = ConversationMembership.REQUESTER; break;
61
+ case "fulfiller": membership = ConversationMembership.FULFILLER; break;
62
+ case "observer": membership = ConversationMembership.OBSERVER; break;
63
+ default: throw new Error("Unexpected conversation tag: " + tag);
64
+ }
65
+
66
+ return { id, membership };
67
+ }
68
+ /*
69
+ // Simple constructors for a graphql client to the service to auto manage login and such.
70
+
71
+ // import { HttpLink, ApolloLink, ApolloClient, gql } from "@apollo/client";
72
+ // import { setContext } from "@apollo/client/link/context";
73
+ // import { PncpClient } from "./client";
74
+
75
+ // Creates an `ApolloLink` which can connect to the paranet with appropriate authentication.
76
+ // export function createParanetApolloLink(cl: PncpClient): ApolloLink {
77
+ // const paranetServiceLink = new HttpLink({
78
+ // uri: `${cl.serviceEndpoint()}/graphql`,
79
+ // });
80
+ //
81
+ // const authLink = setContext(async (_, { headers }) => {
82
+ // if (!cl.hasTokens()) {
83
+ // return {
84
+ // headers,
85
+ // };
86
+ // }
87
+ // if (!cl.isTokenValid()) {
88
+ // console.log("GQL LINK: ATTEMPTING TOKEN REFRESH");
89
+ // await cl.refreshAuth();
90
+ // }
91
+ // let { token } = cl.getTokens();
92
+ // return {
93
+ // headers: {
94
+ // ...headers,
95
+ // Authorization: token ? `Bearer ${token}` : "",
96
+ // },
97
+ // };
98
+ // });
99
+ //
100
+ // return authLink.concat(paranetServiceLink);
101
+ // }
102
+
103
+ */
package/src/index.ts ADDED
@@ -0,0 +1,14 @@
1
+ export * from "./client";
2
+ export * from "./graphql";
3
+
4
+ export * from './proto/pncp';
5
+ export * from './proto/otonoma/common/value';
6
+ export * from './proto/google/protobuf/timestamp';
7
+ export * from './proto/identifiers';
8
+ export * from './proto/mediums';
9
+ export * from './proto/broker_api';
10
+ export * from './proto/observation';
11
+
12
+ export * from './util';
13
+
14
+ export * from './pncp';
package/src/pncp.ts ADDED
@@ -0,0 +1,236 @@
1
+ import { Timestamp } from "./proto/google/protobuf/timestamp";
2
+ import { Value } from "./proto/otonoma/common/value";
3
+ import { ConversationId, EntityId } from "./proto/identifiers";
4
+ import { ObservationCallback } from "./proto/observation";
5
+ import { ConversationState, PncpCallback, PncpMessage, PncpMessageCallback, PncpMessageKind, PncpRequestCallback, SkillMatchStrategy } from "./proto/pncp";
6
+
7
+ // Type exports for working with PNCP request data in more typescript/javascript friendly ways.
8
+ export interface SkillRequest {
9
+ actorVersion?: string;
10
+ subject: string;
11
+ action: string;
12
+ body: any;
13
+ versionReq?: string;
14
+ callback?: any;
15
+ parentConversationId?: ConversationId;
16
+ targetId?: string;
17
+ matchStrategy?: SkillMatchStrategy;
18
+ mustMatch?: boolean;
19
+ useLock?: boolean;
20
+ allowOpenMatch?: boolean;
21
+ }
22
+
23
+ // Useful for reading data out of the ledger.
24
+ export type PncpPacketObject = {
25
+ type: "request",
26
+ body: PncpRequestObject,
27
+ } | {
28
+ type: "message",
29
+ body: PncpMessageObject,
30
+ };
31
+
32
+ export type PncpRequestObject = {
33
+ body: PncpSkillMessageObject;
34
+ callback?: any;
35
+ parentId?: string;
36
+ author: string;
37
+ matchStrategy: SkillMatchStrategy;
38
+ versionReq?: string;
39
+ targetActorId?: string;
40
+ key?: any;
41
+ targetInstanceId?: string;
42
+ mediumInfo?: PncpRequestMediumInfoObject;
43
+ };
44
+
45
+ export type PncpRequestMediumInfoObject = {
46
+ id: string;
47
+ userInfo: any;
48
+ };
49
+
50
+ export type PncpSkillMessageObject = {
51
+ subject: string;
52
+ action: string;
53
+ body: any;
54
+ };
55
+
56
+ export interface MessageRequest {
57
+ conversation: string;
58
+ message: PncpMessageBody;
59
+ }
60
+
61
+ export interface PncpDataMessage {
62
+ data: any;
63
+ }
64
+
65
+ export interface PncpQuestionMessage {
66
+ id: string;
67
+ data: any;
68
+ callback?: any;
69
+ }
70
+
71
+ export interface PncpAnswerMessage {
72
+ reply_to: string;
73
+ data: any;
74
+ }
75
+
76
+ export type PncpMessageBody =
77
+ | { type: typeof PncpMessageKind.PNCP_RESPONSE; value: PncpDataMessage }
78
+ | { type: typeof PncpMessageKind.PNCP_STATUS; value: PncpDataMessage }
79
+ | { type: typeof PncpMessageKind.PNCP_CANCEL; value: PncpDataMessage }
80
+ | { type: typeof PncpMessageKind.PNCP_ERROR; value: PncpDataMessage }
81
+ | { type: typeof PncpMessageKind.PNCP_QUESTION; value: PncpQuestionMessage }
82
+ | { type: typeof PncpMessageKind.PNCP_ANSWER; value: PncpAnswerMessage };
83
+
84
+
85
+ export type PncpCallbackObject = PncpRequestCallbackObject | PncpMessageCallbackObject;
86
+
87
+ export type PncpRequestCallbackObject = {
88
+ type: "skill";
89
+ id: ConversationId;
90
+ messageId: string;
91
+ parentId?: ConversationId;
92
+ body: PncpSkillMessageObject;
93
+ timeCreated: Date;
94
+ authorId: EntityId;
95
+ targetActorId: EntityId;
96
+ parameters: {
97
+ provider?: any;
98
+ skill?: any;
99
+ medium?: any;
100
+ }
101
+ };
102
+
103
+ export type PncpMessageCallbackObject = {
104
+ type: "message";
105
+ id: ConversationId;
106
+ messageId: string;
107
+ timeCreated: Date;
108
+ key?: any;
109
+ message: PncpMessageObject;
110
+ params?: any;
111
+ callback?: any;
112
+ medium?: any;
113
+ conversationState: ConversationState;
114
+ };
115
+
116
+ export type PncpMessageObject = {
117
+ id: ConversationId;
118
+ body: PncpMessageBody;
119
+ };
120
+
121
+
122
+ export function simplifyPncpCallback(cb: PncpCallback): PncpCallbackObject {
123
+ switch (cb.body.oneofKind) {
124
+ case "skill": return simplifyPncpRequestCallback(cb.body.skill);
125
+ case "message": return simplifyPncpMessageCallback(cb.body.message);
126
+ default: throw Error("Unreachable");
127
+ }
128
+ }
129
+
130
+ export function simplifyPncpRequestCallback(cb: PncpRequestCallback): PncpRequestCallbackObject {
131
+ return {
132
+ type: "skill",
133
+ id: cb.id!,
134
+ messageId: cb.messageId,
135
+ parentId: cb.parentId,
136
+ body: {
137
+ subject: cb.body!.subject,
138
+ action: cb.body!.action,
139
+ body: Value.toJson(cb.body!.body!),
140
+ },
141
+ authorId: cb.authorId!,
142
+ timeCreated: Timestamp.toDate(cb.timeCreated!),
143
+ targetActorId: cb.targetActorId!,
144
+ parameters: {
145
+ provider: cb.parameters?.provider && Value.toJson(cb.parameters.provider),
146
+ skill: cb.parameters?.skill && Value.toJson(cb.parameters.skill),
147
+ medium: cb.parameters?.medium && Value.toJson(cb.parameters.medium),
148
+ },
149
+ };
150
+ }
151
+
152
+ export function simplifyPncpMessageCallback(cb: PncpMessageCallback): PncpMessageCallbackObject {
153
+ return {
154
+ type: "message",
155
+ id: cb.id!,
156
+ messageId: cb.messageId,
157
+ timeCreated: Timestamp.toDate(cb.timeCreated!),
158
+ key: cb.key && Value.toJson(cb.key),
159
+ message: simplifyPncpMessage(cb.message!),
160
+ params: cb.params && Value.toJson(cb.params),
161
+ callback: cb.callback && Value.toJson(cb.callback),
162
+ medium: cb.medium && Value.toJson(cb.medium),
163
+ conversationState: cb.conversationState,
164
+ };
165
+ }
166
+
167
+ export function simplifyPncpMessage(msg: PncpMessage): PncpMessageObject {
168
+ let body: PncpMessageBody;
169
+ switch (msg.kind) {
170
+ case PncpMessageKind.PNCP_CANCEL:
171
+ case PncpMessageKind.PNCP_STATUS:
172
+ case PncpMessageKind.PNCP_ERROR:
173
+ case PncpMessageKind.PNCP_RESPONSE: {
174
+ body = {
175
+ type: msg.kind, value: { data: Value.toJson(msg.body!) }
176
+ };
177
+ break;
178
+ }
179
+ case PncpMessageKind.PNCP_QUESTION: {
180
+ let extra = msg.extra;
181
+ if (extra.oneofKind != "question") throw Error("Invalid PNCP");
182
+ body = {
183
+ type: msg.kind,
184
+ value: {
185
+ data: Value.toJson(msg.body!),
186
+ id: extra.question.id,
187
+ callback: extra.question.callback && Value.toJson(extra.question.callback)
188
+ }
189
+ };
190
+ break;
191
+ }
192
+ case PncpMessageKind.PNCP_ANSWER: {
193
+ let extra = msg.extra;
194
+ if (extra.oneofKind != "answer") throw Error("Invalid PNCP");
195
+ body = {
196
+ type: msg.kind,
197
+ value: {
198
+ data: Value.toJson(msg.body!),
199
+ reply_to: extra.answer.replyTo,
200
+ },
201
+ };
202
+ break;
203
+ }
204
+ }
205
+
206
+ return { id: msg.id!, body };
207
+ }
208
+
209
+
210
+
211
+
212
+ export type ObservationCallbackObject = {
213
+ subject: string;
214
+ action: string;
215
+ requester: EntityId;
216
+ fulfiller: EntityId;
217
+ message: PncpCallbackObject;
218
+ id: ConversationId;
219
+ callback?: any;
220
+ prevMid?: string;
221
+ skillId: EntityId;
222
+ };
223
+
224
+ export function simplifyObservationCallback(cb: ObservationCallback): ObservationCallbackObject {
225
+ return {
226
+ subject: cb.subject,
227
+ action: cb.action,
228
+ requester: cb.requester!,
229
+ fulfiller: cb.fulfiller!,
230
+ message: simplifyPncpCallback(cb.message!),
231
+ id: cb.id!,
232
+ callback: cb.callback && Value.toJson(cb.callback),
233
+ prevMid: cb.prevMid,
234
+ skillId: cb.skillId!,
235
+ };
236
+ }
@@ -0,0 +1,193 @@
1
+ // @generated by protobuf-ts 2.9.4
2
+ // @generated from protobuf file "broker.grpc.proto" (package "pncp.v1", syntax proto3)
3
+ // tslint:disable
4
+ import type { RpcTransport } from "@protobuf-ts/runtime-rpc";
5
+ import type { ServiceInfo } from "@protobuf-ts/runtime-rpc";
6
+ import { Broker } from "./broker.grpc";
7
+ import type { PncpMediumMessage } from "./mediums";
8
+ import type { RefreshTokenRequest } from "./broker_api";
9
+ import type { LoginResponse } from "./broker_api";
10
+ import type { LoginRequest } from "./broker_api";
11
+ import type { CrossDomainStreamMessage } from "./broker_api";
12
+ import type { DuplexStreamingCall } from "@protobuf-ts/runtime-rpc";
13
+ import type { CrossDomainResponse } from "./broker_api";
14
+ import type { CrossDomainMessage } from "./broker_api";
15
+ import type { ObservationMessageWrapper } from "./observation";
16
+ import type { ObservationRequest } from "./observation";
17
+ import type { PncpCallback } from "./pncp";
18
+ import type { PncpCallbackRequest } from "./broker_api";
19
+ import type { ServerStreamingCall } from "@protobuf-ts/runtime-rpc";
20
+ import type { PncpMessage } from "./pncp";
21
+ import { stackIntercept } from "@protobuf-ts/runtime-rpc";
22
+ import type { MessageResponse } from "./broker_api";
23
+ import type { PncpRequest } from "./pncp";
24
+ import type { UnaryCall } from "@protobuf-ts/runtime-rpc";
25
+ import type { RpcOptions } from "@protobuf-ts/runtime-rpc";
26
+ // NOTE (JAB, 2024-06-11): Some protobuf compilers (notably, protoc) don't like it when your rpc and
27
+ // messages have the same name. We ran into this with rpc PncpMessageRequest being originally named
28
+ // PncpMessage. This produces a cryptic error message like:
29
+ // broker.grpc.proto:22:19: "PncpMessage" is not a message type.
30
+
31
+ /**
32
+ * @generated from protobuf service pncp.v1.Broker
33
+ */
34
+ export interface IBrokerClient {
35
+ /**
36
+ * A skill request initiates a conversation between the requesting actor and the corresponding matched
37
+ * actor. Any further messages within the conversation are sent via PncpMessage.
38
+ * Messages are forwarded to actors depending on the actor configuration, but the majority of actors
39
+ * will receive their messages as a callback on `PncpCallbackStream`.
40
+ *
41
+ * @generated from protobuf rpc: SkillRequest(pncp.v1.PncpRequest) returns (pncp.v1.MessageResponse);
42
+ */
43
+ skillRequest(input: PncpRequest, options?: RpcOptions): UnaryCall<PncpRequest, MessageResponse>;
44
+ /**
45
+ * Follow up messages within a conversation are sent with via this endpoint.
46
+ *
47
+ * @generated from protobuf rpc: PncpMessageRequest(pncp.v1.PncpMessage) returns (pncp.v1.MessageResponse);
48
+ */
49
+ pncpMessageRequest(input: PncpMessage, options?: RpcOptions): UnaryCall<PncpMessage, MessageResponse>;
50
+ /**
51
+ * The callback stream for an actor to receive all Pncp type messages. This includes skill requests
52
+ * and all additional Pncp messages sent in the conversation thread.
53
+ *
54
+ * @generated from protobuf rpc: PncpCallbackStream(pncp.v1.PncpCallbackRequest) returns (stream pncp.v1.PncpCallback);
55
+ */
56
+ pncpCallbackStream(input: PncpCallbackRequest, options?: RpcOptions): ServerStreamingCall<PncpCallbackRequest, PncpCallback>;
57
+ /**
58
+ * Creates a new observation stream.
59
+ *
60
+ * @generated from protobuf rpc: CreateObserverStream(pncp.v1.ObservationRequest) returns (stream pncp.v1.ObservationMessageWrapper);
61
+ */
62
+ createObserverStream(input: ObservationRequest, options?: RpcOptions): ServerStreamingCall<ObservationRequest, ObservationMessageWrapper>;
63
+ /**
64
+ * A direct cross domain request, posted from one node to another. The other node is often expected to post
65
+ * the results back.
66
+ *
67
+ * @generated from protobuf rpc: CrossDomainRequest(pncp.v1.CrossDomainMessage) returns (pncp.v1.CrossDomainResponse);
68
+ */
69
+ crossDomainRequest(input: CrossDomainMessage, options?: RpcOptions): UnaryCall<CrossDomainMessage, CrossDomainResponse>;
70
+ /**
71
+ * Inverted API for an edge node to connect to another node. It creates this stream so that the node it
72
+ * connects to can stream messages back to the edge node. The edge node is then required to stream
73
+ * `MessageResponse` to each incoming message back to the connected node.
74
+ *
75
+ * @generated from protobuf rpc: CrossDomainStream(stream pncp.v1.CrossDomainResponse) returns (stream pncp.v1.CrossDomainStreamMessage);
76
+ */
77
+ crossDomainStream(options?: RpcOptions): DuplexStreamingCall<CrossDomainResponse, CrossDomainStreamMessage>;
78
+ /**
79
+ * @generated from protobuf rpc: Login(pncp.v1.LoginRequest) returns (pncp.v1.LoginResponse);
80
+ */
81
+ login(input: LoginRequest, options?: RpcOptions): UnaryCall<LoginRequest, LoginResponse>;
82
+ /**
83
+ * @generated from protobuf rpc: RefreshToken(pncp.v1.RefreshTokenRequest) returns (pncp.v1.LoginResponse);
84
+ */
85
+ refreshToken(input: RefreshTokenRequest, options?: RpcOptions): UnaryCall<RefreshTokenRequest, LoginResponse>;
86
+ /**
87
+ * A PNCP message received from a medium. Note, that we are likely to rework mediums.
88
+ * Given currently limitations with mediums this route is left unauthenticated.
89
+ *
90
+ * @generated from protobuf rpc: PncpMediumMessageRequest(pncp.v1.PncpMediumMessage) returns (pncp.v1.MessageResponse);
91
+ */
92
+ pncpMediumMessageRequest(input: PncpMediumMessage, options?: RpcOptions): UnaryCall<PncpMediumMessage, MessageResponse>;
93
+ }
94
+ // NOTE (JAB, 2024-06-11): Some protobuf compilers (notably, protoc) don't like it when your rpc and
95
+ // messages have the same name. We ran into this with rpc PncpMessageRequest being originally named
96
+ // PncpMessage. This produces a cryptic error message like:
97
+ // broker.grpc.proto:22:19: "PncpMessage" is not a message type.
98
+
99
+ /**
100
+ * @generated from protobuf service pncp.v1.Broker
101
+ */
102
+ export class BrokerClient implements IBrokerClient, ServiceInfo {
103
+ typeName = Broker.typeName;
104
+ methods = Broker.methods;
105
+ options = Broker.options;
106
+ constructor(private readonly _transport: RpcTransport) {
107
+ }
108
+ /**
109
+ * A skill request initiates a conversation between the requesting actor and the corresponding matched
110
+ * actor. Any further messages within the conversation are sent via PncpMessage.
111
+ * Messages are forwarded to actors depending on the actor configuration, but the majority of actors
112
+ * will receive their messages as a callback on `PncpCallbackStream`.
113
+ *
114
+ * @generated from protobuf rpc: SkillRequest(pncp.v1.PncpRequest) returns (pncp.v1.MessageResponse);
115
+ */
116
+ skillRequest(input: PncpRequest, options?: RpcOptions): UnaryCall<PncpRequest, MessageResponse> {
117
+ const method = this.methods[0], opt = this._transport.mergeOptions(options);
118
+ return stackIntercept<PncpRequest, MessageResponse>("unary", this._transport, method, opt, input);
119
+ }
120
+ /**
121
+ * Follow up messages within a conversation are sent with via this endpoint.
122
+ *
123
+ * @generated from protobuf rpc: PncpMessageRequest(pncp.v1.PncpMessage) returns (pncp.v1.MessageResponse);
124
+ */
125
+ pncpMessageRequest(input: PncpMessage, options?: RpcOptions): UnaryCall<PncpMessage, MessageResponse> {
126
+ const method = this.methods[1], opt = this._transport.mergeOptions(options);
127
+ return stackIntercept<PncpMessage, MessageResponse>("unary", this._transport, method, opt, input);
128
+ }
129
+ /**
130
+ * The callback stream for an actor to receive all Pncp type messages. This includes skill requests
131
+ * and all additional Pncp messages sent in the conversation thread.
132
+ *
133
+ * @generated from protobuf rpc: PncpCallbackStream(pncp.v1.PncpCallbackRequest) returns (stream pncp.v1.PncpCallback);
134
+ */
135
+ pncpCallbackStream(input: PncpCallbackRequest, options?: RpcOptions): ServerStreamingCall<PncpCallbackRequest, PncpCallback> {
136
+ const method = this.methods[2], opt = this._transport.mergeOptions(options);
137
+ return stackIntercept<PncpCallbackRequest, PncpCallback>("serverStreaming", this._transport, method, opt, input);
138
+ }
139
+ /**
140
+ * Creates a new observation stream.
141
+ *
142
+ * @generated from protobuf rpc: CreateObserverStream(pncp.v1.ObservationRequest) returns (stream pncp.v1.ObservationMessageWrapper);
143
+ */
144
+ createObserverStream(input: ObservationRequest, options?: RpcOptions): ServerStreamingCall<ObservationRequest, ObservationMessageWrapper> {
145
+ const method = this.methods[3], opt = this._transport.mergeOptions(options);
146
+ return stackIntercept<ObservationRequest, ObservationMessageWrapper>("serverStreaming", this._transport, method, opt, input);
147
+ }
148
+ /**
149
+ * A direct cross domain request, posted from one node to another. The other node is often expected to post
150
+ * the results back.
151
+ *
152
+ * @generated from protobuf rpc: CrossDomainRequest(pncp.v1.CrossDomainMessage) returns (pncp.v1.CrossDomainResponse);
153
+ */
154
+ crossDomainRequest(input: CrossDomainMessage, options?: RpcOptions): UnaryCall<CrossDomainMessage, CrossDomainResponse> {
155
+ const method = this.methods[4], opt = this._transport.mergeOptions(options);
156
+ return stackIntercept<CrossDomainMessage, CrossDomainResponse>("unary", this._transport, method, opt, input);
157
+ }
158
+ /**
159
+ * Inverted API for an edge node to connect to another node. It creates this stream so that the node it
160
+ * connects to can stream messages back to the edge node. The edge node is then required to stream
161
+ * `MessageResponse` to each incoming message back to the connected node.
162
+ *
163
+ * @generated from protobuf rpc: CrossDomainStream(stream pncp.v1.CrossDomainResponse) returns (stream pncp.v1.CrossDomainStreamMessage);
164
+ */
165
+ crossDomainStream(options?: RpcOptions): DuplexStreamingCall<CrossDomainResponse, CrossDomainStreamMessage> {
166
+ const method = this.methods[5], opt = this._transport.mergeOptions(options);
167
+ return stackIntercept<CrossDomainResponse, CrossDomainStreamMessage>("duplex", this._transport, method, opt);
168
+ }
169
+ /**
170
+ * @generated from protobuf rpc: Login(pncp.v1.LoginRequest) returns (pncp.v1.LoginResponse);
171
+ */
172
+ login(input: LoginRequest, options?: RpcOptions): UnaryCall<LoginRequest, LoginResponse> {
173
+ const method = this.methods[6], opt = this._transport.mergeOptions(options);
174
+ return stackIntercept<LoginRequest, LoginResponse>("unary", this._transport, method, opt, input);
175
+ }
176
+ /**
177
+ * @generated from protobuf rpc: RefreshToken(pncp.v1.RefreshTokenRequest) returns (pncp.v1.LoginResponse);
178
+ */
179
+ refreshToken(input: RefreshTokenRequest, options?: RpcOptions): UnaryCall<RefreshTokenRequest, LoginResponse> {
180
+ const method = this.methods[7], opt = this._transport.mergeOptions(options);
181
+ return stackIntercept<RefreshTokenRequest, LoginResponse>("unary", this._transport, method, opt, input);
182
+ }
183
+ /**
184
+ * A PNCP message received from a medium. Note, that we are likely to rework mediums.
185
+ * Given currently limitations with mediums this route is left unauthenticated.
186
+ *
187
+ * @generated from protobuf rpc: PncpMediumMessageRequest(pncp.v1.PncpMediumMessage) returns (pncp.v1.MessageResponse);
188
+ */
189
+ pncpMediumMessageRequest(input: PncpMediumMessage, options?: RpcOptions): UnaryCall<PncpMediumMessage, MessageResponse> {
190
+ const method = this.methods[8], opt = this._transport.mergeOptions(options);
191
+ return stackIntercept<PncpMediumMessage, MessageResponse>("unary", this._transport, method, opt, input);
192
+ }
193
+ }
@@ -0,0 +1,32 @@
1
+ // @generated by protobuf-ts 2.9.4
2
+ // @generated from protobuf file "broker.grpc.proto" (package "pncp.v1", syntax proto3)
3
+ // tslint:disable
4
+ import { PncpMediumMessage } from "./mediums";
5
+ import { RefreshTokenRequest } from "./broker_api";
6
+ import { LoginResponse } from "./broker_api";
7
+ import { LoginRequest } from "./broker_api";
8
+ import { CrossDomainStreamMessage } from "./broker_api";
9
+ import { CrossDomainResponse } from "./broker_api";
10
+ import { CrossDomainMessage } from "./broker_api";
11
+ import { ObservationMessageWrapper } from "./observation";
12
+ import { ObservationRequest } from "./observation";
13
+ import { PncpCallback } from "./pncp";
14
+ import { PncpCallbackRequest } from "./broker_api";
15
+ import { PncpMessage } from "./pncp";
16
+ import { MessageResponse } from "./broker_api";
17
+ import { PncpRequest } from "./pncp";
18
+ import { ServiceType } from "@protobuf-ts/runtime-rpc";
19
+ /**
20
+ * @generated ServiceType for protobuf service pncp.v1.Broker
21
+ */
22
+ export const Broker = new ServiceType("pncp.v1.Broker", [
23
+ { name: "SkillRequest", options: {}, I: PncpRequest, O: MessageResponse },
24
+ { name: "PncpMessageRequest", options: {}, I: PncpMessage, O: MessageResponse },
25
+ { name: "PncpCallbackStream", serverStreaming: true, options: {}, I: PncpCallbackRequest, O: PncpCallback },
26
+ { name: "CreateObserverStream", serverStreaming: true, options: {}, I: ObservationRequest, O: ObservationMessageWrapper },
27
+ { name: "CrossDomainRequest", options: {}, I: CrossDomainMessage, O: CrossDomainResponse },
28
+ { name: "CrossDomainStream", serverStreaming: true, clientStreaming: true, options: {}, I: CrossDomainResponse, O: CrossDomainStreamMessage },
29
+ { name: "Login", options: { unauthenticated: true }, I: LoginRequest, O: LoginResponse },
30
+ { name: "RefreshToken", options: { unauthenticated: true }, I: RefreshTokenRequest, O: LoginResponse },
31
+ { name: "PncpMediumMessageRequest", options: { unauthenticated: true }, I: PncpMediumMessage, O: MessageResponse }
32
+ ]);