@pipedream/connectwise_psa 0.2.1 → 0.3.0

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.
@@ -4,7 +4,12 @@ export default {
4
4
  key: "connectwise_psa-create-company",
5
5
  name: "Create Company",
6
6
  description: "Creates a new company in Connectwise. [See the documentation](https://developer.connectwise.com/Products/ConnectWise_PSA/REST#/Companies/postCompanyCompanies)",
7
- version: "0.0.1",
7
+ version: "0.0.4",
8
+ annotations: {
9
+ destructiveHint: false,
10
+ openWorldHint: true,
11
+ readOnlyHint: false,
12
+ },
8
13
  type: "action",
9
14
  props: {
10
15
  connectwise,
@@ -5,7 +5,12 @@ export default {
5
5
  key: "connectwise_psa-create-contact",
6
6
  name: "Create Contact",
7
7
  description: "Creates a new contact in Connectwise. [See the documentation](https://developer.connectwise.com/Products/ConnectWise_PSA/REST#/Contacts/postCompanyContacts)",
8
- version: "0.1.0",
8
+ version: "0.1.3",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: false,
13
+ },
9
14
  type: "action",
10
15
  props: {
11
16
  connectwise,
@@ -4,7 +4,12 @@ export default {
4
4
  key: "connectwise_psa-create-ticket",
5
5
  name: "Create Ticket",
6
6
  description: "Creates a new ticket in Connectwise. [See the documentation](https://developer.connectwise.com/Products/ConnectWise_PSA/REST#/Tickets/postServiceTickets)",
7
- version: "0.1.0",
7
+ version: "0.1.3",
8
+ annotations: {
9
+ destructiveHint: false,
10
+ openWorldHint: true,
11
+ readOnlyHint: false,
12
+ },
8
13
  type: "action",
9
14
  props: {
10
15
  connectwise,
@@ -0,0 +1,47 @@
1
+ import app from "../../connectwise_psa.app.mjs";
2
+
3
+ export default {
4
+ key: "connectwise_psa-get-ticket",
5
+ name: "Get Ticket",
6
+ description: "Retrieves details of a specific ticket. [See the documentation](https://developer.connectwise.com/Products/ConnectWise_PSA/REST#/Tickets/getServiceTicketsById)",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ props: {
15
+ app,
16
+ ticketId: {
17
+ propDefinition: [
18
+ app,
19
+ "ticketId",
20
+ ],
21
+ },
22
+ fields: {
23
+ type: "string",
24
+ label: "Fields",
25
+ description: "Comma-separated list of fields to return. E.g., `id,summary,status,company`",
26
+ optional: true,
27
+ },
28
+ },
29
+ async run({ $ }) {
30
+ const {
31
+ app,
32
+ ticketId,
33
+ fields,
34
+ } = this;
35
+
36
+ const response = await app.getTicket({
37
+ $,
38
+ ticketId,
39
+ params: {
40
+ fields,
41
+ },
42
+ });
43
+
44
+ $.export("$summary", `Successfully retrieved ticket with ID \`${ticketId}\``);
45
+ return response;
46
+ },
47
+ };
@@ -0,0 +1,71 @@
1
+ import app from "../../connectwise_psa.app.mjs";
2
+
3
+ export default {
4
+ key: "connectwise_psa-list-reports",
5
+ name: "List Reports",
6
+ description: "Retrieves a list of available reports. [See the documentation](https://developer.connectwise.com/Products/ConnectWise_PSA/REST#/Reports/getSystemReports)",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ props: {
15
+ app,
16
+ conditions: {
17
+ type: "string",
18
+ label: "Conditions",
19
+ description: "Conditions to filter the reports. E.g., `name contains \"Sales\"`. [See the documentation](https://developer.connectwise.com/Products/ConnectWise_PSA/Developer_Guide) for more information.",
20
+ optional: true,
21
+ },
22
+ orderBy: {
23
+ type: "string",
24
+ label: "Order By",
25
+ description: "Field to order results by. E.g., `name asc` or `id desc`",
26
+ optional: true,
27
+ },
28
+ fields: {
29
+ type: "string",
30
+ label: "Fields",
31
+ description: "Comma-separated list of fields to return. E.g., `id,name,reportUrl`",
32
+ optional: true,
33
+ },
34
+ pageSize: {
35
+ type: "integer",
36
+ label: "Page Size",
37
+ description: "Number of results to return per page (max 1000)",
38
+ optional: true,
39
+ },
40
+ page: {
41
+ type: "integer",
42
+ label: "Page",
43
+ description: "Page number to retrieve (1-based)",
44
+ optional: true,
45
+ },
46
+ },
47
+ async run({ $ }) {
48
+ const {
49
+ app,
50
+ conditions,
51
+ orderBy,
52
+ fields,
53
+ pageSize,
54
+ page,
55
+ } = this;
56
+
57
+ const response = await app.listReports({
58
+ $,
59
+ params: {
60
+ conditions,
61
+ orderBy,
62
+ fields,
63
+ pageSize,
64
+ page,
65
+ },
66
+ });
67
+
68
+ $.export("$summary", `Successfully retrieved \`${response.length}\` report(s)`);
69
+ return response;
70
+ },
71
+ };
@@ -0,0 +1,71 @@
1
+ import app from "../../connectwise_psa.app.mjs";
2
+
3
+ export default {
4
+ key: "connectwise_psa-list-tickets",
5
+ name: "List Tickets",
6
+ description: "Retrieves a list of tickets. [See the documentation](https://developer.connectwise.com/Products/ConnectWise_PSA/REST#/Tickets/getServiceTickets)",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ props: {
15
+ app,
16
+ conditions: {
17
+ type: "string",
18
+ label: "Conditions",
19
+ description: "Conditions to filter the tickets. E.g., `summary contains \"issue\"` or `status/name=\"New\"`. [See the documentation](https://developer.connectwise.com/Products/ConnectWise_PSA/Developer_Guide) for more information.",
20
+ optional: true,
21
+ },
22
+ orderBy: {
23
+ type: "string",
24
+ label: "Order By",
25
+ description: "Field to order results by. E.g., `id desc` or `summary asc`",
26
+ optional: true,
27
+ },
28
+ fields: {
29
+ type: "string",
30
+ label: "Fields",
31
+ description: "Comma-separated list of fields to return. E.g., `id,summary,status`",
32
+ optional: true,
33
+ },
34
+ pageSize: {
35
+ type: "integer",
36
+ label: "Page Size",
37
+ description: "Number of results to return per page (max 1000)",
38
+ optional: true,
39
+ },
40
+ page: {
41
+ type: "integer",
42
+ label: "Page",
43
+ description: "Page number to retrieve (1-based)",
44
+ optional: true,
45
+ },
46
+ },
47
+ async run({ $ }) {
48
+ const {
49
+ app,
50
+ conditions,
51
+ orderBy,
52
+ fields,
53
+ pageSize,
54
+ page,
55
+ } = this;
56
+
57
+ const response = await app.listTickets({
58
+ $,
59
+ params: {
60
+ conditions,
61
+ orderBy,
62
+ fields,
63
+ pageSize,
64
+ page,
65
+ },
66
+ });
67
+
68
+ $.export("$summary", `Successfully retrieved \`${response.length}\` ticket(s)`);
69
+ return response;
70
+ },
71
+ };
@@ -0,0 +1,73 @@
1
+ import app from "../../connectwise_psa.app.mjs";
2
+
3
+ export default {
4
+ key: "connectwise_psa-list-time-entries",
5
+ name: "List Time Entries",
6
+ description: "Retrieves a list of time entries. [See the documentation](https://developer.connectwise.com/Products/ConnectWise_PSA/REST#/TimeEntries/getTimeEntries)",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ props: {
15
+ app,
16
+ conditions: {
17
+ type: "string",
18
+ label: "Conditions",
19
+ description: "Conditions to filter the time entries. E.g., `member/identifier=\"username\"` or `chargeToId=123 AND chargeToType=\"ServiceTicket\"`. [See the documentation](https://developer.connectwise.com/Products/ConnectWise_PSA/Developer_Guide) for more information.",
20
+ optional: true,
21
+ },
22
+ orderBy: {
23
+ type: "string",
24
+ label: "Order By",
25
+ description: "Field to order results by. E.g., `id desc` or `timeStart asc`",
26
+ optional: true,
27
+ },
28
+ fields: {
29
+ type: "string",
30
+ label: "Fields",
31
+ description: "Comma-separated list of fields to return. E.g., `id,timeStart,timeEnd,member`",
32
+ optional: true,
33
+ },
34
+ pageSize: {
35
+ type: "integer",
36
+ label: "Page Size",
37
+ description: "Number of results to return per page (max 1000)",
38
+ optional: true,
39
+ },
40
+ page: {
41
+ type: "integer",
42
+ label: "Page",
43
+ description: "Page number to retrieve (1-based)",
44
+ optional: true,
45
+ },
46
+ },
47
+ async run({ $ }) {
48
+ const {
49
+ app,
50
+ conditions,
51
+ orderBy,
52
+ fields,
53
+ pageSize,
54
+ page,
55
+ } = this;
56
+
57
+ const response = await app.listTimeEntries({
58
+ $,
59
+ params: {
60
+ conditions,
61
+ orderBy,
62
+ fields,
63
+ pageSize,
64
+ page,
65
+ },
66
+ });
67
+
68
+ $.export("$summary", `Successfully retrieved \`${response.length}\` time entr${response.length === 1
69
+ ? "y"
70
+ : "ies"}`);
71
+ return response;
72
+ },
73
+ };
@@ -208,6 +208,24 @@ export default {
208
208
  })) || [];
209
209
  },
210
210
  },
211
+ ticketId: {
212
+ type: "string",
213
+ label: "Ticket ID",
214
+ description: "The ID of the ticket to retrieve",
215
+ async options({ page }) {
216
+ const tickets = await this.listTickets({
217
+ params: {
218
+ page: page + 1,
219
+ },
220
+ });
221
+ return tickets?.map(({
222
+ id: value, summary: label,
223
+ }) => ({
224
+ value,
225
+ label,
226
+ })) || [];
227
+ },
228
+ },
211
229
  },
