@activepieces/piece-google-drive 0.5.5 → 0.5.7

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/package.json CHANGED
@@ -1,19 +1,21 @@
1
1
  {
2
2
  "name": "@activepieces/piece-google-drive",
3
- "version": "0.5.5",
3
+ "version": "0.5.7",
4
4
  "dependencies": {
5
5
  "@sinclair/typebox": "0.26.8",
6
- "axios": "^1.6.0",
6
+ "axios": "^1.6.3",
7
7
  "dayjs": "1.11.9",
8
8
  "form-data": "4.0.0",
9
+ "googleapis": "129.0.0",
10
+ "googleapis-common": "7.0.1",
9
11
  "is-base64": "1.1.0",
10
12
  "lodash": "4.17.21",
11
13
  "mime-types": "2.1.35",
12
14
  "nanoid": "3.3.6",
13
15
  "semver": "7.5.4",
14
16
  "@activepieces/pieces-common": "0.2.5",
15
- "@activepieces/pieces-framework": "0.7.4",
16
- "@activepieces/shared": "0.10.44",
17
+ "@activepieces/pieces-framework": "0.7.7",
18
+ "@activepieces/shared": "0.10.54",
17
19
  "tslib": "1.14.1"
18
20
  },
19
21
  "main": "./src/index.js",
package/src/index.js CHANGED
@@ -9,6 +9,8 @@ const new_file_1 = require("./lib/triggers/new-file");
9
9
  const new_folder_1 = require("./lib/triggers/new-folder");
10
10
  const read_file_1 = require("./lib/action/read-file");
11
11
  const list_files_action_1 = require("./lib/action/list-files.action");
12
+ const search_folder_action_1 = require("./lib/action/search-folder.action");
13
+ const duplicate_file_action_1 = require("./lib/action/duplicate-file.action");
12
14
  exports.googleDriveAuth = pieces_framework_1.PieceAuth.OAuth2({
13
15
  description: "",
14
16
  authUrl: "https://accounts.google.com/o/oauth2/auth",
@@ -17,11 +19,11 @@ exports.googleDriveAuth = pieces_framework_1.PieceAuth.OAuth2({
17
19
  scope: ["https://www.googleapis.com/auth/drive"]
18
20
  });
19
21
  exports.googleDrive = (0, pieces_framework_1.createPiece)({
20
- minimumSupportedRelease: '0.5.0',
22
+ minimumSupportedRelease: '0.5.6',
21
23
  logoUrl: 'https://cdn.activepieces.com/pieces/google-drive.png',
22
- actions: [create_new_folder_1.googleDriveCreateNewFolder, create_new_text_file_1.googleDriveCreateNewTextFile, upload_file_1.googleDriveUploadFile, read_file_1.readFile, list_files_action_1.googleDriveListFiles],
24
+ actions: [create_new_folder_1.googleDriveCreateNewFolder, create_new_text_file_1.googleDriveCreateNewTextFile, upload_file_1.googleDriveUploadFile, read_file_1.readFile, list_files_action_1.googleDriveListFiles, search_folder_action_1.googleDriveSearchFolder, duplicate_file_action_1.duplicateFileAction],
23
25
  displayName: "Google Drive",
24
- authors: ['kanarelo', 'BastienMe', 'MoShizzle', 'Armangiau', 'vitalini', 'pfernandez98'],
26
+ authors: ['kanarelo', 'BastienMe', 'MoShizzle', 'Armangiau', 'vitalini', 'PFernandez98'],
25
27
  triggers: [new_file_1.newFile, new_folder_1.newFolder],
26
28
  auth: exports.googleDriveAuth,
27
29
  });
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/pieces/google-drive/src/index.ts"],"names":[],"mappings":";;;AAAA,qEAAwE;AAExE,sEAA4E;AAC5E,4EAAiF;AACjF,0DAAiE;AACjE,sDAAkD;AAClD,0DAAsD;AACtD,sDAAkD;AAClD,sEAAsE;AAEzD,QAAA,eAAe,GAAG,4BAAS,CAAC,MAAM,CAAC;IAC5C,WAAW,EAAE,EAAE;IACf,OAAO,EAAE,2CAA2C;IACpD,QAAQ,EAAE,qCAAqC;IAC/C,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE,CAAC,uCAAuC,CAAC;CACnD,CAAC,CAAA;AAEW,QAAA,WAAW,GAAG,IAAA,8BAAW,EAAC;IACtC,uBAAuB,EAAE,OAAO;IAC7B,OAAO,EAAE,sDAAsD;IAClE,OAAO,EAAE,CAAC,8CAA0B,EAAE,mDAA4B,EAAE,mCAAqB,EAAE,oBAAQ,EAAE,wCAAoB,CAAC;IAC1H,WAAW,EAAE,cAAc;IAC3B,OAAO,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,CAAC;IACxF,QAAQ,EAAE,CAAC,kBAAO,EAAE,sBAAS,CAAC;IAC3B,IAAI,EAAE,uBAAe;CACxB,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/pieces/google-drive/src/index.ts"],"names":[],"mappings":";;;AAAA,qEAAwE;AAExE,sEAA4E;AAC5E,4EAAiF;AACjF,0DAAiE;AACjE,sDAAkD;AAClD,0DAAsD;AACtD,sDAAkD;AAClD,sEAAsE;AACtE,4EAA4E;AAC5E,8EAAyE;AAE5D,QAAA,eAAe,GAAG,4BAAS,CAAC,MAAM,CAAC;IAC5C,WAAW,EAAE,EAAE;IACf,OAAO,EAAE,2CAA2C;IACpD,QAAQ,EAAE,qCAAqC;IAC/C,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE,CAAC,uCAAuC,CAAC;CACnD,CAAC,CAAA;AAEW,QAAA,WAAW,GAAG,IAAA,8BAAW,EAAC;IACtC,uBAAuB,EAAE,OAAO;IAC7B,OAAO,EAAE,sDAAsD;IAClE,OAAO,EAAE,CAAC,8CAA0B,EAAE,mDAA4B,EAAE,mCAAqB,EAAE,oBAAQ,EAAE,wCAAoB,EAAE,8CAAuB,EAAE,2CAAmB,CAAC;IACxK,WAAW,EAAE,cAAc;IAC3B,OAAO,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,CAAC;IACxF,QAAQ,EAAE,CAAC,kBAAO,EAAE,sBAAS,CAAC;IAC3B,IAAI,EAAE,uBAAe;CACxB,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const duplicateFileAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<true, import("@activepieces/pieces-framework").OAuth2Props>, {
2
+ fileId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ name: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ folderId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
5
+ }>;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.duplicateFileAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const index_1 = require("../../index");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const googleapis_1 = require("googleapis");
8
+ const googleapis_common_1 = require("googleapis-common");
9
+ exports.duplicateFileAction = (0, pieces_framework_1.createAction)({
10
+ displayName: "Duplicate File",
11
+ auth: index_1.googleDriveAuth,
12
+ name: "duplicate_file",
13
+ description: "Duplicate a file from Google Drive. Returns the new file ID.",
14
+ props: {
15
+ fileId: pieces_framework_1.Property.ShortText({
16
+ displayName: "File ID",
17
+ description: "The ID of the file to duplicate",
18
+ required: true,
19
+ }),
20
+ name: pieces_framework_1.Property.ShortText({
21
+ displayName: "Name",
22
+ description: "The name of the new file",
23
+ required: true,
24
+ }),
25
+ folderId: pieces_framework_1.Property.ShortText({
26
+ displayName: "Folder ID",
27
+ description: "The ID of the folder where the file will be duplicated",
28
+ required: true,
29
+ }),
30
+ },
31
+ run(context) {
32
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
33
+ const authClient = new googleapis_common_1.OAuth2Client();
34
+ authClient.setCredentials(context.auth);
35
+ const fileId = context.propsValue.fileId;
36
+ const nameForNewFile = context.propsValue.name;
37
+ const drive = googleapis_1.google.drive({ version: 'v3', auth: authClient });
38
+ const response = yield drive.files.copy({ fileId, auth: authClient });
39
+ if (response.status !== 200) {
40
+ console.error(response);
41
+ throw new Error('Error duplicating file');
42
+ }
43
+ const newFileId = response.data.id;
44
+ const body = { 'name': nameForNewFile };
45
+ drive.files.update;
46
+ const respUpdate = yield drive.files.update({
47
+ fileId: String(newFileId),
48
+ requestBody: body,
49
+ });
50
+ return respUpdate.data;
51
+ });
52
+ },
53
+ });
54
+ //# sourceMappingURL=duplicate-file.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duplicate-file.action.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/google-drive/src/lib/action/duplicate-file.action.ts"],"names":[],"mappings":";;;;AAAA,uCAA8C;AAC9C,qEAAwE;AACxE,2CAAoC;AACpC,yDAAiD;AAEpC,QAAA,mBAAmB,GAAG,IAAA,+BAAY,EAAC;IAC5C,WAAW,EAAE,gBAAgB;IAC7B,IAAI,EAAE,uBAAe;IACrB,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,8DAA8D;IAC3E,KAAK,EAAE;QACH,MAAM,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,iCAAiC;YAC9C,QAAQ,EAAE,IAAI;SACjB,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACrB,WAAW,EAAE,MAAM;YACnB,WAAW,EAAE,0BAA0B;YACvC,QAAQ,EAAE,IAAI;SACjB,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACzB,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,wDAAwD;YACrE,QAAQ,EAAE,IAAI;SACjB,CAAC;KACL;IACK,GAAG,CAAC,OAAO;;YACb,MAAM,UAAU,GAAG,IAAI,gCAAY,EAAE,CAAC;YACtC,UAAU,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;YAEvC,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;YACzC,MAAM,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC;YAE/C,MAAM,KAAK,GAAG,mBAAM,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;YAEhE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAC,CAAC,CAAC;YAEpE,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;gBACzB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;aAC7C;YAED,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAEnC,MAAM,IAAI,GAAG,EAAC,MAAM,EAAE,cAAc,EAAC,CAAC;YAEtC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAA;YAGlB,MAAM,UAAU,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC;gBACxC,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC;gBACzB,WAAW,EAAE,IAAI;aACpB,CAAC,CAAC;YAEH,OAAO,UAAU,CAAC,IAAI,CAAC;QAC3B,CAAC;KAAA;CACJ,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const googleDriveSearchFolder: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<true, import("@activepieces/pieces-framework").OAuth2Props>, {
2
+ query: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ }>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.googleDriveSearchFolder = void 0;
4
+ const tslib_1 = require("tslib");
5
+ /* eslint-disable @typescript-eslint/no-explicit-any */
6
+ const index_1 = require("../../index");
7
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
8
+ const googleapis_1 = require("googleapis");
9
+ const googleapis_common_1 = require("googleapis-common");
10
+ exports.googleDriveSearchFolder = (0, pieces_framework_1.createAction)({
11
+ auth: index_1.googleDriveAuth,
12
+ name: 'search-folder',
13
+ displayName: 'Search folder',
14
+ description: 'Search folder from a Google Drive folder',
15
+ props: {
16
+ query: pieces_framework_1.Property.ShortText({
17
+ displayName: 'Name',
18
+ description: 'Name to search for',
19
+ required: true,
20
+ }),
21
+ },
22
+ run(context) {
23
+ var _a;
24
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
25
+ const authClient = new googleapis_common_1.OAuth2Client();
26
+ authClient.setCredentials(context.auth);
27
+ const drive = googleapis_1.google.drive({ version: 'v3', auth: authClient });
28
+ const query = `name contains '${context.propsValue.query}' and mimeType='application/vnd.google-apps.folder'`;
29
+ const response = yield drive.files.list({
30
+ q: query,
31
+ fields: 'files(id, name)'
32
+ });
33
+ if (response.status !== 200) {
34
+ console.error(response);
35
+ throw new Error('Error searching folder');
36
+ }
37
+ const folders = (_a = response.data.files) !== null && _a !== void 0 ? _a : [];
38
+ if (folders.length > 0) {
39
+ return folders;
40
+ }
41
+ else {
42
+ console.log('Folder not found');
43
+ return [];
44
+ }
45
+ });
46
+ }
47
+ });
48
+ //# sourceMappingURL=search-folder.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-folder.action.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/google-drive/src/lib/action/search-folder.action.ts"],"names":[],"mappings":";;;;AAAA,uDAAuD;AACvD,uCAA8C;AAC9C,qEAAwE;AACxE,2CAAoC;AACpC,yDAAiD;AAEpC,QAAA,uBAAuB,GAAG,IAAA,+BAAY,EAAC;IAChD,IAAI,EAAE,uBAAe;IACrB,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,eAAe;IAC5B,WAAW,EAAE,0CAA0C;IACvD,KAAK,EAAE;QACH,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACtB,WAAW,EAAE,MAAM;YACnB,WAAW,EAAE,oBAAoB;YACjC,QAAQ,EAAE,IAAI;SACjB,CAAC;KACL;IACK,GAAG,CAAE,OAAO;;;YAEd,MAAM,UAAU,GAAG,IAAI,gCAAY,EAAE,CAAC;YACtC,UAAU,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;YAEvC,MAAM,KAAK,GAAG,mBAAM,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;YAChE,MAAM,KAAK,GAAG,kBAAkB,OAAO,CAAC,UAAU,CAAC,KAAK,qDAAqD,CAAC;YAG9G,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC;gBACxC,CAAC,EAAE,KAAK;gBACR,MAAM,EAAE,iBAAiB;aACxB,CAAC,CAAC;YAEH,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;gBACzB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;aAC7C;YAED,MAAM,OAAO,GAAG,MAAA,QAAQ,CAAC,IAAI,CAAC,KAAK,mCAAI,EAAE,CAAC;YAE1C,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;gBACpB,OAAO,OAAO,CAAC;aAClB;iBAAM;gBACH,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;gBAChC,OAAO,EAAE,CAAC;aACb;;KACJ;CACJ,CAAC,CAAC"}