@adbjs/sdk 1.0.0 → 2.0.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.cts CHANGED
@@ -162,17 +162,17 @@ declare class LinkResource extends BaseResource {
162
162
  *
163
163
  * @example
164
164
  * ```ts
165
- * const info = await client.link.infos('https://example.com/file.zip')
166
- * console.log(info)
165
+ * const data = await client.link.infos('https://example.com/file.zip')
166
+ * console.log(data.infos)
167
167
  *
168
168
  * // With password
169
- * const protectedInfo = await client.link.infos(
169
+ * const protectedData = await client.link.infos(
170
170
  * 'https://example.com/protected.zip',
171
171
  * 'mypassword'
172
172
  * )
173
173
  * ```
174
174
  */
175
- infos(links: string | string[], password?: string): Promise<LinkInfoItem[] | undefined>;
175
+ infos(links: string | string[], password?: string): Promise<LinkInfosResponseData | undefined>;
176
176
  /**
177
177
  * Extract links from redirectors/link protectors
178
178
  *
@@ -180,10 +180,11 @@ declare class LinkResource extends BaseResource {
180
180
  *
181
181
  * @example
182
182
  * ```ts
183
- * const links = await client.link.redirector('https://linkprotector.com/abc123')
183
+ * const data = await client.link.redirector('https://linkprotector.com/abc123')
184
+ * console.log(data.links)
184
185
  * ```
185
186
  */
186
- redirector(link: string): Promise<string[] | undefined>;
187
+ redirector(link: string): Promise<RedirectorResponseData | undefined>;
187
188
  /**
188
189
  * Unlock a download link
189
190
  *
@@ -285,12 +286,6 @@ interface WatchOptions {
285
286
  * @default 'Ready'
286
287
  */
287
288
  stopOnStatus?: string;
288
- /**
289
- * Use live mode for reduced bandwidth (delta sync)
290
- * When enabled, only changes are transmitted instead of full status
291
- * @default false
292
- */
293
- useLiveMode?: boolean;
294
289
  }
295
290
  /**
296
291
  * Magnet/Torrent resource for managing torrent downloads
@@ -363,16 +358,38 @@ declare class MagnetResource extends BaseResource {
363
358
  */
364
359
  statusList(statusFilter?: 'active' | 'ready' | 'expired' | 'error'): Promise<MagnetStatusResponseData | undefined>;
