@bundleup/sdk 0.0.17 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,86 +1,3 @@
1
- declare abstract class Base$1<T> {
2
- private apiKey;
3
- protected abstract namespace: string;
4
- private baseUrl;
5
- private version;
6
- constructor(apiKey: string);
7
- protected buildUrl(path?: string | null, searchParams?: Record<string, any>): URL;
8
- protected get headers(): Record<string, string>;
9
- /**
10
- * List resources with optional query parameters.
11
- * @param searchParams - Query parameters for filtering the list.
12
- * @returns A promise that resolves to an array of resources.
13
- * @throws If params is not an object or if the fetch request fails.
14
- */
15
- list<K extends Record<string, any>>(searchParams?: K): Promise<T[]>;
16
- /**
17
- * Create a new resource.
18
- * @param body - The request body containing resource details.
19
- * @returns A promise that resolves to the created resource.
20
- * @throws If body is not an object or if the fetch request fails.
21
- */
22
- create<K extends Record<string, any>>(body: K): Promise<T>;
23
- /**
24
- * Retrieve a specific resource by ID.
25
- * @param id - The ID of the resource to retrieve.
26
- * @returns A promise that resolves to the retrieved resource.
27
- * @throws If id is not provided or if the fetch request fails.
28
- */
29
- retrieve(id: string): Promise<T>;
30
- /**
31
- * Update a specific resource by ID.
32
- * @param id - The ID of the resource to update.
33
- * @param body - The request body containing updated resource details.
34
- * @returns A promise that resolves to the updated resource.
35
- * @throws If id is not provided, if body is not an object, or if the fetch request fails.
36
- */
37
- update<K extends Record<string, any>>(id: string, body: K): Promise<T>;
38
- /**
39
- * Delete a specific resource by ID.
40
- * @param id - The ID of the resource to delete.
41
- * @returns A promise that resolves when the resource is deleted.
42
- * @throws If id is not provided or if the fetch request fails.
43
- */
44
- del(id: string): Promise<void>;
45
- }
46
-
47
- interface Connection {
48
- id: string;
49
- externalId?: string;
50
- expiresAt: Date;
51
- integrationId: string;
52
- isValid: boolean;
53
- refreshedAt?: Date;
54
- createdAt: Date;
55
- updatedAt: Date;
56
- }
57
- declare class Connections extends Base$1<Connection> {
58
- protected namespace: string;
59
- }
60
-
61
- interface Integration {
62
- id: string;
63
- identifier: string;
64
- createdAt: Date;
65
- updatedAt: Date;
66
- }
67
- declare class Integrations extends Base$1<Integration> {
68
- protected namespace: string;
69
- }
70
-
71
- interface Webhook {
72
- id: string;
73
- name: string;
74
- url: string;
75
- events: Record<string, boolean>;
76
- createdAt: Date;
77
- updatedAt: Date;
78
- lastTriggeredAt?: Date;
79
- }
80
- declare class Webhooks extends Base$1<Webhook> {
81
- protected namespace: string;
82
- }
83
-
84
1
  declare class Proxy {
85
2
  private apiKey;
86
3
  private connectionId;
@@ -88,71 +5,46 @@ declare class Proxy {
88
5
  private get headers();
89
6
  constructor(apiKey: string, connectionId: string);
90
7
  private buildUrl;
91
- get(path: string, searchParams?: Record<string, any>, headers?: Record<string, string>): Promise<Response>;
92
- post(path: string, body?: Record<string, any>, headers?: Record<string, string>): Promise<Response>;
93
- put(path: string, body?: Record<string, any>, headers?: Record<string, string>): Promise<Response>;
94
- patch(path: string, body?: Record<string, any>, headers?: Record<string, string>): Promise<Response>;
8
+ get(path: string, headers?: Record<string, string>): Promise<Response>;
9
+ post(path: string, body: BodyInit, headers?: Record<string, string>): Promise<Response>;
10
+ put(path: string, body: BodyInit, headers?: Record<string, string>): Promise<Response>;
11
+ patch(path: string, body: BodyInit, headers?: Record<string, string>): Promise<Response>;
95
12
  delete(path: string, headers?: Record<string, string>): Promise<Response>;
96
13
  }
97
14
 
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
15
  interface Params {
124
16
  limit?: number;
125
17
  after?: string;
126
- includeRaw?: boolean;
18
+ include_raw?: boolean;
127
19
  }
128
20
  interface Response$1<T> {
129
21
  data: T;
130
- _raw?: any;
22
+ _raw?: unknown;
131
23
  metadata: {
132
24
  next: string | null;
133
25
  };
134
26
  }
135
- declare abstract class Base {
27
+ declare abstract class Base$1 {
136
28
  private apiKey;
137
29
  private connectionId;
138
30
  private baseUrl;
139
31
  private version;
140
32
  protected abstract namespace: string;
141
33
  protected get headers(): Record<string, string>;
142
- protected buildUrl(path?: string | null, searchParams?: Record<string, any>): URL;
34
+ protected buildUrl(path?: string | null, searchParams?: Record<string, unknown>): URL;
143
35
  constructor(apiKey: string, connectionId: string);
144
36
  }
145
37
 
146
- declare class Chat extends Base {
38
+ declare class Chat extends Base$1 {
147
39
  protected namespace: string;
148
40
  /**
149
41
  * Fetch chat channels
150
42
  * @param limit - Maximum number of channels to retrieve.
151
43
  * @param after - Cursor for pagination.
152
- * @param includeRaw - Whether to include raw response data.
44
+ * @param include_raw - Whether to include raw response data.
153
45
  * @returns A promise that resolves to the fetch response.
154
46
  */
155
- channels({ limit, after, includeRaw }?: Params): Promise<Response$1<{
47
+ channels({ limit, after, include_raw }?: Params): Promise<Response$1<{
156
48
  id: string;
157
49
  name: string;
158
50
  }[]>>;
@@ -161,7 +53,7 @@ declare class Chat extends Base {
161
53
  interface RepoParams extends Params {
162
54
  repoName: string;
163
55
  }
164
- declare class Git extends Base {
56
+ declare class Git extends Base$1 {
165
57
  protected namespace: string;
166
58
  /**
167
59
  * Fetch repositories
@@ -170,7 +62,7 @@ declare class Git extends Base {
170
62
  * @param includeRaw - Whether to include raw response data.
171
63
  * @returns A promise that resolves to the fetch response.
172
64
  */
173
- repos({ limit, after, includeRaw }?: Params): Promise<Response$1<{
65
+ repos({ limit, after, include_raw }?: Params): Promise<Response$1<{
174
66
  id: string;
175
67
  name: string;
176
68
  full_name: string;
@@ -185,11 +77,11 @@ declare class Git extends Base {
185
77
  * @param repoName - The name of the repository.
186
78
  * @param limit - Maximum number of pull requests to retrieve.
187
79
  * @param after - Cursor for pagination.
188
- * @param includeRaw - Whether to include raw response data.
80
+ * @param include_raw - Whether to include raw response data.
189
81
  * @returns A promise that resolves to the fetch response.
190
82
  * @throws If repoName is not provided.
191
83
  */
192
- pulls({ repoName, limit, after, includeRaw }: RepoParams): Promise<Response$1<{
84
+ pulls(repoName: string, { limit, after, include_raw }: RepoParams): Promise<Response$1<{
193
85
  id: string;
194
86
  number: number;
195
87
  title: string;
@@ -207,11 +99,11 @@ declare class Git extends Base {
207
99
  * @param repoName - The name of the repository.
208
100
  * @param limit - Maximum number of tags to retrieve.
209
101
  * @param after - Cursor for pagination.
210
- * @param includeRaw - Whether to include raw response data.
102
+ * @param include_raw - Whether to include raw response data.
211
103
  * @returns A promise that resolves to the fetch response.
212
104
  * @throws If repoName is not provided.
213
105
  */
214
- tags({ repoName, limit, after, includeRaw }: RepoParams): Promise<Response$1<{
106
+ tags(repoName: string, { limit, after, include_raw }: RepoParams): Promise<Response$1<{
215
107
  name: string;
216
108
  commit_sha: string;
217
109
  }[]>>;
@@ -220,11 +112,11 @@ declare class Git extends Base {
220
112
  * @param repoName - The name of the repository.
221
113
  * @param limit - Maximum number of releases to retrieve.
222
114
  * @param after - Cursor for pagination.
223
- * @param includeRaw - Whether to include raw response data.
115
+ * @param include_raw - Whether to include raw response data.
224
116
  * @returns A promise that resolves to the fetch response.
225
117
  * @throws If repoName is not provided.
226
118
  */
227
- releases({ repoName, limit, after, includeRaw }: RepoParams): Promise<Response$1<{
119
+ releases(repoName: string, { limit, after, include_raw }: RepoParams): Promise<Response$1<{
228
120
  id: string;
229
121
  name: string;
230
122
  tag_name: string;
@@ -236,16 +128,16 @@ declare class Git extends Base {
236
128
  }[]>>;
237
129
  }
238
130
 
239
- declare class PM extends Base {
131
+ declare class PM extends Base$1 {
240
132
  protected namespace: string;
241
133
  /**
242
134
  * Fetch issues
243
135
  * @param limit - Maximum number of issues to retrieve.
244
136
  * @param after - Cursor for pagination.
245
- * @param includeRaw - Whether to include raw response data.
137
+ * @param include_raw - Whether to include raw response data.
246
138
  * @returns A promise that resolves to the fetch response.
247
139
  */
248
- issues({ limit, after, includeRaw }?: Params): Promise<Response$1<{
140
+ issues({ limit, after, include_raw }?: Params): Promise<Response$1<{
249
141
  id: string;
250
142
  url: string;
251
143
  title: string;
@@ -256,6 +148,209 @@ declare class PM extends Base {
256
148
  }[]>>;
257
149
  }
258
150
 
151
+ declare class Unify {
152
+ private apiKey;
153
+ private connectionId;
154
+ constructor(apiKey: string, connectionId: string);
155
+ /**
156
+ * Access the Chat API for the connection.
157
+ */
158
+ get chat(): Chat;
159
+ /**
160
+ * Access the Git API for the connection.
161
+ */
162
+ get git(): Git;
163
+ /**
164
+ * Access the PM API for the connection.
165
+ */
166
+ get pm(): PM;
167
+ }
168
+
169
+ declare abstract class Base<T> {
170
+ private apiKey;
171
+ protected abstract namespace: string;
172
+ private baseUrl;
173
+ private version;
174
+ constructor(apiKey: string);
175
+ private buildUrl;
176
+ private get headers();
177
+ /**
178
+ * List resources with optional query parameters.
179
+ * @param searchParams - Query parameters for filtering the list.
180
+ * @returns A promise that resolves to an array of resources.
181
+ * @throws If params is not an object or if the fetch request fails.
182
+ */
183
+ protected list(searchParams?: Record<string, unknown>): Promise<T[]>;
184
+ /**
185
+ * Create a new resource.
186
+ * @param body - The request body containing resource details.
187
+ * @returns A promise that resolves to the created resource.
188
+ * @throws If body is not an object or if the fetch request fails.
189
+ */
190
+ protected create(body: Record<string, unknown>): Promise<T>;
191
+ /**
192
+ * Retrieve a specific resource by ID.
193
+ * @param id - The ID of the resource to retrieve.
194
+ * @returns A promise that resolves to the retrieved resource.
195
+ * @throws If id is not provided or if the fetch request fails.
196
+ */
197
+ protected retrieve(id: string): Promise<T>;
198
+ /**
199
+ * Update a specific resource by ID.
200
+ * @param id - The ID of the resource to update.
201
+ * @param body - The request body containing updated resource details.
202
+ * @returns A promise that resolves to the updated resource.
203
+ * @throws If id is not provided, if body is not an object, or if the fetch request fails.
204
+ */
205
+ protected update(id: string, body: Record<string, unknown>): Promise<T>;
206
+ /**
207
+ * Delete a specific resource by ID.
208
+ * @param id - The ID of the resource to delete.
209
+ * @returns A promise that resolves when the resource is deleted.
210
+ * @throws If id is not provided or if the fetch request fails.
211
+ */
212
+ protected del(id: string): Promise<void>;
213
+ }
214
+
215
+ interface Connection {
216
+ id: string;
217
+ externalId?: string;
218
+ expiresAt: Date;
219
+ integrationId: string;
220
+ isValid: boolean;
221
+ refreshedAt?: Date;
222
+ createdAt: Date;
223
+ updatedAt: Date;
224
+ }
225
+ interface ConnectionListParams {
226
+ offset: number;
227
+ limit: number;
228
+ integration_id: string;
229
+ integration_identifier: string;
230
+ external_id: string;
231
+ }
232
+ declare class Connections extends Base<Connection> {
233
+ protected namespace: string;
234
+ /**
235
+ * List all connections with optional query parameters.
236
+ * @param searchParams - Query parameters for filtering the list of connections.
237
+ * - offset: The number of items to skip before starting to collect the result set.
238
+ * - limit: The number of items to return.
239
+ * - integration_id: Filter connections by integration ID.
240
+ * - integration_identifier: Filter connections by integration identifier.
241
+ * - external_id: Filter connections by external ID.
242
+ * @returns A promise that resolves to an array of connection objects.
243
+ * @throws If the fetch request fails or if the search parameters are invalid.
244
+ */
245
+ list(searchParams?: Partial<ConnectionListParams>): Promise<Connection[]>;
246
+ /**
247
+ * Retrieve a specific connection by ID.
248
+ * @param id - The ID of the connection to retrieve.
249
+ * @returns A promise that resolves to the connection object.
250
+ * @throws If the fetch request fails or if the ID is invalid.
251
+ */
252
+ retrieve(id: string): Promise<Connection>;
253
+ /**
254
+ * Delete a specific connection by ID.
255
+ * @param id - The ID of the connection to delete.
256
+ * @returns A promise that resolves when the connection is deleted.
257
+ * @throws If the fetch request fails or if the ID is invalid.
258
+ */
259
+ del(id: string): Promise<void>;
260
+ }
261
+
262
+ interface Integration {
263
+ id: string;
264
+ identifier: string;
265
+ createdAt: Date;
266
+ updatedAt: Date;
267
+ }
268
+ interface IntegrationListParams {
269
+ offset: number;
270
+ limit: number;
271
+ status: string;
272
+ }
273
+ declare class Integrations extends Base<Integration> {
274
+ protected namespace: string;
275
+ /**
276
+ * List all integrations with optional query parameters.
277
+ * @param searchParams - Query parameters for filtering the list of integrations.
278
+ * - offset: The number of items to skip before starting to collect the result set.
279
+ * - limit: The number of items to return.
280
+ * - status: Filter integrations by status (e.g., 'active', 'inactive').
281
+ * @returns A promise that resolves to an array of integration objects.
282
+ * @throws If the fetch request fails or if the search parameters are invalid.
283
+ */
284
+ list(searchParams?: Partial<IntegrationListParams>): Promise<Integration[]>;
285
+ /**
286
+ * Retrieve a specific integration by ID.
287
+ * @param id - The ID of the integration to retrieve.
288
+ * @returns A promise that resolves to the integration object.
289
+ * @throws If the fetch request fails or if the ID is invalid.
290
+ */
291
+ retrieve(id: string): Promise<Integration>;
292
+ }
293
+
294
+ interface Webhook {
295
+ id: string;
296
+ name: string;
297
+ url: string;
298
+ events: Record<string, boolean>;
299
+ createdAt: Date;
300
+ updatedAt: Date;
301
+ lastTriggeredAt?: Date;
302
+ }
303
+ interface WebhookListParams {
304
+ offset: number;
305
+ limit: number;
306
+ }
307
+ interface WebhookBody extends Record<string, unknown> {
308
+ name: string;
309
+ url: string;
310
+ events: Record<string, boolean>;
311
+ }
312
+ declare class Webhooks extends Base<Webhook> {
313
+ protected namespace: string;
314
+ /**
315
+ * List all webhooks with optional query parameters.
316
+ * @param searchParams - Query parameters for filtering the list of webhooks.
317
+ * - offset: The number of items to skip before starting to collect the result set.
318
+ * - limit: The number of items to return.
319
+ * @returns A promise that resolves to an array of webhook objects.
320
+ * @throws If the fetch request fails or if the search parameters are invalid.
321
+ */
322
+ list(searchParams?: Partial<WebhookListParams>): Promise<Webhook[]>;
323
+ /**
324
+ * Retrieve a specific webhook by ID.
325
+ * @param id - The ID of the webhook to retrieve.
326
+ * @returns A promise that resolves to the webhook object.
327
+ * @throws If the fetch request fails or if the ID is invalid.
328
+ */
329
+ retrieve(id: string): Promise<Webhook>;
330
+ /**
331
+ * Create a new webhook with the specified data.
332
+ * @param data - An object containing the properties of the webhook to create.
333
+ * @returns A promise that resolves to the created webhook object.
334
+ * @throws If the fetch request fails or if the data is invalid.
335
+ */
336
+ create(data: WebhookBody): Promise<Webhook>;
337
+ /**
338
+ * Update an existing webhook with the specified data.
339
+ * @param id - The ID of the webhook to update.
340
+ * @param data - An object containing the properties of the webhook to update.
341
+ * @returns A promise that resolves to the updated webhook object.
342
+ * @throws If the fetch request fails, if the ID is invalid, or if the data is invalid.
343
+ */
344
+ update(id: string, data: WebhookBody): Promise<Webhook>;
345
+ /**
346
+ * Delete a specific webhook by ID.
347
+ * @param id - The ID of the webhook to delete.
348
+ * @returns A promise that resolves when the webhook is deleted.
349
+ * @throws If the fetch request fails or if the ID is invalid.
350
+ */
351
+ del(id: string): Promise<void>;
352
+ }
353
+
259
354
  declare class BundleUp {
260
355
  private apiKey;
261
356
  constructor(apiKey: string);
@@ -271,10 +366,6 @@ declare class BundleUp {
271
366
  * Access the Webhooks resource.
272
367
  */
273
368
  get webhooks(): Webhooks;
274
- /**
275
- * Access the Sessions resource.
276
- */
277
- get sessions(): Sessions;
278
369
  /**
279
370
  * Create a Proxy instance for a specific connection.
280
371
  * @param connectionId - The ID of the connection.
@@ -286,11 +377,7 @@ declare class BundleUp {
286
377
  * @param connectionId - The ID of the connection.
287
378
  * @returns An object containing Unify methods.
288
379
  */
289
- unify(connectionId: string): {
290
- chat: Chat;
291
- git: Git;
292
- pm: PM;
293
- };
380
+ unify(connectionId: string): Unify;
294
381
  }
295
382
 
296
383
  export { BundleUp };