@activepieces/piece-google-tasks 0.0.0-pre1

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,7 @@
1
+ # pieces-google-tasks
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Running lint
6
+
7
+ Run `nx lint pieces-google-tasks` to execute the lint via [ESLint](https://eslint.org/).
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@activepieces/piece-google-tasks",
3
+ "version": "0.0.0-pre1",
4
+ "dependencies": {
5
+ "@sinclair/typebox": "0.24.51",
6
+ "axios": "1.2.4",
7
+ "cron-validator": "1.3.1",
8
+ "nanoid": "3.3.4"
9
+ },
10
+ "peerDependencies": {
11
+ "@activepieces/framework": "0.0.1",
12
+ "@activepieces/shared": "0.0.1",
13
+ "tslib": "2.4.1"
14
+ },
15
+ "main": "./src/index.js",
16
+ "types": "./src/index.d.ts"
17
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const googleTasks: import("@activepieces/framework").Piece;
package/src/index.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.googleTasks = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const package_json_1 = tslib_1.__importDefault(require("../package.json"));
6
+ const framework_1 = require("@activepieces/framework");
7
+ const new_task_1 = require("./lib/actions/new-task");
8
+ exports.googleTasks = (0, framework_1.createPiece)({
9
+ name: 'google_tasks',
10
+ logoUrl: 'https://cdn.activepieces.com/pieces/google_tasks.png',
11
+ actions: [new_task_1.googleTasksAddNewTaskAction],
12
+ displayName: "Google Tasks",
13
+ authors: ['abaza738'],
14
+ triggers: [],
15
+ version: package_json_1.default.version,
16
+ });
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/pieces/google-tasks/src/index.ts"],"names":[],"mappings":";;;;AAAA,2EAA0C;AAC1C,uDAAsD;AACtD,qDAAqE;AAExD,QAAA,WAAW,GAAG,IAAA,uBAAW,EAAC;IACtC,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,sDAAsD;IAC/D,OAAO,EAAE,CAAC,sCAA2B,CAAC;IACtC,WAAW,EAAE,cAAc;IAC3B,OAAO,EAAE,CAAC,UAAU,CAAC;IACrB,QAAQ,EAAE,EAAE;IACX,OAAO,EAAE,sBAAW,CAAC,OAAO;CAC7B,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const googleTasksAddNewTaskAction: import("@activepieces/framework").Action;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.googleTasksAddNewTaskAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const framework_1 = require("@activepieces/framework");
6
+ const common_1 = require("../common");
7
+ exports.googleTasksAddNewTaskAction = (0, framework_1.createAction)({
8
+ name: 'add_task',
9
+ description: 'Add a new task to a specified task list',
10
+ displayName: 'Add Task',
11
+ props: {
12
+ authentication: common_1.googleTasksCommon.authentication,
13
+ tasks_list: common_1.googleTasksCommon.tasksList,
14
+ title: common_1.googleTasksCommon.title,
15
+ notes: common_1.googleTasksCommon.notes,
16
+ completed: common_1.googleTasksCommon.completed,
17
+ },
18
+ run({ propsValue }) {
19
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
20
+ const task = {
21
+ kind: 'tasks#task',
22
+ status: propsValue.completed ? common_1.TaskStatus.COMPLETED : common_1.TaskStatus.NEEDS_ACTION,
23
+ title: propsValue.title,
24
+ completed: propsValue.completed ? new Date().toISOString() : '',
25
+ notes: propsValue.notes,
26
+ };
27
+ return (0, common_1.createTask)(propsValue.authentication, propsValue.tasks_list, task);
28
+ });
29
+ },
30
+ });
31
+ //# sourceMappingURL=new-task.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-task.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/google-tasks/src/lib/actions/new-task.ts"],"names":[],"mappings":";;;;AAAA,uDAAuD;AACvD,sCAA4E;AAE/D,QAAA,2BAA2B,GAAG,IAAA,wBAAY,EAAC;IACpD,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,yCAAyC;IACtD,WAAW,EAAE,UAAU;IACvB,KAAK,EAAE;QACH,cAAc,EAAE,0BAAiB,CAAC,cAAc;QAChD,UAAU,EAAE,0BAAiB,CAAC,SAAS;QACvC,KAAK,EAAE,0BAAiB,CAAC,KAAK;QAC9B,KAAK,EAAE,0BAAiB,CAAC,KAAK;QAC9B,SAAS,EAAE,0BAAiB,CAAC,SAAS;KACzC;IACK,GAAG,CAAC,EAAE,UAAU,EAAE;;YACpB,MAAM,IAAI,GAAS;gBACf,IAAI,EAAE,YAAY;gBAClB,MAAM,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,mBAAU,CAAC,SAAS,CAAC,CAAC,CAAC,mBAAU,CAAC,YAAY;gBAC7E,KAAK,EAAE,UAAU,CAAC,KAAK;gBACvB,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE;gBAC/D,KAAK,EAAE,UAAU,CAAC,KAAK;aAC1B,CAAC;YAEF,OAAO,IAAA,mBAAU,EAAC,UAAU,CAAC,cAAc,EAAE,UAAU,CAAC,UAAW,EAAE,IAAI,CAAC,CAAC;QAC/E,CAAC;KAAA;CACJ,CAAC,CAAC"}
@@ -0,0 +1,56 @@
1
+ import { OAuth2PropertyValue } from "@activepieces/framework";
2
+ export declare enum TaskStatus {
3
+ NEEDS_ACTION = "needsAction",
4
+ COMPLETED = "completed"
5
+ }
6
+ /**
7
+ * @see https://developers.google.com/tasks/reference/rest/v1/tasklists/list#response-body
8
+ */
9
+ export declare type TasksListResponse = {
10
+ "kind": string;
11
+ "etag": string;
12
+ "nextPageToken": string;
13
+ "items": TasksList[];
14
+ };
15
+ /**
16
+ * @see https://developers.google.com/tasks/reference/rest/v1/tasklists#resource:-tasklist
17
+ */
18
+ export declare type TasksList = {
19
+ kind: string;
20
+ id: string;
21
+ etag: string;
22
+ title: string;
23
+ updated: string;
24
+ selfLink: string;
25
+ };
26
+ /**
27
+ * @see https://developers.google.com/tasks/reference/rest/v1/tasks#resource:-task
28
+ */
29
+ export declare type Task = {
30
+ kind: "tasks#task";
31
+ title: string;
32
+ status: TaskStatus;
33
+ notes?: string;
34
+ /**
35
+ * *Optional* RFC 3339 timestamp of due date of the task
36
+ */
37
+ due?: string;
38
+ /**
39
+ * *Optional* RFC 3339 timestamp of completion.
40
+ * Filled automatically if `status === 'completed'`
41
+ */
42
+ completed?: string;
43
+ };
44
+ export declare const googleTasksCommon: {
45
+ baseUrl: string;
46
+ authentication: import("@activepieces/framework").OAuth2Property<true>;
47
+ /**
48
+ * @property Target task list ID where the new task will be created
49
+ */
50
+ tasksList: import("@activepieces/framework").DropdownProperty<string, false> | import("@activepieces/framework").DropdownProperty<string, true>;
51
+ title: import("@activepieces/framework").ShortTextProperty<true>;
52
+ notes: import("@activepieces/framework").LongTextProperty<false>;
53
+ completed: import("@activepieces/framework").CheckboxProperty<false>;
54
+ };
55
+ export declare function getTasks(authProp: OAuth2PropertyValue): Promise<TasksList[]>;
56
+ export declare function createTask(authProp: OAuth2PropertyValue, taskListId: string, task: Task): Promise<import("@activepieces/framework").HttpResponse<import("@activepieces/framework").HttpMessageBody>>;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTask = exports.getTasks = exports.googleTasksCommon = exports.TaskStatus = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const framework_1 = require("@activepieces/framework");
6
+ var TaskStatus;
7
+ (function (TaskStatus) {
8
+ TaskStatus["NEEDS_ACTION"] = "needsAction";
9
+ TaskStatus["COMPLETED"] = "completed";
10
+ })(TaskStatus = exports.TaskStatus || (exports.TaskStatus = {}));
11
+ exports.googleTasksCommon = {
12
+ baseUrl: `https://tasks.googleapis.com`,
13
+ authentication: framework_1.Property.OAuth2({
14
+ description: "",
15
+ displayName: 'Authentication',
16
+ authUrl: "https://accounts.google.com/o/oauth2/auth",
17
+ tokenUrl: "https://oauth2.googleapis.com/token",
18
+ required: true,
19
+ scope: ["https://www.googleapis.com/auth/tasks"]
20
+ }),
21
+ /**
22
+ * @property Target task list ID where the new task will be created
23
+ */
24
+ tasksList: framework_1.Property.Dropdown({
25
+ displayName: 'Tasks List',
26
+ refreshers: ['authentication'],
27
+ required: true,
28
+ options: (propsValue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
29
+ if (!propsValue['authentication']) {
30
+ return {
31
+ disabled: true,
32
+ placeholder: "Please connect your account first",
33
+ options: [],
34
+ };
35
+ }
36
+ const authProp = propsValue['authentication'];
37
+ const tasksLists = yield getTasks(authProp);
38
+ return {
39
+ disabled: false,
40
+ options: tasksLists.map(list => {
41
+ return {
42
+ label: list.title,
43
+ value: list.id,
44
+ };
45
+ }),
46
+ };
47
+ }),
48
+ }),
49
+ title: framework_1.Property.ShortText({
50
+ displayName: 'Title',
51
+ required: true,
52
+ }),
53
+ notes: framework_1.Property.LongText({
54
+ displayName: 'Notes',
55
+ required: false,
56
+ }),
57
+ completed: framework_1.Property.Checkbox({
58
+ displayName: 'Completed',
59
+ description: 'Mark task as completed',
60
+ required: false,
61
+ }),
62
+ };
63
+ function getTasks(authProp) {
64
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
65
+ // docs: https://developers.google.com/tasks/reference/rest/v1/tasklists/list
66
+ const request = {
67
+ method: framework_1.HttpMethod.GET,
68
+ url: `${exports.googleTasksCommon.baseUrl}/tasks/v1/users/@me/lists`,
69
+ authentication: {
70
+ type: framework_1.AuthenticationType.BEARER_TOKEN,
71
+ token: authProp.access_token,
72
+ },
73
+ };
74
+ const response = yield framework_1.httpClient.sendRequest(request);
75
+ return response.body.items;
76
+ });
77
+ }
78
+ exports.getTasks = getTasks;
79
+ function createTask(authProp, taskListId, task) {
80
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
81
+ const request = {
82
+ method: framework_1.HttpMethod.POST,
83
+ url: `${exports.googleTasksCommon.baseUrl}/tasks/v1/lists/${taskListId}/tasks`,
84
+ authentication: {
85
+ type: framework_1.AuthenticationType.BEARER_TOKEN,
86
+ token: authProp.access_token,
87
+ },
88
+ body: task,
89
+ };
90
+ return framework_1.httpClient.sendRequest(request);
91
+ });
92
+ }
93
+ exports.createTask = createTask;
94
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/google-tasks/src/lib/common/index.ts"],"names":[],"mappings":";;;;AAAA,uDAAiI;AAEjI,IAAY,UAGX;AAHD,WAAY,UAAU;IAClB,0CAA4B,CAAA;IAC5B,qCAAuB,CAAA;AAC3B,CAAC,EAHW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAGrB;AA6CY,QAAA,iBAAiB,GAAG;IAC7B,OAAO,EAAE,8BAA8B;IACvC,cAAc,EAAE,oBAAQ,CAAC,MAAM,CAAC;QAC5B,WAAW,EAAE,EAAE;QACf,WAAW,EAAE,gBAAgB;QAC7B,OAAO,EAAE,2CAA2C;QACpD,QAAQ,EAAE,qCAAqC;QAC/C,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,CAAC,uCAAuC,CAAC;KACnD,CAAC;IAEF;;OAEG;IACH,SAAS,EAAE,oBAAQ,CAAC,QAAQ,CAAS;QACjC,WAAW,EAAE,YAAY;QACzB,UAAU,EAAE,CAAC,gBAAgB,CAAC;QAC9B,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,CAAO,UAAU,EAAE,EAAE;YAC1B,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;gBAC/B,OAAO;oBACH,QAAQ,EAAE,IAAI;oBACd,WAAW,EAAE,mCAAmC;oBAChD,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