gdrivekit 3.2.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/LICENSE +21 -0
- package/README.md +275 -0
- package/dist/auth.d.ts +3 -0
- package/dist/components/01-FileOperation/copyFile.d.ts +6 -0
- package/dist/components/01-FileOperation/deleteFile.d.ts +7 -0
- package/dist/components/01-FileOperation/downloadFile.d.ts +8 -0
- package/dist/components/01-FileOperation/getFileIdByName.d.ts +15 -0
- package/dist/components/01-FileOperation/getFileInfo.d.ts +20 -0
- package/dist/components/01-FileOperation/helpers.d.ts +18 -0
- package/dist/components/01-FileOperation/moveFile.d.ts +6 -0
- package/dist/components/01-FileOperation/readFileData.d.ts +5 -0
- package/dist/components/01-FileOperation/renameFile.d.ts +6 -0
- package/dist/components/01-FileOperation/updateFile.d.ts +8 -0
- package/dist/components/01-FileOperation/uploadFile.d.ts +12 -0
- package/dist/components/02-JsonOperation/addJsonKeyValue.d.ts +13 -0
- package/dist/components/02-JsonOperation/createJsonFile.d.ts +14 -0
- package/dist/components/02-JsonOperation/deleteJsonFieldAndKeys.d.ts +13 -0
- package/dist/components/02-JsonOperation/pushJsonObjectToArray.d.ts +5 -0
- package/dist/components/02-JsonOperation/readJsonFileData.d.ts +5 -0
- package/dist/components/02-JsonOperation/selectJsonContent.d.ts +6 -0
- package/dist/components/02-JsonOperation/updateJsonFieldAndValues.d.ts +13 -0
- package/dist/components/03-FolderOperation/createFolder.d.ts +6 -0
- package/dist/components/03-FolderOperation/deleteFolder.d.ts +7 -0
- package/dist/components/03-FolderOperation/renameFolder.d.ts +6 -0
- package/dist/components/04-SearchOperation/searchByContent.d.ts +5 -0
- package/dist/components/04-SearchOperation/searchByExactName.d.ts +5 -0
- package/dist/components/04-SearchOperation/searchByName.d.ts +5 -0
- package/dist/components/04-SearchOperation/searchByType.d.ts +5 -0
- package/dist/components/04-SearchOperation/searchFiles.d.ts +6 -0
- package/dist/components/04-SearchOperation/searchModifiedAfter.d.ts +5 -0
- package/dist/components/04-SearchOperation/searchSharedFiles.d.ts +4 -0
- package/dist/components/04-SearchOperation/searchStarredFiles.d.ts +4 -0
- package/dist/components/05-ListOperation/getFolderIdByName.d.ts +15 -0
- package/dist/components/05-ListOperation/listAllFolders.d.ts +4 -0
- package/dist/components/05-ListOperation/listArchives.d.ts +4 -0
- package/dist/components/05-ListOperation/listAudios.d.ts +4 -0
- package/dist/components/05-ListOperation/listDocs.d.ts +4 -0
- package/dist/components/05-ListOperation/listFiles.d.ts +5 -0
- package/dist/components/05-ListOperation/listFilesInFolder.d.ts +5 -0
- package/dist/components/05-ListOperation/listFoldersByName.d.ts +5 -0
- package/dist/components/05-ListOperation/listFoldersInFolder.d.ts +5 -0
- package/dist/components/05-ListOperation/listImages.d.ts +4 -0
- package/dist/components/05-ListOperation/listJSONs.d.ts +4 -0
- package/dist/components/05-ListOperation/listPDFs.d.ts +4 -0
- package/dist/components/05-ListOperation/listPresentations.d.ts +4 -0
- package/dist/components/05-ListOperation/listRecentFiles.d.ts +5 -0
- package/dist/components/05-ListOperation/listSheets.d.ts +4 -0
- package/dist/components/05-ListOperation/listVideos.d.ts +4 -0
- package/dist/components/06-BatchOperation/deleteMultipleFiles.d.ts +10 -0
- package/dist/components/06-BatchOperation/downloadMultipleFiles.d.ts +14 -0
- package/dist/components/06-BatchOperation/uploadMultipleFiles.d.ts +9 -0
- package/dist/components/07-UtilityOperation/createStream.d.ts +4 -0
- package/dist/components/07-UtilityOperation/encrypt.d.ts +8 -0
- package/dist/components/07-UtilityOperation/fileUtils.d.ts +20 -0
- package/dist/components/07-UtilityOperation/shareFile.d.ts +4 -0
- package/dist/components/07-UtilityOperation/zip.d.ts +18 -0
- package/dist/components/08-ConversionOperation/convertDocs.d.ts +5 -0
- package/dist/components/08-ConversionOperation/convertDrawing.d.ts +3 -0
- package/dist/components/08-ConversionOperation/convertPdf.d.ts +2 -0
- package/dist/components/08-ConversionOperation/convertSheets.d.ts +5 -0
- package/dist/components/08-ConversionOperation/convertSlides.d.ts +4 -0
- package/dist/components/09-WatcherOperation/watchFolderDeepEvent.d.ts +8 -0
- package/dist/components/09-WatcherOperation/watchFolderEvent.d.ts +8 -0
- package/dist/components/10-ScriptOperation/createGoogleScript.d.ts +29 -0
- package/dist/components/10-ScriptOperation/deleteGoogleScript.d.ts +4 -0
- package/dist/components/10-ScriptOperation/deployGoogleScript.d.ts +7 -0
- package/dist/components/10-ScriptOperation/runGoogleScriptFunction.d.ts +22 -0
- package/dist/components/10-ScriptOperation/updateGoogleScript.d.ts +4 -0
- package/dist/components/index.d.ts +65 -0
- package/dist/const/index.d.ts +34 -0
- package/dist/drivers/Client.d.ts +27 -0
- package/dist/drivers/GoogleDriveService.d.ts +238 -0
- package/dist/drivers/functions/archive/convertFilesAndFoldersToZip.d.ts +16 -0
- package/dist/drivers/functions/conversion/ConversionFunction.d.ts +3 -0
- package/dist/drivers/functions/encryption/decryptText.d.ts +2 -0
- package/dist/drivers/functions/encryption/encryptText.d.ts +2 -0
- package/dist/drivers/functions/files/createStream.d.ts +2 -0
- package/dist/drivers/functions/files/createStreamfilesandFolder.d.ts +2 -0
- package/dist/drivers/functions/files/deleteFile.d.ts +8 -0
- package/dist/drivers/functions/files/downloadFile.d.ts +8 -0
- package/dist/drivers/functions/files/getAllFilesInParent.d.ts +6 -0
- package/dist/drivers/functions/files/getFile.d.ts +6 -0
- package/dist/drivers/functions/files/listFiles.d.ts +6 -0
- package/dist/drivers/functions/files/moveFile.d.ts +3 -0
- package/dist/drivers/functions/files/readFileData.d.ts +4 -0
- package/dist/drivers/functions/files/updateFileContent.d.ts +2 -0
- package/dist/drivers/functions/files/uploadFile.d.ts +6 -0
- package/dist/drivers/functions/folders/createFolder.d.ts +6 -0
- package/dist/drivers/functions/json/addJsonContent.d.ts +3 -0
- package/dist/drivers/functions/json/createJsonFile.d.ts +11 -0
- package/dist/drivers/functions/json/pushJsonObjectToArray.d.ts +2 -0
- package/dist/drivers/functions/json/selectJsonContent.d.ts +2 -0
- package/dist/drivers/functions/json/updateJsonContent.d.ts +3 -0
- package/dist/drivers/functions/metadata/getCompleteFileMetadata.d.ts +3 -0
- package/dist/drivers/functions/metadata/getFileMetadata.d.ts +3 -0
- package/dist/drivers/functions/metadata/getFileTypeBreakdown.d.ts +2 -0
- package/dist/drivers/functions/metadata/getImageMetadata.d.ts +3 -0
- package/dist/drivers/functions/metadata/getVideoMetadata.d.ts +3 -0
- package/dist/drivers/functions/metadata/updateFileMetadata.d.ts +3 -0
- package/dist/drivers/functions/permissions/shareFile.d.ts +3 -0
- package/dist/drivers/functions/scripts/DeployScript.d.ts +13 -0
- package/dist/drivers/functions/scripts/createScriptProject.d.ts +13 -0
- package/dist/drivers/functions/scripts/deleteScriptProject.d.ts +10 -0
- package/dist/drivers/functions/scripts/manageTrigger.d.ts +26 -0
- package/dist/drivers/functions/scripts/runScriptProject.d.ts +6 -0
- package/dist/drivers/functions/scripts/updateScriptProject.d.ts +10 -0
- package/dist/drivers/functions/search/findDuplicate.d.ts +2 -0
- package/dist/drivers/functions/search/searchFiles.d.ts +3 -0
- package/dist/drivers/functions/storage/getStorageQuota.d.ts +3 -0
- package/dist/drivers/functions/utils.d.ts +6 -0
- package/dist/drivers/functions/watcher/watchFolder.d.ts +6 -0
- package/dist/drivers/functions/watcher/watchFolderDeep.d.ts +6 -0
- package/dist/drivers/oauth2-client.d.ts +204 -0
- package/dist/drivers/services.d.ts +37 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +36210 -0
- package/dist/operations.d.ts +330 -0
- package/package.json +62 -0
- package/types/archiver-bypass.d.ts +9 -0
- package/types/archiver-extend.d.ts +0 -0
- package/types/index.d.ts +756 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { OAuth2Client } from "../../oauth2-client";
|
|
2
|
+
export declare function convertFilesAndFoldersToZip(oauth2: OAuth2Client, options: {
|
|
3
|
+
folderId?: string;
|
|
4
|
+
fileIds?: string[];
|
|
5
|
+
zipName: string;
|
|
6
|
+
uploadToFolderId?: string;
|
|
7
|
+
password?: string;
|
|
8
|
+
}): Promise<{
|
|
9
|
+
success: boolean;
|
|
10
|
+
data?: {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
webViewLink: string;
|
|
14
|
+
};
|
|
15
|
+
error?: string;
|
|
16
|
+
}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OAuth2Client } from "../../oauth2-client";
|
|
2
|
+
import { ApiResponse } from "../../../types/index";
|
|
3
|
+
/**
|
|
4
|
+
* Delete file from Google Drive
|
|
5
|
+
*/
|
|
6
|
+
export declare function deleteFile(client: OAuth2Client, fileId: string): Promise<ApiResponse<{
|
|
7
|
+
message: string;
|
|
8
|
+
}>>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OAuth2Client } from "../../oauth2-client";
|
|
2
|
+
import { ApiResponse } from "../../../types/index";
|
|
3
|
+
/**
|
|
4
|
+
* Download file to local storage
|
|
5
|
+
*/
|
|
6
|
+
export declare function downloadFile(client: OAuth2Client, fileId: string, destPath: string): Promise<ApiResponse<{
|
|
7
|
+
path: string;
|
|
8
|
+
}>>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { OAuth2Client } from "../../oauth2-client";
|
|
2
|
+
import { ApiResponse, ListFilesParams, ListFilesResponse } from "../../../types/index";
|
|
3
|
+
/**
|
|
4
|
+
* List files in Google Drive
|
|
5
|
+
*/
|
|
6
|
+
export declare function listFiles(client: OAuth2Client, params?: ListFilesParams): Promise<ApiResponse<ListFilesResponse>>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { OAuth2Client } from "../../oauth2-client";
|
|
2
|
+
import { ApiResponse, FileMetadata, UploadFileMetadata } from "../../../types/index";
|
|
3
|
+
/**
|
|
4
|
+
* Upload file to Google Drive (multipart upload)
|
|
5
|
+
*/
|
|
6
|
+
export declare function uploadFile(client: OAuth2Client, filePath: string, metadata?: UploadFileMetadata): Promise<ApiResponse<FileMetadata>>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { OAuth2Client } from "../../oauth2-client";
|
|
2
|
+
import { ApiResponse, FileMetadata } from "../../../types/index";
|
|
3
|
+
/**
|
|
4
|
+
* Create folder in Google Drive
|
|
5
|
+
*/
|
|
6
|
+
export declare function createFolder(client: OAuth2Client, folderName: string, parentFolderId?: string): Promise<ApiResponse<FileMetadata>>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OAuth2Client } from "../../oauth2-client";
|
|
2
|
+
import { FileMetadata } from "../../../types";
|
|
3
|
+
export declare function createJsonFile(oauth2: OAuth2Client, jsonContent: string, name: string): Promise<{
|
|
4
|
+
success: boolean;
|
|
5
|
+
data: FileMetadata;
|
|
6
|
+
error?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
success: boolean;
|
|
9
|
+
error: string;
|
|
10
|
+
data?: undefined;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OAuth2Client } from "../../oauth2-client";
|
|
2
|
+
export declare function DeployScript(oauth2: OAuth2Client, scriptId: string): Promise<{
|
|
3
|
+
success: boolean;
|
|
4
|
+
data: {
|
|
5
|
+
deploymentId: any;
|
|
6
|
+
webAppUrl: any;
|
|
7
|
+
};
|
|
8
|
+
error?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
success: boolean;
|
|
11
|
+
error: any;
|
|
12
|
+
data?: undefined;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OAuth2Client } from "../../oauth2-client";
|
|
2
|
+
export type ScriptProjectType = "HTML" | "API" | "FUNCTION";
|
|
3
|
+
export declare function createScriptProject(oauth2: OAuth2Client, title: string, code: string, projectType?: ScriptProjectType): Promise<{
|
|
4
|
+
success: boolean;
|
|
5
|
+
data: {
|
|
6
|
+
scriptId: any;
|
|
7
|
+
};
|
|
8
|
+
error?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
success: boolean;
|
|
11
|
+
error: any;
|
|
12
|
+
data?: undefined;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OAuth2Client } from "../../oauth2-client";
|
|
2
|
+
export declare function deleteScriptProject(oauth2: OAuth2Client, scriptId: string): Promise<{
|
|
3
|
+
success: boolean;
|
|
4
|
+
data: string;
|
|
5
|
+
error?: undefined;
|
|
6
|
+
} | {
|
|
7
|
+
success: boolean;
|
|
8
|
+
error: any;
|
|
9
|
+
data?: undefined;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { OAuth2Client } from "../../oauth2-client";
|
|
2
|
+
export type TriggerSchedule = "none" | "minutely" | "hourly" | "daily" | "weekly";
|
|
3
|
+
/**
|
|
4
|
+
* Create or update a time-based trigger for a script
|
|
5
|
+
* Note: Triggers are created by calling a setup function in the script itself
|
|
6
|
+
*/
|
|
7
|
+
export declare function manageTrigger(oauth2: OAuth2Client, scriptId: string, schedule: TriggerSchedule): Promise<{
|
|
8
|
+
success: boolean;
|
|
9
|
+
needsAuth: boolean;
|
|
10
|
+
error: string;
|
|
11
|
+
data?: undefined;
|
|
12
|
+
} | {
|
|
13
|
+
success: boolean;
|
|
14
|
+
data: any;
|
|
15
|
+
needsAuth?: undefined;
|
|
16
|
+
error?: undefined;
|
|
17
|
+
} | {
|
|
18
|
+
success: boolean;
|
|
19
|
+
error: any;
|
|
20
|
+
needsAuth?: undefined;
|
|
21
|
+
data?: undefined;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Generate the trigger setup code to be included in the script
|
|
25
|
+
*/
|
|
26
|
+
export declare function generateTriggerSetupCode(): string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { OAuth2Client } from "../../oauth2-client";
|
|
2
|
+
import { ScriptProjectType } from "./createScriptProject";
|
|
3
|
+
/**
|
|
4
|
+
* Call a Google Apps Script Web App URL with parameters
|
|
5
|
+
*/
|
|
6
|
+
export declare function runScriptProject(oauth2: OAuth2Client, url: string, functionName?: string, parameters?: Record<string, any>, projectType?: ScriptProjectType): Promise<any>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OAuth2Client } from "../../oauth2-client";
|
|
2
|
+
export declare function updateScriptProject(oauth2: OAuth2Client, scriptId: string, files: any[]): Promise<{
|
|
3
|
+
success: boolean;
|
|
4
|
+
data: any;
|
|
5
|
+
error?: undefined;
|
|
6
|
+
} | {
|
|
7
|
+
success: boolean;
|
|
8
|
+
error: any;
|
|
9
|
+
data?: undefined;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { OAuth2Client } from "../oauth2-client";
|
|
2
|
+
import { type HttpResponse } from "../Client";
|
|
3
|
+
/**
|
|
4
|
+
* Helper method to make authenticated requests using native fetch
|
|
5
|
+
*/
|
|
6
|
+
export declare function fetchWithAuth(oauthClient: OAuth2Client, url: string, options?: RequestInit): Promise<HttpResponse>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { OAuth2Client } from "../../oauth2-client";
|
|
2
|
+
import { FileMetadata } from "../../../types";
|
|
3
|
+
export declare function watchFolder(oauth2: OAuth2Client, folderId: string, intervalMs: number | undefined, callback: (event: {
|
|
4
|
+
type: "added" | "modified" | "deleted";
|
|
5
|
+
file: FileMetadata;
|
|
6
|
+
}) => void): Promise<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { OAuth2Client } from "../../oauth2-client";
|
|
2
|
+
import { FileMetadata } from "../../../types";
|
|
3
|
+
export declare function watchFolderDeep(oauth2: OAuth2Client, folderId: string, intervalMs: number | undefined, callback: (event: {
|
|
4
|
+
type: "added" | "modified" | "deleted";
|
|
5
|
+
file: FileMetadata;
|
|
6
|
+
}) => void): Promise<void>;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import type { TokenData, GoogleCredentials } from "../types/index";
|
|
2
|
+
export interface OAuth2ClientOptions {
|
|
3
|
+
/** Path to tokens file (default: ./tokens.json) */
|
|
4
|
+
tokensPath?: string;
|
|
5
|
+
/** Whether to auto-save tokens to file (default: true) */
|
|
6
|
+
autoSaveToFile?: boolean;
|
|
7
|
+
/** Callback when tokens are refreshed - use this for custom persistence */
|
|
8
|
+
onTokensRefresh?: (tokens: TokenData) => void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Lightweight OAuth2 client using Bun's native fetch
|
|
12
|
+
* Handles token storage, refresh, and authorization headers
|
|
13
|
+
*
|
|
14
|
+
* Token refresh happens automatically when:
|
|
15
|
+
* - A token is within 5 minutes of expiry
|
|
16
|
+
* - An API call is made via getAccessToken() or getAuthHeader()
|
|
17
|
+
*/
|
|
18
|
+
export declare class OAuth2Client {
|
|
19
|
+
get(url: string, arg1: {
|
|
20
|
+
headers: {
|
|
21
|
+
length: number;
|
|
22
|
+
toString(): string;
|
|
23
|
+
toLocaleString(): string;
|
|
24
|
+
toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string;
|
|
25
|
+
pop(): [string, string] | undefined;
|
|
26
|
+
push(...items: [string, string][]): number;
|
|
27
|
+
concat(...items: ConcatArray<[string, string]>[]): [string, string][];
|
|
28
|
+
concat(...items: ([string, string] | ConcatArray<[string, string]>)[]): [string, string][];
|
|
29
|
+
join(separator?: string): string;
|
|
30
|
+
reverse(): [string, string][];
|
|
31
|
+
shift(): [string, string] | undefined;
|
|
32
|
+
slice(start?: number, end?: number): [string, string][];
|
|
33
|
+
sort(compareFn?: ((a: [string, string], b: [string, string]) => number) | undefined): [string, string][];
|
|
34
|
+
splice(start: number, deleteCount?: number): [string, string][];
|
|
35
|
+
splice(start: number, deleteCount: number, ...items: [string, string][]): [string, string][];
|
|
36
|
+
unshift(...items: [string, string][]): number;
|
|
37
|
+
indexOf(searchElement: [string, string], fromIndex?: number): number;
|
|
38
|
+
lastIndexOf(searchElement: [string, string], fromIndex?: number): number;
|
|
39
|
+
every<S extends [string, string]>(predicate: (value: [string, string], index: number, array: [string, string][]) => value is S, thisArg?: any): this is S[];
|
|
40
|
+
every(predicate: (value: [string, string], index: number, array: [string, string][]) => unknown, thisArg?: any): boolean;
|
|
41
|
+
some(predicate: (value: [string, string], index: number, array: [string, string][]) => unknown, thisArg?: any): boolean;
|
|
42
|
+
forEach(callbackfn: (value: [string, string], index: number, array: [string, string][]) => void, thisArg?: any): void;
|
|
43
|
+
map<U>(callbackfn: (value: [string, string], index: number, array: [string, string][]) => U, thisArg?: any): U[];
|
|
44
|
+
filter<S extends [string, string]>(predicate: (value: [string, string], index: number, array: [string, string][]) => value is S, thisArg?: any): S[];
|
|
45
|
+
filter(predicate: (value: [string, string], index: number, array: [string, string][]) => unknown, thisArg?: any): [string, string][];
|
|
46
|
+
reduce(callbackfn: (previousValue: [string, string], currentValue: [string, string], currentIndex: number, array: [string, string][]) => [string, string]): [string, string];
|
|
47
|
+
reduce(callbackfn: (previousValue: [string, string], currentValue: [string, string], currentIndex: number, array: [string, string][]) => [string, string], initialValue: [string, string]): [string, string];
|
|
48
|
+
reduce<U>(callbackfn: (previousValue: U, currentValue: [string, string], currentIndex: number, array: [string, string][]) => U, initialValue: U): U;
|
|
49
|
+
reduceRight(callbackfn: (previousValue: [string, string], currentValue: [string, string], currentIndex: number, array: [string, string][]) => [string, string]): [string, string];
|
|
50
|
+
reduceRight(callbackfn: (previousValue: [string, string], currentValue: [string, string], currentIndex: number, array: [string, string][]) => [string, string], initialValue: [string, string]): [string, string];
|
|
51
|
+
reduceRight<U>(callbackfn: (previousValue: U, currentValue: [string, string], currentIndex: number, array: [string, string][]) => U, initialValue: U): U;
|
|
52
|
+
find<S extends [string, string]>(predicate: (value: [string, string], index: number, obj: [string, string][]) => value is S, thisArg?: any): S | undefined;
|
|
53
|
+
find(predicate: (value: [string, string], index: number, obj: [string, string][]) => unknown, thisArg?: any): [string, string] | undefined;
|
|
54
|
+
findIndex(predicate: (value: [string, string], index: number, obj: [string, string][]) => unknown, thisArg?: any): number;
|
|
55
|
+
fill(value: [string, string], start?: number, end?: number): [string, string][];
|
|
56
|
+
copyWithin(target: number, start: number, end?: number): [string, string][];
|
|
57
|
+
entries(): ArrayIterator<[number, [string, string]]>;
|
|
58
|
+
keys(): ArrayIterator<number>;
|
|
59
|
+
values(): ArrayIterator<[string, string]>;
|
|
60
|
+
includes(searchElement: [string, string], fromIndex?: number): boolean;
|
|
61
|
+
flatMap<U, This = undefined>(callback: (this: This, value: [string, string], index: number, array: [string, string][]) => U | readonly U[], thisArg?: This | undefined): U[];
|
|
62
|
+
flat<A, D extends number = 1>(this: A, depth?: D | undefined): FlatArray<A, D>[];
|
|
63
|
+
at(index: number): [string, string] | undefined;
|
|
64
|
+
findLast<S extends [string, string]>(predicate: (value: [string, string], index: number, array: [string, string][]) => value is S, thisArg?: any): S | undefined;
|
|
65
|
+
findLast(predicate: (value: [string, string], index: number, array: [string, string][]) => unknown, thisArg?: any): [string, string] | undefined;
|
|
66
|
+
findLastIndex(predicate: (value: [string, string], index: number, array: [string, string][]) => unknown, thisArg?: any): number;
|
|
67
|
+
toReversed(): [string, string][];
|
|
68
|
+
toSorted(compareFn?: ((a: [string, string], b: [string, string]) => number) | undefined): [string, string][];
|
|
69
|
+
toSpliced(start: number, deleteCount: number, ...items: [string, string][]): [string, string][];
|
|
70
|
+
toSpliced(start: number, deleteCount?: number): [string, string][];
|
|
71
|
+
with(index: number, value: [string, string]): [string, string][];
|
|
72
|
+
[Symbol.iterator](): ArrayIterator<[string, string]>;
|
|
73
|
+
[Symbol.unscopables]: {
|
|
74
|
+
[x: number]: boolean | undefined;
|
|
75
|
+
length?: boolean | undefined;
|
|
76
|
+
toString?: boolean | undefined;
|
|
77
|
+
toLocaleString?: boolean | undefined;
|
|
78
|
+
pop?: boolean | undefined;
|
|
79
|
+
push?: boolean | undefined;
|
|
80
|
+
concat?: boolean | undefined;
|
|
81
|
+
join?: boolean | undefined;
|
|
82
|
+
reverse?: boolean | undefined;
|
|
83
|
+
shift?: boolean | undefined;
|
|
84
|
+
slice?: boolean | undefined;
|
|
85
|
+
sort?: boolean | undefined;
|
|
86
|
+
splice?: boolean | undefined;
|
|
87
|
+
unshift?: boolean | undefined;
|
|
88
|
+
indexOf?: boolean | undefined;
|
|
89
|
+
lastIndexOf?: boolean | undefined;
|
|
90
|
+
every?: boolean | undefined;
|
|
91
|
+
some?: boolean | undefined;
|
|
92
|
+
forEach?: boolean | undefined;
|
|
93
|
+
map?: boolean | undefined;
|
|
94
|
+
filter?: boolean | undefined;
|
|
95
|
+
reduce?: boolean | undefined;
|
|
96
|
+
reduceRight?: boolean | undefined;
|
|
97
|
+
find?: boolean | undefined;
|
|
98
|
+
findIndex?: boolean | undefined;
|
|
99
|
+
fill?: boolean | undefined;
|
|
100
|
+
copyWithin?: boolean | undefined;
|
|
101
|
+
entries?: boolean | undefined;
|
|
102
|
+
keys?: boolean | undefined;
|
|
103
|
+
values?: boolean | undefined;
|
|
104
|
+
includes?: boolean | undefined;
|
|
105
|
+
flatMap?: boolean | undefined;
|
|
106
|
+
flat?: boolean | undefined;
|
|
107
|
+
at?: boolean | undefined;
|
|
108
|
+
findLast?: boolean | undefined;
|
|
109
|
+
findLastIndex?: boolean | undefined;
|
|
110
|
+
toReversed?: boolean | undefined;
|
|
111
|
+
toSorted?: boolean | undefined;
|
|
112
|
+
toSpliced?: boolean | undefined;
|
|
113
|
+
with?: boolean | undefined;
|
|
114
|
+
[Symbol.iterator]?: boolean | undefined;
|
|
115
|
+
readonly [Symbol.unscopables]?: boolean | undefined;
|
|
116
|
+
};
|
|
117
|
+
Authorization: string;
|
|
118
|
+
} | {
|
|
119
|
+
Authorization: string;
|
|
120
|
+
} | {
|
|
121
|
+
append(name: string, value: string): void;
|
|
122
|
+
delete(name: string): void;
|
|
123
|
+
get(name: string): string | null;
|
|
124
|
+
getSetCookie(): string[];
|
|
125
|
+
has(name: string): boolean;
|
|
126
|
+
set(name: string, value: string): void;
|
|
127
|
+
forEach(callbackfn: (value: string, key: string, parent: Headers) => void, thisArg?: any): void;
|
|
128
|
+
entries(): HeadersIterator<[string, string]>;
|
|
129
|
+
keys(): HeadersIterator<string>;
|
|
130
|
+
values(): HeadersIterator<string>;
|
|
131
|
+
[Symbol.iterator](): HeadersIterator<[string, string]>;
|
|
132
|
+
Authorization: string;
|
|
133
|
+
};
|
|
134
|
+
body?: BodyInit | null;
|
|
135
|
+
cache?: RequestCache;
|
|
136
|
+
credentials?: RequestCredentials;
|
|
137
|
+
integrity?: string;
|
|
138
|
+
keepalive?: boolean;
|
|
139
|
+
method?: string;
|
|
140
|
+
mode?: RequestMode;
|
|
141
|
+
priority?: RequestPriority;
|
|
142
|
+
redirect?: RequestRedirect;
|
|
143
|
+
referrer?: string;
|
|
144
|
+
referrerPolicy?: ReferrerPolicy;
|
|
145
|
+
signal?: AbortSignal | null;
|
|
146
|
+
window?: null;
|
|
147
|
+
}): void;
|
|
148
|
+
private accessToken;
|
|
149
|
+
private refreshToken;
|
|
150
|
+
private clientId;
|
|
151
|
+
private clientSecret;
|
|
152
|
+
private redirectUri;
|
|
153
|
+
private expiryDate;
|
|
154
|
+
private tokensPath;
|
|
155
|
+
private autoSaveToFile;
|
|
156
|
+
private onTokensRefresh?;
|
|
157
|
+
private isRefreshing;
|
|
158
|
+
private refreshPromise;
|
|
159
|
+
constructor(credentials: GoogleCredentials, options?: OAuth2ClientOptions | string);
|
|
160
|
+
/**
|
|
161
|
+
* Set tokens and optionally enable auto-save on refresh
|
|
162
|
+
*/
|
|
163
|
+
setCredentials(tokens: TokenData): void;
|
|
164
|
+
/**
|
|
165
|
+
* Set callback for when tokens are refreshed
|
|
166
|
+
*/
|
|
167
|
+
onTokensRefreshed(callback: (tokens: TokenData) => void): void;
|
|
168
|
+
/**
|
|
169
|
+
* Get a valid access token, refreshing if expired
|
|
170
|
+
* Automatically refreshes the token if it's within 5 minutes of expiry
|
|
171
|
+
*/
|
|
172
|
+
getAccessToken(): Promise<string>;
|
|
173
|
+
/**
|
|
174
|
+
* Check if the current token is expired or about to expire
|
|
175
|
+
*/
|
|
176
|
+
isTokenExpired(bufferMinutes?: number): boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Get current tokens (useful for persistence)
|
|
179
|
+
*/
|
|
180
|
+
getTokens(): TokenData;
|
|
181
|
+
/**
|
|
182
|
+
* Refresh the access token using the refresh token
|
|
183
|
+
*/
|
|
184
|
+
refreshAccessToken(): Promise<void>;
|
|
185
|
+
/**
|
|
186
|
+
* Get authorization header for API requests
|
|
187
|
+
*/
|
|
188
|
+
getAuthHeader(): Promise<{
|
|
189
|
+
Authorization: string;
|
|
190
|
+
}>;
|
|
191
|
+
/**
|
|
192
|
+
* Exchange authorization code for tokens
|
|
193
|
+
*/
|
|
194
|
+
getToken(code: string): Promise<TokenData>;
|
|
195
|
+
/**
|
|
196
|
+
* Generate OAuth2 authorization URL
|
|
197
|
+
*/
|
|
198
|
+
generateAuthUrl(options: {
|
|
199
|
+
access_type?: string;
|
|
200
|
+
prompt?: string;
|
|
201
|
+
scope: string[];
|
|
202
|
+
include_granted_scopes?: boolean;
|
|
203
|
+
}): string;
|
|
204
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { GoogleCredentials, TokenData } from "../types/index";
|
|
2
|
+
import { GoogleDriveService, DriveServiceOptions } from "./GoogleDriveService";
|
|
3
|
+
declare let driveService: GoogleDriveService;
|
|
4
|
+
export interface InitDriveServiceOptions extends DriveServiceOptions {
|
|
5
|
+
/** Google credentials (will read from ./credentials.json if not provided) */
|
|
6
|
+
credentials?: GoogleCredentials;
|
|
7
|
+
/** Token data (will read from ./tokens.json if not provided) */
|
|
8
|
+
tokens?: TokenData;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Initialize the Google Drive service with automatic token refresh
|
|
12
|
+
*
|
|
13
|
+
* @example Basic usage (reads from files)
|
|
14
|
+
* ```ts
|
|
15
|
+
* const service = initDriveService();
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @example With custom token refresh callback (for SSR/serverless)
|
|
19
|
+
* ```ts
|
|
20
|
+
* const service = initDriveService({
|
|
21
|
+
* credentials: myCredentials,
|
|
22
|
+
* tokens: myTokens,
|
|
23
|
+
* autoSaveToFile: false, // Disable file writes in serverless
|
|
24
|
+
* onTokensRefresh: async (tokens) => {
|
|
25
|
+
* // Save tokens to your database or session
|
|
26
|
+
* await saveTokensToDatabase(tokens);
|
|
27
|
+
* }
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function initDriveService(options?: InitDriveServiceOptions): GoogleDriveService;
|
|
32
|
+
export declare function initDriveService(creds?: GoogleCredentials, tokens?: TokenData): GoogleDriveService;
|
|
33
|
+
/**
|
|
34
|
+
* Reset the drive service instance (useful for testing or re-initialization)
|
|
35
|
+
*/
|
|
36
|
+
export declare function resetDriveService(): void;
|
|
37
|
+
export { driveService };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as operations from "./operations";
|
|
2
|
+
import { generateCredentialsAndTokens } from "./auth";
|
|
3
|
+
import { initDriveService, resetDriveService, type InitDriveServiceOptions } from "./drivers/services";
|
|
4
|
+
import { DriveServiceOptions, GoogleDriveService } from "./drivers/GoogleDriveService";
|
|
5
|
+
import { OAuth2Client, OAuth2ClientOptions } from "./drivers/oauth2-client";
|
|
6
|
+
export { generateCredentialsAndTokens, operations, initDriveService, resetDriveService, GoogleDriveService, OAuth2Client, type InitDriveServiceOptions, type DriveServiceOptions, type OAuth2ClientOptions, };
|