@pipedream/salesforce_rest_api 0.4.0 → 0.4.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.
@@ -0,0 +1,52 @@
1
+ import salesForceRestApi from "../../salesforce_rest_api.app.mjs";
2
+ import {
3
+ removeNullEntries, toSingleLineString,
4
+ } from "../../common/utils.mjs";
5
+ import constants from "../../common/constants.mjs";
6
+
7
+ export default {
8
+ key: "salesforce_rest_api-add-contact-to-campaign",
9
+ name: "Add Contact to Campaign",
10
+ description: toSingleLineString(`
11
+ Adds an existing contact to an existing campaign.
12
+ See [Event SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_campaignmember.htm)
13
+ and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
14
+ `),
15
+ version: "0.0.1",
16
+ type: "action",
17
+ props: {
18
+ salesForceRestApi,
19
+ campaignId: {
20
+ propDefinition: [
21
+ salesForceRestApi,
22
+ "sobjectId",
23
+ () => ({
24
+ objectType: constants.OBJECT_TYPE.CAMPAIGN,
25
+ }),
26
+ ],
27
+ label: "Campaign ID",
28
+ description: "ID of the Campaign to which this Lead is associated.",
29
+ },
30
+ contactId: {
31
+ propDefinition: [
32
+ salesForceRestApi,
33
+ "sobjectId",
34
+ () => ({
35
+ objectType: constants.OBJECT_TYPE.CONTACT,
36
+ }),
37
+ ],
38
+ label: "Contact ID",
39
+ description: "ID of the Contact who is associated with a Campaign.",
40
+ },
41
+ },
42
+ async run({ $ }) {
43
+ const data = removeNullEntries({
44
+ CampaignId: this.campaignId,
45
+ ContactId: this.contactId,
46
+ });
47
+ const response = await this.salesForceRestApi
48
+ .createObject(constants.OBJECT_TYPE.CAMPAIGN_MEMBER, data);
49
+ response && $.export("$summary", "Successfully added contact to campaign");
50
+ return response;
51
+ },
52
+ };
@@ -0,0 +1,51 @@
1
+ import salesForceRestApi from "../../salesforce_rest_api.app.mjs";
2
+ import {
3
+ removeNullEntries, toSingleLineString,
4
+ } from "../../common/utils.mjs";
5
+ import constants from "../../common/constants.mjs";
6
+
7
+ export default {
8
+ key: "salesforce_rest_api-add-lead-to-campaign",
9
+ name: "Add Lead to Campaign",
10
+ description: toSingleLineString(`
11
+ Adds an existing lead to an existing campaign.
12
+ See [Event SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_campaignmember.htm)
13
+ and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
14
+ `),
15
+ version: "0.0.1",
16
+ type: "action",
17
+ props: {
18
+ salesForceRestApi,
19
+ campaignId: {
20
+ propDefinition: [
21
+ salesForceRestApi,
22
+ "sobjectId",
23
+ () => ({
24
+ objectType: constants.OBJECT_TYPE.CAMPAIGN,
25
+ }),
26
+ ],
27
+ label: "Campaign ID",
28
+ description: "ID of the Campaign to which this Lead is associated.",
29
+ },
30
+ leadId: {
31
+ propDefinition: [
32
+ salesForceRestApi,
33
+ "sobjectId",
34
+ () => ({
35
+ objectType: constants.OBJECT_TYPE.LEAD,
36
+ }),
37
+ ],
38
+ label: "Lead ID",
39
+ description: "ID of the Lead who is associated with a Campaign.",
40
+ },
41
+ },
42
+ async run({ $ }) {
43
+ const data = removeNullEntries({
44
+ CampaignId: this.campaignId,
45
+ LeadId: this.leadId,
46
+ });
47
+ const response = await this.salesForceRestApi.createObject("CampaignMember", data);
48
+ response && $.export("$summary", "Successfully added lead to campaign");
49
+ return response;
50
+ },
51
+ };
@@ -10,14 +10,19 @@ export default {
10
10
  props: {
11
11
  salesForceRestApi,
12
12
  sobjectType: {
13
- type: "string",
14
- label: "Object type",
15
- description:
16
- "Salesforce standard object type of the record to get field values from. [Object types](https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_list.htm)",
13
+ propDefinition: [
14
+ salesForceRestApi,
15
+ "objectType",
16
+ ],
17
17
  },
18
18
  sobjectId: {
19
- type: "string",
20
- label: "Object id",
19
+ propDefinition: [
20
+ salesForceRestApi,
21
+ "sobjectId",
22
+ (c) => ({
23
+ objectType: c.sobjectType,
24
+ }),
25
+ ],
21
26
  description:
22
27
  "ID of the Salesforce standard object to get field values from.",
23
28
  },
@@ -11,14 +11,19 @@ export default {
11
11
  props: {
12
12
  salesForceRestApi,
13
13
  sobjectType: {
14
- type: "string",
15
- label: "Object type",
16
- description:
17
- "Salesforce standard object type of the record to get field values from. [Object types](https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_list.htm)",
14
+ propDefinition: [
15
+ salesForceRestApi,
16
+ "objectType",
17
+ ],
18
18
  },
19
19
  sobjectId: {
20
- type: "string",
21
- label: "Object ID",
20
+ propDefinition: [
21
+ salesForceRestApi,
22
+ "sobjectId",
23
+ (c) => ({
24
+ objectType: c.sobjectType,
25
+ }),
26
+ ],
22
27
  description:
23
28
  "ID of the Salesforce standard object to get field values from.",
24
29
  },
@@ -10,16 +10,20 @@ export default {
10
10
  props: {
11
11
  salesForceRestApi,
12
12
  sobjectType: {
13
- type: "string",
14
- label: "Object type",
15
- description:
16
- "Salesforce standard object type of the record to get field values from. [Object types](https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_list.htm)",
13
+ propDefinition: [
14
+ salesForceRestApi,
15
+ "objectType",
16
+ ],
17
17
  },
18
18
  ids: {
19
+ propDefinition: [
20
+ salesForceRestApi,
21
+ "sobjectId",
22
+ (c) => ({
23
+ objectType: c.sobjectType,
24
+ }),
25
+ ],
19
26
  type: "string[]",
20
- label: "Record IDs to be returned",
21
- description:
22
- "Record IDs to be returned",
23
27
  },
24
28
  fields: {
25
29
  type: "string[]",
@@ -34,14 +38,14 @@ export default {
34
38
  fields,
35
39
  ids,
36
40
  } = this;
37
- const response = await this.salesForceRestApi.getRecords(
41
+ const response = await this.salesForceRestApi.getRecords(
38
42
  sobjectType, {
39
- fields: fields.join(","),
40
- ids: ids.join(","),
43
+ fields: Array.isArray(fields) && fields.join(",") || fields,
44
+ ids: Array.isArray(ids) && ids.join(",") || ids,
41
45
  },
42
46
  );
43
47
  if (response) {
44
- $.export("$summary", "Record found successfully" );
48
+ $.export("$summary", "Record found successfully");
45
49
  }
46
50
  return response;
47
51
  },
@@ -0,0 +1,39 @@
1
+ import salesForceRestApi from "../../salesforce_rest_api.app.mjs";
2
+ import { toSingleLineString } from "../../common/utils.mjs";
3
+
4
+ export default {
5
+ key: "salesforce_rest_api-post-feed-to-chatter",
6
+ name: "Post a Message to Chatter Feed",
7
+ description: toSingleLineString(`
8
+ Posts a message to the Chatter Feed.
9
+ [See doc](https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/quickreference_post_feed_item.htm)
10
+ `),
11
+ version: "0.0.1",
12
+ type: "action",
13
+ props: {
14
+ salesForceRestApi,
15
+ text: {
16
+ label: "Text body",
17
+ description: "Text body.",
18
+ type: "string",
19
+ },
20
+ subjectId: {
21
+ label: "Subject ID",
22
+ description: "Specify the user, group, or record that will parent the feed item.",
23
+ type: "string",
24
+ },
25
+ },
26
+ async run({ $ }) {
27
+ const params = {
28
+ text: this.text,
29
+ subjectId: this.subjectId,
30
+ feedElementType: "FeedItem",
31
+ };
32
+ const response = await this.salesForceRestApi.postFeed({
33
+ $,
34
+ params,
35
+ });
36
+ response && $.export("$summary", "Successfully added message to chatter feed");
37
+ return response;
38
+ },
39
+ };
@@ -1,5 +1,5 @@
1
- import salesforce from "../../salesforce_rest_api.app.mjs";
2
1
  import { toSingleLineString } from "../../common/utils.mjs";
2
+ import salesforce from "../../salesforce_rest_api.app.mjs";
3
3
 
4
4
  export default {
5
5
  key: "salesforce_rest_api-soql-search",
@@ -8,7 +8,7 @@ export default {
8
8
  Executes a SOQL query.
9
9
  See [docs](https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql.htm)
10
10
  `),
11
- version: "0.2.2",
11
+ version: "0.2.3",
12
12
  type: "action",
13
13
  props: {
14
14
  salesforce,
@@ -23,7 +23,7 @@ export default {
23
23
  $,
24
24
  query: this.query,
25
25
  });
26
- $.export("$summary", "Successfully returned ${response.length} results for SOQL query");
26
+ $.export("$summary", `Successfully returned ${response.totalSize} results for SOQL query`);
27
27
  return response;
28
28
  },
29
29
  };
@@ -27,4 +27,10 @@ export default {
27
27
  "Cadence",
28
28
  "Call",
29
29
  ],
30
+ OBJECT_TYPE: {
31
+ CAMPAIGN: "Campaign",
32
+ CONTACT: "Contact",
33
+ CAMPAIGN_MEMBER: "CampaignMember",
34
+ LEAD: "Lead",
35
+ },
30
36
  };
@@ -29,11 +29,6 @@ export default {
29
29
  label: "First Name",
30
30
  description: "The contact's first name up to 40 characters.",
31
31
  },
32
- MiddleName: {
33
- type: "string",
34
- label: "Middle Name",
35
- description: "The contact's middle name up to 40 characters. To enable this field, ask Salesforce Customer Support for help.",
36
- },
37
32
  Phone: {
38
33
  type: "string",
39
34
  label: "Phone",
@@ -24,9 +24,4 @@ export default {
24
24
  label: "First Name",
25
25
  description: "The lead's first name up to 40 characters.",
26
26
  },
27
- MiddleName: {
28
- type: "string",
29
- label: "Middle Name",
30
- description: "The lead's middle name up to 40 characters. To enable this field, ask Salesforce Customer Support for help.",
31
- },
32
27
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/salesforce_rest_api",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Pipedream Salesforce (REST API) Components",
5
5
  "main": "salesforce_rest_api.app.mjs",
6
6
  "keywords": [
@@ -524,7 +524,7 @@ export default {
524
524
  $, query,
525
525
  }) {
526
526
  const baseUrl = this._baseApiVersionUrl();
527
- const url = `${baseUrl}/query/?q=${encodeURI(query)}`;
527
+ const url = `${baseUrl}/query/?q=${encodeURIComponent(query)}`;
528
528
  return this._makeRequest({
529
529
  $,
530
530
  url,
@@ -534,7 +534,7 @@ export default {
534
534
  $, search,
535
535
  }) {
536
536
  const baseUrl = this._baseApiVersionUrl();
537
- const url = `${baseUrl}/search/?q=${encodeURI(search)}`;
537
+ const url = `${baseUrl}/search/?q=${encodeURIComponent(search)}`;
538
538
  return this._makeRequest({
539
539
  $,
540
540
  url,
@@ -555,5 +555,14 @@ export default {
555
555
  };
556
556
  return axios($ ?? this, requestConfig);
557
557
  },
558
+ async postFeed(args = {}) {
559
+ const baseUrl = this._baseApiVersionUrl();
560
+ const url = `${baseUrl}/chatter/feed-elements`;
561
+ return this._makeRequest({
562
+ url,
563
+ method: "POST",
564
+ ...args,
565
+ });
566
+ },
558
567
  },
559
568
  };
@@ -8,10 +8,13 @@ export default {
8
8
  name: "New Object (of Selectable Type)",
9
9
  key: "salesforce_rest_api-new-object",
10
10
  description: "Emit new event (at regular intervals) when an object of arbitrary type (selected as an input parameter by the user) is created. See [the docs](https://sforce.co/3yPSJZy) for more information.",
11
- version: "0.1.0",
11
+ version: "0.1.1",
12
12
  methods: {
13
13
  ...common.methods,
14
14
  isItemRelevant(item, startTimestamp, endTimestamp) {
15
+ if (!item) {
16
+ return false;
17
+ }
15
18
  const startDate = Date.parse(startTimestamp);
16
19
  const endDate = Date.parse(endTimestamp);
17
20
  const createdDate = Date.parse(item.CreatedDate);
@@ -46,10 +49,11 @@ export default {
46
49
  startTimestamp,
47
50
  endTimestamp,
48
51
  );
52
+ this.setLatestDateCovered(latestDateCovered);
49
53
 
50
54
  // By the time we try to retrieve an item, it might've been deleted. This
51
55
  // will cause `getSObject` to throw a 404 exception, which will reject its
52
- // promise. Hence, we need to filter those items that we still in Salesforce
56
+ // promise. Hence, we need to filter those items that are still in Salesforce
53
57
  // and exclude those that are not.
54
58
  const itemRetrievals = await Promise.allSettled(
55
59
  ids.map((id) => this.salesforce.getSObject(this.objectType, id)),
@@ -62,8 +66,6 @@ export default {
62
66
  const meta = this.generateMeta(item);
63
67
  this.$emit(item, meta);
64
68
  });
65
-
66
- this.setLatestDateCovered(latestDateCovered);
67
69
  },
68
70
  },
69
71
  };
@@ -8,7 +8,7 @@ export default {
8
8
  name: "New Deleted Object (of Selectable Type)",
9
9
  key: "salesforce_rest_api-object-deleted",
10
10
  description: "Emit new event (at regular intervals) when an object of arbitrary type (selected as an input parameter by the user) is deleted. [See the docs](https://sforce.co/3msDDEE) for more information.",
11
- version: "0.1.0",
11
+ version: "0.1.1",
12
12
  methods: {
13
13
  ...common.methods,
14
14
  generateMeta(item) {
@@ -38,6 +38,7 @@ export default {
38
38
  startTimestamp,
39
39
  endTimestamp,
40
40
  );
41
+ this.setLatestDateCovered(latestDateCovered);
41
42
 
42
43
  // When a record is deleted, the `getDeleted` API only shows the ID of the
43
44
  // deleted item and the date in which it was deleted.
@@ -45,8 +46,6 @@ export default {
45
46
  const meta = this.generateMeta(item);
46
47
  this.$emit(item, meta);
47
48
  });
48
-
49
- this.setLatestDateCovered(latestDateCovered);
50
49
  },
51
50
  },
52
51
  };
@@ -8,7 +8,7 @@ export default {
8
8
  name: "New Updated Object (of Selectable Type)",
9
9
  key: "salesforce_rest_api-object-updated",
10
10
  description: "Emit new event (at regular intervals) when an object of arbitrary type (selected as an input parameter by the user) is updated. [See the docs](https://sforce.co/3yPSJZy) for more information.",
11
- version: "0.1.0",
11
+ version: "0.1.1",
12
12
  methods: {
13
13
  ...common.methods,
14
14
  generateMeta(item) {
@@ -41,10 +41,11 @@ export default {
41
41
  startTimestamp,
42
42
  endTimestamp,
43
43
  );
44
+ this.setLatestDateCovered(latestDateCovered);
44
45
 
45
46
  // By the time we try to retrieve an item, it might've been deleted. This
46
47
  // will cause `getSObject` to throw a 404 exception, which will reject its
47
- // promise. Hence, we need to filter those items that we still in Salesforce
48
+ // promise. Hence, we need to filter those items that are still in Salesforce
48
49
  // and exclude those that are not.
49
50
  const itemRetrievals = await Promise.allSettled(
50
51
  ids.map((id) => this.salesforce.getSObject(this.objectType, id)),
@@ -56,8 +57,6 @@ export default {
56
57
  const meta = this.generateMeta(item);
57
58
  this.$emit(item, meta);
58
59
  });
59
-
60
- this.setLatestDateCovered(latestDateCovered);
61
60
  },
62
61
  },
63
62
  };
@@ -15,7 +15,7 @@ export default {
15
15
  name: "New Updated Field on Record (of Selectable Type)",
16
16
  key: "salesforce_rest_api-updated-field-on-record",
17
17
  description: "Emit new event (at regular intervals) when a field of your choosing is updated on any record of a specified Salesforce object. Field history tracking must be enabled for the chosen field. See the docs on [field history tracking](https://sforce.co/3mtj0rF) and [history objects](https://sforce.co/3Fn4lWB) for more information.",
18
- version: "0.1.0",
18
+ version: "0.1.1",
19
19
  props: {
20
20
  ...common.props,
21
21
  objectType: {
@@ -130,10 +130,11 @@ export default {
130
130
  startTimestamp,
131
131
  endTimestamp,
132
132
  );
133
+ this.setLatestDateCovered(latestDateCovered);
133
134
 
134
135
  // By the time we try to retrieve an item, it might've been deleted. This
135
136
  // will cause `getSObject` to throw a 404 exception, which will reject its
136
- // promise. Hence, we need to filter those items that we still in Salesforce
137
+ // promise. Hence, we need to filter those items that are still in Salesforce
137
138
  // and exclude those that are not.
138
139
  const historyItemRetrievals = await Promise.allSettled(
139
140
  ids.map((id) => this.salesforce.getSObject(historyObjectType, id)),
@@ -172,8 +173,6 @@ export default {
172
173
  const meta = this.generateMeta(event);
173
174
  this.$emit(event, meta);
174
175
  });
175
-
176
- this.setLatestDateCovered(latestDateCovered);
177
176
  },
178
177
  },
179
178
  };