gdrivekit 1.0.0 β†’ 1.0.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.md CHANGED
@@ -1,15 +1,185 @@
1
- # googledrive
1
+ ## 🧩 gdrivekit
2
2
 
3
- To install dependencies:
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
+ * ⚑ Minimal setup, lightweight, and easy to use
15
+ * πŸ’‘ Works with Node.js and Bun
16
+
17
+ ---
18
+
19
+ ### πŸ“¦ Installation
4
20
 
5
21
  ```bash
6
- bun install
22
+ npm install gdrivekit
7
23
  ```
8
24
 
9
- To run:
25
+ or
10
26
 
11
27
  ```bash
12
- bun run index.ts
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** β€” the tokens will be stored locally and reused automatically.
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
+ });
49
+ ```
50
+
51
+ βœ… **Run this code once** to authenticate your app and save tokens (usually in `tokens.json`).
52
+ After that, you **don’t need to call it again** unless you delete your tokens or change your Google credentials.
53
+
54
+ ---
55
+
56
+ # πŸ”„ Initializing the Drive Service
57
+
58
+ Once tokens are generated, you can initialize the Google Drive service and perform file operations:
59
+
60
+ ```ts
61
+ import { operations } from "gdrivekit";
62
+ import { initDriveService } from "./drivers/services";
63
+
64
+ async function main() {
65
+ initDriveService();
66
+
67
+ // Example: Search files by name
68
+ const files = await operations.searchByName("test");
69
+ console.log(files.data?.files);
70
+ }
71
+
72
+ main();
73
+ ```
74
+
75
+ ---
76
+
77
+ ## 🧠 Available Operations
78
+
79
+ ### πŸ“ **File Operations**
80
+
81
+ | Method | Description |
82
+ | ------------------ | ----------------------------------------- |
83
+ | `uploadFile()` | Upload a new file to Google Drive |
84
+ | `downloadFile()` | Download a file from Drive |
85
+ | `deleteFile()` | Permanently delete a file |
86
+ | `renameFile()` | Rename an existing file |
87
+ | `updateFile()` | Update file metadata or content |
88
+ | `getFileInfo()` | Get details of a specific file |
89
+ | `moveFile()` | Move file to another folder using file ID |
90
+ | `moveFileByName()` | Move file by its name |
91
+ | `copyFile()` | Make a copy of a file in Drive |
92
+
93
+ ---
94
+
95
+ ### πŸ—‚οΈ **Folder Operations**
96
+
97
+ | Method | Description |
98
+ | --------------------- | --------------------------------------- |
99
+ | `createFolder()` | Create a new folder |
100
+ | `deleteFolder()` | Delete an existing folder |
101
+ | `listAllFolders()` | List all folders in Drive |
102
+ | `listFilesInFolder()` | List all files within a specific folder |
103
+
104
+ ---
105
+
106
+ ### πŸ” **Search Operations**
107
+
108
+ | Method | Description |
109
+ | ----------------------- | -------------------------------------- |
110
+ | `searchByName()` | Search files containing a name |
111
+ | `searchByExactName()` | Search files matching exact name |
112
+ | `searchByType()` | Search by file type (e.g., PDF, image) |
113
+ | `searchModifiedAfter()` | Find files modified after a given date |
114
+ | `searchStarredFiles()` | List all starred files |
115
+ | `searchSharedFiles()` | Find files shared with you |
116
+ | `searchByContent()` | Search within file content |
117
+
118
+ ---
119
+
120
+ ### πŸ“‹ **List Operations**
121
+
122
+ | Method | Description |
123
+ | ------------------- | ------------------------------------- |
124
+ | `listFiles()` | List all files in Drive |
125
+ | `listRecentFiles()` | List recently modified or added files |
126
+ | `listPDFs()` | List all PDF files |
127
+ | `listImages()` | List all image files |
128
+
129
+ ---
130
+
131
+ ### 🧩 **Batch Operations**
132
+
133
+ | Method | Description |
134
+ | ------------------------- | ------------------------------------ |
135
+ | `uploadMultipleFiles()` | Upload multiple files at once |
136
+ | `deleteMultipleFiles()` | Delete multiple files simultaneously |
137
+ | `downloadMultipleFiles()` | Download multiple files in parallel |
138
+
139
+ ---
140
+
141
+ ### 🧰 **Utility Operations**
142
+
143
+ | Method | Description |
144
+ | --------------------- | --------------------------- |
145
+ | `fileExists()` | Check if a file exists |
146
+ | `getFolderIdByName()` | Fetch folder ID by its name |
147
+ | `getFileIdByName()` | Fetch file ID by its name |
148
+
149
+ ---
150
+
151
+ ### ⚑ Example: Upload a File
152
+
153
+ ```ts
154
+ await operations.uploadFile({
155
+ name: "report.pdf",
156
+ path: "./files/report.pdf",
157
+ mimeType: "application/pdf",
158
+ });
159
+ ```
160
+
161
+ ---
162
+
163
+ ### ⚑ Example: Search and Download
164
+
165
+ ```ts
166
+ const files = await operations.searchByName("invoice");
167
+ if (files?.data?.files?.length) {
168
+ await operations.downloadFile(files.data.files[0].id, "./downloads/invoice.pdf");
169
+ }
13
170
  ```
