drivekit 1.1.0 → 1.1.1

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
@@ -155,6 +155,20 @@ interface DownloadOptions {
155
155
  /** Optional AbortSignal for instant operation cancellation */
156
156
  signal?: AbortSignal;
157
157
  }
158
+ /**
159
+ * Writable stream for direct uploads into Google Drive with completion promise
160
+ */
161
+ interface DriveWriteStream extends NodeJS.WritableStream {
162
+ /** Resolves with the uploaded file metadata upon completion, or rejects on upload failure */
163
+ done: Promise<DriveApiFile>;
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
+ }
158
172
  /**
159
173
  * Permission role types
160
174
  */
@@ -527,21 +541,42 @@ interface DriveKitPlugin {
527
541
  }
528
542
  declare class PluginManager {
529
543
  private plugins;
544
+ /**
545
+ * Register a plugin. If a plugin with the same name already exists,
546
+ * it replaces the old one to avoid duplicate side-effects.
547
+ */
530
548
  use(plugin: DriveKitPlugin): this;
549
+ /**
550
+ * Unregister a plugin by its name.
551
+ * Returns true if a plugin was found and removed, false otherwise.
552
+ */
553
+ unuse(pluginName: string): boolean;
554
+ /**
555
+ * Check if a plugin with given name is currently active
556
+ */
557
+ has(pluginName: string): boolean;
558
+ /**
559
+ * Returns all currently registered plugins
560
+ */
561
+ getPlugins(): readonly DriveKitPlugin[];
531
562
  runBeforeUpload(options: UploadOptions): Promise<UploadOptions>;
532
563
  runAfterUpload(file: DriveApiFile): Promise<DriveApiFile>;
533
564
  runBeforeDownload(fileId: string, options: DownloadOptions): Promise<DownloadOptions>;
534
565
  runAfterDownload(result: any): Promise<any>;
535
566
  }
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: {
567
+ interface WebhookPluginOptions {
541
568
  url: string;
542
569
  headers?: Record<string, string>;
543
570
  events?: ('upload' | 'download')[];
544
- }): DriveKitPlugin;
571
+ timeout?: number;
572
+ retries?: number;
573
+ onError?: (err: Error, event: 'upload' | 'download') => void;
574
+ }
575
+ /**
576
+ * Creates an official Webhook Plugin to notify external services (Slack, Discord, Telegram, Zapier)
577
+ * when uploads or downloads finish. Includes configurable timeout, retry mechanism, and error callback.
578
+ */
579
+ declare function createWebhookPlugin(options: WebhookPluginOptions): DriveKitPlugin;
545
580
  /**
546
581
  * Creates an Auto-Namer Plugin to automatically prefix/suffix or timestamp files
547
582
  */
