@pipedream/salesforce_rest_api 1.6.1 → 1.8.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.
Files changed (59) hide show
  1. package/actions/add-contact-to-campaign/add-contact-to-campaign.mjs +1 -1
  2. package/actions/add-lead-to-campaign/add-lead-to-campaign.mjs +1 -1
  3. package/actions/common/batch-operation.mjs +86 -0
  4. package/actions/convert-soap-xml-to-json/convert-soap-xml-to-json.mjs +1 -1
  5. package/actions/create-account/create-account.mjs +1 -1
  6. package/actions/create-accounts-batch/create-accounts-batch.mjs +22 -0
  7. package/actions/create-attachment/create-attachment.mjs +1 -1
  8. package/actions/create-campaign/create-campaign.mjs +1 -1
  9. package/actions/create-case/create-case.mjs +1 -1
  10. package/actions/create-casecomment/create-casecomment.mjs +1 -1
  11. package/actions/create-contact/create-contact.mjs +1 -1
  12. package/actions/create-content-note/create-content-note.mjs +1 -1
  13. package/actions/create-event/create-event.mjs +1 -1
  14. package/actions/create-lead/create-lead.mjs +1 -1
  15. package/actions/create-note/create-note.mjs +1 -1
  16. package/actions/create-opportunities-batch/create-opportunities-batch.mjs +22 -0
  17. package/actions/create-opportunity/create-opportunity.mjs +1 -1
  18. package/actions/create-record/create-record.mjs +1 -1
  19. package/actions/create-task/create-task.mjs +1 -1
  20. package/actions/create-user/create-user.mjs +1 -1
  21. package/actions/delete-opportunity/delete-opportunity.mjs +1 -1
  22. package/actions/delete-record/delete-record.mjs +1 -1
  23. package/actions/find-records/find-records.mjs +1 -1
  24. package/actions/get-case/get-case.mjs +36 -0
  25. package/actions/get-user/get-user.mjs +34 -0
  26. package/actions/insert-blob-data/insert-blob-data.mjs +1 -1
  27. package/actions/list-case-comments/list-case-comments.mjs +32 -0
  28. package/actions/list-email-messages/list-email-messages.mjs +38 -0
  29. package/actions/list-email-templates/list-email-templates.mjs +23 -0
  30. package/actions/list-knowledge-articles/list-knowledge-articles.mjs +23 -0
  31. package/actions/post-feed-to-chatter/post-feed-to-chatter.mjs +1 -1
  32. package/actions/search-string/search-string.mjs +1 -1
  33. package/actions/send-email/send-email.mjs +60 -0
  34. package/actions/soql-search/soql-search.mjs +1 -1
  35. package/actions/sosl-search/sosl-search.mjs +1 -1
  36. package/actions/update-account/update-account.mjs +1 -1
  37. package/actions/update-accounts-batch/update-accounts-batch.mjs +22 -0
  38. package/actions/update-contact/update-contact.mjs +1 -1
  39. package/actions/update-email-template/update-email-template.mjs +81 -0
  40. package/actions/update-opportunities-batch/update-opportunities-batch.mjs +22 -0
  41. package/actions/update-opportunity/update-opportunity.mjs +1 -1
  42. package/actions/update-record/update-record.mjs +1 -1
  43. package/actions/upsert-record/upsert-record.mjs +1 -1
  44. package/package.json +1 -1
  45. package/salesforce_rest_api.app.mjs +43 -0
  46. package/sources/case-updated-instant/case-updated-instant.mjs +43 -0
  47. package/sources/common/common-new-record.mjs +157 -0
  48. package/sources/common/common-updated-record.mjs +198 -0
  49. package/sources/{common.mjs → common/common.mjs} +2 -2
  50. package/sources/email-template-updated-instant/email-template-updated-instant.mjs +43 -0
  51. package/sources/knowledge-article-updated-instant/knowledge-article-updated-instant.mjs +43 -0
  52. package/sources/new-case-instant/new-case-instant.mjs +43 -0
  53. package/sources/new-email-template-instant/new-email-template-instant.mjs +43 -0
  54. package/sources/new-knowledge-article-instant/new-knowledge-article-instant.mjs +43 -0
  55. package/sources/new-outbound-message/new-outbound-message.mjs +1 -1
  56. package/sources/new-record-instant/new-record-instant.mjs +4 -118
  57. package/sources/record-deleted-instant/record-deleted-instant.mjs +2 -2
  58. package/sources/record-updated-instant/record-updated-instant.mjs +4 -138
  59. /package/sources/{common-webhook-methods.mjs → common/common-webhook-methods.mjs} +0 -0
