drivekit 1.1.1 → 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/README.ar.md +31 -13
- package/README.md +10 -4
- package/dist/cli.cjs +364 -80
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +360 -76
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +358 -76
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -3
- package/dist/index.d.ts +51 -3
- package/dist/index.js +355 -75
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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,6 +153,12 @@ 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
|
}
|
|
@@ -687,6 +694,14 @@ declare class DriveKit {
|
|
|
687
694
|
* Registers a middleware plugin into DriveKit lifecycle
|
|
688
695
|
*/
|
|
689
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;
|
|
690
705
|
/**
|
|
691
706
|
* Returns a fluent, chained reference to a specific file
|
|
692
707
|
*/
|
|
@@ -730,7 +745,7 @@ declare class DriveKit {
|
|
|
730
745
|
*/
|
|
731
746
|
exists(idOrPath: string): Promise<boolean>;
|
|
732
747
|
/**
|
|
733
|
-
* 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
|
|
734
749
|
*/
|
|
735
750
|
ls(folderIdOrPath?: string): Promise<DriveApiFile[]>;
|
|
736
751
|
/**
|
|
@@ -746,10 +761,11 @@ declare class DriveKit {
|
|
|
746
761
|
* - Automatic conversion for Google Docs, Sheets, and Slides
|
|
747
762
|
* - Progress events
|
|
748
763
|
* - Saves directly to file or returns Readable Stream
|
|
764
|
+
* - Leverages local metadata cache to bypass redundant Google API roundtrips
|
|
749
765
|
*/
|
|
750
766
|
download(fileIdOrPath: string, options?: DownloadOptions): Promise<any>;
|
|
751
767
|
/**
|
|
752
|
-
* Gets file metadata
|
|
768
|
+
* Gets file metadata and updates the local metadata cache
|
|
753
769
|
*/
|
|
754
770
|
getFile(fileIdOrPath: string): Promise<DriveApiFile>;
|
|
755
771
|
/**
|
|
@@ -881,6 +897,10 @@ declare class DriveKit {
|
|
|
881
897
|
createWriteStream(remotePath: string, options?: Omit<UploadOptions, 'source'>): Promise<NodeJS.WritableStream & {
|
|
882
898
|
done: Promise<DriveApiFile>;
|
|
883
899
|
}>;
|
|
900
|
+
/**
|
|
901
|
+
* Synchronous getter for the active metadata cache instance
|
|
902
|
+
*/
|
|
903
|
+
get cache(): IMetadataCache | null;
|
|
884
904
|
/**
|
|
885
905
|
* Returns the active persistent metadata cache instance (SQLite/Memory)
|
|
886
906
|
*/
|
|
@@ -1034,6 +1054,7 @@ declare class PathResolver {
|
|
|
1034
1054
|
private drive;
|
|
1035
1055
|
private rootFolderId;
|
|
1036
1056
|
private cache;
|
|
1057
|
+
private inFlightResolves;
|
|
1037
1058
|
private cacheTTL;
|
|
1038
1059
|
private enableCache;
|
|
1039
1060
|
private metadataCache?;
|
|
@@ -1061,6 +1082,7 @@ declare class PathResolver {
|
|
|
1061
1082
|
/**
|
|
1062
1083
|
* Resolves a path to a Google Drive item (file or folder).
|
|
1063
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.
|
|
1064
1086
|
*/
|
|
1065
1087
|
resolve(virtualPath: string, options?: {
|
|
1066
1088
|
createIfMissing?: boolean;
|
|
@@ -1070,6 +1092,7 @@ declare class PathResolver {
|
|
|
1070
1092
|
isFolder: boolean;
|
|
1071
1093
|
mimeType: string;
|
|
1072
1094
|
}>;
|
|
1095
|
+
private doResolve;
|
|
1073
1096
|
/**
|
|
1074
1097
|
* Ensures that a directory structure exists (like mkdir -p).
|
|
1075
1098
|
*/
|
|
@@ -1103,6 +1126,14 @@ declare class ResumableUploader {
|
|
|
1103
1126
|
* Upload from generic Readable Stream
|
|
1104
1127
|
*/
|
|
1105
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;
|
|
1106
1137
|
/**
|
|
1107
1138
|
* Fast direct upload using googleapis multipart
|
|
1108
1139
|
*/
|
|
@@ -1266,6 +1297,23 @@ declare function isRetryableError(error: any): boolean;
|
|
|
1266
1297
|
*/
|
|
1267
1298
|
declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
1268
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
|
+
|
|
1269
1317
|
/**
|
|
1270
1318
|
* Creates and initializes a DriveKit instance
|
|
1271
1319
|
*
|
|
@@ -1286,4 +1334,4 @@ declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Pro
|
|
|
1286
1334
|
*/
|
|
1287
1335
|
declare function createDrive(options?: DriveKitOptions): Promise<DriveKit>;
|
|
1288
1336
|
|
|
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 };
|
|
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,6 +153,12 @@ 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
|
}
|
|
@@ -687,6 +694,14 @@ declare class DriveKit {
|
|
|
687
694
|
* Registers a middleware plugin into DriveKit lifecycle
|
|
688
695
|
*/
|
|
689
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;
|
|
690
705
|
/**
|
|
691
706
|
* Returns a fluent, chained reference to a specific file
|
|
692
707
|
*/
|
|
@@ -730,7 +745,7 @@ declare class DriveKit {
|
|
|
730
745
|
*/
|
|
731
746
|
exists(idOrPath: string): Promise<boolean>;
|
|
732
747
|
/**
|
|
733
|
-
* 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
|
|
734
749
|
*/
|
|
735
750
|
ls(folderIdOrPath?: string): Promise<DriveApiFile[]>;
|
|
736
751
|
/**
|
|
@@ -746,10 +761,11 @@ declare class DriveKit {
|
|
|
746
761
|
* - Automatic conversion for Google Docs, Sheets, and Slides
|
|
747
762
|
* - Progress events
|
|
748
763
|
* - Saves directly to file or returns Readable Stream
|
|
764
|
+
* - Leverages local metadata cache to bypass redundant Google API roundtrips
|
|
749
765
|
*/
|
|
750
766
|
download(fileIdOrPath: string, options?: DownloadOptions): Promise<any>;
|
|
751
767
|
/**
|
|
752
|
-
* Gets file metadata
|
|
768
|
+
* Gets file metadata and updates the local metadata cache
|
|
753
769
|
*/
|
|
754
770
|
getFile(fileIdOrPath: string): Promise<DriveApiFile>;
|
|
755
771
|
/**
|
|
@@ -881,6 +897,10 @@ declare class DriveKit {
|
|
|
881
897
|
createWriteStream(remotePath: string, options?: Omit<UploadOptions, 'source'>): Promise<NodeJS.WritableStream & {
|
|
882
898
|
done: Promise<DriveApiFile>;
|
|
883
899
|
}>;
|
|
900
|
+
/**
|
|
901
|
+
* Synchronous getter for the active metadata cache instance
|
|
902
|
+
*/
|
|
903
|
+
get cache(): IMetadataCache | null;
|
|
884
904
|
/**
|
|
885
905
|
* Returns the active persistent metadata cache instance (SQLite/Memory)
|
|
886
906
|
*/
|
|
@@ -1034,6 +1054,7 @@ declare class PathResolver {
|
|
|
1034
1054
|
private drive;
|
|
1035
1055
|
private rootFolderId;
|
|
1036
1056
|
private cache;
|
|
1057
|
+
private inFlightResolves;
|
|
1037
1058
|
private cacheTTL;
|
|
1038
1059
|
private enableCache;
|
|
1039
1060
|
private metadataCache?;
|
|
@@ -1061,6 +1082,7 @@ declare class PathResolver {
|
|
|
1061
1082
|
/**
|
|
1062
1083
|
* Resolves a path to a Google Drive item (file or folder).
|
|
1063
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.
|
|
1064
1086
|
*/
|
|
1065
1087
|
resolve(virtualPath: string, options?: {
|
|
1066
1088
|
createIfMissing?: boolean;
|
|
@@ -1070,6 +1092,7 @@ declare class PathResolver {
|
|
|
1070
1092
|
isFolder: boolean;
|
|
1071
1093
|
mimeType: string;
|
|
1072
1094
|
}>;
|
|
1095
|
+
private doResolve;
|
|
1073
1096
|
/**
|
|
1074
1097
|
* Ensures that a directory structure exists (like mkdir -p).
|
|
1075
1098
|
*/
|
|
@@ -1103,6 +1126,14 @@ declare class ResumableUploader {
|
|
|
1103
1126
|
* Upload from generic Readable Stream
|
|
1104
1127
|
*/
|
|
1105
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;
|
|
1106
1137
|
/**
|
|
1107
1138
|
* Fast direct upload using googleapis multipart
|
|
1108
1139
|
*/
|
|
@@ -1266,6 +1297,23 @@ declare function isRetryableError(error: any): boolean;
|
|
|
1266
1297
|
*/
|
|
1267
1298
|
declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
1268
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
|
+
|
|
1269
1317
|
/**
|
|
1270
1318
|
* Creates and initializes a DriveKit instance
|
|
1271
1319
|
*
|
|
@@ -1286,4 +1334,4 @@ declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Pro
|
|
|
1286
1334
|
*/
|
|
1287
1335
|
declare function createDrive(options?: DriveKitOptions): Promise<DriveKit>;
|
|
1288
1336
|
|
|
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 };
|
|
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 };
|