@bundleup/sdk 0.0.7 → 0.0.9
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/index.d.mts +26 -2
- package/dist/index.d.ts +26 -2
- package/dist/index.js +35 -1
- package/dist/index.mjs +35 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -4,8 +4,8 @@ declare abstract class Base<T> {
|
|
|
4
4
|
private baseUrl;
|
|
5
5
|
private version;
|
|
6
6
|
constructor(apiKey: string);
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
protected get apiUrl(): string;
|
|
8
|
+
protected get headers(): Record<string, string>;
|
|
9
9
|
/**
|
|
10
10
|
* List resources with optional query parameters.
|
|
11
11
|
* @param params - Query parameters for filtering the list.
|
|
@@ -95,6 +95,29 @@ declare class Request {
|
|
|
95
95
|
delete(path: string, headers?: Record<string, string>): Promise<Response>;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
interface SessionCreateRequest {
|
|
99
|
+
integrationId: string;
|
|
100
|
+
externalId?: string;
|
|
101
|
+
metadata?: Record<string, any>;
|
|
102
|
+
}
|
|
103
|
+
interface SessionCreateResponse {
|
|
104
|
+
expires_in: number;
|
|
105
|
+
token: string;
|
|
106
|
+
externalId?: string;
|
|
107
|
+
}
|
|
108
|
+
declare class Sessions {
|
|
109
|
+
private apiKey;
|
|
110
|
+
constructor(apiKey: string);
|
|
111
|
+
private get headers();
|
|
112
|
+
/**
|
|
113
|
+
* Create a new session.
|
|
114
|
+
* @param params - The session creation parameters.
|
|
115
|
+
* @returns A promise that resolves to the created session details.
|
|
116
|
+
* @throws If the fetch request fails.
|
|
117
|
+
*/
|
|
118
|
+
create(params: SessionCreateRequest): Promise<SessionCreateResponse>;
|
|
119
|
+
}
|
|
120
|
+
|
|
98
121
|
type ChatMessageRequest = {
|
|
99
122
|
channelId: string;
|
|
100
123
|
content: string;
|
|
@@ -119,6 +142,7 @@ declare class BundleUp {
|
|
|
119
142
|
get connections(): Connections;
|
|
120
143
|
get integrations(): Integrations;
|
|
121
144
|
get webhooks(): Webhooks;
|
|
145
|
+
get sessions(): Sessions;
|
|
122
146
|
connect(connectionId: string): {
|
|
123
147
|
req: Request;
|
|
124
148
|
chat: Chat;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ declare abstract class Base<T> {
|
|
|
4
4
|
private baseUrl;
|
|
5
5
|
private version;
|
|
6
6
|
constructor(apiKey: string);
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
protected get apiUrl(): string;
|
|
8
|
+
protected get headers(): Record<string, string>;
|
|
9
9
|
/**
|
|
10
10
|
* List resources with optional query parameters.
|
|
11
11
|
* @param params - Query parameters for filtering the list.
|
|
@@ -95,6 +95,29 @@ declare class Request {
|
|
|
95
95
|
delete(path: string, headers?: Record<string, string>): Promise<Response>;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
interface SessionCreateRequest {
|
|
99
|
+
integrationId: string;
|
|
100
|
+
externalId?: string;
|
|
101
|
+
metadata?: Record<string, any>;
|
|
102
|
+
}
|
|
103
|
+
interface SessionCreateResponse {
|
|
104
|
+
expires_in: number;
|
|
105
|
+
token: string;
|
|
106
|
+
externalId?: string;
|
|
107
|
+
}
|
|
108
|
+
declare class Sessions {
|
|
109
|
+
private apiKey;
|
|
110
|
+
constructor(apiKey: string);
|
|
111
|
+
private get headers();
|
|
112
|
+
/**
|
|
113
|
+
* Create a new session.
|
|
114
|
+
* @param params - The session creation parameters.
|
|
115
|
+
* @returns A promise that resolves to the created session details.
|
|
116
|
+
* @throws If the fetch request fails.
|
|
117
|
+
*/
|
|
118
|
+
create(params: SessionCreateRequest): Promise<SessionCreateResponse>;
|
|
119
|
+
}
|
|
120
|
+
|
|
98
121
|
type ChatMessageRequest = {
|
|
99
122
|
channelId: string;
|
|
100
123
|
content: string;
|
|
@@ -119,6 +142,7 @@ declare class BundleUp {
|
|
|
119
142
|
get connections(): Connections;
|
|
120
143
|
get integrations(): Integrations;
|
|
121
144
|
get webhooks(): Webhooks;
|
|
145
|
+
get sessions(): Sessions;
|
|
122
146
|
connect(connectionId: string): {
|
|
123
147
|
req: Request;
|
|
124
148
|
chat: Chat;
|
package/dist/index.js
CHANGED
|
@@ -195,7 +195,7 @@ var Request = class {
|
|
|
195
195
|
return {
|
|
196
196
|
"Content-Type": "application/json",
|
|
197
197
|
Authorization: `Bearer ${this.apiKey}`,
|
|
198
|
-
"
|
|
198
|
+
"Connection-Id": this.connectionId
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
201
|
buildUrl(path, searchParams = {}) {
|
|
@@ -294,6 +294,37 @@ var Request = class {
|
|
|
294
294
|
}
|
|
295
295
|
};
|
|
296
296
|
|
|
297
|
+
// src/session.ts
|
|
298
|
+
var Sessions = class {
|
|
299
|
+
constructor(apiKey) {
|
|
300
|
+
this.apiKey = apiKey;
|
|
301
|
+
}
|
|
302
|
+
get headers() {
|
|
303
|
+
return {
|
|
304
|
+
"Content-Type": "application/json",
|
|
305
|
+
Authorization: `Bearer ${this.apiKey}`
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Create a new session.
|
|
310
|
+
* @param params - The session creation parameters.
|
|
311
|
+
* @returns A promise that resolves to the created session details.
|
|
312
|
+
* @throws If the fetch request fails.
|
|
313
|
+
*/
|
|
314
|
+
async create(params) {
|
|
315
|
+
const response = await fetch("https://api.bundleup.io/v1/sessions", {
|
|
316
|
+
method: "POST",
|
|
317
|
+
headers: this.headers,
|
|
318
|
+
body: JSON.stringify(params)
|
|
319
|
+
});
|
|
320
|
+
if (!response.ok) {
|
|
321
|
+
throw new Error("Failed to create session");
|
|
322
|
+
}
|
|
323
|
+
const data = await response.json();
|
|
324
|
+
return data;
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
|
|
297
328
|
// src/methods/chat.ts
|
|
298
329
|
var Chat = class {
|
|
299
330
|
constructor(apiKey, connectionId) {
|
|
@@ -339,6 +370,9 @@ var BundleUp = class {
|
|
|
339
370
|
get webhooks() {
|
|
340
371
|
return new Webhooks(this.apiKey);
|
|
341
372
|
}
|
|
373
|
+
get sessions() {
|
|
374
|
+
return new Sessions(this.apiKey);
|
|
375
|
+
}
|
|
342
376
|
connect(connectionId) {
|
|
343
377
|
if (!connectionId) {
|
|
344
378
|
throw new Error("Connection ID is required to create a Fetch instance.");
|
package/dist/index.mjs
CHANGED
|
@@ -169,7 +169,7 @@ var Request = class {
|
|
|
169
169
|
return {
|
|
170
170
|
"Content-Type": "application/json",
|
|
171
171
|
Authorization: `Bearer ${this.apiKey}`,
|
|
172
|
-
"
|
|
172
|
+
"Connection-Id": this.connectionId
|
|
173
173
|
};
|
|
174
174
|
}
|
|
175
175
|
buildUrl(path, searchParams = {}) {
|
|
@@ -268,6 +268,37 @@ var Request = class {
|
|
|
268
268
|
}
|
|
269
269
|
};
|
|
270
270
|
|
|
271
|
+
// src/session.ts
|
|
272
|
+
var Sessions = class {
|
|
273
|
+
constructor(apiKey) {
|
|
274
|
+
this.apiKey = apiKey;
|
|
275
|
+
}
|
|
276
|
+
get headers() {
|
|
277
|
+
return {
|
|
278
|
+
"Content-Type": "application/json",
|
|
279
|
+
Authorization: `Bearer ${this.apiKey}`
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Create a new session.
|
|
284
|
+
* @param params - The session creation parameters.
|
|
285
|
+
* @returns A promise that resolves to the created session details.
|
|
286
|
+
* @throws If the fetch request fails.
|
|
287
|
+
*/
|
|
288
|
+
async create(params) {
|
|
289
|
+
const response = await fetch("https://api.bundleup.io/v1/sessions", {
|
|
290
|
+
method: "POST",
|
|
291
|
+
headers: this.headers,
|
|
292
|
+
body: JSON.stringify(params)
|
|
293
|
+
});
|
|
294
|
+
if (!response.ok) {
|
|
295
|
+
throw new Error("Failed to create session");
|
|
296
|
+
}
|
|
297
|
+
const data = await response.json();
|
|
298
|
+
return data;
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
|
|
271
302
|
// src/methods/chat.ts
|
|
272
303
|
var Chat = class {
|
|
273
304
|
constructor(apiKey, connectionId) {
|
|
@@ -313,6 +344,9 @@ var BundleUp = class {
|
|
|
313
344
|
get webhooks() {
|
|
314
345
|
return new Webhooks(this.apiKey);
|
|
315
346
|
}
|
|
347
|
+
get sessions() {
|
|
348
|
+
return new Sessions(this.apiKey);
|
|
349
|
+
}
|
|
316
350
|
connect(connectionId) {
|
|
317
351
|
if (!connectionId) {
|
|
318
352
|
throw new Error("Connection ID is required to create a Fetch instance.");
|