365
360
  /**
366
- * Get magnet status using live mode for reduced bandwidth consumption
361
+ * Get magnet status using live mode for bandwidth-optimized delta synchronization
362
+ *
363
+ * Live mode is designed for monitoring multiple magnets efficiently by only transmitting
364
+ * changes between polling intervals, drastically reducing bandwidth usage for dashboards
365
+ * and real-time monitoring applications.
366
+ *
367
+ * ## How it works
368
+ *
369
+ * 1. **Session initialization**: Generate a random session ID and start with counter = 0
370
+ * 2. **First call (fullsync)**: Returns ALL magnets with `fullsync: true`
371
+ * 3. **Update counter**: Use the `counter` value returned by the API for the next call
372
+ * 4. **Subsequent calls (delta)**: Returns ONLY magnets that changed since last call
373
+ * 5. **Repeat**: Keep calling with updated counter to receive only deltas
374
+ *
375
+ * ## When to use
367
376
  *
368
- * Live mode uses delta synchronization - only changes since the last call are transmitted.
369
- * On the first call (counter=0), all data is returned with `fullsync: true`.
370
- * Subsequent calls return only modifications.
377
+ * - Monitoring multiple active magnets simultaneously
378
+ * - Building real-time dashboards
379
+ * - High-frequency polling scenarios (every few seconds)
380
+ * - ❌ Watching a single specific magnet (use `watch()` instead)
371
381
  *
372
- * @param options - Live mode options
373
- * @param options.session - Session ID (generate once per session and reuse)
374
- * @param options.counter - Synchronization counter (start at 0, use returned counter for next call)
375
- * @param id - Optional magnet ID to filter a specific magnet
382
+ * ## Important notes
383
+ *
384
+ * - **Don't use the `id` parameter**: Passing an ID defeats the purpose of live mode
385
+ * as it disables delta sync and behaves like a regular `status()` call
386
+ * - **Session persistence**: Keep the same session ID for the entire monitoring session
387
+ * - **Counter tracking**: Always update the counter with the value returned by the API
388
+ * - **Empty deltas**: When no magnets changed, `magnets` will be an empty array
389
+ *
390
+ * @param options - Live mode session options
391
+ * @param options.session - Unique session ID (generate once: `Math.floor(Math.random() * 1000000)`)
392
+ * @param options.counter - Sync counter (start at 0, then use value from previous API response)
376
393
  *
377
394
  * @example
378
395
  * ```ts
@@ -380,27 +397,60 @@ declare class MagnetResource extends BaseResource {
380
397
  * const session = Math.floor(Math.random() * 1000000)
381
398
  * let counter = 0
382
399
  *
383
- * // First call - full sync
400
+ * // First call - returns all magnets (fullsync: true)
384
401
  * const firstCall = await client.magnet.statusLive({ session, counter })
385
402
  * console.log('Full sync:', firstCall.fullsync) // true
386
- * console.log('All magnets:', firstCall.magnets)
387
- *
388
- * // Update counter with value returned by API
389
- * counter = firstCall.counter
403
+ * console.log('All magnets:', firstCall.magnets) // Array of all magnets
404
+ * counter = firstCall.counter // Update counter for next call
390
405
  *
391
- * // Second call - only changes
406
+ * // Second call - returns only magnets that changed
407
+ * await new Promise(resolve => setTimeout(resolve, 3000)) // Wait 3 seconds
392
408
  * const secondCall = await client.magnet.statusLive({ session, counter })
393
- * console.log('Delta sync:', secondCall.magnets) // Only modified magnets
409
+ * console.log('Delta sync:', secondCall.magnets) // Only changed magnets
410
+ * counter = secondCall.counter
411
+ *
412
+ * // Example: Monitor all magnets until none are active
413
+ * const activeMagnets = new Map()
414
+ *
415
+ * while (true) {
416
+ * const response = await client.magnet.statusLive({ session, counter })
417
+ * counter = response.counter ?? counter
418
+ *
419
+ * // Update our local state with changes
420
+ * if (response.fullsync) {
421
+ * activeMagnets.clear()
422
+ * response.magnets?.forEach(m => activeMagnets.set(m.id, m))
423
+ * } else {
424
+ * response.magnets?.forEach(m => {
425
+ * if (m.status === 'Ready' || m.status === 'Error' || m.status === 'Expired') {
426
+ * activeMagnets.delete(m.id)
427
+ * } else {
428
+ * activeMagnets.set(m.id, m)
429
+ * }
430
+ * })
431
+ * }
432
+ *
433
+ * // Display current state
434
+ * console.log(`Active downloads: ${activeMagnets.size}`)
435
+ * activeMagnets.forEach(m => {
436
+ * console.log(` ${m.filename}: ${m.status} - ${m.downloaded}/${m.size} bytes`)
437
+ * })
438
+ *
439
+ * // Stop when no more active magnets
440
+ * if (activeMagnets.size === 0) {
441
+ * console.log('All downloads completed!')
442
+ * break
443
+ * }
394
444
  *
395
- * // Filter specific magnet in live mode
396
- * const magnetLive = await client.magnet.statusLive({ session, counter }, 123)
445
+ * await new Promise(resolve => setTimeout(resolve, 3000))
446
+ * }
397
447
  * ```
398
448
  *
399
449
  * @remarks
400
- * This is ideal for real-time dashboards or frequent polling scenarios
401
- * as it significantly reduces bandwidth usage by transmitting only changes.
450
+ * This method is ideal for scenarios where you're monitoring multiple magnets and want
451
+ * to minimize bandwidth. For simple single-magnet monitoring, use `watch()` instead.
402
452
  */
