Skip to content

Commit 4b3cb2a

Browse files
committed
updates
1 parent 19cb266 commit 4b3cb2a

File tree

4 files changed

+820
-34
lines changed

4 files changed

+820
-34
lines changed

components/google_drive/actions/create-file/create-file.js

Lines changed: 52 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
const googleDrive = require("../../google_drive.app");
22
const fs = require("fs");
33
const got = require("got");
4+
const isoLanguages = require("../language-codes.js");
5+
const googleMimeTypes = require("../google-mime-types.js");
6+
const mimeDb = require("mime-db");
7+
const mimeTypes = Object.keys(mimeDb);
48

59
module.exports = {
610
key: "google_drive-create-file",
@@ -16,11 +20,12 @@ module.exports = {
1620
"watchedDrive",
1721
],
1822
},
19-
parents: {
23+
parent: {
2024
type: "string",
2125
label: "Parent Folder",
2226
description:
23-
"The ID of the parent folder which contain the file. If not specified as part of a create request, the file will be placed directly in the user's My Drive folder.",
27+
`The ID of the parent folder which contains the file. If not specified as part of a
28+
create request, the file will be placed directly in the user's My Drive folder.`,
2429
optional: true,
2530
async options({ prevContext }) {
2631
const { nextPageToken } = prevContext;
@@ -41,31 +46,25 @@ module.exports = {
4146
uploadType: {
4247
type: "string",
4348
label: "Upload Type",
44-
description: `The type of upload request to the /upload URI. If you are uploading data (using an /upload URI), this field is required. If you are creating a metadata-only file, this field is not required.
49+
description: `The type of upload request to the /upload URI. If you are uploading data
50+
(using an /upload URI), this field is required. If you are creating a metadata-only file,
51+
this field is not required.
4552
media - Simple upload. Upload the media only, without any metadata.
4653
multipart - Multipart upload. Upload both the media and its metadata, in a single request.
47-
resumable - Resumable upload. Upload the file in a resumable fashion, using a series of at least two requests where the first request includes the metadata.
48-
`,
54+
resumable - Resumable upload. Upload the file in a resumable fashion, using a series of
55+
at least two requests where the first request includes the metadata.`,
4956
options: [
50-
{
51-
label: "Media (upload the media only, without any metadata)",
52-
value: "media",
53-
},
54-
{
55-
label: "Multipart (upload both the media and its metadata, in a single request)",
56-
value: "multipart",
57-
},
58-
{
59-
label: "Resumable (Upload the file in a resumable fashion, using a series of requests)",
60-
value: "resumable",
61-
},
57+
"media",
58+
"multipart",
59+
"resumable",
6260
],
6361
},
6462
fileUrl: {
6563
type: "string",
6664
label: "File URL",
6765
description:
68-
"The URL of the file you want to upload to Google Drive. Must specify either File URL or File Path.",
66+
`The URL of the file you want to upload to Google Drive. Must specify either File URL
67+
or File Path.`,
6968
optional: true,
7069
},
7170
filePath: {
@@ -78,14 +77,18 @@ module.exports = {
7877
ignoreDefaultVisibility: {
7978
type: "boolean",
8079
label: "Ignore Default Visibility",
81-
description: "Whether to ignore the domain's default visibility settings for the created file. Domain administrators can choose to make all uploaded files visible to the domain by default; this parameter bypasses that behavior for the request. Permissions are still inherited from parent folders.",
80+
description: `Whether to ignore the domain's default visibility settings for the created
81+
file. Domain administrators can choose to make all uploaded files visible to the domain
82+
by default; this parameter bypasses that behavior for the request. Permissions are still
83+
inherited from parent folders.`,
8284
default: false,
8385
},
8486
includePermissionsForView: {
8587
type: "string",
8688
label: "Include Permissions For View",
8789
description:
88-
"Specifies which additional view's permissions to include in the response. Only 'published' is supported.",
90+
`Specifies which additional view's permissions to include in the response. Only
91+
'published' is supported.`,
8992
optional: true,
9093
options: [
9194
"published",
@@ -95,7 +98,9 @@ module.exports = {
9598
type: "boolean",
9699
label: "Keep Revision Forever",
97100
description:
98-
"Whether to set the 'keepForever' field in the new head revision. This is only applicable to files with binary content in Google Drive. Only 200 revisions for the file can be kept forever. If the limit is reached, try deleting pinned revisions.",
101+
`Whether to set the 'keepForever' field in the new head revision. This is only applicable
102+
to files with binary content in Google Drive. Only 200 revisions for the file can be kept
103+
forever. If the limit is reached, try deleting pinned revisions.`,
99104
default: false,
100105
},
101106
ocrLanguage: {
@@ -104,6 +109,7 @@ module.exports = {
104109
description:
105110
"A language hint for OCR processing during image import (ISO 639-1 code).",
106111
optional: true,
112+
options: isoLanguages,
107113
},
108114
useContentAsIndexableText: {
109115
type: "boolean",
@@ -116,35 +122,41 @@ module.exports = {
116122
type: "boolean",
117123
label: "Supports All Drives",
118124
description:
119-
"Whether to include shared drives. Set to 'true' if saving to a shared drive. Defaults to 'false' if left blank.",
125+
`Whether to include shared drives. Set to 'true' if saving to a shared drive.
126+
Defaults to 'false' if left blank.`,
120127
optional: true,
121128
},
122129
contentHintsIndexableText: {
123130
type: "string",
124131
label: "Content Hints Indexable Text",
125132
description:
126-
"Text to be indexed for the file to improve fullText queries. This is limited to 128KB in length and may contain HTML elements.",
133+
`Text to be indexed for the file to improve fullText queries. This is limited to 128KB in
134+
length and may contain HTML elements.`,
127135
optional: true,
128136
},
129137
contentRestrictionsReadOnly: {
130138
type: "boolean",
131139
label: "Content Restrictions Read Only",
132140
description:
133-
"Whether the content of the file is read-only. If a file is read-only, a new revision of the file may not be added, comments may not be added or modified, and the title of the file may not be modified.",
141+
`Whether the content of the file is read-only. If a file is read-only, a new revision of
142+
the file may not be added, comments may not be added or modified, and the title of the file
143+
may not be modified.`,
134144
optional: true,
135145
},
136146
contentRestrictionsReason: {
137147
type: "string",
138148
label: "Content Restrictions Reason",
139149
description:
140-
"Reason for why the content of the file is restricted. This is only mutable on requests that also set readOnly=true.",
150+
`Reason for why the content of the file is restricted. This is only mutable on requests
151+
that also set readOnly=true.`,
141152
optional: true,
142153
},
143154
copyRequiresWriterPermission: {
144155
type: "boolean",
145156
label: "Copy Requires Writer Permission",
146157
description:
147-
"Whether the options to copy, print, or download this file, should be disabled for readers and commenters.",
158+
`Whether the options to copy, print, or download this file, should be disabled for
159+
readers and commenters.`,
148160
optional: true,
149161
},
150162
description: {
@@ -157,16 +169,25 @@ module.exports = {
157169
type: "string",
158170
label: "Folder Color RGB",
159171
description:
160-
"The color for a folder as an RGB hex string. If an unsupported color is specified, the closest color in the palette will be used instead.",
172+
`The color for a folder as an RGB hex string. If an unsupported color is specified,
173+
the closest color in the palette will be used instead.`,
161174
optional: true,
162175
},
163176
mimeType: {
164177
type: "string",
165178
label: "Mime Type",
166-
description: `The MIME type of the file. Google Drive will attempt to automatically detect an appropriate value from uploaded content if no value is provided. The value cannot be changed unless a new revision is uploaded. If a file is created with a Google Doc MIME type, the uploaded content will be imported if possible.
167-
Google Workspace and Drive MIME Types: https://developers.google.com/drive/api/v3/mime-types
168-
`,
179+
description: `The MIME type of the file. Google Drive will attempt to automatically detect
180+
an appropriate value from uploaded content if no value is provided. The value cannot be
181+
changed unless a new revision is uploaded. If a file is created with a Google Doc MIME
182+
type, the uploaded content will be imported if possible. Google Workspace and Drive
183+
MIME Types: https://developers.google.com/drive/api/v3/mime-types`,
169184
optional: true,
185+
async options({ page = 0 }) {
186+
const allTypes = googleMimeTypes.concat(mimeTypes);
187+
const start = (page - 1) * 10;
188+
const end = start + 10;
189+
return allTypes.slice(start, end);
190+
},
170191
},
171192
name: {
172193
type: "string",
@@ -217,7 +238,7 @@ module.exports = {
217238
name: this.name,
218239
originalFilename: this.originalFilename,
219240
parents: [
220-
this.parents,
241+
this.parent,
221242
],
222243
mimeType: this.mimeType,
223244
description: this.description,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module.exports = [
2+
"application/vnd.google-apps.audio",
3+
"application/vnd.google-apps.document",
4+
"application/vnd.google-apps.drive-sdk",
5+
"application/vnd.google-apps.drawing",
6+
"application/vnd.google-apps.file",
7+
"application/vnd.google-apps.folder",
8+
"application/vnd.google-apps.form",
9+
"application/vnd.google-apps.fusiontable",
10+
"application/vnd.google-apps.map",
11+
"application/vnd.google-apps.photo",
12+
"application/vnd.google-apps.presentation",
13+
"application/vnd.google-apps.script",
14+
"application/vnd.google-apps.shortcut",
15+
"application/vnd.google-apps.site",
16+
"application/vnd.google-apps.spreadsheet",
17+
"application/vnd.google-apps.unknown",
18+
"application/vnd.google-apps.video",
19+
];

0 commit comments

Comments
 (0)