lexmount 0.2.2 → 0.2.4

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 CHANGED
@@ -14,6 +14,9 @@ Node.js SDK for the Lexmount browser automation service.
14
14
  - Typed public API with ESM and CommonJS support
15
15
  - Session management with pagination support
16
16
  - Persistent context management
17
+ - Extension upload/list/get/delete
18
+ - Session downloads list/get/archive/delete
19
+ - Session creation with upstream proxy support
17
20
  - Structured SDK errors
18
21
  - Configurable SDK logging
19
22
  - TSDoc + TypeDoc based API documentation generation
@@ -93,6 +96,20 @@ const session = await client.sessions.create({
93
96
  });
94
97
  ```
95
98
 
99
+ Create a session with extensions and an upstream proxy:
100
+
101
+ ```ts
102
+ const session = await client.sessions.create({
103
+ extensionIds: ['ext_123'],
104
+ proxy: {
105
+ type: 'external',
106
+ server: 'http://10.3.6.54:28080',
107
+ username: 'user',
108
+ password: 'pass',
109
+ },
110
+ });
111
+ ```
112
+
96
113
  List sessions with pagination metadata:
97
114
 
98
115
  ```ts
@@ -110,6 +127,15 @@ Delete a session:
110
127
  await client.sessions.delete({ sessionId: 'session-id' });
111
128
  ```
112
129
 
130
+ List and archive session downloads:
131
+
132
+ ```ts
133
+ const downloads = await client.sessions.downloads.list(session.id);
134
+ console.log(downloads.summary.count);
135
+
136
+ const archive = await client.sessions.downloads.archive(session.id);
137
+ ```
138
+
113
139
  ### Contexts
114
140
 
115
141
  Create and inspect contexts:
@@ -138,6 +164,30 @@ Force release a stuck lock:
138
164
  await client.contexts.forceRelease('context-id');
139
165
  ```
140
166
 
167
+ ### Extensions
168
+
169
+ Upload an extension archive:
170
+
171
+ ```ts
172
+ const extension = await client.extensions.upload('/absolute/path/to/extension.zip', {
173
+ name: 'demo-extension',
174
+ });
175
+ ```
176
+
177
+ List and inspect extensions:
178
+
179
+ ```ts
180
+ const extensions = await client.extensions.list({ limit: 10 });
181
+ const details = await client.extensions.get(extension.id);
182
+ console.log(details.name);
183
+ ```
184
+
185
+ Delete an uploaded extension:
186
+
187
+ ```ts
188
+ await client.extensions.delete(extension.id);
189
+ ```
190
+
141
191
  ### Playwright Example
142
192
 
143
193
  ```ts
@@ -224,6 +274,9 @@ Example scripts live in [examples](./examples):
224
274
  - `context-list-get.ts`
225
275
  - `context-modes.ts`
226
276
  - `context-lock-handling.ts`
277
+ - `extension-basic.ts`
278
+ - `proxy-session.ts`
279
+ - `session-downloads.ts`
227
280
 
228
281
  Run them with:
229
282
 
@@ -232,6 +285,9 @@ cd examples
232
285
  npm install
233
286
  npm run playwright-basic
234
287
  npm run session-management
288
+ npm run extension-basic
289
+ npm run proxy-session
290
+ npm run session-downloads
235
291
  ```
236
292
 
237
293
  ### Development
@@ -259,6 +315,9 @@ Lexmount 浏览器自动化服务的 Node.js SDK。
259
315
  - 提供完整类型定义,同时支持 ESM 和 CommonJS
260
316
  - 会话管理,支持分页信息
261
317
  - 持久化 context 管理
318
+ - 扩展上传、查询、详情、删除
319
+ - 会话下载的查询、获取、归档、清理
320
+ - 支持通过上游代理创建会话
262
321
  - 结构化 SDK 异常
263
322
  - 可配置 SDK 日志
264
323
  - 基于 TSDoc + TypeDoc 的自动文档生成能力
@@ -338,6 +397,20 @@ const session = await client.sessions.create({
338
397
  });
339
398
  ```
340
399
 
400
+ 结合扩展和上游代理创建会话:
401
+
402
+ ```ts
403
+ const session = await client.sessions.create({
404
+ extensionIds: ['ext_123'],
405
+ proxy: {
406
+ type: 'external',
407
+ server: 'http://10.3.6.54:28080',
408
+ username: 'user',
409
+ password: 'pass',
410
+ },
411
+ });
412
+ ```
413
+
341
414
  分页列出会话:
342
415
 
343
416
  ```ts
