@activepieces/piece-google-drive 0.7.7 → 0.7.9

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.
Files changed (85) hide show
  1. package/package.json +7 -20
  2. package/src/index.js +108 -79
  3. package/src/index.d.ts +0 -6
  4. package/src/index.d.ts.map +0 -1
  5. package/src/index.js.map +0 -1
  6. package/src/lib/action/add-permission.action.d.ts +0 -11
  7. package/src/lib/action/add-permission.action.d.ts.map +0 -1
  8. package/src/lib/action/add-permission.action.js +0 -77
  9. package/src/lib/action/add-permission.action.js.map +0 -1
  10. package/src/lib/action/create-new-folder.d.ts +0 -12
  11. package/src/lib/action/create-new-folder.d.ts.map +0 -1
  12. package/src/lib/action/create-new-folder.js +0 -37
  13. package/src/lib/action/create-new-folder.js.map +0 -1
  14. package/src/lib/action/create-new-text-file.d.ts +0 -14
  15. package/src/lib/action/create-new-text-file.d.ts.map +0 -1
  16. package/src/lib/action/create-new-text-file.js +0 -81
  17. package/src/lib/action/create-new-text-file.js.map +0 -1
  18. package/src/lib/action/delete-file.d.ts +0 -8
  19. package/src/lib/action/delete-file.d.ts.map +0 -1
  20. package/src/lib/action/delete-file.js +0 -34
  21. package/src/lib/action/delete-file.js.map +0 -1
  22. package/src/lib/action/delete-permission.action.d.ts +0 -9
  23. package/src/lib/action/delete-permission.action.d.ts.map +0 -1
  24. package/src/lib/action/delete-permission.action.js +0 -78
  25. package/src/lib/action/delete-permission.action.js.map +0 -1
  26. package/src/lib/action/duplicate-file.action.d.ts +0 -11
  27. package/src/lib/action/duplicate-file.action.d.ts.map +0 -1
  28. package/src/lib/action/duplicate-file.action.js +0 -77
  29. package/src/lib/action/duplicate-file.action.js.map +0 -1
  30. package/src/lib/action/get-file-by-id.d.ts +0 -8
  31. package/src/lib/action/get-file-by-id.d.ts.map +0 -1
  32. package/src/lib/action/get-file-by-id.js +0 -40
  33. package/src/lib/action/get-file-by-id.js.map +0 -1
  34. package/src/lib/action/list-files.action.d.ts +0 -11
  35. package/src/lib/action/list-files.action.d.ts.map +0 -1
  36. package/src/lib/action/list-files.action.js +0 -159
  37. package/src/lib/action/list-files.action.js.map +0 -1
  38. package/src/lib/action/move-file.d.ts +0 -12
  39. package/src/lib/action/move-file.d.ts.map +0 -1
  40. package/src/lib/action/move-file.js +0 -46
  41. package/src/lib/action/move-file.js.map +0 -1
  42. package/src/lib/action/read-file.d.ts +0 -8
  43. package/src/lib/action/read-file.d.ts.map +0 -1
  44. package/src/lib/action/read-file.js +0 -28
  45. package/src/lib/action/read-file.js.map +0 -1
  46. package/src/lib/action/save-file-as-pdf.action.d.ts +0 -10
  47. package/src/lib/action/save-file-as-pdf.action.d.ts.map +0 -1
  48. package/src/lib/action/save-file-as-pdf.action.js +0 -66
  49. package/src/lib/action/save-file-as-pdf.action.js.map +0 -1
  50. package/src/lib/action/search-folder-or-file.action.d.ts +0 -15
  51. package/src/lib/action/search-folder-or-file.action.d.ts.map +0 -1
  52. package/src/lib/action/search-folder-or-file.action.js +0 -114
  53. package/src/lib/action/search-folder-or-file.action.js.map +0 -1
  54. package/src/lib/action/send-to-trash.d.ts +0 -8
  55. package/src/lib/action/send-to-trash.d.ts.map +0 -1
  56. package/src/lib/action/send-to-trash.js +0 -38
  57. package/src/lib/action/send-to-trash.js.map +0 -1
  58. package/src/lib/action/set-public-access.d.ts +0 -8
  59. package/src/lib/action/set-public-access.d.ts.map +0 -1
  60. package/src/lib/action/set-public-access.js +0 -60
  61. package/src/lib/action/set-public-access.js.map +0 -1
  62. package/src/lib/action/upload-file.d.ts +0 -13
  63. package/src/lib/action/upload-file.d.ts.map +0 -1
  64. package/src/lib/action/upload-file.js +0 -61
  65. package/src/lib/action/upload-file.js.map +0 -1
  66. package/src/lib/auth.d.ts +0 -11
  67. package/src/lib/auth.d.ts.map +0 -1
  68. package/src/lib/auth.js +0 -86
  69. package/src/lib/auth.js.map +0 -1
  70. package/src/lib/common/get-file-content.d.ts +0 -4
  71. package/src/lib/common/get-file-content.d.ts.map +0 -1
  72. package/src/lib/common/get-file-content.js +0 -69
  73. package/src/lib/common/get-file-content.js.map +0 -1
  74. package/src/lib/common/index.d.ts +0 -23
  75. package/src/lib/common/index.d.ts.map +0 -1
  76. package/src/lib/common/index.js +0 -150
  77. package/src/lib/common/index.js.map +0 -1
  78. package/src/lib/triggers/new-file.d.ts +0 -43
  79. package/src/lib/triggers/new-file.d.ts.map +0 -1
  80. package/src/lib/triggers/new-file.js +0 -100
  81. package/src/lib/triggers/new-file.js.map +0 -1
  82. package/src/lib/triggers/new-folder.d.ts +0 -39
  83. package/src/lib/triggers/new-folder.d.ts.map +0 -1
  84. package/src/lib/triggers/new-folder.js +0 -64
  85. package/src/lib/triggers/new-folder.js.map +0 -1
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setPublicAccess = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const auth_1 = require("../auth");
7
- const googleapis_1 = require("googleapis");
8
- const get_file_content_1 = require("../common/get-file-content");
9
- exports.setPublicAccess = (0, pieces_framework_1.createAction)({
10
- auth: auth_1.googleDriveAuth,
11
- name: 'set_public_access',
12
- description: 'Set public access for a file or folder',
13
- displayName: 'Set public access',
14
- props: {
15
- fileId: pieces_framework_1.Property.ShortText({
16
- displayName: 'File or Folder ID',
17
- description: 'The ID of the file or folder to update permissions for',
18
- required: true,
19
- }),
20
- role: pieces_framework_1.Property.StaticDropdown({
21
- displayName: 'Role',
22
- description: 'The role to assign for public access',
23
- options: {
24
- options: [
25
- { label: 'Reader', value: 'reader' },
26
- { label: 'Commenter', value: 'commenter' },
27
- { label: 'Editor', value: 'writer' },
28
- ],
29
- },
30
- defaultValue: 'reader',
31
- required: true,
32
- }),
33
- },
34
- run(context) {
35
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
36
- const authClient = yield (0, auth_1.createGoogleClient)(context.auth);
37
- const fileId = context.propsValue.fileId;
38
- const role = context.propsValue.role;
39
- const drive = googleapis_1.google.drive({ version: 'v3', auth: authClient });
40
- const permission = {
41
- role,
42
- type: 'anyone',
43
- };
44
- const res = yield drive.permissions.create({
45
- fileId: fileId,
46
- requestBody: permission,
47
- });
48
- const file = yield drive.files.get({
49
- fileId: fileId,
50
- fields: 'name,mimeType,webContentLink,webViewLink',
51
- });
52
- if (file.data.mimeType === 'application/vnd.google-apps.folder') {
53
- return Object.assign(Object.assign({}, res.data), { webViewLink: file.data.webViewLink, downloadUrl: null });
54
- }
55
- const content = yield (0, get_file_content_1.downloadFileFromDrive)(context.auth, context.files, fileId, file.data.name);
56
- return Object.assign(Object.assign({}, res.data), { downloadUrl: content });
57
- });
58
- },
59
- });
60
- //# sourceMappingURL=set-public-access.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"set-public-access.js","sourceRoot":"","sources":["../../../../src/lib/action/set-public-access.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,kCAA8D;AAC9D,2CAAoC;AACpC,iEAAmE;AAEtD,QAAA,eAAe,GAAG,IAAA,+BAAY,EAAC;IAC1C,IAAI,EAAE,sBAAe;IACrB,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,wCAAwC;IACrD,WAAW,EAAE,mBAAmB;IAChC,KAAK,EAAE;QACL,MAAM,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACzB,WAAW,EAAE,mBAAmB;YAChC,WAAW,EAAE,wDAAwD;YACrE,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAC5B,WAAW,EAAE,MAAM;YACnB,WAAW,EAAE,sCAAsC;YACnD,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;oBACpC,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE;oBAC1C,EAAE,KAAK,EAAE,QAAQ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
@@ -1,13 +0,0 @@
1
- export declare const googleDriveUploadFile: import("@activepieces/pieces-framework").IAction<(import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
2
- serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
3
- userEmail: import("@activepieces/pieces-framework").ShortTextProperty<false>;
4
- }>)[], {
5
- fileName: import("@activepieces/pieces-framework").ShortTextProperty<true>;
6
- file: import("@activepieces/pieces-framework").FileProperty<true>;
7
- parentFolder: import("@activepieces/pieces-framework").DropdownProperty<string, false, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
8
- serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
9
- userEmail: import("@activepieces/pieces-framework").ShortTextProperty<false>;
10
- }>)[]>;
11
- include_team_drives: import("@activepieces/pieces-framework").CheckboxProperty<false>;
12
- }>;
13
- //# sourceMappingURL=upload-file.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upload-file.d.ts","sourceRoot":"","sources":["../../../../src/lib/action/upload-file.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,qBAAqB;;;;;;;;;;;EA4DhC,CAAC"}
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.googleDriveUploadFile = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const pieces_common_1 = require("@activepieces/pieces-common");
7
- const form_data_1 = tslib_1.__importDefault(require("form-data"));
8
- const auth_1 = require("../auth");
9
- const mime_types_1 = tslib_1.__importDefault(require("mime-types"));
10
- const common_1 = require("../common");
11
- exports.googleDriveUploadFile = (0, pieces_framework_1.createAction)({
12
- auth: auth_1.googleDriveAuth,
13
- name: 'upload_gdrive_file',
14
- description: 'Upload a file in your Google Drive',
15
- displayName: 'Upload file',
16
- props: {
17
- fileName: pieces_framework_1.Property.ShortText({
18
- displayName: 'File name',
19
- description: 'The name of the file',
20
- required: true,
21
- }),
22
- file: pieces_framework_1.Property.File({
23
- displayName: 'File',
24
- description: 'The file URL or base64 to upload',
25
- required: true,
26
- }),
27
- parentFolder: common_1.common.properties.parentFolder,
28
- include_team_drives: common_1.common.properties.include_team_drives,
29
- },
30
- run(context) {
31
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
32
- const fileData = context.propsValue.file;
33
- const mimeType = mime_types_1.default.lookup(fileData.extension ? fileData.extension : '');
34
- const meta = Object.assign({ mimeType: mimeType, name: context.propsValue.fileName }, (context.propsValue.parentFolder
35
- ? { parents: [context.propsValue.parentFolder] }
36
- : {}));
37
- const metaBuffer = Buffer.from(JSON.stringify(meta), 'utf-8');
38
- const fileBuffer = Buffer.from(fileData.base64, 'base64');
39
- const form = new form_data_1.default();
40
- form.append('Metadata', metaBuffer, { contentType: 'application/json' });
41
- form.append('Media', fileBuffer);
42
- const result = yield pieces_common_1.httpClient.sendRequest({
43
- method: pieces_common_1.HttpMethod.POST,
44
- url: `https://www.googleapis.com/upload/drive/v3/files`,
45
- queryParams: {
46
- uploadType: 'multipart',
47
- supportsAllDrives: String(context.propsValue.include_team_drives || false),
48
- },
49
- body: form,
50
- headers: Object.assign({}, form.getHeaders()),
51
- authentication: {
52
- type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
53
- token: yield (0, auth_1.getAccessToken)(context.auth),
54
- },
55
- });
56
- console.debug('File upload response', result);
57
- return result.body;
58
- });
59
- },
60
- });
61
- //# sourceMappingURL=upload-file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upload-file.js","sourceRoot":"","sources":["../../../../src/lib/action/upload-file.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAIqC;AACrC,kEAAiC;AACjC,kCAA0D;AAC1D,oEAA8B;AAC9B,sCAAmC;AAEtB,QAAA,qBAAqB,GAAG,IAAA,+BAAY,E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,EAAE,CAAC;YAC5B,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC,CAAC;YACzE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;YAEjC,MAAM,MAAM,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC1C,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG,EAAE,kDAAkD;gBACvD,WAAW,EAAE;oBACX,UAAU,EAAE,WAAW;oBACvB,iBAAiB,EAAE,MAAM,CACvB,OAAO,CAAC,UAAU,CAAC,mBAAmB,IAAI,KAAK,CAChD;iBACF;gBACD,IAAI,EAAE,IAAI;gBACV,OAAO,oBACF,IAAI,CAAC,UAAU,EAAE,CACrB;gBACD,cAAc,EAAE;oBACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,MAAM,IAAA,qBAAc,EAAC,OAAO,CAAC,IAAI,CAAC;iBAC1C;aACF,CAAC,CAAC;YAEH,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;YAC9C,OAAO,MAAM,CAAC,IAAI,CAAC;QACrB,CAAC;KAAA;CACF,CAAC,CAAC"}
package/src/lib/auth.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import { AppConnectionValueForAuthProperty } from '@activepieces/pieces-framework';
2
- import { OAuth2Client } from 'googleapis-common';
3
- export declare const googleDriveScopes: string[];
4
- export declare const googleDriveAuth: (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
5
- serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
6
- userEmail: import("@activepieces/pieces-framework").ShortTextProperty<false>;
7
- }>)[];
8
- export type GoogleDriveAuthValue = AppConnectionValueForAuthProperty<typeof googleDriveAuth>;
9
- export declare function createGoogleClient(auth: GoogleDriveAuthValue): Promise<OAuth2Client>;
10
- export declare const getAccessToken: (auth: GoogleDriveAuthValue) => Promise<string>;
11
- //# sourceMappingURL=auth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAuB,MAAM,gCAAgC,CAAC;AAGxG,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,eAAO,MAAM,iBAAiB,UAA4C,CAAC;AAE3E,eAAO,MAAM,eAAe;;;KAqCzB,CAAC;AAEJ,MAAM,MAAM,oBAAoB,GAAG,iCAAiC,CAAC,OAAO,eAAe,CAAC,CAAC;AAE7F,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,YAAY,CAAC,CAkB1F;AAED,eAAO,MAAM,cAAc,SAAgB,oBAAoB,KAAG,OAAO,CAAC,MAAM,CAW/E,CAAC"}
package/src/lib/auth.js DELETED
@@ -1,86 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAccessToken = exports.googleDriveAuth = exports.googleDriveScopes = void 0;
4
- exports.createGoogleClient = createGoogleClient;
5
- const tslib_1 = require("tslib");
6
- const pieces_framework_1 = require("@activepieces/pieces-framework");
7
- const shared_1 = require("@activepieces/shared");
8
- const googleapis_1 = require("googleapis");
9
- const googleapis_common_1 = require("googleapis-common");
10
- exports.googleDriveScopes = ['https://www.googleapis.com/auth/drive'];
11
- exports.googleDriveAuth = [pieces_framework_1.PieceAuth.OAuth2({
12
- description: '',
13
- authUrl: 'https://accounts.google.com/o/oauth2/auth',
14
- tokenUrl: 'https://oauth2.googleapis.com/token',
15
- required: true,
16
- scope: exports.googleDriveScopes,
17
- }), pieces_framework_1.PieceAuth.CustomAuth({
18
- displayName: 'Service Account (Advanced)',
19
- description: 'Authenticate via service account from https://console.cloud.google.com/ > IAM & Admin > Service Accounts > Create Service Account > Keys > Add key. <br> <br> You can optionally use domain-wide delegation (https://support.google.com/a/answer/162106?hl=en#zippy=%2Cset-up-domain-wide-delegation-for-a-client) to access files without adding the service account to each one. <br> <br> **Note:** Without a user email, the service account only has access to files/folders you explicitly share with it.',
20
- required: true,
21
- props: {
22
- serviceAccount: pieces_framework_1.Property.LongText({
23
- displayName: 'Service Account JSON Key',
24
- required: true,
25
- }),
26
- userEmail: pieces_framework_1.Property.ShortText({
27
- displayName: 'User Email',
28
- required: false,
29
- description: 'Email address of the user to impersonate for domain-wide delegation.',
30
- }),
31
- },
32
- validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
33
- try {
34
- yield (0, exports.getAccessToken)({
35
- type: shared_1.AppConnectionType.CUSTOM_AUTH,
36
- props: Object.assign({}, auth),
37
- });
38
- }
39
- catch (e) {
40
- return {
41
- valid: false,
42
- error: e.message,
43
- };
44
- }
45
- return {
46
- valid: true,
47
- };
48
- }),
49
- })];
50
- function createGoogleClient(auth) {
51
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
52
- if (auth.type === shared_1.AppConnectionType.CUSTOM_AUTH) {
53
- let serviceAccount;
54
- try {
55
- serviceAccount = JSON.parse(auth.props.serviceAccount);
56
- }
57
- catch (_a) {
58
- throw new Error('Invalid Service Account JSON Key. Please provide a valid JSON string.');
59
- }
60
- return new googleapis_1.google.auth.JWT({
61
- email: serviceAccount.client_email,
62
- key: serviceAccount.private_key,
63
- scopes: exports.googleDriveScopes,
64
- subject: auth.props.userEmail,
65
- });
66
- }
67
- const authClient = new googleapis_common_1.OAuth2Client();
68
- authClient.setCredentials(auth);
69
- return authClient;
70
- });
71
- }
72
- const getAccessToken = (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
73
- if (auth.type === shared_1.AppConnectionType.CUSTOM_AUTH) {
74
- const googleClient = yield createGoogleClient(auth);
75
- const response = yield googleClient.getAccessToken();
76
- if (response.token) {
77
- return response.token;
78
- }
79
- else {
80
- throw new Error('Could not retrieve access token from service account json');
81
- }
82
- }
83
- return auth.access_token;
84
- });
85
- exports.getAccessToken = getAccessToken;
86
- //# sourceMappingURL=auth.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":";;;AAgDA,gDAkBC;;AAlED,qEAAwG;AACxG,iDAAyD;AACzD,2CAAoC;AACpC,yDAAiD;AAEpC,QAAA,iBAAiB,GAAG,CAAC,uCAAuC,CAAC,CAAC;AAE9D,QAAA,eAAe,GAAG,CAAC,4BAAS,CAAC,MAAM,CAAC;QAC/C,WAAW,EAAE,EAAE;QACf,OAAO,EAAE,2CAA2C;QACpD,QAAQ,EAAE,qCAAqC;QAC/C,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,yBAAiB;KACzB,CAAC,EAAE,4BAAS,CAAC,UAAU,CAAC;QACvB,WAAW,EAAE,4BAA4B;QACzC,WAAW,EAAE,kfAAkf;QAC/f,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE;YACL,cAAc,EAAE,2BAAQ,CAAC,QAAQ,CAAC;gBAChC,WAAW,EAAE,0BAA0B;gBACvC,QAAQ,EAAE,IAAI;aACf,CAAC;YACF,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;gBAC5B,WAAW,EAAE,YAAY;gBACzB,QAAQ,EAAE,KAAK;gBACf,WAAW,EAAE,sEAAsE;aACpF,CAAC;SACH;QACD,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;YACvB,IAAI,CAAC;gBACH,MAAM,IAAA,sBAAc,EAAC;oBACnB,IAAI,EAAE,0BAAiB,CAAC,WAAW;oBACnC,KAAK,oBAAO,IAAI,CAAE;iBACnB,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO;oBACL,KAAK,EAAE,KAAK;oBACZ,KAAK,EAAG,CAAW,CAAC,OAAO;iBAC5B,CAAC;YACJ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I,CAAC,YAAY,CAAC;AAC3B,CAAC,CAAA,CAAC;AAXW,QAAA,cAAc,kBAWzB"}
@@ -1,4 +0,0 @@
1
- import { FilesService } from '@activepieces/pieces-framework';
2
- import { GoogleDriveAuthValue } from '../auth';
3
- export declare function downloadFileFromDrive(auth: GoogleDriveAuthValue, files: FilesService, fileId: string, fileName: string | undefined): Promise<string>;
4
- //# sourceMappingURL=get-file-content.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-file-content.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/get-file-content.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACb,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,oBAAoB,EAAkB,MAAM,SAAS,CAAC;AA0D/D,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,oBAAoB,EAC1B,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC3B,OAAO,CAAC,MAAM,CAAC,CAyCjB"}
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.downloadFileFromDrive = downloadFileFromDrive;
4
- const tslib_1 = require("tslib");
5
- const mime_types_1 = require("mime-types");
6
- const auth_1 = require("../auth");
7
- function getMimeType(auth, fileId) {
8
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
9
- const accessToken = yield (0, auth_1.getAccessToken)(auth);
10
- const mimeType = (yield fetch(`https://www.googleapis.com/drive/v3/files/${fileId}?fields=mimeType&supportsAllDrives=true`, {
11
- headers: {
12
- Authorization: `Bearer ${accessToken}`,
13
- },
14
- }).then((res) => res.json()))['mimeType'];
15
- return mimeType;
16
- });
17
- }
18
- const googledlCall = (url, auth, fileId, files, fileName) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
19
- const mimeType = yield getMimeType(auth, fileId);
20
- const accessToken = yield (0, auth_1.getAccessToken)(auth);
21
- const download = yield fetch(url, {
22
- headers: {
23
- Authorization: `Bearer ${accessToken}`,
24
- },
25
- })
26
- .then((response) => response.ok ? response.blob() : Promise.reject(response))
27
- .catch((error) => {
28
- var _a;
29
- return Promise.reject(new Error(`Error when download file:\n\tDownload file response: ${(_a = error.message) !== null && _a !== void 0 ? _a : error}`));
30
- });
31
- const extensionResult = (0, mime_types_1.extension)(mimeType);
32
- const fileExtension = extensionResult ? '.' + extensionResult : '';
33
- const srcFileName = fileName !== null && fileName !== void 0 ? fileName : fileId + fileExtension;
34
- return files.write({
35
- fileName: srcFileName,
36
- data: Buffer.from(yield download.arrayBuffer()),
37
- });
38
- });
39
- function downloadFileFromDrive(auth, files, fileId, fileName) {
40
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
41
- let mimeType = yield getMimeType(auth, fileId);
42
- // the google drive API doesn't allowed downloading google documents but we can export them to office formats
43
- if ([
44
- 'application/vnd.google-apps.document',
45
- 'application/vnd.google-apps.spreadsheet',
46
- 'application/vnd.google-apps.presentation',
47
- ].includes(mimeType)) {
48
- switch (mimeType) {
49
- case 'application/vnd.google-apps.document':
50
- mimeType =
51
- 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
52
- break;
53
- case 'application/vnd.google-apps.spreadsheet':
54
- mimeType =
55
- 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
56
- break;
57
- case 'application/vnd.google-apps.presentation':
58
- mimeType =
59
- 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
60
- break;
61
- }
62
- return yield googledlCall(`https://www.googleapis.com/drive/v3/files/${fileId}/export?mimeType=${mimeType}&supportsAllDrives=true`, auth, fileId, files, fileName);
63
- }
64
- else {
65
- return yield googledlCall(`https://www.googleapis.com/drive/v3/files/${fileId}?alt=media&supportsAllDrives=true`, auth, fileId, files, fileName);
66
- }
67
- });
68
- }
69
- //# sourceMappingURL=get-file-content.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-file-content.js","sourceRoot":"","sources":["../../../../src/lib/common/get-file-content.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GoogleDriveAuthValue } from '../auth';
2
- export declare const common: {
3
- properties: {
4
- parentFolder: import("@activepieces/pieces-framework").DropdownProperty<string, false, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
5
- serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
6
- userEmail: import("@activepieces/pieces-framework").ShortTextProperty<false>;
7
- }>)[]>;
8
- include_team_drives: import("@activepieces/pieces-framework").CheckboxProperty<false>;
9
- };
10
- getFiles(auth: GoogleDriveAuthValue, search?: {
11
- parent?: string;
12
- createdTime?: string | number | Date;
13
- createdTimeOp?: string;
14
- includeTeamDrive?: boolean;
15
- }, order?: string): Promise<any[]>;
16
- getFolders(auth: GoogleDriveAuthValue, search?: {
17
- parent?: string;
18
- createdTime?: string | number | Date;
19
- createdTimeOp?: string;
20
- includeTeamDrive?: boolean;
21
- }, order?: string): Promise<any[]>;
22
- };
23
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAmB,oBAAoB,EAAsC,MAAM,SAAS,CAAC;AAOpG,eAAO,MAAM,MAAM;;;;;;;;mBAiFT,oBAAoB,WACjB;QACP,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;QACrC,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;KAC5B,UACO,MAAM;qBAoCR,oBAAoB,WACjB;QACP,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;QACrC,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;KAC5B,UACO,MAAM;CAkCjB,CAAC"}
@@ -1,150 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.common = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_common_1 = require("@activepieces/pieces-common");
6
- const pieces_framework_1 = require("@activepieces/pieces-framework");
7
- const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
8
- const googleapis_1 = require("googleapis");
9
- const auth_1 = require("../auth");
10
- const FOLDER_DROPDOWN_PAGE_SIZE = 1000;
11
- const escapeDriveQueryLiteral = (value) => value.replace(/\\/g, '\\\\').replace(/'/g, "\\'");
12
- exports.common = {
13
- properties: {
14
- parentFolder: pieces_framework_1.Property.Dropdown({
15
- displayName: 'Parent Folder',
16
- description: "The Drive folder to target. Leave empty to use the root of My Drive. Type in the box to search your Drive by folder name. If the folder still isn't listed, switch this field to 'Dynamic value' (the toggle next to the field) and paste the folder ID — you can copy it from the folder's URL in Drive, after /folders/ (e.g. https://drive.google.com/drive/folders/<FOLDER_ID>).",
17
- required: false,
18
- auth: auth_1.googleDriveAuth,
19
- refreshers: ['include_team_drives'],
20
- refreshOnSearch: true,
21
- options: (_a, ctx_1) => tslib_1.__awaiter(void 0, [_a, ctx_1], void 0, function* ({ auth, include_team_drives }, ctx) {
22
- var _b, _c, _d;
23
- if (!auth) {
24
- return {
25
- disabled: true,
26
- options: [],
27
- placeholder: 'Please authenticate first',
28
- };
29
- }
30
- const authValue = auth;
31
- const accessToken = yield (0, auth_1.getAccessToken)(authValue);
32
- const searchValue = (_c = (_b = ctx === null || ctx === void 0 ? void 0 : ctx.searchValue) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
33
- const qParts = [
34
- "mimeType='application/vnd.google-apps.folder'",
35
- 'trashed = false',
36
- ];
37
- if (searchValue.length > 0) {
38
- qParts.push(`name contains '${escapeDriveQueryLiteral(searchValue)}'`);
39
- }
40
- const request = {
41
- method: pieces_common_1.HttpMethod.GET,
42
- url: `https://www.googleapis.com/drive/v3/files`,
43
- queryParams: {
44
- q: qParts.join(' and '),
45
- includeItemsFromAllDrives: include_team_drives ? 'true' : 'false',
46
- supportsAllDrives: 'true',
47
- corpora: include_team_drives ? 'allDrives' : 'user',
48
- pageSize: String(FOLDER_DROPDOWN_PAGE_SIZE),
49
- fields: 'nextPageToken, files(id, name)',
50
- },
51
- authentication: {
52
- type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
53
- token: accessToken,
54
- },
55
- };
56
- let folders = [];
57
- let truncated = false;
58
- try {
59
- const response = yield pieces_common_1.httpClient.sendRequest(request);
60
- folders = (_d = response.body.files) !== null && _d !== void 0 ? _d : [];
61
- truncated = Boolean(response.body.nextPageToken);
62
- }
63
- catch (e) {
64
- throw new Error(`Failed to get folders\nError:${e}`);
65
- }
66
- return {
67
- disabled: false,
68
- placeholder: truncated
69
- ? `Showing first ${folders.length} matches — type to narrow the list, or switch to Dynamic value to paste an ID.`
70
- : undefined,
71
- options: folders.map((folder) => {
72
- return {
73
- label: folder.name,
74
- value: folder.id,
75
- };
76
- }),
77
- };
78
- }),
79
- }),
80
- include_team_drives: pieces_framework_1.Property.Checkbox({
81
- displayName: 'Include Team Drives',
82
- description: 'Determines if folders from Team Drives should be included in the results.',
83
- defaultValue: false,
84
- required: false,
85
- }),
86
- },
87
- getFiles(auth, search, order) {
88
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
89
- var _a, _b, _c;
90
- const authClient = yield (0, auth_1.createGoogleClient)(auth);
91
- const drive = googleapis_1.google.drive({ version: 'v3', auth: authClient });
92
- const q = [];
93
- if (search === null || search === void 0 ? void 0 : search.parent)
94
- q.push(`'${search.parent}' in parents`);
95
- if (search === null || search === void 0 ? void 0 : search.createdTime)
96
- q.push(`createdTime ${(_a = search.createdTimeOp) !== null && _a !== void 0 ? _a : '>'} '${(0, dayjs_1.default)(search.createdTime).format()}'`);
97
- q.push(`trashed = false`);
98
- const allFiles = [];
99
- let pageToken = undefined;
100
- do {
101
- const listParams = {
102
- q: q.concat("mimeType!='application/vnd.google-apps.folder'").join(' and '),
103
- fields: 'nextPageToken, files(id, name, mimeType, webViewLink, kind, createdTime)',
104
- orderBy: order !== null && order !== void 0 ? order : 'createdTime desc',
105
- supportsAllDrives: true,
106
- includeItemsFromAllDrives: search === null || search === void 0 ? void 0 : search.includeTeamDrive,
107
- corpora: (search === null || search === void 0 ? void 0 : search.includeTeamDrive) ? 'allDrives' : 'user',
108
- };
109
- if (pageToken)
110
- listParams.pageToken = pageToken;
111
- const response = yield drive.files.list(listParams);
112
- allFiles.push(...((_b = response.data.files) !== null && _b !== void 0 ? _b : []));
113
- pageToken = (_c = response.data.nextPageToken) !== null && _c !== void 0 ? _c : undefined;
114
- } while (pageToken);
115
- return allFiles;
116
- });
117
- },
118
- getFolders(auth, search, order) {
119
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
120
- var _a, _b, _c;
121
- const authClient = yield (0, auth_1.createGoogleClient)(auth);
122
- const drive = googleapis_1.google.drive({ version: 'v3', auth: authClient });
123
- const q = [`mimeType='application/vnd.google-apps.folder'`];
124
- if (search === null || search === void 0 ? void 0 : search.parent)
125
- q.push(`'${search.parent}' in parents`);
126
- if (search === null || search === void 0 ? void 0 : search.createdTime)
127
- q.push(`createdTime ${(_a = search.createdTimeOp) !== null && _a !== void 0 ? _a : '>'} '${(0, dayjs_1.default)(search.createdTime).format()}'`);
128
- q.push(`trashed = false`);
129
- const allFolders = [];
130
- let pageToken = undefined;
131
- do {
132
- const listParams = {
133
- q: q.join(' and '),
134
- fields: 'nextPageToken, files(id, name, createdTime)',
135
- orderBy: order !== null && order !== void 0 ? order : 'createdTime desc',
136
- supportsAllDrives: true,
137
- includeItemsFromAllDrives: search === null || search === void 0 ? void 0 : search.includeTeamDrive,
138
- corpora: (search === null || search === void 0 ? void 0 : search.includeTeamDrive) ? 'allDrives' : 'user',
139
- };
140
- if (pageToken)
141
- listParams.pageToken = pageToken;
142
- const response = yield drive.files.list(listParams);
143
- allFolders.push(...((_b = response.data.files) !== null && _b !== void 0 ? _b : []));
144
- pageToken = (_c = response.data.nextPageToken) !== null && _c !== void 0 ? _c : undefined;
145
- } while (pageToken);
146
- return allFolders;
147
- });
148
- },
149
- };
150
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/common/index.ts"],"names":[],"mappings":";;;;AAAA,+DAKqC;AACrC,qEAA0D;AAC1D,0DAA0B;AAC1B,2CAAoC;AACpC,kCAAoG;AAEpG,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAEvC,MAAM,uBAAuB,GAAG,CAAC,KAAa,EAAU,EAAE,CACxD,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAEvC,QAAA,MAAM,GAAG;IACpB,UAAU,EAAE;QACV,YAAY,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC9B,WAAW,EAAE,eAAe;YAC5B,WAAW,EACT,sXAAsX;YACxX,QAAQ,EAAE,KAAK;YACf,IAAI,EAAE,sBAAe;YACrB,UAAU,EAAE,CAAC,qBAAqB,CAAC;YACnC,eAAe,EAAE,IAAI;YACrB,OAAO,EAAE,YAA2C,EAAE,2DAAtC,EAAE,IAAI,EAAE,mBAAmB,EAAE,EAAE,GAAG;;gBAChD,IAAI,CAAC,IAAI,EAAE,CAAC;oBACV,OAAO;wBACL,QAAQ,EAAE,IAAI;wBACd,OAAO,EAAE,EAAE;wBACX,WAAW,EAAE,2BAA2B;qBACzC,CAAC;gBACJ,CAAC;gBACD,MAAM,SAAS,GAAG,IAA4B,CAAC;gBAC/C,MAAM,WAAW,GAAG,MAAM,IAAA,qBAAc,EAAC,SAAS,CAAC,CAAC;gBACpD,MAAM,WAAW,GAAG,MAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,WAAW,0CAAE,IAAI,EAAE,mCAAI,EAAE,CAAC;gBACnD,M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}
@@ -1,43 +0,0 @@
1
- import { TriggerStrategy } from '@activepieces/pieces-framework';
2
- export declare const newFile: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
3
- serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
4
- userEmail: import("@activepieces/pieces-framework").ShortTextProperty<false>;
5
- }>)[], {
6
- parentFolder: import("@activepieces/pieces-framework").DropdownProperty<string, false, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
7
- serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
8
- userEmail: import("@activepieces/pieces-framework").ShortTextProperty<false>;
9
- }>)[]>;
10
- include_team_drives: import("@activepieces/pieces-framework").CheckboxProperty<false>;
11
- include_file_content: import("@activepieces/pieces-framework").CheckboxProperty<false>;
12
- }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
13
- serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
14
- userEmail: import("@activepieces/pieces-framework").ShortTextProperty<false>;
15
- }>)[], {
16
- parentFolder: import("@activepieces/pieces-framework").DropdownProperty<string, false, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
17
- serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
18
- userEmail: import("@activepieces/pieces-framework").ShortTextProperty<false>;
19
- }>)[]>;
20
- include_team_drives: import("@activepieces/pieces-framework").CheckboxProperty<false>;
21
- include_file_content: import("@activepieces/pieces-framework").CheckboxProperty<false>;
22
- }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
23
- serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
24
- userEmail: import("@activepieces/pieces-framework").ShortTextProperty<false>;
25
- }>)[], {
26
- parentFolder: import("@activepieces/pieces-framework").DropdownProperty<string, false, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
27
- serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
28
- userEmail: import("@activepieces/pieces-framework").ShortTextProperty<false>;
29
- }>)[]>;
30
- include_team_drives: import("@activepieces/pieces-framework").CheckboxProperty<false>;
31
- include_file_content: import("@activepieces/pieces-framework").CheckboxProperty<false>;
32
- }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
33
- serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
34
- userEmail: import("@activepieces/pieces-framework").ShortTextProperty<false>;
35
- }>)[], {
36
- parentFolder: import("@activepieces/pieces-framework").DropdownProperty<string, false, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
37
- serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
38
- userEmail: import("@activepieces/pieces-framework").ShortTextProperty<false>;
39
- }>)[]>;
40
- include_team_drives: import("@activepieces/pieces-framework").CheckboxProperty<false>;
41
- include_file_content: import("@activepieces/pieces-framework").CheckboxProperty<false>;
42
- }>;
43
- //# sourceMappingURL=new-file.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"new-file.d.ts","sourceRoot":"","sources":["../../../../src/lib/triggers/new-file.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAgCjE,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0DlB,CAAC"}