@pipedream/salesforce_rest_api 1.14.0 → 1.14.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 +1 -1
- package/sources/case-updated-instant/case-updated-instant.mjs +1 -1
- package/sources/common/common-feed.mjs +22 -17
- package/sources/common/common-new-record.mjs +19 -11
- package/sources/common/common-updated-record.mjs +21 -14
- package/sources/common/common.mjs +10 -1
- package/sources/email-template-updated-instant/email-template-updated-instant.mjs +1 -1
- package/sources/knowledge-article-updated-instant/knowledge-article-updated-instant.mjs +1 -1
- package/sources/new-case-instant/new-case-instant.mjs +1 -1
- package/sources/new-email-template-instant/new-email-template-instant.mjs +1 -1
- package/sources/new-feed-comment/new-feed-comment.mjs +1 -1
- package/sources/new-feed-item/new-feed-item.mjs +1 -1
- package/sources/new-knowledge-article-instant/new-knowledge-article-instant.mjs +1 -1
- package/sources/new-record-instant/new-record-instant.mjs +1 -1
- package/sources/record-deleted-instant/record-deleted-instant.mjs +1 -1
- package/sources/record-updated-instant/record-updated-instant.mjs +1 -1
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
name: "Case Updated (Instant, of Selectable Type)",
|
|
8
8
|
key: "salesforce_rest_api-case-updated-instant",
|
|
9
9
|
description: "Emit new event when a case is updated. [See the documentation](https://sforce.co/3yPSJZy)",
|
|
10
|
-
version: "0.0.
|
|
10
|
+
version: "0.0.11",
|
|
11
11
|
props: {
|
|
12
12
|
salesforce: common.props.salesforce,
|
|
13
13
|
db: "$.service.db",
|
|
@@ -43,24 +43,29 @@ export default {
|
|
|
43
43
|
const nameField = await this.salesforce.getNameFieldForObjectType(objectType);
|
|
44
44
|
this.setNameField(nameField);
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
try {
|
|
47
|
+
const extraConditions = await this._buildExtraConditions();
|
|
48
|
+
const { records } = await this.query({
|
|
49
|
+
query: `SELECT Id FROM ${objectType} WHERE Id != null ${extraConditions} ORDER BY CreatedDate DESC LIMIT ${DEPLOY_HISTORICAL_LIMIT}`,
|
|
50
|
+
});
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
52
|
+
// Emit oldest-first so historical events are delivered chronologically,
|
|
53
|
+
// matching the timer polling path.
|
|
54
|
+
for (const record of [
|
|
55
|
+
...records,
|
|
56
|
+
].reverse()) {
|
|
57
|
+
const object = await this.salesforce.getSObject(objectType, record.Id);
|
|
58
|
+
const event = {
|
|
59
|
+
body: {
|
|
60
|
+
"New": object,
|
|
61
|
+
"UserId": record.Id,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
await this.processWebhookEvent(event);
|
|
65
|
+
}
|
|
66
|
+
} catch (err) {
|
|
67
|
+
console.log("Error seeding historical records during deploy:", err);
|
|
68
|
+
console.log("The source will still be created and will emit new records going forward.");
|
|
64
69
|
}
|
|
65
70
|
},
|
|
66
71
|
},
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import startCase from "lodash/startCase.js";
|
|
2
2
|
import { v4 as uuidv4 } from "uuid";
|
|
3
3
|
import common from "../common/common.mjs";
|
|
4
|
+
import constants from "../../common/constants.mjs";
|
|
4
5
|
|
|
5
6
|
export default {
|
|
6
7
|
...common,
|
|
@@ -12,17 +13,24 @@ export default {
|
|
|
12
13
|
this.setNameField(nameField);
|
|
13
14
|
|
|
14
15
|
// emit historical events
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
try {
|
|
17
|
+
const { records } = await this.query({
|
|
18
|
+
query: `SELECT Id FROM ${objectType} ORDER BY ${constants.FIELD_NAME.CREATED_DATE} DESC LIMIT ${constants.DEPLOY_HISTORICAL_LIMIT}`,
|
|
19
|
+
});
|
|
20
|
+
const ids = records.map((r) => r.Id);
|
|
21
|
+
for (const id of ids.slice(-constants.DEPLOY_HISTORICAL_LIMIT).reverse()) {
|
|
22
|
+
const object = await this.salesforce.getSObject(objectType, id);
|
|
23
|
+
const event = {
|
|
24
|
+
body: {
|
|
25
|
+
"New": object,
|
|
26
|
+
"UserId": id,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
this.processWebhookEvent(event);
|
|
30
|
+
}
|
|
31
|
+
} catch (err) {
|
|
32
|
+
console.log("Error seeding historical records during deploy:", err);
|
|
33
|
+
console.log("The source will still be created and will emit new records going forward.");
|
|
26
34
|
}
|
|
27
35
|
},
|
|
28
36
|
async activate() {
|
|
@@ -13,20 +13,27 @@ export default {
|
|
|
13
13
|
this.setNameField(nameField);
|
|
14
14
|
|
|
15
15
|
if (!this.skipFirstRun) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
try {
|
|
17
|
+
const { records } = await this.query({
|
|
18
|
+
query: `SELECT Id FROM ${objectType} ORDER BY ${constants.FIELD_NAME.LAST_MODIFIED_DATE} DESC LIMIT ${constants.DEPLOY_HISTORICAL_LIMIT}`,
|
|
19
|
+
});
|
|
20
|
+
const ids = records.map((r) => r.Id);
|
|
21
|
+
|
|
22
|
+
for (const id of ids.slice(-constants.DEPLOY_HISTORICAL_LIMIT).reverse()) {
|
|
23
|
+
const object = await this.salesforce.getSObject(objectType, id);
|
|
24
|
+
|
|
25
|
+
const event = {
|
|
26
|
+
body: {
|
|
27
|
+
"New": object,
|
|
28
|
+
"UserId": id,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
const meta = this.generateWebhookMeta(event);
|
|
32
|
+
this.$emit(event.body, meta);
|
|
33
|
+
}
|
|
34
|
+
} catch (err) {
|
|
35
|
+
console.log("Error seeding historical records during deploy:", err);
|
|
36
|
+
console.log("The source will still be created and will emit updated records going forward.");
|
|
30
37
|
}
|
|
31
38
|
}
|
|
32
39
|
},
|
|
@@ -89,9 +89,18 @@ export default {
|
|
|
89
89
|
this.db.set("latestDateCovered", latestDateCovered);
|
|
90
90
|
},
|
|
91
91
|
getNameField() {
|
|
92
|
-
|
|
92
|
+
// Cache in memory for the lifetime of this execution. The deploy hook emits
|
|
93
|
+
// up to DEPLOY_HISTORICAL_LIMIT historical events, each building meta via
|
|
94
|
+
// getNameField(); without this the db is read once per event (e.g. 25x).
|
|
95
|
+
if (this._nameField === undefined) {
|
|
96
|
+
this._nameField = this.db.get("nameField");
|
|
97
|
+
}
|
|
98
|
+
return this._nameField;
|
|
93
99
|
},
|
|
94
100
|
setNameField(nameField) {
|
|
101
|
+
// Keep the in-memory cache coherent with the persisted value so a read after
|
|
102
|
+
// a write doesn't fall back to db.get.
|
|
103
|
+
this._nameField = nameField;
|
|
95
104
|
this.db.set("nameField", nameField);
|
|
96
105
|
},
|
|
97
106
|
processTimerEvent() {
|
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
name: "Email Template Updated (Instant, of Selectable Type)",
|
|
8
8
|
key: "salesforce_rest_api-email-template-updated-instant",
|
|
9
9
|
description: "Emit new event when an email template is updated. [See the documentation](https://sforce.co/3yPSJZy)",
|
|
10
|
-
version: "0.0.
|
|
10
|
+
version: "0.0.11",
|
|
11
11
|
props: {
|
|
12
12
|
salesforce: common.props.salesforce,
|
|
13
13
|
db: "$.service.db",
|
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
name: "Knowledge Article Updated (Instant, of Selectable Type)",
|
|
8
8
|
key: "salesforce_rest_api-knowledge-article-updated-instant",
|
|
9
9
|
description: "Emit new event when a knowledge article is updated. [See the documentation](https://sforce.co/3yPSJZy)",
|
|
10
|
-
version: "0.0.
|
|
10
|
+
version: "0.0.11",
|
|
11
11
|
props: {
|
|
12
12
|
salesforce: common.props.salesforce,
|
|
13
13
|
db: "$.service.db",
|
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
name: "New Case (Instant, of Selectable Type)",
|
|
8
8
|
key: "salesforce_rest_api-new-case-instant",
|
|
9
9
|
description: "Emit new event when a case is created. [See the documentation](https://sforce.co/3yPSJZy)",
|
|
10
|
-
version: "0.0.
|
|
10
|
+
version: "0.0.11",
|
|
11
11
|
props: {
|
|
12
12
|
salesforce: common.props.salesforce,
|
|
13
13
|
db: "$.service.db",
|
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
name: "New Email Template (Instant, of Selectable Type)",
|
|
8
8
|
key: "salesforce_rest_api-new-email-template-instant",
|
|
9
9
|
description: "Emit new event when an email template is created. [See the documentation](https://sforce.co/3yPSJZy)",
|
|
10
|
-
version: "0.0.
|
|
10
|
+
version: "0.0.11",
|
|
11
11
|
props: {
|
|
12
12
|
salesforce: common.props.salesforce,
|
|
13
13
|
db: "$.service.db",
|
|
@@ -12,7 +12,7 @@ export default {
|
|
|
12
12
|
name: "New Chatter Feed Comment (Instant or Polling)",
|
|
13
13
|
key: "salesforce_rest_api-new-feed-comment",
|
|
14
14
|
description: "Emit new events for each Chatter FeedComment (reply) created in Salesforce, polling `FeedComment` via SOQL on `CreatedDate`. Use this to react to comments on Chatter posts, since Chatter activity does not update the parent record's `LastModifiedDate`. The payload includes both `ParentId` (a polymorphic reference to the feed's parent - either a record feed, e.g. a Case ID starting with `500`, or a User feed) and `FeedItemId` (the ID of the FeedItem the comment belongs to) - these are distinct fields; do not confuse them. Set `parentObjectType` to a parent object API name (e.g. `Case`) to append `AND Parent.Type = '<value>'` to the SOQL WHERE clause. Set `excludeSelf` to `true` to drop comments authored by the connected integration user. Note: querying FeedComment without a parent filter requires the `View All Data` permission on the connected user. Attempts instant delivery via webhook and falls back to timer polling automatically. [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_feedcomment.htm)",
|
|
15
|
-
version: "0.0.
|
|
15
|
+
version: "0.0.3",
|
|
16
16
|
props: {
|
|
17
17
|
...common.props,
|
|
18
18
|
parentObjectType: {
|
|
@@ -12,7 +12,7 @@ export default {
|
|
|
12
12
|
name: "New Chatter Feed Item (Instant or Polling)",
|
|
13
13
|
key: "salesforce_rest_api-new-feed-item",
|
|
14
14
|
description: "Emit new events for each Chatter FeedItem (post) created in Salesforce, polling `FeedItem` via SOQL on `CreatedDate`. Use this to react to Chatter posts on Cases and other records, since Chatter activity does not update the parent record's `LastModifiedDate` (so **New Record (Instant, of Selectable Type)** and **New Case (Instant, of Selectable Type)** never emit for it). Set `parentObjectType` to the parent object's API name (e.g. `Case`, `Opportunity`) to only emit posts whose parent record is of that type. Set `excludeSelf` to `true` to drop posts authored by the connected integration user. Note: `Body` is null for system-generated post types (e.g. `TrackedChange`). Attempts instant delivery via webhook and falls back to timer polling automatically when the Streaming API does not support this object. [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_feeditem.htm)",
|
|
15
|
-
version: "0.0.
|
|
15
|
+
version: "0.0.3",
|
|
16
16
|
props: {
|
|
17
17
|
...common.props,
|
|
18
18
|
parentObjectType: {
|
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
name: "New Knowledge Article (Instant, of Selectable Type)",
|
|
8
8
|
key: "salesforce_rest_api-new-knowledge-article-instant",
|
|
9
9
|
description: "Emit new event when a knowledge article is created. [See the documentation](https://sforce.co/3yPSJZy)",
|
|
10
|
-
version: "0.0.
|
|
10
|
+
version: "0.0.11",
|
|
11
11
|
props: {
|
|
12
12
|
salesforce: common.props.salesforce,
|
|
13
13
|
db: "$.service.db",
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
name: "New Record (Instant, of Selectable Type)",
|
|
7
7
|
key: "salesforce_rest_api-new-record-instant",
|
|
8
8
|
description: "Emit new event when a record of the selected object type is created. [See the documentation](https://sforce.co/3yPSJZy)",
|
|
9
|
-
version: "0.2.
|
|
9
|
+
version: "0.2.11",
|
|
10
10
|
props: {
|
|
11
11
|
...common.props,
|
|
12
12
|
fieldsToObtain: {
|
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
name: "New Deleted Record (Instant, of Selectable Type)",
|
|
8
8
|
key: "salesforce_rest_api-record-deleted-instant",
|
|
9
9
|
description: "Emit new event when a record of the selected object type is deleted. [See the documentation](https://sforce.co/3msDDEE)",
|
|
10
|
-
version: "0.1.
|
|
10
|
+
version: "0.1.10",
|
|
11
11
|
methods: {
|
|
12
12
|
...common.methods,
|
|
13
13
|
generateWebhookMeta(data) {
|
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
name: "New Updated Record (Instant, of Selectable Type)",
|
|
8
8
|
key: "salesforce_rest_api-record-updated-instant",
|
|
9
9
|
description: "Emit new event when a record of the selected type is updated. [See the documentation](https://sforce.co/3yPSJZy)",
|
|
10
|
-
version: "0.2.
|
|
10
|
+
version: "0.2.11",
|
|
11
11
|
props: {
|
|
12
12
|
...common.props,
|
|
13
13
|
fields: {
|