@@ -355,6 +428,15 @@ for (const session of result) {
355
428
  await client.sessions.delete({ sessionId: 'session-id' });
356
429
  ```
357
430
 
431
+ 列出并归档会话下载:
432
+
433
+ ```ts
434
+ const downloads = await client.sessions.downloads.list(session.id);
435
+ console.log(downloads.summary.count);
436
+
437
+ const archive = await client.sessions.downloads.archive(session.id);
438
+ ```
439
+
358
440
  ### Contexts
359
441
 
360
442
  创建并查看 context:
@@ -383,6 +465,30 @@ const contexts = await client.contexts.list({
383
465
  await client.contexts.forceRelease('context-id');
384
466
  ```
385
467
 
468
+ ### Extensions
469
+
470
+ 上传扩展压缩包:
471
+
472
+ ```ts
473
+ const extension = await client.extensions.upload('/absolute/path/to/extension.zip', {
474
+ name: 'demo-extension',
475
+ });
476
+ ```
477
+
478
+ 列出并查看扩展详情:
479
+
480
+ ```ts
481
+ const extensions = await client.extensions.list({ limit: 10 });
482
+ const details = await client.extensions.get(extension.id);
483
+ console.log(details.name);
484
+ ```
485
+
486
+ 删除已上传扩展:
487
+
488
+ ```ts
489
+ await client.extensions.delete(extension.id);
490
+ ```
491
+
386
492
  ### Playwright 示例
387
493
 
388
494
  ```ts
@@ -469,6 +575,9 @@ npm run docs:html
469
575
  - `context-list-get.ts`
470
576
  - `context-modes.ts`
471
577
  - `context-lock-handling.ts`
578
+ - `extension-basic.ts`
579
+ - `proxy-session.ts`
580
+ - `session-downloads.ts`
472
581
 
473
582
  运行方式:
474
583
 
@@ -477,6 +586,9 @@ cd examples
477
586
  npm install
478
587
  npm run playwright-basic
479
588
  npm run session-management
589
+ npm run extension-basic
590
+ npm run proxy-session
591
+ npm run session-downloads
480
592
  ```
481
593
 
482
594
  ### 开发
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { AxiosResponse } from 'axios';
1
+ import { AxiosRequestConfig, AxiosResponse } from 'axios';
2
2
 
3
3
  /**
4
4
  * Supported SDK log levels.
@@ -67,6 +67,27 @@ interface SessionContext {
67
67
  */
68
68
  mode: ContextAccessMode;
69
69
  }
70
+ /**
71
+ * Upstream proxy configuration for a session.
72
+ */
73
+ interface SessionProxyConfig {
74
+ /**
75
+ * Proxy type. Currently `external` is supported by the API.
76
+ */
77
+ type?: 'external' | string;
78
+ /**
79
+ * Upstream proxy server URL.
80
+ */
81
+ server: string;
82
+ /**
83
+ * Optional upstream proxy username.
84
+ */
85
+ username?: string;
86
+ /**
87
+ * Optional upstream proxy password.
88
+ */
89
+ password?: string;
90
+ }
70
91
  /**
71
92
  * SDK client configuration.
72
93
  */
@@ -112,6 +133,14 @@ interface SessionCreateOptions {
112
133
  * Optional persistent context configuration.
113
134
  */
114
135
  context?: SessionContext;
136
+ /**
137
+ * Optional uploaded browser extension identifiers to mount.
138
+ */
139
+ extensionIds?: string[];
140
+ /**
141
+ * Optional upstream proxy configuration.
142
+ */
143
+ proxy?: SessionProxyConfig;
115
144
  }
116
145
  /**
117
146
  * Session list options.
@@ -174,6 +203,72 @@ interface ForceReleaseResponse {
174
203
  status: string;
175
204
  message: string;
176
205
  }
206
+ /**
207
+ * Extension metadata returned by the API.
208
+ */
209
+ interface ExtensionInfoShape {
210
+ id: string;
211
+ name: string;
212
+ projectId: string;
213
+ createdAt?: string;
214
+ updatedAt?: string;
215
+ }
216
+ /**
217
+ * Extension upload options.
218
+ */
219
+ interface ExtensionUploadOptions {
220
+ /**
221
+ * Optional display name for the uploaded extension.
222
+ */
223
+ name?: string;
224
+ /**
225
+ * Override the default project identifier.
226
+ */
227
+ projectId?: string;
228
+ }
229
+ /**
230
+ * Extension list options.
231
+ */
232
+ interface ExtensionListOptions {
233
+ /**
234
+ * Override the default project identifier.
235
+ */
236
+ projectId?: string;
237
+ /**
238
+ * Maximum number of extensions to return.
239
+ */
240
+ limit?: number;
241
+ /**
242
+ * Number of extensions to skip.
243
+ */
244
+ offset?: number;
245
+ }
246
+ /**
247
+ * Session download metadata returned by the API.
248
+ */
249
+ interface SessionDownloadInfoShape {
250
+ id: string;
251
+ filename: string;
252
+ contentType: string | null;
253
+ size: number;
254
+ sha256: string | null;
255
+ status: string;
256
+ createdAt: string;
257
+ }
258
+ /**
259
+ * Structured response from session download listing.
260
+ */
261
+ interface SessionDownloadsListResponseShape {
262
+ count: number;
263
+ totalSize: number;
264
+ }
265
+ /**
266
+ * Structured response from session download deletion.
267
+ */
268
+ interface SessionDownloadsDeleteResponseShape {
269
+ status: string;
270
+ deletedCount: number;
271
+ }
177
272
  /**
178
273
  * Session pagination metadata.
179
274
  */
