@renterra/sdk 0.2.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.
@@ -0,0 +1,4 @@
1
+ export type { ConnectRenterraOptions, RenterraSdk } from "./rest.js";
2
+ export { connectRenterra } from "./rest.js";
3
+ export type { RenterraCallOptions } from "./transport.js";
4
+ export { RenterraError } from "./transport.js";
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { connectRenterra } from "./rest.js";
2
+ export { RenterraError } from "./transport.js";
package/dist/mcp.d.ts ADDED
@@ -0,0 +1,456 @@
1
+ import type { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
2
+ import type { RequestOptions } from "@modelcontextprotocol/sdk/shared/protocol.js";
3
+ import type { McpContracts } from "./generated/contracts.js";
4
+ export type { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
5
+ export { renterraSdkDebug } from "./debug.js";
6
+ export type McpToolName = keyof McpContracts;
7
+ export type McpInput<T extends McpToolName> = McpContracts[T]["input"];
8
+ export type McpOutput<T extends McpToolName> = McpContracts[T]["output"];
9
+ export type RenterraCallOptions = Pick<RequestOptions, "signal" | "timeout">;
10
+ export declare class RenterraError extends Error {
11
+ readonly code: "invalid_input" | "tool_error" | "invalid_output" | "request_failed";
12
+ readonly tool: McpToolName;
13
+ readonly name = "RenterraError";
14
+ constructor(code: "invalid_input" | "tool_error" | "invalid_output" | "request_failed", tool: McpToolName, message: string, options?: ErrorOptions);
15
+ }
16
+ export type ConnectRenterraOptions = {
17
+ url: string | URL;
18
+ authProvider?: OAuthClientProvider;
19
+ tokenEndpoint?: string;
20
+ authorizationCode?: string;
21
+ fetch?: typeof globalThis.fetch;
22
+ };
23
+ export declare const DEFAULT_MCP_SESSION_TOKEN_ENDPOINT = "/api/artifacts/mcp-token";
24
+ export declare function createSessionAuthProvider(endpoint?: string, fetchFn?: typeof globalThis.fetch): OAuthClientProvider;
25
+ export declare function connectRenterra(options: ConnectRenterraOptions): Promise<{
26
+ customers: {
27
+ search: (input?: McpInput<"search_customers">, options?: RenterraCallOptions) => Promise<{
28
+ [k: string]: unknown;
29
+ data: {
30
+ id: string;
31
+ created_at: string;
32
+ updated_at: string;
33
+ is_archived: boolean;
34
+ archived_at: string | null;
35
+ deleted_at: string | null;
36
+ name: string;
37
+ type: "Individual" | "Company";
38
+ status: "ACTIVE" | "PREVIOUS" | "UNDESIRABLE" | "PROSPECTIVE" | "CREDIT_HOLD";
39
+ account_type: "Cash" | "Account";
40
+ billing_email: string | null;
41
+ website: string | null;
42
+ primary_contact_id: string | null;
43
+ credit_balance: number;
44
+ total_revenue: number;
45
+ ytd_revenue: number;
46
+ address: {
47
+ address_line_1: string;
48
+ address_line_2: string | null;
49
+ locality: string;
50
+ administrative_area: string;
51
+ postal_code: string | null;
52
+ country: string | null;
53
+ [k: string]: unknown;
54
+ } | null;
55
+ [k: string]: unknown;
56
+ }[];
57
+ pagination: {
58
+ page: number;
59
+ page_size: number;
60
+ has_more: boolean;
61
+ [k: string]: unknown;
62
+ };
63
+ }>;
64
+ get: (id: string, options?: RenterraCallOptions) => Promise<{
65
+ [k: string]: unknown;
66
+ id: string;
67
+ created_at: string;
68
+ updated_at: string;
69
+ is_archived: boolean;
70
+ archived_at: string | null;
71
+ deleted_at: string | null;
72
+ name: string;
73
+ type: "Individual" | "Company";
74
+ status: "ACTIVE" | "PREVIOUS" | "UNDESIRABLE" | "PROSPECTIVE" | "CREDIT_HOLD";
75
+ account_type: "Cash" | "Account";
76
+ billing_email: string | null;
77
+ website: string | null;
78
+ primary_contact_id: string | null;
79
+ credit_balance: number;
80
+ total_revenue: number;
81
+ ytd_revenue: number;
82
+ address: {
83
+ address_line_1: string;
84
+ address_line_2: string | null;
85
+ locality: string;
86
+ administrative_area: string;
87
+ postal_code: string | null;
88
+ country: string | null;
89
+ [k: string]: unknown;
90
+ } | null;
91
+ }>;
92
+ };
93
+ orders: {
94
+ search: (input?: McpInput<"search_orders">, options?: RenterraCallOptions) => Promise<{
95
+ [k: string]: unknown;
96
+ data: {
97
+ id: string;
98
+ number: number;
99
+ source: "Online" | "Manual";
100
+ status: "Quote" | "Expired" | "Reservation" | "Canceled" | "Rental" | "Completed" | "Closed";
101
+ customer_id: string;
102
+ branch_id: string;
103
+ start_time: string;
104
+ end_time: string | null;
105
+ job_number: string | null;
106
+ job_description: string | null;
107
+ po_number: string | null;
108
+ contract_signed_at: string | null;
109
+ is_historical: boolean;
110
+ items: {
111
+ description: string;
112
+ quantity: number;
113
+ item_id: string | null;
114
+ [k: string]: unknown;
115
+ }[];
116
+ lines: {
117
+ description: string;
118
+ quantity: number;
119
+ item_id: string | null;
120
+ id: string;
121
+ inventory_on_order_ids: string[];
122
+ [k: string]: unknown;
123
+ }[];
124
+ [k: string]: unknown;
125
+ }[];
126
+ pagination: {
127
+ page: number;
128
+ page_size: number;
129
+ has_more: boolean;
130
+ [k: string]: unknown;
131
+ };
132
+ }>;
133
+ get: (id: string, options?: RenterraCallOptions) => Promise<{
134
+ [k: string]: unknown;
135
+ id: string;
136
+ number: number;
137
+ source: "Online" | "Manual";
138
+ status: "Quote" | "Expired" | "Reservation" | "Canceled" | "Rental" | "Completed" | "Closed";
139
+ customer_id: string;
140
+ branch_id: string;
141
+ start_time: string;
142
+ end_time: string | null;
143
+ job_number: string | null;
144
+ job_description: string | null;
145
+ po_number: string | null;
146
+ contract_signed_at: string | null;
147
+ is_historical: boolean;
148
+ items: {
149
+ description: string;
150
+ quantity: number;
151
+ item_id: string | null;
152
+ [k: string]: unknown;
153
+ }[];
154
+ lines: {
155
+ description: string;
156
+ quantity: number;
157
+ item_id: string | null;
158
+ id: string;
159
+ inventory_on_order_ids: string[];
160
+ [k: string]: unknown;
161
+ }[];
162
+ }>;
163
+ listContracts: (order_id: string, options?: RenterraCallOptions) => Promise<{
164
+ [k: string]: unknown;
165
+ data: {
166
+ id: string;
167
+ created_at: string;
168
+ signed_by: string | null;
169
+ is_downloadable: boolean;
170
+ [k: string]: unknown;
171
+ }[];
172
+ }>;
173
+ };
174
+ invoices: {
175
+ search: (input?: McpInput<"search_invoices">, options?: RenterraCallOptions) => Promise<{
176
+ [k: string]: unknown;
177
+ data: {
178
+ id: string;
179
+ number: string;
180
+ status: "Unpaid" | "Paid" | "Void" | "BadDebt";
181
+ customer_id: string | null;
182
+ order_id: string | null;
183
+ total_cents: number;
184
+ tax_total_cents: number;
185
+ paid_cents: number;
186
+ issue_date: string | null;
187
+ due_date: string;
188
+ paid_at: string | null;
189
+ items: {
190
+ description: string;
191
+ quantity: number;
192
+ total_cents: number;
193
+ item_id: string | null;
194
+ [k: string]: unknown;
195
+ }[];
196
+ lines: {
197
+ description: string;
198
+ quantity: number;
199
+ total_cents: number;
200
+ item_id: string | null;
201
+ id: string;
202
+ group_id: string;
203
+ sales_tax_cents: number;
204
+ ledger_account_id: string;
205
+ revenue_allocations: {
206
+ item_id: string;
207
+ ledger_account_id: string;
208
+ percentage: number;
209
+ [k: string]: unknown;
210
+ }[];
211
+ [k: string]: unknown;
212
+ }[];
213
+ payments: {
214
+ allocation_id: string;
215
+ payment_id: string;
216
+ amount_cents: number;
217
+ allocated_at: string;
218
+ type: "Payment" | "Refund";
219
+ method: "Cash" | "Card" | "Bank" | "Check" | "Credit" | "Other";
220
+ created_at: string;
221
+ succeeded_at: string | null;
222
+ refunded_payment_id: string | null;
223
+ [k: string]: unknown;
224
+ }[];
225
+ [k: string]: unknown;
226
+ }[];
227
+ pagination: {
228
+ page: number;
229
+ page_size: number;
230
+ has_more: boolean;
231
+ [k: string]: unknown;
232
+ };
233
+ }>;
234
+ get: (id: string, options?: RenterraCallOptions) => Promise<{
235
+ [k: string]: unknown;
236
+ id: string;
237
+ number: string;
238
+ status: "Unpaid" | "Paid" | "Void" | "BadDebt";
239
+ customer_id: string | null;
240
+ order_id: string | null;
241
+ total_cents: number;
242
+ tax_total_cents: number;
243
+ paid_cents: number;
244
+ issue_date: string | null;
245
+ due_date: string;
246
+ paid_at: string | null;
247
+ items: {
248
+ description: string;
249
+ quantity: number;
250
+ total_cents: number;
251
+ item_id: string | null;
252
+ [k: string]: unknown;
253
+ }[];
254
+ lines: {
255
+ description: string;
256
+ quantity: number;
257
+ total_cents: number;
258
+ item_id: string | null;
259
+ id: string;
260
+ group_id: string;
261
+ sales_tax_cents: number;
262
+ ledger_account_id: string;
263
+ revenue_allocations: {
264
+ item_id: string;
265
+ ledger_account_id: string;
266
+ percentage: number;
267
+ [k: string]: unknown;
268
+ }[];
269
+ [k: string]: unknown;
270
+ }[];
271
+ payments: {
272
+ allocation_id: string;
273
+ payment_id: string;
274
+ amount_cents: number;
275
+ allocated_at: string;
276
+ type: "Payment" | "Refund";
277
+ method: "Cash" | "Card" | "Bank" | "Check" | "Credit" | "Other";
278
+ created_at: string;
279
+ succeeded_at: string | null;
280
+ refunded_payment_id: string | null;
281
+ [k: string]: unknown;
282
+ }[];
283
+ }>;
284
+ };
285
+ payments: {
286
+ search: (input?: McpInput<"search_payments">, options?: RenterraCallOptions) => Promise<{
287
+ [k: string]: unknown;
288
+ data: {
289
+ id: string;
290
+ type: "Payment" | "Refund";
291
+ method: "Cash" | "Card" | "Bank" | "Check" | "Credit" | "Other";
292
+ amount_cents: number;
293
+ customer_id: string | null;
294
+ branch_id: string;
295
+ order_id: string | null;
296
+ refunded_payment_id: string | null;
297
+ created_at: string;
298
+ succeeded_at: string | null;
299
+ allocations: {
300
+ id: string;
301
+ invoice_id: string;
302
+ amount_cents: number;
303
+ created_at: string;
304
+ [k: string]: unknown;
305
+ }[];
306
+ [k: string]: unknown;
307
+ }[];
308
+ pagination: {
309
+ page: number;
310
+ page_size: number;
311
+ has_more: boolean;
312
+ [k: string]: unknown;
313
+ };
314
+ }>;
315
+ get: (id: string, options?: RenterraCallOptions) => Promise<{
316
+ [k: string]: unknown;
317
+ id: string;
318
+ type: "Payment" | "Refund";
319
+ method: "Cash" | "Card" | "Bank" | "Check" | "Credit" | "Other";
320
+ amount_cents: number;
321
+ customer_id: string | null;
322
+ branch_id: string;
323
+ order_id: string | null;
324
+ refunded_payment_id: string | null;
325
+ created_at: string;
326
+ succeeded_at: string | null;
327
+ allocations: {
328
+ id: string;
329
+ invoice_id: string;
330
+ amount_cents: number;
331
+ created_at: string;
332
+ [k: string]: unknown;
333
+ }[];
334
+ }>;
335
+ };
336
+ inventoryItems: {
337
+ search: (input?: McpInput<"search_inventory_items">, options?: RenterraCallOptions) => Promise<{
338
+ [k: string]: unknown;
339
+ data: {
340
+ id: string;
341
+ updated_at: string;
342
+ kind: "Actual" | "Slot";
343
+ type: "Serial" | "Sale" | "Bulk" | "Part";
344
+ make: string | null;
345
+ model: string | null;
346
+ model_year: number | null;
347
+ condition: ("Excellent" | "Good" | "Ok" | "Bad" | "Terrible") | null;
348
+ item_number: string | null;
349
+ part_number: string | null;
350
+ serial_number: string | null;
351
+ description: string;
352
+ category: string;
353
+ class: string;
354
+ group: string;
355
+ [k: string]: unknown;
356
+ }[];
357
+ pagination: {
358
+ page: number;
359
+ page_size: number;
360
+ has_more: boolean;
361
+ [k: string]: unknown;
362
+ };
363
+ }>;
364
+ get: (id: string, options?: RenterraCallOptions) => Promise<{
365
+ [k: string]: unknown;
366
+ id: string;
367
+ updated_at: string;
368
+ kind: "Actual" | "Slot";
369
+ type: "Serial" | "Sale" | "Bulk" | "Part";
370
+ make: string | null;
371
+ model: string | null;
372
+ model_year: number | null;
373
+ condition: ("Excellent" | "Good" | "Ok" | "Bad" | "Terrible") | null;
374
+ item_number: string | null;
375
+ part_number: string | null;
376
+ serial_number: string | null;
377
+ description: string;
378
+ category: string;
379
+ class: string;
380
+ group: string;
381
+ }>;
382
+ };
383
+ inventoryOnOrders: {
384
+ search: (input?: McpInput<"search_inventory_on_orders">, options?: RenterraCallOptions) => Promise<{
385
+ [k: string]: unknown;
386
+ data: ({
387
+ id: string;
388
+ source: "order" | "work_order";
389
+ order_id: string | null;
390
+ work_order_id: string | null;
391
+ line_id: string;
392
+ item_id: string;
393
+ slot_id: string | null;
394
+ description: string;
395
+ quantity: number;
396
+ status: "Ready" | "OnRent" | "CalledOff" | "PickedUp" | "CheckedIn" | "Sold";
397
+ type: "rental";
398
+ billing_start_time: string;
399
+ billing_end_time: string | null;
400
+ [k: string]: unknown;
401
+ } | {
402
+ id: string;
403
+ source: "order" | "work_order";
404
+ order_id: string | null;
405
+ work_order_id: string | null;
406
+ line_id: string;
407
+ item_id: string;
408
+ slot_id: string | null;
409
+ description: string;
410
+ quantity: number;
411
+ status: "Ready" | "OnRent" | "CalledOff" | "PickedUp" | "CheckedIn" | "Sold";
412
+ type: "sale";
413
+ sale_time: string | null;
414
+ [k: string]: unknown;
415
+ })[];
416
+ pagination: {
417
+ page: number;
418
+ page_size: number;
419
+ has_more: boolean;
420
+ [k: string]: unknown;
421
+ };
422
+ }>;
423
+ get: (id: string, options?: RenterraCallOptions) => Promise<{
424
+ [k: string]: unknown;
425
+ id: string;
426
+ source: "order" | "work_order";
427
+ order_id: string | null;
428
+ work_order_id: string | null;
429
+ line_id: string;
430
+ item_id: string;
431
+ slot_id: string | null;
432
+ description: string;
433
+ quantity: number;
434
+ status: "Ready" | "OnRent" | "CalledOff" | "PickedUp" | "CheckedIn" | "Sold";
435
+ type: "rental";
436
+ billing_start_time: string;
437
+ billing_end_time: string | null;
438
+ } | {
439
+ [k: string]: unknown;
440
+ id: string;
441
+ source: "order" | "work_order";
442
+ order_id: string | null;
443
+ work_order_id: string | null;
444
+ line_id: string;
445
+ item_id: string;
446
+ slot_id: string | null;
447
+ description: string;
448
+ quantity: number;
449
+ status: "Ready" | "OnRent" | "CalledOff" | "PickedUp" | "CheckedIn" | "Sold";
450
+ type: "sale";
451
+ sale_time: string | null;
452
+ }>;
453
+ };
454
+ close: () => Promise<void>;
455
+ }>;
456
+ export type RenterraSdk = Awaited<ReturnType<typeof connectRenterra>>;
package/dist/mcp.js ADDED
@@ -0,0 +1,185 @@
1
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2
+ import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
3
+ import { CallToolResultSchema } from "@modelcontextprotocol/sdk/types.js";
4
+ import { AjvJsonSchemaValidator } from "@modelcontextprotocol/sdk/validation/ajv";
5
+ import { debugHttpFailure, sdkDebug } from "./debug.js";
6
+ import { toolSchemas } from "./generated/schemas.js";
7
+ export { renterraSdkDebug } from "./debug.js";
8
+ export class RenterraError extends Error {
9
+ code;
10
+ tool;
11
+ name = "RenterraError";
12
+ constructor(code, tool, message, options) {
13
+ super(message, options);
14
+ this.code = code;
15
+ this.tool = tool;
16
+ }
17
+ }
18
+ export const DEFAULT_MCP_SESSION_TOKEN_ENDPOINT = "/api/artifacts/mcp-token";
19
+ const SESSION_CLIENT_METADATA = {
20
+ client_name: "Renterra artifact session",
21
+ redirect_uris: [],
22
+ grant_types: [],
23
+ response_types: [],
24
+ token_endpoint_auth_method: "none",
25
+ };
26
+ export function createSessionAuthProvider(endpoint = DEFAULT_MCP_SESSION_TOKEN_ENDPOINT, fetchFn = globalThis.fetch) {
27
+ let cached;
28
+ const cacheTokens = (tokens) => {
29
+ cached = { tokens, expiresAt: Date.now() + ((tokens.expires_in ?? 600) - 30) * 1000 };
30
+ return tokens;
31
+ };
32
+ const fetchTokens = async () => {
33
+ const startedAt = Date.now();
34
+ sdkDebug("session_token.start");
35
+ let response;
36
+ try {
37
+ response = await fetchFn(endpoint, { method: "POST", credentials: "same-origin" });
38
+ }
39
+ catch (error) {
40
+ sdkDebug("session_token.failed", { durationMs: Date.now() - startedAt });
41
+ throw error;
42
+ }
43
+ sdkDebug("session_token.response", {
44
+ status: response.status,
45
+ durationMs: Date.now() - startedAt,
46
+ });
47
+ if (!response.ok) {
48
+ throw new Error(`Artifact session token request failed: ${response.status}`);
49
+ }
50
+ const body = (await response.json());
51
+ return cacheTokens({
52
+ access_token: body.access_token,
53
+ token_type: body.token_type ?? "Bearer",
54
+ expires_in: body.expires_in,
55
+ scope: body.scope,
56
+ });
57
+ };
58
+ return {
59
+ redirectUrl: endpoint,
60
+ clientMetadata: SESSION_CLIENT_METADATA,
61
+ clientInformation: () => ({
62
+ client_id: "renterra-artifact-session",
63
+ ...SESSION_CLIENT_METADATA,
64
+ }),
65
+ tokens: async () => (cached && cached.expiresAt > Date.now() ? cached.tokens : fetchTokens()),
66
+ saveTokens: (tokens) => {
67
+ cacheTokens(tokens);
68
+ },
69
+ redirectToAuthorization: () => {
70
+ throw new Error("Renterra session is not authenticated");
71
+ },
72
+ saveCodeVerifier: () => { },
73
+ codeVerifier: () => {
74
+ throw new Error("Artifact sessions do not use authorization codes");
75
+ },
76
+ };
77
+ }
78
+ export async function connectRenterra(options) {
79
+ const startedAt = Date.now();
80
+ sdkDebug("connection.start");
81
+ const authProvider = options.authProvider ??
82
+ createSessionAuthProvider(options.tokenEndpoint, options.fetch ?? globalThis.fetch);
83
+ const client = new Client({ name: "renterra-sdk", version: "0.0.0" });
84
+ try {
85
+ const transport = new StreamableHTTPClientTransport(new URL(options.url), {
86
+ authProvider,
87
+ fetch: async (input, init) => {
88
+ const response = await (options.fetch ?? globalThis.fetch)(input, {
89
+ ...init,
90
+ credentials: "omit",
91
+ });
92
+ if (!response.ok && new URL(input, options.url).href === new URL(options.url).href)
93
+ await debugHttpFailure(response);
94
+ return response;
95
+ },
96
+ });
97
+ if (options.authorizationCode)
98
+ await transport.finishAuth(options.authorizationCode);
99
+ await client.connect(transport);
100
+ sdkDebug("connection.connected", { durationMs: Date.now() - startedAt });
101
+ }
102
+ catch (error) {
103
+ sdkDebug("connection.failed", { durationMs: Date.now() - startedAt });
104
+ await client.close();
105
+ throw error;
106
+ }
107
+ const validator = new AjvJsonSchemaValidator();
108
+ async function call(tool, input, callOptions) {
109
+ const startedAt = Date.now();
110
+ sdkDebug("tool.start", { tool, args: input });
111
+ try {
112
+ const schema = toolSchemas[tool];
113
+ const parsedInput = validator.getValidator(schema.input)(input);
114
+ if (!parsedInput.valid)
115
+ throw new RenterraError("invalid_input", tool, parsedInput.errorMessage);
116
+ const result = (await client
117
+ .callTool({ name: tool, arguments: input }, CallToolResultSchema, callOptions)
118
+ .catch((cause) => {
119
+ throw new RenterraError("request_failed", tool, `MCP request failed: ${tool}`, { cause });
120
+ }));
121
+ if (result.isError) {
122
+ const message = result.content
123
+ .filter((item) => item.type === "text")
124
+ .map((item) => item.text)
125
+ .join("\n");
126
+ throw new RenterraError("tool_error", tool, message || `MCP tool failed: ${tool}`);
127
+ }
128
+ const parsedOutput = validator.getValidator(schema.output)(result.structuredContent);
129
+ if (!parsedOutput.valid)
130
+ throw new RenterraError("invalid_output", tool, `Invalid response from ${tool}: ${parsedOutput.errorMessage}`);
131
+ sdkDebug("tool.succeeded", {
132
+ tool,
133
+ result: parsedOutput.data,
134
+ durationMs: Date.now() - startedAt,
135
+ });
136
+ return parsedOutput.data;
137
+ }
138
+ catch (error) {
139
+ sdkDebug("tool.failed", {
140
+ tool,
141
+ code: error instanceof RenterraError ? error.code : "request_failed",
142
+ durationMs: Date.now() - startedAt,
143
+ });
144
+ throw error;
145
+ }
146
+ }
147
+ return {
148
+ customers: {
149
+ search: (input = {}, options) => call("search_customers", input, options),
150
+ get: (id, options) => call("get_customer", { id }, options),
151
+ },
152
+ orders: {
153
+ search: (input = {}, options) => call("search_orders", input, options),
154
+ get: (id, options) => call("get_order", { id }, options),
155
+ listContracts: (order_id, options) => call("list_order_contracts", { order_id }, options),
156
+ },
157
+ invoices: {
158
+ search: (input = {}, options) => call("search_invoices", input, options),
159
+ get: (id, options) => call("get_invoice", { id }, options),
160
+ },
161
+ payments: {
162
+ search: (input = {}, options) => call("search_payments", input, options),
163
+ get: (id, options) => call("get_payment", { id }, options),
164
+ },
165
+ inventoryItems: {
166
+ search: (input = {}, options) => call("search_inventory_items", input, options),
167
+ get: (id, options) => call("get_inventory_item", { id }, options),
168
+ },
169
+ inventoryOnOrders: {
170
+ search: (input = {}, options) => call("search_inventory_on_orders", input, options),
171
+ get: (id, options) => call("get_inventory_on_order", { id }, options),
172
+ },
173
+ close: async () => {
174
+ sdkDebug("connection.closing");
175
+ try {
176
+ await client.close();
177
+ sdkDebug("connection.closed");
178
+ }
179
+ catch (error) {
180
+ sdkDebug("connection.close_failed");
181
+ throw error;
182
+ }
183
+ },
184
+ };
185
+ }