212
230
  methods: {
213
231
  _baseUrl() {
@@ -260,6 +278,26 @@ export default {
260
278
  ...opts,
261
279
  });
262
280
  },
281
+ getTicket({
282
+ ticketId, ...opts
283
+ }) {
284
+ return this._makeRequest({
285
+ path: `/service/tickets/${ticketId}`,
286
+ ...opts,
287
+ });
288
+ },
289
+ listTimeEntries(opts = {}) {
290
+ return this._makeRequest({
291
+ path: "/time/entries",
292
+ ...opts,
293
+ });
294
+ },
295
+ listReports(opts = {}) {
296
+ return this._makeRequest({
297
+ path: "/system/reports",
298
+ ...opts,
299
+ });
300
+ },
263
301
  listCompanyTypes(opts = {}) {
264
302
  return this._makeRequest({
265
303
  path: "/company/companies/types",
@@ -339,6 +377,7 @@ export default {
339
377
  resourceFn,
340
378
  params,
341
379
  max,
380
+ lastId,
342
381
  }) {
343
382
  params = {
344
383
  ...params,
@@ -350,12 +389,19 @@ export default {
350
389
  params,
351
390
  });
352
391
  for (const item of items) {
353
- yield item;
354
- count++;
355
392
  if (max && count >= max) {
356
393
  return;
357
394
  }
395
+
396
+ // orderby id desc
397
+ if (item.id <= lastId) {
398
+ return;
399
+ }
400
+
401
+ yield item;
402
+ count++;
358
403
  }
404
+
359
405
  hasMore = items.length;
360
406
  params.page++;
361
407
  } while (hasMore);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/connectwise_psa",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Pipedream Connectwise PSA Components",
5
5
  "main": "connectwise_psa.app.mjs",
6
6
  "keywords": [
@@ -13,6 +13,6 @@
13
13
  "access": "public"
14
14
  },
15
15
  "dependencies": {
16
- "@pipedream/platform": "^2.0.0"
16
+ "@pipedream/platform": "^2.0.2"
17
17
  }
18
18
  }
@@ -25,7 +25,10 @@ export default {
25
25
  this.db.set("lastId", lastId);
26
26
  },
27
27
  getParams() {
28
- return {};
28
+ return {
29
+ pageSize: 500,
30
+ orderBy: "id desc",
31
+ };
29
32
  },
30
33
  generateMeta(item) {
31
34
  return {
@@ -38,25 +41,30 @@ export default {
38
41
  const lastId = this._getLastId();
39
42
  const resourceFn = this.getResourceFn();
40
43
  const params = this.getParams();
41
- const results = this.connectwise.paginate({
44
+ const iterator = this.connectwise.paginate({
42
45
  resourceFn,
43
46
  params,
44
47
  max,
48
+ lastId,
45
49
  });
46
- let items = [];
47
- for await (const item of results) {
48
- if (item.id > lastId) {
49
- items.push(item);
50
+
51
+ const items = [];
52
+ let firstNewId;
53
+
54
+ for await (const item of iterator) {
55
+ if (!firstNewId) {
56
+ firstNewId = item.id;
50
57
  }
58
+ items.push(item);
51
59
  }
52
- if (!items.length) {
53
- return;
54
- }
55
- if (max) {
56
- items = items.slice(-1 * max);
60
+
61
+ if (firstNewId) {
62
+ this._setLastId(firstNewId);
57
63
  }
58
- this._setLastId(items[items.length - 1].id);
59
- items.forEach((item) => this.$emit(item, this.generateMeta(item)));
64
+
65
+ items
66
+ .reverse()
67
+ .forEach((item) => this.$emit(item, this.generateMeta(item)));
60
68
  },
61
69
  getResourceFn() {
62
70
  throw new Error("getResourceFn is not implemented");
@@ -6,7 +6,7 @@ export default {
6
6
  key: "connectwise_psa-new-contact-created",
7
7
  name: "New Contact Created",
8
8
  description: "Emit new event when a new contact is created in Connectwise.",
9
- version: "0.0.2",
9
+ version: "0.0.4",
10
10
  type: "source",
11
11
  dedupe: "unique",
12
12
  methods: {
@@ -6,7 +6,7 @@ export default {
6
6
  key: "connectwise_psa-new-project-created",
7
7
  name: "New Project Created",
8
8
  description: "Emit new event when a new project is created in Connectwise.",
9
- version: "0.0.2",
9
+ version: "0.0.4",
10
10
  type: "source",
11
11
  dedupe: "unique",
12
12
  methods: {
@@ -6,7 +6,7 @@ export default {
6
6
  key: "connectwise_psa-new-ticket-created",
7
7
  name: "New Ticket Created",
8
8
  description: "Emit new event when a new ticket is created in Connectwise.",
9
- version: "0.0.2",
9
+ version: "0.0.4",
10
10
  type: "source",
11
11
  dedupe: "unique",
12
12
  methods: {