@@ -250,6 +345,35 @@ declare class ContextsResource {
250
345
  private handleError;
251
346
  }
252
347
 
348
+ /**
349
+ * Extension resource implementation.
350
+ */
351
+
352
+ /**
353
+ * Extension metadata returned by the API.
354
+ */
355
+ declare class ExtensionInfo implements ExtensionInfoShape {
356
+ readonly id: string;
357
+ readonly name: string;
358
+ readonly projectId: string;
359
+ readonly createdAt?: string;
360
+ readonly updatedAt?: string;
361
+ constructor(shape: ExtensionInfoShape);
362
+ }
363
+ /**
364
+ * Browser extension resource operations.
365
+ */
366
+ declare class ExtensionsResource {
367
+ private readonly client;
368
+ constructor(client: Lexmount);
369
+ upload(filePath: string, options?: ExtensionUploadOptions): Promise<ExtensionInfo>;
370
+ list(options?: ExtensionListOptions): Promise<ExtensionInfo[]>;
371
+ get(extensionId: string, projectId?: string): Promise<ExtensionInfo>;
372
+ delete(extensionId: string): Promise<void>;
373
+ private parseInfo;
374
+ private handleError;
375
+ }
376
+
253
377
  /**
254
378
  * Session resource implementation.
255
379
  */
@@ -275,7 +399,6 @@ interface SessionInfoOptions {
275
399
  createdAt: string;
276
400
  inspectUrl: string;
277
401
  containerId: string | null;
278
- inspectUrlDbg?: string;
279
402
  ws?: string | null;
280
403
  client?: Lexmount;
281
404
  }
