@pipedream/google_drive 0.8.1 → 0.8.3
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.
@@ -1,5 +1,5 @@
|
|
1
|
+
import { ConfigurationError } from "@pipedream/platform";
|
1
2
|
import {
|
2
|
-
GOOGLE_DRIVE_FOLDER_MIME_TYPE,
|
3
3
|
GOOGLE_DRIVE_GRANTEE_DOMAIN,
|
4
4
|
GOOGLE_DRIVE_GRANTEE_GROUP,
|
5
5
|
GOOGLE_DRIVE_GRANTEE_USER,
|
@@ -20,7 +20,7 @@ export default {
|
|
20
20
|
name: "Share File or Folder",
|
21
21
|
description:
|
22
22
|
"Add a [sharing permission](https://support.google.com/drive/answer/7166529) to the sharing preferences of a file or folder and provide a sharing URL. [See the documentation](https://developers.google.com/drive/api/v3/reference/permissions/create)",
|
23
|
-
version: "0.1.
|
23
|
+
version: "0.1.7",
|
24
24
|
type: "action",
|
25
25
|
props: {
|
26
26
|
googleDrive,
|
@@ -31,17 +31,27 @@ export default {
|
|
31
31
|
],
|
32
32
|
optional: true,
|
33
33
|
},
|
34
|
-
|
34
|
+
fileId: {
|
35
35
|
propDefinition: [
|
36
36
|
googleDrive,
|
37
|
-
"
|
37
|
+
"fileId",
|
38
38
|
(c) => ({
|
39
39
|
drive: c.drive,
|
40
40
|
}),
|
41
41
|
],
|
42
|
-
optional:
|
43
|
-
description: "The file or folder
|
44
|
-
|
42
|
+
optional: true,
|
43
|
+
description: "The file to share. You must specify either a file or a folder.",
|
44
|
+
},
|
45
|
+
folderId: {
|
46
|
+
propDefinition: [
|
47
|
+
googleDrive,
|
48
|
+
"folderId",
|
49
|
+
(c) => ({
|
50
|
+
drive: c.drive,
|
51
|
+
}),
|
52
|
+
],
|
53
|
+
optional: true,
|
54
|
+
description: "The folder to share. You must specify either a file or a folder.",
|
45
55
|
},
|
46
56
|
type: {
|
47
57
|
propDefinition: [
|
@@ -54,13 +64,9 @@ export default {
|
|
54
64
|
async additionalProps() {
|
55
65
|
const obj = {};
|
56
66
|
const {
|
57
|
-
|
67
|
+
fileId, folderId, type,
|
58
68
|
} = this;
|
59
|
-
if (!
|
60
|
-
|
61
|
-
const { mimeType } = await this.googleDrive.getFile(this.fileOrFolderId, {
|
62
|
-
fields: "mimeType",
|
63
|
-
});
|
69
|
+
if (!(fileId || folderId) || !type) return obj;
|
64
70
|
|
65
71
|
const emailAddress = {
|
66
72
|
type: "string",
|
@@ -93,7 +99,7 @@ export default {
|
|
93
99
|
break;
|
94
100
|
}
|
95
101
|
|
96
|
-
const isFolder =
|
102
|
+
const isFolder = !!folderId;
|
97
103
|
const options = GOOGLE_DRIVE_ROLE_OPTIONS;
|
98
104
|
|
99
105
|
if (isFolder) {
|
@@ -114,10 +120,13 @@ export default {
|
|
114
120
|
},
|
115
121
|
async run({ $ }) {
|
116
122
|
const {
|
117
|
-
|
123
|
+
fileId, folderId, role, type, domain, emailAddress,
|
118
124
|
} = this;
|
125
|
+
if (!(fileId || folderId)) {
|
126
|
+
throw new ConfigurationError("You must specify either a file or a folder");
|
127
|
+
}
|
119
128
|
// Create the permission for the file
|
120
|
-
await this.googleDrive.createPermission(
|
129
|
+
await this.googleDrive.createPermission(folderId ?? fileId, {
|
121
130
|
role,
|
122
131
|
type,
|
123
132
|
domain,
|
@@ -125,11 +134,13 @@ export default {
|
|
125
134
|
});
|
126
135
|
|
127
136
|
// Get the file to get the `webViewLink` sharing URL
|
128
|
-
const resp = await this.googleDrive.getFile(
|
137
|
+
const resp = await this.googleDrive.getFile(folderId ?? fileId);
|
129
138
|
const webViewLink = resp.webViewLink;
|
130
139
|
$.export(
|
131
140
|
"$summary",
|
132
|
-
`Successfully shared
|
141
|
+
`Successfully shared ${folderId
|
142
|
+
? "folder"
|
143
|
+
: "file"} "${resp.name}" with ${type} "${
|
133
144
|
emailAddress ?? domain ?? ""
|
134
145
|
}" with role '${role}'`,
|
135
146
|
);
|
@@ -11,7 +11,7 @@ export default {
|
|
11
11
|
key: "google_drive-upload-file",
|
12
12
|
name: "Upload File",
|
13
13
|
description: "Upload a file to Google Drive. [See the documentation](https://developers.google.com/drive/api/v3/manage-uploads) for more information",
|
14
|
-
version: "0.1.
|
14
|
+
version: "0.1.8",
|
15
15
|
type: "action",
|
16
16
|
props: {
|
17
17
|
googleDrive,
|
@@ -104,7 +104,7 @@ export default {
|
|
104
104
|
const file = await getFileStream({
|
105
105
|
$,
|
106
106
|
fileUrl,
|
107
|
-
filePath: filePath
|
107
|
+
filePath: filePath?.startsWith("/tmp/")
|
108
108
|
? filePath
|
109
109
|
: `/tmp/${filePath}`,
|
110
110
|
});
|