@pipedream/google_drive 0.8.9 → 0.8.10

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.
@@ -3,19 +3,36 @@ import {
3
3
  toSingleLineString,
4
4
  getFileStream,
5
5
  } from "../../common/utils.mjs";
6
+ import { additionalProps } from "../../common/filePathOrUrl.mjs";
6
7
 
7
8
  export default {
8
9
  key: "google_drive-update-file",
9
10
  name: "Update File",
10
11
  description: "Update a file's metadata and/or content. [See the documentation](https://developers.google.com/drive/api/v3/reference/files/update) for more information",
11
- version: "0.1.7",
12
+ version: "1.0.0",
12
13
  type: "action",
14
+ additionalProps,
13
15
  props: {
14
16
  googleDrive,
15
- requiredPropsAlert: {
16
- type: "alert",
17
- alertType: "info",
18
- content: "Either `File URL` and `File Path` should be specified.",
17
+ updateType: {
18
+ type: "string",
19
+ label: "Update Type",
20
+ description: "Whether to update content or metadata only",
21
+ options: [
22
+ {
23
+ label: "Upload content from File URL",
24
+ value: "File URL",
25
+ },
26
+ {
27
+ label: "Upload content from File Path",
28
+ value: "File Path",
29
+ },
30
+ {
31
+ label: "Update file metadata only",
32
+ value: "File Metadata",
33
+ },
34
+ ],
35
+ reloadProps: true,
19
36
  },
20
37
  drive: {
21
38
  propDefinition: [
@@ -40,6 +57,8 @@ export default {
40
57
  "fileUrl",
41
58
  ],
42
59
  description: "The URL of the file to use to update content",
60
+ optional: false,
61
+ hidden: true,
43
62
  },
44
63
  filePath: {
45
64
  propDefinition: [
@@ -51,6 +70,8 @@ export default {
51
70
  directory](https://pipedream.com/docs/workflows/steps/code/nodejs/working-with-files/#the-tmp-directory)
52
71
  (e.g., \`/tmp/myFile.csv\`) with which to update content
53
72
  `),
73
+ optional: false,
74
+ hidden: true,
54
75
  },
55
76
  name: {
56
77
  propDefinition: [
@@ -128,16 +149,21 @@ export default {
128
149
  ocrLanguage,
129
150
  useContentAsIndexableText,
130
151
  advanced,
152
+ updateType,
131
153
  } = this;
132
154
 
133
- const fileStream =
134
- fileUrl || filePath
135
- ? await getFileStream({
136
- $,
137
- fileUrl,
138
- filePath,
139
- })
140
- : undefined;
155
+ let fileStream;
156
+ if (updateType === "File URL") {
157
+ fileStream = await getFileStream({
158
+ $,
159
+ fileUrl,
160
+ });
161
+ } else if (updateType === "File Path") {
162
+ fileStream = await getFileStream({
163
+ $,
164
+ filePath,
165
+ });
166
+ }
141
167
 
142
168
  // Update file content, if set, separately from metadata to prevent
143
169
  // multipart upload, which `google-apis-nodejs-client` doesn't seem to
@@ -5,21 +5,20 @@ import {
5
5
  omitEmptyStringValues,
6
6
  } from "../../common/utils.mjs";
7
7
  import { GOOGLE_DRIVE_UPLOAD_TYPE_MULTIPART } from "../../common/constants.mjs";
8
- import { ConfigurationError } from "@pipedream/platform";
8
+ import {
9
+ additionalProps, updateType,
10
+ } from "../../common/filePathOrUrl.mjs";
9
11
 
10
12
  export default {
11
13
  key: "google_drive-upload-file",
12
14
  name: "Upload File",
13
15
  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.10",
16
+ version: "1.0.0",
15
17
  type: "action",
18
+ additionalProps,
16
19
  props: {
17
20
  googleDrive,
18
- infoAlert: {
19
- type: "alert",
20
- alertType: "info",
21
- content: "Either `File URL` and `File Path` should be specified.",
22
- },
21
+ updateType,
23
22
  drive: {
24
23
  propDefinition: [
25
24
  googleDrive,
@@ -44,12 +43,16 @@ export default {
44
43
  googleDrive,
45
44
  "fileUrl",
46
45
  ],
46
+ optional: false,
47
+ hidden: true,
47
48
  },
48
49
  filePath: {
49
50
  propDefinition: [
50
51
  googleDrive,
51
52
  "filePath",
52
53
  ],
54
+ optional: false,
55
+ hidden: true,
53
56
  },
54
57
  name: {
55
58
  propDefinition: [
@@ -94,9 +97,6 @@ export default {
94
97
  mimeType,
95
98
  } = this;
96
99
  let { uploadType } = this;
97
- if (!fileUrl && !filePath) {
98
- throw new ConfigurationError("Either `File URL` and `File Path` should be specified.");
99
- }
100
100
  const driveId = this.googleDrive.getDriveId(this.drive);
101
101
 
102
102
  const filename = name || path.basename(fileUrl || filePath);
@@ -0,0 +1,27 @@
1
+ export const updateType = {
2
+ type: "string",
3
+ label: "Use File URL or File Path",
4
+ description: "Whether to upload a file from a URL or from the `/tmp` folder",
5
+ options: [
6
+ "File URL",
7
+ "File Path",
8
+ ],
9
+ reloadProps: true,
10
+ };
11
+
12
+ export async function additionalProps(previousProps) {
13
+ const { updateType } = this;
14
+
15
+ if (updateType === "File URL") {
16
+ previousProps.fileUrl.hidden = false;
17
+ previousProps.filePath.hidden = true;
18
+ } else if (updateType === "File Path") {
19
+ previousProps.fileUrl.hidden = true;
20
+ previousProps.filePath.hidden = false;
21
+ } else {
22
+ previousProps.fileUrl.hidden = true;
23
+ previousProps.filePath.hidden = true;
24
+ }
25
+
26
+ return {};
27
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/google_drive",
3
- "version": "0.8.9",
3
+ "version": "0.8.10",
4
4
  "description": "Pipedream Google_drive Components",
5
5
  "main": "google_drive.app.mjs",
6
6
  "keywords": [