@pipedream/google_drive 0.6.15 → 0.6.17
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.
@@ -5,7 +5,7 @@ export default {
|
|
5
5
|
key: "google_drive-list-files",
|
6
6
|
name: "List Files",
|
7
7
|
description: "List files from a specific folder. [See the documentation](https://developers.google.com/drive/api/v3/reference/files/list) for more information",
|
8
|
-
version: "0.1.
|
8
|
+
version: "0.1.5",
|
9
9
|
type: "action",
|
10
10
|
props: {
|
11
11
|
googleDrive,
|
@@ -39,6 +39,7 @@ export default {
|
|
39
39
|
description: "Filter by file name that contains a specific text",
|
40
40
|
type: "string",
|
41
41
|
optional: true,
|
42
|
+
reloadProps: true,
|
42
43
|
},
|
43
44
|
trashed: {
|
44
45
|
label: "Trashed",
|
@@ -47,6 +48,22 @@ export default {
|
|
47
48
|
optional: true,
|
48
49
|
},
|
49
50
|
},
|
51
|
+
async additionalProps() {
|
52
|
+
const props = {};
|
53
|
+
if (this.filterText) {
|
54
|
+
props.filterType = {
|
55
|
+
type: "string",
|
56
|
+
label: "Filter Type",
|
57
|
+
description: "Whether to return files with names containing the Filter Text or files with names that match the Filter Text exactly. Defaults to \"CONTAINS\"",
|
58
|
+
options: [
|
59
|
+
"CONTAINS",
|
60
|
+
"EXACT MATCH",
|
61
|
+
],
|
62
|
+
default: "CONTAINS",
|
63
|
+
};
|
64
|
+
}
|
65
|
+
return props;
|
66
|
+
},
|
50
67
|
async run({ $ }) {
|
51
68
|
const opts = getListFilesOpts(this.drive, {
|
52
69
|
q: "",
|
@@ -57,7 +74,9 @@ export default {
|
|
57
74
|
if (this.filterText) {
|
58
75
|
opts.q += `${opts.q
|
59
76
|
? " AND "
|
60
|
-
: ""}name
|
77
|
+
: ""}name ${this.filterType === "CONTAINS"
|
78
|
+
? "contains"
|
79
|
+
: "="} '${this.filterText}'`;
|
61
80
|
}
|
62
81
|
if (typeof this.trashed !== "undefined") {
|
63
82
|
opts.q += `${opts.q
|
package/package.json
CHANGED
@@ -21,11 +21,38 @@ export default {
|
|
21
21
|
key: "google_drive-new-or-modified-files",
|
22
22
|
name: "New or Modified Files",
|
23
23
|
description: "Emit new event any time any file in your linked Google Drive is added, modified, or deleted",
|
24
|
-
version: "0.
|
24
|
+
version: "0.2.0",
|
25
25
|
type: "source",
|
26
26
|
// Dedupe events based on the "x-goog-message-number" header for the target channel:
|
27
27
|
// https://developers.google.com/drive/api/v3/push#making-watch-requests
|
28
28
|
dedupe: "unique",
|
29
|
+
props: {
|
30
|
+
...common.props,
|
31
|
+
folders: {
|
32
|
+
type: "string[]",
|
33
|
+
label: "Folders",
|
34
|
+
description:
|
35
|
+
"(Optional) The folders you want to watch for changes. Leave blank to watch for any new file in the Drive.",
|
36
|
+
optional: true,
|
37
|
+
default: [],
|
38
|
+
options({ prevContext }) {
|
39
|
+
const { nextPageToken } = prevContext;
|
40
|
+
const baseOpts = {
|
41
|
+
q: "mimeType = 'application/vnd.google-apps.folder' and trashed = false",
|
42
|
+
};
|
43
|
+
const opts = this.isMyDrive()
|
44
|
+
? baseOpts
|
45
|
+
: {
|
46
|
+
...baseOpts,
|
47
|
+
corpora: "drive",
|
48
|
+
driveId: this.getDriveId(),
|
49
|
+
includeItemsFromAllDrives: true,
|
50
|
+
supportsAllDrives: true,
|
51
|
+
};
|
52
|
+
return this.googleDrive.listFilesOptions(nextPageToken, opts);
|
53
|
+
},
|
54
|
+
},
|
55
|
+
},
|
29
56
|
hooks: {
|
30
57
|
async deploy() {
|
31
58
|
const daysAgo = new Date();
|
@@ -45,6 +72,15 @@ export default {
|
|
45
72
|
},
|
46
73
|
methods: {
|
47
74
|
...common.methods,
|
75
|
+
shouldProcess(file) {
|
76
|
+
if (file.mimeType !== "application/vnd.google-apps.folder") {
|
77
|
+
const watchedFolders = new Set(this.folders);
|
78
|
+
return (
|
79
|
+
watchedFolders.size == 0 ||
|
80
|
+
(file.parents && file.parents.some((p) => watchedFolders.has(p)))
|
81
|
+
);
|
82
|
+
}
|
83
|
+
},
|
48
84
|
getUpdateTypes() {
|
49
85
|
return [
|
50
86
|
GOOGLE_DRIVE_NOTIFICATION_ADD,
|
@@ -86,6 +122,17 @@ export default {
|
|
86
122
|
const changes = await this.getChanges(headers);
|
87
123
|
|
88
124
|
for (const file of changedFiles) {
|
125
|
+
file.parents = (await this.googleDrive.getFile(file.id, {
|
126
|
+
fields: "parents",
|
127
|
+
})).parents;
|
128
|
+
|
129
|
+
console.log(file); // see what file was processed
|
130
|
+
|
131
|
+
if (!this.shouldProcess(file)) {
|
132
|
+
console.log(`Skipping file ${file.name}`);
|
133
|
+
continue;
|
134
|
+
}
|
135
|
+
|
89
136
|
const eventToEmit = {
|
90
137
|
file,
|
91
138
|
...changes,
|