@@ -580,6 +615,7 @@ interface IMetadataCache {
580
615
  upsertFile(entry: CacheFileEntry): void;
581
616
  upsertFiles(entries: CacheFileEntry[]): void;
582
617
  deleteFile(id: string): void;
618
+ pruneMissing(activeIds: string[]): number;
583
619
  clear(): void;
584
620
  getMeta(key: string): string | null;
585
621
  setMeta(key: string, value: string): void;
@@ -605,6 +641,7 @@ declare class SqliteMetadataCache implements IMetadataCache {
605
641
  upsertFile(entry: CacheFileEntry): void;
606
642
  upsertFiles(entries: CacheFileEntry[]): void;
607
643
  deleteFile(id: string): void;
644
+ pruneMissing(activeIds: string[]): number;
608
645
  clear(): void;
609
646
  getMeta(key: string): string | null;
610
647
  setMeta(key: string, value: string): void;
@@ -627,6 +664,7 @@ declare class MemoryMetadataCache implements IMetadataCache {
627
664
  upsertFile(entry: CacheFileEntry): void;
628
665
  upsertFiles(entries: CacheFileEntry[]): void;
629
666
  deleteFile(id: string): void;
667
+ pruneMissing(activeIds: string[]): number;
630
668
  clear(): void;
631
669
  getMeta(key: string): string | null;
632
670
  setMeta(key: string, value: string): void;
@@ -840,7 +878,9 @@ declare class DriveKit {
840
878
  /**
841
879
  * Creates a writable stream directly into Google Drive
842
880
  */
843
- createWriteStream(remotePath: string, options?: Omit<UploadOptions, 'source'>): Promise<NodeJS.WritableStream>;
881
+ createWriteStream(remotePath: string, options?: Omit<UploadOptions, 'source'>): Promise<NodeJS.WritableStream & {
882
+ done: Promise<DriveApiFile>;
883
+ }>;
844
884
  /**
845
885
  * Returns the active persistent metadata cache instance (SQLite/Memory)
846
886
  */
@@ -895,6 +935,10 @@ declare class DriveKit {
895
935
  serveWebDAV(options?: {
896
936
  port?: number;
897
937
  host?: string;
938
+ auth?: {
939
+ username?: string;
940
+ password?: string;
941
+ };
898
942
  }): Promise<{
899
943
  server: http.Server;
900
944
  url: string;
@@ -1128,10 +1172,18 @@ declare class ConcurrencyPool {
1128
1172
  interface WebDAVServerOptions {
1129
1173
  port?: number;
1130
1174
  host?: string;
1175
+ auth?: {
1176
+ username?: string;
1177
+ password?: string;
1178
+ };
1131
1179
  }
1132
1180
  /**
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.
1181
+ * Escapes unsafe characters for valid XML output
1182
+ */
1183
+ declare function escapeXml(unsafe: string): string;
1184
+ /**
1185
+ * Creates and starts a production-grade, zero-dependency WebDAV server for DriveKit.
1186
+ * Supports HTTP Basic Authentication, Streaming PUT (Zero-Buffer), Range requests, MOVE, COPY, and MKCOL.
1135
1187
  */
1136
1188
  declare function startWebDAVServer(drive: DriveKit, options?: WebDAVServerOptions): Promise<{
1137
1189
  server: http$1.Server;
@@ -1234,4 +1286,4 @@ declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Pro
1234
1286
  */
1235
1287
  declare function createDrive(options?: DriveKitOptions): Promise<DriveKit>;
1236
1288
 
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 };
1289
+ 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 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, isGoogleWorkspaceDoc, isRetryableError, loginWithBrowser, lookupMimeType, renderFileRow, runInteractiveExplorer, startWebDAVServer, terminalLink, withRetry };
package/dist/index.d.ts CHANGED
@@ -155,6 +155,20 @@ interface DownloadOptions {
155
155
  /** Optional AbortSignal for instant operation cancellation */
156
156
  signal?: AbortSignal;
157
157
  }
158
+ /**
159
+ * Writable stream for direct uploads into Google Drive with completion promise
160
+ */
161
+ interface DriveWriteStream extends NodeJS.WritableStream {
162
+ /** Resolves with the uploaded file metadata upon completion, or rejects on upload failure */
163
+ done: Promise<DriveApiFile>;
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
+ }
158
172
  /**
159
173
  * Permission role types
160
174
  */
@@ -527,21 +541,42 @@ interface DriveKitPlugin {
527
541
  }
528
542
  declare class PluginManager {
529
543
  private plugins;
544
+ /**
545
+ * Register a plugin. If a plugin with the same name already exists,
546
+ * it replaces the old one to avoid duplicate side-effects.
547
+ */
530
548
  use(plugin: DriveKitPlugin): this;
549
+ /**
550
+ * Unregister a plugin by its name.
551
+ * Returns true if a plugin was found and removed, false otherwise.
552
+ */
553
+ unuse(pluginName: string): boolean;
554
+ /**
555
+ * Check if a plugin with given name is currently active
556
+ */
557
+ has(pluginName: string): boolean;
558
+ /**
559
+ * Returns all currently registered plugins
560
+ */
561
+ getPlugins(): readonly DriveKitPlugin[];
531
562
  runBeforeUpload(options: UploadOptions): Promise<UploadOptions>;
532
563
  runAfterUpload(file: DriveApiFile): Promise<DriveApiFile>;
533
564
  runBeforeDownload(fileId: string, options: DownloadOptions): Promise<DownloadOptions>;
534
565
  runAfterDownload(result: any): Promise<any>;
535
566
  }
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: {
567
+ interface WebhookPluginOptions {
541
568
  url: string;
542
569
  headers?: Record<string, string>;
543
570
  events?: ('upload' | 'download')[];
544
- }): DriveKitPlugin;
571
+ timeout?: number;
572
+ retries?: number;
573
+ onError?: (err: Error, event: 'upload' | 'download') => void;
574
+ }
575
+ /**
576
+ * Creates an official Webhook Plugin to notify external services (Slack, Discord, Telegram, Zapier)
577
+ * when uploads or downloads finish. Includes configurable timeout, retry mechanism, and error callback.
578
+ */
579
+ declare function createWebhookPlugin(options: WebhookPluginOptions): DriveKitPlugin;
545
580
  /**
546
581
  * Creates an Auto-Namer Plugin to automatically prefix/suffix or timestamp files
547
582
  */
@@ -580,6 +615,7 @@ interface IMetadataCache {
580
615
  upsertFile(entry: CacheFileEntry): void;
581
616
  upsertFiles(entries: CacheFileEntry[]): void;
582
617
  deleteFile(id: string): void;
618
+ pruneMissing(activeIds: string[]): number;
583
619
  clear(): void;
584
620
  getMeta(key: string): string | null;
585
621
  setMeta(key: string, value: string): void;
@@ -605,6 +641,7 @@ declare class SqliteMetadataCache implements IMetadataCache {
605
641
  upsertFile(entry: CacheFileEntry): void;
606
642
  upsertFiles(entries: CacheFileEntry[]): void;
607
643
  deleteFile(id: string): void;
644
+ pruneMissing(activeIds: string[]): number;
608
645
  clear(): void;
609
646
  getMeta(key: string): string | null;
610
647
  setMeta(key: string, value: string): void;
@@ -627,6 +664,7 @@ declare class MemoryMetadataCache implements IMetadataCache {
627
664
  upsertFile(entry: CacheFileEntry): void;
628
665
  upsertFiles(entries: CacheFileEntry[]): void;
629
666
  deleteFile(id: string): void;
667
+ pruneMissing(activeIds: string[]): number;
630
668
  clear(): void;
631
669
  getMeta(key: string): string | null;
632
670
  setMeta(key: string, value: string): void;
@@ -840,7 +878,9 @@ declare class DriveKit {
840
878
  /**
841
879
  * Creates a writable stream directly into Google Drive
842
880
  */
843
- createWriteStream(remotePath: string, options?: Omit<UploadOptions, 'source'>): Promise<NodeJS.WritableStream>;
881
+ createWriteStream(remotePath: string, options?: Omit<UploadOptions, 'source'>): Promise<NodeJS.WritableStream & {
882
+ done: Promise<DriveApiFile>;
883
+ }>;
844
884
  /**
845
885
  * Returns the active persistent metadata cache instance (SQLite/Memory)
846
886
  */
@@ -895,6 +935,10 @@ declare class DriveKit {
895
935
  serveWebDAV(options?: {
896
936
  port?: number;
897
937
  host?: string;
938
+ auth?: {
939
+ username?: string;
940
+ password?: string;
941
+ };
898
942
  }): Promise<{
899
943
  server: http.Server;
900
944
  url: string;
@@ -1128,10 +1172,18 @@ declare class ConcurrencyPool {
1128
1172
  interface WebDAVServerOptions {
1129
1173
  port?: number;
1130
1174
  host?: string;
1175
+ auth?: {
1176
+ username?: string;
1177
+ password?: string;
1178
+ };
1131
1179
  }
1132
1180
  /**
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.
1181
+ * Escapes unsafe characters for valid XML output
1182
+ */
1183
+ declare function escapeXml(unsafe: string): string;
1184
+ /**
1185
+ * Creates and starts a production-grade, zero-dependency WebDAV server for DriveKit.
1186
+ * Supports HTTP Basic Authentication, Streaming PUT (Zero-Buffer), Range requests, MOVE, COPY, and MKCOL.
1135
1187
  */
1136
1188
  declare function startWebDAVServer(drive: DriveKit, options?: WebDAVServerOptions): Promise<{
1137
1189
  server: http$1.Server;
@@ -1234,4 +1286,4 @@ declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Pro
1234
1286
  */
1235
1287
  declare function createDrive(options?: DriveKitOptions): Promise<DriveKit>;
1236
1288
 
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 };
1289
+ 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 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, isGoogleWorkspaceDoc, isRetryableError, loginWithBrowser, lookupMimeType, renderFileRow, runInteractiveExplorer, startWebDAVServer, terminalLink, withRetry };