@pipedream/google_drive 0.3.3 → 0.4.0
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/actions/add-file-sharing-preference/add-file-sharing-preference.mjs +83 -0
- package/actions/copy-file/copy-file.mjs +34 -0
- package/actions/create-file/create-file.mjs +242 -0
- package/actions/create-file-from-template/create-file-from-template.mjs +98 -0
- package/actions/create-file-from-text/create-file-from-text.mjs +67 -0
- package/actions/create-folder/create-folder.mjs +54 -0
- package/actions/create-shared-drive/create-shared-drive.mjs +25 -0
- package/actions/delete-file/delete-file.mjs +37 -0
- package/actions/delete-shared-drive/delete-shared-drive.mjs +30 -0
- package/actions/download-file/download-file.mjs +120 -0
- package/actions/find-file/find-file.mjs +35 -0
- package/actions/find-folder/find-folder.mjs +38 -0
- package/actions/get-folder-id-for-path/get-folder-id-for-path.mjs +62 -0
- package/actions/get-shared-drive/get-shared-drive.mjs +37 -0
- package/actions/google-mime-types.mjs +19 -0
- package/actions/google-workspace-export-formats.mjs +74 -0
- package/actions/language-codes.mjs +742 -0
- package/actions/move-file/move-file.mjs +52 -0
- package/actions/move-file-to-trash/move-file-to-trash.mjs +41 -0
- package/actions/replace-file/replace-file.mjs +90 -0
- package/actions/search-shared-drives/search-shared-drives.mjs +34 -0
- package/actions/update-file/update-file.mjs +164 -0
- package/actions/update-shared-drive/update-shared-drive.mjs +77 -0
- package/actions/upload-file/upload-file.mjs +89 -0
- package/constants.mjs +190 -0
- package/google_drive.app.mjs +1429 -0
- package/package.json +23 -20
- package/pnpm-lock.yaml +393 -0
- package/sources/changes-to-specific-files/changes-to-specific-files.mjs +226 -0
- package/sources/changes-to-specific-files-shared-drive/changes-to-specific-files-shared-drive.mjs +110 -0
- package/sources/common-webhook.mjs +201 -0
- package/sources/new-files-instant/new-files-instant.mjs +95 -0
- package/sources/new-or-modified-comments/new-or-modified-comments.mjs +104 -0
- package/sources/new-or-modified-files/new-or-modified-files.mjs +66 -0
- package/sources/new-or-modified-folders/new-or-modified-folders.mjs +86 -0
- package/sources/new-shared-drive/new-shared-drive.mjs +68 -0
- package/utils.mjs +247 -0
- package/LICENSE +0 -7
- package/google_drive.app.js +0 -212
- package/sources/changes-to-specific-files/changes-to-specific-files.js +0 -226
- package/sources/new-or-modified-files/new-or-modified-files.js +0 -213
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import googleDrive from "../../google_drive.app.mjs";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Uses Google Drive API to create a permission for a file. The role granted by
|
|
5
|
+
* the permission is one of `owner`,`organizer`,`fileOrganizer`,
|
|
6
|
+
* `writer`,`commenter`, `reader`. See the [Google Drive API Reference for
|
|
7
|
+
* Permissions](https://bit.ly/2XKKG1X) for more information.
|
|
8
|
+
*/
|
|
9
|
+
export default {
|
|
10
|
+
key: "google_drive-add-file-sharing-preference",
|
|
11
|
+
name: "Add File Sharing Preference",
|
|
12
|
+
description:
|
|
13
|
+
"Add a [sharing](https://support.google.com/drive/answer/7166529) permission to the sharing preferences of a file and provide a sharing URL. [See the docs](https://developers.google.com/drive/api/v3/reference/permissions/create) for more information",
|
|
14
|
+
version: "0.0.4",
|
|
15
|
+
type: "action",
|
|
16
|
+
props: {
|
|
17
|
+
googleDrive,
|
|
18
|
+
drive: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
googleDrive,
|
|
21
|
+
"watchedDrive",
|
|
22
|
+
],
|
|
23
|
+
optional: true,
|
|
24
|
+
},
|
|
25
|
+
fileId: {
|
|
26
|
+
propDefinition: [
|
|
27
|
+
googleDrive,
|
|
28
|
+
"fileId",
|
|
29
|
+
(c) => ({
|
|
30
|
+
drive: c.drive,
|
|
31
|
+
}),
|
|
32
|
+
],
|
|
33
|
+
optional: false,
|
|
34
|
+
description: "The file to share",
|
|
35
|
+
},
|
|
36
|
+
role: {
|
|
37
|
+
propDefinition: [
|
|
38
|
+
googleDrive,
|
|
39
|
+
"role",
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
type: {
|
|
43
|
+
propDefinition: [
|
|
44
|
+
googleDrive,
|
|
45
|
+
"type",
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
domain: {
|
|
49
|
+
propDefinition: [
|
|
50
|
+
googleDrive,
|
|
51
|
+
"domain",
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
emailAddress: {
|
|
55
|
+
propDefinition: [
|
|
56
|
+
googleDrive,
|
|
57
|
+
"emailAddress",
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
async run({ $ }) {
|
|
62
|
+
const {
|
|
63
|
+
fileId,
|
|
64
|
+
role,
|
|
65
|
+
type,
|
|
66
|
+
domain,
|
|
67
|
+
emailAddress,
|
|
68
|
+
} = this;
|
|
69
|
+
// Create the permission for the file
|
|
70
|
+
await this.googleDrive.createPermission(fileId, {
|
|
71
|
+
role,
|
|
72
|
+
type,
|
|
73
|
+
domain,
|
|
74
|
+
emailAddress,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// Get the file to get the `webViewLink` sharing URL
|
|
78
|
+
const resp = await this.googleDrive.getFile(this.fileId);
|
|
79
|
+
const webViewLink = resp.webViewLink;
|
|
80
|
+
$.export("$summary", `Successfully added a sharing permission to the file, "${resp.name}"`);
|
|
81
|
+
return webViewLink;
|
|
82
|
+
},
|
|
83
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import googleDrive from "../../google_drive.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "google_drive-copy-file",
|
|
5
|
+
name: "Copy File",
|
|
6
|
+
description: "Create a copy of the specified file. [See the docs](https://developers.google.com/drive/api/v3/reference/files/copy) for more information",
|
|
7
|
+
version: "0.0.3",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
googleDrive,
|
|
11
|
+
drive: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
googleDrive,
|
|
14
|
+
"watchedDrive",
|
|
15
|
+
],
|
|
16
|
+
optional: true,
|
|
17
|
+
},
|
|
18
|
+
fileId: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
googleDrive,
|
|
21
|
+
"fileId",
|
|
22
|
+
(c) => ({
|
|
23
|
+
drive: c.drive,
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
description: "The file to copy",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
async run({ $ }) {
|
|
30
|
+
const resp = await this.googleDrive.copyFile(this.fileId);
|
|
31
|
+
$.export("$summary", `Successfully created a copy of the file, "${resp.name}"`);
|
|
32
|
+
return resp;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import googleDrive from "../../google_drive.app.mjs";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import got from "got";
|
|
4
|
+
import { toSingleLineString } from "../../utils.mjs";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
key: "google_drive-create-file",
|
|
8
|
+
name: "Create a New File",
|
|
9
|
+
description: "Create a new file from a URL or /tmp/filepath. [See the docs](https://developers.google.com/drive/api/v3/reference/files/create) for more information",
|
|
10
|
+
version: "0.0.7",
|
|
11
|
+
type: "action",
|
|
12
|
+
props: {
|
|
13
|
+
googleDrive,
|
|
14
|
+
drive: {
|
|
15
|
+
propDefinition: [
|
|
16
|
+
googleDrive,
|
|
17
|
+
"watchedDrive",
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
parent: {
|
|
21
|
+
propDefinition: [
|
|
22
|
+
googleDrive,
|
|
23
|
+
"folderId",
|
|
24
|
+
(c) => ({
|
|
25
|
+
drive: c.drive,
|
|
26
|
+
}),
|
|
27
|
+
],
|
|
28
|
+
label: "Parent Folder",
|
|
29
|
+
description: toSingleLineString(`
|
|
30
|
+
The ID of the parent folder which contains the file. If not specified, the file will be
|
|
31
|
+
placed directly in the drive's top-level folder.
|
|
32
|
+
`),
|
|
33
|
+
optional: true,
|
|
34
|
+
},
|
|
35
|
+
uploadType: {
|
|
36
|
+
propDefinition: [
|
|
37
|
+
googleDrive,
|
|
38
|
+
"uploadType",
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
fileUrl: {
|
|
42
|
+
propDefinition: [
|
|
43
|
+
googleDrive,
|
|
44
|
+
"fileUrl",
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
filePath: {
|
|
48
|
+
propDefinition: [
|
|
49
|
+
googleDrive,
|
|
50
|
+
"filePath",
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
ignoreDefaultVisibility: {
|
|
54
|
+
type: "boolean",
|
|
55
|
+
label: "Ignore Default Visibility",
|
|
56
|
+
description: toSingleLineString(`
|
|
57
|
+
Whether to ignore the domain's default visibility settings for the created
|
|
58
|
+
file. Domain administrators can choose to make all uploaded files visible to the domain
|
|
59
|
+
by default; this parameter bypasses that behavior for the request. Permissions are still
|
|
60
|
+
inherited from parent folders.
|
|
61
|
+
`),
|
|
62
|
+
default: false,
|
|
63
|
+
},
|
|
64
|
+
includePermissionsForView: {
|
|
65
|
+
type: "string",
|
|
66
|
+
label: "Include Permissions For View",
|
|
67
|
+
description: toSingleLineString(`
|
|
68
|
+
Specifies which additional view's permissions to include in the response. Only
|
|
69
|
+
'published' is supported.
|
|
70
|
+
`),
|
|
71
|
+
optional: true,
|
|
72
|
+
options: [
|
|
73
|
+
"published",
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
keepRevisionForever: {
|
|
77
|
+
propDefinition: [
|
|
78
|
+
googleDrive,
|
|
79
|
+
"keepRevisionForever",
|
|
80
|
+
],
|
|
81
|
+
default: false,
|
|
82
|
+
},
|
|
83
|
+
ocrLanguage: {
|
|
84
|
+
propDefinition: [
|
|
85
|
+
googleDrive,
|
|
86
|
+
"ocrLanguage",
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
useContentAsIndexableText: {
|
|
90
|
+
propDefinition: [
|
|
91
|
+
googleDrive,
|
|
92
|
+
"useContentAsIndexableText",
|
|
93
|
+
],
|
|
94
|
+
default: false,
|
|
95
|
+
},
|
|
96
|
+
supportsAllDrives: {
|
|
97
|
+
type: "boolean",
|
|
98
|
+
label: "Supports All Drives",
|
|
99
|
+
description: toSingleLineString(`
|
|
100
|
+
Whether to include shared drives. Set to 'true' if saving to a shared drive.
|
|
101
|
+
Defaults to 'false' if left blank.
|
|
102
|
+
`),
|
|
103
|
+
optional: true,
|
|
104
|
+
},
|
|
105
|
+
contentHintsIndexableText: {
|
|
106
|
+
type: "string",
|
|
107
|
+
label: "Content Hints Indexable Text",
|
|
108
|
+
description: toSingleLineString(`
|
|
109
|
+
Text to be indexed for the file to improve fullText queries. This is limited to 128KB in
|
|
110
|
+
length and may contain HTML elements.
|
|
111
|
+
`),
|
|
112
|
+
optional: true,
|
|
113
|
+
},
|
|
114
|
+
contentRestrictionsReadOnly: {
|
|
115
|
+
type: "boolean",
|
|
116
|
+
label: "Content Restrictions Read Only",
|
|
117
|
+
description: toSingleLineString(`
|
|
118
|
+
Whether the content of the file is read-only. If a file is read-only, a new revision of
|
|
119
|
+
the file may not be added, comments may not be added or modified, and the title of the file
|
|
120
|
+
may not be modified.
|
|
121
|
+
`),
|
|
122
|
+
optional: true,
|
|
123
|
+
},
|
|
124
|
+
contentRestrictionsReason: {
|
|
125
|
+
type: "string",
|
|
126
|
+
label: "Content Restrictions Reason",
|
|
127
|
+
description: toSingleLineString(`
|
|
128
|
+
Reason for why the content of the file is restricted. This is only mutable on requests
|
|
129
|
+
that also set readOnly=true.
|
|
130
|
+
`),
|
|
131
|
+
optional: true,
|
|
132
|
+
},
|
|
133
|
+
copyRequiresWriterPermission: {
|
|
134
|
+
type: "boolean",
|
|
135
|
+
label: "Copy Requires Writer Permission",
|
|
136
|
+
description: toSingleLineString(`
|
|
137
|
+
Whether the options to copy, print, or download this file, should be disabled for
|
|
138
|
+
readers and commenters
|
|
139
|
+
`),
|
|
140
|
+
optional: true,
|
|
141
|
+
},
|
|
142
|
+
description: {
|
|
143
|
+
type: "string",
|
|
144
|
+
label: "Description",
|
|
145
|
+
description: "A short description of the file",
|
|
146
|
+
optional: true,
|
|
147
|
+
},
|
|
148
|
+
folderColorRgb: {
|
|
149
|
+
type: "string",
|
|
150
|
+
label: "Folder Color RGB",
|
|
151
|
+
description: toSingleLineString(`
|
|
152
|
+
The color for a folder as an RGB hex string. If an unsupported color is specified,
|
|
153
|
+
the closest color in the palette will be used instead.
|
|
154
|
+
`),
|
|
155
|
+
optional: true,
|
|
156
|
+
},
|
|
157
|
+
mimeType: {
|
|
158
|
+
propDefinition: [
|
|
159
|
+
googleDrive,
|
|
160
|
+
"mimeType",
|
|
161
|
+
],
|
|
162
|
+
},
|
|
163
|
+
name: {
|
|
164
|
+
propDefinition: [
|
|
165
|
+
googleDrive,
|
|
166
|
+
"fileName",
|
|
167
|
+
],
|
|
168
|
+
description: "Name of the file",
|
|
169
|
+
},
|
|
170
|
+
originalFilename: {
|
|
171
|
+
type: "string",
|
|
172
|
+
label: "Original Filename",
|
|
173
|
+
description:
|
|
174
|
+
"The original filename of the uploaded content if available, or else the original value of the name field. This is only available for files with binary content in Google Drive.",
|
|
175
|
+
optional: true,
|
|
176
|
+
},
|
|
177
|
+
shortcutDetailsTargetId: {
|
|
178
|
+
type: "string",
|
|
179
|
+
label: "Shortcut Details Target ID",
|
|
180
|
+
description: "The ID of the file that this shortcut points to",
|
|
181
|
+
optional: true,
|
|
182
|
+
},
|
|
183
|
+
starred: {
|
|
184
|
+
type: "boolean",
|
|
185
|
+
label: "Starred",
|
|
186
|
+
description: "Whether the user has starred the file",
|
|
187
|
+
optional: true,
|
|
188
|
+
},
|
|
189
|
+
writersCanShare: {
|
|
190
|
+
type: "boolean",
|
|
191
|
+
label: "Writers Can Share",
|
|
192
|
+
description:
|
|
193
|
+
"Whether users with only writer permission can modify the file's permissions. Not populated for items in shared drives.",
|
|
194
|
+
optional: true,
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
async run({ $ }) {
|
|
198
|
+
const body = this.fileUrl
|
|
199
|
+
? await got.stream(this.fileUrl)
|
|
200
|
+
: fs.createReadStream(this.filePath);
|
|
201
|
+
const driveId = this.googleDrive.getDriveId(this.drive);
|
|
202
|
+
const resp = await this.googleDrive.createFile({
|
|
203
|
+
ignoreDefaultVisibility: this.ignoreDefaultVisibility,
|
|
204
|
+
includePermissionsForView: this.includePermissionsForView,
|
|
205
|
+
keepRevisionForever: this.keepRevisionForever,
|
|
206
|
+
ocrLanguage: this.ocrLanguage,
|
|
207
|
+
useContentAsIndexableText: this.useContentAsIndexableText,
|
|
208
|
+
supportsAllDrives: this.supportsAllDrives,
|
|
209
|
+
resource: {
|
|
210
|
+
name: this.name,
|
|
211
|
+
originalFilename: this.originalFilename,
|
|
212
|
+
parents: [
|
|
213
|
+
this.parent ?? driveId,
|
|
214
|
+
],
|
|
215
|
+
mimeType: this.mimeType,
|
|
216
|
+
description: this.description,
|
|
217
|
+
folderColorRgb: this.folderColorRgb,
|
|
218
|
+
shortcutDetails: {
|
|
219
|
+
targetId: this.shortcutDetailsTargetId,
|
|
220
|
+
},
|
|
221
|
+
starred: this.starred,
|
|
222
|
+
writersCanShare: this.writersCanShare,
|
|
223
|
+
contentHints: {
|
|
224
|
+
indexableText: this.contentHintsIndexableText,
|
|
225
|
+
},
|
|
226
|
+
contentRestrictions: {
|
|
227
|
+
readOnly: this.contentRestrictionsReadOnly,
|
|
228
|
+
reason: this.contentRestrictionsReason,
|
|
229
|
+
},
|
|
230
|
+
copyRequiresWriterPermission: this.copyRequiresWriterPermission,
|
|
231
|
+
},
|
|
232
|
+
media: {
|
|
233
|
+
mimeType: this.mimeType,
|
|
234
|
+
uploadType: this.uploadType,
|
|
235
|
+
body,
|
|
236
|
+
},
|
|
237
|
+
fields: "*",
|
|
238
|
+
});
|
|
239
|
+
$.export("$summary", `Successfully created a new file, "${resp.name}"`);
|
|
240
|
+
return resp;
|
|
241
|
+
},
|
|
242
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import googleDrive from "../../google_drive.app.mjs";
|
|
2
|
+
import Mustaches from "google-docs-mustaches";
|
|
3
|
+
|
|
4
|
+
const MODE_GOOGLE_DOC = "Google Doc";
|
|
5
|
+
const MODE_PDF = "Pdf";
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
key: "google_drive-create-file-from-template",
|
|
9
|
+
name: "Create New File From Template",
|
|
10
|
+
description: "Create a new google doc file from template. [See documentation](https://www.npmjs.com/package/google-docs-mustaches)",
|
|
11
|
+
version: "0.0.2",
|
|
12
|
+
type: "action",
|
|
13
|
+
props: {
|
|
14
|
+
googleDrive,
|
|
15
|
+
templateId: {
|
|
16
|
+
propDefinition: [
|
|
17
|
+
googleDrive,
|
|
18
|
+
"fileId",
|
|
19
|
+
],
|
|
20
|
+
description:
|
|
21
|
+
"Id of the file you want to use as a template.",
|
|
22
|
+
},
|
|
23
|
+
folderId: {
|
|
24
|
+
propDefinition: [
|
|
25
|
+
googleDrive,
|
|
26
|
+
"folderId",
|
|
27
|
+
],
|
|
28
|
+
description:
|
|
29
|
+
"Folder id of the newly created google doc and pdf.",
|
|
30
|
+
},
|
|
31
|
+
name: {
|
|
32
|
+
propDefinition: [
|
|
33
|
+
googleDrive,
|
|
34
|
+
"fileName",
|
|
35
|
+
],
|
|
36
|
+
description:
|
|
37
|
+
"Name of the file you want to create (eg. `myFile` will create a google doc called `myFile` and a pdf called `myFile.pdf`)",
|
|
38
|
+
optional: false,
|
|
39
|
+
},
|
|
40
|
+
mode: {
|
|
41
|
+
type: "string[]",
|
|
42
|
+
label: "Mode",
|
|
43
|
+
description: "Select if you want to create the google doc, the pdf or both files.",
|
|
44
|
+
options: [
|
|
45
|
+
MODE_GOOGLE_DOC,
|
|
46
|
+
MODE_PDF,
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
replaceValues: {
|
|
50
|
+
type: "object",
|
|
51
|
+
label: "Replace values",
|
|
52
|
+
description: "Substrings to replace in the document. (eg. `{{ key }}` in the document will be replace by the value.",
|
|
53
|
+
optional: true,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
async run({ $ }) {
|
|
57
|
+
const result = {
|
|
58
|
+
folderId: this.folderId,
|
|
59
|
+
name: this.name,
|
|
60
|
+
mode: this.mode,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const client = new Mustaches.default({
|
|
64
|
+
token: () => this.googleDrive.$auth.oauth_access_token,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
/* CREATE THE GOOGLE DOC */
|
|
68
|
+
|
|
69
|
+
const googleDocId = await client.interpolate({
|
|
70
|
+
source: this.templateId,
|
|
71
|
+
destination: this.folderId,
|
|
72
|
+
name: this.name,
|
|
73
|
+
data: this.replaceValues,
|
|
74
|
+
});
|
|
75
|
+
result["googleDocId"] = googleDocId;
|
|
76
|
+
|
|
77
|
+
/* CREATE THE PDF */
|
|
78
|
+
|
|
79
|
+
if (this.mode.includes(MODE_PDF)) {
|
|
80
|
+
const pdfId = await client.export({
|
|
81
|
+
file: googleDocId,
|
|
82
|
+
mimeType: "application/pdf",
|
|
83
|
+
name: this.name,
|
|
84
|
+
destination: this.folderId,
|
|
85
|
+
});
|
|
86
|
+
result["pdfId"] = pdfId;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* REMOVE THE GOOGLE DOC */
|
|
90
|
+
|
|
91
|
+
if (!this.mode.includes(MODE_GOOGLE_DOC)) {
|
|
92
|
+
await this.googleDrive.deleteFile(googleDocId);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
$.export("$summary", "New file successfully created");
|
|
96
|
+
return result;
|
|
97
|
+
},
|
|
98
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import googleDrive from "../../google_drive.app.mjs";
|
|
2
|
+
import { Readable } from "stream";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "google_drive-create-file-from-text",
|
|
6
|
+
name: "Create New File From Text",
|
|
7
|
+
description: "Create a new file from plain text. [See the docs](https://developers.google.com/drive/api/v3/reference/files/create) for more information",
|
|
8
|
+
version: "0.0.4",
|
|
9
|
+
type: "action",
|
|
10
|
+
props: {
|
|
11
|
+
googleDrive,
|
|
12
|
+
drive: {
|
|
13
|
+
propDefinition: [
|
|
14
|
+
googleDrive,
|
|
15
|
+
"watchedDrive",
|
|
16
|
+
],
|
|
17
|
+
optional: true,
|
|
18
|
+
},
|
|
19
|
+
parentId: {
|
|
20
|
+
propDefinition: [
|
|
21
|
+
googleDrive,
|
|
22
|
+
"folderId",
|
|
23
|
+
(c) => ({
|
|
24
|
+
drive: c.drive,
|
|
25
|
+
}),
|
|
26
|
+
],
|
|
27
|
+
description:
|
|
28
|
+
"The folder you want to add the file to. If not specified, the file will be placed directly in the drive's top-level folder.",
|
|
29
|
+
optional: true,
|
|
30
|
+
},
|
|
31
|
+
name: {
|
|
32
|
+
propDefinition: [
|
|
33
|
+
googleDrive,
|
|
34
|
+
"fileName",
|
|
35
|
+
],
|
|
36
|
+
description:
|
|
37
|
+
"The name of the file you want to create (e.g., `myFile.txt`)",
|
|
38
|
+
},
|
|
39
|
+
content: {
|
|
40
|
+
type: "string",
|
|
41
|
+
label: "Content",
|
|
42
|
+
description: "Enter text to create the file with.",
|
|
43
|
+
optional: true,
|
|
44
|
+
default: "",
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
async run({ $ }) {
|
|
48
|
+
const {
|
|
49
|
+
parentId,
|
|
50
|
+
name,
|
|
51
|
+
content,
|
|
52
|
+
} = this;
|
|
53
|
+
const file = Readable.from([
|
|
54
|
+
content,
|
|
55
|
+
]);
|
|
56
|
+
const driveId = this.googleDrive.getDriveId(this.drive);
|
|
57
|
+
const resp = await this.googleDrive.createFile({
|
|
58
|
+
mimeType: "text/plain",
|
|
59
|
+
file,
|
|
60
|
+
name,
|
|
61
|
+
parentId,
|
|
62
|
+
driveId,
|
|
63
|
+
});
|
|
64
|
+
$.export("$summary", `Successfully created a new file, "${resp.name}"`);
|
|
65
|
+
return resp;
|
|
66
|
+
},
|
|
67
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import googleDrive from "../../google_drive.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "google_drive-create-folder",
|
|
5
|
+
name: "Create Folder",
|
|
6
|
+
description: "Create a new empty folder. [See the docs](https://developers.google.com/drive/api/v3/reference/files/create) for more information",
|
|
7
|
+
version: "0.0.4",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
googleDrive,
|
|
11
|
+
drive: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
googleDrive,
|
|
14
|
+
"watchedDrive",
|
|
15
|
+
],
|
|
16
|
+
optional: true,
|
|
17
|
+
},
|
|
18
|
+
parentId: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
googleDrive,
|
|
21
|
+
"folderId",
|
|
22
|
+
(c) => ({
|
|
23
|
+
drive: c.drive,
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
description:
|
|
27
|
+
"Select a folder in which to place the new folder. If not specified, the folder will be placed directly in the drive's top-level folder.",
|
|
28
|
+
optional: true,
|
|
29
|
+
},
|
|
30
|
+
name: {
|
|
31
|
+
propDefinition: [
|
|
32
|
+
googleDrive,
|
|
33
|
+
"fileName",
|
|
34
|
+
],
|
|
35
|
+
label: "Name",
|
|
36
|
+
description: "The name of the new folder",
|
|
37
|
+
optional: true,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
async run({ $ }) {
|
|
41
|
+
const {
|
|
42
|
+
parentId,
|
|
43
|
+
name,
|
|
44
|
+
} = this;
|
|
45
|
+
const driveId = this.googleDrive.getDriveId(this.drive);
|
|
46
|
+
const resp = await this.googleDrive.createFolder({
|
|
47
|
+
name,
|
|
48
|
+
parentId,
|
|
49
|
+
driveId,
|
|
50
|
+
});
|
|
51
|
+
$.export("$summary", `Successfully created a new folder, "${resp.name}"`);
|
|
52
|
+
return resp;
|
|
53
|
+
},
|
|
54
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import googleDrive from "../../google_drive.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "google_drive-create-shared-drive",
|
|
5
|
+
name: "Create Shared Drive",
|
|
6
|
+
description: "Create a new shared drive. [See the docs](https://developers.google.com/drive/api/v3/reference/drives/create) for more information",
|
|
7
|
+
version: "0.0.3",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
googleDrive,
|
|
11
|
+
name: {
|
|
12
|
+
type: "string",
|
|
13
|
+
label: "Name",
|
|
14
|
+
description: "The name of the new shared drive",
|
|
15
|
+
optional: true,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
async run({ $ }) {
|
|
19
|
+
const resp = await this.googleDrive.createDrive({
|
|
20
|
+
name: this.name,
|
|
21
|
+
});
|
|
22
|
+
$.export("$summary", `Successfully created a new shared drive, "${resp.name}"`);
|
|
23
|
+
return resp;
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import googleDrive from "../../google_drive.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "google_drive-delete-file",
|
|
5
|
+
name: "Delete File",
|
|
6
|
+
description:
|
|
7
|
+
"Permanently delete a file or folder without moving it to the trash. [See the docs](https://developers.google.com/drive/api/v3/reference/files/delete) for more information",
|
|
8
|
+
version: "0.0.4",
|
|
9
|
+
type: "action",
|
|
10
|
+
props: {
|
|
11
|
+
googleDrive,
|
|
12
|
+
drive: {
|
|
13
|
+
propDefinition: [
|
|
14
|
+
googleDrive,
|
|
15
|
+
"watchedDrive",
|
|
16
|
+
],
|
|
17
|
+
optional: true,
|
|
18
|
+
},
|
|
19
|
+
fileId: {
|
|
20
|
+
propDefinition: [
|
|
21
|
+
googleDrive,
|
|
22
|
+
"fileOrFolderId",
|
|
23
|
+
(c) => ({
|
|
24
|
+
drive: c.drive,
|
|
25
|
+
}),
|
|
26
|
+
],
|
|
27
|
+
description: "The file or folder to delete",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
async run({ $ }) {
|
|
31
|
+
await this.googleDrive.deleteFile(this.fileId);
|
|
32
|
+
$.export("$summary", "Successfully deleted the file");
|
|
33
|
+
return {
|
|
34
|
+
success: true,
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import googleDrive from "../../google_drive.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "google_drive-delete-shared-drive",
|
|
5
|
+
name: "Delete Shared Drive",
|
|
6
|
+
description: "Delete a shared drive without any content. [See the docs](https://developers.google.com/drive/api/v3/reference/drives/delete) for more information",
|
|
7
|
+
version: "0.0.3",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
googleDrive,
|
|
11
|
+
drive: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
googleDrive,
|
|
14
|
+
"watchedDrive",
|
|
15
|
+
],
|
|
16
|
+
description:
|
|
17
|
+
"Select a [shared drive](https://support.google.com/a/users/answer/9310351) to delete.",
|
|
18
|
+
default: "",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
async run({ $ }) {
|
|
22
|
+
await this.googleDrive.deleteSharedDrive(
|
|
23
|
+
this.googleDrive.getDriveId(this.drive),
|
|
24
|
+
);
|
|
25
|
+
$.export("$summary", "Successfully deleted the shared drive");
|
|
26
|
+
return {
|
|
27
|
+
success: true,
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
};
|