@pipedream/google_drive 0.4.3 → 0.4.4
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,
|