@@ -292,7 +415,6 @@ declare class SessionInfo {
292
415
  readonly createdAt: string;
293
416
  readonly inspectUrl: string;
294
417
  readonly containerId: string | null;
295
- readonly inspectUrlDbg?: string;
296
418
  readonly ws: string | null;
297
419
  private readonly client?;
298
420
  private closed;
@@ -327,6 +449,47 @@ declare class SessionListResponse implements Iterable<SessionInfo> {
327
449
  [Symbol.iterator](): Iterator<SessionInfo>;
328
450
  at(index: number): SessionInfo | undefined;
329
451
  }
452
+ /**
453
+ * Session download metadata returned by the API.
454
+ */
455
+ declare class SessionDownloadInfo implements SessionDownloadInfoShape {
456
+ readonly id: string;
457
+ readonly filename: string;
458
+ readonly contentType: string | null;
459
+ readonly size: number;
460
+ readonly sha256: string | null;
461
+ readonly status: string;
462
+ readonly createdAt: string;
463
+ constructor(shape: SessionDownloadInfoShape);
464
+ }
465
+ /**
466
+ * Structured response from `sessions.downloads.list()`.
467
+ */
468
+ declare class SessionDownloadsListResponse {
469
+ readonly downloads: SessionDownloadInfo[];
470
+ readonly summary: SessionDownloadsListResponseShape;
471
+ constructor(downloads: SessionDownloadInfo[], summary: SessionDownloadsListResponseShape);
472
+ }
473
+ /**
474
+ * Structured response from `sessions.downloads.delete()`.
475
+ */
476
+ declare class SessionDownloadsDeleteResponse implements SessionDownloadsDeleteResponseShape {
477
+ readonly status: string;
478
+ readonly deletedCount: number;
479
+ constructor(shape: SessionDownloadsDeleteResponseShape);
480
+ }
481
+ /**
482
+ * Session download operations.
483
+ */
484
+ declare class SessionDownloadsResource {
485
+ private readonly client;
486
+ constructor(client: Lexmount);
487
+ list(sessionId: string, projectId?: string): Promise<SessionDownloadsListResponse>;
488
+ get(sessionId: string, downloadId: string, projectId?: string): Promise<Buffer>;
489
+ archive(sessionId: string, projectId?: string): Promise<Buffer>;
490
+ delete(sessionId: string, projectId?: string): Promise<SessionDownloadsDeleteResponse>;
491
+ private handleError;
492
+ }
330
493
  /**
331
494
  * Alias kept for parity with the Python SDK.
332
495
  */
@@ -336,6 +499,7 @@ type SessionCreateResponse = SessionInfo;
336
499
  */
337
500
  declare class SessionsResource {
338
501
  private readonly client;
502
+ readonly downloads: SessionDownloadsResource;
339
503
  constructor(client: Lexmount);
340
504
  /**
341
505
  * Create a new browser session.
@@ -355,6 +519,7 @@ declare class SessionsResource {
355
519
  * @internal
356
520
  */
357
521
  _getWebSocketDebuggerUrl(sessionId: string): Promise<string | null>;
522
+ private normalizeProxy;
358
523
  private handleCreateError;
359
524
  private handleListError;
360
525
  private handleDeleteError;
@@ -388,6 +553,10 @@ declare class Lexmount {
388
553
  * Persistent context operations.
389
554
  */
390
555
  readonly contexts: ContextsResource;
556
+ /**
557
+ * Browser extension operations.
558
+ */
559
+ readonly extensions: ExtensionsResource;
391
560
  private readonly httpClient;
392
561
  constructor(config?: LexmountConfig);
393
562
  /**
@@ -395,19 +564,19 @@ declare class Lexmount {
395
564
  *
396
565
  * @internal
397
566
  */
398
- _post<T = unknown>(url: string, data: Record<string, unknown>): Promise<AxiosResponse<T>>;
567
+ _post<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
399
568
  /**
400
569
  * Internal GET request helper with timeout and network error mapping.
401
570
  *
402
571
  * @internal
403
572
  */
404
- _get<T = unknown>(url: string, params: Record<string, unknown>): Promise<AxiosResponse<T>>;
573
+ _get<T = unknown>(url: string, params?: Record<string, unknown>, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
405
574
  /**
406
575
  * Internal DELETE request helper with timeout and network error mapping.
407
576
  *
408
577
  * @internal
409
578
  */
410
- _delete<T = unknown>(url: string, data: Record<string, unknown>): Promise<AxiosResponse<T>>;
579
+ _delete<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
411
580
  /**
412
581
  * Close the client.
413
582
  *
@@ -420,6 +589,7 @@ declare class Lexmount {
420
589
  toString(): string;
421
590
  private request;
422
591
  private normalizeRequestError;
592
+ private getDefaultHeaders;
423
593
  }
424
594
 
425
595
  /**
@@ -487,6 +657,6 @@ declare class TimeoutError extends LexmountError {
487
657
  /**
488
658
  * Lexmount Node.js SDK.
489
659
  */
490
- declare const VERSION = "0.2.0";
660
+ declare const VERSION = "0.2.4";
491
661
 
492
- export { APIError, AuthenticationError, type BrowserMode, type ContextAccessMode, type ContextCreateOptions, ContextInfo, type ContextListOptions, ContextListResponse, ContextLockedError, type ContextMetadata, ContextNotFoundError, type ContextStatus, ContextsResource, type ForceReleaseResponse, Lexmount, type LexmountConfig, LexmountError, LexmountLogger, type LogLevel, NetworkError, PaginationInfo, type PaginationInfoShape, type SessionContext, type SessionCreateOptions, type SessionCreateResponse, type SessionDeleteOptions, SessionInfo, type SessionListOptions, SessionListResponse, SessionNotFoundError, type SessionStatus, SessionsResource, TimeoutError, VERSION, ValidationError, Lexmount as default, disableLogging, enableLogging, getLogger, setLogLevel };
662
+ export { APIError, AuthenticationError, type BrowserMode, type ContextAccessMode, type ContextCreateOptions, ContextInfo, type ContextListOptions, ContextListResponse, ContextLockedError, type ContextMetadata, ContextNotFoundError, type ContextStatus, ContextsResource, ExtensionInfo, type ExtensionInfoShape, type ExtensionListOptions, type ExtensionUploadOptions, ExtensionsResource, type ForceReleaseResponse, Lexmount, type LexmountConfig, LexmountError, LexmountLogger, type LogLevel, NetworkError, PaginationInfo, type PaginationInfoShape, type SessionContext, type SessionCreateOptions, type SessionCreateResponse, type SessionDeleteOptions, SessionDownloadInfo, type SessionDownloadInfoShape, SessionDownloadsDeleteResponse, type SessionDownloadsDeleteResponseShape, SessionDownloadsListResponse, type SessionDownloadsListResponseShape, SessionDownloadsResource, SessionInfo, type SessionListOptions, SessionListResponse, SessionNotFoundError, type SessionProxyConfig, type SessionStatus, SessionsResource, TimeoutError, VERSION, ValidationError, Lexmount as default, disableLogging, enableLogging, getLogger, setLogLevel };