14
171
 
15
- This project was created using `bun init` in bun v1.3.0. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
172
+ ---
173
+
174
+ ### πŸ§‘β€πŸ’» Author
175
+
176
+ **Vikash Khati**
177
+ [GitHub](https://github.com/vikashkhati007) β€’ [NPM](https://www.npmjs.com/~vikashkhati007)
178
+
179
+ ---
180
+
181
+ ### βš–οΈ License
182
+
183
+ **MIT License** β€” free to use, modify, and distribute.
184
+
185
+ ---
package/dist/index.js CHANGED
@@ -778992,10 +778992,8 @@ async function generateCredentialsAndTokens({
778992
778992
  clientid,
778993
778993
  projectid,
778994
778994
  clientsecret,
778995
- redirecturis = [
778996
- "http://localhost:3000/oauth2callback",
778997
- "http://localhost:3000/oauth2/callback"
778998
- ]
778995
+ redirecturis,
778996
+ javascript_origin
778999
778997
  }) {
779000
778998
  if (!fs2.existsSync(CREDENTIALS_PATH)) {
779001
778999
  const baseCredentials = {
@@ -779006,8 +779004,8 @@ async function generateCredentialsAndTokens({
779006
779004
  token_uri: "https://oauth2.googleapis.com/token",
779007
779005
  auth_provider_x509_cert_url: "https://www.googleapis.com/oauth2/v1/certs",
779008
779006
  client_secret: clientsecret,
779009
- redirect_uris: redirecturis,
779010
- javascript_origins: ["http://localhost:3000"]
779007
+ redirect_uris: redirecturis || ["http://localhost:3000/oauth2callback", "http://localhost:3000/oauth2/callback"],
779008
+ javascript_origins: javascript_origin || ["http://localhost:3000"]
779011
779009
  }
779012
779010
  };
779013
779011
  fs2.writeFileSync(CREDENTIALS_PATH, JSON.stringify(baseCredentials, null, 2));
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "gdrivekit",
3
- "version": "1.0.0",
4
- "description": "A lightweight Bun + TypeScript package for Google Drive OAuth2 authentication and file operations.",
3
+ "version": "1.0.2",
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
- "main": "index.ts",
7
- "types": "index.ts",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
8
  "scripts": {
9
9
  "dev": "bun run index.ts",
10
10
  "build": "bun build ./index.ts --outdir dist --target node",
@@ -12,13 +12,27 @@
12
12
  },
13
13
  "keywords": [
14
14
  "google-drive",
15
- "bun",
16
- "typescript",
15
+ "google drive",
16
+ "googledrive",
17
+ "gdrive",
18
+ "drive-api",
17
19
  "googleapis",
18
- "oauth2"
20
+ "google drive api",
21
+ "google drive oauth2",
22
+ "google drive upload",
23
+ "google drive automation",
24
+ "gdrivekit"
19
25
  ],
20
26
  "author": "Vikash Khati",
21
27
  "license": "MIT",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "https://github.com/vikashkhati007/gdrivekit"
31
+ },
32
+ "homepage": "https://www.npmjs.com/package/gdrivekit",
33
+ "bugs": {
34
+ "url": "https://github.com/vikashkhati007/gdrivekit/issues"
35
+ },
22
36
  "dependencies": {
23
37
  "googleapis": "^164.1.0"
24
38
  },
package/index.ts DELETED
@@ -1,3 +0,0 @@
1
- import * as operations from "./operations";
2
- import { generateCredentialsAndTokens } from "./auth";
3
- export { generateCredentialsAndTokens, operations };