-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathextensions.ts
More file actions
203 lines (181 loc) · 5.02 KB
/
extensions.ts
File metadata and controls
203 lines (181 loc) · 5.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../core/resource';
import { APIPromise } from '../core/api-promise';
import { type Uploadable } from '../core/uploads';
import { buildHeaders } from '../internal/headers';
import { RequestOptions } from '../internal/request-options';
import { multipartFormRequestOptions } from '../internal/uploads';
import { path } from '../internal/utils/path';
/**
* Create, list, retrieve, and delete browser extensions.
*/
export class Extensions extends APIResource {
/**
* List extensions owned by the caller's organization.
*
* @example
* ```ts
* const extensions = await client.extensions.list();
* ```
*/
list(options?: RequestOptions): APIPromise<ExtensionListResponse> {
return this._client.get('/extensions', options);
}
/**
* Delete an extension by its ID or by its name.
*
* @example
* ```ts
* await client.extensions.delete('id_or_name');
* ```
*/
delete(idOrName: string, options?: RequestOptions): APIPromise<void> {
return this._client.delete(path`/extensions/${idOrName}`, {
...options,
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
});
}
/**
* Download the extension as a ZIP archive by ID or name.
*
* @example
* ```ts
* const response = await client.extensions.download(
* 'id_or_name',
* );
*
* const content = await response.blob();
* console.log(content);
* ```
*/
download(idOrName: string, options?: RequestOptions): APIPromise<Response> {
return this._client.get(path`/extensions/${idOrName}`, {
...options,
headers: buildHeaders([{ Accept: 'application/octet-stream' }, options?.headers]),
__binaryResponse: true,
});
}
/**
* Returns a ZIP archive containing the unpacked extension fetched from the Chrome
* Web Store.
*
* @example
* ```ts
* const response =
* await client.extensions.downloadFromChromeStore({
* url: 'url',
* });
*
* const content = await response.blob();
* console.log(content);
* ```
*/
downloadFromChromeStore(
query: ExtensionDownloadFromChromeStoreParams,
options?: RequestOptions,
): APIPromise<Response> {
return this._client.get('/extensions/from_chrome_store', {
query,
...options,
headers: buildHeaders([{ Accept: 'application/octet-stream' }, options?.headers]),
__binaryResponse: true,
});
}
/**
* Upload a zip file containing an unpacked browser extension. Optionally provide a
* unique name for later reference.
*
* @example
* ```ts
* const response = await client.extensions.upload({
* file: fs.createReadStream('path/to/file'),
* });
* ```
*/
upload(body: ExtensionUploadParams, options?: RequestOptions): APIPromise<ExtensionUploadResponse> {
return this._client.post('/extensions', multipartFormRequestOptions({ body, ...options }, this._client));
}
}
export type ExtensionListResponse = Array<ExtensionListResponse.ExtensionListResponseItem>;
export namespace ExtensionListResponse {
/**
* A browser extension uploaded to Kernel.
*/
export interface ExtensionListResponseItem {
/**
* Unique identifier for the extension
*/
id: string;
/**
* Timestamp when the extension was created
*/
created_at: string;
/**
* Size of the extension archive in bytes
*/
size_bytes: number;
/**
* Timestamp when the extension was last used
*/
last_used_at?: string | null;
/**
* Optional, easier-to-reference name for the extension. Must be unique within the
* organization.
*/
name?: string | null;
}
}
/**
* A browser extension uploaded to Kernel.
*/
export interface ExtensionUploadResponse {
/**
* Unique identifier for the extension
*/
id: string;
/**
* Timestamp when the extension was created
*/
created_at: string;
/**
* Size of the extension archive in bytes
*/
size_bytes: number;
/**
* Timestamp when the extension was last used
*/
last_used_at?: string | null;
/**
* Optional, easier-to-reference name for the extension. Must be unique within the
* organization.
*/
name?: string | null;
}
export interface ExtensionDownloadFromChromeStoreParams {
/**
* Chrome Web Store URL for the extension.
*/
url: string;
/**
* Target operating system for the extension package. Defaults to linux.
*/
os?: 'win' | 'mac' | 'linux';
}
export interface ExtensionUploadParams {
/**
* ZIP file containing the browser extension.
*/
file: Uploadable;
/**
* Optional unique name within the organization to reference this extension.
*/
name?: string;
}
export declare namespace Extensions {
export {
type ExtensionListResponse as ExtensionListResponse,
type ExtensionUploadResponse as ExtensionUploadResponse,
type ExtensionDownloadFromChromeStoreParams as ExtensionDownloadFromChromeStoreParams,
type ExtensionUploadParams as ExtensionUploadParams,
};
}