@activepieces/piece-google-drive 0.5.6 → 0.5.8

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@activepieces/piece-google-drive",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "dependencies": {
5
5
  "@sinclair/typebox": "0.26.8",
6
6
  "axios": "^1.6.3",
@@ -14,8 +14,8 @@
14
14
  "nanoid": "3.3.6",
15
15
  "semver": "7.5.4",
16
16
  "@activepieces/pieces-common": "0.2.5",
17
- "@activepieces/pieces-framework": "0.7.5",
18
- "@activepieces/shared": "0.10.48",
17
+ "@activepieces/pieces-framework": "0.7.7",
18
+ "@activepieces/shared": "0.10.54",
19
19
  "tslib": "1.14.1"
20
20
  },
21
21
  "main": "./src/index.js",
package/src/index.js CHANGED
@@ -10,6 +10,8 @@ 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
12
  const search_folder_action_1 = require("./lib/action/search-folder.action");
13
+ const duplicate_file_action_1 = require("./lib/action/duplicate-file.action");
14
+ const save_file_as_pdf_action_1 = require("./lib/action/save-file-as-pdf.action");
13
15
  exports.googleDriveAuth = pieces_framework_1.PieceAuth.OAuth2({
14
16
  description: "",
15
17
  authUrl: "https://accounts.google.com/o/oauth2/auth",
@@ -20,10 +22,10 @@ exports.googleDriveAuth = pieces_framework_1.PieceAuth.OAuth2({
20
22
  exports.googleDrive = (0, pieces_framework_1.createPiece)({
21
23
  minimumSupportedRelease: '0.5.6',
22
24
  logoUrl: 'https://cdn.activepieces.com/pieces/google-drive.png',
23
- 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],
24
25
  displayName: "Google Drive",
25
- authors: ['kanarelo', 'BastienMe', 'MoShizzle', 'Armangiau', 'vitalini', 'pfernandez98'],
26
+ authors: ['kanarelo', 'BastienMe', 'MoShizzle', 'Armangiau', 'vitalini', 'PFernandez98'],
26
27
  triggers: [new_file_1.newFile, new_folder_1.newFolder],
28
+ 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, save_file_as_pdf_action_1.saveFileAsPdf],
27
29
  auth: exports.googleDriveAuth,
28
30
  });
29
31
  //# sourceMappingURL=index.js.map
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;AACtE,4EAA4E;AAE/D,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,CAAC;IACnJ,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;AACzE,kFAAqE;AAExD,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,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;IAC9B,OAAO,EAAE,CAAC,8CAA0B,EAAE,mDAA4B,EAAE,mCAAqB,EAAE,oBAAQ,EAAE,wCAAoB,EAAE,8CAAuB,EAAE,2CAAmB,EAAE,uCAAa,CAAC;IACpL,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,5 @@
1
+ export declare const saveFileAsPdf: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<true, import("@activepieces/pieces-framework").OAuth2Props>, {
2
+ documentId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ folderId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ name: import("@activepieces/pieces-framework").ShortTextProperty<true>;
5
+ }>;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.saveFileAsPdf = void 0;
5
+ const tslib_1 = require("tslib");
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
+ const stream_1 = require("stream");
11
+ exports.saveFileAsPdf = (0, pieces_framework_1.createAction)({
12
+ displayName: "Save file as PDF",
13
+ auth: index_1.googleDriveAuth,
14
+ name: "save_file_as_pdf",
15
+ description: "Save a file as PDF in a Google Drive folder",
16
+ props: {
17
+ documentId: pieces_framework_1.Property.ShortText({
18
+ displayName: "Document ID",
19
+ description: "The ID of the document to export",
20
+ required: true,
21
+ }),
22
+ folderId: pieces_framework_1.Property.ShortText({
23
+ displayName: "Folder ID",
24
+ description: "The ID of the folder where the file will be exported",
25
+ required: true,
26
+ }),
27
+ name: pieces_framework_1.Property.ShortText({
28
+ displayName: "Name",
29
+ description: "The name of the new file (do not include the extension)",
30
+ required: true,
31
+ }),
32
+ },
33
+ run(context) {
34
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
35
+ const authClient = new googleapis_common_1.OAuth2Client();
36
+ authClient.setCredentials(context.auth);
37
+ const documentId = context.propsValue.documentId;
38
+ const folderId = context.propsValue.folderId;
39
+ const nameForNewFile = context.propsValue.name;
40
+ const drive = googleapis_1.google.drive({ version: 'v3', auth: authClient });
41
+ const result = yield drive.files.export({
42
+ fileId: documentId,
43
+ mimeType: 'application/pdf',
44
+ }, { responseType: "arraybuffer" });
45
+ const requestBody = {
46
+ name: nameForNewFile + ".pdf",
47
+ parents: [folderId],
48
+ };
49
+ const templateBuffer = Buffer.from(result.data, 'base64');
50
+ const streamm = new stream_1.Stream.PassThrough().end(templateBuffer);
51
+ const media = {
52
+ mimeType: 'application/pdf',
53
+ body: streamm,
54
+ };
55
+ const file = yield drive.files.create({
56
+ requestBody,
57
+ media: media,
58
+ });
59
+ return file.data;
60
+ });
61
+ },
62
+ });
63
+ //# sourceMappingURL=save-file-as-pdf.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"save-file-as-pdf.action.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/google-drive/src/lib/action/save-file-as-pdf.action.ts"],"names":[],"mappings":";AAAA,uDAAuD;;;;AAEvD,uCAA8C;AAC9C,qEAAwE;AACxE,2CAAoC;AACpC,yDAAiD;AACjD,mCAAgC;AAEnB,QAAA,aAAa,GAAG,IAAA,+BAAY,EAAC;IACtC,WAAW,EAAE,kBAAkB;IAC/B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