@activepieces/piece-google-drive 0.5.43 → 0.5.44
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@activepieces/piece-google-drive",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.44",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@ai-sdk/anthropic": "1.2.12",
|
|
6
6
|
"@ai-sdk/google": "1.2.19",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"nanoid": "3.3.8",
|
|
21
21
|
"semver": "7.6.0",
|
|
22
22
|
"zod": "3.25.76",
|
|
23
|
-
"@activepieces/pieces-common": "0.6.
|
|
23
|
+
"@activepieces/pieces-common": "0.6.3",
|
|
24
24
|
"@activepieces/pieces-framework": "0.18.0",
|
|
25
|
-
"@activepieces/shared": "0.17.
|
|
25
|
+
"@activepieces/shared": "0.17.11",
|
|
26
26
|
"tslib": "2.8.1"
|
|
27
27
|
},
|
|
28
28
|
"overrides": {
|
|
@@ -2,5 +2,6 @@ export declare const googleDriveListFiles: import("@activepieces/pieces-framewor
|
|
|
2
2
|
folderId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
3
|
include_team_drives: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
4
4
|
includeTrashed: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
5
|
+
depthLevel: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
5
6
|
downloadFiles: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
6
7
|
}>;
|
|
@@ -8,6 +8,66 @@ const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
|
8
8
|
const querystring_1 = tslib_1.__importDefault(require("querystring"));
|
|
9
9
|
const common_1 = require("../common");
|
|
10
10
|
const get_file_content_1 = require("../common/get-file-content");
|
|
11
|
+
function getFilesRecursively(auth_1, folderId_1, maxLevel_1, includeTrashed_1, includeTeamDrives_1) {
|
|
12
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (auth, folderId, maxLevel, includeTrashed, includeTeamDrives, currentLevel = 0) {
|
|
13
|
+
const files = [];
|
|
14
|
+
if (currentLevel > maxLevel) {
|
|
15
|
+
return files;
|
|
16
|
+
}
|
|
17
|
+
let q = `'${folderId}' in parents`;
|
|
18
|
+
if (!includeTrashed) {
|
|
19
|
+
q += ' and trashed=false';
|
|
20
|
+
}
|
|
21
|
+
const params = {
|
|
22
|
+
q: q,
|
|
23
|
+
fields: 'files(id,kind,mimeType,name,trashed,parents)',
|
|
24
|
+
supportsAllDrives: 'true',
|
|
25
|
+
includeItemsFromAllDrives: includeTeamDrives ? 'true' : 'false',
|
|
26
|
+
};
|
|
27
|
+
let response = yield pieces_common_1.httpClient.sendRequest({
|
|
28
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
29
|
+
url: `https://www.googleapis.com/drive/v3/files?${querystring_1.default.stringify(params)}`,
|
|
30
|
+
headers: {
|
|
31
|
+
Authorization: `Bearer ${auth.access_token}`,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
// Add files from current level
|
|
35
|
+
for (const file of response.body.files) {
|
|
36
|
+
files.push({
|
|
37
|
+
file,
|
|
38
|
+
level: currentLevel,
|
|
39
|
+
parentFolder: folderId
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
// Handle pagination for current level
|
|
43
|
+
while (response.body.nextPageToken) {
|
|
44
|
+
params.pageToken = response.body.nextPageToken;
|
|
45
|
+
response = yield pieces_common_1.httpClient.sendRequest({
|
|
46
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
47
|
+
url: `https://www.googleapis.com/drive/v3/files?${querystring_1.default.stringify(params)}`,
|
|
48
|
+
headers: {
|
|
49
|
+
Authorization: `Bearer ${auth.access_token}`,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
for (const file of response.body.files) {
|
|
53
|
+
files.push({
|
|
54
|
+
file,
|
|
55
|
+
level: currentLevel,
|
|
56
|
+
parentFolder: folderId
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// If we haven't reached max level, recursively get files from subfolders
|
|
61
|
+
if (currentLevel + 1 < maxLevel) {
|
|
62
|
+
const subfolders = files.filter(f => f.file.mimeType === 'application/vnd.google-apps.folder');
|
|
63
|
+
for (const subfolder of subfolders) {
|
|
64
|
+
const subfolderFiles = yield getFilesRecursively(auth, subfolder.file.id, maxLevel, includeTrashed, includeTeamDrives, currentLevel + 1);
|
|
65
|
+
files.push(...subfolderFiles);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return files;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
11
71
|
exports.googleDriveListFiles = (0, pieces_framework_1.createAction)({
|
|
12
72
|
auth: index_1.googleDriveAuth,
|
|
13
73
|
name: 'list-files',
|
|
@@ -26,6 +86,12 @@ exports.googleDriveListFiles = (0, pieces_framework_1.createAction)({
|
|
|
26
86
|
required: false,
|
|
27
87
|
defaultValue: false
|
|
28
88
|
}),
|
|
89
|
+
depthLevel: pieces_framework_1.Property.Number({
|
|
90
|
+
displayName: 'Depth Level',
|
|
91
|
+
description: 'How many levels deep to search for files. 1 = current folder only, 2 = current + next level, etc.',
|
|
92
|
+
required: false,
|
|
93
|
+
defaultValue: 1
|
|
94
|
+
}),
|
|
29
95
|
downloadFiles: pieces_framework_1.Property.Checkbox({
|
|
30
96
|
displayName: 'Download Files',
|
|
31
97
|
description: 'Download all file contents in a list',
|
|
@@ -35,47 +101,26 @@ exports.googleDriveListFiles = (0, pieces_framework_1.createAction)({
|
|
|
35
101
|
},
|
|
36
102
|
run(context) {
|
|
37
103
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
var _a, _b;
|
|
38
105
|
const result = {
|
|
39
106
|
type: 'drive#fileList',
|
|
40
107
|
incompleteSearch: false,
|
|
41
108
|
files: [],
|
|
42
109
|
};
|
|
43
|
-
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
const params = {
|
|
50
|
-
q: q,
|
|
51
|
-
fields: 'files(id,kind,mimeType,name,trashed)',
|
|
52
|
-
supportsAllDrives: 'true',
|
|
53
|
-
includeItemsFromAllDrives: context.propsValue.include_team_drives ? 'true' : 'false',
|
|
54
|
-
};
|
|
55
|
-
let response = yield pieces_common_1.httpClient.sendRequest({
|
|
56
|
-
method: pieces_common_1.HttpMethod.GET,
|
|
57
|
-
url: `https://www.googleapis.com/drive/v3/files?${querystring_1.default.stringify(params)}`,
|
|
58
|
-
headers: {
|
|
59
|
-
Authorization: `Bearer ${context.auth.access_token}`,
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
result.files = [...response.body.files];
|
|
63
|
-
while (response.body.nextPageToken) {
|
|
64
|
-
params.pageToken = response.body.nextPageToken;
|
|
65
|
-
response = yield pieces_common_1.httpClient.sendRequest({
|
|
66
|
-
method: pieces_common_1.HttpMethod.GET,
|
|
67
|
-
url: `https://www.googleapis.com/drive/v3/files?${querystring_1.default.stringify(params)}`,
|
|
68
|
-
headers: {
|
|
69
|
-
Authorization: `Bearer ${context.auth.access_token}`,
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
result.files.push(...response.body.files);
|
|
73
|
-
result.incompleteSearch = result.incompleteSearch || response.body.incompleteSearch;
|
|
74
|
-
}
|
|
110
|
+
const depthLevel = context.propsValue.depthLevel || 1;
|
|
111
|
+
// Get files recursively based on depth level
|
|
112
|
+
const filesWithLevel = yield getFilesRecursively(context.auth, context.propsValue.folderId, depthLevel, (_a = context.propsValue.includeTrashed) !== null && _a !== void 0 ? _a : false, (_b = context.propsValue.include_team_drives) !== null && _b !== void 0 ? _b : false);
|
|
113
|
+
// Extract just the file objects for backward compatibility
|
|
114
|
+
result.files = filesWithLevel.map(f => f.file);
|
|
75
115
|
// If downloadFiles is enabled, download each file and add URLs to array
|
|
76
116
|
if (context.propsValue.downloadFiles) {
|
|
77
117
|
const downloadedFiles = [];
|
|
78
|
-
for (const
|
|
118
|
+
for (const fileWithLevel of filesWithLevel) {
|
|
119
|
+
const file = fileWithLevel.file;
|
|
120
|
+
// Skip folders when downloading
|
|
121
|
+
if (file.mimeType === 'application/vnd.google-apps.folder') {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
79
124
|
try {
|
|
80
125
|
const fileUrl = yield (0, get_file_content_1.downloadFileFromDrive)(context.auth, context.files, file.id, file.name);
|
|
81
126
|
downloadedFiles.push(fileUrl);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-files.action.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/google-drive/src/lib/action/list-files.action.ts"],"names":[],"mappings":";;;;AAAA,+DAAqE;AACrE,uCAA8C;AAC9C,qEAAwE;AACxE,sEAAsC;AACtC,sCAAmC;AACnC,iEAAmE;
|
|
1
|
+
{"version":3,"file":"list-files.action.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/google-drive/src/lib/action/list-files.action.ts"],"names":[],"mappings":";;;;AAAA,+DAAqE;AACrE,uCAA8C;AAC9C,qEAAwE;AACxE,sEAAsC;AACtC,sCAAmC;AACnC,iEAAmE;AAenE,SAAe,mBAAmB;iEAChC,IAAS,EACT,QAAgB,EAChB,QAAgB,EAChB,cAAuB,EACvB,iBAA0B,EAC1B,YAAY,GAAG,CAAC;QAEhB,MAAM,KAAK,GAAoB,EAAE,CAAC;QAElC,IAAI,YAAY,GAAG,QAAQ,EAAE,CAAC;YAC5B,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC,GAAG,IAAI,QAAQ,cAAc,CAAC;QACnC,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,CAAC,IAAI,oBAAoB,CAAC;QAC5B,CAAC;QAED,MAAM,MAAM,GAA2B;YACrC,CAAC,EAAE,CAAC;YACJ,MAAM,EAAE,8CA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