403
- statusLive(options: LiveStatusOptions, id?: number): Promise<MagnetStatusResponseData | undefined>;
453
+ statusLive(options: LiveStatusOptions): Promise<MagnetStatusResponseData | undefined>;
404
454
  /**
405
455
  * Delete a magnet
406
456
  *
@@ -434,9 +484,9 @@ declare class MagnetResource extends BaseResource {
434
484
  *
435
485
  * @example
436
486
  * ```ts
437
- * const files = await client.magnet.files(123)
438
- * files?.forEach(file => {
439
- * console.log(file.filename, file.link)
487
+ * const data = await client.magnet.files(123)
488
+ * data?.magnets?.forEach(magnet => {
489
+ * console.log(magnet.filename, magnet.files)
440
490
  * })
441
491
  * ```
442
492
  *
@@ -444,33 +494,32 @@ declare class MagnetResource extends BaseResource {
444
494
  * Files are now retrieved separately from magnet status (since v4.1)
445
495
  * Only available for magnets with status 'Ready'
446
496
  */
447
- files(ids: number | number[]): Promise<MagnetFilesItem[] | undefined>;
497
+ files(ids: number | number[]): Promise<MagnetFilesResponseData | undefined>;
448
498
  /**
449
499
  * Watch a magnet's status with automatic polling
450
500
  *
501
+ * This is a simple helper that polls the status of a specific magnet until it reaches
502
+ * a target status (default: 'Ready'). For advanced use cases with multiple magnets
503
+ * or bandwidth optimization, use `statusLive()` directly instead.
504
+ *
451
505
  * @param id - The magnet ID to watch
452
506
  * @param options - Watch options
453
507
  * @param options.interval - Polling interval in milliseconds (default: 3000)
454
508
  * @param options.maxAttempts - Maximum polling attempts, 0 for infinite (default: 0)
455
509
  * @param options.onUpdate - Callback called on each status update
456
510
  * @param options.stopOnStatus - Stop when magnet reaches this status (default: 'Ready')
457
- * @param options.useLiveMode - Use live mode for reduced bandwidth (default: false)
458
511
  *
459
512
  * @example
460
513
  * ```ts
461
- * // Standard mode
462
514
  * await client.magnet.watch(123, {
463
515
  * onUpdate: (status) => console.log('Status:', status.magnets[0]?.status),
464
516
  * stopOnStatus: 'Ready'
465
517
  * })
466
- *
467
- * // Live mode for reduced bandwidth
468
- * await client.magnet.watch(123, {
469
- * useLiveMode: true,
470
- * interval: 2000,
471
- * onUpdate: (status) => console.log('Update:', status)
472
- * })
473
518
  * ```
519
+ *
520
+ * @remarks
521
+ * For monitoring multiple magnets efficiently, use `statusLive()` directly.
522
+ * See the `statusLive()` documentation for details on delta synchronization.
474
523
  */
475
524
  watch(id: number, options?: WatchOptions): Promise<MagnetStatusResponseData | undefined>;
476
525
  }
