@@ -10,50 +10,65 @@ import { path } from '../internal/utils/path';
1010
1111export class Extensions extends APIResource {
1212 /**
13- * List extensions owned by the caller's organization.
13+ * Upload a zip file containing an unpacked browser extension. Optionally provide a
14+ * unique name for later reference.
1415 *
1516 * @example
1617 * ```ts
17- * const extensions = await client.extensions.list();
18+ * const extension = await client.extensions.create({
19+ * file: fs.createReadStream('path/to/file'),
20+ * });
1821 * ```
1922 */
20- list ( options ?: RequestOptions ) : APIPromise < ExtensionListResponse > {
21- return this . _client . get ( '/extensions' , options ) ;
23+ create ( body : ExtensionCreateParams , options ?: RequestOptions ) : APIPromise < ExtensionCreateResponse > {
24+ return this . _client . post ( '/extensions' , multipartFormRequestOptions ( { body , ... options } , this . _client ) ) ;
2225 }
2326
2427 /**
25- * Delete an extension by its ID or by its name.
28+ * Download the extension as a ZIP archive by ID or name.
2629 *
2730 * @example
2831 * ```ts
29- * await client.extensions.delete('id_or_name');
32+ * const extension = await client.extensions.retrieve(
33+ * 'id_or_name',
34+ * );
35+ *
36+ * const content = await extension.blob();
37+ * console.log(content);
3038 * ```
3139 */
32- delete ( idOrName : string , options ?: RequestOptions ) : APIPromise < void > {
33- return this . _client . delete ( path `/extensions/${ idOrName } ` , {
40+ retrieve ( idOrName : string , options ?: RequestOptions ) : APIPromise < Response > {
41+ return this . _client . get ( path `/extensions/${ idOrName } ` , {
3442 ...options ,
35- headers : buildHeaders ( [ { Accept : '*/*' } , options ?. headers ] ) ,
43+ headers : buildHeaders ( [ { Accept : 'application/octet-stream' } , options ?. headers ] ) ,
44+ __binaryResponse : true ,
3645 } ) ;
3746 }
3847
3948 /**
40- * Download the extension as a ZIP archive by ID or name .
49+ * List extensions owned by the caller's organization .
4150 *
4251 * @example
4352 * ```ts
44- * const response = await client.extensions.download(
45- * 'id_or_name',
46- * );
53+ * const extensions = await client.extensions.list();
54+ * ```
55+ */
56+ list ( options ?: RequestOptions ) : APIPromise < ExtensionListResponse > {
57+ return this . _client . get ( '/extensions' , options ) ;
58+ }
59+
60+ /**
61+ * Delete an extension by its ID or by its name.
4762 *
48- * const content = await response.blob();
49- * console.log(content);
63+ * @example
64+ * ```ts
65+ * await client.extensions.delete('id_or_name');
5066 * ```
5167 */
52- download ( idOrName : string , options ?: RequestOptions ) : APIPromise < Response > {
53- return this . _client . get ( path `/extensions/${ idOrName } ` , {
68+ delete ( idOrName : string , options ?: RequestOptions ) : APIPromise < void > {
69+ return this . _client . delete ( path `/extensions/${ idOrName } ` , {
5470 ...options ,
55- headers : buildHeaders ( [ { Accept : 'application/octet-stream' } , options ?. headers ] ) ,
56- __binaryResponse : true ,
71+ headers : buildHeaders ( [ { Accept : '*/*' } , options ?. headers ] ) ,
5772 } ) ;
5873 }
5974
@@ -83,21 +98,37 @@ export class Extensions extends APIResource {
8398 __binaryResponse : true ,
8499 } ) ;
85100 }
101+ }
86102
103+ /**
104+ * A browser extension uploaded to Kernel.
105+ */
106+ export interface ExtensionCreateResponse {
87107 /**
88- * Upload a zip file containing an unpacked browser extension. Optionally provide a
89- * unique name for later reference.
90- *
91- * @example
92- * ```ts
93- * const response = await client.extensions.upload({
94- * file: fs.createReadStream('path/to/file'),
95- * });
96- * ```
108+ * Unique identifier for the extension
97109 */
98- upload ( body : ExtensionUploadParams , options ?: RequestOptions ) : APIPromise < ExtensionUploadResponse > {
99- return this . _client . post ( '/extensions' , multipartFormRequestOptions ( { body, ...options } , this . _client ) ) ;
100- }
110+ id : string ;
111+
112+ /**
113+ * Timestamp when the extension was created
114+ */
115+ created_at : string ;
116+
117+ /**
118+ * Size of the extension archive in bytes
119+ */
120+ size_bytes : number ;
121+
122+ /**
123+ * Timestamp when the extension was last used
124+ */
125+ last_used_at ?: string | null ;
126+
127+ /**
128+ * Optional, easier-to-reference name for the extension. Must be unique within the
129+ * organization.
130+ */
131+ name ?: string | null ;
101132}
102133
103134export type ExtensionListResponse = Array < ExtensionListResponse . ExtensionListResponseItem > ;
@@ -135,35 +166,16 @@ export namespace ExtensionListResponse {
135166 }
136167}
137168
138- /**
139- * A browser extension uploaded to Kernel.
140- */
141- export interface ExtensionUploadResponse {
142- /**
143- * Unique identifier for the extension
144- */
145- id : string ;
146-
169+ export interface ExtensionCreateParams {
147170 /**
148- * Timestamp when the extension was created
149- */
150- created_at : string ;
151-
152- /**
153- * Size of the extension archive in bytes
154- */
155- size_bytes : number ;
156-
157- /**
158- * Timestamp when the extension was last used
171+ * ZIP file containing the browser extension.
159172 */
160- last_used_at ?: string | null ;
173+ file : Uploadable ;
161174
162175 /**
163- * Optional, easier-to-reference name for the extension. Must be unique within the
164- * organization.
176+ * Optional unique name within the organization to reference this extension.
165177 */
166- name ?: string | null ;
178+ name ?: string ;
167179}
168180
169181export interface ExtensionDownloadFromChromeStoreParams {
@@ -178,23 +190,11 @@ export interface ExtensionDownloadFromChromeStoreParams {
178190 os ?: 'win' | 'mac' | 'linux' ;
179191}
180192
181- export interface ExtensionUploadParams {
182- /**
183- * ZIP file containing the browser extension.
184- */
185- file : Uploadable ;
186-
187- /**
188- * Optional unique name within the organization to reference this extension.
189- */
190- name ?: string ;
191- }
192-
193193export declare namespace Extensions {
194194 export {
195+ type ExtensionCreateResponse as ExtensionCreateResponse ,
195196 type ExtensionListResponse as ExtensionListResponse ,
196- type ExtensionUploadResponse as ExtensionUploadResponse ,
197+ type ExtensionCreateParams as ExtensionCreateParams ,
197198 type ExtensionDownloadFromChromeStoreParams as ExtensionDownloadFromChromeStoreParams ,
198- type ExtensionUploadParams as ExtensionUploadParams ,
199199 } ;
200200}
0 commit comments