@pipedream/connectwise_psa 0.2.0 → 0.2.2

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.3",
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.2",
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.2",
8
+ annotations: {
9
+ destructiveHint: false,
10
+ openWorldHint: true,
11
+ readOnlyHint: false,
12
+ },
8
13
  type: "action",
9
14
  props: {
10
15
  connectwise,
@@ -339,6 +339,7 @@ export default {
339
339
  resourceFn,
340
340
  params,
341
341
  max,
342
+ lastId,
342
343
  }) {
343
344
  params = {
344
345
  ...params,
@@ -350,12 +351,19 @@ export default {
350
351
  params,
351
352
  });
352
353
  for (const item of items) {
353
- yield item;
354
- count++;
355
354
  if (max && count >= max) {
356
355
  return;
357
356
  }
357
+
358
+ // orderby id desc
359
+ if (item.id <= lastId) {
360
+ return;
361
+ }
362
+
363
+ yield item;
364
+ count++;
358
365
  }
366
+
359
367
  hasMore = items.length;
360
368
  params.page++;
361
369
  } while (hasMore);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/connectwise_psa",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Pipedream Connectwise PSA Components",
5
5
  "main": "connectwise_psa.app.mjs",
6
6
  "keywords": [
@@ -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,24 +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,
47
+ max,
48
+ lastId,
44
49
  });
45
- let items = [];
46
- for await (const item of results) {
47
- if (item.id > lastId) {
48
- 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;
49
57
  }
58
+ items.push(item);
50
59
  }
51
- if (!items.length) {
52
- return;
53
- }
54
- if (max) {
55
- items = items.slice(-1 * max);
60
+
61
+ if (firstNewId) {
62
+ this._setLastId(firstNewId);
56
63
  }
57
- this._setLastId(items[items.length - 1].id);
58
- items.forEach((item) => this.$emit(item, this.generateMeta(item)));
64
+
65
+ items
66
+ .reverse()
67
+ .forEach((item) => this.$emit(item, this.generateMeta(item)));
59
68
  },
60
69
  getResourceFn() {
61
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.1",
9
+ version: "0.0.3",
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.1",
9
+ version: "0.0.3",
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.1",
9
+ version: "0.0.3",
10
10
  type: "source",
11
11
  dedupe: "unique",
12
12
  methods: {