@@ -0,0 +1,43 @@
1
+ import common from "../common/common-updated-record.mjs";
2
+ import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
3
+
4
+ export default {
5
+ ...common,
6
+ type: "source",
7
+ name: "Knowledge Article Updated (Instant, of Selectable Type)",
8
+ key: "salesforce_rest_api-knowledge-article-updated-instant",
9
+ description: "Emit new event when a knowledge article is updated. [See the documentation](https://sforce.co/3yPSJZy)",
10
+ version: "0.0.2",
11
+ props: {
12
+ salesforce: common.props.salesforce,
13
+ db: "$.service.db",
14
+ http: {
15
+ type: "$.interface.http",
16
+ customResponse: true,
17
+ },
18
+ timer: {
19
+ type: "$.interface.timer",
20
+ description: "The timer is only used as a fallback if instant event delivery (webhook) is not available.",
21
+ default: {
22
+ intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
23
+ },
24
+ },
25
+ fieldsToObtain: {
26
+ propDefinition: [
27
+ common.props.salesforce,
28
+ "fieldsToObtain",
29
+ () => ({
30
+ objType: "KnowledgeArticle",
31
+ }),
32
+ ],
33
+ optional: true,
34
+ description: "Select the field(s) to be retrieved for the records. Only applicable if the source is running on a timer. If running on a webhook, or if not specified, all fields will be retrieved.",
35
+ },
36
+ },
37
+ methods: {
38
+ ...common.methods,
39
+ getObjectType() {
40
+ return "KnowledgeArticle";
41
+ },
42
+ },
43
+ };
@@ -0,0 +1,43 @@
1
+ import common from "../common/common-new-record.mjs";
2
+ import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
3
+
4
+ export default {
5
+ ...common,
6
+ type: "source",
7
+ name: "New Case (Instant, of Selectable Type)",
8
+ key: "salesforce_rest_api-new-case-instant",
9
+ description: "Emit new event when a case is created. [See the documentation](https://sforce.co/3yPSJZy)",
10
+ version: "0.0.2",
11
+ props: {
12
+ salesforce: common.props.salesforce,
13
+ db: "$.service.db",
14
+ http: {
15
+ type: "$.interface.http",
16
+ customResponse: true,
17
+ },
18
+ timer: {
19
+ type: "$.interface.timer",
20
+ description: "The timer is only used as a fallback if instant event delivery (webhook) is not available.",
21
+ default: {
22
+ intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
23
+ },
24
+ },
25
+ fieldsToObtain: {
26
+ propDefinition: [
27
+ common.props.salesforce,
28
+ "fieldsToObtain",
29
+ () => ({
30
+ objType: "Case",
31
+ }),
32
+ ],
33
+ optional: true,
34
+ description: "Select the field(s) to be retrieved for the records. Only applicable if the source is running on a timer. If running on a webhook, or if not specified, all fields will be retrieved.",
35
+ },
36
+ },
37
+ methods: {
38
+ ...common.methods,
39
+ getObjectType() {
40
+ return "Case";
41
+ },
42
+ },
43
+ };
@@ -0,0 +1,43 @@
1
+ import common from "../common/common-new-record.mjs";
2
+ import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
3
+
4
+ export default {
5
+ ...common,
6
+ type: "source",
7
+ name: "New Email Template (Instant, of Selectable Type)",
8
+ key: "salesforce_rest_api-new-email-template-instant",
9
+ description: "Emit new event when an email template is created. [See the documentation](https://sforce.co/3yPSJZy)",
10
+ version: "0.0.2",
11
+ props: {
12
+ salesforce: common.props.salesforce,
13
+ db: "$.service.db",
14
+ http: {
15
+ type: "$.interface.http",
16
+ customResponse: true,
17
+ },
18
+ timer: {
19
+ type: "$.interface.timer",
20
+ description: "The timer is only used as a fallback if instant event delivery (webhook) is not available.",
21
+ default: {
22
+ intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
23
+ },
24
+ },
25
+ fieldsToObtain: {
26
+ propDefinition: [
27
+ common.props.salesforce,
28
+ "fieldsToObtain",
29
+ () => ({
30
+ objType: "EmailTemplate",
31
+ }),
32
+ ],
33
+ optional: true,
34
+ description: "Select the field(s) to be retrieved for the records. Only applicable if the source is running on a timer. If running on a webhook, or if not specified, all fields will be retrieved.",
35
+ },
36
+ },
37
+ methods: {
38
+ ...common.methods,
39
+ getObjectType() {
40
+ return "EmailTemplate";
41
+ },
42
+ },
43
+ };
@@ -0,0 +1,43 @@
1
+ import common from "../common/common-new-record.mjs";
2
+ import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
3
+
4
+ export default {
5
+ ...common,
6
+ type: "source",
7
+ name: "New Knowledge Article (Instant, of Selectable Type)",
8
+ key: "salesforce_rest_api-new-knowledge-article-instant",
9
+ description: "Emit new event when a knowledge article is created. [See the documentation](https://sforce.co/3yPSJZy)",
10
+ version: "0.0.2",
11
+ props: {
12
+ salesforce: common.props.salesforce,
13
+ db: "$.service.db",
14
+ http: {
15
+ type: "$.interface.http",
16
+ customResponse: true,
17
+ },
18
+ timer: {
19
+ type: "$.interface.timer",
20
+ description: "The timer is only used as a fallback if instant event delivery (webhook) is not available.",
21
+ default: {
22
+ intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
23
+ },
24
+ },
25
+ fieldsToObtain: {
26
+ propDefinition: [
27
+ common.props.salesforce,
28
+ "fieldsToObtain",
29
+ () => ({
30
+ objType: "KnowledgeArticle",
31
+ }),
32
+ ],
33
+ optional: true,
34
+ description: "Select the field(s) to be retrieved for the records. Only applicable if the source is running on a timer. If running on a webhook, or if not specified, all fields will be retrieved.",
35
+ },
36
+ },
37
+ methods: {
38
+ ...common.methods,
39
+ getObjectType() {
40
+ return "KnowledgeArticle";
41
+ },
42
+ },
43
+ };
@@ -6,7 +6,7 @@ export default {
6
6
  name: "New Outbound Message (Instant)",
7
7
  key: "salesforce_rest_api-new-outbound-message",
8
8
  description: "Emit new event when a new outbound message is received in Salesforce.",
9
- version: "0.1.7",
9
+ version: "0.1.8",
10
10
  dedupe: "unique",
11
11
  props: {
12
12
  db: "$.service.db",
@@ -1,5 +1,4 @@
1
- import startCase from "lodash/startCase.js";
2
- import common from "../common.mjs";
1
+ import common from "../common/common-new-record.mjs";
3
2
 
4
3
  export default {
5
4
  ...common,
@@ -7,7 +6,7 @@ export default {
7
6
  name: "New Record (Instant, of Selectable Type)",
8
7
  key: "salesforce_rest_api-new-record-instant",
9
8
  description: "Emit new event when a record of the selected object type is created. [See the documentation](https://sforce.co/3yPSJZy)",
10
- version: "0.2.0",
9
+ version: "0.2.2",
11
10
  props: {
12
11
  ...common.props,
13
12
  fieldsToObtain: {
@@ -22,123 +21,10 @@ export default {
22
21
  description: "Select the field(s) to be retrieved for the records. Only applicable if the source is running on a timer. If running on a webhook, or if not specified, all fields will be retrieved.",
23
22
  },
24
23
  },
25
- hooks: {
26
- ...common.hooks,
27
- async deploy() {
28
- const objectType = this.objectType;
29
- const nameField = await this.salesforce.getNameFieldForObjectType(objectType);
30
- this.setNameField(nameField);
31
-
32
- // emit historical events
33
- const { recentItems } = await this.salesforce.listSObjectTypeIds(objectType);
34
- const ids = recentItems.map((item) => item.Id);
35
- for (const id of ids.slice(-25)) {
36
- const object = await this.salesforce.getSObject(objectType, id);
37
- const event = {
38
- body: {
39
- "New": object,
40
- "UserId": id,
41
- },
42
- };
43
- this.processWebhookEvent(event);
44
- }
45
- },
46
- },
47
24
  methods: {
48
25
  ...common.methods,
49
- generateTimerMeta(item, fieldName) {
50
- const { objectType } = this;
51
- const {
52
- CreatedDate: createdDate,
53
- [fieldName]: name,
54
- Id: id,
55
- } = item;
56
- const entityType = startCase(objectType);
57
- const summary = `New ${entityType} created: ${name ?? id}`;
58
- const ts = Date.parse(createdDate);
59
- return {
60
- id,
61
- summary,
62
- ts,
63
- };
64
- },
65
- generateWebhookMeta(data) {
66
- const nameField = this.getNameField();
67
- const { New: newObject } = data.body;
68
- const {
69
- CreatedDate: createdDate,
70
- Id: id,
71
- [nameField]: name,
72
- } = newObject;
73
- const entityType = startCase(this.objectType).toLowerCase();
74
- const summary = `New ${entityType} created: ${name ?? id}`;
75
- const ts = Date.parse(createdDate);
76
- return {
77
- id,
78
- summary,
79
- ts,
80
- };
81
- },
82
- getEventType() {
83
- return "new";
84
- },
85
- async processTimerEvent(eventData) {
86
- const {
87
- paginate,
88
- objectType,
89
- setLatestDateCovered,
90
- getObjectTypeColumns,
91
- getNameField,
92
- generateTimerMeta,
93
- $emit: emit,
94
- } = this;
95
-
96
- const {
97
- startTimestamp,
98
- endTimestamp,
99
- } = eventData;
100
-
101
- const fieldName = getNameField();
102
- const columns = getObjectTypeColumns();
103
-
104
- const events = await paginate({
105
- objectType,
106
- startTimestamp,
107
- endTimestamp,
108
- columns,
109
- });
110
-
111
- const [
112
- latestEvent,
113
- ] = events;
114
-
115
- if (latestEvent?.CreatedDate) {
116
- const latestDateCovered = new Date(latestEvent.CreatedDate);
117
- latestDateCovered.setSeconds(0);
118
- setLatestDateCovered(latestDateCovered.toISOString());
119
- }
120
-
121
- Array.from(events)
122
- .reverse()
123
- .forEach((item) => {
124
- const meta = generateTimerMeta(item, fieldName);
125
- emit(item, meta);
126
- });
127
- },
128
- async timerActivateHook() {
129
- const {
130
- objectType,
131
- getObjectTypeDescription,
132
- setObjectTypeColumns,
133
- } = this;
134
-
135
- let columns = this.fieldsToObtain;
136
- if (!columns?.length) {
137
- const { fields } = await getObjectTypeDescription(objectType);
138
- columns = fields.map(({ name }) => name);
139
- }
140
-
141
- setObjectTypeColumns(columns);
26
+ getObjectType() {
27
+ return this.objectType;
142
28
  },
143
29
  },
144
30
  };
@@ -1,5 +1,5 @@
1
1
  import startCase from "lodash/startCase.js";
2
- import common from "../common.mjs";
2
+ import common from "../common/common.mjs";
3
3
 
4
4
  export default {
5
5
  ...common,
@@ -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.0",
10
+ version: "0.1.2",
11
11
  methods: {
12
12
  ...common.methods,
13
13
  generateWebhookMeta(data) {
@@ -1,6 +1,4 @@
1
- import startCase from "lodash/startCase.js";
2
- import common from "../common.mjs";
3
- import constants from "../../common/constants.mjs";
1
+ import common from "../common/common-updated-record.mjs";
4
2
  const { salesforce } = common.props;
5
3
 
6
4
  export default {
@@ -9,7 +7,7 @@ export default {
9
7
  name: "New Updated Record (Instant, of Selectable Type)",
10
8
  key: "salesforce_rest_api-record-updated-instant",
11
9
  description: "Emit new event when a record of the selected type is updated. [See the documentation](https://sforce.co/3yPSJZy)",
12
- version: "0.2.0",
10
+ version: "0.2.2",
13
11
  props: {
14
12
  ...common.props,
15
13
  fields: {
@@ -29,140 +27,8 @@ export default {
29
27
  },
30
28
  methods: {
31
29
  ...common.methods,
32
- generateWebhookMeta(data) {
33
- const nameField = this.getNameField();
34
- const { New: newObject } = data.body;
35
- const {
36
- LastModifiedDate: lastModifiedDate,
37
- Id: id,
38
- [nameField]: name,
39
- } = newObject;
40
- const entityType = startCase(this.objectType);
41
- const summary = `${entityType} updated: ${name}`;
42
- const ts = Date.parse(lastModifiedDate);
43
- const compositeId = `${id}-${ts}`;
44
- return {
45
- id: compositeId,
46
- summary,
47
- ts,
48
- };
49
- },
50
- generateTimerMeta(item, fieldName) {
51
- const { objectType } = this;
52
-
53
- const {
54
- LastModifiedDate: lastModifiedDate,
55
- [fieldName]: name,
56
- Id: id,
57
- } = item;
58
-
59
- const entityType = startCase(objectType);
60
- const summary = `${entityType} updated: ${name}`;
61
- const ts = Date.parse(lastModifiedDate);
62
- return {
63
- id: `${id}-${ts}`,
64
- summary,
65
- ts,
66
- };
67
- },
68
- getEventType() {
69
- return "updated";
70
- },
71
- isEventRelevant(changedFields) {
72
- const { fields } = this;
73
- return fields?.length
74
- ? Object.keys(changedFields).some((key) => fields.includes(key))
75
- : true;
76
- },
77
- getChangedFields(body) {
78
- return Object.entries(body.New).filter(([
79
- key,
80
- value,
81
- ]) => {
82
- const oldValue = body.Old[key];
83
- return (
84
- value !== undefined
85
- && oldValue !== undefined
86
- && JSON.stringify(value) !== JSON.stringify(oldValue)
87
- );
88
- })
89
- .reduce((obj, [
90
- key,
91
- value,
92
- ]) => {
93
- obj[key] = {
94
- old: body.Old[key],
95
- new: value,
96
- };
97
- return obj;
98
- }, {});
99
- },
100
- processWebhookEvent(event) {
101
- const { body } = event;
102
- const changedFields = this.getChangedFields(body);
103
- if (this.isEventRelevant(changedFields)) {
104
- const meta = this.generateWebhookMeta(event);
105
- this.$emit({
106
- ...body,
107
- changedFields,
108
- }, meta);
109
- }
110
- },
111
- async processTimerEvent(eventData) {
112
- const {
113
- getNameField,
114
- getObjectTypeColumns,
115
- paginate,
116
- objectType,
117
- setLatestDateCovered,
118
- generateTimerMeta,
119
- $emit: emit,
120
- } = this;
121
-
122
- const {
123
- startTimestamp,
124
- endTimestamp,
125
- } = eventData;
126
-
127
- const fieldName = getNameField();
128
- const columns = getObjectTypeColumns();
129
-
130
- const events = await paginate({
131
- objectType,
132
- startTimestamp,
133
- endTimestamp,
134
- columns,
135
- dateFieldName: constants.FIELD_NAME.LAST_MODIFIED_DATE,
136
- });
137
-
138
- const [
139
- latestEvent,
140
- ] = events;
141
-
142
- if (latestEvent?.LastModifiedDate) {
143
- const latestDateCovered = new Date(latestEvent.LastModifiedDate);
144
- latestDateCovered.setSeconds(0);
145
- setLatestDateCovered(latestDateCovered.toISOString());
146
- }
147
-
148
- Array.from(events)
149
- .reverse()
150
- .forEach((item) => {
151
- const meta = generateTimerMeta(item, fieldName);
152
- emit(item, meta);
153
- });
154
- },
155
- async timerActivateHook() {
156
- const {
157
- objectType,
158
- getObjectTypeDescription,
159
- setObjectTypeColumns,
160
- } = this;
161
-
162
- const { fields } = await getObjectTypeDescription(objectType);
163
- const columns = fields.map(({ name }) => name);
164
-
165
- setObjectTypeColumns(columns);
30
+ getObjectType() {
31
+ return this.objectType;
166
32
  },
167
33
  },
168
34
  };