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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Vikash Khati
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
## 🧩 gdrivekit
|
|
2
|
+
|
|
3
|
+
> **Google Drive file automation in just a few lines of code.**
|
|
4
|
+
> Perform uploads, downloads, folder management, and advanced search operations effortlessly using TypeScript or Node.js.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
### 🚀 Features
|
|
9
|
+
|
|
10
|
+
- 📂 Upload, download, and manage Google Drive files
|
|
11
|
+
- 🗂️ Create and organize folders
|
|
12
|
+
- 🔍 Powerful search and filter utilities
|
|
13
|
+
- ⚙️ Batch file operations
|
|
14
|
+
- ⚡ **Lazy Loading Architecture:** Functions are loaded only when needed.
|
|
15
|
+
- 💡 Works with Node.js and Bun
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
### 📦 Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install gdrivekit
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
or
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
bun add gdrivekit
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
### 💻 Example Usage
|
|
34
|
+
|
|
35
|
+
### ⚙️ One-Time Setup (Token Generation)
|
|
36
|
+
|
|
37
|
+
Before you can use Google Drive operations, you must generate **access and refresh tokens**.
|
|
38
|
+
This only needs to be done **once**.
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { generateCredentialsAndTokens } from "gdrivekit";
|
|
42
|
+
|
|
43
|
+
await generateCredentialsAndTokens({
|
|
44
|
+
clientid: process.env.GOOGLE_CLIENT_ID!,
|
|
45
|
+
projectid: process.env.GOOGLE_PROJECT_ID!,
|
|
46
|
+
clientsecret: process.env.GOOGLE_CLIENT_SECRET!,
|
|
47
|
+
redirecturis: ["http://localhost:3000/oauth2callback"],
|
|
48
|
+
javascript_origin: ["http://localhost:3000"],
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
# 🔄 Initializing the Drive Service
|
|
55
|
+
|
|
56
|
+
Initialize the service and access operations through categorized groups:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { initDriveService, operations } from "gdrivekit";
|
|
60
|
+
|
|
61
|
+
async function main() {
|
|
62
|
+
initDriveService();
|
|
63
|
+
|
|
64
|
+
// Example: Search files by name using searchOperations
|
|
65
|
+
const files = await operations.searchOperations.searchByName("test");
|
|
66
|
+
console.log(files.data?.files);
|
|
67
|
+
|
|
68
|
+
// Example: Get Folder ID by Name using folderOperations
|
|
69
|
+
const folder = await operations.folderOperations.getFolderIdByName(
|
|
70
|
+
"My Documents"
|
|
71
|
+
);
|
|
72
|
+
console.log(folder);
|
|
73
|
+
|
|
74
|
+
// Example: List all folders using listOperations
|
|
75
|
+
const allFolders = await operations.listOperations.listAllFolders();
|
|
76
|
+
console.log(allFolders);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
main();
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## 🧠 Available Operations
|
|
85
|
+
|
|
86
|
+
All operations are grouped by category under the main `operations` object.
|
|
87
|
+
|
|
88
|
+
### 📁 **`operations.fileOperations`**
|
|
89
|
+
|
|
90
|
+
| Method | Description |
|
|
91
|
+
| ----------------------- | ----------------------------------------------- |
|
|
92
|
+
| `readFileData()` | Read file content |
|
|
93
|
+
| `uploadFile()` | Upload a new file to Google Drive |
|
|
94
|
+
| `downloadFile()` | Download a file from Drive |
|
|
95
|
+
| `deleteFile()` | Permanently delete a file |
|
|
96
|
+
| `renameFile()` | Rename an existing file |
|
|
97
|
+
| `updateFile()` | Update file metadata or content |
|
|
98
|
+
| `getFileInfo()` | Get details of a specific file |
|
|
99
|
+
| `getFileIdByName()` | Fetch file ID by its name (Exact Match) |
|
|
100
|
+
| `getCompleteFileInfo()` | Get complete file metadata including all fields |
|
|
101
|
+
| `moveFile()` | Move file to another folder using file ID |
|
|
102
|
+
| `copyFile()` | Make a copy of a file in Drive |
|
|
103
|
+
| `getImageMetadata()` | Get image metadata (EXIF data, dimensions) |
|
|
104
|
+
| `getVideoMetadata()` | Get video metadata (duration, dimensions) |
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
### 🗂️ **`operations.folderOperations`**
|
|
109
|
+
|
|
110
|
+
| Method | Description |
|
|
111
|
+
| --------------------- | ----------------------------------------- |
|
|
112
|
+
| `createFolder()` | Create a new folder |
|
|
113
|
+
| `deleteFolder()` | Delete an existing folder |
|
|
114
|
+
| `renameFolder()` | Rename an existing folder |
|
|
115
|
+
| `getFolderIdByName()` | Fetch folder ID by its name (Exact Match) |
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
### 🔍 **`operations.searchOperations`**
|
|
120
|
+
|
|
121
|
+
| Method | Description |
|
|
122
|
+
| ----------------------- | -------------------------------------- |
|
|
123
|
+
| `searchByName()` | Search files containing a name |
|
|
124
|
+
| `searchByExactName()` | Search files matching exact name |
|
|
125
|
+
| `searchByType()` | Search by file type (e.g., PDF, image) |
|
|
126
|
+
| `searchModifiedAfter()` | Find files modified after a given date |
|
|
127
|
+
| `searchStarredFiles()` | List all starred files |
|
|
128
|
+
| `searchSharedFiles()` | Find files shared with you |
|
|
129
|
+
| `searchByContent()` | Search within file content |
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
### 📋 **`operations.listOperations`**
|
|
134
|
+
|
|
135
|
+
| Method | Description |
|
|
136
|
+
| ----------------------- | ----------------------------------------- |
|
|
137
|
+
| `listFiles()` | List all files in Drive |
|
|
138
|
+
| `listRecentFiles()` | List recently modified or added files |
|
|
139
|
+
| `listFoldersByName()` | List all folders with a specific name |
|
|
140
|
+
| `listAllFolders()` | List all folders in Drive |
|
|
141
|
+
| `listFilesInFolder()` | List all files within a specific folder |
|
|
142
|
+
| `listFoldersInFolder()` | List all folders within a specific folder |
|
|
143
|
+
| `listPDFs()` | List all PDF files |
|
|
144
|
+
| `listImages()` | List all image files |
|
|
145
|
+
| `listVideos()` | List all video files |
|
|
146
|
+
| `listAudios()` | List all audio files |
|
|
147
|
+
| `listArchives()` | List all archive files |
|
|
148
|
+
| `listJSONs()` | List all json files |
|
|
149
|
+
| `listSheets()` | List all sheet files |
|
|
150
|
+
| `listPresentations()` | List all presentation files |
|
|
151
|
+
| `listDocs()` | List all docs files |
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
### 🧩 **`operations.batchOperations`**
|
|
156
|
+
|
|
157
|
+
| Method | Description |
|
|
158
|
+
| ------------------------- | ------------------------------------ |
|
|
159
|
+
| `uploadMultipleFiles()` | Upload multiple files at once |
|
|
160
|
+
| `deleteMultipleFiles()` | Delete multiple files simultaneously |
|
|
161
|
+
| `downloadMultipleFiles()` | Download multiple files in parallel |
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
### 🧰 **`operations.utilityOperations`**
|
|
166
|
+
|
|
167
|
+
| Method | Description |
|
|
168
|
+
| -------------------------------- | --------------------------------------------------------- |
|
|
169
|
+
| `encryptText()` | Encrypt plain text using AES-256-GCM |
|
|
170
|
+
| `decryptText()` | Decrypt encrypted text using AES-256-GCM |
|
|
171
|
+
| `filesAndFoldersToZip()` | Create a zip archive of folder and multiple files |
|
|
172
|
+
| `findDuplicateFilesAndFolders()` | Find duplicate file and folder names in Drive |
|
|
173
|
+
| `getFileTypeBreakdown()` | Get folder type breakdown in a parent folder |
|
|
174
|
+
| `getAllFilesInParent()` | Get all files in a parent folder not including subfolders |
|
|
175
|
+
| `shareFile()` | Share a file with a user |
|
|
176
|
+
| `fileExists()` | Check if a file exists |
|
|
177
|
+
| `getStorageQuota()` | Get storage quota information |
|
|
178
|
+
| `createStream()` | Create stream for any Google Drive file |
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
### ❴❵ **`operations.jsonOperations`**
|
|
183
|
+
|
|
184
|
+
| Method | Description |
|
|
185
|
+
| ---------------------------- | --------------------------------------- |
|
|
186
|
+
| `createJsonFile()` | Create a new JSON file |
|
|
187
|
+
| `readJsonFileData()` | Read JSON file content |
|
|
188
|
+
| `addJsonKeyValue()` | Add a new key-value pair to a JSON file |
|
|
189
|
+
| `pushJsonObjectToArray()` | Push a new object to a JSON array field |
|
|
190
|
+
| `updateJsonFieldAndValues()` | Update an existing field in a JSON file |
|
|
191
|
+
| `selectJsonContent()` | Select content from a JSON file |
|
|
192
|
+
| `deleteJsonFieldAndKeys()` | Delete a field from a JSON file |
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
### ⚞ **`operations.conversionOperations`**
|
|
197
|
+
|
|
198
|
+
| Method | Description |
|
|
199
|
+
| ----------------------- | ------------------------------------------ |
|
|
200
|
+
| `convertTextToDocs()` | Convert a text file to Google Docs format |
|
|
201
|
+
| `convertDocsToPdf()` | Convert a Google Docs file to PDF |
|
|
202
|
+
| `convertDocsToWord()` | Convert a Google Docs file to Word |
|
|
203
|
+
| `convertDocsToText()` | Convert a Google Docs file to plain text |
|
|
204
|
+
| `convertCsvToSheet()` | Convert a CSV file to Google Sheets |
|
|
205
|
+
| `convertExcelToSheet()` | Convert an Excel file to Google Sheets |
|
|
206
|
+
| `convertSheetToCsv()` | Convert a Google Sheet to CSV |
|
|
207
|
+
| `convertSheetToPdf()` | Convert a Google Sheet to PDF |
|
|
208
|
+
| `convertPptToSlides()` | Convert a PowerPoint file to Google Slides |
|
|
209
|
+
| `convertSlidesToPpt()` | Convert a Google Slides file to PowerPoint |
|
|
210
|
+
| `convertSlidesToPdf()` | Convert a Google Slides file to PDF |
|
|
211
|
+
| `convertPdfToDocs()` | Convert a PDF file to Google Docs (OCR) |
|
|
212
|
+
| `convertDrawingToPng()` | Convert a Google Drawing to PNG |
|
|
213
|
+
| `convertDrawingToPdf()` | Convert a Google Drawing to PDF |
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
### ⚞ **`operations.watcherOperations`**
|
|
218
|
+
|
|
219
|
+
| Method | Description |
|
|
220
|
+
| ------------------------ | ------------------------------------------------------------ |
|
|
221
|
+
| `watchFolderEvent()` | Detect add/modify/delete events in a folder (non-recursive). |
|
|
222
|
+
| `watchFolderDeepEvent()` | Detect events recursively in a folder and subfolders. |
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
### ⚞ **`operations.scriptOperations`**
|
|
227
|
+
|
|
228
|
+
| Method | Description |
|
|
229
|
+
| ---------------------- | ----------------------------------------------- |
|
|
230
|
+
| `createGoogleScript()` | Create a new Google Apps Script project. |
|
|
231
|
+
| `updateGoogleScript()` | Update code in an existing Apps Script project. |
|
|
232
|
+
| `deleteGoogleScript()` | Move an Apps Script project to trash. |
|
|
233
|
+
| `deployGoogleScript()` | Deploy a new version of an Apps Script project. |
|
|
234
|
+
|
|
235
|
+
## 🔑 Enabling Google Apps Script API (Required for Script Tools)
|
|
236
|
+
|
|
237
|
+
### 1️⃣ Enable Apps Script API in Google Cloud Console
|
|
238
|
+
|
|
239
|
+
Open this link (replace YOUR_PROJECT_ID if needed):
|
|
240
|
+
|
|
241
|
+
👉 https://console.cloud.google.com/apis/library/script.googleapis.com?project=YOUR_PROJECT_ID
|
|
242
|
+
|
|
243
|
+
Then:
|
|
244
|
+
|
|
245
|
+
1. Click **Enable**
|
|
246
|
+
2. Make sure the Apps Script API is active in your Cloud project
|
|
247
|
+
|
|
248
|
+
### 2️⃣ Enable Apps Script API in Your Google Account
|
|
249
|
+
|
|
250
|
+
Apps Script also requires user-level permission.
|
|
251
|
+
|
|
252
|
+
Open:
|
|
253
|
+
|
|
254
|
+
👉 https://script.google.com/home/usersettings
|
|
255
|
+
|
|
256
|
+
Then turn **ON**:
|
|
257
|
+
|
|
258
|
+
🔘 “Apps Script API”
|
|
259
|
+
|
|
260
|
+
This MUST be enabled or script creation, updating, and deployment will fail.
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
### 🧑💻 Author
|
|
265
|
+
|
|
266
|
+
**VK**
|
|
267
|
+
[GitHub](https://github.com/vk007) • [NPM](https://www.npmjs.com/~vk007)
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
### ⚖️ License
|
|
272
|
+
|
|
273
|
+
**MIT License** — free to use, modify, and distribute.
|
|
274
|
+
|
|
275
|
+
---
|
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { CredentialsFileParams } from "./types";
|
|
2
|
+
import { OAuth2Client } from "./drivers/oauth2-client";
|
|
3
|
+
export declare function generateCredentialsAndTokens({ clientid, projectid, clientsecret, redirecturis, javascript_origin, }: CredentialsFileParams): Promise<OAuth2Client>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Download a file from Google Drive
|
|
3
|
+
* @param fileId - Google Drive file ID
|
|
4
|
+
* @param savePath - Where to save the file (e.g., './downloads/file.pdf')
|
|
5
|
+
*/
|
|
6
|
+
export declare function downloadFile(fileId: string, savePath: string): Promise<import("../../types").ApiResponse<{
|
|
7
|
+
path: string;
|
|
8
|
+
}>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get file ID by name
|
|
3
|
+
* @param fileName - File name to find
|
|
4
|
+
*/
|
|
5
|
+
export declare function getFileIdByName(fileName: string): Promise<{
|
|
6
|
+
success: boolean;
|
|
7
|
+
fileId: string;
|
|
8
|
+
file: any;
|
|
9
|
+
error?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
success: boolean;
|
|
12
|
+
error: string | undefined;
|
|
13
|
+
fileId?: undefined;
|
|
14
|
+
file?: undefined;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get file information
|
|
3
|
+
* @param fileId - Google Drive file ID
|
|
4
|
+
*/
|
|
5
|
+
export declare function getFileInfo(fileId: string): Promise<import("../../types").ApiResponse<import("../../types").FileMetadata>>;
|
|
6
|
+
/**
|
|
7
|
+
* Get complete file metadata including all available fields
|
|
8
|
+
* @param fileId - Google Drive file ID
|
|
9
|
+
*/
|
|
10
|
+
export declare function getCompleteFileInfo(fileId: string): Promise<import("../../types").ApiResponse<import("../../types").FileMetadata>>;
|
|
11
|
+
/**
|
|
12
|
+
* Get image metadata for an image file
|
|
13
|
+
* @param fileId - Google Drive file ID of the image
|
|
14
|
+
*/
|
|
15
|
+
export declare function getImageMetadata(fileId: string): Promise<import("../../types").ApiResponse<import("../../types").ImageMediaMetadata>>;
|
|
16
|
+
/**
|
|
17
|
+
* Get video metadata for a video file
|
|
18
|
+
* @param fileId - Google Drive file ID of the video
|
|
19
|
+
*/
|
|
20
|
+
export declare function getVideoMetadata(fileId: string): Promise<import("../../types").ApiResponse<import("../../types").VideoMediaMetadata>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic helper to search for items by name with optional type filtering
|
|
3
|
+
* @param name - Name to search for
|
|
4
|
+
* @param type - Optional: 'file' | 'folder'
|
|
5
|
+
* @param searchType - Optional: 'exact' | 'contains' (default: 'exact')
|
|
6
|
+
*/
|
|
7
|
+
export declare function searchByNameHelper(name: string, type?: "file" | "folder", searchType?: "exact" | "contains"): Promise<import("../../types").ApiResponse<import("../../types").ListFilesResponse>>;
|
|
8
|
+
/**
|
|
9
|
+
* Generic helper to get ID by name with optional type filtering
|
|
10
|
+
* @param name - Name to search for
|
|
11
|
+
* @param type - Optional: 'file' | 'folder'
|
|
12
|
+
*/
|
|
13
|
+
export declare function getIdByNameHelper(name: string, type?: "file" | "folder"): Promise<{
|
|
14
|
+
success: boolean;
|
|
15
|
+
id?: string;
|
|
16
|
+
item?: any;
|
|
17
|
+
error?: string;
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Move file to a different folder
|
|
3
|
+
* @param fileId - Google Drive file ID
|
|
4
|
+
* @param newFolderId - Destination folder ID
|
|
5
|
+
*/
|
|
6
|
+
export declare function moveFile(fileId: string, newFolderId: string): Promise<import("../../types").ApiResponse<import("../../types").FileMetadata>>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MimeType } from "../../types/index";
|
|
2
|
+
/**
|
|
3
|
+
* Update file content (replace existing file content)
|
|
4
|
+
* @param fileId - Google Drive file ID
|
|
5
|
+
* @param newContent - New content for the file
|
|
6
|
+
* @param mimeType - MIME type of the content
|
|
7
|
+
*/
|
|
8
|
+
export declare function updateFile(fileId: string, newContent: string, mimeType: MimeType): Promise<any>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MimeType } from "../../types/index";
|
|
2
|
+
/**
|
|
3
|
+
* Upload a file to Google Drive
|
|
4
|
+
* @param filePath - Path to local file (e.g., './document.pdf')
|
|
5
|
+
* @param options - Optional: fileName, folderId
|
|
6
|
+
*/
|
|
7
|
+
export declare function uploadFile(filePath: string, options?: {
|
|
8
|
+
fileName?: string;
|
|
9
|
+
folderId?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
mimeType?: MimeType;
|
|
12
|
+
}): Promise<import("../../types/index").ApiResponse<import("../../types/index").FileMetadata>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add a new key-value pair to a JSON file on Google Drive.
|
|
3
|
+
* Supports nested keys (e.g., "user.profile.name").
|
|
4
|
+
*/
|
|
5
|
+
export declare function addJsonKeyValue(fileId: string, key: string, value: any): Promise<{
|
|
6
|
+
success: boolean;
|
|
7
|
+
data: import("../../types").FileMetadata | undefined;
|
|
8
|
+
error?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
success: boolean;
|
|
11
|
+
error: any;
|
|
12
|
+
data?: undefined;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a new JSON file on Google Drive.
|
|
3
|
+
* @param jsonContent - JSON object to store in the file.
|
|
4
|
+
* @param name - Name for the new JSON file.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createJsonFile(jsonContent: any, name: string): Promise<{
|
|
7
|
+
success: boolean;
|
|
8
|
+
data: import("../../types").FileMetadata;
|
|
9
|
+
error?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
success: boolean;
|
|
12
|
+
error: string;
|
|
13
|
+
data?: undefined;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delete a key (supports nested paths like "user.profile.name")
|
|
3
|
+
* from a JSON file stored in Google Drive.
|
|
4
|
+
*/
|
|
5
|
+
export declare function deleteJsonFieldAndKeys(fileId: string, key: string): Promise<{
|
|
6
|
+
success: boolean;
|
|
7
|
+
data: import("../../types").FileMetadata | undefined;
|
|
8
|
+
error?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
success: boolean;
|
|
11
|
+
error: any;
|
|
12
|
+
data?: undefined;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Update or rename a key in a JSON file stored on Google Drive.
|
|
3
|
+
* Supports nested keys using dot notation (e.g., "user.profile.name").
|
|
4
|
+
*/
|
|
5
|
+
export declare function updateJsonFieldAndValues(fileId: string, keyPath: string, newKey?: string, newValue?: any): Promise<{
|
|
6
|
+
success: boolean;
|
|
7
|
+
data: import("../../types").FileMetadata | undefined;
|
|
8
|
+
error?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
success: boolean;
|
|
11
|
+
error: any;
|
|
12
|
+
data?: undefined;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a new folder
|
|
3
|
+
* @param folderName - Name of the folder
|
|
4
|
+
* @param parentFolderId - Optional: Parent folder ID (creates in root if not specified)
|
|
5
|
+
*/
|
|
6
|
+
export declare function createFolder(folderName: string, parentFolderId?: string): Promise<import("../../types").ApiResponse<import("../../types").FileMetadata>>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rename a folder
|
|
3
|
+
* @param folderId - Google Drive folder ID
|
|
4
|
+
* @param newName - New name for the folder
|
|
5
|
+
*/
|
|
6
|
+
export declare function renameFolder(folderId: string, newName: string): Promise<import("../../types").ApiResponse<import("../../types").FileMetadata>>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search files by raw query string
|
|
3
|
+
* @param query - Google Drive API query string (e.g. "name = 'test' and trashed = false")
|
|
4
|
+
* @param pageSize - Max results, default 10
|
|
5
|
+
*/
|
|
6
|
+
export declare function searchFiles(query: string, pageSize?: number): Promise<import("../../types").ApiResponse<import("../../types").ListFilesResponse>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get folder ID by name
|
|
3
|
+
* @param folderName - Folder name to find
|
|
4
|
+
*/
|
|
5
|
+
export declare function getFolderIdByName(folderName: string): Promise<{
|
|
6
|
+
success: boolean;
|
|
7
|
+
folderId: string;
|
|
8
|
+
folder: any;
|
|
9
|
+
error?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
success: boolean;
|
|
12
|
+
error: string | undefined;
|
|
13
|
+
folderId?: undefined;
|
|
14
|
+
folder?: undefined;
|
|
15
|
+
}>;
|