@pipedream/google_drive 0.4.2 → 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.
package/README.md ADDED
@@ -0,0 +1,10 @@
1
+ # Overview
2
+
3
+ Using the Google Drive API, you can build applications that:
4
+
5
+ - Create and manage files and folders
6
+ - Download and upload files
7
+ - Share and organize files
8
+ - Search for files
9
+ - Track changes to files
10
+ - And much more!
@@ -7,7 +7,7 @@ export default {
7
7
  key: "google_drive-create-file",
8
8
  name: "Create a New File",
9
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",
10
+ version: "0.0.8",
11
11
  type: "action",
12
12
  props: {
13
13
  googleDrive,
@@ -135,7 +135,7 @@ export default {
135
135
  label: "Copy Requires Writer Permission",
136
136
  description: toSingleLineString(`
137
137
  Whether the options to copy, print, or download this file, should be disabled for
138
- readers and commenters
138
+ readers and commentators
139
139
  `),
140
140
  optional: true,
141
141
  },
@@ -4,13 +4,16 @@ import {
4
4
  toSingleLineString,
5
5
  } from "../../utils.mjs";
6
6
 
7
- import { GOOGLE_DRIVE_FOLDER_MIME_TYPE } from "../../constants.mjs";
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.5",
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
- "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.",
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
- createIfExists: {
50
+ createIfUnique: {
46
51
  type: "boolean",
47
- label: "Create If Exists?",
52
+ label: "Create Only If Filename Is Unique?",
48
53
  description: toSingleLineString(`
49
- If the folder already exists and is not in the trash, should we create it? This option defaults to 'true' for
50
- backwards compatability 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: true,
58
+ default: false,
54
59
  },
55
60
  },
56
61
  async run({ $ }) {
57
62
  const {
63
+ drive,
58
64
  parentId,
59
65
  name,
60
- createIfExists,
66
+ createIfUnique,
61
67
  } = this;
62
- let folder;
63
- if (createIfExists == false) {//checking "false" because if this optional prop may not be given
64
- const folders = (await this.googleDrive.listFilesInPage(null, getListFilesOpts(this.drive, {
65
- q: `mimeType = '${GOOGLE_DRIVE_FOLDER_MIME_TYPE}' and name contains '${name}' and trashed=false`.trim(),
66
- }))).files;
67
- for (let f of folders) {
68
- if (f.name == name) {
69
- folder = f;
70
- break;
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
- if (folder) {
74
- $.export("$summary", "Found existing folder, therefore not creating folder. Returning found folder.");
75
- const folderDetails = await this.googleDrive.getFile(folder.id);
80
+ const folders = (await this.googleDrive.listFilesInPage(null, getListFilesOpts(drive, {
81
+ q,
82
+ }))).files;
76
83
 
77
- return folderDetails;
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
- const driveId = this.googleDrive.getDriveId(this.drive);
89
+
81
90
  const resp = await this.googleDrive.createFolder({
82
91
  name,
83
92
  parentId,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "google_drive-update-shared-drive",
5
5
  name: "Update Shared Drive",
6
6
  description: "Update an existing shared drive. [See the docs](https://developers.google.com/drive/api/v3/reference/drives/update) for more information",
7
- version: "0.0.3",
7
+ version: "0.0.4",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -27,7 +27,7 @@ export default {
27
27
  type: "string",
28
28
  label: "Background Image Link",
29
29
  description:
30
- "A link to the new backround image for the shared drive. Cannot be set if `Theme ID` is set in the same request.",
30
+ "A link to the new background image for the shared drive. Cannot be set if `Theme ID` is set in the same request.",
31
31
  optional: true,
32
32
  },
33
33
  colorRgb: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/google_drive",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Pipedream Google_drive Components",
5
5
  "main": "google_drive.app.mjs",
6
6
  "keywords": [