@pipedream/google_drive 0.4.3 → 0.4.5
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.
|
@@ -4,13 +4,16 @@ import {
|
|
|
4
4
|
toSingleLineString,
|
|
5
5
|
} from "../../utils.mjs";
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
MY_DRIVE_VALUE,
|
|
9
|
+
GOOGLE_DRIVE_FOLDER_MIME_TYPE,
|
|
10
|
+
} from "../../constants.mjs";
|
|
8
11
|
|
|
9
12
|
export default {
|
|
10
13
|
key: "google_drive-create-folder",
|
|
11
14
|
name: "Create Folder",
|
|
12
15
|
description: "Create a new empty folder. [See the docs](https://developers.google.com/drive/api/v3/reference/files/create) for more information",
|
|
13
|
-
version: "0.0.
|
|
16
|
+
version: "0.0.7",
|
|
14
17
|
type: "action",
|
|
15
18
|
props: {
|
|
16
19
|
googleDrive,
|
|
@@ -29,8 +32,10 @@ export default {
|
|
|
29
32
|
drive: c.drive,
|
|
30
33
|
}),
|
|
31
34
|
],
|
|
32
|
-
description:
|
|
33
|
-
|
|
35
|
+
description: toSingleLineString(`
|
|
36
|
+
Select a folder in which to place the new folder.
|
|
37
|
+
If not specified, the folder will be placed directly in the drive's top-level folder.
|
|
38
|
+
`),
|
|
34
39
|
optional: true,
|
|
35
40
|
},
|
|
36
41
|
name: {
|
|
@@ -42,42 +47,46 @@ export default {
|
|
|
42
47
|
description: "The name of the new folder",
|
|
43
48
|
optional: true,
|
|
44
49
|
},
|
|
45
|
-
|
|
50
|
+
createIfUnique: {
|
|
46
51
|
type: "boolean",
|
|
47
|
-
label: "Create If
|
|
52
|
+
label: "Create Only If Filename Is Unique?",
|
|
48
53
|
description: toSingleLineString(`
|
|
49
|
-
If the folder already exists
|
|
50
|
-
backwards compatibility and to be consistent with default Google Drive behavior.
|
|
54
|
+
If the folder already exists, **do not** create. This option defaults to \`false\` for
|
|
55
|
+
backwards compatibility and to be consistent with default Google Drive behavior.
|
|
51
56
|
`),
|
|
52
57
|
optional: true,
|
|
53
|
-
default:
|
|
58
|
+
default: false,
|
|
54
59
|
},
|
|
55
60
|
},
|
|
56
61
|
async run({ $ }) {
|
|
57
62
|
const {
|
|
63
|
+
drive,
|
|
58
64
|
parentId,
|
|
59
65
|
name,
|
|
60
|
-
|
|
66
|
+
createIfUnique,
|
|
61
67
|
} = this;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
|
|
69
|
+
const driveId = await this.googleDrive.getDriveId(drive);
|
|
70
|
+
|
|
71
|
+
if (createIfUnique) {
|
|
72
|
+
let q = `mimeType = '${GOOGLE_DRIVE_FOLDER_MIME_TYPE}' and name = '${name}' and trashed = false`;
|
|
73
|
+
if (parentId) {
|
|
74
|
+
q += ` and '${parentId}' in parents`;
|
|
75
|
+
} else if (drive === MY_DRIVE_VALUE) {
|
|
76
|
+
q += " and 'root' in parents";
|
|
77
|
+
} else {
|
|
78
|
+
q += ` and '${driveId}' in parents`;
|
|
72
79
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
const folders = (await this.googleDrive.listFilesInPage(null, getListFilesOpts(drive, {
|
|
81
|
+
q,
|
|
82
|
+
}))).files;
|
|
76
83
|
|
|
77
|
-
|
|
84
|
+
if (folders.length) {
|
|
85
|
+
$.export("$summary", "Found existing folder, therefore not creating folder. Returning found folder.");
|
|
86
|
+
return this.googleDrive.getFile(folders[0].id);
|
|
78
87
|
}
|
|
79
88
|
}
|
|
80
|
-
|
|
89
|
+
|
|
81
90
|
const resp = await this.googleDrive.createFolder({
|
|
82
91
|
name,
|
|
83
92
|
parentId,
|
|
@@ -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 docs](https://developers.google.com/drive/api/v3/reference/files/list) for more information",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.2",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
googleDrive,
|
|
@@ -34,12 +34,25 @@ export default {
|
|
|
34
34
|
description: "The paths of the fields you want included in the response. If not specified, the response includes a default set of fields specific to this method. For development you can use the special value `*` to return all fields, but you'll achieve greater performance by only selecting the fields you need.\n\n**eg:** `files(id,mimeType,name,webContentLink,webViewLink)`",
|
|
35
35
|
optional: true,
|
|
36
36
|
},
|
|
37
|
+
filterText: {
|
|
38
|
+
label: "Filter Text",
|
|
39
|
+
description: "Filter by file name that contains a specific text",
|
|
40
|
+
type: "string",
|
|
41
|
+
optional: true,
|
|
42
|
+
},
|
|
37
43
|
},
|
|
38
44
|
async run({ $ }) {
|
|
39
|
-
const opts = getListFilesOpts(this.drive
|
|
45
|
+
const opts = getListFilesOpts(this.drive, {
|
|
46
|
+
q: "",
|
|
47
|
+
});
|
|
40
48
|
if (this.folderId) {
|
|
41
49
|
opts.q = `"${this.folderId}" in parents`;
|
|
42
50
|
}
|
|
51
|
+
if (this.filterText) {
|
|
52
|
+
opts.q += `${opts.q
|
|
53
|
+
? " AND "
|
|
54
|
+
: ""}name contains '${this.filterText}'`;
|
|
55
|
+
}
|
|
43
56
|
if (this.fields) {
|
|
44
57
|
opts.fields = this.fields;
|
|
45
58
|
}
|