@@ -584,11 +633,11 @@ declare class UserResource extends BaseResource {
584
633
  *
585
634
  * @example
586
635
  * ```ts
587
- * const user = await client.user.getInfo()
588
- * console.log(user.username, user.isPremium)
636
+ * const data = await client.user.getInfo()
637
+ * console.log(data.user.username, data.user.isPremium)
589
638
  * ```
590
639
  */
591
- getInfo(): Promise<UserInfo | undefined>;
640
+ getInfo(): Promise<UserResponseData | undefined>;
592
641
  /**
593
642
  * Get available hosts for the current user based on their subscription
594
643
  *
package/dist/index.d.ts CHANGED
@@ -162,17 +162,17 @@ declare class LinkResource extends BaseResource {
162
162
  *
163
163
  * @example
164
164
  * ```ts
165
- * const info = await client.link.infos('https://example.com/file.zip')
166
- * console.log(info)
165
+ * const data = await client.link.infos('https://example.com/file.zip')
166
+ * console.log(data.infos)
167
167
  *
168
168
  * // With password
169
- * const protectedInfo = await client.link.infos(
169
+ * const protectedData = await client.link.infos(
170
170
  * 'https://example.com/protected.zip',
171
171
  * 'mypassword'
172
172
  * )
173
173
  * ```
174
174
  */
175
- infos(links: string | string[], password?: string): Promise<LinkInfoItem[] | undefined>;
175
+ infos(links: string | string[], password?: string): Promise<LinkInfosResponseData | undefined>;
176
176
  /**
177
177
  * Extract links from redirectors/link protectors
178
178
  *
@@ -180,10 +180,11 @@ declare class LinkResource extends BaseResource {
180
180
  *
181
181
  * @example
182
182
  * ```ts
183
- * const links = await client.link.redirector('https://linkprotector.com/abc123')
183
+ * const data = await client.link.redirector('https://linkprotector.com/abc123')
184
+ * console.log(data.links)
184
185
  * ```
185
186
  */
186
- redirector(link: string): Promise<string[] | undefined>;
187
+ redirector(link: string): Promise<RedirectorResponseData | undefined>;
187
188
  /**
188
189
  * Unlock a download link
189
190
  *
@@ -285,12 +286,6 @@ interface WatchOptions {
285
286
  * @default 'Ready'
286
287
  */
287
288
  stopOnStatus?: string;
288
- /**
289
- * Use live mode for reduced bandwidth (delta sync)
290
- * When enabled, only changes are transmitted instead of full status
291
- * @default false
292
- */
293
- useLiveMode?: boolean;
294
289
  }
295
290
  /**
296
291
  * Magnet/Torrent resource for managing torrent downloads
@@ -363,16 +358,38 @@ declare class MagnetResource extends BaseResource {
363
358
  */
364
359
  statusList(statusFilter?: 'active' | 'ready' | 'expired' | 'error'): Promise<MagnetStatusResponseData | undefined>;
