drivekit 1.1.0 → 1.1.2

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
@@ -3,6 +3,7 @@ import { drive_v3 } from '@googleapis/drive';
3
3
  import { OAuth2Client } from 'google-auth-library';
4
4
  import { EventEmitter } from 'node:events';
5
5
  import http$1 from 'node:http';
6
+ import https from 'node:https';
6
7
 
7
8
  interface BrowserLoginOptions {
8
9
  clientId: string;
@@ -152,9 +153,29 @@ interface DownloadOptions {
152
153
  onProgress?: (progress: DownloadProgress) => void;
153
154
  /** Export MIME type for Google Workspace documents */
154
155
  exportMimeType?: string;
156
+ /** Optional pre-resolved file metadata to skip extra Google API roundtrip */
157
+ metadata?: {
158
+ name?: string;
159
+ mimeType?: string;
160
+ size?: number;
161
+ };
155
162
  /** Optional AbortSignal for instant operation cancellation */
156
163
  signal?: AbortSignal;
157
164
  }
165
+ /**
166
+ * Writable stream for direct uploads into Google Drive with completion promise
167
+ */
168
+ interface DriveWriteStream extends NodeJS.WritableStream {
169
+ /** Resolves with the uploaded file metadata upon completion, or rejects on upload failure */
170
+ done: Promise<DriveApiFile>;
171
+ }
172
+ /**
173
+ * Writable stream for direct uploads into Google Drive with completion promise
174
+ */
175
+ interface DriveWriteStream extends NodeJS.WritableStream {
176
+ /** Resolves with the uploaded file metadata upon completion, or rejects on upload failure */
177
+ done: Promise<DriveApiFile>;
178
+ }
158
179
  /**
159
180
  * Permission role types
160
181
  */
@@ -527,21 +548,42 @@ interface DriveKitPlugin {
527
548
  }
528
549
  declare class PluginManager {
529
550
  private plugins;
551
+ /**
552
+ * Register a plugin. If a plugin with the same name already exists,
553
+ * it replaces the old one to avoid duplicate side-effects.
554
+ */
530
555
  use(plugin: DriveKitPlugin): this;
556
+ /**
557
+ * Unregister a plugin by its name.
558
+ * Returns true if a plugin was found and removed, false otherwise.
559
+ */
560
+ unuse(pluginName: string): boolean;
561
+ /**
562
+ * Check if a plugin with given name is currently active
563
+ */
564
+ has(pluginName: string): boolean;
565
+ /**
566
+ * Returns all currently registered plugins
567
+ */
568
+ getPlugins(): readonly DriveKitPlugin[];
531
569
  runBeforeUpload(options: UploadOptions): Promise<UploadOptions>;
532
570
  runAfterUpload(file: DriveApiFile): Promise<DriveApiFile>;
533
571
  runBeforeDownload(fileId: string, options: DownloadOptions): Promise<DownloadOptions>;
534
572
  runAfterDownload(result: any): Promise<any>;
535
573
  }
536
- /**
537
- * Creates an official Webhook Plugin to notify external services (Slack, Discord, Telegram, Zapier)
538
- * when uploads or downloads finish.
539
- */
540
- declare function createWebhookPlugin(options: {
574
+ interface WebhookPluginOptions {
541
575
  url: string;
542
576
  headers?: Record<string, string>;
543
577
  events?: ('upload' | 'download')[];
544
- }): DriveKitPlugin;
578
+ timeout?: number;
579
+ retries?: number;
580
+ onError?: (err: Error, event: 'upload' | 'download') => void;
581
+ }
582
+ /**
583
+ * Creates an official Webhook Plugin to notify external services (Slack, Discord, Telegram, Zapier)
584
+ * when uploads or downloads finish. Includes configurable timeout, retry mechanism, and error callback.
585
+ */
586
+ declare function createWebhookPlugin(options: WebhookPluginOptions): DriveKitPlugin;
545
587
  /**
546
588
  * Creates an Auto-Namer Plugin to automatically prefix/suffix or timestamp files
547
589
  */
@@ -580,6 +622,7 @@ interface IMetadataCache {
580
622
  upsertFile(entry: CacheFileEntry): void;
581
623
  upsertFiles(entries: CacheFileEntry[]): void;
582
624
  deleteFile(id: string): void;
625
+ pruneMissing(activeIds: string[]): number;
583
626
  clear(): void;
584
627
  getMeta(key: string): string | null;
585
628
  setMeta(key: string, value: string): void;
@@ -605,6 +648,7 @@ declare class SqliteMetadataCache implements IMetadataCache {
605
648
  upsertFile(entry: CacheFileEntry): void;
606
649
  upsertFiles(entries: CacheFileEntry[]): void;
607
650
  deleteFile(id: string): void;
651
+ pruneMissing(activeIds: string[]): number;
608
652
  clear(): void;
609
653
  getMeta(key: string): string | null;
610
654
  setMeta(key: string, value: string): void;
@@ -627,6 +671,7 @@ declare class MemoryMetadataCache implements IMetadataCache {
627
671
  upsertFile(entry: CacheFileEntry): void;
628
672
  upsertFiles(entries: CacheFileEntry[]): void;
629
673
  deleteFile(id: string): void;
674
+ pruneMissing(activeIds: string[]): number;
630
675
  clear(): void;
631
676
  getMeta(key: string): string | null;
632
677
  setMeta(key: string, value: string): void;
@@ -649,6 +694,14 @@ declare class DriveKit {
649
694
  * Registers a middleware plugin into DriveKit lifecycle
650
695
  */
651
696
  use(plugin: DriveKitPlugin): this;
697
+ /**
698
+ * Unregisters a middleware plugin by name
699
+ */
700
+ unuse(pluginName: string): boolean;
701
+ /**
702
+ * Access the underlying plugin manager instance
703
+ */
704
+ get plugins(): PluginManager;
652
705
  /**
653
706
  * Returns a fluent, chained reference to a specific file
654
707
  */
@@ -692,7 +745,7 @@ declare class DriveKit {
692
745
  */
693
746
  exists(idOrPath: string): Promise<boolean>;
694
747
  /**
695
- * Lists contents of a folder (by folder ID or path)
748
+ * Lists contents of a folder (by folder ID or path) with opportunistic tree caching
696
749
  */
697
750
  ls(folderIdOrPath?: string): Promise<DriveApiFile[]>;
698
751
  /**
@@ -708,10 +761,11 @@ declare class DriveKit {
708
761
  * - Automatic conversion for Google Docs, Sheets, and Slides
709
762
  * - Progress events
710
763
  * - Saves directly to file or returns Readable Stream
764
+ * - Leverages local metadata cache to bypass redundant Google API roundtrips
711
765
  */
712
766
  download(fileIdOrPath: string, options?: DownloadOptions): Promise<any>;
713
767
  /**
714
- * Gets file metadata
768
+ * Gets file metadata and updates the local metadata cache
715
769
  */
716
770
  getFile(fileIdOrPath: string): Promise<DriveApiFile>;
717
771
  /**
@@ -840,7 +894,13 @@ declare class DriveKit {
840
894
  /**
841
895
  * Creates a writable stream directly into Google Drive
842
896
  */
843
- createWriteStream(remotePath: string, options?: Omit<UploadOptions, 'source'>): Promise<NodeJS.WritableStream>;
897
+ createWriteStream(remotePath: string, options?: Omit<UploadOptions, 'source'>): Promise<NodeJS.WritableStream & {
898
+ done: Promise<DriveApiFile>;
899
+ }>;
900
+ /**
901
+ * Synchronous getter for the active metadata cache instance
902
+ */
903
+ get cache(): IMetadataCache | null;
844
904
  /**
845
905
  * Returns the active persistent metadata cache instance (SQLite/Memory)
846
906
  */
@@ -895,6 +955,10 @@ declare class DriveKit {
895
955
  serveWebDAV(options?: {
896
956
  port?: number;
897
957
  host?: string;
958
+ auth?: {
959
+ username?: string;
960
+ password?: string;
961
+ };
898
962
  }): Promise<{
899
963
  server: http.Server;
900
964
  url: string;
@@ -990,6 +1054,7 @@ declare class PathResolver {
990
1054
  private drive;
991
1055
  private rootFolderId;
992
1056
  private cache;
1057
+ private inFlightResolves;
993
1058
  private cacheTTL;
994
1059
  private enableCache;
995
1060
  private metadataCache?;
@@ -1017,6 +1082,7 @@ declare class PathResolver {
1017
1082
  /**
1018
1083
  * Resolves a path to a Google Drive item (file or folder).
1019
1084
  * If createIfMissing is true, any missing intermediate directories will be automatically created (like mkdir -p).
1085
+ * Incorporates in-flight request coalescing to deduplicate concurrent resolutions of identical paths.
1020
1086
  */
1021
1087
  resolve(virtualPath: string, options?: {
1022
1088
  createIfMissing?: boolean;
@@ -1026,6 +1092,7 @@ declare class PathResolver {
1026
1092
  isFolder: boolean;
1027
1093
  mimeType: string;
1028
1094
  }>;
1095
+ private doResolve;
1029
1096
  /**
1030
1097
  * Ensures that a directory structure exists (like mkdir -p).
1031
1098
  */
@@ -1059,6 +1126,14 @@ declare class ResumableUploader {
1059
1126
  * Upload from generic Readable Stream
1060
1127
  */
1061
1128
  private uploadFromStream;
1129
+ /**
1130
+ * Calculates optimal chunk size based on file size for maximum throughput.
1131
+ */
1132
+ private computeAdaptiveChunkSize;
1133
+ /**
1134
+ * Attaches real-time progress monitoring to direct stream uploads.
1135
+ */
1136
+ private wrapStreamWithProgress;
1062
1137
  /**
1063
1138
  * Fast direct upload using googleapis multipart
1064
1139
  */
@@ -1128,10 +1203,18 @@ declare class ConcurrencyPool {
1128
1203
  interface WebDAVServerOptions {
1129
1204
  port?: number;
1130
1205
  host?: string;
1206
+ auth?: {
1207
+ username?: string;
1208
+ password?: string;
1209
+ };
1131
1210
  }
1132
1211
  /**
1133
- * Creates and starts a lightweight zero-dependency WebDAV server for DriveKit.
1134
- * Allows mounting Google Drive directly in macOS Finder, Windows Explorer, or Linux.
1212
+ * Escapes unsafe characters for valid XML output
1213
+ */
1214
+ declare function escapeXml(unsafe: string): string;
1215
+ /**
1216
+ * Creates and starts a production-grade, zero-dependency WebDAV server for DriveKit.
1217
+ * Supports HTTP Basic Authentication, Streaming PUT (Zero-Buffer), Range requests, MOVE, COPY, and MKCOL.
1135
1218
  */
1136
1219
  declare function startWebDAVServer(drive: DriveKit, options?: WebDAVServerOptions): Promise<{
1137
1220
  server: http$1.Server;
@@ -1214,6 +1297,23 @@ declare function isRetryableError(error: any): boolean;
1214
1297
  */
1215
1298
  declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
1216
1299
 
1300
+ interface HttpAgentOptions {
1301
+ keepAlive?: boolean;
1302
+ maxSockets?: number;
1303
+ maxFreeSockets?: number;
1304
+ keepAliveMsecs?: number;
1305
+ timeout?: number;
1306
+ }
1307
+ /**
1308
+ * Returns a high-performance HTTPS Agent with persistent connection pooling
1309
+ * and Keep-Alive enabled to eliminate TCP/TLS handshake latency on Google APIs.
1310
+ */
1311
+ declare function getOptimizedHttpsAgent(options?: HttpAgentOptions): https.Agent;
1312
+ /**
1313
+ * Returns a high-performance HTTP Agent with connection pooling.
1314
+ */
1315
+ declare function getOptimizedHttpAgent(options?: HttpAgentOptions): http$1.Agent;
1316
+
1217
1317
  /**
1218
1318
  * Creates and initializes a DriveKit instance
1219
1319
  *
@@ -1234,4 +1334,4 @@ declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Pro
1234
1334
  */
1235
1335
  declare function createDrive(options?: DriveKitOptions): Promise<DriveKit>;
1236
1336
 
1237
- export { type BrowserLoginOptions, type CacheFileEntry, type CacheStats, ConcurrencyPool, DEFAULT_CHUNK_SIZE, DEFAULT_EXPORT_MIMES, DEFAULT_SCOPES, type DownloadOptions, type DownloadProgress, Downloader, type DriveApiFile, type DriveApiFileList, type DriveApiPermission, DriveAuthError, DriveAuthenticator, DriveFileRef, DriveFolderRef, DriveKit, type DriveKitAuthConfig, DriveKitError, type DriveKitOptions, type DriveKitPlugin, DriveNotFoundError, DriveQueryBuilder, DriveRateLimitError, DriveUploadError, DriveWatcher, type DuplicateGroup, type FileChangeEvent, GOOGLE_WORKSPACE_MIME_TYPES, type IMetadataCache, type LoginResult, MIN_CHUNK_SIZE, MULTIPART_THRESHOLD, MemoryMetadataCache, PathResolver, type PermissionRole, type PermissionType, PluginManager, type PullResult, ResumableUploader, type RetryOptions, type ShareOptions, SmartSyncEngine, SqliteMetadataCache, StorageCleaner, type SyncResult, type UploadOptions, type UploadProgress, type WatcherOptions, type WebDAVServerOptions, calculateFileMd5, createAutoNamePlugin, createDrive, createWebhookPlugin, DriveKit as default, formatBytes, formatDuration, formatSpeed, getExtensionForMime, getFileIcon, isGoogleWorkspaceDoc, isRetryableError, loginWithBrowser, lookupMimeType, renderFileRow, runInteractiveExplorer, startWebDAVServer, terminalLink, withRetry };
1337
+ export { type BrowserLoginOptions, type CacheFileEntry, type CacheStats, ConcurrencyPool, DEFAULT_CHUNK_SIZE, DEFAULT_EXPORT_MIMES, DEFAULT_SCOPES, type DownloadOptions, type DownloadProgress, Downloader, type DriveApiFile, type DriveApiFileList, type DriveApiPermission, DriveAuthError, DriveAuthenticator, DriveFileRef, DriveFolderRef, DriveKit, type DriveKitAuthConfig, DriveKitError, type DriveKitOptions, type DriveKitPlugin, DriveNotFoundError, DriveQueryBuilder, DriveRateLimitError, DriveUploadError, DriveWatcher, type DriveWriteStream, type DuplicateGroup, type FileChangeEvent, GOOGLE_WORKSPACE_MIME_TYPES, type HttpAgentOptions, type IMetadataCache, type LoginResult, MIN_CHUNK_SIZE, MULTIPART_THRESHOLD, MemoryMetadataCache, PathResolver, type PermissionRole, type PermissionType, PluginManager, type PullResult, ResumableUploader, type RetryOptions, type ShareOptions, SmartSyncEngine, SqliteMetadataCache, StorageCleaner, type SyncResult, type UploadOptions, type UploadProgress, type WatcherOptions, type WebDAVServerOptions, type WebhookPluginOptions, calculateFileMd5, createAutoNamePlugin, createDrive, createWebhookPlugin, DriveKit as default, escapeXml, formatBytes, formatDuration, formatSpeed, getExtensionForMime, getFileIcon, getOptimizedHttpAgent, getOptimizedHttpsAgent, isGoogleWorkspaceDoc, isRetryableError, loginWithBrowser, lookupMimeType, renderFileRow, runInteractiveExplorer, startWebDAVServer, terminalLink, withRetry };
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import { drive_v3 } from '@googleapis/drive';
3
3
  import { OAuth2Client } from 'google-auth-library';
4
4
  import { EventEmitter } from 'node:events';
5
5
  import http$1 from 'node:http';
6
+ import https from 'node:https';
6
7
 
7
8
  interface BrowserLoginOptions {
8
9
  clientId: string;
@@ -152,9 +153,29 @@ interface DownloadOptions {
152
153
  onProgress?: (progress: DownloadProgress) => void;
153
154
  /** Export MIME type for Google Workspace documents */
154
155
  exportMimeType?: string;
156
+ /** Optional pre-resolved file metadata to skip extra Google API roundtrip */
157
+ metadata?: {
158
+ name?: string;
159
+ mimeType?: string;
160
+ size?: number;
161
+ };
155
162
  /** Optional AbortSignal for instant operation cancellation */
156
163
  signal?: AbortSignal;
157
164
  }
165
+ /**
166
+ * Writable stream for direct uploads into Google Drive with completion promise
167
+ */
168
+ interface DriveWriteStream extends NodeJS.WritableStream {
169
+ /** Resolves with the uploaded file metadata upon completion, or rejects on upload failure */
170
+ done: Promise<DriveApiFile>;
171
+ }
172
+ /**
173
+ * Writable stream for direct uploads into Google Drive with completion promise
174
+ */
175
+ interface DriveWriteStream extends NodeJS.WritableStream {
176
+ /** Resolves with the uploaded file metadata upon completion, or rejects on upload failure */
177
+ done: Promise<DriveApiFile>;
178
+ }
158
179
  /**
159
180
  * Permission role types
160
181
  */
@@ -527,21 +548,42 @@ interface DriveKitPlugin {
527
548
  }
528
549
  declare class PluginManager {
529
550
  private plugins;
551
+ /**
552
+ * Register a plugin. If a plugin with the same name already exists,
553
+ * it replaces the old one to avoid duplicate side-effects.
554
+ */
530
555
  use(plugin: DriveKitPlugin): this;
556
+ /**
557
+ * Unregister a plugin by its name.
558
+ * Returns true if a plugin was found and removed, false otherwise.
559
+ */
560
+ unuse(pluginName: string): boolean;
561
+ /**
562
+ * Check if a plugin with given name is currently active
563
+ */
564
+ has(pluginName: string): boolean;
565
+ /**
566
+ * Returns all currently registered plugins
567
+ */
568
+ getPlugins(): readonly DriveKitPlugin[];
531
569
  runBeforeUpload(options: UploadOptions): Promise<UploadOptions>;
532
570
  runAfterUpload(file: DriveApiFile): Promise<DriveApiFile>;
533
571
  runBeforeDownload(fileId: string, options: DownloadOptions): Promise<DownloadOptions>;
534
572
  runAfterDownload(result: any): Promise<any>;
535
573
  }
536
- /**
537
- * Creates an official Webhook Plugin to notify external services (Slack, Discord, Telegram, Zapier)
538
- * when uploads or downloads finish.
539
- */
540
- declare function createWebhookPlugin(options: {
574
+ interface WebhookPluginOptions {
541
575
  url: string;
542
576
  headers?: Record<string, string>;
543
577
  events?: ('upload' | 'download')[];
544
- }): DriveKitPlugin;
578
+ timeout?: number;
579
+ retries?: number;
580
+ onError?: (err: Error, event: 'upload' | 'download') => void;
581
+ }
582
+ /**
583
+ * Creates an official Webhook Plugin to notify external services (Slack, Discord, Telegram, Zapier)
584
+ * when uploads or downloads finish. Includes configurable timeout, retry mechanism, and error callback.
585
+ */
586
+ declare function createWebhookPlugin(options: WebhookPluginOptions): DriveKitPlugin;
545
587
  /**
546
588
  * Creates an Auto-Namer Plugin to automatically prefix/suffix or timestamp files
547
589
  */
@@ -580,6 +622,7 @@ interface IMetadataCache {
580
622
  upsertFile(entry: CacheFileEntry): void;
581
623
  upsertFiles(entries: CacheFileEntry[]): void;
582
624
  deleteFile(id: string): void;
625
+ pruneMissing(activeIds: string[]): number;
583
626
  clear(): void;
584
627
  getMeta(key: string): string | null;
585
628
  setMeta(key: string, value: string): void;
@@ -605,6 +648,7 @@ declare class SqliteMetadataCache implements IMetadataCache {
605
648
  upsertFile(entry: CacheFileEntry): void;
606
649
  upsertFiles(entries: CacheFileEntry[]): void;
607
650
  deleteFile(id: string): void;
651
+ pruneMissing(activeIds: string[]): number;
608
652
  clear(): void;
609
653
  getMeta(key: string): string | null;
610
654
  setMeta(key: string, value: string): void;
@@ -627,6 +671,7 @@ declare class MemoryMetadataCache implements IMetadataCache {
627
671
  upsertFile(entry: CacheFileEntry): void;
628
672
  upsertFiles(entries: CacheFileEntry[]): void;
629
673
  deleteFile(id: string): void;
674
+ pruneMissing(activeIds: string[]): number;
630
675
  clear(): void;
631
676
  getMeta(key: string): string | null;
632
677
  setMeta(key: string, value: string): void;
@@ -649,6 +694,14 @@ declare class DriveKit {
649
694
  * Registers a middleware plugin into DriveKit lifecycle
650
695
  */
651
696
  use(plugin: DriveKitPlugin): this;
697
+ /**
698
+ * Unregisters a middleware plugin by name
699
+ */
700
+ unuse(pluginName: string): boolean;
701
+ /**
702
+ * Access the underlying plugin manager instance
703
+ */
704
+ get plugins(): PluginManager;
652
705
  /**
653
706
  * Returns a fluent, chained reference to a specific file
654
707
  */
@@ -692,7 +745,7 @@ declare class DriveKit {
692
745
  */
693
746
  exists(idOrPath: string): Promise<boolean>;
694
747
  /**
695
- * Lists contents of a folder (by folder ID or path)
748
+ * Lists contents of a folder (by folder ID or path) with opportunistic tree caching
696
749
  */
697
750
  ls(folderIdOrPath?: string): Promise<DriveApiFile[]>;
698
751
  /**
@@ -708,10 +761,11 @@ declare class DriveKit {
708
761
  * - Automatic conversion for Google Docs, Sheets, and Slides
709
762
  * - Progress events
710
763
  * - Saves directly to file or returns Readable Stream
764
+ * - Leverages local metadata cache to bypass redundant Google API roundtrips
711
765
  */
712
766
  download(fileIdOrPath: string, options?: DownloadOptions): Promise<any>;
713
767
  /**
714
- * Gets file metadata
768
+ * Gets file metadata and updates the local metadata cache
715
769
  */
716
770
  getFile(fileIdOrPath: string): Promise<DriveApiFile>;
717
771
  /**
@@ -840,7 +894,13 @@ declare class DriveKit {
840
894
  /**
841
895
  * Creates a writable stream directly into Google Drive
842
896
  */
843
- createWriteStream(remotePath: string, options?: Omit<UploadOptions, 'source'>): Promise<NodeJS.WritableStream>;
897
+ createWriteStream(remotePath: string, options?: Omit<UploadOptions, 'source'>): Promise<NodeJS.WritableStream & {
898
+ done: Promise<DriveApiFile>;
899
+ }>;
900
+ /**
901
+ * Synchronous getter for the active metadata cache instance
902
+ */
903
+ get cache(): IMetadataCache | null;
844
904
  /**
845
905
  * Returns the active persistent metadata cache instance (SQLite/Memory)
846
906
  */
@@ -895,6 +955,10 @@ declare class DriveKit {
895
955
  serveWebDAV(options?: {
896
956
  port?: number;
897
957
  host?: string;
958
+ auth?: {
959
+ username?: string;
960
+ password?: string;
961
+ };
898
962
  }): Promise<{
899
963
  server: http.Server;
900
964
  url: string;
@@ -990,6 +1054,7 @@ declare class PathResolver {
990
1054
  private drive;
991
1055
  private rootFolderId;
992
1056
  private cache;
1057
+ private inFlightResolves;
993
1058
  private cacheTTL;
994
1059
  private enableCache;
995
1060
  private metadataCache?;
@@ -1017,6 +1082,7 @@ declare class PathResolver {
1017
1082
  /**
1018
1083
  * Resolves a path to a Google Drive item (file or folder).
1019
1084
  * If createIfMissing is true, any missing intermediate directories will be automatically created (like mkdir -p).
1085
+ * Incorporates in-flight request coalescing to deduplicate concurrent resolutions of identical paths.
1020
1086
  */
1021
1087
  resolve(virtualPath: string, options?: {
1022
1088
  createIfMissing?: boolean;
@@ -1026,6 +1092,7 @@ declare class PathResolver {
1026
1092
  isFolder: boolean;
1027
1093
  mimeType: string;
1028
1094
  }>;
1095
+ private doResolve;
1029
1096
  /**
1030
1097
  * Ensures that a directory structure exists (like mkdir -p).
1031
1098
  */
@@ -1059,6 +1126,14 @@ declare class ResumableUploader {
1059
1126
  * Upload from generic Readable Stream
1060
1127
  */
1061
1128
  private uploadFromStream;
1129
+ /**
1130
+ * Calculates optimal chunk size based on file size for maximum throughput.
1131
+ */
1132
+ private computeAdaptiveChunkSize;
1133
+ /**
1134
+ * Attaches real-time progress monitoring to direct stream uploads.
1135
+ */
1136
+ private wrapStreamWithProgress;
1062
1137
  /**
1063
1138
  * Fast direct upload using googleapis multipart
1064
1139
  */
@@ -1128,10 +1203,18 @@ declare class ConcurrencyPool {
1128
1203
  interface WebDAVServerOptions {
1129
1204
  port?: number;
1130
1205
  host?: string;
1206
+ auth?: {
1207
+ username?: string;
1208
+ password?: string;
1209
+ };
1131
1210
  }
1132
1211
  /**
1133
- * Creates and starts a lightweight zero-dependency WebDAV server for DriveKit.
1134
- * Allows mounting Google Drive directly in macOS Finder, Windows Explorer, or Linux.
1212
+ * Escapes unsafe characters for valid XML output
1213
+ */
1214
+ declare function escapeXml(unsafe: string): string;
1215
+ /**
1216
+ * Creates and starts a production-grade, zero-dependency WebDAV server for DriveKit.
1217
+ * Supports HTTP Basic Authentication, Streaming PUT (Zero-Buffer), Range requests, MOVE, COPY, and MKCOL.
1135
1218
  */
1136
1219
  declare function startWebDAVServer(drive: DriveKit, options?: WebDAVServerOptions): Promise<{
1137
1220
  server: http$1.Server;
@@ -1214,6 +1297,23 @@ declare function isRetryableError(error: any): boolean;
1214
1297
  */
1215
1298
  declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
1216
1299
 
1300
+ interface HttpAgentOptions {
1301
+ keepAlive?: boolean;
1302
+ maxSockets?: number;
1303
+ maxFreeSockets?: number;
1304
+ keepAliveMsecs?: number;
1305
+ timeout?: number;
1306
+ }
1307
+ /**
1308
+ * Returns a high-performance HTTPS Agent with persistent connection pooling
1309
+ * and Keep-Alive enabled to eliminate TCP/TLS handshake latency on Google APIs.
1310
+ */
1311
+ declare function getOptimizedHttpsAgent(options?: HttpAgentOptions): https.Agent;
1312
+ /**
1313
+ * Returns a high-performance HTTP Agent with connection pooling.
1314
+ */
1315
+ declare function getOptimizedHttpAgent(options?: HttpAgentOptions): http$1.Agent;
1316
+
1217
1317
  /**
1218
1318
  * Creates and initializes a DriveKit instance
1219
1319
  *
@@ -1234,4 +1334,4 @@ declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Pro
1234
1334
  */
1235
1335
  declare function createDrive(options?: DriveKitOptions): Promise<DriveKit>;
1236
1336
 
1237
- export { type BrowserLoginOptions, type CacheFileEntry, type CacheStats, ConcurrencyPool, DEFAULT_CHUNK_SIZE, DEFAULT_EXPORT_MIMES, DEFAULT_SCOPES, type DownloadOptions, type DownloadProgress, Downloader, type DriveApiFile, type DriveApiFileList, type DriveApiPermission, DriveAuthError, DriveAuthenticator, DriveFileRef, DriveFolderRef, DriveKit, type DriveKitAuthConfig, DriveKitError, type DriveKitOptions, type DriveKitPlugin, DriveNotFoundError, DriveQueryBuilder, DriveRateLimitError, DriveUploadError, DriveWatcher, type DuplicateGroup, type FileChangeEvent, GOOGLE_WORKSPACE_MIME_TYPES, type IMetadataCache, type LoginResult, MIN_CHUNK_SIZE, MULTIPART_THRESHOLD, MemoryMetadataCache, PathResolver, type PermissionRole, type PermissionType, PluginManager, type PullResult, ResumableUploader, type RetryOptions, type ShareOptions, SmartSyncEngine, SqliteMetadataCache, StorageCleaner, type SyncResult, type UploadOptions, type UploadProgress, type WatcherOptions, type WebDAVServerOptions, calculateFileMd5, createAutoNamePlugin, createDrive, createWebhookPlugin, DriveKit as default, formatBytes, formatDuration, formatSpeed, getExtensionForMime, getFileIcon, isGoogleWorkspaceDoc, isRetryableError, loginWithBrowser, lookupMimeType, renderFileRow, runInteractiveExplorer, startWebDAVServer, terminalLink, withRetry };
1337
+ export { type BrowserLoginOptions, type CacheFileEntry, type CacheStats, ConcurrencyPool, DEFAULT_CHUNK_SIZE, DEFAULT_EXPORT_MIMES, DEFAULT_SCOPES, type DownloadOptions, type DownloadProgress, Downloader, type DriveApiFile, type DriveApiFileList, type DriveApiPermission, DriveAuthError, DriveAuthenticator, DriveFileRef, DriveFolderRef, DriveKit, type DriveKitAuthConfig, DriveKitError, type DriveKitOptions, type DriveKitPlugin, DriveNotFoundError, DriveQueryBuilder, DriveRateLimitError, DriveUploadError, DriveWatcher, type DriveWriteStream, type DuplicateGroup, type FileChangeEvent, GOOGLE_WORKSPACE_MIME_TYPES, type HttpAgentOptions, type IMetadataCache, type LoginResult, MIN_CHUNK_SIZE, MULTIPART_THRESHOLD, MemoryMetadataCache, PathResolver, type PermissionRole, type PermissionType, PluginManager, type PullResult, ResumableUploader, type RetryOptions, type ShareOptions, SmartSyncEngine, SqliteMetadataCache, StorageCleaner, type SyncResult, type UploadOptions, type UploadProgress, type WatcherOptions, type WebDAVServerOptions, type WebhookPluginOptions, calculateFileMd5, createAutoNamePlugin, createDrive, createWebhookPlugin, DriveKit as default, escapeXml, formatBytes, formatDuration, formatSpeed, getExtensionForMime, getFileIcon, getOptimizedHttpAgent, getOptimizedHttpsAgent, isGoogleWorkspaceDoc, isRetryableError, loginWithBrowser, lookupMimeType, renderFileRow, runInteractiveExplorer, startWebDAVServer, terminalLink, withRetry };