@robono/server 0.1.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.js ADDED
@@ -0,0 +1,244 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { RobonoError } from "./errors.js";
3
+ import { assertMessageAllowed, restrictionsFor, } from "./restrictions.js";
4
+ const DEFAULT_BASE_URL = "https://api.robono.com/v1";
5
+ const DEFAULT_API_VERSION = "2026-07-19";
6
+ const RETRYABLE_STATUS = new Set([408, 425, 429, 500, 502, 503, 504]);
7
+ export class RobonoServer {
8
+ directory;
9
+ connections;
10
+ networkConnections;
11
+ messages;
12
+ transforms;
13
+ apiKey;
14
+ baseUrl;
15
+ defaultTimeoutMs;
16
+ defaultRetries;
17
+ fetcher;
18
+ userAgent;
19
+ apiVersion;
20
+ constructor(options) {
21
+ if (!options.apiKey?.trim()) {
22
+ throw new RobonoError("A Robono API key is required.", {
23
+ code: "api_key_required",
24
+ });
25
+ }
26
+ this.apiKey = options.apiKey.trim();
27
+ this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
28
+ this.defaultTimeoutMs = positiveInteger(options.timeoutMs, 15_000);
29
+ this.defaultRetries = nonnegativeInteger(options.retries, 2);
30
+ this.fetcher = options.fetch ?? globalThis.fetch;
31
+ if (!this.fetcher) {
32
+ throw new RobonoError("This environment does not provide fetch.", {
33
+ code: "fetch_required",
34
+ });
35
+ }
36
+ this.userAgent = options.userAgent ?? "@robono/server/0.1.0";
37
+ this.apiVersion = options.apiVersion?.trim() || DEFAULT_API_VERSION;
38
+ this.directory = {
39
+ list: (input = {}, requestOptions) => this.request("/networks", {
40
+ include_phone_robono: input.includePhoneRobono ?? true,
41
+ include_self: input.includeSelf ?? false,
42
+ }, requestOptions, false),
43
+ };
44
+ this.connections = {
45
+ create: (input, requestOptions) => this.request("/connections", input, requestOptions),
46
+ updateProfile: (input, requestOptions) => this.request("/connections/profile", input, requestOptions),
47
+ disconnect: (input, requestOptions) => this.request("/connections/disconnect", input, requestOptions),
48
+ };
49
+ this.networkConnections = {
50
+ request: (input, requestOptions) => this.request("/network-connections", input, requestOptions),
51
+ respond: (input, requestOptions) => this.request("/network-connections/respond", input, requestOptions),
52
+ list: (input = {}, requestOptions) => this.request("/network-connections/list", input, requestOptions, false),
53
+ disconnect: (input, requestOptions) => this.request("/network-connections/disconnect", input, requestOptions),
54
+ update: (input, requestOptions) => this.request("/network-connections/update", input, requestOptions),
55
+ restrictions: restrictionsFor,
56
+ };
57
+ this.messages = {
58
+ sendToRobono: (input, requestOptions) => this.request("/messages", input, requestOptions),
59
+ send: (input, requestOptions = {}) => {
60
+ if (requestOptions.connection && requestOptions.direction) {
61
+ const limits = restrictionsFor(requestOptions.connection, requestOptions.direction);
62
+ assertMessageAllowed(limits, {
63
+ messageKind: input.message_kind,
64
+ ...(input.message_kind === "text"
65
+ ? { textBody: input.text_body }
66
+ : { media: input.media }),
67
+ });
68
+ }
69
+ return this.request("/network-messages", input, requestOptions);
70
+ },
71
+ sendGuardian: (input, requestOptions) => this.request("/guardian-messages", input, requestOptions),
72
+ listGuardian: (input, requestOptions) => this.request("/guardian-messages/list", input, requestOptions, false),
73
+ markGuardian: (input, requestOptions) => this.request("/guardian-messages/events", input, requestOptions),
74
+ list: (input, requestOptions) => this.request("/network-messages/list", input, requestOptions, false),
75
+ mark: (input, requestOptions) => this.request("/network-messages/events", input, requestOptions),
76
+ markHeard: (input, requestOptions) => this.request("/message-events", { ...input, event: "heard" }, requestOptions),
77
+ };
78
+ this.transforms = {
79
+ message: (input, requestOptions) => this.request("/message-transforms", input, requestOptions),
80
+ speech: (input, requestOptions) => this.request("/speech-transforms", input, requestOptions),
81
+ };
82
+ }
83
+ async languages(options) {
84
+ return this.request("/languages", {}, options, false);
85
+ }
86
+ async health(options = {}) {
87
+ const healthUrl = this.baseUrl.replace(/\/v1$/, "/health");
88
+ return this.requestAbsolute(healthUrl, {}, options, false, false);
89
+ }
90
+ async request(path, body, options = {}, idempotentWrite = true) {
91
+ return this.requestAbsolute(`${this.baseUrl}${path}`, body, options, true, idempotentWrite);
92
+ }
93
+ async requestAbsolute(url, body, options, authenticated, idempotentWrite) {
94
+ const retries = nonnegativeInteger(options.retries, this.defaultRetries);
95
+ const timeoutMs = positiveInteger(options.timeoutMs, this.defaultTimeoutMs);
96
+ const requestId = options.requestId ?? `req_${randomUUID()}`;
97
+ const suppliedIdempotencyKey = "idempotencyKey" in options
98
+ ? options.idempotencyKey
99
+ : undefined;
100
+ const idempotencyKey = suppliedIdempotencyKey ??
101
+ (idempotentWrite ? `idem_${randomUUID()}` : undefined);
102
+ let lastError;
103
+ for (let attempt = 0; attempt <= retries; attempt += 1) {
104
+ if (attempt > 0)
105
+ await wait(retryDelay(attempt), options.signal);
106
+ const controller = new AbortController();
107
+ const timeout = setTimeout(() => controller.abort(), timeoutMs);
108
+ const onAbort = () => controller.abort();
109
+ options.signal?.addEventListener("abort", onAbort, { once: true });
110
+ try {
111
+ const headers = {
112
+ "content-type": "application/json",
113
+ "accept": "application/json",
114
+ "robono-request-id": requestId,
115
+ "x-client-info": this.userAgent,
116
+ "robono-api-version": this.apiVersion,
117
+ };
118
+ if (authenticated)
119
+ headers.authorization = `Bearer ${this.apiKey}`;
120
+ if (idempotencyKey)
121
+ headers["idempotency-key"] = idempotencyKey;
122
+ const response = await this.fetcher(url, {
123
+ method: "POST",
124
+ headers,
125
+ body: JSON.stringify(body),
126
+ signal: controller.signal,
127
+ });
128
+ const payload = await parseResponse(response);
129
+ if (!response.ok) {
130
+ const apiError = apiErrorFrom(response, payload, requestId);
131
+ if (apiError.retryable && attempt < retries) {
132
+ lastError = apiError;
133
+ continue;
134
+ }
135
+ throw apiError;
136
+ }
137
+ return payload;
138
+ }
139
+ catch (cause) {
140
+ if (cause instanceof RobonoError)
141
+ throw cause;
142
+ const abortedByCaller = options.signal?.aborted === true;
143
+ const timedOut = controller.signal.aborted && !abortedByCaller;
144
+ const error = new RobonoError(abortedByCaller
145
+ ? "The Robono request was cancelled."
146
+ : timedOut
147
+ ? "The Robono request timed out."
148
+ : "The Robono service could not be reached.", {
149
+ code: abortedByCaller
150
+ ? "request_cancelled"
151
+ : timedOut
152
+ ? "request_timeout"
153
+ : "network_error",
154
+ requestId,
155
+ retryable: !abortedByCaller,
156
+ cause,
157
+ });
158
+ if (error.retryable && attempt < retries) {
159
+ lastError = error;
160
+ continue;
161
+ }
162
+ throw error;
163
+ }
164
+ finally {
165
+ clearTimeout(timeout);
166
+ options.signal?.removeEventListener("abort", onAbort);
167
+ }
168
+ }
169
+ throw lastError instanceof Error
170
+ ? lastError
171
+ : new RobonoError("The Robono request failed.", { requestId });
172
+ }
173
+ }
174
+ async function parseResponse(response) {
175
+ const text = await response.text();
176
+ if (!text)
177
+ return {};
178
+ try {
179
+ return JSON.parse(text);
180
+ }
181
+ catch (cause) {
182
+ throw new RobonoError("Robono returned a response that was not valid JSON.", {
183
+ status: response.status,
184
+ code: "invalid_json_response",
185
+ retryable: response.status >= 500,
186
+ cause,
187
+ });
188
+ }
189
+ }
190
+ function apiErrorFrom(response, payload, fallbackRequestId) {
191
+ const record = isRecord(payload) ? payload : {};
192
+ const nested = isRecord(record.error) ? record.error : record;
193
+ const status = response.status;
194
+ return new RobonoError(stringValue(nested.message) || stringValue(record.message) ||
195
+ `Robono request failed with status ${status}.`, {
196
+ status,
197
+ code: stringValue(nested.code) || stringValue(record.code) ||
198
+ `http_${status}`,
199
+ requestId: stringValue(record.request_id) ||
200
+ response.headers.get("robono-request-id") || fallbackRequestId,
201
+ fields: Array.isArray(record.fields)
202
+ ? record.fields
203
+ : Array.isArray(nested.fields)
204
+ ? nested.fields
205
+ : [],
206
+ details: record.details ?? nested.details,
207
+ retryable: RETRYABLE_STATUS.has(status),
208
+ });
209
+ }
210
+ function isRecord(value) {
211
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
212
+ }
213
+ function stringValue(value) {
214
+ return typeof value === "string" ? value : "";
215
+ }
216
+ function positiveInteger(value, fallback) {
217
+ return Number.isFinite(value) && (value ?? 0) > 0
218
+ ? Math.floor(value)
219
+ : fallback;
220
+ }
221
+ function nonnegativeInteger(value, fallback) {
222
+ return Number.isFinite(value) && (value ?? -1) >= 0
223
+ ? Math.floor(value)
224
+ : fallback;
225
+ }
226
+ function retryDelay(attempt) {
227
+ return Math.min(2_000, 150 * 2 ** Math.max(0, attempt - 1)) +
228
+ Math.floor(Math.random() * 100);
229
+ }
230
+ async function wait(milliseconds, signal) {
231
+ if (signal?.aborted)
232
+ throw signal.reason ?? new Error("Aborted");
233
+ await new Promise((resolve, reject) => {
234
+ const timer = setTimeout(resolve, milliseconds);
235
+ if (!signal)
236
+ return;
237
+ const abort = () => {
238
+ clearTimeout(timer);
239
+ reject(signal.reason ?? new Error("Aborted"));
240
+ };
241
+ signal.addEventListener("abort", abort, { once: true });
242
+ });
243
+ }
244
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EACL,oBAAoB,EAEpB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AA6B3B,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AACrD,MAAM,mBAAmB,GAAG,YAAY,CAAC;AACzC,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAEtE,MAAM,OAAO,YAAY;IACd,SAAS,CAKhB;IACO,WAAW,CAkBlB;IACO,kBAAkB,CAmCzB;IACO,QAAQ,CA6Df;IACO,UAAU,CAajB;IAEe,MAAM,CAAS;IACf,OAAO,CAAS;IAChB,gBAAgB,CAAS;I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MAAM,KAAK,GAAG,GAAG,EAAE;YACjB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;QAChD,CAAC,CAAC;QACF,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,23 @@
1
+ export interface RobonoErrorDetails {
2
+ status?: number;
3
+ code?: string;
4
+ requestId?: string;
5
+ fields?: unknown[];
6
+ details?: unknown;
7
+ retryable?: boolean;
8
+ cause?: unknown;
9
+ }
10
+ export declare class RobonoError extends Error {
11
+ readonly status: number | null;
12
+ readonly code: string;
13
+ readonly requestId: string | null;
14
+ readonly fields: unknown[];
15
+ readonly details: unknown;
16
+ readonly retryable: boolean;
17
+ readonly cause: unknown;
18
+ constructor(message: string, input?: RobonoErrorDetails);
19
+ }
20
+ export declare class RobonoWebhookError extends RobonoError {
21
+ constructor(message: string, code?: string, details?: RobonoErrorDetails);
22
+ }
23
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,SAAkB,KAAK,EAAE,OAAO,CAAC;gBAErB,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,kBAAuB;CAW5D;AAED,qBAAa,kBAAmB,SAAQ,WAAW;gBAE/C,OAAO,EAAE,MAAM,EACf,IAAI,SAAoB,EACxB,OAAO,GAAE,kBAAuB;CAKnC"}
package/dist/errors.js ADDED
@@ -0,0 +1,27 @@
1
+ export class RobonoError extends Error {
2
+ status;
3
+ code;
4
+ requestId;
5
+ fields;
6
+ details;
7
+ retryable;
8
+ cause;
9
+ constructor(message, input = {}) {
10
+ super(message);
11
+ this.name = "RobonoError";
12
+ this.status = input.status ?? null;
13
+ this.code = input.code ?? "robono_error";
14
+ this.requestId = input.requestId ?? null;
15
+ this.fields = input.fields ?? [];
16
+ this.details = input.details;
17
+ this.retryable = input.retryable ?? false;
18
+ this.cause = input.cause;
19
+ }
20
+ }
21
+ export class RobonoWebhookError extends RobonoError {
22
+ constructor(message, code = "invalid_webhook", details = {}) {
23
+ super(message, { ...details, code });
24
+ this.name = "RobonoWebhookError";
25
+ }
26
+ }
27
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAUA,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC3B,MAAM,CAAgB;IACtB,IAAI,CAAS;IACb,SAAS,CAAgB;IACzB,MAAM,CAAY;IAClB,OAAO,CAAU;IACjB,SAAS,CAAU;IACV,KAAK,CAAU;IAEjC,YAAY,OAAe,EAAE,QAA4B,EAAE;QACzD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,cAAc,CAAC;QACzC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC;QAC1C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAC3B,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,WAAW;IACjD,YACE,OAAe,EACf,IAAI,GAAG,iBAAiB,EACxB,UAA8B,EAAE;QAEhC,KAAK,CAAC,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ export { RobonoServer } from "./client.js";
2
+ export { createRobonoBackendAdapter } from "./adapter.js";
3
+ export type { RobonoBackendAdapterOptions } from "./adapter.js";
4
+ export { RobonoError, RobonoWebhookError } from "./errors.js";
5
+ export { assertMessageAllowed, isMessageAllowed, restrictionsFor, } from "./restrictions.js";
6
+ export { verifyRobonoWebhook } from "./webhooks.js";
7
+ export type * from "./types.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAC1D,YAAY,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,mBAAmB,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export { RobonoServer } from "./client.js";
2
+ export { createRobonoBackendAdapter } from "./adapter.js";
3
+ export { RobonoError, RobonoWebhookError } from "./errors.js";
4
+ export { assertMessageAllowed, isMessageAllowed, restrictionsFor, } from "./restrictions.js";
5
+ export { verifyRobonoWebhook } from "./webhooks.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { BridgeConnection, ConnectionCapabilities, DirectionCapabilities, MediaInput, MessageKind } from "./types.js";
2
+ export type BridgeDirection = "source_to_target" | "target_to_source";
3
+ export declare function restrictionsFor(connection: Pick<BridgeConnection, "capabilities"> | {
4
+ capabilities: ConnectionCapabilities;
5
+ }, direction: BridgeDirection): DirectionCapabilities;
6
+ export declare function isMessageAllowed(restrictions: DirectionCapabilities, kind: MessageKind): boolean;
7
+ export declare function assertMessageAllowed(restrictions: DirectionCapabilities, input: {
8
+ messageKind: MessageKind;
9
+ textBody?: string;
10
+ media?: MediaInput;
11
+ }): void;
12
+ //# sourceMappingURL=restrictions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restrictions.d.ts","sourceRoot":"","sources":["../src/restrictions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,UAAU,EACV,WAAW,EACZ,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,eAAe,GAAG,kBAAkB,GAAG,kBAAkB,CAAC;AAEtE,wBAAgB,eAAe,CAC7B,UAAU,EAAE,IAAI,CAAC,gBAAgB,EAAE,cAAc,CAAC,GAAG;IACnD,YAAY,EAAE,sBAAsB,CAAC;CACtC,EACD,SAAS,EAAE,eAAe,GACzB,qBAAqB,CAiBvB;AAED,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,qBAAqB,EACnC,IAAI,EAAE,WAAW,WAGlB;AAED,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,qBAAqB,EACnC,KAAK,EAAE;IAAE,WAAW,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,UAAU,CAAA;CAAE,QAgE3E"}
@@ -0,0 +1,65 @@
1
+ import { RobonoError } from "./errors.js";
2
+ export function restrictionsFor(connection, direction) {
3
+ const key = direction === "source_to_target"
4
+ ? "from_source_to_target"
5
+ : "from_target_to_source";
6
+ const value = connection.capabilities[key];
7
+ if (value && typeof value === "object")
8
+ return value;
9
+ const allowed = direction === "source_to_target"
10
+ ? intersection(connection.capabilities.source?.allowed_outbound_message_kinds, connection.capabilities.target?.allowed_inbound_message_kinds)
11
+ : intersection(connection.capabilities.target?.allowed_outbound_message_kinds, connection.capabilities.source?.allowed_inbound_message_kinds);
12
+ return { allowed_message_kinds: allowed };
13
+ }
14
+ export function isMessageAllowed(restrictions, kind) {
15
+ return restrictions.allowed_message_kinds.includes(kind);
16
+ }
17
+ export function assertMessageAllowed(restrictions, input) {
18
+ if (!isMessageAllowed(restrictions, input.messageKind)) {
19
+ throw new RobonoError(`The negotiated connection does not allow ${input.messageKind} messages.`, {
20
+ code: "message_kind_not_allowed",
21
+ details: { allowedMessageKinds: restrictions.allowed_message_kinds },
22
+ });
23
+ }
24
+ if (input.messageKind === "text") {
25
+ const max = restrictions.text?.max_characters;
26
+ if (max && (input.textBody?.length ?? 0) > max) {
27
+ throw new RobonoError(`Text messages can contain at most ${max} characters for this connection.`, {
28
+ code: "text_too_long",
29
+ details: { maxCharacters: max },
30
+ });
31
+ }
32
+ return;
33
+ }
34
+ const section = input.messageKind === "image"
35
+ ? restrictions.photo
36
+ : restrictions[input.messageKind];
37
+ const bytes = input.media?.byte_size;
38
+ if (section?.max_file_bytes && bytes && bytes > section.max_file_bytes) {
39
+ throw new RobonoError("The media file is larger than this connection permits.", {
40
+ code: "media_too_large",
41
+ details: { maxFileBytes: section.max_file_bytes },
42
+ });
43
+ }
44
+ const duration = input.media?.duration_ms;
45
+ if (section?.max_duration_ms && duration && duration > section.max_duration_ms) {
46
+ throw new RobonoError("The media duration is longer than this connection permits.", {
47
+ code: "media_too_long",
48
+ details: { maxDurationMs: section.max_duration_ms },
49
+ });
50
+ }
51
+ const mime = input.media?.mime_type;
52
+ if (mime && section?.allowed_input_mime_types?.length &&
53
+ !section.allowed_input_mime_types.includes(mime)) {
54
+ throw new RobonoError(`The negotiated connection does not accept ${mime}.`, {
55
+ code: "media_type_not_allowed",
56
+ details: { allowedMimeTypes: section.allowed_input_mime_types },
57
+ });
58
+ }
59
+ }
60
+ function intersection(first, second) {
61
+ const left = first ?? ["voice"];
62
+ const right = new Set(second ?? ["voice"]);
63
+ return left.filter((kind) => right.has(kind));
64
+ }
65
+ //# sourceMappingURL=restrictions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restrictions.js","sourceRoot":"","sources":["../src/restrictions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM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