365
360
  /**
366
- * Get magnet status using live mode for reduced bandwidth consumption
361
+ * Get magnet status using live mode for bandwidth-optimized delta synchronization
362
+ *
363
+ * Live mode is designed for monitoring multiple magnets efficiently by only transmitting
364
+ * changes between polling intervals, drastically reducing bandwidth usage for dashboards
365
+ * and real-time monitoring applications.
366
+ *
367
+ * ## How it works
368
+ *
369
+ * 1. **Session initialization**: Generate a random session ID and start with counter = 0
370
+ * 2. **First call (fullsync)**: Returns ALL magnets with `fullsync: true`
371
+ * 3. **Update counter**: Use the `counter` value returned by the API for the next call
372
+ * 4. **Subsequent calls (delta)**: Returns ONLY magnets that changed since last call
373
+ * 5. **Repeat**: Keep calling with updated counter to receive only deltas
374
+ *
375
+ * ## When to use
367
376
  *
368
- * Live mode uses delta synchronization - only changes since the last call are transmitted.
369
- * On the first call (counter=0), all data is returned with `fullsync: true`.
370
- * Subsequent calls return only modifications.
377
+ * - Monitoring multiple active magnets simultaneously
378
+ * - Building real-time dashboards
379
+ * - High-frequency polling scenarios (every few seconds)
380
+ * - ❌ Watching a single specific magnet (use `watch()` instead)
371
381
  *
372
- * @param options - Live mode options
373
- * @param options.session - Session ID (generate once per session and reuse)
374
- * @param options.counter - Synchronization counter (start at 0, use returned counter for next call)
375
- * @param id - Optional magnet ID to filter a specific magnet
382
+ * ## Important notes
383
+ *
384
+ * - **Don't use the `id` parameter**: Passing an ID defeats the purpose of live mode
385
+ * as it disables delta sync and behaves like a regular `status()` call
386
+ * - **Session persistence**: Keep the same session ID for the entire monitoring session
387
+ * - **Counter tracking**: Always update the counter with the value returned by the API
388
+ * - **Empty deltas**: When no magnets changed, `magnets` will be an empty array
389
+ *
390
+ * @param options - Live mode session options
391
+ * @param options.session - Unique session ID (generate once: `Math.floor(Math.random() * 1000000)`)
392
+ * @param options.counter - Sync counter (start at 0, then use value from previous API response)
376
393
  *
377
394
  * @example
378
395
  * ```ts
@@ -380,27 +397,60 @@ declare class MagnetResource extends BaseResource {
380
397
  * const session = Math.floor(Math.random() * 1000000)
381
398
  * let counter = 0
382
399
  *
383
- * // First call - full sync
400
+ * // First call - returns all magnets (fullsync: true)
384
401
  * const firstCall = await client.magnet.statusLive({ session, counter })
385
402
  * console.log('Full sync:', firstCall.fullsync) // true
386
- * console.log('All magnets:', firstCall.magnets)
387
- *
388
- * // Update counter with value returned by API
389
- * counter = firstCall.counter
403
+ * console.log('All magnets:', firstCall.magnets) // Array of all magnets
404
+ * counter = firstCall.counter // Update counter for next call
390
405
  *
391
- * // Second call - only changes
406
+ * // Second call - returns only magnets that changed
407
+ * await new Promise(resolve => setTimeout(resolve, 3000)) // Wait 3 seconds
392
408
  * const secondCall = await client.magnet.statusLive({ session, counter })
393
- * console.log('Delta sync:', secondCall.magnets) // Only modified magnets
409
+ * console.log('Delta sync:', secondCall.magnets) // Only changed magnets
410
+ * counter = secondCall.counter
411
+ *
412
+ * // Example: Monitor all magnets until none are active
413
+ * const activeMagnets = new Map()
414
+ *
415
+ * while (true) {
416
+ * const response = await client.magnet.statusLive({ session, counter })
417
+ * counter = response.counter ?? counter
418
+ *
419
+ * // Update our local state with changes
420
+ * if (response.fullsync) {
421
+ * activeMagnets.clear()
422
+ * response.magnets?.forEach(m => activeMagnets.set(m.id, m))
423
+ * } else {
424
+ * response.magnets?.forEach(m => {
425
+ * if (m.status === 'Ready' || m.status === 'Error' || m.status === 'Expired') {
426
+ * activeMagnets.delete(m.id)
427
+ * } else {
428
+ * activeMagnets.set(m.id, m)
429
+ * }
430
+ * })
431
+ * }
432
+ *
433
+ * // Display current state
434
+ * console.log(`Active downloads: ${activeMagnets.size}`)
435
+ * activeMagnets.forEach(m => {
436
+ * console.log(` ${m.filename}: ${m.status} - ${m.downloaded}/${m.size} bytes`)
437
+ * })
438
+ *
439
+ * // Stop when no more active magnets
440
+ * if (activeMagnets.size === 0) {
441
+ * console.log('All downloads completed!')
442
+ * break
443
+ * }
394
444
  *
395
- * // Filter specific magnet in live mode
396
- * const magnetLive = await client.magnet.statusLive({ session, counter }, 123)
445
+ * await new Promise(resolve => setTimeout(resolve, 3000))
446
+ * }
397
447
  * ```
398
448
  *
399
449
  * @remarks
400
- * This is ideal for real-time dashboards or frequent polling scenarios
401
- * as it significantly reduces bandwidth usage by transmitting only changes.
450
+ * This method is ideal for scenarios where you're monitoring multiple magnets and want
451
+ * to minimize bandwidth. For simple single-magnet monitoring, use `watch()` instead.
402
452
  */
