gdrivekit 1.0.8 → 1.1.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/README.md +25 -0
- package/dist/index.js +130 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -159,6 +159,7 @@ main();
|
|
|
159
159
|
|
|
160
160
|
| Method | Description |
|
|
161
161
|
| --------------------- | --------------------------- |
|
|
162
|
+
| `shareFile()` | Share a file with a user |
|
|
162
163
|
| `fileExists()` | Check if a file exists |
|
|
163
164
|
| `getStorageQuota()` | Get storage quota information |
|
|
164
165
|
| `getFolderIdByName()` | Fetch folder ID by its name |
|
|
@@ -167,13 +168,37 @@ main();
|
|
|
167
168
|
---
|
|
168
169
|
|
|
169
170
|
### ❴❵ **Json Operation**
|
|
171
|
+
|
|
170
172
|
| Method | Description |
|
|
171
173
|
| ----------------------- | ----------------------------------------- |
|
|
174
|
+
| `createJsonFile()` | Create a new JSON file |
|
|
172
175
|
| `readJsonFileData()` | Read JSON file content |
|
|
173
176
|
| `addJsonKeyValue()` | Add a new key-value pair to a JSON file |
|
|
174
177
|
| `updateJsonFieldAndValues()` | Update an existing field in a JSON file |
|
|
175
178
|
| `deleteJsonFieldAndKeys()` | Delete a field from a JSON file |
|
|
176
179
|
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
### ⚞ **Conversion Operation**
|
|
183
|
+
|
|
184
|
+
| Method | Description |
|
|
185
|
+
| ----------------------- | --------------------------------------------------------- |
|
|
186
|
+
| `convertTextToDocs()` | Convert a text file (`.txt`) to Google Docs format |
|
|
187
|
+
| `convertDocsToPdf()` | Convert a Google Docs file to PDF |
|
|
188
|
+
| `convertDocsToWord()` | Convert a Google Docs file to Microsoft Word (`.docx`) |
|
|
189
|
+
| `convertDocsToText()` | Convert a Google Docs file to plain text (`.txt`) |
|
|
190
|
+
| `convertCsvToSheet()` | Convert a CSV file to Google Sheets |
|
|
191
|
+
| `convertExcelToSheet()` | Convert an Excel file (`.xlsx`) to Google Sheets |
|
|
192
|
+
| `convertSheetToCsv()` | Convert a Google Sheet to CSV |
|
|
193
|
+
| `convertSheetToPdf()` | Convert a Google Sheet to PDF |
|
|
194
|
+
| `convertPptToSlides()` | Convert a PowerPoint file (`.pptx`) to Google Slides |
|
|
195
|
+
| `convertSlidesToPpt()` | Convert a Google Slides file to PowerPoint (`.pptx`) |
|
|
196
|
+
| `convertSlidesToPdf()` | Convert a Google Slides file to PDF |
|
|
197
|
+
| `convertPdfToDocs()` | Convert a PDF file to Google Docs (with OCR if supported) |
|
|
198
|
+
| `convertDrawingToPng()` | Convert a Google Drawing to PNG image |
|
|
199
|
+
| `convertDrawingToPdf()` | Convert a Google Drawing to PDF |
|
|
200
|
+
|
|
201
|
+
|
|
177
202
|
---
|
|
178
203
|
|
|
179
204
|
### ⚡ Example: Upload a File
|
package/dist/index.js
CHANGED
|
@@ -778706,6 +778706,7 @@ __export(exports_operations, {
|
|
|
778706
778706
|
uploadFile: () => uploadFile,
|
|
778707
778707
|
updateJsonFieldAndValues: () => updateJsonFieldAndValues,
|
|
778708
778708
|
updateFile: () => updateFile,
|
|
778709
|
+
shareFile: () => shareFile,
|
|
778709
778710
|
searchStarredFiles: () => searchStarredFiles,
|
|
778710
778711
|
searchSharedFiles: () => searchSharedFiles,
|
|
778711
778712
|
searchModifiedAfter: () => searchModifiedAfter,
|
|
@@ -778748,14 +778749,26 @@ __export(exports_operations, {
|
|
|
778748
778749
|
deleteJsonFieldAndKeys: () => deleteJsonFieldAndKeys,
|
|
778749
778750
|
deleteFolder: () => deleteFolder,
|
|
778750
778751
|
deleteFile: () => deleteFile,
|
|
778752
|
+
createJsonFile: () => createJsonFile,
|
|
778751
778753
|
createFolder: () => createFolder,
|
|
778752
778754
|
copyFile: () => copyFile,
|
|
778755
|
+
convertTextToDocs: () => convertTextToDocs,
|
|
778756
|
+
convertSlidesToPpt: () => convertSlidesToPpt,
|
|
778757
|
+
convertSlidesToPdf: () => convertSlidesToPdf,
|
|
778758
|
+
convertSheetToPdf: () => convertSheetToPdf,
|
|
778759
|
+
convertSheetToCsv: () => convertSheetToCsv,
|
|
778760
|
+
convertPptToSlides: () => convertPptToSlides,
|
|
778761
|
+
convertPdfToDocs: () => convertPdfToDocs,
|
|
778762
|
+
convertExcelToSheet: () => convertExcelToSheet,
|
|
778763
|
+
convertDrawingToPng: () => convertDrawingToPng,
|
|
778764
|
+
convertDrawingToPdf: () => convertDrawingToPdf,
|
|
778765
|
+
convertDocsToWord: () => convertDocsToWord,
|
|
778766
|
+
convertDocsToText: () => convertDocsToText,
|
|
778767
|
+
convertDocsToPdf: () => convertDocsToPdf,
|
|
778768
|
+
convertCsvToSheet: () => convertCsvToSheet,
|
|
778753
778769
|
addJsonKeyValue: () => addJsonKeyValue
|
|
778754
778770
|
});
|
|
778755
778771
|
|
|
778756
|
-
// drivers/services.ts
|
|
778757
|
-
var driveService;
|
|
778758
|
-
|
|
778759
778772
|
// types/index.ts
|
|
778760
778773
|
var MIME_TYPES = {
|
|
778761
778774
|
FOLDER: "application/vnd.google-apps.folder",
|
|
@@ -778785,6 +778798,9 @@ var MIME_TYPES = {
|
|
|
778785
778798
|
RAR: "application/x-rar-compressed"
|
|
778786
778799
|
};
|
|
778787
778800
|
|
|
778801
|
+
// drivers/services.ts
|
|
778802
|
+
var driveService;
|
|
778803
|
+
|
|
778788
778804
|
// operations.ts
|
|
778789
778805
|
async function searchByNameHelper(name, type, searchType = "exact") {
|
|
778790
778806
|
let query = searchType === "exact" ? `name='${name}'` : `name contains '${name}'`;
|
|
@@ -778806,7 +778822,10 @@ async function getIdByNameHelper(name, type) {
|
|
|
778806
778822
|
item
|
|
778807
778823
|
};
|
|
778808
778824
|
}
|
|
778809
|
-
return {
|
|
778825
|
+
return {
|
|
778826
|
+
success: false,
|
|
778827
|
+
error: `${type ? type.charAt(0).toUpperCase() + type.slice(1) : "Item"} not found`
|
|
778828
|
+
};
|
|
778810
778829
|
}
|
|
778811
778830
|
async function readFileData(fileId) {
|
|
778812
778831
|
const response = await driveService.readFileData(fileId);
|
|
@@ -778872,6 +778891,9 @@ async function moveFileByName(fileName, folderName) {
|
|
|
778872
778891
|
async function copyFile(fileId, newName) {
|
|
778873
778892
|
return await driveService.copyFile(fileId, newName ? { name: newName } : undefined);
|
|
778874
778893
|
}
|
|
778894
|
+
async function createJsonFile(jsonContent, name) {
|
|
778895
|
+
return await driveService.createJsonFile(JSON.stringify(jsonContent), name);
|
|
778896
|
+
}
|
|
778875
778897
|
async function readJsonFileData(fileId) {
|
|
778876
778898
|
const content = await readFileData(fileId);
|
|
778877
778899
|
try {
|
|
@@ -779153,6 +779175,9 @@ async function fileExists(fileName) {
|
|
|
779153
779175
|
async function getStorageQuota() {
|
|
779154
779176
|
return await driveService.getStorageQuota();
|
|
779155
779177
|
}
|
|
779178
|
+
async function shareFile(fileId, emailAddress, role = "reader") {
|
|
779179
|
+
return await driveService.shareFile(fileId, emailAddress, role);
|
|
779180
|
+
}
|
|
779156
779181
|
async function getFolderIdByName(folderName) {
|
|
779157
779182
|
const result = await getIdByNameHelper(folderName, "folder");
|
|
779158
779183
|
if (result.success) {
|
|
@@ -779175,6 +779200,90 @@ async function getFileIdByName(fileName) {
|
|
|
779175
779200
|
}
|
|
779176
779201
|
return { success: false, error: result.error };
|
|
779177
779202
|
}
|
|
779203
|
+
async function convertTextToDocs(fileId) {
|
|
779204
|
+
const response = await driveService.ConversionFunction(fileId, MIME_TYPES.DOCUMENT);
|
|
779205
|
+
if (response.success && response.data)
|
|
779206
|
+
return response.data;
|
|
779207
|
+
throw new Error(response.error || "Failed to convert Text → Google Docs");
|
|
779208
|
+
}
|
|
779209
|
+
async function convertDocsToPdf(fileId) {
|
|
779210
|
+
const response = await driveService.ConversionFunction(fileId, MIME_TYPES.PDF);
|
|
779211
|
+
if (response.success && response.data)
|
|
779212
|
+
return response.data;
|
|
779213
|
+
throw new Error(response.error || "Failed to convert Docs → PDF");
|
|
779214
|
+
}
|
|
779215
|
+
async function convertDocsToWord(fileId) {
|
|
779216
|
+
const response = await driveService.ConversionFunction(fileId, MIME_TYPES.WORD);
|
|
779217
|
+
if (response.success && response.data)
|
|
779218
|
+
return response.data;
|
|
779219
|
+
throw new Error(response.error || "Failed to convert Docs → Word");
|
|
779220
|
+
}
|
|
779221
|
+
async function convertDocsToText(fileId) {
|
|
779222
|
+
const response = await driveService.ConversionFunction(fileId, MIME_TYPES.TEXT);
|
|
779223
|
+
if (response.success && response.data)
|
|
779224
|
+
return response.data;
|
|
779225
|
+
throw new Error(response.error || "Failed to convert Docs → Text");
|
|
779226
|
+
}
|
|
779227
|
+
async function convertCsvToSheet(fileId) {
|
|
779228
|
+
const response = await driveService.ConversionFunction(fileId, MIME_TYPES.SPREADSHEET);
|
|
779229
|
+
if (response.success && response.data)
|
|
779230
|
+
return response.data;
|
|
779231
|
+
throw new Error(response.error || "Failed to convert CSV → Google Sheet");
|
|
779232
|
+
}
|
|
779233
|
+
async function convertExcelToSheet(fileId) {
|
|
779234
|
+
const response = await driveService.ConversionFunction(fileId, MIME_TYPES.SPREADSHEET);
|
|
779235
|
+
if (response.success && response.data)
|
|
779236
|
+
return response.data;
|
|
779237
|
+
throw new Error(response.error || "Failed to convert Excel → Google Sheet");
|
|
779238
|
+
}
|
|
779239
|
+
async function convertSheetToCsv(fileId) {
|
|
779240
|
+
const response = await driveService.ConversionFunction(fileId, MIME_TYPES.CSV);
|
|
779241
|
+
if (response.success && response.data)
|
|
779242
|
+
return response.data;
|
|
779243
|
+
throw new Error(response.error || "Failed to convert Sheet → CSV");
|
|
779244
|
+
}
|
|
779245
|
+
async function convertSheetToPdf(fileId) {
|
|
779246
|
+
const response = await driveService.ConversionFunction(fileId, MIME_TYPES.PDF);
|
|
779247
|
+
if (response.success && response.data)
|
|
779248
|
+
return response.data;
|
|
779249
|
+
throw new Error(response.error || "Failed to convert Sheet → PDF");
|
|
779250
|
+
}
|
|
779251
|
+
async function convertPptToSlides(fileId) {
|
|
779252
|
+
const response = await driveService.ConversionFunction(fileId, MIME_TYPES.PRESENTATION);
|
|
779253
|
+
if (response.success && response.data)
|
|
779254
|
+
return response.data;
|
|
779255
|
+
throw new Error(response.error || "Failed to convert PPT → Google Slides");
|
|
779256
|
+
}
|
|
779257
|
+
async function convertSlidesToPpt(fileId) {
|
|
779258
|
+
const response = await driveService.ConversionFunction(fileId, MIME_TYPES.POWERPOINT);
|
|
779259
|
+
if (response.success && response.data)
|
|
779260
|
+
return response.data;
|
|
779261
|
+
throw new Error(response.error || "Failed to convert Slides → PPTX");
|
|
779262
|
+
}
|
|
779263
|
+
async function convertSlidesToPdf(fileId) {
|
|
779264
|
+
const response = await driveService.ConversionFunction(fileId, MIME_TYPES.PDF);
|
|
779265
|
+
if (response.success && response.data)
|
|
779266
|
+
return response.data;
|
|
779267
|
+
throw new Error(response.error || "Failed to convert Slides → PDF");
|
|
779268
|
+
}
|
|
779269
|
+
async function convertPdfToDocs(fileId) {
|
|
779270
|
+
const response = await driveService.ConversionFunction(fileId, MIME_TYPES.DOCUMENT);
|
|
779271
|
+
if (response.success && response.data)
|
|
779272
|
+
return response.data;
|
|
779273
|
+
throw new Error(response.error || "Failed to convert PDF → Google Docs");
|
|
779274
|
+
}
|
|
779275
|
+
async function convertDrawingToPng(fileId) {
|
|
779276
|
+
const response = await driveService.ConversionFunction(fileId, MIME_TYPES.PNG);
|
|
779277
|
+
if (response.success && response.data)
|
|
779278
|
+
return response.data;
|
|
779279
|
+
throw new Error(response.error || "Failed to convert Drawing → PNG");
|
|
779280
|
+
}
|
|
779281
|
+
async function convertDrawingToPdf(fileId) {
|
|
779282
|
+
const response = await driveService.ConversionFunction(fileId, MIME_TYPES.PDF);
|
|
779283
|
+
if (response.success && response.data)
|
|
779284
|
+
return response.data;
|
|
779285
|
+
throw new Error(response.error || "Failed to convert Drawing → PDF");
|
|
779286
|
+
}
|
|
779178
779287
|
var driveOperations = {
|
|
779179
779288
|
readFileData,
|
|
779180
779289
|
uploadFile,
|
|
@@ -779189,6 +779298,7 @@ var driveOperations = {
|
|
|
779189
779298
|
copyFile,
|
|
779190
779299
|
getImageMetadata,
|
|
779191
779300
|
getVideoMetadata,
|
|
779301
|
+
createJsonFile,
|
|
779192
779302
|
readJsonFileData,
|
|
779193
779303
|
addJsonKeyValue,
|
|
779194
779304
|
updateJsonFieldAndValues,
|
|
@@ -779220,10 +779330,25 @@ var driveOperations = {
|
|
|
779220
779330
|
uploadMultipleFiles,
|
|
779221
779331
|
deleteMultipleFiles,
|
|
779222
779332
|
downloadMultipleFiles,
|
|
779333
|
+
shareFile,
|
|
779223
779334
|
fileExists,
|
|
779224
779335
|
getStorageQuota,
|
|
779225
779336
|
getFolderIdByName,
|
|
779226
|
-
getFileIdByName
|
|
779337
|
+
getFileIdByName,
|
|
779338
|
+
convertTextToDocs,
|
|
779339
|
+
convertDocsToPdf,
|
|
779340
|
+
convertDocsToWord,
|
|
779341
|
+
convertDocsToText,
|
|
779342
|
+
convertCsvToSheet,
|
|
779343
|
+
convertExcelToSheet,
|
|
779344
|
+
convertSheetToCsv,
|
|
779345
|
+
convertSheetToPdf,
|
|
779346
|
+
convertPptToSlides,
|
|
779347
|
+
convertSlidesToPpt,
|
|
779348
|
+
convertSlidesToPdf,
|
|
779349
|
+
convertPdfToDocs,
|
|
779350
|
+
convertDrawingToPng,
|
|
779351
|
+
convertDrawingToPdf
|
|
779227
779352
|
};
|
|
779228
779353
|
|
|
779229
779354
|
// auth.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gdrivekit",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A lightweight Google Drive toolkit for File Management. Handle Google Drive operations easily — upload, download, and other file operations in a few lines of code.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|