@bundleup/sdk 0.0.17 → 0.0.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.
- package/README.md +333 -2
- package/dist/index.d.mts +10 -39
- package/dist/index.d.ts +10 -39
- package/dist/index.js +30 -108
- package/dist/index.mjs +30 -108
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -1,4 +1,335 @@
|
|
|
1
|
-
#
|
|
1
|
+
# BundleUp JavaScript SDK
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@bundleup/sdk)
|
|
4
|
-
[](https://opensource.org/licenses/ISC)
|
|
5
|
+
|
|
6
|
+
Official JavaScript/TypeScript SDK for the [BundleUp](https://bundleup.io) API. Connect to 100+ integrations with a single, unified API.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @bundleup/sdk
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Or with yarn:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
yarn add @bundleup/sdk
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Or with pnpm:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pnpm add @bundleup/sdk
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Requirements
|
|
27
|
+
|
|
28
|
+
- Node.js 16 or higher
|
|
29
|
+
- TypeScript 5.0+ (for TypeScript projects)
|
|
30
|
+
|
|
31
|
+
## Features
|
|
32
|
+
|
|
33
|
+
- **TypeScript First** - Built with TypeScript, includes full type definitions
|
|
34
|
+
- **Modern JavaScript** - ESM and CommonJS support for maximum compatibility
|
|
35
|
+
- **Promise-based API** - Uses native fetch for all HTTP requests
|
|
36
|
+
- **Comprehensive Coverage** - Full support for Connections, Integrations, Webhooks, Proxy, and Unify APIs
|
|
37
|
+
- **Lightweight** - Zero dependencies beyond native fetch API
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
import { BundleUp } from '@bundleup/sdk';
|
|
43
|
+
|
|
44
|
+
// Initialize the client with your API key
|
|
45
|
+
const client = new BundleUp(process.env.BUNDLEUP_API_KEY);
|
|
46
|
+
|
|
47
|
+
// List all connections
|
|
48
|
+
const connections = await client.connections.list();
|
|
49
|
+
console.log(connections);
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Authentication
|
|
53
|
+
|
|
54
|
+
The BundleUp SDK uses API keys for authentication. You can obtain your API key from the [BundleUp Dashboard](https://app.bundleup.io).
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
import { BundleUp } from '@bundleup/sdk';
|
|
58
|
+
|
|
59
|
+
// Initialize with API key
|
|
60
|
+
const client = new BundleUp('your_api_key_here');
|
|
61
|
+
|
|
62
|
+
// Or use environment variable (recommended)
|
|
63
|
+
const client = new BundleUp(process.env.BUNDLEUP_API_KEY);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Security Best Practice:** Never commit your API keys to version control. Use environment variables or a secure credential management system.
|
|
67
|
+
|
|
68
|
+
## Usage
|
|
69
|
+
|
|
70
|
+
### Connections
|
|
71
|
+
|
|
72
|
+
Manage your integration connections:
|
|
73
|
+
|
|
74
|
+
```javascript
|
|
75
|
+
// List all connections
|
|
76
|
+
const connections = await client.connections.list();
|
|
77
|
+
|
|
78
|
+
// List with query parameters
|
|
79
|
+
const connections = await client.connections.list({ status: 'active', limit: '10' });
|
|
80
|
+
|
|
81
|
+
// Retrieve a specific connection
|
|
82
|
+
const connection = await client.connections.retrieve('conn_123');
|
|
83
|
+
|
|
84
|
+
// Delete a connection
|
|
85
|
+
await client.connections.del('conn_123');
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Integrations
|
|
89
|
+
|
|
90
|
+
Work with available integrations:
|
|
91
|
+
|
|
92
|
+
```javascript
|
|
93
|
+
// List all integrations
|
|
94
|
+
const integrations = await client.integrations.list();
|
|
95
|
+
|
|
96
|
+
// Retrieve a specific integration
|
|
97
|
+
const integration = await client.integrations.retrieve('int_123');
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Webhooks
|
|
101
|
+
|
|
102
|
+
Manage webhook subscriptions:
|
|
103
|
+
|
|
104
|
+
```javascript
|
|
105
|
+
// List all webhooks
|
|
106
|
+
const webhooks = await client.webhooks.list();
|
|
107
|
+
|
|
108
|
+
// Create a webhook
|
|
109
|
+
const webhook = await client.webhooks.create({
|
|
110
|
+
url: 'https://example.com/webhook',
|
|
111
|
+
events: {
|
|
112
|
+
'connection.created': true,
|
|
113
|
+
'connection.deleted': true
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// Retrieve a webhook
|
|
118
|
+
const webhook = await client.webhooks.retrieve('webhook_123');
|
|
119
|
+
|
|
120
|
+
// Update a webhook
|
|
121
|
+
const updated = await client.webhooks.update('webhook_123', {
|
|
122
|
+
url: 'https://example.com/new-webhook'
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// Delete a webhook
|
|
126
|
+
await client.webhooks.del('webhook_123');
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Proxy API
|
|
130
|
+
|
|
131
|
+
Make direct calls to the underlying integration APIs:
|
|
132
|
+
|
|
133
|
+
```javascript
|
|
134
|
+
// Create a proxy instance
|
|
135
|
+
const proxy = client.proxy('conn_123');
|
|
136
|
+
|
|
137
|
+
// Make GET request
|
|
138
|
+
const users = await proxy.get('/api/users');
|
|
139
|
+
const data = await users.json();
|
|
140
|
+
|
|
141
|
+
// Make POST request
|
|
142
|
+
const response = await proxy.post('/api/users', JSON.stringify({
|
|
143
|
+
name: 'John Doe',
|
|
144
|
+
email: 'john@example.com'
|
|
145
|
+
}));
|
|
146
|
+
const newUser = await response.json();
|
|
147
|
+
|
|
148
|
+
// Make PUT request
|
|
149
|
+
const response = await proxy.put('/api/users/123', JSON.stringify({
|
|
150
|
+
name: 'Jane Doe'
|
|
151
|
+
}));
|
|
152
|
+
|
|
153
|
+
// Make PATCH request
|
|
154
|
+
const response = await proxy.patch('/api/users/123', JSON.stringify({
|
|
155
|
+
email: 'jane@example.com'
|
|
156
|
+
}));
|
|
157
|
+
|
|
158
|
+
// Make DELETE request
|
|
159
|
+
await proxy.delete('/api/users/123');
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Unify API
|
|
163
|
+
|
|
164
|
+
Access unified, normalized data across different integrations.
|
|
165
|
+
|
|
166
|
+
#### Chat (Slack, Discord, Microsoft Teams, etc.)
|
|
167
|
+
|
|
168
|
+
```javascript
|
|
169
|
+
// Get unified API instance for a connection
|
|
170
|
+
const unify = client.unify('conn_123');
|
|
171
|
+
|
|
172
|
+
// List channels
|
|
173
|
+
const channels = await unify.chat.channels({ limit: 100 });
|
|
174
|
+
|
|
175
|
+
// List channels with pagination
|
|
176
|
+
const channels = await unify.chat.channels({
|
|
177
|
+
limit: 50,
|
|
178
|
+
after: 'cursor_token'
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// Include raw response from the integration
|
|
182
|
+
const channels = await unify.chat.channels({
|
|
183
|
+
limit: 100,
|
|
184
|
+
includeRaw: true
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
#### Git (GitHub, GitLab, Bitbucket, etc.)
|
|
189
|
+
|
|
190
|
+
```javascript
|
|
191
|
+
const unify = client.unify('conn_123');
|
|
192
|
+
|
|
193
|
+
// List repositories
|
|
194
|
+
const repos = await unify.git.repos({ limit: 50 });
|
|
195
|
+
|
|
196
|
+
// List pull requests for a repository
|
|
197
|
+
const pulls = await unify.git.pulls({
|
|
198
|
+
repoName: 'owner/repo',
|
|
199
|
+
limit: 20
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
// List tags for a repository
|
|
203
|
+
const tags = await unify.git.tags({ repoName: 'owner/repo' });
|
|
204
|
+
|
|
205
|
+
// List releases for a repository
|
|
206
|
+
const releases = await unify.git.releases({
|
|
207
|
+
repoName: 'owner/repo',
|
|
208
|
+
limit: 10
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// Include raw response
|
|
212
|
+
const repos = await unify.git.repos({ includeRaw: true });
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
#### Project Management (Jira, Linear, Asana, etc.)
|
|
216
|
+
|
|
217
|
+
```javascript
|
|
218
|
+
// Get issues
|
|
219
|
+
const issues = await client.unify('conn_123').pm.issues({ limit: 100 });
|
|
220
|
+
|
|
221
|
+
// List with pagination
|
|
222
|
+
const issues = await client.unify('conn_123').pm.issues({
|
|
223
|
+
limit: 50,
|
|
224
|
+
after: 'cursor_token'
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
// Include raw response
|
|
228
|
+
const issues = await client.unify('conn_123').pm.issues({
|
|
229
|
+
includeRaw: true
|
|
230
|
+
});
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## Error Handling
|
|
234
|
+
|
|
235
|
+
The SDK throws standard JavaScript errors. You can catch and handle them as needed:
|
|
236
|
+
|
|
237
|
+
```javascript
|
|
238
|
+
try {
|
|
239
|
+
const client = new BundleUp('your-api-key');
|
|
240
|
+
const connections = await client.connections.list();
|
|
241
|
+
} catch (error) {
|
|
242
|
+
if (error.message.includes('401')) {
|
|
243
|
+
console.error('Authentication failed: Invalid API key');
|
|
244
|
+
} else if (error.message.includes('404')) {
|
|
245
|
+
console.error('Resource not found');
|
|
246
|
+
} else if (error.message.includes('429')) {
|
|
247
|
+
console.error('Rate limit exceeded');
|
|
248
|
+
} else {
|
|
249
|
+
console.error('API error:', error.message);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## Advanced Usage
|
|
255
|
+
|
|
256
|
+
### Query Parameters
|
|
257
|
+
|
|
258
|
+
The `list()` method supports query parameters:
|
|
259
|
+
|
|
260
|
+
```javascript
|
|
261
|
+
// List with filters
|
|
262
|
+
const connections = await client.connections.list({
|
|
263
|
+
status: 'active',
|
|
264
|
+
limit: '50',
|
|
265
|
+
page: '1'
|
|
266
|
+
});
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Custom Headers
|
|
270
|
+
|
|
271
|
+
When using the Proxy API, you can pass custom headers:
|
|
272
|
+
|
|
273
|
+
```javascript
|
|
274
|
+
const proxy = client.proxy('conn_123');
|
|
275
|
+
const response = await proxy.get('/api/users', {}, {
|
|
276
|
+
'X-Custom-Header': 'value'
|
|
277
|
+
});
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### TypeScript Support
|
|
281
|
+
|
|
282
|
+
The SDK is written in TypeScript and includes comprehensive type definitions:
|
|
283
|
+
|
|
284
|
+
```typescript
|
|
285
|
+
import { BundleUp } from '@bundleup/sdk';
|
|
286
|
+
|
|
287
|
+
const client = new BundleUp(process.env.BUNDLEUP_API_KEY!);
|
|
288
|
+
|
|
289
|
+
// Types are inferred automatically
|
|
290
|
+
const connections = await client.connections.list();
|
|
291
|
+
const webhook = await client.webhooks.create({
|
|
292
|
+
url: 'https://example.com/webhook',
|
|
293
|
+
events: {
|
|
294
|
+
'connection.created': true
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
## Development
|
|
300
|
+
|
|
301
|
+
After cloning the repository, install dependencies:
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
npm install
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
Build the package:
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
npm run build
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
Run tests:
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
npm test
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
## Contributing
|
|
320
|
+
|
|
321
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/bundleup/javascript.
|
|
322
|
+
|
|
323
|
+
## License
|
|
324
|
+
|
|
325
|
+
This package is available as open source under the terms of the [ISC License](https://opensource.org/licenses/ISC).
|
|
326
|
+
|
|
327
|
+
## Support
|
|
328
|
+
|
|
329
|
+
- Documentation: [https://docs.bundleup.io](https://docs.bundleup.io)
|
|
330
|
+
- Email: [support@bundleup.io](mailto:support@bundleup.io)
|
|
331
|
+
- GitHub Issues: [https://github.com/bundleup/javascript/issues](https://github.com/bundleup/javascript/issues)
|
|
332
|
+
|
|
333
|
+
## Code of Conduct
|
|
334
|
+
|
|
335
|
+
Everyone interacting in the BundleUp project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/bundleup/javascript/blob/main/CODE_OF_CONDUCT).
|
package/dist/index.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ declare abstract class Base$1<T> {
|
|
|
4
4
|
private baseUrl;
|
|
5
5
|
private version;
|
|
6
6
|
constructor(apiKey: string);
|
|
7
|
-
protected buildUrl(path?: string | null, searchParams?: Record<string,
|
|
7
|
+
protected buildUrl(path?: string | null, searchParams?: Record<string, string>): URL;
|
|
8
8
|
protected get headers(): Record<string, string>;
|
|
9
9
|
/**
|
|
10
10
|
* List resources with optional query parameters.
|
|
@@ -12,14 +12,14 @@ declare abstract class Base$1<T> {
|
|
|
12
12
|
* @returns A promise that resolves to an array of resources.
|
|
13
13
|
* @throws If params is not an object or if the fetch request fails.
|
|
14
14
|
*/
|
|
15
|
-
list<K extends Record<string,
|
|
15
|
+
list<K extends Record<string, string>>(searchParams?: K): Promise<T[]>;
|
|
16
16
|
/**
|
|
17
17
|
* Create a new resource.
|
|
18
18
|
* @param body - The request body containing resource details.
|
|
19
19
|
* @returns A promise that resolves to the created resource.
|
|
20
20
|
* @throws If body is not an object or if the fetch request fails.
|
|
21
21
|
*/
|
|
22
|
-
create<K extends Record<string,
|
|
22
|
+
create<K extends Record<string, unknown>>(body: K): Promise<T>;
|
|
23
23
|
/**
|
|
24
24
|
* Retrieve a specific resource by ID.
|
|
25
25
|
* @param id - The ID of the resource to retrieve.
|
|
@@ -34,7 +34,7 @@ declare abstract class Base$1<T> {
|
|
|
34
34
|
* @returns A promise that resolves to the updated resource.
|
|
35
35
|
* @throws If id is not provided, if body is not an object, or if the fetch request fails.
|
|
36
36
|
*/
|
|
37
|
-
update<K extends Record<string,
|
|
37
|
+
update<K extends Record<string, unknown>>(id: string, body: K): Promise<T>;
|
|
38
38
|
/**
|
|
39
39
|
* Delete a specific resource by ID.
|
|
40
40
|
* @param id - The ID of the resource to delete.
|
|
@@ -88,38 +88,13 @@ declare class Proxy {
|
|
|
88
88
|
private get headers();
|
|
89
89
|
constructor(apiKey: string, connectionId: string);
|
|
90
90
|
private buildUrl;
|
|
91
|
-
get(path: string,
|
|
92
|
-
post(path: string, body
|
|
93
|
-
put(path: string, body
|
|
94
|
-
patch(path: string, body
|
|
91
|
+
get(path: string, headers?: Record<string, string>): Promise<Response>;
|
|
92
|
+
post(path: string, body: BodyInit, headers?: Record<string, string>): Promise<Response>;
|
|
93
|
+
put(path: string, body: BodyInit, headers?: Record<string, string>): Promise<Response>;
|
|
94
|
+
patch(path: string, body: BodyInit, headers?: Record<string, string>): Promise<Response>;
|
|
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
|
-
redirectUri?: string;
|
|
103
|
-
}
|
|
104
|
-
interface SessionCreateResponse {
|
|
105
|
-
token: string;
|
|
106
|
-
auth_url: string;
|
|
107
|
-
expires_in: number;
|
|
108
|
-
external_id?: string;
|
|
109
|
-
}
|
|
110
|
-
declare class Sessions {
|
|
111
|
-
private apiKey;
|
|
112
|
-
constructor(apiKey: string);
|
|
113
|
-
private get headers();
|
|
114
|
-
/**
|
|
115
|
-
* Create a new session.
|
|
116
|
-
* @param params - The session creation parameters.
|
|
117
|
-
* @returns A promise that resolves to the created session details.
|
|
118
|
-
* @throws If the fetch request fails.
|
|
119
|
-
*/
|
|
120
|
-
create(params: SessionCreateRequest): Promise<SessionCreateResponse>;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
98
|
interface Params {
|
|
124
99
|
limit?: number;
|
|
125
100
|
after?: string;
|
|
@@ -127,7 +102,7 @@ interface Params {
|
|
|
127
102
|
}
|
|
128
103
|
interface Response$1<T> {
|
|
129
104
|
data: T;
|
|
130
|
-
_raw?:
|
|
105
|
+
_raw?: unknown;
|
|
131
106
|
metadata: {
|
|
132
107
|
next: string | null;
|
|
133
108
|
};
|
|
@@ -139,7 +114,7 @@ declare abstract class Base {
|
|
|
139
114
|
private version;
|
|
140
115
|
protected abstract namespace: string;
|
|
141
116
|
protected get headers(): Record<string, string>;
|
|
142
|
-
protected buildUrl(path?: string | null, searchParams?: Record<string,
|
|
117
|
+
protected buildUrl(path?: string | null, searchParams?: Record<string, string | number | undefined>): URL;
|
|
143
118
|
constructor(apiKey: string, connectionId: string);
|
|
144
119
|
}
|
|
145
120
|
|
|
@@ -271,10 +246,6 @@ declare class BundleUp {
|
|
|
271
246
|
* Access the Webhooks resource.
|
|
272
247
|
*/
|
|
273
248
|
get webhooks(): Webhooks;
|
|
274
|
-
/**
|
|
275
|
-
* Access the Sessions resource.
|
|
276
|
-
*/
|
|
277
|
-
get sessions(): Sessions;
|
|
278
249
|
/**
|
|
279
250
|
* Create a Proxy instance for a specific connection.
|
|
280
251
|
* @param connectionId - The ID of the connection.
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ declare abstract class Base$1<T> {
|
|
|
4
4
|
private baseUrl;
|
|
5
5
|
private version;
|
|
6
6
|
constructor(apiKey: string);
|
|
7
|
-
protected buildUrl(path?: string | null, searchParams?: Record<string,
|
|
7
|
+
protected buildUrl(path?: string | null, searchParams?: Record<string, string>): URL;
|
|
8
8
|
protected get headers(): Record<string, string>;
|
|
9
9
|
/**
|
|
10
10
|
* List resources with optional query parameters.
|
|
@@ -12,14 +12,14 @@ declare abstract class Base$1<T> {
|
|
|
12
12
|
* @returns A promise that resolves to an array of resources.
|
|
13
13
|
* @throws If params is not an object or if the fetch request fails.
|
|
14
14
|
*/
|
|
15
|
-
list<K extends Record<string,
|
|
15
|
+
list<K extends Record<string, string>>(searchParams?: K): Promise<T[]>;
|
|
16
16
|
/**
|
|
17
17
|
* Create a new resource.
|
|
18
18
|
* @param body - The request body containing resource details.
|
|
19
19
|
* @returns A promise that resolves to the created resource.
|
|
20
20
|
* @throws If body is not an object or if the fetch request fails.
|
|
21
21
|
*/
|
|
22
|
-
create<K extends Record<string,
|
|
22
|
+
create<K extends Record<string, unknown>>(body: K): Promise<T>;
|
|
23
23
|
/**
|
|
24
24
|
* Retrieve a specific resource by ID.
|
|
25
25
|
* @param id - The ID of the resource to retrieve.
|
|
@@ -34,7 +34,7 @@ declare abstract class Base$1<T> {
|
|
|
34
34
|
* @returns A promise that resolves to the updated resource.
|
|
35
35
|
* @throws If id is not provided, if body is not an object, or if the fetch request fails.
|
|
36
36
|
*/
|
|
37
|
-
update<K extends Record<string,
|
|
37
|
+
update<K extends Record<string, unknown>>(id: string, body: K): Promise<T>;
|
|
38
38
|
/**
|
|
39
39
|
* Delete a specific resource by ID.
|
|
40
40
|
* @param id - The ID of the resource to delete.
|
|
@@ -88,38 +88,13 @@ declare class Proxy {
|
|
|
88
88
|
private get headers();
|
|
89
89
|
constructor(apiKey: string, connectionId: string);
|
|
90
90
|
private buildUrl;
|
|
91
|
-
get(path: string,
|
|
92
|
-
post(path: string, body
|
|
93
|
-
put(path: string, body
|
|
94
|
-
patch(path: string, body
|
|
91
|
+
get(path: string, headers?: Record<string, string>): Promise<Response>;
|
|
92
|
+
post(path: string, body: BodyInit, headers?: Record<string, string>): Promise<Response>;
|
|
93
|
+
put(path: string, body: BodyInit, headers?: Record<string, string>): Promise<Response>;
|
|
94
|
+
patch(path: string, body: BodyInit, headers?: Record<string, string>): Promise<Response>;
|
|
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
|
-
redirectUri?: string;
|
|
103
|
-
}
|
|
104
|
-
interface SessionCreateResponse {
|
|
105
|
-
token: string;
|
|
106
|
-
auth_url: string;
|
|
107
|
-
expires_in: number;
|
|
108
|
-
external_id?: string;
|
|
109
|
-
}
|
|
110
|
-
declare class Sessions {
|
|
111
|
-
private apiKey;
|
|
112
|
-
constructor(apiKey: string);
|
|
113
|
-
private get headers();
|
|
114
|
-
/**
|
|
115
|
-
* Create a new session.
|
|
116
|
-
* @param params - The session creation parameters.
|
|
117
|
-
* @returns A promise that resolves to the created session details.
|
|
118
|
-
* @throws If the fetch request fails.
|
|
119
|
-
*/
|
|
120
|
-
create(params: SessionCreateRequest): Promise<SessionCreateResponse>;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
98
|
interface Params {
|
|
124
99
|
limit?: number;
|
|
125
100
|
after?: string;
|
|
@@ -127,7 +102,7 @@ interface Params {
|
|
|
127
102
|
}
|
|
128
103
|
interface Response$1<T> {
|
|
129
104
|
data: T;
|
|
130
|
-
_raw?:
|
|
105
|
+
_raw?: unknown;
|
|
131
106
|
metadata: {
|
|
132
107
|
next: string | null;
|
|
133
108
|
};
|
|
@@ -139,7 +114,7 @@ declare abstract class Base {
|
|
|
139
114
|
private version;
|
|
140
115
|
protected abstract namespace: string;
|
|
141
116
|
protected get headers(): Record<string, string>;
|
|
142
|
-
protected buildUrl(path?: string | null, searchParams?: Record<string,
|
|
117
|
+
protected buildUrl(path?: string | null, searchParams?: Record<string, string | number | undefined>): URL;
|
|
143
118
|
constructor(apiKey: string, connectionId: string);
|
|
144
119
|
}
|
|
145
120
|
|
|
@@ -271,10 +246,6 @@ declare class BundleUp {
|
|
|
271
246
|
* Access the Webhooks resource.
|
|
272
247
|
*/
|
|
273
248
|
get webhooks(): Webhooks;
|
|
274
|
-
/**
|
|
275
|
-
* Access the Sessions resource.
|
|
276
|
-
*/
|
|
277
|
-
get sessions(): Sessions;
|
|
278
249
|
/**
|
|
279
250
|
* Create a Proxy instance for a specific connection.
|
|
280
251
|
* @param connectionId - The ID of the connection.
|
package/dist/index.js
CHANGED
|
@@ -76,9 +76,7 @@ var Base = class {
|
|
|
76
76
|
headers: this.headers
|
|
77
77
|
});
|
|
78
78
|
if (!response.ok) {
|
|
79
|
-
throw new Error(
|
|
80
|
-
`Failed to fetch ${url.toString()}: ${response.statusText}`
|
|
81
|
-
);
|
|
79
|
+
throw new Error(`Failed to fetch ${url.toString()}: ${response.statusText}`);
|
|
82
80
|
}
|
|
83
81
|
const data = await response.json();
|
|
84
82
|
return data;
|
|
@@ -100,9 +98,7 @@ var Base = class {
|
|
|
100
98
|
body: JSON.stringify(body)
|
|
101
99
|
});
|
|
102
100
|
if (!response.ok) {
|
|
103
|
-
throw new Error(
|
|
104
|
-
`Failed to create ${url.toString()}: ${response.statusText}`
|
|
105
|
-
);
|
|
101
|
+
throw new Error(`Failed to create ${url.toString()}: ${response.statusText}`);
|
|
106
102
|
}
|
|
107
103
|
const data = await response.json();
|
|
108
104
|
return data;
|
|
@@ -123,9 +119,7 @@ var Base = class {
|
|
|
123
119
|
headers: this.headers
|
|
124
120
|
});
|
|
125
121
|
if (!response.ok) {
|
|
126
|
-
throw new Error(
|
|
127
|
-
`Failed to retrieve ${url.toString()}: ${response.statusText}`
|
|
128
|
-
);
|
|
122
|
+
throw new Error(`Failed to retrieve ${url.toString()}: ${response.statusText}`);
|
|
129
123
|
}
|
|
130
124
|
const data = await response.json();
|
|
131
125
|
return data;
|
|
@@ -151,9 +145,7 @@ var Base = class {
|
|
|
151
145
|
body: JSON.stringify(body)
|
|
152
146
|
});
|
|
153
147
|
if (!response.ok) {
|
|
154
|
-
throw new Error(
|
|
155
|
-
`Failed to update ${url.toString()}: ${response.statusText}`
|
|
156
|
-
);
|
|
148
|
+
throw new Error(`Failed to update ${url.toString()}: ${response.statusText}`);
|
|
157
149
|
}
|
|
158
150
|
const data = await response.json();
|
|
159
151
|
return data;
|
|
@@ -174,9 +166,7 @@ var Base = class {
|
|
|
174
166
|
headers: this.headers
|
|
175
167
|
});
|
|
176
168
|
if (!response.ok) {
|
|
177
|
-
throw new Error(
|
|
178
|
-
`Failed to delete ${url.toString()}: ${response.statusText}`
|
|
179
|
-
);
|
|
169
|
+
throw new Error(`Failed to delete ${url.toString()}: ${response.statusText}`);
|
|
180
170
|
}
|
|
181
171
|
}
|
|
182
172
|
};
|
|
@@ -219,85 +209,69 @@ var Proxy2 = class {
|
|
|
219
209
|
"BU-Connection-Id": this.connectionId
|
|
220
210
|
};
|
|
221
211
|
}
|
|
222
|
-
buildUrl(path
|
|
212
|
+
buildUrl(path) {
|
|
223
213
|
if (!path) {
|
|
224
214
|
throw new Error("Path is required to build URL.");
|
|
225
215
|
}
|
|
226
|
-
if (!isObject(searchParams)) {
|
|
227
|
-
throw new Error("URL search params must be an object.");
|
|
228
|
-
}
|
|
229
216
|
if (!path.startsWith("/")) {
|
|
230
217
|
path = `/${path}`;
|
|
231
218
|
}
|
|
232
219
|
const url = new URL(path, this.baseUrl);
|
|
233
|
-
url.search = new URLSearchParams(searchParams).toString();
|
|
234
220
|
return url;
|
|
235
221
|
}
|
|
236
|
-
get(path,
|
|
222
|
+
get(path, headers = {}) {
|
|
237
223
|
if (!path) {
|
|
238
224
|
throw new Error("Path is required for GET request.");
|
|
239
225
|
}
|
|
240
226
|
if (!isObject(headers)) {
|
|
241
227
|
throw new Error("Headers must be an object.");
|
|
242
228
|
}
|
|
243
|
-
|
|
244
|
-
throw new Error("URL search params must be an object.");
|
|
245
|
-
}
|
|
246
|
-
const url = this.buildUrl(path, searchParams);
|
|
229
|
+
const url = this.buildUrl(path);
|
|
247
230
|
return fetch(url, {
|
|
248
231
|
method: "GET",
|
|
249
232
|
headers: { ...this.headers, ...headers }
|
|
250
233
|
});
|
|
251
234
|
}
|
|
252
|
-
post(path, body
|
|
235
|
+
post(path, body, headers = {}) {
|
|
253
236
|
if (!path) {
|
|
254
237
|
throw new Error("Path is required for POST request.");
|
|
255
238
|
}
|
|
256
239
|
if (!isObject(headers)) {
|
|
257
240
|
throw new Error("Headers must be an object.");
|
|
258
241
|
}
|
|
259
|
-
if (!isObject(body)) {
|
|
260
|
-
throw new Error("Request body must be an object.");
|
|
261
|
-
}
|
|
262
242
|
const url = this.buildUrl(path);
|
|
263
243
|
return fetch(url, {
|
|
244
|
+
body,
|
|
264
245
|
method: "POST",
|
|
265
|
-
headers: { ...this.headers, ...headers }
|
|
266
|
-
body: JSON.stringify(body)
|
|
246
|
+
headers: { ...this.headers, ...headers }
|
|
267
247
|
});
|
|
268
248
|
}
|
|
269
|
-
put(path, body
|
|
249
|
+
put(path, body, headers = {}) {
|
|
270
250
|
if (!path) {
|
|
271
251
|
throw new Error("Path is required for PUT request.");
|
|
272
252
|
}
|
|
273
253
|
if (!isObject(headers)) {
|
|
274
254
|
throw new Error("Headers must be an object.");
|
|
275
255
|
}
|
|
276
|
-
if (!isObject(body)) {
|
|
277
|
-
throw new Error("Request body must be an object.");
|
|
278
|
-
}
|
|
279
256
|
const url = this.buildUrl(path);
|
|
280
257
|
return fetch(url, {
|
|
258
|
+
body,
|
|
281
259
|
method: "PUT",
|
|
282
|
-
headers: { ...this.headers, ...headers }
|
|
283
|
-
body: JSON.stringify(body)
|
|
260
|
+
headers: { ...this.headers, ...headers }
|
|
284
261
|
});
|
|
285
262
|
}
|
|
286
|
-
patch(path, body
|
|
263
|
+
patch(path, body, headers = {}) {
|
|
287
264
|
if (!path) {
|
|
288
265
|
throw new Error("Path is required for PATCH request.");
|
|
289
266
|
}
|
|
290
267
|
if (!isObject(headers)) {
|
|
291
268
|
throw new Error("Headers must be an object.");
|
|
292
269
|
}
|
|
293
|
-
if (!isObject(body)) {
|
|
294
|
-
throw new Error("Request body must be an object.");
|
|
295
|
-
}
|
|
296
270
|
const url = this.buildUrl(path);
|
|
297
271
|
return fetch(url, {
|
|
272
|
+
body,
|
|
298
273
|
method: "PATCH",
|
|
299
|
-
headers: { ...this.headers, ...headers }
|
|
300
|
-
body: JSON.stringify(body)
|
|
274
|
+
headers: { ...this.headers, ...headers }
|
|
301
275
|
});
|
|
302
276
|
}
|
|
303
277
|
delete(path, headers = {}) {
|
|
@@ -315,37 +289,6 @@ var Proxy2 = class {
|
|
|
315
289
|
}
|
|
316
290
|
};
|
|
317
291
|
|
|
318
|
-
// src/session.ts
|
|
319
|
-
var Sessions = class {
|
|
320
|
-
constructor(apiKey) {
|
|
321
|
-
this.apiKey = apiKey;
|
|
322
|
-
}
|
|
323
|
-
get headers() {
|
|
324
|
-
return {
|
|
325
|
-
"Content-Type": "application/json",
|
|
326
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* Create a new session.
|
|
331
|
-
* @param params - The session creation parameters.
|
|
332
|
-
* @returns A promise that resolves to the created session details.
|
|
333
|
-
* @throws If the fetch request fails.
|
|
334
|
-
*/
|
|
335
|
-
async create(params) {
|
|
336
|
-
const response = await fetch("https://api.bundleup.io/v1/sessions", {
|
|
337
|
-
method: "POST",
|
|
338
|
-
headers: this.headers,
|
|
339
|
-
body: JSON.stringify(params)
|
|
340
|
-
});
|
|
341
|
-
if (!response.ok) {
|
|
342
|
-
throw new Error("Failed to create session");
|
|
343
|
-
}
|
|
344
|
-
const data = await response.json();
|
|
345
|
-
return data;
|
|
346
|
-
}
|
|
347
|
-
};
|
|
348
|
-
|
|
349
292
|
// src/unify/base.ts
|
|
350
293
|
var Base2 = class {
|
|
351
294
|
constructor(apiKey, connectionId) {
|
|
@@ -366,17 +309,17 @@ var Base2 = class {
|
|
|
366
309
|
throw new Error("URL search params must be an object.");
|
|
367
310
|
}
|
|
368
311
|
const parts = [this.version, this.namespace, path].filter(Boolean).join("/");
|
|
369
|
-
|
|
312
|
+
const parsedSearchParams = Object.entries(searchParams).reduce(
|
|
370
313
|
(acc, [key, value]) => {
|
|
371
314
|
if (value !== void 0 && value !== null) {
|
|
372
|
-
acc[key] = value;
|
|
315
|
+
acc[key] = value.toString();
|
|
373
316
|
}
|
|
374
317
|
return acc;
|
|
375
318
|
},
|
|
376
319
|
{}
|
|
377
320
|
);
|
|
378
321
|
const url = new URL(parts, this.baseUrl);
|
|
379
|
-
url.search = new URLSearchParams(
|
|
322
|
+
url.search = new URLSearchParams(parsedSearchParams).toString();
|
|
380
323
|
return url;
|
|
381
324
|
}
|
|
382
325
|
};
|
|
@@ -403,9 +346,7 @@ var Chat = class extends Base2 {
|
|
|
403
346
|
}
|
|
404
347
|
});
|
|
405
348
|
if (!response.ok) {
|
|
406
|
-
throw new Error(
|
|
407
|
-
`Failed to fetch ${url.toString()}: ${response.statusText}`
|
|
408
|
-
);
|
|
349
|
+
throw new Error(`Failed to fetch ${url.toString()}: ${response.statusText}`);
|
|
409
350
|
}
|
|
410
351
|
const data = await response.json();
|
|
411
352
|
return data;
|
|
@@ -434,9 +375,7 @@ var Git = class extends Base2 {
|
|
|
434
375
|
}
|
|
435
376
|
});
|
|
436
377
|
if (!response.ok) {
|
|
437
|
-
throw new Error(
|
|
438
|
-
`Failed to fetch ${url.toString()}: ${response.statusText}`
|
|
439
|
-
);
|
|
378
|
+
throw new Error(`Failed to fetch ${url.toString()}: ${response.statusText}`);
|
|
440
379
|
}
|
|
441
380
|
const data = await response.json();
|
|
442
381
|
return data;
|
|
@@ -465,9 +404,7 @@ var Git = class extends Base2 {
|
|
|
465
404
|
}
|
|
466
405
|
});
|
|
467
406
|
if (!response.ok) {
|
|
468
|
-
throw new Error(
|
|
469
|
-
`Failed to fetch ${url.toString()}: ${response.statusText}`
|
|
470
|
-
);
|
|
407
|
+
throw new Error(`Failed to fetch ${url.toString()}: ${response.statusText}`);
|
|
471
408
|
}
|
|
472
409
|
const data = await response.json();
|
|
473
410
|
return data;
|
|
@@ -496,9 +433,7 @@ var Git = class extends Base2 {
|
|
|
496
433
|
}
|
|
497
434
|
});
|
|
498
435
|
if (!response.ok) {
|
|
499
|
-
throw new Error(
|
|
500
|
-
`Failed to fetch ${url.toString()}: ${response.statusText}`
|
|
501
|
-
);
|
|
436
|
+
throw new Error(`Failed to fetch ${url.toString()}: ${response.statusText}`);
|
|
502
437
|
}
|
|
503
438
|
const data = await response.json();
|
|
504
439
|
return data;
|
|
@@ -516,13 +451,10 @@ var Git = class extends Base2 {
|
|
|
516
451
|
if (!repoName) {
|
|
517
452
|
throw new Error("repoName is required to fetch releases.");
|
|
518
453
|
}
|
|
519
|
-
const url = this.buildUrl(
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
after
|
|
524
|
-
}
|
|
525
|
-
);
|
|
454
|
+
const url = this.buildUrl(`repos/${encodeURIComponent(repoName)}/releases`, {
|
|
455
|
+
limit,
|
|
456
|
+
after
|
|
457
|
+
});
|
|
526
458
|
const response = await fetch(url, {
|
|
527
459
|
headers: {
|
|
528
460
|
...this.headers,
|
|
@@ -530,9 +462,7 @@ var Git = class extends Base2 {
|
|
|
530
462
|
}
|
|
531
463
|
});
|
|
532
464
|
if (!response.ok) {
|
|
533
|
-
throw new Error(
|
|
534
|
-
`Failed to fetch ${url.toString()}: ${response.statusText}`
|
|
535
|
-
);
|
|
465
|
+
throw new Error(`Failed to fetch ${url.toString()}: ${response.statusText}`);
|
|
536
466
|
}
|
|
537
467
|
const data = await response.json();
|
|
538
468
|
return data;
|
|
@@ -561,9 +491,7 @@ var PM = class extends Base2 {
|
|
|
561
491
|
}
|
|
562
492
|
});
|
|
563
493
|
if (!response.ok) {
|
|
564
|
-
throw new Error(
|
|
565
|
-
`Failed to fetch ${url.toString()}: ${response.statusText}`
|
|
566
|
-
);
|
|
494
|
+
throw new Error(`Failed to fetch ${url.toString()}: ${response.statusText}`);
|
|
567
495
|
}
|
|
568
496
|
const data = await response.json();
|
|
569
497
|
return data;
|
|
@@ -596,12 +524,6 @@ var BundleUp = class {
|
|
|
596
524
|
get webhooks() {
|
|
597
525
|
return new Webhooks(this.apiKey);
|
|
598
526
|
}
|
|
599
|
-
/**
|
|
600
|
-
* Access the Sessions resource.
|
|
601
|
-
*/
|
|
602
|
-
get sessions() {
|
|
603
|
-
return new Sessions(this.apiKey);
|
|
604
|
-
}
|
|
605
527
|
/**
|
|
606
528
|
* Create a Proxy instance for a specific connection.
|
|
607
529
|
* @param connectionId - The ID of the connection.
|
package/dist/index.mjs
CHANGED
|
@@ -50,9 +50,7 @@ var Base = class {
|
|
|
50
50
|
headers: this.headers
|
|
51
51
|
});
|
|
52
52
|
if (!response.ok) {
|
|
53
|
-
throw new Error(
|
|
54
|
-
`Failed to fetch ${url.toString()}: ${response.statusText}`
|
|
55
|
-
);
|
|
53
|
+
throw new Error(`Failed to fetch ${url.toString()}: ${response.statusText}`);
|
|
56
54
|
}
|
|
57
55
|
const data = await response.json();
|
|
58
56
|
return data;
|
|
@@ -74,9 +72,7 @@ var Base = class {
|
|
|
74
72
|
body: JSON.stringify(body)
|
|
75
73
|
});
|
|
76
74
|
if (!response.ok) {
|
|
77
|
-
throw new Error(
|
|
78
|
-
`Failed to create ${url.toString()}: ${response.statusText}`
|
|
79
|
-
);
|
|
75
|
+
throw new Error(`Failed to create ${url.toString()}: ${response.statusText}`);
|
|
80
76
|
}
|
|
81
77
|
const data = await response.json();
|
|
82
78
|
return data;
|
|
@@ -97,9 +93,7 @@ var Base = class {
|
|
|
97
93
|
headers: this.headers
|
|
98
94
|
});
|
|
99
95
|
if (!response.ok) {
|
|
100
|
-
throw new Error(
|
|
101
|
-
`Failed to retrieve ${url.toString()}: ${response.statusText}`
|
|
102
|
-
);
|
|
96
|
+
throw new Error(`Failed to retrieve ${url.toString()}: ${response.statusText}`);
|
|
103
97
|
}
|
|
104
98
|
const data = await response.json();
|
|
105
99
|
return data;
|
|
@@ -125,9 +119,7 @@ var Base = class {
|
|
|
125
119
|
body: JSON.stringify(body)
|
|
126
120
|
});
|
|
127
121
|
if (!response.ok) {
|
|
128
|
-
throw new Error(
|
|
129
|
-
`Failed to update ${url.toString()}: ${response.statusText}`
|
|
130
|
-
);
|
|
122
|
+
throw new Error(`Failed to update ${url.toString()}: ${response.statusText}`);
|
|
131
123
|
}
|
|
132
124
|
const data = await response.json();
|
|
133
125
|
return data;
|
|
@@ -148,9 +140,7 @@ var Base = class {
|
|
|
148
140
|
headers: this.headers
|
|
149
141
|
});
|
|
150
142
|
if (!response.ok) {
|
|
151
|
-
throw new Error(
|
|
152
|
-
`Failed to delete ${url.toString()}: ${response.statusText}`
|
|
153
|
-
);
|
|
143
|
+
throw new Error(`Failed to delete ${url.toString()}: ${response.statusText}`);
|
|
154
144
|
}
|
|
155
145
|
}
|
|
156
146
|
};
|
|
@@ -193,85 +183,69 @@ var Proxy = class {
|
|
|
193
183
|
"BU-Connection-Id": this.connectionId
|
|
194
184
|
};
|
|
195
185
|
}
|
|
196
|
-
buildUrl(path
|
|
186
|
+
buildUrl(path) {
|
|
197
187
|
if (!path) {
|
|
198
188
|
throw new Error("Path is required to build URL.");
|
|
199
189
|
}
|
|
200
|
-
if (!isObject(searchParams)) {
|
|
201
|
-
throw new Error("URL search params must be an object.");
|
|
202
|
-
}
|
|
203
190
|
if (!path.startsWith("/")) {
|
|
204
191
|
path = `/${path}`;
|
|
205
192
|
}
|
|
206
193
|
const url = new URL(path, this.baseUrl);
|
|
207
|
-
url.search = new URLSearchParams(searchParams).toString();
|
|
208
194
|
return url;
|
|
209
195
|
}
|
|
210
|
-
get(path,
|
|
196
|
+
get(path, headers = {}) {
|
|
211
197
|
if (!path) {
|
|
212
198
|
throw new Error("Path is required for GET request.");
|
|
213
199
|
}
|
|
214
200
|
if (!isObject(headers)) {
|
|
215
201
|
throw new Error("Headers must be an object.");
|
|
216
202
|
}
|
|
217
|
-
|
|
218
|
-
throw new Error("URL search params must be an object.");
|
|
219
|
-
}
|
|
220
|
-
const url = this.buildUrl(path, searchParams);
|
|
203
|
+
const url = this.buildUrl(path);
|
|
221
204
|
return fetch(url, {
|
|
222
205
|
method: "GET",
|
|
223
206
|
headers: { ...this.headers, ...headers }
|
|
224
207
|
});
|
|
225
208
|
}
|
|
226
|
-
post(path, body
|
|
209
|
+
post(path, body, headers = {}) {
|
|
227
210
|
if (!path) {
|
|
228
211
|
throw new Error("Path is required for POST request.");
|
|
229
212
|
}
|
|
230
213
|
if (!isObject(headers)) {
|
|
231
214
|
throw new Error("Headers must be an object.");
|
|
232
215
|
}
|
|
233
|
-
if (!isObject(body)) {
|
|
234
|
-
throw new Error("Request body must be an object.");
|
|
235
|
-
}
|
|
236
216
|
const url = this.buildUrl(path);
|
|
237
217
|
return fetch(url, {
|
|
218
|
+
body,
|
|
238
219
|
method: "POST",
|
|
239
|
-
headers: { ...this.headers, ...headers }
|
|
240
|
-
body: JSON.stringify(body)
|
|
220
|
+
headers: { ...this.headers, ...headers }
|
|
241
221
|
});
|
|
242
222
|
}
|
|
243
|
-
put(path, body
|
|
223
|
+
put(path, body, headers = {}) {
|
|
244
224
|
if (!path) {
|
|
245
225
|
throw new Error("Path is required for PUT request.");
|
|
246
226
|
}
|
|
247
227
|
if (!isObject(headers)) {
|
|
248
228
|
throw new Error("Headers must be an object.");
|
|
249
229
|
}
|
|
250
|
-
if (!isObject(body)) {
|
|
251
|
-
throw new Error("Request body must be an object.");
|
|
252
|
-
}
|
|
253
230
|
const url = this.buildUrl(path);
|
|
254
231
|
return fetch(url, {
|
|
232
|
+
body,
|
|
255
233
|
method: "PUT",
|
|
256
|
-
headers: { ...this.headers, ...headers }
|
|
257
|
-
body: JSON.stringify(body)
|
|
234
|
+
headers: { ...this.headers, ...headers }
|
|
258
235
|
});
|
|
259
236
|
}
|
|
260
|
-
patch(path, body
|
|
237
|
+
patch(path, body, headers = {}) {
|
|
261
238
|
if (!path) {
|
|
262
239
|
throw new Error("Path is required for PATCH request.");
|
|
263
240
|
}
|
|
264
241
|
if (!isObject(headers)) {
|
|
265
242
|
throw new Error("Headers must be an object.");
|
|
266
243
|
}
|
|
267
|
-
if (!isObject(body)) {
|
|
268
|
-
throw new Error("Request body must be an object.");
|
|
269
|
-
}
|
|
270
244
|
const url = this.buildUrl(path);
|
|
271
245
|
return fetch(url, {
|
|
246
|
+
body,
|
|
272
247
|
method: "PATCH",
|
|
273
|
-
headers: { ...this.headers, ...headers }
|
|
274
|
-
body: JSON.stringify(body)
|
|
248
|
+
headers: { ...this.headers, ...headers }
|
|
275
249
|
});
|
|
276
250
|
}
|
|
277
251
|
delete(path, headers = {}) {
|
|
@@ -289,37 +263,6 @@ var Proxy = class {
|
|
|
289
263
|
}
|
|
290
264
|
};
|
|
291
265
|
|
|
292
|
-
// src/session.ts
|
|
293
|
-
var Sessions = class {
|
|
294
|
-
constructor(apiKey) {
|
|
295
|
-
this.apiKey = apiKey;
|
|
296
|
-
}
|
|
297
|
-
get headers() {
|
|
298
|
-
return {
|
|
299
|
-
"Content-Type": "application/json",
|
|
300
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Create a new session.
|
|
305
|
-
* @param params - The session creation parameters.
|
|
306
|
-
* @returns A promise that resolves to the created session details.
|
|
307
|
-
* @throws If the fetch request fails.
|
|
308
|
-
*/
|
|
309
|
-
async create(params) {
|
|
310
|
-
const response = await fetch("https://api.bundleup.io/v1/sessions", {
|
|
311
|
-
method: "POST",
|
|
312
|
-
headers: this.headers,
|
|
313
|
-
body: JSON.stringify(params)
|
|
314
|
-
});
|
|
315
|
-
if (!response.ok) {
|
|
316
|
-
throw new Error("Failed to create session");
|
|
317
|
-
}
|
|
318
|
-
const data = await response.json();
|
|
319
|
-
return data;
|
|
320
|
-
}
|
|
321
|
-
};
|
|
322
|
-
|
|
323
266
|
// src/unify/base.ts
|
|
324
267
|
var Base2 = class {
|
|
325
268
|
constructor(apiKey, connectionId) {
|
|
@@ -340,17 +283,17 @@ var Base2 = class {
|
|
|
340
283
|
throw new Error("URL search params must be an object.");
|
|
341
284
|
}
|
|
342
285
|
const parts = [this.version, this.namespace, path].filter(Boolean).join("/");
|
|
343
|
-
|
|
286
|
+
const parsedSearchParams = Object.entries(searchParams).reduce(
|
|
344
287
|
(acc, [key, value]) => {
|
|
345
288
|
if (value !== void 0 && value !== null) {
|
|
346
|
-
acc[key] = value;
|
|
289
|
+
acc[key] = value.toString();
|
|
347
290
|
}
|
|
348
291
|
return acc;
|
|
349
292
|
},
|
|
350
293
|
{}
|
|
351
294
|
);
|
|
352
295
|
const url = new URL(parts, this.baseUrl);
|
|
353
|
-
url.search = new URLSearchParams(
|
|
296
|
+
url.search = new URLSearchParams(parsedSearchParams).toString();
|
|
354
297
|
return url;
|
|
355
298
|
}
|
|
356
299
|
};
|
|
@@ -377,9 +320,7 @@ var Chat = class extends Base2 {
|
|
|
377
320
|
}
|
|
378
321
|
});
|
|
379
322
|
if (!response.ok) {
|
|
380
|
-
throw new Error(
|
|
381
|
-
`Failed to fetch ${url.toString()}: ${response.statusText}`
|
|
382
|
-
);
|
|
323
|
+
throw new Error(`Failed to fetch ${url.toString()}: ${response.statusText}`);
|
|
383
324
|
}
|
|
384
325
|
const data = await response.json();
|
|
385
326
|
return data;
|
|
@@ -408,9 +349,7 @@ var Git = class extends Base2 {
|
|
|
408
349
|
}
|
|
409
350
|
});
|
|
410
351
|
if (!response.ok) {
|
|
411
|
-
throw new Error(
|
|
412
|
-
`Failed to fetch ${url.toString()}: ${response.statusText}`
|
|
413
|
-
);
|
|
352
|
+
throw new Error(`Failed to fetch ${url.toString()}: ${response.statusText}`);
|
|
414
353
|
}
|
|
415
354
|
const data = await response.json();
|
|
416
355
|
return data;
|
|
@@ -439,9 +378,7 @@ var Git = class extends Base2 {
|
|
|
439
378
|
}
|
|
440
379
|
});
|
|
441
380
|
if (!response.ok) {
|
|
442
|
-
throw new Error(
|
|
443
|
-
`Failed to fetch ${url.toString()}: ${response.statusText}`
|
|
444
|
-
);
|
|
381
|
+
throw new Error(`Failed to fetch ${url.toString()}: ${response.statusText}`);
|
|
445
382
|
}
|
|
446
383
|
const data = await response.json();
|
|
447
384
|
return data;
|
|
@@ -470,9 +407,7 @@ var Git = class extends Base2 {
|
|
|
470
407
|
}
|
|
471
408
|
});
|
|
472
409
|
if (!response.ok) {
|
|
473
|
-
throw new Error(
|
|
474
|
-
`Failed to fetch ${url.toString()}: ${response.statusText}`
|
|
475
|
-
);
|
|
410
|
+
throw new Error(`Failed to fetch ${url.toString()}: ${response.statusText}`);
|
|
476
411
|
}
|
|
477
412
|
const data = await response.json();
|
|
478
413
|
return data;
|
|
@@ -490,13 +425,10 @@ var Git = class extends Base2 {
|
|
|
490
425
|
if (!repoName) {
|
|
491
426
|
throw new Error("repoName is required to fetch releases.");
|
|
492
427
|
}
|
|
493
|
-
const url = this.buildUrl(
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
after
|
|
498
|
-
}
|
|
499
|
-
);
|
|
428
|
+
const url = this.buildUrl(`repos/${encodeURIComponent(repoName)}/releases`, {
|
|
429
|
+
limit,
|
|
430
|
+
after
|
|
431
|
+
});
|
|
500
432
|
const response = await fetch(url, {
|
|
501
433
|
headers: {
|
|
502
434
|
...this.headers,
|
|
@@ -504,9 +436,7 @@ var Git = class extends Base2 {
|
|
|
504
436
|
}
|
|
505
437
|
});
|
|
506
438
|
if (!response.ok) {
|
|
507
|
-
throw new Error(
|
|
508
|
-
`Failed to fetch ${url.toString()}: ${response.statusText}`
|
|
509
|
-
);
|
|
439
|
+
throw new Error(`Failed to fetch ${url.toString()}: ${response.statusText}`);
|
|
510
440
|
}
|
|
511
441
|
const data = await response.json();
|
|
512
442
|
return data;
|
|
@@ -535,9 +465,7 @@ var PM = class extends Base2 {
|
|
|
535
465
|
}
|
|
536
466
|
});
|
|
537
467
|
if (!response.ok) {
|
|
538
|
-
throw new Error(
|
|
539
|
-
`Failed to fetch ${url.toString()}: ${response.statusText}`
|
|
540
|
-
);
|
|
468
|
+
throw new Error(`Failed to fetch ${url.toString()}: ${response.statusText}`);
|
|
541
469
|
}
|
|
542
470
|
const data = await response.json();
|
|
543
471
|
return data;
|
|
@@ -570,12 +498,6 @@ var BundleUp = class {
|
|
|
570
498
|
get webhooks() {
|
|
571
499
|
return new Webhooks(this.apiKey);
|
|
572
500
|
}
|
|
573
|
-
/**
|
|
574
|
-
* Access the Sessions resource.
|
|
575
|
-
*/
|
|
576
|
-
get sessions() {
|
|
577
|
-
return new Sessions(this.apiKey);
|
|
578
|
-
}
|
|
579
501
|
/**
|
|
580
502
|
* Create a Proxy instance for a specific connection.
|
|
581
503
|
* @param connectionId - The ID of the connection.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bundleup/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"description": "SDK package for BundleUp",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
14
14
|
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
15
|
-
"lint": "eslint src
|
|
15
|
+
"lint": "eslint src",
|
|
16
16
|
"test": "jest",
|
|
17
17
|
"clean": "rm -rf dist"
|
|
18
18
|
},
|
|
@@ -21,8 +21,7 @@
|
|
|
21
21
|
"jest": "^29.0.0",
|
|
22
22
|
"ts-jest": "^29.1.0",
|
|
23
23
|
"tsup": "^7.0.0",
|
|
24
|
-
"typescript": "^5.0.0"
|
|
25
|
-
"eslint": "^8.0.0"
|
|
24
|
+
"typescript": "^5.0.0"
|
|
26
25
|
},
|
|
27
26
|
"files": [
|
|
28
27
|
"dist"
|