403
- statusLive(options: LiveStatusOptions, id?: number): Promise<MagnetStatusResponseData | undefined>;
453
+ statusLive(options: LiveStatusOptions): Promise<MagnetStatusResponseData | undefined>;
404
454
  /**
405
455
  * Delete a magnet
406
456
  *
@@ -434,9 +484,9 @@ declare class MagnetResource extends BaseResource {
434
484
  *
435
485
  * @example
436
486
  * ```ts
437
- * const files = await client.magnet.files(123)
438
- * files?.forEach(file => {
439
- * console.log(file.filename, file.link)
487
+ * const data = await client.magnet.files(123)
488
+ * data?.magnets?.forEach(magnet => {
489
+ * console.log(magnet.filename, magnet.files)
440
490
  * })
441
491
  * ```
442
492
  *
@@ -444,33 +494,32 @@ declare class MagnetResource extends BaseResource {
444
494
  * Files are now retrieved separately from magnet status (since v4.1)
445
495
  * Only available for magnets with status 'Ready'
446
496
  */
447
- files(ids: number | number[]): Promise<MagnetFilesItem[] | undefined>;
497
+ files(ids: number | number[]): Promise<MagnetFilesResponseData | undefined>;
448
498
  /**
449
499
  * Watch a magnet's status with automatic polling
450
500
  *
501
+ * This is a simple helper that polls the status of a specific magnet until it reaches
502
+ * a target status (default: 'Ready'). For advanced use cases with multiple magnets
503
+ * or bandwidth optimization, use `statusLive()` directly instead.
504
+ *
451
505
  * @param id - The magnet ID to watch
452
506
  * @param options - Watch options
453
507
  * @param options.interval - Polling interval in milliseconds (default: 3000)
454
508
  * @param options.maxAttempts - Maximum polling attempts, 0 for infinite (default: 0)
455
509
  * @param options.onUpdate - Callback called on each status update
456
510
  * @param options.stopOnStatus - Stop when magnet reaches this status (default: 'Ready')
457
- * @param options.useLiveMode - Use live mode for reduced bandwidth (default: false)
458
511
  *
459
512
  * @example
460
513
  * ```ts
461
- * // Standard mode
462
514
  * await client.magnet.watch(123, {
463
515
  * onUpdate: (status) => console.log('Status:', status.magnets[0]?.status),
464
516
  * stopOnStatus: 'Ready'
465
517
  * })
466
- *
467
- * // Live mode for reduced bandwidth
468
- * await client.magnet.watch(123, {
469
- * useLiveMode: true,
470
- * interval: 2000,
471
- * onUpdate: (status) => console.log('Update:', status)
472
- * })
473
518
  * ```
519
+ *
520
+ * @remarks
521
+ * For monitoring multiple magnets efficiently, use `statusLive()` directly.
522
+ * See the `statusLive()` documentation for details on delta synchronization.
474
523
  */
475
524
  watch(id: number, options?: WatchOptions): Promise<MagnetStatusResponseData | undefined>;
476
525
  }
@@ -584,11 +633,11 @@ declare class UserResource extends BaseResource {
584
633
  *
585
634
  * @example
586
635
  * ```ts
587
- * const user = await client.user.getInfo()
588
- * console.log(user.username, user.isPremium)
636
+ * const data = await client.user.getInfo()
637
+ * console.log(data.user.username, data.user.isPremium)
589
638
  * ```
590
639
  */
591
- getInfo(): Promise<UserInfo | undefined>;
640
+ getInfo(): Promise<UserResponseData | undefined>;
592
641
  /**
593
642
  * Get available hosts for the current user based on their subscription
594
643
  *