@pipedream/monday 0.3.3 → 0.3.4

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.
@@ -5,7 +5,7 @@ export default {
5
5
  name: "Create Group",
6
6
  description: "Creates a new group in a specific board. [See the docs here](https://api.developer.monday.com/docs/groups-queries#create-a-group)",
7
7
  type: "action",
8
- version: "0.0.1",
8
+ version: "0.0.2",
9
9
  props: {
10
10
  monday,
11
11
  boardId: {
@@ -6,7 +6,7 @@ export default {
6
6
  name: "Create Item",
7
7
  description: "Creates an item. [See the docs here](https://api.developer.monday.com/docs/items-queries#create-an-item)",
8
8
  type: "action",
9
- version: "0.0.1",
9
+ version: "0.0.3",
10
10
  props: {
11
11
  monday,
12
12
  boardId: {
@@ -30,11 +30,17 @@ export default {
30
30
  "itemName",
31
31
  ],
32
32
  },
33
- columnValues: {
33
+ columns: {
34
34
  propDefinition: [
35
35
  monday,
36
- "itemColumnValues",
36
+ "column",
37
+ (c) => ({
38
+ boardId: c.boardId,
39
+ }),
37
40
  ],
41
+ type: "string[]",
42
+ description: "Select columns to fill",
43
+ reloadProps: true,
38
44
  },
39
45
  createLabels: {
40
46
  propDefinition: [
@@ -43,7 +49,37 @@ export default {
43
49
  ],
44
50
  },
45
51
  },
52
+ async additionalProps() {
53
+ const props = {};
54
+ if (!this.columns) {
55
+ return props;
56
+ }
57
+ for (const column of this.columns) {
58
+ let description;
59
+ if (column === "status") {
60
+ description = "Value for status. [Status Index Value Map](https://view.monday.com/1073554546-ad9f20a427a16e67ded630108994c11b?r=use1)";
61
+ } else if (column === "person") {
62
+ description = "The ID of the person/user to add to item";
63
+ } else if (column === "date4") {
64
+ description = "Enter date of item in YYYY-MM-DD format. Eg. `2022-09-02`";
65
+ } else {
66
+ description = `Value for column ${column}`;
67
+ }
68
+ props[column] = {
69
+ type: "string",
70
+ label: column,
71
+ description,
72
+ };
73
+ }
74
+ return props;
75
+ },
46
76
  async run({ $ }) {
77
+ const columnValues = {};
78
+ if (this.columns?.length > 0) {
79
+ for (const column of this.columns) {
80
+ columnValues[column] = this[column];
81
+ }
82
+ }
47
83
  const {
48
84
  data,
49
85
  errors,
@@ -53,7 +89,7 @@ export default {
53
89
  boardId: +this.boardId,
54
90
  groupId: utils.emptyStrToUndefined(this.groupId),
55
91
  itemName: utils.emptyStrToUndefined(this.itemName),
56
- columnValues: utils.strinfied(this.columnValues),
92
+ columnValues: utils.strinfied(columnValues),
57
93
  createLabels: utils.emptyStrToUndefined(this.createLabels),
58
94
  });
59
95
 
@@ -6,7 +6,7 @@ export default {
6
6
  name: "Create an Update",
7
7
  description: "Creates a new update. [See the docs here](https://api.developer.monday.com/docs/updates-queries#create-an-update)",
8
8
  type: "action",
9
- version: "0.0.1",
9
+ version: "0.0.3",
10
10
  props: {
11
11
  monday,
12
12
  updateBody: {
@@ -5,7 +5,7 @@ export default {
5
5
  name: "Update Item Name",
6
6
  description: "Update an item's name. [See the docs here](https://api.developer.monday.com/docs/item-name)",
7
7
  type: "action",
8
- version: "0.0.1",
8
+ version: "0.0.3",
9
9
  props: {
10
10
  monday,
11
11
  boardId: {
@@ -80,4 +80,34 @@ export default {
80
80
  }
81
81
  }
82
82
  `,
83
+ createWebhook: `
84
+ mutation createWebhook (
85
+ $boardId: Int!
86
+ $url: String!
87
+ $event: WebhookEventType!
88
+ $config: JSON
89
+ ) {
90
+ create_webhook(
91
+ board_id: $boardId
92
+ url: $url
93
+ event: $event
94
+ config: $config
95
+ ) {
96
+ id
97
+ board_id
98
+ }
99
+ }
100
+ `,
101
+ deleteWebhook: `
102
+ mutation deleteWebhook (
103
+ $id: Int!
104
+ ) {
105
+ delete_webhook(
106
+ id: $id
107
+ ) {
108
+ id
109
+ board_id
110
+ }
111
+ }
112
+ `,
83
113
  };
@@ -40,7 +40,9 @@ export default {
40
40
  listItemsBoard: `
41
41
  query listItems ($boardId: Int!) {
42
42
  boards (ids: [$boardId]) {
43
- items {
43
+ items (
44
+ newest_first: true
45
+ ) {
44
46
  id
45
47
  name
46
48
  }
@@ -62,4 +64,116 @@ export default {
62
64
  }
63
65
  }
64
66
  `,
67
+ listColumns: `
68
+ query listColumns ($boardId: Int!) {
69
+ boards (ids: [$boardId]) {
70
+ columns {
71
+ id
72
+ title
73
+ }
74
+ }
75
+ }
76
+ `,
77
+ listUsers: `
78
+ query {
79
+ users (
80
+ newest_first: true
81
+ ) {
82
+ id
83
+ name
84
+ created_at
85
+ }
86
+ }
87
+ `,
88
+ getItem: `
89
+ query getItem ($id: Int!) {
90
+ items (ids: [$id]) {
91
+ id
92
+ name
93
+ board {
94
+ id
95
+ }
96
+ group {
97
+ id
98
+ }
99
+ created_at
100
+ creator_id
101
+ updated_at
102
+ parent_item {
103
+ id
104
+ }
105
+ column_values {
106
+ id
107
+ value
108
+ }
109
+ email
110
+ }
111
+ }
112
+ `,
113
+ getBoard: `
114
+ query getBoard($id: Int!) {
115
+ boards (ids: [$id]) {
116
+ id
117
+ name
118
+ board_folder_id
119
+ columns {
120
+ id
121
+ }
122
+ description
123
+ groups {
124
+ id
125
+ }
126
+ items {
127
+ id
128
+ }
129
+ owner {
130
+ id
131
+ }
132
+ permissions
133
+ tags {
134
+ id
135
+ }
136
+ type
137
+ updated_at
138
+ workspace_id
139
+ }
140
+ }
141
+ `,
142
+ getUser: `
143
+ query getUser($id: Int!) {
144
+ users (ids: [$id]) {
145
+ id
146
+ name
147
+ account {
148
+ id
149
+ }
150
+ birthday
151
+ country_code
152
+ created_at
153
+ join_date
154
+ email
155
+ is_admin
156
+ is_guest
157
+ is_pending
158
+ is_view_only
159
+ is_verified
160
+ location
161
+ mobile_phone
162
+ phone
163
+ photo_original
164
+ photo_small
165
+ photo_thumb
166
+ photo_thumb_small
167
+ photo_tiny
168
+ teams {
169
+ id
170
+ }
171
+ time_zone_identifier
172
+ title
173
+ url
174
+ utc_hours_diff
175
+ current_language
176
+ }
177
+ }
178
+ `,
65
179
  };
package/monday.app.mjs CHANGED
@@ -11,7 +11,7 @@ export default {
11
11
  app: "monday",
12
12
  propDefinitions: {
13
13
  boardId: {
14
- type: "integer",
14
+ type: "string",
15
15
  label: "Board ID",
16
16
  description: "The board's unique identifier",
17
17
  async options({ page }) {
@@ -91,7 +91,7 @@ export default {
91
91
  description: "The update text",
92
92
  },
93
93
  itemId: {
94
- type: "integer",
94
+ type: "string",
95
95
  label: "Item ID",
96
96
  description: "The item's unique identifier",
97
97
  optional: true,
@@ -102,7 +102,7 @@ export default {
102
102
  },
103
103
  },
104
104
  updateId: {
105
- type: "integer",
105
+ type: "string",
106
106
  label: "Update ID",
107
107
  description: "The update's unique identifier",
108
108
  optional: true,
@@ -115,6 +115,22 @@ export default {
115
115
  });
116
116
  },
117
117
  },
118
+ column: {
119
+ type: "string",
120
+ label: "Column",
121
+ description: "Column to watch for changes",
122
+ async options({ boardId }) {
123
+ const columns = await this.listColumns({
124
+ boardId: +boardId,
125
+ });
126
+ return columns
127
+ .filter((column) => column.id !== "name")
128
+ .map((column) => ({
129
+ label: column.title,
130
+ value: column.id,
131
+ }));
132
+ },
133
+ },
118
134
  },
119
135
  methods: {
120
136
  async makeRequest({
@@ -124,6 +140,49 @@ export default {
124
140
  monday.setToken(this.$auth.api_key);
125
141
  return monday.api(query, options);
126
142
  },
143
+ async createWebhook(variables) {
144
+ return this.makeRequest({
145
+ query: mutations.createWebhook,
146
+ options: {
147
+ variables,
148
+ },
149
+ });
150
+ },
151
+ async deleteWebhook(variables) {
152
+ return this.makeRequest({
153
+ query: mutations.deleteWebhook,
154
+ options: {
155
+ variables,
156
+ },
157
+ });
158
+ },
159
+ async getItem(variables) {
160
+ const { data } = await this.makeRequest({
161
+ query: queries.getItem,
162
+ options: {
163
+ variables,
164
+ },
165
+ });
166
+ return data?.items[0];
167
+ },
168
+ async getBoard(variables) {
169
+ const { data } = await this.makeRequest({
170
+ query: queries.getBoard,
171
+ options: {
172
+ variables,
173
+ },
174
+ });
175
+ return data?.boards[0];
176
+ },
177
+ async getUser(variables) {
178
+ const { data } = await this.makeRequest({
179
+ query: queries.getUser,
180
+ options: {
181
+ variables,
182
+ },
183
+ });
184
+ return data?.users[0];
185
+ },
127
186
  async createBoard(variables) {
128
187
  return this.makeRequest({
129
188
  query: mutations.createBoard,
@@ -201,6 +260,24 @@ export default {
201
260
  },
202
261
  });
203
262
  },
263
+ async listColumns(variables) {
264
+ const { data } = await this.makeRequest({
265
+ query: queries.listColumns,
266
+ options: {
267
+ variables,
268
+ },
269
+ });
270
+ return data?.boards[0]?.columns;
271
+ },
272
+ async listUsers(variables) {
273
+ const { data } = await this.makeRequest({
274
+ query: queries.listUsers,
275
+ options: {
276
+ variables,
277
+ },
278
+ });
279
+ return data?.users;
280
+ },
204
281
  async listBoardsOptions(variables) {
205
282
  const {
206
283
  data,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/monday",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "Pipedream Monday Components",
5
5
  "main": "monday.app.mjs",
6
6
  "keywords": [
@@ -0,0 +1,19 @@
1
+ import common from "../common/common-webhook.mjs";
2
+
3
+ export default {
4
+ ...common,
5
+ key: "monday-column-value-updated",
6
+ name: "Column Value Updated",
7
+ description: "Emit new event when a column value is updated on a board in Monday. For changes to Name, use the Name Updated Trigger.",
8
+ type: "source",
9
+ version: "0.0.1",
10
+ dedupe: "unique",
11
+ methods: {
12
+ ...common.methods,
13
+ getWebhookArgs() {
14
+ return {
15
+ event: "change_column_value",
16
+ };
17
+ },
18
+ },
19
+ };
@@ -0,0 +1,31 @@
1
+ import monday from "../../monday.app.mjs";
2
+
3
+ export default {
4
+ props: {
5
+ monday,
6
+ db: "$.service.db",
7
+ timer: {
8
+ label: "Polling interval",
9
+ description: "Pipedream will poll the Monday API on this schedule",
10
+ type: "$.interface.timer",
11
+ default: {
12
+ intervalSeconds: 60 * 15, // every 15 minutes
13
+ },
14
+ },
15
+ },
16
+ methods: {
17
+ _getLastId() {
18
+ return this.db.get("lastId") || 0;
19
+ },
20
+ _setLastId(lastId) {
21
+ this.db.set("lastId", lastId);
22
+ },
23
+ emitEvent(item) {
24
+ const meta = this.generateMeta(item);
25
+ this.$emit(item, meta);
26
+ },
27
+ generateMeta() {
28
+ throw new Error("generateMeta is not implemented");
29
+ },
30
+ },
31
+ };
@@ -0,0 +1,93 @@
1
+ import monday from "../../monday.app.mjs";
2
+
3
+ export default {
4
+ props: {
5
+ monday,
6
+ db: "$.service.db",
7
+ http: {
8
+ type: "$.interface.http",
9
+ customResponse: true,
10
+ },
11
+ boardId: {
12
+ propDefinition: [
13
+ monday,
14
+ "boardId",
15
+ ],
16
+ },
17
+ },
18
+ hooks: {
19
+ async deploy() {
20
+ const { items } = (await this.monday.listItemsBoard({
21
+ boardId: +this.boardId,
22
+ })).data.boards[0];
23
+ for (const item of items.slice(-25).reverse()) {
24
+ const itemData = await this.monday.getItem({
25
+ id: +item.id,
26
+ });
27
+ const meta = this.generateMeta(item);
28
+ this.$emit(itemData, meta);
29
+ }
30
+ },
31
+ async activate() {
32
+ const args = this.getWebhookArgs();
33
+ const { data } = await this.monday.createWebhook({
34
+ boardId: +this.boardId,
35
+ url: this.http.endpoint,
36
+ ...args,
37
+ });
38
+ const hookId = data?.create_webhook?.id;
39
+ if (!hookId) {
40
+ throw new Error ("Failed to establish webhook");
41
+ }
42
+ this._setHookId(data.create_webhook.id);
43
+ },
44
+ async deactivate() {
45
+ const hookId = this._getHookId();
46
+ await this.monday.deleteWebhook({
47
+ id: hookId,
48
+ });
49
+ },
50
+ },
51
+ methods: {
52
+ _getHookId() {
53
+ return this.db.get("hookId");
54
+ },
55
+ _setHookId(hookId) {
56
+ this.db.set("hookId", hookId);
57
+ },
58
+ getWebhookArgs() {
59
+ throw new Error("getEventType is not implemented");
60
+ },
61
+ generateMeta(item) {
62
+ return {
63
+ id: `${item.id}_${item.updated_at}`,
64
+ summary: item.name,
65
+ ts: Date.parse(item.updated_at),
66
+ };
67
+ },
68
+ },
69
+ async run(event) {
70
+ const { body } = event;
71
+
72
+ // verify the webhook
73
+ if (body?.challenge) {
74
+ await this.http.respond({
75
+ status: 200,
76
+ body,
77
+ });
78
+ return;
79
+ }
80
+
81
+ const itemId = body?.event?.pulseId;
82
+ if (!itemId) {
83
+ return;
84
+ }
85
+
86
+ const updatedItem = await this.monday.getItem({
87
+ id: itemId,
88
+ });
89
+
90
+ const meta = this.generateMeta(updatedItem);
91
+ this.$emit(updatedItem, meta);
92
+ },
93
+ };
@@ -0,0 +1,19 @@
1
+ import common from "../common/common-webhook.mjs";
2
+
3
+ export default {
4
+ ...common,
5
+ key: "monday-name-updated",
6
+ name: "Name Updated",
7
+ description: "Emit new event when an item's Name is updated on a board in Monday.",
8
+ type: "source",
9
+ version: "0.0.1",
10
+ dedupe: "unique",
11
+ methods: {
12
+ ...common.methods,
13
+ getWebhookArgs() {
14
+ return {
15
+ event: "change_name",
16
+ };
17
+ },
18
+ },
19
+ };
@@ -0,0 +1,63 @@
1
+ import common from "../common/common-polling.mjs";
2
+
3
+ export default {
4
+ ...common,
5
+ key: "monday-new-board",
6
+ name: "New Board",
7
+ description: "Emit new event when a new board is created in Monday.",
8
+ type: "source",
9
+ version: "0.0.1",
10
+ dedupe: "unique",
11
+ props: {
12
+ ...common.props,
13
+ maxRequests: {
14
+ type: "integer",
15
+ min: 1,
16
+ label: "Max API Requests per Execution",
17
+ description: "The maximum number of API requests to make per execution (e.g., multiple requests are required to retrieve paginated results)",
18
+ optional: true,
19
+ default: 1,
20
+ },
21
+ },
22
+ methods: {
23
+ ...common.methods,
24
+ generateMeta(board) {
25
+ return {
26
+ id: board.id,
27
+ summary: board.name,
28
+ ts: Date.now(),
29
+ };
30
+ },
31
+ },
32
+ async run() {
33
+ const lastId = this._getLastId();
34
+
35
+ let maxId = lastId;
36
+ let done = false;
37
+ let page = 1;
38
+ do {
39
+ const { boards } = (await this.monday.listBoards({
40
+ page,
41
+ })).data;
42
+ for (const board of boards) {
43
+ if (+board.id <= lastId) {
44
+ done = true;
45
+ break;
46
+ }
47
+ if (+board.id > maxId) {
48
+ maxId = +board.id;
49
+ }
50
+ const boardData = await this.monday.getBoard({
51
+ id: +board.id,
52
+ });
53
+ this.emitEvent(boardData);
54
+ }
55
+ if (boards.length === 0) {
56
+ done = true;
57
+ }
58
+ page++;
59
+ } while (!done && page <= this.maxRequests);
60
+
61
+ this._setLastId(maxId);
62
+ },
63
+ };
@@ -0,0 +1,19 @@
1
+ import common from "../common/common-webhook.mjs";
2
+
3
+ export default {
4
+ ...common,
5
+ key: "monday-new-item",
6
+ name: "New Item",
7
+ description: "Emit new event when a new item is added to a board in Monday.",
8
+ type: "source",
9
+ version: "0.0.1",
10
+ dedupe: "unique",
11
+ methods: {
12
+ ...common.methods,
13
+ getWebhookArgs() {
14
+ return {
15
+ event: "create_item",
16
+ };
17
+ },
18
+ },
19
+ };
@@ -0,0 +1,41 @@
1
+ import common from "../common/common-polling.mjs";
2
+
3
+ export default {
4
+ ...common,
5
+ key: "monday-new-user",
6
+ name: "New User",
7
+ description: "Emit new event when a new user is created in Monday.",
8
+ type: "source",
9
+ version: "0.0.1",
10
+ dedupe: "unique",
11
+ methods: {
12
+ ...common.methods,
13
+ generateMeta(user) {
14
+ return {
15
+ id: user.id,
16
+ summary: user.name,
17
+ ts: Date.parse(user.created_at),
18
+ };
19
+ },
20
+ },
21
+ async run() {
22
+ const lastId = this._getLastId();
23
+ let maxId = lastId;
24
+
25
+ const users = await this.monday.listUsers();
26
+ for (const user of users) {
27
+ if (+user.id <= lastId) {
28
+ break;
29
+ }
30
+ if (+user.id > maxId) {
31
+ maxId = +user.id;
32
+ }
33
+ const userData = await this.monday.getUser({
34
+ id: +user.id,
35
+ });
36
+ this.emitEvent(userData);
37
+ }
38
+
39
+ this._setLastId(maxId);
40
+ },
41
+ };
@@ -0,0 +1,34 @@
1
+ import common from "../common/common-webhook.mjs";
2
+
3
+ export default {
4
+ ...common,
5
+ key: "monday-specific-column-updated",
6
+ name: "Specific Column Updated",
7
+ description: "Emit new event when a value in the specified column is updated on a board in Monday. For changes to Name, use the Name Updated Trigger.",
8
+ type: "source",
9
+ version: "0.0.1",
10
+ dedupe: "unique",
11
+ props: {
12
+ ...common.props,
13
+ column: {
14
+ propDefinition: [
15
+ common.props.monday,
16
+ "column",
17
+ (c) => ({
18
+ boardId: c.boardId,
19
+ }),
20
+ ],
21
+ },
22
+ },
23
+ methods: {
24
+ ...common.methods,
25
+ getWebhookArgs() {
26
+ return {
27
+ event: "change_specific_column_value",
28
+ config: JSON.stringify({
29
+ columnId: this.column,
30
+ }),
31
+ };
32
+ },
33
+ },
34
+ };