@activepieces/piece-google-drive 0.3.0 → 0.4.1

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,14 +1,17 @@
1
1
  {
2
2
  "name": "@activepieces/piece-google-drive",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "dependencies": {
5
5
  "@sinclair/typebox": "^0.26.3",
6
- "axios": "1.2.4",
6
+ "axios": "1.4.0",
7
+ "dayjs": "^1.11.8",
7
8
  "form-data": "^4.0.0",
9
+ "mime-types": "^2.1.35",
8
10
  "nanoid": "^3.3.4",
9
- "@activepieces/pieces-common": "0.1.0",
10
- "@activepieces/pieces-framework": "0.4.0",
11
- "@activepieces/shared": "0.4.0",
11
+ "semver": "7.5.3",
12
+ "@activepieces/pieces-common": "0.2.1",
13
+ "@activepieces/pieces-framework": "0.6.3",
14
+ "@activepieces/shared": "0.5.10",
12
15
  "tslib": "1.14.1"
13
16
  },
14
17
  "main": "./src/index.js",
package/src/index.js CHANGED
@@ -4,6 +4,9 @@ exports.googleDrive = exports.googleDriveAuth = void 0;
4
4
  const pieces_framework_1 = require("@activepieces/pieces-framework");
5
5
  const create_new_folder_1 = require("./lib/action/create-new-folder");
6
6
  const create_new_text_file_1 = require("./lib/action/create-new-text-file");
7
+ const upload_file_1 = require("./lib/action/upload-file");
8
+ const new_file_1 = require("./lib/triggers/new-file");
9
+ const new_folder_1 = require("./lib/triggers/new-folder");
7
10
  exports.googleDriveAuth = pieces_framework_1.PieceAuth.OAuth2({
8
11
  description: "",
9
12
  displayName: 'Authentication',
@@ -15,10 +18,10 @@ exports.googleDriveAuth = pieces_framework_1.PieceAuth.OAuth2({
15
18
  exports.googleDrive = (0, pieces_framework_1.createPiece)({
16
19
  minimumSupportedRelease: '0.5.0',
17
20
  logoUrl: 'https://cdn.activepieces.com/pieces/google-drive.png',
18
- actions: [create_new_folder_1.googleDriveCreateNewFolder, create_new_text_file_1.googleDriveCreateNewTextFile],
21
+ actions: [create_new_folder_1.googleDriveCreateNewFolder, create_new_text_file_1.googleDriveCreateNewTextFile, upload_file_1.googleDriveUploadFile],
19
22
  displayName: "Google Drive",
20
- authors: ['kanarelo'],
21
- triggers: [],
23
+ authors: ['kanarelo', 'BastienMe', 'MoShizzle'],
24
+ triggers: [new_file_1.newFile, new_folder_1.newFolder],
22
25
  auth: exports.googleDriveAuth,
23
26
  });
24
27
  //# 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;AACxE,sEAA4E;AAC5E,4EAAiF;AAEpE,QAAA,eAAe,GAAG,4BAAS,CAAC,MAAM,CAAC;IAC5C,WAAW,EAAE,EAAE;IACf,WAAW,EAAE,gBAAgB;IAC7B,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;IAClC,uBAAuB,EAAE,OAAO;IACjC,OAAO,EAAE,sDAAsD;IAClE,OAAO,EAAE,CAAC,8CAA0B,EAAE,mDAA4B,CAAC;IACnE,WAAW,EAAE,cAAc;IAC3B,OAAO,EAAE,CAAC,UAAU,CAAC;IACrB,QAAQ,EAAE,EAAE;IACT,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;AAEzC,QAAA,eAAe,GAAG,4BAAS,CAAC,MAAM,CAAC;IAC5C,WAAW,EAAE,EAAE;IACf,WAAW,EAAE,gBAAgB;IAC7B,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,CAAC;IAC1F,WAAW,EAAE,cAAc;IAC3B,OAAO,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,WAAW,CAAC;IAC/C,QAAQ,EAAE,CAAC,kBAAO,EAAE,sBAAS,CAAC;IAC3B,IAAI,EAAE,uBAAe;CACxB,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const googleDriveUploadFile: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<true, import("@activepieces/pieces-framework").OAuth2Props>, {
2
+ fileName: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ file: import("@activepieces/pieces-framework").FileProperty<true>;
4
+ parentFolder: import("@activepieces/pieces-framework").DropdownProperty<string, false>;
5
+ }>;
@@ -0,0 +1,93 @@
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 __1 = require("../../");
9
+ const mime_types_1 = tslib_1.__importDefault(require("mime-types"));
10
+ exports.googleDriveUploadFile = (0, pieces_framework_1.createAction)({
11
+ auth: __1.googleDriveAuth,
12
+ name: 'upload_gdrive_file',
13
+ description: 'Upload a file in your Google Drive',
14
+ displayName: 'Upload file',
15
+ props: {
16
+ fileName: pieces_framework_1.Property.ShortText({
17
+ displayName: 'File name',
18
+ description: 'The name of the file',
19
+ required: true,
20
+ }),
21
+ file: pieces_framework_1.Property.File({
22
+ displayName: "File",
23
+ description: "The file URL or base64 to upload",
24
+ required: true,
25
+ }),
26
+ parentFolder: pieces_framework_1.Property.Dropdown({
27
+ displayName: "Parent Folder",
28
+ required: false,
29
+ refreshers: [],
30
+ options: ({ auth }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
31
+ if (!auth) {
32
+ return {
33
+ disabled: true,
34
+ options: [],
35
+ placeholder: 'Please authenticate first'
36
+ };
37
+ }
38
+ const authProp = auth;
39
+ const folders = (yield pieces_common_1.httpClient.sendRequest({
40
+ method: pieces_common_1.HttpMethod.GET,
41
+ url: `https://www.googleapis.com/drive/v3/files`,
42
+ queryParams: {
43
+ q: "mimeType='application/vnd.google-apps.folder'"
44
+ },
45
+ authentication: {
46
+ type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
47
+ token: authProp['access_token'],
48
+ }
49
+ })).body.files;
50
+ return {
51
+ disabled: false,
52
+ options: folders.map((sheet) => {
53
+ return {
54
+ label: sheet.name,
55
+ value: sheet.id
56
+ };
57
+ })
58
+ };
59
+ })
60
+ }),
61
+ },
62
+ sampleData: {
63
+ "kind": "drive#file",
64
+ "id": "1VjCR4-747AvKH7KeQ6GclFpCnu_41ZDX",
65
+ "name": "text.txt",
66
+ "mimeType": "plain/text"
67
+ },
68
+ run(context) {
69
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
70
+ const fileData = context.propsValue.file;
71
+ const mimeType = mime_types_1.default.lookup(fileData.extension ? fileData.extension : '');
72
+ const meta = Object.assign({ 'mimeType': mimeType, 'name': context.propsValue.fileName }, (context.propsValue.parentFolder ? { 'parents': [context.propsValue.parentFolder] } : {}));
73
+ const metaBuffer = Buffer.from(JSON.stringify(meta), 'utf-8');
74
+ const fileBuffer = Buffer.from(fileData.base64, 'base64');
75
+ const form = new form_data_1.default();
76
+ form.append("Metadata", metaBuffer, { contentType: 'application/json' });
77
+ form.append("Media", fileBuffer);
78
+ const result = yield pieces_common_1.httpClient.sendRequest({
79
+ method: pieces_common_1.HttpMethod.POST,
80
+ url: `https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart`,
81
+ body: form,
82
+ headers: Object.assign({}, form.getHeaders()),
83
+ authentication: {
84
+ type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
85
+ token: context.auth.access_token,
86
+ }
87
+ });
88
+ console.debug("File upload response", result);
89
+ return result.body;
90
+ });
91
+ }
92
+ });
93
+ //# sourceMappingURL=upload-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload-file.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/google-drive/src/lib/action/upload-file.ts"],"names":[],"mappings":";;;;AAAA,qEAA6F;AAC7F,+DAAyF;AACzF,kEAAiC;AACjC,8BAAyC;AACzC,oEAA8B;AAEjB,QAAA,qBAAqB,GAAG,IAAA,+BAAY,EAAC;IAChD,IAAI,EAAE,mBAAe;IACnB,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,oCAAoC;IACjD,WAAW,EAAE,aAAa;IAC1B,KAAK,EAAE;QACL,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,sBAAsB;YACnC,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,IAAI,CAAC;YAClB,WAAW,EAAE,MAAM;YACnB,WAAW,EAAE,kCAAkC;YAC/C,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,YAAY,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC9B,WAAW,EAAE,eAAe;YAC5B,QAAQ,EAAE,KAAK;YACf,UAAU,EAAE,EAAE;YACd,OAAO,EAAE,CAAO,EAAE,IAAI,EAAE,EAAE,EAAE;gBAC1B,IAAI,CAAC,IAAI,EAAE;oBACT,OAAO;wBACL,QAAQ,EAAE,IAAI;wBACd,OAAO,EAAE,E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AAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC7F,CAAA;YAED,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;YAC9D,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YAE1D,MAAM,IAAI,GAAG,IAAI,mBAAQ,EAAE,CAAA;YAC3B,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,uEAAuE;gBAC5E,IAAI,EAAE,IAAI;gBACV,OAAO,oBACF,IAAI,CAAC,UAAU,EAAE,CACrB;gBACD,cAAc,EAAE;oBACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,YAAY;iBACjC;aACF,CAAC,CAAA;YAEF,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAA;YAC7C,OAAO,MAAM,CAAC,IAAI,CAAC;QACrB,CAAC;KAAA;CACJ,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { OAuth2PropertyValue } from "@activepieces/pieces-framework";
2
+ export declare const common: {
3
+ properties: {
4
+ folder: import("@activepieces/pieces-framework").DropdownProperty<unknown, false>;
5
+ };
6
+ getFiles(auth: OAuth2PropertyValue, search?: {
7
+ parent?: string;
8
+ createdTime?: string | number | Date;
9
+ createdTimeOp?: string;
10
+ }, order?: string): Promise<{
11
+ id: string;
12
+ name: string;
13
+ }[]>;
14
+ getFolders(auth: OAuth2PropertyValue, search?: {
15
+ parent?: string;
16
+ createdTime?: string | number | Date;
17
+ createdTimeOp?: string;
18
+ }, order?: string): Promise<{
19
+ id: string;
20
+ name: string;
21
+ }[]>;
22
+ };
@@ -0,0 +1,82 @@
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
+ exports.common = {
9
+ properties: {
10
+ folder: pieces_framework_1.Property.Dropdown({
11
+ displayName: "Parent Folder",
12
+ required: false,
13
+ refreshers: [],
14
+ options: ({ auth }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
15
+ if (!auth) {
16
+ return {
17
+ disabled: true,
18
+ options: [],
19
+ placeholder: 'Please authenticate first'
20
+ };
21
+ }
22
+ const authProp = auth;
23
+ const folders = yield exports.common.getFolders(authProp);
24
+ return {
25
+ disabled: false,
26
+ options: folders.map((sheet) => {
27
+ return {
28
+ label: sheet.name,
29
+ value: sheet.id
30
+ };
31
+ })
32
+ };
33
+ })
34
+ }),
35
+ },
36
+ getFiles(auth, search, order) {
37
+ var _a;
38
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
39
+ const q = [];
40
+ if (search === null || search === void 0 ? void 0 : search.parent)
41
+ q.push(`'${search.parent}' in parents`);
42
+ if (search === null || search === void 0 ? void 0 : search.createdTime)
43
+ q.push(`createdTime ${(_a = search.createdTimeOp) !== null && _a !== void 0 ? _a : '>'} '${(0, dayjs_1.default)(search.createdTime).format()}'`);
44
+ const response = yield pieces_common_1.httpClient.sendRequest({
45
+ method: pieces_common_1.HttpMethod.GET,
46
+ url: `https://www.googleapis.com/drive/v3/files`,
47
+ queryParams: {
48
+ q: q.join(' and '),
49
+ orderBy: order !== null && order !== void 0 ? order : 'createdTime asc'
50
+ },
51
+ authentication: {
52
+ type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
53
+ token: auth.access_token,
54
+ }
55
+ });
56
+ return response.body.files;
57
+ });
58
+ },
59
+ getFolders(auth, search, order) {
60
+ var _a;
61
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
62
+ const q = [`mimeType='application/vnd.google-apps.folder'`];
63
+ if (search === null || search === void 0 ? void 0 : search.parent)
64
+ q.push(`'${search.parent}' in parents`);
65
+ if (search === null || search === void 0 ? void 0 : search.createdTime)
66
+ q.push(`createdTime ${(_a = search.createdTimeOp) !== null && _a !== void 0 ? _a : '>'} '${(0, dayjs_1.default)(search.createdTime).format()}'`);
67
+ const response = yield pieces_common_1.httpClient.sendRequest({
68
+ method: pieces_common_1.HttpMethod.GET,
69
+ url: `https://www.googleapis.com/drive/v3/files`,
70
+ queryParams: {
71
+ q: q.join(' and ')
72
+ },
73
+ authentication: {
74
+ type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
75
+ token: auth.access_token,
76
+ }
77
+ });
78
+ return response.body.files;
79
+ });
80
+ }
81
+ };
82
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/google-drive/src/lib/common/index.ts"],"names":[],"mappings":";;;;AAAA,+DAAyF;AACzF,qEAA+E;AAC/E,0DAA0B;AAEb,QAAA,MAAM,GAAG;IAClB,UAAU,EAAE;QACR,MAAM,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACtB,WAAW,EAAE,eAAe;YAC5B,QAAQ,EAAE,KAAK;YACf,UAAU,EAAE,EAAE;YACd,OAAO,EAAE,CAAO,EAAE,IAAI,EAAE,EAAE,EAAE;gBACxB,IAAI,CAAC,IAAI,EAAE;oBACP,OAAO;wBACH,QAAQ,EAAE,IAAI;wBACd,OAAO,EAAE,EAAE;wBACX,WAAW,EAAE,2BAA2B;qBAC3C,CAAA;iBACJ;gBAED,MAAM,QA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,KAAK,CAAC;;KAC9B;IAEK,UAAU,CAAC,IAAyB,EAAE,MAI3C,EAAE,KAAc;;;YACb,MAAM,CAAC,GAAa,CAAC,+CAA+C,CAAC,CAAC;YACtE,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM;gBAAE,CAAC,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,MAAM,cAAc,CAAC,CAAC;YAC5D,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW;gBAAE,CAAC,CAAC,IAAI,CAAC,eAAe,MAAA,MAAM,CAAC,aAAa,mCAAI,GAAG,KAAK,IAAA,eAAK,EAAC,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YAEtH,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAA4C;gBACrF,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,GAAG,EAAE,2CAA2C;gBAChD,WAAW,EAAE;oBACT,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;iBACrB;gBACD,cAAc,EAAE;oBACZ,IAAI,EAAE,kCAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,IAAI,CAAC,YAAY;iBAC3B;aACJ,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;;KAC9B;CACJ,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { TriggerStrategy } from "@activepieces/pieces-framework";
2
+ export declare const newFile: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<true, import("@activepieces/pieces-framework").OAuth2Props>, {
3
+ parentFolder: import("@activepieces/pieces-framework").DropdownProperty<unknown, false>;
4
+ }>;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.newFile = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const pieces_framework_2 = require("@activepieces/pieces-framework");
7
+ const pieces_common_1 = require("@activepieces/pieces-common");
8
+ const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
9
+ const __1 = require("../..");
10
+ const common_1 = require("../common");
11
+ const polling = {
12
+ strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
13
+ items: ({ auth, propsValue, lastFetchEpochMS }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
14
+ var _a;
15
+ const currentValues = (_a = yield common_1.common.getFiles(auth, {
16
+ parent: propsValue.parentFolder,
17
+ createdTime: lastFetchEpochMS
18
+ })) !== null && _a !== void 0 ? _a : [];
19
+ const items = currentValues.map((item) => ({
20
+ epochMilliSeconds: (0, dayjs_1.default)(item.createdTime).valueOf(),
21
+ data: item
22
+ }));
23
+ return items;
24
+ })
25
+ };
26
+ exports.newFile = (0, pieces_framework_1.createTrigger)({
27
+ auth: __1.googleDriveAuth,
28
+ name: 'new_file',
29
+ displayName: 'New File',
30
+ description: 'Trigger when a new file is uploaded.',
31
+ props: {
32
+ parentFolder: common_1.common.properties.folder
33
+ },
34
+ type: pieces_framework_2.TriggerStrategy.POLLING,
35
+ onEnable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
36
+ yield pieces_common_1.pollingHelper.onEnable(polling, {
37
+ auth: context.auth,
38
+ store: context.store,
39
+ propsValue: context.propsValue,
40
+ });
41
+ }),
42
+ onDisable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
43
+ yield pieces_common_1.pollingHelper.onDisable(polling, {
44
+ auth: context.auth,
45
+ store: context.store,
46
+ propsValue: context.propsValue,
47
+ });
48
+ }),
49
+ run: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
50
+ return yield pieces_common_1.pollingHelper.poll(polling, {
51
+ auth: context.auth,
52
+ store: context.store,
53
+ propsValue: context.propsValue,
54
+ });
55
+ }),
56
+ test: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
57
+ return yield pieces_common_1.pollingHelper.test(polling, {
58
+ auth: context.auth,
59
+ store: context.store,
60
+ propsValue: context.propsValue,
61
+ });
62
+ }),
63
+ sampleData: {
64
+ "kind": "drive#file",
65
+ "mimeType": "image/jpeg",
66
+ "id": "1dpv4-sKJfKRwI9qx1vWqQhEGEn3EpbI5",
67
+ "name": "sweep.jpg"
68
+ }
69
+ });
70
+ //# sourceMappingURL=new-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-file.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/google-drive/src/lib/triggers/new-file.ts"],"names":[],"mappings":";;;;AAAA,qEAAqF;AACrF,qEAAiE;AACjE,+DAAqF;AAErF,0DAA0B;AAC1B,6BAAwC;AACxC,sCAAmC;AAEnC,MAAM,OAAO,GAAkF;IAC3F,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAClC,KAAK,EAAE,CAAO,EAAE,IAAI,EAAE,UAAU,EAAE,gBAAgB,EAAE,EAAE,EAAE;;QACpD,MAAM,aAAa,GAAG,MAAA,MAAM,eAAM,CAAC,QAAQ,CAAC,IAAI,EAAE;YAC9C,MAAM,EAAE,UAAU,CAAC,YAAY;YAC/B,WAAW,EAAE,gBAAgB;SAChC,CAAC,mCAAI,EAAE,CAAC;QACT,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,CAAC;YAC5C,iBAAiB,EAAE,IAAA,eAAK,EAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE;YACpD,IAAI,EAAE,IAAI;SACb,CAAC,CAAC,CAAC;QACJ,OAAO,KAAK,CAAC;IACjB,CAAC,CAAA;CACJ,CAAC;AAEW,QAAA,OAAO,GAAG,IAAA,gCAAa,EAAC;IACjC,IAAI,EAAE,mBAAe;IACrB,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,UAAU;IACvB,WAAW,EAAE,sCAAsC;IACnD,KAAK,EAAE;QACH,YAAY,EA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const newFolder: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<true, import("@activepieces/pieces-framework").OAuth2Props>, {
3
+ parentFolder: import("@activepieces/pieces-framework").DropdownProperty<unknown, false>;
4
+ }>;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.newFolder = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const pieces_framework_2 = require("@activepieces/pieces-framework");
7
+ const pieces_common_1 = require("@activepieces/pieces-common");
8
+ const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
9
+ const __1 = require("../..");
10
+ const common_1 = require("../common");
11
+ const polling = {
12
+ strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
13
+ items: ({ auth, propsValue, lastFetchEpochMS }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
14
+ var _a;
15
+ const currentValues = (_a = yield common_1.common.getFolders(auth, {
16
+ parent: propsValue.parentFolder,
17
+ createdTime: lastFetchEpochMS
18
+ })) !== null && _a !== void 0 ? _a : [];
19
+ const items = currentValues.map((item) => ({
20
+ epochMilliSeconds: (0, dayjs_1.default)(item.createdTime).valueOf(),
21
+ data: item
22
+ }));
23
+ return items;
24
+ })
25
+ };
26
+ exports.newFolder = (0, pieces_framework_1.createTrigger)({
27
+ auth: __1.googleDriveAuth,
28
+ name: 'new_folder',
29
+ displayName: 'New Folder',
30
+ description: 'Trigger when a new folder is created or uploaded.',
31
+ props: {
32
+ parentFolder: common_1.common.properties.folder
33
+ },
34
+ type: pieces_framework_2.TriggerStrategy.POLLING,
35
+ onEnable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
36
+ yield pieces_common_1.pollingHelper.onEnable(polling, {
37
+ auth: context.auth,
38
+ store: context.store,
39
+ propsValue: context.propsValue,
40
+ });
41
+ }),
42
+ onDisable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
43
+ yield pieces_common_1.pollingHelper.onDisable(polling, {
44
+ auth: context.auth,
45
+ store: context.store,
46
+ propsValue: context.propsValue,
47
+ });
48
+ }),
49
+ run: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
50
+ return yield pieces_common_1.pollingHelper.poll(polling, {
51
+ auth: context.auth,
52
+ store: context.store,
53
+ propsValue: context.propsValue,
54
+ });
55
+ }),
56
+ test: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
57
+ return yield pieces_common_1.pollingHelper.test(polling, {
58
+ auth: context.auth,
59
+ store: context.store,
60
+ propsValue: context.propsValue,
61
+ });
62
+ }),
63
+ sampleData: {
64
+ "kind": "drive#file",
65
+ "mimeType": "application/vnd.google-apps.folder",
66
+ "id": "1aMEtTqIYn5651wdK7WLxaK_SDim4mvXW",
67
+ "name": "New Folder WOOOO"
68
+ }
69
+ });
70
+ //# sourceMappingURL=new-folder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-folder.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/google-drive/src/lib/triggers/new-folder.ts"],"names":[],"mappings":";;;;AAAA,qEAAqF;AACrF,qEAAiE;AACjE,+DAAqF;AAErF,0DAA0B;AAC1B,6BAAwC;AACxC,sCAAmC;AAEnC,MAAM,OAAO,GAAkF;IAC3F,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAClC,KAAK,EAAE,CAAO,EAAE,IAAI,EAAE,UAAU,EAAE,gBAAgB,EAAE,EAAE,EAAE;;QACpD,MAAM,aAAa,GAAG,MAAA,MAAM,eAAM,CAAC,UAAU,CAAC,IAAI,EAAE;YAChD,MAAM,EAAE,UAAU,CAAC,YAAY;YAC/B,WAAW,EAAE,gBAAgB;SAChC,CAAC,mCAAI,EAAE,CAAC;QACT,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,CAAC;YAC5C,iBAAiB,EAAE,IAAA,eAAK,EAAC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