@bundleup/sdk 0.0.13 → 0.0.14
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 +106 -5
- package/dist/index.d.ts +106 -5
- package/dist/index.js +165 -1
- package/dist/index.mjs +165 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
declare abstract class Base<T> {
|
|
1
|
+
declare abstract class Base$1<T> {
|
|
2
2
|
private apiKey;
|
|
3
3
|
protected abstract namespace: string;
|
|
4
4
|
private baseUrl;
|
|
5
5
|
private version;
|
|
6
6
|
constructor(apiKey: string);
|
|
7
|
-
|
|
7
|
+
protected buildUrl(path?: string | null, searchParams?: Record<string, any>): URL;
|
|
8
8
|
protected get headers(): Record<string, string>;
|
|
9
9
|
/**
|
|
10
10
|
* List resources with optional query parameters.
|
|
@@ -54,7 +54,7 @@ interface Connection {
|
|
|
54
54
|
createdAt: Date;
|
|
55
55
|
updatedAt: Date;
|
|
56
56
|
}
|
|
57
|
-
declare class Connections extends Base<Connection> {
|
|
57
|
+
declare class Connections extends Base$1<Connection> {
|
|
58
58
|
protected namespace: string;
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -64,7 +64,7 @@ interface Integration {
|
|
|
64
64
|
createdAt: Date;
|
|
65
65
|
updatedAt: Date;
|
|
66
66
|
}
|
|
67
|
-
declare class Integrations extends Base<Integration> {
|
|
67
|
+
declare class Integrations extends Base$1<Integration> {
|
|
68
68
|
protected namespace: string;
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -77,7 +77,7 @@ interface Webhook {
|
|
|
77
77
|
updatedAt: Date;
|
|
78
78
|
lastTriggeredAt?: Date;
|
|
79
79
|
}
|
|
80
|
-
declare class Webhooks extends Base<Webhook> {
|
|
80
|
+
declare class Webhooks extends Base$1<Webhook> {
|
|
81
81
|
protected namespace: string;
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -120,6 +120,98 @@ declare class Sessions {
|
|
|
120
120
|
create(params: SessionCreateRequest): Promise<SessionCreateResponse>;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
interface Params {
|
|
124
|
+
limit?: number;
|
|
125
|
+
after?: string;
|
|
126
|
+
includeRaw?: boolean;
|
|
127
|
+
}
|
|
128
|
+
interface Response$1<T> {
|
|
129
|
+
data: T;
|
|
130
|
+
_raw?: any;
|
|
131
|
+
pageInfo: {
|
|
132
|
+
next: string | null;
|
|
133
|
+
limit: number;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
declare abstract class Base {
|
|
137
|
+
private apiKey;
|
|
138
|
+
private connectionId;
|
|
139
|
+
private baseUrl;
|
|
140
|
+
private version;
|
|
141
|
+
protected abstract namespace: string;
|
|
142
|
+
protected get headers(): Record<string, string>;
|
|
143
|
+
protected buildUrl(path?: string | null, searchParams?: Record<string, any>): URL;
|
|
144
|
+
constructor(apiKey: string, connectionId: string);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
declare class Chat extends Base {
|
|
148
|
+
protected namespace: string;
|
|
149
|
+
/**
|
|
150
|
+
* Fetch chat channels with optional query parameters.
|
|
151
|
+
* @param limit - Maximum number of channels to retrieve.
|
|
152
|
+
* @param after - Cursor for pagination.
|
|
153
|
+
* @param includeRaw - Whether to include raw response data.
|
|
154
|
+
* @returns A promise that resolves to the fetch response.
|
|
155
|
+
*/
|
|
156
|
+
channels({ limit, after, includeRaw }?: Params): Promise<Response$1<{
|
|
157
|
+
id: string;
|
|
158
|
+
name: string;
|
|
159
|
+
}[]>>;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
interface RepoParams extends Params {
|
|
163
|
+
repoName: string;
|
|
164
|
+
}
|
|
165
|
+
declare class Git extends Base {
|
|
166
|
+
protected namespace: string;
|
|
167
|
+
/**
|
|
168
|
+
* Fetch repositories with optional query parameters.
|
|
169
|
+
* @param limit - Maximum number of repositories to retrieve.
|
|
170
|
+
* @param after - Cursor for pagination.
|
|
171
|
+
* @param includeRaw - Whether to include raw response data.
|
|
172
|
+
* @returns A promise that resolves to the fetch response.
|
|
173
|
+
*/
|
|
174
|
+
repos({ limit, after, includeRaw }?: Params): Promise<Response$1<{
|
|
175
|
+
id: string;
|
|
176
|
+
name: string;
|
|
177
|
+
full_name: string;
|
|
178
|
+
description: string | null;
|
|
179
|
+
created_at: string;
|
|
180
|
+
updated_at: string;
|
|
181
|
+
}[]>>;
|
|
182
|
+
/**
|
|
183
|
+
* Fetch pull requests for a specific repository.
|
|
184
|
+
* @param repoName - The name of the repository.
|
|
185
|
+
* @param limit - Maximum number of pull requests to retrieve.
|
|
186
|
+
* @param after - Cursor for pagination.
|
|
187
|
+
* @param includeRaw - Whether to include raw response data.
|
|
188
|
+
* @returns A promise that resolves to the fetch response.
|
|
189
|
+
* @throws If repoName is not provided.
|
|
190
|
+
*/
|
|
191
|
+
pulls({ repoName, limit, after, includeRaw }: RepoParams): Promise<Response$1<{
|
|
192
|
+
id: string;
|
|
193
|
+
number: number;
|
|
194
|
+
title: string;
|
|
195
|
+
state: string;
|
|
196
|
+
created_at: string;
|
|
197
|
+
updated_at: string;
|
|
198
|
+
merged_at: string | null;
|
|
199
|
+
}[]>>;
|
|
200
|
+
/**
|
|
201
|
+
* Fetch tags for a specific repository.
|
|
202
|
+
* @param repoName - The name of the repository.
|
|
203
|
+
* @param limit - Maximum number of tags to retrieve.
|
|
204
|
+
* @param after - Cursor for pagination.
|
|
205
|
+
* @param includeRaw - Whether to include raw response data.
|
|
206
|
+
* @returns A promise that resolves to the fetch response.
|
|
207
|
+
* @throws If repoName is not provided.
|
|
208
|
+
*/
|
|
209
|
+
tags({ repoName, limit, after, includeRaw }: RepoParams): Promise<Response$1<{
|
|
210
|
+
name: string;
|
|
211
|
+
commit_sha: string;
|
|
212
|
+
}[]>>;
|
|
213
|
+
}
|
|
214
|
+
|
|
123
215
|
declare class BundleUp {
|
|
124
216
|
private apiKey;
|
|
125
217
|
constructor(apiKey: string);
|
|
@@ -145,6 +237,15 @@ declare class BundleUp {
|
|
|
145
237
|
* @returns A Proxy instance.
|
|
146
238
|
*/
|
|
147
239
|
proxy(connectionId: string): Proxy;
|
|
240
|
+
/**
|
|
241
|
+
* Access Unify API for a specific connection.
|
|
242
|
+
* @param connectionId - The ID of the connection.
|
|
243
|
+
* @returns An object containing Unify methods.
|
|
244
|
+
*/
|
|
245
|
+
unify(connectionId: string): {
|
|
246
|
+
chat: Chat;
|
|
247
|
+
git: Git;
|
|
248
|
+
};
|
|
148
249
|
}
|
|
149
250
|
|
|
150
251
|
export { BundleUp };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
declare abstract class Base<T> {
|
|
1
|
+
declare abstract class Base$1<T> {
|
|
2
2
|
private apiKey;
|
|
3
3
|
protected abstract namespace: string;
|
|
4
4
|
private baseUrl;
|
|
5
5
|
private version;
|
|
6
6
|
constructor(apiKey: string);
|
|
7
|
-
|
|
7
|
+
protected buildUrl(path?: string | null, searchParams?: Record<string, any>): URL;
|
|
8
8
|
protected get headers(): Record<string, string>;
|
|
9
9
|
/**
|
|
10
10
|
* List resources with optional query parameters.
|
|
@@ -54,7 +54,7 @@ interface Connection {
|
|
|
54
54
|
createdAt: Date;
|
|
55
55
|
updatedAt: Date;
|
|
56
56
|
}
|
|
57
|
-
declare class Connections extends Base<Connection> {
|
|
57
|
+
declare class Connections extends Base$1<Connection> {
|
|
58
58
|
protected namespace: string;
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -64,7 +64,7 @@ interface Integration {
|
|
|
64
64
|
createdAt: Date;
|
|
65
65
|
updatedAt: Date;
|
|
66
66
|
}
|
|
67
|
-
declare class Integrations extends Base<Integration> {
|
|
67
|
+
declare class Integrations extends Base$1<Integration> {
|
|
68
68
|
protected namespace: string;
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -77,7 +77,7 @@ interface Webhook {
|
|
|
77
77
|
updatedAt: Date;
|
|
78
78
|
lastTriggeredAt?: Date;
|
|
79
79
|
}
|
|
80
|
-
declare class Webhooks extends Base<Webhook> {
|
|
80
|
+
declare class Webhooks extends Base$1<Webhook> {
|
|
81
81
|
protected namespace: string;
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -120,6 +120,98 @@ declare class Sessions {
|
|
|
120
120
|
create(params: SessionCreateRequest): Promise<SessionCreateResponse>;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
interface Params {
|
|
124
|
+
limit?: number;
|
|
125
|
+
after?: string;
|
|
126
|
+
includeRaw?: boolean;
|
|
127
|
+
}
|
|
128
|
+
interface Response$1<T> {
|
|
129
|
+
data: T;
|
|
130
|
+
_raw?: any;
|
|
131
|
+
pageInfo: {
|
|
132
|
+
next: string | null;
|
|
133
|
+
limit: number;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
declare abstract class Base {
|
|
137
|
+
private apiKey;
|
|
138
|
+
private connectionId;
|
|
139
|
+
private baseUrl;
|
|
140
|
+
private version;
|
|
141
|
+
protected abstract namespace: string;
|
|
142
|
+
protected get headers(): Record<string, string>;
|
|
143
|
+
protected buildUrl(path?: string | null, searchParams?: Record<string, any>): URL;
|
|
144
|
+
constructor(apiKey: string, connectionId: string);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
declare class Chat extends Base {
|
|
148
|
+
protected namespace: string;
|
|
149
|
+
/**
|
|
150
|
+
* Fetch chat channels with optional query parameters.
|
|
151
|
+
* @param limit - Maximum number of channels to retrieve.
|
|
152
|
+
* @param after - Cursor for pagination.
|
|
153
|
+
* @param includeRaw - Whether to include raw response data.
|
|
154
|
+
* @returns A promise that resolves to the fetch response.
|
|
155
|
+
*/
|
|
156
|
+
channels({ limit, after, includeRaw }?: Params): Promise<Response$1<{
|
|
157
|
+
id: string;
|
|
158
|
+
name: string;
|
|
159
|
+
}[]>>;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
interface RepoParams extends Params {
|
|
163
|
+
repoName: string;
|
|
164
|
+
}
|
|
165
|
+
declare class Git extends Base {
|
|
166
|
+
protected namespace: string;
|
|
167
|
+
/**
|
|
168
|
+
* Fetch repositories with optional query parameters.
|
|
169
|
+
* @param limit - Maximum number of repositories to retrieve.
|
|
170
|
+
* @param after - Cursor for pagination.
|
|
171
|
+
* @param includeRaw - Whether to include raw response data.
|
|
172
|
+
* @returns A promise that resolves to the fetch response.
|
|
173
|
+
*/
|
|
174
|
+
repos({ limit, after, includeRaw }?: Params): Promise<Response$1<{
|
|
175
|
+
id: string;
|
|
176
|
+
name: string;
|
|
177
|
+
full_name: string;
|
|
178
|
+
description: string | null;
|
|
179
|
+
created_at: string;
|
|
180
|
+
updated_at: string;
|
|
181
|
+
}[]>>;
|
|
182
|
+
/**
|
|
183
|
+
* Fetch pull requests for a specific repository.
|
|
184
|
+
* @param repoName - The name of the repository.
|
|
185
|
+
* @param limit - Maximum number of pull requests to retrieve.
|
|
186
|
+
* @param after - Cursor for pagination.
|
|
187
|
+
* @param includeRaw - Whether to include raw response data.
|
|
188
|
+
* @returns A promise that resolves to the fetch response.
|
|
189
|
+
* @throws If repoName is not provided.
|
|
190
|
+
*/
|
|
191
|
+
pulls({ repoName, limit, after, includeRaw }: RepoParams): Promise<Response$1<{
|
|
192
|
+
id: string;
|
|
193
|
+
number: number;
|
|
194
|
+
title: string;
|
|
195
|
+
state: string;
|
|
196
|
+
created_at: string;
|
|
197
|
+
updated_at: string;
|
|
198
|
+
merged_at: string | null;
|
|
199
|
+
}[]>>;
|
|
200
|
+
/**
|
|
201
|
+
* Fetch tags for a specific repository.
|
|
202
|
+
* @param repoName - The name of the repository.
|
|
203
|
+
* @param limit - Maximum number of tags to retrieve.
|
|
204
|
+
* @param after - Cursor for pagination.
|
|
205
|
+
* @param includeRaw - Whether to include raw response data.
|
|
206
|
+
* @returns A promise that resolves to the fetch response.
|
|
207
|
+
* @throws If repoName is not provided.
|
|
208
|
+
*/
|
|
209
|
+
tags({ repoName, limit, after, includeRaw }: RepoParams): Promise<Response$1<{
|
|
210
|
+
name: string;
|
|
211
|
+
commit_sha: string;
|
|
212
|
+
}[]>>;
|
|
213
|
+
}
|
|
214
|
+
|
|
123
215
|
declare class BundleUp {
|
|
124
216
|
private apiKey;
|
|
125
217
|
constructor(apiKey: string);
|
|
@@ -145,6 +237,15 @@ declare class BundleUp {
|
|
|
145
237
|
* @returns A Proxy instance.
|
|
146
238
|
*/
|
|
147
239
|
proxy(connectionId: string): Proxy;
|
|
240
|
+
/**
|
|
241
|
+
* Access Unify API for a specific connection.
|
|
242
|
+
* @param connectionId - The ID of the connection.
|
|
243
|
+
* @returns An object containing Unify methods.
|
|
244
|
+
*/
|
|
245
|
+
unify(connectionId: string): {
|
|
246
|
+
chat: Chat;
|
|
247
|
+
git: Git;
|
|
248
|
+
};
|
|
148
249
|
}
|
|
149
250
|
|
|
150
251
|
export { BundleUp };
|
package/dist/index.js
CHANGED
|
@@ -337,6 +337,156 @@ var Sessions = class {
|
|
|
337
337
|
}
|
|
338
338
|
};
|
|
339
339
|
|
|
340
|
+
// src/unify/base.ts
|
|
341
|
+
var Base2 = class {
|
|
342
|
+
constructor(apiKey, connectionId) {
|
|
343
|
+
this.apiKey = apiKey;
|
|
344
|
+
this.connectionId = connectionId;
|
|
345
|
+
this.baseUrl = "https://unify.bundleup.io";
|
|
346
|
+
this.version = "v1";
|
|
347
|
+
}
|
|
348
|
+
get headers() {
|
|
349
|
+
return {
|
|
350
|
+
"Content-Type": "application/json",
|
|
351
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
352
|
+
"BU-Connection-Id": this.connectionId
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
buildUrl(path, searchParams = {}) {
|
|
356
|
+
if (!isObject(searchParams)) {
|
|
357
|
+
throw new Error("URL search params must be an object.");
|
|
358
|
+
}
|
|
359
|
+
const parts = [this.version, this.namespace, path].filter(Boolean).join("/");
|
|
360
|
+
const url = new URL(parts, this.baseUrl);
|
|
361
|
+
url.search = new URLSearchParams(searchParams).toString();
|
|
362
|
+
return url;
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
// src/unify/chat.ts
|
|
367
|
+
var Chat = class extends Base2 {
|
|
368
|
+
constructor() {
|
|
369
|
+
super(...arguments);
|
|
370
|
+
this.namespace = "chat";
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Fetch chat channels with optional query parameters.
|
|
374
|
+
* @param limit - Maximum number of channels to retrieve.
|
|
375
|
+
* @param after - Cursor for pagination.
|
|
376
|
+
* @param includeRaw - Whether to include raw response data.
|
|
377
|
+
* @returns A promise that resolves to the fetch response.
|
|
378
|
+
*/
|
|
379
|
+
async channels({ limit = 100, after, includeRaw } = {}) {
|
|
380
|
+
const url = this.buildUrl("channels", { limit, after });
|
|
381
|
+
const response = await fetch(url, {
|
|
382
|
+
headers: {
|
|
383
|
+
...this.headers,
|
|
384
|
+
"BU-Include-Raw": includeRaw ? "true" : "false"
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
if (!response.ok) {
|
|
388
|
+
throw new Error(
|
|
389
|
+
`Failed to fetch ${url.toString()}: ${response.statusText}`
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
const data = await response.json();
|
|
393
|
+
return data;
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
// src/unify/git.ts
|
|
398
|
+
var Git = class extends Base2 {
|
|
399
|
+
constructor() {
|
|
400
|
+
super(...arguments);
|
|
401
|
+
this.namespace = "git";
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Fetch repositories with optional query parameters.
|
|
405
|
+
* @param limit - Maximum number of repositories to retrieve.
|
|
406
|
+
* @param after - Cursor for pagination.
|
|
407
|
+
* @param includeRaw - Whether to include raw response data.
|
|
408
|
+
* @returns A promise that resolves to the fetch response.
|
|
409
|
+
*/
|
|
410
|
+
async repos({ limit = 100, after, includeRaw } = {}) {
|
|
411
|
+
const url = this.buildUrl("repos", { limit, after });
|
|
412
|
+
const response = await fetch(url, {
|
|
413
|
+
headers: {
|
|
414
|
+
...this.headers,
|
|
415
|
+
"BU-Include-Raw": includeRaw ? "true" : "false"
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
if (!response.ok) {
|
|
419
|
+
throw new Error(
|
|
420
|
+
`Failed to fetch ${url.toString()}: ${response.statusText}`
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
const data = await response.json();
|
|
424
|
+
return data;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Fetch pull requests for a specific repository.
|
|
428
|
+
* @param repoName - The name of the repository.
|
|
429
|
+
* @param limit - Maximum number of pull requests to retrieve.
|
|
430
|
+
* @param after - Cursor for pagination.
|
|
431
|
+
* @param includeRaw - Whether to include raw response data.
|
|
432
|
+
* @returns A promise that resolves to the fetch response.
|
|
433
|
+
* @throws If repoName is not provided.
|
|
434
|
+
*/
|
|
435
|
+
async pulls({ repoName, limit = 100, after, includeRaw }) {
|
|
436
|
+
if (!repoName) {
|
|
437
|
+
throw new Error("repoName is required to fetch pulls.");
|
|
438
|
+
}
|
|
439
|
+
const url = this.buildUrl(`repos/${encodeURIComponent(repoName)}/pulls`, {
|
|
440
|
+
limit,
|
|
441
|
+
after
|
|
442
|
+
});
|
|
443
|
+
const response = await fetch(url, {
|
|
444
|
+
headers: {
|
|
445
|
+
...this.headers,
|
|
446
|
+
"BU-Include-Raw": includeRaw ? "true" : "false"
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
if (!response.ok) {
|
|
450
|
+
throw new Error(
|
|
451
|
+
`Failed to fetch ${url.toString()}: ${response.statusText}`
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
const data = await response.json();
|
|
455
|
+
return data;
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Fetch tags for a specific repository.
|
|
459
|
+
* @param repoName - The name of the repository.
|
|
460
|
+
* @param limit - Maximum number of tags to retrieve.
|
|
461
|
+
* @param after - Cursor for pagination.
|
|
462
|
+
* @param includeRaw - Whether to include raw response data.
|
|
463
|
+
* @returns A promise that resolves to the fetch response.
|
|
464
|
+
* @throws If repoName is not provided.
|
|
465
|
+
*/
|
|
466
|
+
async tags({ repoName, limit = 100, after, includeRaw }) {
|
|
467
|
+
if (!repoName) {
|
|
468
|
+
throw new Error("repoName is required to fetch tags.");
|
|
469
|
+
}
|
|
470
|
+
const url = this.buildUrl(`repos/${encodeURIComponent(repoName)}/tags`, {
|
|
471
|
+
limit,
|
|
472
|
+
after
|
|
473
|
+
});
|
|
474
|
+
const response = await fetch(url, {
|
|
475
|
+
headers: {
|
|
476
|
+
...this.headers,
|
|
477
|
+
"BU-Include-Raw": includeRaw ? "true" : "false"
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
if (!response.ok) {
|
|
481
|
+
throw new Error(
|
|
482
|
+
`Failed to fetch ${url.toString()}: ${response.statusText}`
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
const data = await response.json();
|
|
486
|
+
return data;
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
|
|
340
490
|
// src/index.ts
|
|
341
491
|
var BundleUp = class {
|
|
342
492
|
constructor(apiKey) {
|
|
@@ -376,10 +526,24 @@ var BundleUp = class {
|
|
|
376
526
|
*/
|
|
377
527
|
proxy(connectionId) {
|
|
378
528
|
if (!connectionId) {
|
|
379
|
-
throw new Error("Connection ID is required to create a
|
|
529
|
+
throw new Error("Connection ID is required to create a Proxy instance.");
|
|
380
530
|
}
|
|
381
531
|
return new Proxy2(this.apiKey, connectionId);
|
|
382
532
|
}
|
|
533
|
+
/**
|
|
534
|
+
* Access Unify API for a specific connection.
|
|
535
|
+
* @param connectionId - The ID of the connection.
|
|
536
|
+
* @returns An object containing Unify methods.
|
|
537
|
+
*/
|
|
538
|
+
unify(connectionId) {
|
|
539
|
+
if (!connectionId) {
|
|
540
|
+
throw new Error("Connection ID is required to create a Unify instance.");
|
|
541
|
+
}
|
|
542
|
+
return {
|
|
543
|
+
chat: new Chat(this.apiKey, connectionId),
|
|
544
|
+
git: new Git(this.apiKey, connectionId)
|
|
545
|
+
};
|
|
546
|
+
}
|
|
383
547
|
};
|
|
384
548
|
// Annotate the CommonJS export names for ESM import in node:
|
|
385
549
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -311,6 +311,156 @@ var Sessions = class {
|
|
|
311
311
|
}
|
|
312
312
|
};
|
|
313
313
|
|
|
314
|
+
// src/unify/base.ts
|
|
315
|
+
var Base2 = class {
|
|
316
|
+
constructor(apiKey, connectionId) {
|
|
317
|
+
this.apiKey = apiKey;
|
|
318
|
+
this.connectionId = connectionId;
|
|
319
|
+
this.baseUrl = "https://unify.bundleup.io";
|
|
320
|
+
this.version = "v1";
|
|
321
|
+
}
|
|
322
|
+
get headers() {
|
|
323
|
+
return {
|
|
324
|
+
"Content-Type": "application/json",
|
|
325
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
326
|
+
"BU-Connection-Id": this.connectionId
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
buildUrl(path, searchParams = {}) {
|
|
330
|
+
if (!isObject(searchParams)) {
|
|
331
|
+
throw new Error("URL search params must be an object.");
|
|
332
|
+
}
|
|
333
|
+
const parts = [this.version, this.namespace, path].filter(Boolean).join("/");
|
|
334
|
+
const url = new URL(parts, this.baseUrl);
|
|
335
|
+
url.search = new URLSearchParams(searchParams).toString();
|
|
336
|
+
return url;
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
// src/unify/chat.ts
|
|
341
|
+
var Chat = class extends Base2 {
|
|
342
|
+
constructor() {
|
|
343
|
+
super(...arguments);
|
|
344
|
+
this.namespace = "chat";
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Fetch chat channels with optional query parameters.
|
|
348
|
+
* @param limit - Maximum number of channels to retrieve.
|
|
349
|
+
* @param after - Cursor for pagination.
|
|
350
|
+
* @param includeRaw - Whether to include raw response data.
|
|
351
|
+
* @returns A promise that resolves to the fetch response.
|
|
352
|
+
*/
|
|
353
|
+
async channels({ limit = 100, after, includeRaw } = {}) {
|
|
354
|
+
const url = this.buildUrl("channels", { limit, after });
|
|
355
|
+
const response = await fetch(url, {
|
|
356
|
+
headers: {
|
|
357
|
+
...this.headers,
|
|
358
|
+
"BU-Include-Raw": includeRaw ? "true" : "false"
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
if (!response.ok) {
|
|
362
|
+
throw new Error(
|
|
363
|
+
`Failed to fetch ${url.toString()}: ${response.statusText}`
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
const data = await response.json();
|
|
367
|
+
return data;
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
// src/unify/git.ts
|
|
372
|
+
var Git = class extends Base2 {
|
|
373
|
+
constructor() {
|
|
374
|
+
super(...arguments);
|
|
375
|
+
this.namespace = "git";
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Fetch repositories with optional query parameters.
|
|
379
|
+
* @param limit - Maximum number of repositories to retrieve.
|
|
380
|
+
* @param after - Cursor for pagination.
|
|
381
|
+
* @param includeRaw - Whether to include raw response data.
|
|
382
|
+
* @returns A promise that resolves to the fetch response.
|
|
383
|
+
*/
|
|
384
|
+
async repos({ limit = 100, after, includeRaw } = {}) {
|
|
385
|
+
const url = this.buildUrl("repos", { limit, after });
|
|
386
|
+
const response = await fetch(url, {
|
|
387
|
+
headers: {
|
|
388
|
+
...this.headers,
|
|
389
|
+
"BU-Include-Raw": includeRaw ? "true" : "false"
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
if (!response.ok) {
|
|
393
|
+
throw new Error(
|
|
394
|
+
`Failed to fetch ${url.toString()}: ${response.statusText}`
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
const data = await response.json();
|
|
398
|
+
return data;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Fetch pull requests for a specific repository.
|
|
402
|
+
* @param repoName - The name of the repository.
|
|
403
|
+
* @param limit - Maximum number of pull requests to retrieve.
|
|
404
|
+
* @param after - Cursor for pagination.
|
|
405
|
+
* @param includeRaw - Whether to include raw response data.
|
|
406
|
+
* @returns A promise that resolves to the fetch response.
|
|
407
|
+
* @throws If repoName is not provided.
|
|
408
|
+
*/
|
|
409
|
+
async pulls({ repoName, limit = 100, after, includeRaw }) {
|
|
410
|
+
if (!repoName) {
|
|
411
|
+
throw new Error("repoName is required to fetch pulls.");
|
|
412
|
+
}
|
|
413
|
+
const url = this.buildUrl(`repos/${encodeURIComponent(repoName)}/pulls`, {
|
|
414
|
+
limit,
|
|
415
|
+
after
|
|
416
|
+
});
|
|
417
|
+
const response = await fetch(url, {
|
|
418
|
+
headers: {
|
|
419
|
+
...this.headers,
|
|
420
|
+
"BU-Include-Raw": includeRaw ? "true" : "false"
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
if (!response.ok) {
|
|
424
|
+
throw new Error(
|
|
425
|
+
`Failed to fetch ${url.toString()}: ${response.statusText}`
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
const data = await response.json();
|
|
429
|
+
return data;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Fetch tags for a specific repository.
|
|
433
|
+
* @param repoName - The name of the repository.
|
|
434
|
+
* @param limit - Maximum number of tags to retrieve.
|
|
435
|
+
* @param after - Cursor for pagination.
|
|
436
|
+
* @param includeRaw - Whether to include raw response data.
|
|
437
|
+
* @returns A promise that resolves to the fetch response.
|
|
438
|
+
* @throws If repoName is not provided.
|
|
439
|
+
*/
|
|
440
|
+
async tags({ repoName, limit = 100, after, includeRaw }) {
|
|
441
|
+
if (!repoName) {
|
|
442
|
+
throw new Error("repoName is required to fetch tags.");
|
|
443
|
+
}
|
|
444
|
+
const url = this.buildUrl(`repos/${encodeURIComponent(repoName)}/tags`, {
|
|
445
|
+
limit,
|
|
446
|
+
after
|
|
447
|
+
});
|
|
448
|
+
const response = await fetch(url, {
|
|
449
|
+
headers: {
|
|
450
|
+
...this.headers,
|
|
451
|
+
"BU-Include-Raw": includeRaw ? "true" : "false"
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
if (!response.ok) {
|
|
455
|
+
throw new Error(
|
|
456
|
+
`Failed to fetch ${url.toString()}: ${response.statusText}`
|
|
457
|
+
);
|
|
458
|
+
}
|
|
459
|
+
const data = await response.json();
|
|
460
|
+
return data;
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
|
|
314
464
|
// src/index.ts
|
|
315
465
|
var BundleUp = class {
|
|
316
466
|
constructor(apiKey) {
|
|
@@ -350,10 +500,24 @@ var BundleUp = class {
|
|
|
350
500
|
*/
|
|
351
501
|
proxy(connectionId) {
|
|
352
502
|
if (!connectionId) {
|
|
353
|
-
throw new Error("Connection ID is required to create a
|
|
503
|
+
throw new Error("Connection ID is required to create a Proxy instance.");
|
|
354
504
|
}
|
|
355
505
|
return new Proxy(this.apiKey, connectionId);
|
|
356
506
|
}
|
|
507
|
+
/**
|
|
508
|
+
* Access Unify API for a specific connection.
|
|
509
|
+
* @param connectionId - The ID of the connection.
|
|
510
|
+
* @returns An object containing Unify methods.
|
|
511
|
+
*/
|
|
512
|
+
unify(connectionId) {
|
|
513
|
+
if (!connectionId) {
|
|
514
|
+
throw new Error("Connection ID is required to create a Unify instance.");
|
|
515
|
+
}
|
|
516
|
+
return {
|
|
517
|
+
chat: new Chat(this.apiKey, connectionId),
|
|
518
|
+
git: new Git(this.apiKey, connectionId)
|
|
519
|
+
};
|
|
520
|
+
}
|
|
357
521
|
};
|
|
358
522
|
export {
|
|
359
523
|
BundleUp
|