@robono/server 0.4.0 → 0.6.0

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/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type BridgeDirection, restrictionsFor } from "./restrictions.js";
2
- import type { BridgeConnection, BridgeConnectionListResponse, BridgeConnectionResponse, BridgeMessageEventResponse, BridgeMessageListResponse, ConnectEndpointInput, CreateRobonoConnectionInput, DirectoryResponse, EndpointConnection, EndpointMessageResponse, GuardianMessageListResponse, JsonObject, LanguageResponse, PushDiagnosticResponse, ReportPushDiagnosticInput, RequestBridgeConnectionInput, RespondBridgeConnectionInput, RobonoConnectionResponse, RobonoConnectionListResponse, RobonoMessageListResponse, RobonoRequestOptions, RobonoServerOptions, SendBridgeMessageInput, SendBridgeMessageResponse, SendEndpointMessageInput, SendGuardianMessageInput, SendGuardianMessageResponse, SendRobonoMessageInput, SendRobonoMessageResponse, TransformOutput, TransformResponse, UpdateBridgeConnectionInput } from "./types.js";
2
+ import type { BridgeConnection, BridgeConnectionListResponse, BridgeConnectionResponse, BridgeMessageEventResponse, BridgeMessageListResponse, ConnectEndpointInput, CreateRobonoConnectionInput, DirectoryResponse, DisconnectEndpointConnectionInput, EndpointConnection, EndpointConnectionCursor, EndpointConnectionListResponse, EndpointMessageListResponse, EndpointMessageResponse, GuardianMessageListResponse, JsonObject, LanguageResponse, MessageTransformInput, PushDiagnosticResponse, ReportPushDiagnosticInput, RequestBridgeConnectionInput, RespondBridgeConnectionInput, RobonoConnectionResponse, RobonoConnectionListResponse, RobonoMessageListResponse, RobonoRequestOptions, RobonoServerOptions, SendBridgeMessageInput, SendBridgeMessageResponse, SendEndpointMessageInput, SendGuardianMessageInput, SendGuardianMessageResponse, SendRobonoMessageInput, SendRobonoMessageResponse, SpeechTransformInput, TransformResponse, UpdateBridgeConnectionInput, UpdateEndpointConnectionInput, MarkEndpointMessageInput } from "./types.js";
3
3
  export declare class RobonoServer {
4
4
  readonly directory: {
5
5
  list: (input?: {
@@ -15,6 +15,7 @@ export declare class RobonoServer {
15
15
  status?: string;
16
16
  limit?: number;
17
17
  before?: string;
18
+ connection_id?: string;
18
19
  }, options?: RobonoRequestOptions) => Promise<RobonoConnectionListResponse>;
19
20
  updateProfile: (input: JsonObject, options?: RobonoRequestOptions) => Promise<RobonoConnectionResponse>;
20
21
  disconnect: (input: {
@@ -24,6 +25,20 @@ export declare class RobonoServer {
24
25
  disconnected_at?: string;
25
26
  }, options?: RobonoRequestOptions) => Promise<JsonObject>;
26
27
  };
28
+ /**
29
+ * Fully normalized connection operations for every directory endpoint.
30
+ * Prefer this namespace in new server-only integrations.
31
+ */
32
+ readonly endpointConnections: {
33
+ connect: (input: ConnectEndpointInput, options?: RobonoRequestOptions) => Promise<EndpointConnection>;
34
+ list: (input: {
35
+ external_user_id: string;
36
+ limit?: number;
37
+ cursor?: EndpointConnectionCursor;
38
+ }, options?: RobonoRequestOptions) => Promise<EndpointConnectionListResponse>;
39
+ update: (input: UpdateEndpointConnectionInput, options?: RobonoRequestOptions) => Promise<EndpointConnection>;
40
+ disconnect: (input: DisconnectEndpointConnectionInput, options?: RobonoRequestOptions) => Promise<EndpointConnection>;
41
+ };
27
42
  readonly networkConnections: {
28
43
  request: (input: RequestBridgeConnectionInput, options?: RobonoRequestOptions) => Promise<BridgeConnectionResponse>;
29
44
  update: (input: UpdateBridgeConnectionInput, options?: RobonoRequestOptions) => Promise<BridgeConnectionResponse>;
@@ -33,6 +48,7 @@ export declare class RobonoServer {
33
48
  status?: string;
34
49
  limit?: number;
35
50
  before?: string;
51
+ bridge_connection_id?: string;
36
52
  }, options?: RobonoRequestOptions) => Promise<BridgeConnectionListResponse>;
37
53
  disconnect: (input: {
38
54
  bridge_connection_id: string;
@@ -49,6 +65,7 @@ export declare class RobonoServer {
49
65
  external_user_id?: string;
50
66
  limit?: number;
51
67
  before?: string;
68
+ after?: string;
52
69
  }, options?: RobonoRequestOptions) => Promise<RobonoMessageListResponse>;
53
70
  send: {
54
71
  (input: SendEndpointMessageInput, options?: RobonoRequestOptions): Promise<EndpointMessageResponse>;
@@ -74,6 +91,7 @@ export declare class RobonoServer {
74
91
  external_user_id?: string;
75
92
  limit?: number;
76
93
  before?: string;
94
+ after?: string;
77
95
  }, options?: RobonoRequestOptions) => Promise<BridgeMessageListResponse>;
78
96
  mark: (input: {
79
97
  bridge_connection_id: string;
@@ -88,14 +106,33 @@ export declare class RobonoServer {
88
106
  heard_at?: string;
89
107
  dry_run?: boolean;
90
108
  }, options?: RobonoRequestOptions) => Promise<JsonObject>;
109
+ markFromRobono: (input: {
110
+ connection_id: string;
111
+ robono_message_id: string;
112
+ external_user_id: string;
113
+ event: "delivered" | "read" | "heard";
114
+ occurred_at?: string;
115
+ dry_run?: boolean;
116
+ }, options?: RobonoRequestOptions) => Promise<JsonObject>;
117
+ };
118
+ /**
119
+ * Fully normalized message operations for every directory endpoint.
120
+ * Prefer this namespace in new server-only integrations.
121
+ */
122
+ readonly endpointMessages: {
123
+ send: (input: SendEndpointMessageInput, options?: RobonoRequestOptions) => Promise<EndpointMessageResponse>;
124
+ list: (input: {
125
+ connection: EndpointConnection;
126
+ external_user_id: string;
127
+ limit?: number;
128
+ before?: string;
129
+ after?: string;
130
+ }, options?: RobonoRequestOptions) => Promise<EndpointMessageListResponse>;
131
+ mark: (input: MarkEndpointMessageInput, options?: RobonoRequestOptions) => Promise<EndpointMessageResponse>;
91
132
  };
92
133
  readonly transforms: {
93
- message: (input: {
94
- connection_id: string;
95
- message_id: string;
96
- outputs: TransformOutput[];
97
- }, options?: RobonoRequestOptions) => Promise<TransformResponse>;
98
- speech: (input: JsonObject, options?: RobonoRequestOptions) => Promise<TransformResponse>;
134
+ message: (input: MessageTransformInput, options?: RobonoRequestOptions) => Promise<TransformResponse>;
135
+ speech: (input: SpeechTransformInput, options?: RobonoRequestOptions) => Promise<TransformResponse>;
99
136
  };
100
137
  readonly diagnostics: {
101
138
  reportPush: (input: ReportPushDiagnosticInput, options?: RobonoRequestOptions) => Promise<PushDiagnosticResponse>;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACV,gBAAgB,EAChB,4BAA4B,EAC5B,wBAAwB,EACxB,0BAA0B,EAC1B,yBAAyB,EAEzB,oBAAoB,EACpB,2BAA2B,EAC3B,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,2BAA2B,EAC3B,UAAU,EACV,gBAAgB,EAChB,sBAAsB,EACtB,yBAAyB,EACzB,4BAA4B,EAC5B,4BAA4B,EAC5B,wBAAwB,EACxB,4BAA4B,EAC5B,yBAAyB,EACzB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,EACxB,wBAAwB,EACxB,2BAA2B,EAC3B,sBAAsB,EACtB,yBAAyB,EACzB,eAAe,EACf,iBAAiB,EACjB,2BAA2B,EAC5B,MAAM,YAAY,CAAC;AAMpB,qBAAa,YAAY;IACvB,QAAQ,CAAC,SAAS,EAAE;QAClB,IAAI,EAAE,CACJ,KAAK,CAAC,EAAE;YAAE,kBAAkB,CAAC,EAAE,OAAO,CAAC;YAAC,WAAW,CAAC,EAAE,OAAO,CAAA;SAAE,EAC/D,OAAO,CAAC,EAAE,oBAAoB,KAC3B,OAAO,CAAC,iBAAiB,CAAC,CAAC;KACjC,CAAC;IACF,QAAQ,CAAC,WAAW,EAAE;QACpB,OAAO,EAAE,CACP,KAAK,EAAE,oBAAoB,EAC3B,OAAO,CAAC,EAAE,oBAAoB,KAC3B,OAAO,CAAC,kBAAkB,CAAC,CAAC;QACjC,MAAM,EAAE,CACN,KAAK,EAAE,2BAA2B,EAClC,OAAO,CAAC,EAAE,oBAAoB,KAC3B,OAAO,CAAC,wBAAwB,CAAC,CAAC;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AQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAExB,OAAO,EAAE,mBAAmB;IAwalC,SAAS,CAAC,OAAO,CAAC,EAAE,oBAAoB;IAIxC,MAAM,CAAC,OAAO,GAAE,IAAI,CAAC,oBAAoB,EAAE,gBAAgB,CAAM;YAEnC,IAAI;iBAAW,MAAM;;YAU3C,OAAO;YAeP,eAAe;CAuF9B"}
package/dist/client.js CHANGED
@@ -2,13 +2,23 @@ import { randomUUID } from "node:crypto";
2
2
  import { RobonoError } from "./errors.js";
3
3
  import { assertMessageAllowed, restrictionsFor, } from "./restrictions.js";
4
4
  const DEFAULT_BASE_URL = "https://api.robono.com/v1";
5
- const DEFAULT_API_VERSION = "2026-07-19";
5
+ const DEFAULT_API_VERSION = "2026-07-25";
6
6
  const RETRYABLE_STATUS = new Set([408, 425, 429, 500, 502, 503, 504]);
7
7
  export class RobonoServer {
8
8
  directory;
9
9
  connections;
10
+ /**
11
+ * Fully normalized connection operations for every directory endpoint.
12
+ * Prefer this namespace in new server-only integrations.
13
+ */
14
+ endpointConnections;
10
15
  networkConnections;
11
16
  messages;
17
+ /**
18
+ * Fully normalized message operations for every directory endpoint.
19
+ * Prefer this namespace in new server-only integrations.
20
+ */
21
+ endpointMessages;
12
22
  transforms;
13
23
  diagnostics;
14
24
  apiKey;
@@ -34,7 +44,7 @@ export class RobonoServer {
34
44
  code: "fetch_required",
35
45
  });
36
46
  }
37
- this.userAgent = options.userAgent ?? "@robono/server/0.4.0";
47
+ this.userAgent = options.userAgent ?? "@robono/server/0.6.0";
38
48
  this.apiVersion = options.apiVersion?.trim() || DEFAULT_API_VERSION;
39
49
  this.directory = {
40
50
  list: (input = {}, requestOptions) => this.request("/networks", {
@@ -65,7 +75,7 @@ export class RobonoServer {
65
75
  ? { capabilities: input.capabilities }
66
76
  : {}),
67
77
  }, requestOptions);
68
- return normalizeEndpointConnection(input.endpoint, raw);
78
+ return normalizeEndpointConnection(input.endpoint, raw, input.external_user_id);
69
79
  }
70
80
  const raw = await this.request("/network-connections", {
71
81
  target_app_id: input.endpoint.id,
@@ -75,6 +85,9 @@ export class RobonoServer {
75
85
  ...(input.target_contact_label
76
86
  ? { target_contact_label: input.target_contact_label }
77
87
  : {}),
88
+ ...(input.external_profile
89
+ ? { external_profile: input.external_profile }
90
+ : {}),
78
91
  ...(input.capabilities
79
92
  ? { capabilities: input.capabilities }
80
93
  : {}),
@@ -93,7 +106,7 @@ export class RobonoServer {
93
106
  ? { external_approval: input.external_approval }
94
107
  : {}),
95
108
  }, requestOptions);
96
- return normalizeEndpointConnection(input.endpoint, raw);
109
+ return normalizeEndpointConnection(input.endpoint, raw, input.external_user_id);
97
110
  },
98
111
  create: (input, requestOptions) => this.request("/connections", input, requestOptions),
99
112
  list: (input = {}, requestOptions) => this.request("/connections/list", input, requestOptions, false),
@@ -114,6 +127,7 @@ export class RobonoServer {
114
127
  send: (async (input, requestOptions = {}) => {
115
128
  if ("connection" in input) {
116
129
  const { connection, send_invite_sms_if_pending, external_profile, ...message } = input;
130
+ assertEndpointMessageAllowed(connection, message, input.external_user_id);
117
131
  if (connection.endpoint_type === "robono_phone") {
118
132
  const raw = await this.request("/messages", {
119
133
  ...message,
@@ -148,10 +162,158 @@ export class RobonoServer {
148
162
  list: (input, requestOptions) => this.request("/network-messages/list", input, requestOptions, false),
149
163
  mark: (input, requestOptions) => this.request("/network-messages/events", input, requestOptions),
150
164
  markHeard: (input, requestOptions) => this.request("/message-events", { ...input, event: "heard" }, requestOptions),
165
+ markFromRobono: (input, requestOptions) => this.request("/message-events", input, requestOptions),
166
+ };
167
+ this.endpointConnections = {
168
+ connect: (input, requestOptions) => this.connections.connect(input, requestOptions),
169
+ list: async ({ external_user_id, limit = 50, cursor = {} }, requestOptions) => {
170
+ const pageLimit = Math.max(1, Math.min(100, Math.floor(limit)));
171
+ const [directory, bridgePage, robonoPage] = await Promise.all([
172
+ this.directory.list({ includePhoneRobono: true, includeSelf: true }, requestOptions),
173
+ this.networkConnections.list({
174
+ external_user_id,
175
+ limit: pageLimit,
176
+ ...(cursor.connected_app_before
177
+ ? { before: cursor.connected_app_before }
178
+ : {}),
179
+ }, requestOptions),
180
+ this.connections.list({
181
+ external_user_id,
182
+ limit: pageLimit,
183
+ ...(cursor.robono_before
184
+ ? { before: cursor.robono_before }
185
+ : {}),
186
+ }, requestOptions),
187
+ ]);
188
+ const connections = [
189
+ ...bridgePage.connections.map((connection) => normalizeEndpointConnection(endpointForBridge(directory.directory, connection, external_user_id), connection, external_user_id)),
190
+ ...robonoPage.connections.map((connection) => normalizeEndpointConnection(phoneEndpoint(directory.directory), connection, external_user_id)),
191
+ ].sort((left, right) => connectionTimestamp(right).localeCompare(connectionTimestamp(left))).slice(0, pageLimit);
192
+ const hasMore = bridgePage.has_more || robonoPage.has_more ||
193
+ bridgePage.connections.length + robonoPage.connections.length >
194
+ pageLimit;
195
+ const lastConnectedApp = lastConnectionOfType(connections, "connected_app");
196
+ const lastRobono = lastConnectionOfType(connections, "robono_phone");
197
+ const connectedAppBefore = lastConnectedApp
198
+ ? connectionTimestamp(lastConnectedApp)
199
+ : cursor.connected_app_before;
200
+ const robonoBefore = lastRobono
201
+ ? connectionTimestamp(lastRobono)
202
+ : cursor.robono_before;
203
+ return {
204
+ connections,
205
+ has_more: hasMore,
206
+ next_cursor: hasMore
207
+ ? {
208
+ ...(connectedAppBefore
209
+ ? { connected_app_before: connectedAppBefore }
210
+ : {}),
211
+ ...(robonoBefore
212
+ ? { robono_before: robonoBefore }
213
+ : {}),
214
+ }
215
+ : null,
216
+ };
217
+ },
218
+ update: async (input, requestOptions) => {
219
+ const { connection, external_user_id, display_name, external_profile, capabilities, guardians, } = input;
220
+ if (connection.endpoint_type === "connected_app") {
221
+ const raw = await this.networkConnections.update({
222
+ bridge_connection_id: connection.connection_id,
223
+ external_user_id,
224
+ ...(display_name ? { display_name } : {}),
225
+ ...(external_profile ? { external_profile } : {}),
226
+ ...(capabilities ? { capabilities } : {}),
227
+ ...(guardians ? { guardians } : {}),
228
+ }, requestOptions);
229
+ return normalizeEndpointConnection(connection.endpoint, raw, external_user_id);
230
+ }
231
+ const raw = await this.connections.updateProfile({
232
+ connection_id: connection.connection_id,
233
+ external_user_id,
234
+ ...(display_name ? { external_display_name: display_name } : {}),
235
+ ...(external_profile ? { external_profile } : {}),
236
+ ...(capabilities ? { capabilities } : {}),
237
+ }, requestOptions);
238
+ return normalizeEndpointConnection(connection.endpoint, raw, external_user_id);
239
+ },
240
+ disconnect: async (input, requestOptions) => {
241
+ const { connection, external_user_id, reason } = input;
242
+ const raw = connection.endpoint_type === "connected_app"
243
+ ? await this.networkConnections.disconnect({
244
+ bridge_connection_id: connection.connection_id,
245
+ external_user_id,
246
+ ...(reason ? { reason } : {}),
247
+ }, requestOptions)
248
+ : await this.connections.disconnect({
249
+ connection_id: connection.connection_id,
250
+ external_user_id,
251
+ ...(reason ? { reason } : {}),
252
+ }, requestOptions);
253
+ return normalizeEndpointConnection(connection.endpoint, raw, external_user_id);
254
+ },
255
+ };
256
+ this.endpointMessages = {
257
+ send: (input, requestOptions) => this.messages.send(input, requestOptions),
258
+ list: async (input, requestOptions) => {
259
+ const { connection, external_user_id, limit, before, after, } = input;
260
+ const page = connection.endpoint_type === "connected_app"
261
+ ? await this.messages.list({
262
+ bridge_connection_id: connection.connection_id,
263
+ external_user_id,
264
+ ...(limit ? { limit } : {}),
265
+ ...(before ? { before } : {}),
266
+ ...(after ? { after } : {}),
267
+ }, requestOptions)
268
+ : await this.messages.listFromRobono({
269
+ connection_id: connection.connection_id,
270
+ external_user_id,
271
+ ...(limit ? { limit } : {}),
272
+ ...(before ? { before } : {}),
273
+ ...(after ? { after } : {}),
274
+ }, requestOptions);
275
+ return {
276
+ messages: page.messages.map((message) => normalizeEndpointMessageRecord(connection, message)),
277
+ has_more: page.has_more,
278
+ next_before: page.next_before,
279
+ next_after: page.next_after ?? null,
280
+ sync_cursor: page.sync_cursor ?? null,
281
+ };
282
+ },
283
+ mark: async (input, requestOptions) => {
284
+ const { connection, external_user_id, message_id, event, occurred_at } = input;
285
+ const raw = connection.endpoint_type === "connected_app"
286
+ ? await this.messages.mark({
287
+ bridge_connection_id: connection.connection_id,
288
+ bridge_message_id: message_id,
289
+ event,
290
+ ...(occurred_at ? { occurred_at } : {}),
291
+ }, requestOptions)
292
+ : await this.messages.markFromRobono({
293
+ connection_id: connection.connection_id,
294
+ robono_message_id: message_id,
295
+ external_user_id,
296
+ event,
297
+ ...(occurred_at ? { occurred_at } : {}),
298
+ }, requestOptions);
299
+ return {
300
+ endpoint_type: connection.endpoint_type,
301
+ connection_id: connection.connection_id,
302
+ message_id,
303
+ status: optionalString(record(raw).status) ?? event,
304
+ raw,
305
+ };
306
+ },
151
307
  };
152
308
  this.transforms = {
153
- message: (input, requestOptions) => this.request("/message-transforms", input, requestOptions),
154
- speech: (input, requestOptions) => this.request("/speech-transforms", input, requestOptions),
309
+ message: (input, requestOptions) => this.request("/message-transforms", input, {
310
+ timeoutMs: 120_000,
311
+ ...requestOptions,
312
+ }),
313
+ speech: (input, requestOptions) => this.request("/speech-transforms", input, {
314
+ timeoutMs: 120_000,
315
+ ...requestOptions,
316
+ }),
155
317
  };
156
318
  this.diagnostics = {
157
319
  reportPush: (input, requestOptions) => this.request("/push-diagnostics/events", input, requestOptions),
@@ -162,12 +324,12 @@ export class RobonoServer {
162
324
  }
163
325
  async health(options = {}) {
164
326
  const healthUrl = this.baseUrl.replace(/\/v1$/, "/health");
165
- return this.requestAbsolute(healthUrl, {}, options, false, false);
327
+ return this.requestAbsolute(healthUrl, undefined, options, false, false, "GET");
166
328
  }
167
329
  async request(path, body, options = {}, idempotentWrite = true) {
168
330
  return this.requestAbsolute(`${this.baseUrl}${path}`, body, options, true, idempotentWrite);
169
331
  }
170
- async requestAbsolute(url, body, options, authenticated, idempotentWrite) {
332
+ async requestAbsolute(url, body, options, authenticated, idempotentWrite, method = "POST") {
171
333
  const retries = nonnegativeInteger(options.retries, this.defaultRetries);
172
334
  const timeoutMs = positiveInteger(options.timeoutMs, this.defaultTimeoutMs);
173
335
  const requestId = options.requestId ?? `req_${randomUUID()}`;
@@ -186,20 +348,21 @@ export class RobonoServer {
186
348
  options.signal?.addEventListener("abort", onAbort, { once: true });
187
349
  try {
188
350
  const headers = {
189
- "content-type": "application/json",
190
351
  "accept": "application/json",
191
352
  "robono-request-id": requestId,
192
353
  "x-client-info": this.userAgent,
193
354
  "robono-api-version": this.apiVersion,
194
355
  };
356
+ if (method === "POST")
357
+ headers["content-type"] = "application/json";
195
358
  if (authenticated)
196
359
  headers.authorization = `Bearer ${this.apiKey}`;
197
360
  if (idempotencyKey)
198
361
  headers["idempotency-key"] = idempotencyKey;
199
362
  const response = await this.fetcher(url, {
200
- method: "POST",
363
+ method,
201
364
  headers,
202
- body: JSON.stringify(body),
365
+ ...(method === "POST" ? { body: JSON.stringify(body) } : {}),
203
366
  signal: controller.signal,
204
367
  });
205
368
  const payload = await parseResponse(response);
@@ -318,18 +481,34 @@ async function wait(milliseconds, signal) {
318
481
  signal.addEventListener("abort", abort, { once: true });
319
482
  });
320
483
  }
321
- function normalizeEndpointConnection(endpoint, raw) {
484
+ function normalizeEndpointConnection(endpoint, raw, externalUserId) {
322
485
  if ("bridge_connection_id" in raw) {
486
+ const ownSource = raw.source.external_user_id === externalUserId;
487
+ const other = ownSource ? raw.target : raw.source;
488
+ const profile = record(other.profile);
489
+ const avatar = record(profile.avatar);
323
490
  return {
324
491
  endpoint,
325
492
  endpoint_type: "connected_app",
326
493
  connection_id: raw.bridge_connection_id,
327
494
  status: raw.status,
328
- external_user_id: raw.source.external_user_id,
495
+ external_user_id: ownSource
496
+ ? raw.source.external_user_id
497
+ : raw.target.external_user_id ?? externalUserId,
329
498
  capabilities: raw.capabilities,
499
+ peer: {
500
+ endpoint,
501
+ external_user_id: other.external_user_id,
502
+ display_name: other.display_name,
503
+ identifier: ownSource ? raw.target.identifier : null,
504
+ avatar_url: optionalString(avatar.source_url) ?? null,
505
+ avatar_version: optionalString(avatar.version) ?? null,
506
+ profile,
507
+ },
330
508
  raw,
331
509
  };
332
510
  }
511
+ const user = raw.robono_user;
333
512
  return {
334
513
  endpoint,
335
514
  endpoint_type: "robono_phone",
@@ -337,9 +516,73 @@ function normalizeEndpointConnection(endpoint, raw) {
337
516
  status: raw.status,
338
517
  external_user_id: raw.external_user_id,
339
518
  capabilities: raw.capabilities,
519
+ peer: {
520
+ endpoint,
521
+ external_user_id: user?.id ?? null,
522
+ display_name: user?.display_name ?? raw.target_contact_label ??
523
+ raw.phone_masked,
524
+ identifier: raw.phone_masked,
525
+ avatar_url: user?.avatar_url ?? null,
526
+ avatar_version: user?.avatar_version ?? null,
527
+ profile: user ? { ...user } : {},
528
+ },
340
529
  raw,
341
530
  };
342
531
  }
532
+ function endpointForBridge(directory, connection, externalUserId) {
533
+ const ownSource = connection.source.external_user_id === externalUserId;
534
+ const app = ownSource ? connection.target.app : connection.source.app;
535
+ const appId = app.id;
536
+ return directory.find((entry) => entry.id === appId) ??
537
+ fallbackDirectoryEntry(app);
538
+ }
539
+ function phoneEndpoint(directory) {
540
+ return directory.find((entry) => entry.type === "robono_phone") ??
541
+ fallbackDirectoryEntry({
542
+ id: "robono-phone",
543
+ slug: "robono",
544
+ display_name: "Robono",
545
+ }, "robono_phone");
546
+ }
547
+ function fallbackDirectoryEntry(app, type = "connected_app") {
548
+ const displayName = app.display_name?.trim() || "Connected app";
549
+ return {
550
+ type,
551
+ id: app.id,
552
+ slug: app.slug?.trim() || app.id,
553
+ display_name: displayName,
554
+ description: "",
555
+ icon_url: "",
556
+ accepts_inbound_bridge_requests: true,
557
+ accepted_identifier: {
558
+ label: "Friend identifier",
559
+ description: `Enter the identifier used by ${displayName}.`,
560
+ example: "",
561
+ format: "text",
562
+ },
563
+ default_capabilities: {},
564
+ };
565
+ }
566
+ function connectionTimestamp(connection) {
567
+ const raw = connection.raw;
568
+ return optionalString(raw.created_at) ?? optionalString(raw.updated_at) ?? "";
569
+ }
570
+ function lastConnectionOfType(connections, type) {
571
+ for (let index = connections.length - 1; index >= 0; index -= 1) {
572
+ const connection = connections[index];
573
+ if (connection?.endpoint_type === type)
574
+ return connection;
575
+ }
576
+ return undefined;
577
+ }
578
+ function record(value) {
579
+ return value && typeof value === "object" && !Array.isArray(value)
580
+ ? value
581
+ : {};
582
+ }
583
+ function optionalString(value) {
584
+ return typeof value === "string" && value.trim() ? value.trim() : undefined;
585
+ }
343
586
  function normalizeEndpointMessage(connection, raw) {
344
587
  const messageId = connection.endpoint_type === "connected_app"
345
588
  ? raw.bridge_message_id ?? null
@@ -352,4 +595,63 @@ function normalizeEndpointMessage(connection, raw) {
352
595
  raw,
353
596
  };
354
597
  }
598
+ function normalizeEndpointMessageRecord(connection, raw) {
599
+ const bridge = connection.endpoint_type === "connected_app";
600
+ return {
601
+ endpoint_type: connection.endpoint_type,
602
+ connection_id: connection.connection_id,
603
+ message_id: bridge
604
+ ? raw.bridge_message_id
605
+ : raw.robono_message_id,
606
+ direction: raw.direction,
607
+ external_message_id: raw.external_message_id,
608
+ message_kind: raw.message_kind,
609
+ text_body: raw.text_body,
610
+ media: raw.media,
611
+ status: raw.status,
612
+ accepted_at: bridge
613
+ ? raw.accepted_at
614
+ : null,
615
+ accepted_via: bridge
616
+ ? raw.accepted_via
617
+ : null,
618
+ delivered_at: raw.delivered_at,
619
+ read_at: raw.read_at,
620
+ heard_at: raw.heard_at,
621
+ failed_at: raw.failed_at,
622
+ failure_code: raw.failure_code,
623
+ created_at: raw.created_at,
624
+ raw,
625
+ };
626
+ }
627
+ function assertEndpointMessageAllowed(connection, input, externalUserId) {
628
+ if (connection.endpoint_type === "connected_app") {
629
+ const raw = connection.raw;
630
+ const direction = raw.source.external_user_id === externalUserId
631
+ ? "source_to_target"
632
+ : "target_to_source";
633
+ assertMessageAllowed(restrictionsFor(raw, direction), {
634
+ messageKind: input.message_kind,
635
+ ...(input.message_kind === "text"
636
+ ? { textBody: input.text_body }
637
+ : { media: input.media }),
638
+ });
639
+ return;
640
+ }
641
+ const capabilities = connection.capabilities;
642
+ assertMessageAllowed({
643
+ allowed_message_kinds: capabilities.allowed_outbound_message_kinds ??
644
+ ["text", "voice", "image", "video", "document"],
645
+ ...(capabilities.text ? { text: capabilities.text } : {}),
646
+ ...(capabilities.voice ? { voice: capabilities.voice } : {}),
647
+ ...(capabilities.photo ? { photo: capabilities.photo } : {}),
648
+ ...(capabilities.video ? { video: capabilities.video } : {}),
649
+ ...(capabilities.document ? { document: capabilities.document } : {}),
650
+ }, {
651
+ messageKind: input.message_kind,
652
+ ...(input.message_kind === "text"
653
+ ? { textBody: input.text_body }
654
+ : { media: input.media }),
655
+ });
656
+ }
355
657
  //# sourceMappingURL=client.js.map