@pipedream/salesforce_rest_api 1.0.0 → 1.0.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.
Files changed (42) hide show
  1. package/README.md +66 -2
  2. package/actions/add-contact-to-campaign/add-contact-to-campaign.mjs +1 -1
  3. package/actions/add-lead-to-campaign/add-lead-to-campaign.mjs +1 -1
  4. package/actions/common/base.mjs +18 -0
  5. package/actions/convert-soap-xml-to-json/convert-soap-xml-to-json.mjs +1 -1
  6. package/actions/create-account/create-account.mjs +7 -4
  7. package/actions/create-attachment/create-attachment.mjs +7 -4
  8. package/actions/create-campaign/create-campaign.mjs +7 -4
  9. package/actions/create-case/create-case.mjs +7 -4
  10. package/actions/create-casecomment/create-casecomment.mjs +7 -4
  11. package/actions/create-contact/create-contact.mjs +7 -4
  12. package/actions/create-event/create-event.mjs +1 -1
  13. package/actions/create-lead/create-lead.mjs +7 -4
  14. package/actions/create-note/create-note.mjs +7 -4
  15. package/actions/create-opportunity/create-opportunity.mjs +7 -4
  16. package/actions/create-record/create-record.mjs +1 -1
  17. package/actions/create-task/create-task.mjs +7 -4
  18. package/actions/delete-opportunity/delete-opportunity.mjs +1 -1
  19. package/actions/delete-record/delete-record.mjs +1 -1
  20. package/actions/find-create-record/find-create-record.mjs +1 -1
  21. package/actions/find-records/find-records.mjs +1 -1
  22. package/actions/get-sobject-fields-values/get-sobject-fields-values.mjs +1 -1
  23. package/actions/insert-blob-data/insert-blob-data.mjs +1 -1
  24. package/actions/post-feed-to-chatter/post-feed-to-chatter.mjs +1 -1
  25. package/actions/soql-search/soql-search.mjs +1 -1
  26. package/actions/sosl-search/sosl-search.mjs +1 -1
  27. package/actions/update-account/update-account.mjs +7 -4
  28. package/actions/update-contact/update-contact.mjs +7 -4
  29. package/actions/update-opportunity/update-opportunity.mjs +7 -4
  30. package/actions/update-record/update-record.mjs +1 -1
  31. package/package.json +1 -1
  32. package/salesforce_rest_api.app.mjs +0 -6
  33. package/sources/common.mjs +45 -0
  34. package/sources/new-outbound-message/new-outbound-message.mjs +1 -1
  35. package/sources/new-record/new-record.mjs +19 -11
  36. package/sources/new-record-instant/new-record-instant.mjs +1 -1
  37. package/sources/object-updated/object-updated.mjs +18 -10
  38. package/sources/object-updated-instant/object-updated-instant.mjs +1 -1
  39. package/sources/record-deleted/record-deleted.mjs +1 -1
  40. package/sources/record-deleted-instant/record-deleted-instant.mjs +1 -1
  41. package/sources/updated-field-on-record/updated-field-on-record.mjs +9 -13
  42. package/sources/updated-field-on-record-instant/updated-field-on-record-instant.mjs +1 -1
package/README.md CHANGED
@@ -1,8 +1,72 @@
1
1
  # Getting Started
2
2
 
3
- You can install the Pipedream Salesforce app in the [Accounts](https://pipedream.com/accounts) section of your account, or directly in a workflow.
3
+ You can install the Pipedream Salesforce app in the [Accounts](https://pipedream.com/accounts) section of your Pipedream account, or directly in a workflow.
4
4
 
5
- ### Webhooks
5
+ ## Prerequisite: Salesforce Edition with API Access
6
+
7
+ In order to use this application, you must be on a Salesforce Edition that has API Access, and API Access must be enabled. See [here](https://help.salesforce.com/s/articleView?id=000385436&type=1) for more details.
8
+
9
+ **Salesforce Editions with API Access**
10
+ * Enterprise Edition
11
+ * Unlimited Edition
12
+ * Developer Edition
13
+ * Performance Edition
14
+ * Professional Edition (API access available as an add-on)
15
+
16
+ ### Enabling API Access on Salesforce
17
+
18
+ Your Salesforce user needs a **System Administrator** profile in order to enable API access. If you don't have this on your Salesforce Profile, ask your System Administrator to enable API Access for your user.
19
+
20
+ The most straightforward way to add these permissions is to create a new Permission Set in Salesforce, and to add it to the user once created.
21
+
22
+ Here is a step-by-step on how to do this:
23
+
24
+ **Create New Permission Set**
25
+
26
+ 1. Navigate to your Salesforce instance, and click the Setup wheel in the top-right corner.
27
+ 2. Under the Administration tab on the lefthand sidebar, click Users --> Permission Sets.
28
+ 3. On the Permissions Set page, click New.
29
+ 4. Create a new permission set, give it a label, API name, and description. Example: <br>
30
+ **Label**: Pipedream API Access
31
+ **API Name**: Pipedream
32
+ **Description**: Adds a set of permissions required for Pipedream.
33
+
34
+ <img src="https://res.cloudinary.com/dpenc2lit/image/upload/v1702598220/Screenshot_2023-12-14_at_2.57.21_PM_dfgsrw.png" width=500>
35
+
36
+ **Add Permissions**
37
+
38
+ 5. Now that the permission set is created, navigate to System Permissions.
39
+ <img src="https://res.cloudinary.com/dpenc2lit/image/upload/v1702598358/Screenshot_2023-12-14_at_3.00.49_PM_axtws5.png" width=500>
40
+
41
+ 6. From System Permissions, click Edit.
42
+ <img src="https://res.cloudinary.com/dpenc2lit/image/upload/v1702598417/Screenshot_2023-12-14_at_3.01.38_PM_pvbopv.png" width=500>
43
+
44
+ 7. Select the following permission, and click Save.
45
+ - API Enabled
46
+
47
+ If you'd like to utilize Pipedream's webhook triggers, you will need to add the following permissions to the permissions set as well:
48
+ - Apex REST Services
49
+ - Author Apex
50
+ - View Roles and Role Hierarchy
51
+ - Modify Metadata Through Metadata API Functions
52
+ - View Setup and Configuration
53
+ <img src="https://res.cloudinary.com/dpenc2lit/image/upload/v1702598514/Screenshot_2023-12-14_at_3.48.50_PM_pcychy.png" width=500>
54
+
55
+ 8. The list of added permissions (6) should look like this, and click save again.
56
+ <img src="https://res.cloudinary.com/dpenc2lit/image/upload/v1702598417/Screenshot_2023-12-14_at_3.10.17_PM_urgge8.png" width=500>
57
+
58
+ **Add Permission Set to User**
59
+
60
+ 9. From the newly created Permission Set, click Manage Assignments, then Add Assignment.
61
+ <img src="https://res.cloudinary.com/dpenc2lit/image/upload/v1702598514/Screenshot_2023-12-14_at_3.21.59_PM_rqedtd.png" width=500>
62
+
63
+ 10. Select the user you'd like to assign this permission set to, and click Assign. The user should now show up under Current Assignments.
64
+ <img src="https://res.cloudinary.com/dpenc2lit/image/upload/v1702598514/Screenshot_2023-12-14_at_3.52.42_PM_w4ge4p.png" width=500>
65
+
66
+ 11. You should now be able to use the Salesforce integration along with the webhook triggers if you configured the required permissions above.
67
+
68
+
69
+ # Troubleshooting
6
70
 
7
71
  If you happen to stumble on the error: `UNKNOWN_EXCEPTION: admin operation already in progress` when creating an **Instant** trigger, you can follow the steps below to use the Salesforce Flow Builder to be able to use webhooks with Pipedream. This is a known error in Salesforce.
8
72
 
@@ -12,7 +12,7 @@ export default {
12
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
13
  and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
14
14
  `),
15
- version: "0.0.3",
15
+ version: "0.0.4",
16
16
  type: "action",
17
17
  props: {
18
18
  salesForceRestApi,
@@ -12,7 +12,7 @@ export default {
12
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
13
  and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
14
14
  `),
15
- version: "0.0.3",
15
+ version: "0.0.4",
16
16
  type: "action",
17
17
  props: {
18
18
  salesForceRestApi,
@@ -0,0 +1,18 @@
1
+ import salesforce from "../../salesforce_rest_api.app.mjs";
2
+
3
+ export default {
4
+ props: {
5
+ salesforce,
6
+ },
7
+ methods: {
8
+ additionalProps(selector, sobject) {
9
+ if (!selector || !sobject) {
10
+ return {};
11
+ }
12
+ return selector.reduce((props, prop) => ({
13
+ ...props,
14
+ [prop]: sobject[prop],
15
+ }), {});
16
+ },
17
+ },
18
+ };
@@ -5,7 +5,7 @@ export default {
5
5
  key: "salesforce_rest_api-convert-soap-xml-to-json",
6
6
  name: "Convert SOAP XML Object to JSON",
7
7
  description: "Converts a SOAP XML Object received from Salesforce to JSON",
8
- version: "0.0.2",
8
+ version: "0.0.3",
9
9
  type: "action",
10
10
  props: {
11
11
  salesforce_rest_api,
@@ -1,11 +1,14 @@
1
- import salesforce from "../../salesforce_rest_api.app.mjs";
1
+ import common from "../common/base.mjs";
2
2
  import account from "../../common/sobjects/account.mjs";
3
3
  import {
4
4
  pickBy, pick,
5
5
  } from "lodash-es";
6
6
  import { toSingleLineString } from "../../common/utils.mjs";
7
7
 
8
+ const { salesforce } = common.props;
9
+
8
10
  export default {
11
+ ...common,
9
12
  key: "salesforce_rest_api-create-account",
10
13
  name: "Create Account",
11
14
  description: toSingleLineString(`
@@ -14,7 +17,7 @@ export default {
14
17
  See [Account SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_account.htm)
15
18
  and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
16
19
  `),
17
- version: "0.2.4",
20
+ version: "0.2.5",
18
21
  type: "action",
19
22
  props: {
20
23
  salesforce,
@@ -33,8 +36,8 @@ export default {
33
36
  reloadProps: true,
34
37
  },
35
38
  },
36
- async additionalProps() {
37
- return this.salesforce.additionalProps(this.selector, account);
39
+ additionalProps() {
40
+ return this.additionalProps(this.selector, account);
38
41
  },
39
42
  async run({ $ }) {
40
43
  const data = pickBy(pick(this, [
@@ -1,11 +1,14 @@
1
- import salesforce from "../../salesforce_rest_api.app.mjs";
1
+ import common from "../common/base.mjs";
2
2
  import attachment from "../../common/sobjects/attachment.mjs";
3
3
  import {
4
4
  pickBy, pick,
5
5
  } from "lodash-es";
6
6
  import { toSingleLineString } from "../../common/utils.mjs";
7
7
 
8
+ const { salesforce } = common.props;
9
+
8
10
  export default {
11
+ ...common,
9
12
  key: "salesforce_rest_api-create-attachment",
10
13
  name: "Create Attachment",
11
14
  description: toSingleLineString(`
@@ -13,7 +16,7 @@ export default {
13
16
  See [Attachment SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_attachment.htm)
14
17
  and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
15
18
  `),
16
- version: "0.3.4",
19
+ version: "0.3.5",
17
20
  type: "action",
18
21
  props: {
19
22
  salesforce,
@@ -42,8 +45,8 @@ export default {
42
45
  reloadProps: true,
43
46
  },
44
47
  },
45
- async additionalProps() {
46
- return this.salesforce.additionalProps(this.selector, attachment);
48
+ additionalProps() {
49
+ return this.additionalProps(this.selector, attachment);
47
50
  },
48
51
  async run({ $ }) {
49
52
  const data = pickBy(pick(this, [
@@ -1,11 +1,14 @@
1
- import salesforce from "../../salesforce_rest_api.app.mjs";
1
+ import common from "../common/base.mjs";
2
2
  import campaign from "../../common/sobjects/campaign.mjs";
3
3
  import {
4
4
  pickBy, pick,
5
5
  } from "lodash-es";
6
6
  import { toSingleLineString } from "../../common/utils.mjs";
7
7
 
8
+ const { salesforce } = common.props;
9
+
8
10
  export default {
11
+ ...common,
9
12
  key: "salesforce_rest_api-create-campaign",
10
13
  name: "Create Campaign",
11
14
  description: toSingleLineString(`
@@ -13,7 +16,7 @@ export default {
13
16
  See [Campaign SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_campaign.htm)
14
17
  and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
15
18
  `),
16
- version: "0.2.4",
19
+ version: "0.2.5",
17
20
  type: "action",
18
21
  props: {
19
22
  salesforce,
@@ -33,8 +36,8 @@ export default {
33
36
  optional: true,
34
37
  },
35
38
  },
36
- async additionalProps() {
37
- return this.salesforce.additionalProps(this.selector, campaign);
39
+ additionalProps() {
40
+ return this.additionalProps(this.selector, campaign);
38
41
  },
39
42
  async run({ $ }) {
40
43
  const data = pickBy(pick(this, [
@@ -1,11 +1,14 @@
1
- import salesforce from "../../salesforce_rest_api.app.mjs";
1
+ import common from "../common/base.mjs";
2
2
  import salesforceCase from "../../common/sobjects/case.mjs";
3
3
  import {
4
4
  pickBy, pick,
5
5
  } from "lodash-es";
6
6
  import { toSingleLineString } from "../../common/utils.mjs";
7
7
 
8
+ const { salesforce } = common.props;
9
+
8
10
  export default {
11
+ ...common,
9
12
  key: "salesforce_rest_api-create-case",
10
13
  name: "Create Case",
11
14
  description: toSingleLineString(`
@@ -13,7 +16,7 @@ export default {
13
16
  See [Case SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_case.htm)
14
17
  and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
15
18
  `),
16
- version: "0.2.4",
19
+ version: "0.2.5",
17
20
  type: "action",
18
21
  props: {
19
22
  salesforce,
@@ -32,8 +35,8 @@ export default {
32
35
  reloadProps: true,
33
36
  },
34
37
  },
35
- async additionalProps() {
36
- return this.salesforce.additionalProps(this.selector, salesforceCase);
38
+ additionalProps() {
39
+ return this.additionalProps(this.selector, salesforceCase);
37
40
  },
38
41
  async run({ $ }) {
39
42
  const data = pickBy(pick(this, [
@@ -1,11 +1,14 @@
1
- import salesforce from "../../salesforce_rest_api.app.mjs";
1
+ import common from "../common/base.mjs";
2
2
  import caseComment from "../../common/sobjects/caseComment.mjs";
3
3
  import {
4
4
  pickBy, pick,
5
5
  } from "lodash-es";
6
6
  import { toSingleLineString } from "../../common/utils.mjs";
7
7
 
8
+ const { salesforce } = common.props;
9
+
8
10
  export default {
11
+ ...common,
9
12
  key: "salesforce_rest_api-create-casecomment",
10
13
  name: "Create CaseComment",
11
14
  description: toSingleLineString(`
@@ -13,7 +16,7 @@ export default {
13
16
  See [CaseComment SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_casecomment.htm)
14
17
  and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
15
18
  `),
16
- version: "0.2.4",
19
+ version: "0.2.5",
17
20
  type: "action",
18
21
  props: {
19
22
  salesforce,
@@ -32,8 +35,8 @@ export default {
32
35
  reloadProps: true,
33
36
  },
34
37
  },
35
- async additionalProps() {
36
- return this.salesforce.additionalProps(this.selector, caseComment);
38
+ additionalProps() {
39
+ return this.additionalProps(this.selector, caseComment);
37
40
  },
38
41
  async run({ $ }) {
39
42
  const data = pickBy(pick(this, [
@@ -1,11 +1,14 @@
1
- import salesforce from "../../salesforce_rest_api.app.mjs";
1
+ import common from "../common/base.mjs";
2
2
  import contact from "../../common/sobjects/contact.mjs";
3
3
  import {
4
4
  pickBy, pick,
5
5
  } from "lodash-es";
6
6
  import { toSingleLineString } from "../../common/utils.mjs";
7
7
 
8
+ const { salesforce } = common.props;
9
+
8
10
  export default {
11
+ ...common,
9
12
  key: "salesforce_rest_api-create-contact",
10
13
  name: "Create Contact",
11
14
  description: toSingleLineString(`
@@ -13,7 +16,7 @@ export default {
13
16
  See [Contact SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_contact.htm)
14
17
  and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
15
18
  `),
16
- version: "0.2.4",
19
+ version: "0.2.5",
17
20
  type: "action",
18
21
  props: {
19
22
  salesforce,
@@ -32,8 +35,8 @@ export default {
32
35
  reloadProps: true,
33
36
  },
34
37
  },
35
- async additionalProps() {
36
- return this.salesforce.additionalProps(this.selector, contact);
38
+ additionalProps() {
39
+ return this.additionalProps(this.selector, contact);
37
40
  },
38
41
  async run({ $ }) {
39
42
  const data = pickBy(pick(this, [
@@ -11,7 +11,7 @@ export default {
11
11
  See [Event SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_event.htm)
12
12
  and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
13
13
  `),
14
- version: "0.2.4",
14
+ version: "0.2.5",
15
15
  type: "action",
16
16
  props: {
17
17
  salesforce,
@@ -1,11 +1,14 @@
1
- import salesforce from "../../salesforce_rest_api.app.mjs";
1
+ import common from "../common/base.mjs";
2
2
  import lead from "../../common/sobjects/lead.mjs";
3
3
  import {
4
4
  pickBy, pick,
5
5
  } from "lodash-es";
6
6
  import { toSingleLineString } from "../../common/utils.mjs";
7
7
 
8
+ const { salesforce } = common.props;
9
+
8
10
  export default {
11
+ ...common,
9
12
  key: "salesforce_rest_api-create-lead",
10
13
  name: "Create Lead",
11
14
  description: toSingleLineString(`
@@ -13,7 +16,7 @@ export default {
13
16
  See [Lead SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_lead.htm)
14
17
  and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
15
18
  `),
16
- version: "0.2.4",
19
+ version: "0.2.5",
17
20
  type: "action",
18
21
  props: {
19
22
  salesforce,
@@ -37,8 +40,8 @@ export default {
37
40
  reloadProps: true,
38
41
  },
39
42
  },
40
- async additionalProps() {
41
- return this.salesforce.additionalProps(this.selector, lead);
43
+ additionalProps() {
44
+ return this.additionalProps(this.selector, lead);
42
45
  },
43
46
  async run({ $ }) {
44
47
  const data = pickBy(pick(this, [
@@ -1,11 +1,14 @@
1
- import salesforce from "../../salesforce_rest_api.app.mjs";
1
+ import common from "../common/base.mjs";
2
2
  import note from "../../common/sobjects/note.mjs";
3
3
  import {
4
4
  pickBy, pick,
5
5
  } from "lodash-es";
6
6
  import { toSingleLineString } from "../../common/utils.mjs";
7
7
 
8
+ const { salesforce } = common.props;
9
+
8
10
  export default {
11
+ ...common,
9
12
  key: "salesforce_rest_api-create-note",
10
13
  name: "Create Note",
11
14
  description: toSingleLineString(`
@@ -13,7 +16,7 @@ export default {
13
16
  See [Note SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_note.htm)
14
17
  and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
15
18
  `),
16
- version: "0.2.4",
19
+ version: "0.2.5",
17
20
  type: "action",
18
21
  props: {
19
22
  salesforce,
@@ -37,8 +40,8 @@ export default {
37
40
  reloadProps: true,
38
41
  },
39
42
  },
40
- async additionalProps() {
41
- return this.salesforce.additionalProps(this.selector, note);
43
+ additionalProps() {
44
+ return this.additionalProps(this.selector, note);
42
45
  },
43
46
  async run({ $ }) {
44
47
  const data = pickBy(pick(this, [
@@ -1,11 +1,14 @@
1
- import salesforce from "../../salesforce_rest_api.app.mjs";
1
+ import common from "../common/base.mjs";
2
2
  import opportunity from "../../common/sobjects/opportunity.mjs";
3
3
  import {
4
4
  pickBy, pick,
5
5
  } from "lodash-es";
6
6
  import { toSingleLineString } from "../../common/utils.mjs";
7
7
 
8
+ const { salesforce } = common.props;
9
+
8
10
  export default {
11
+ ...common,
9
12
  key: "salesforce_rest_api-create-opportunity",
10
13
  name: "Create Opportunity",
11
14
  description: toSingleLineString(`
@@ -13,7 +16,7 @@ export default {
13
16
  See [Opportunity SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_opportunity.htm)
14
17
  and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
15
18
  `),
16
- version: "0.2.4",
19
+ version: "0.2.5",
17
20
  type: "action",
18
21
  props: {
19
22
  salesforce,
@@ -42,8 +45,8 @@ export default {
42
45
  reloadProps: true,
43
46
  },
44
47
  },
45
- async additionalProps() {
46
- return this.salesforce.additionalProps(this.selector, opportunity);
48
+ additionalProps() {
49
+ return this.additionalProps(this.selector, opportunity);
47
50
  },
48
51
  async run({ $ }) {
49
52
  const data = pickBy(pick(this, [
@@ -8,7 +8,7 @@ export default {
8
8
  Create new records of a given resource.
9
9
  See [docs](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_create.htm)
10
10
  `),
11
- version: "0.2.4",
11
+ version: "0.2.5",
12
12
  type: "action",
13
13
  props: {
14
14
  salesforce,
@@ -1,11 +1,14 @@
1
- import salesforce from "../../salesforce_rest_api.app.mjs";
1
+ import common from "../common/base.mjs";
2
2
  import task from "../../common/sobjects/task.mjs";
3
3
  import {
4
4
  pickBy, pick,
5
5
  } from "lodash-es";
6
6
  import { toSingleLineString } from "../../common/utils.mjs";
7
7
 
8
+ const { salesforce } = common.props;
9
+
8
10
  export default {
11
+ ...common,
9
12
  key: "salesforce_rest_api-create-task",
10
13
  name: "Create Task",
11
14
  description: toSingleLineString(`
@@ -13,7 +16,7 @@ export default {
13
16
  See [Task SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_task.htm)
14
17
  and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
15
18
  `),
16
- version: "0.3.4",
19
+ version: "0.3.5",
17
20
  type: "action",
18
21
  props: {
19
22
  salesforce,
@@ -37,8 +40,8 @@ export default {
37
40
  reloadProps: true,
38
41
  },
39
42
  },
40
- async additionalProps() {
41
- return this.salesforce.additionalProps(this.selector, task);
43
+ additionalProps() {
44
+ return this.additionalProps(this.selector, task);
42
45
  },
43
46
  async run({ $ }) {
44
47
  const data = pickBy(pick(this, [
@@ -9,7 +9,7 @@ export default {
9
9
  See [Opportunity SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_opportunity.htm)
10
10
  and [Delete Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_delete_record.htm)
11
11
  `),
12
- version: "0.2.4",
12
+ version: "0.2.5",
13
13
  type: "action",
14
14
  props: {
15
15
  salesforce,
@@ -5,7 +5,7 @@ export default {
5
5
  name: "Delete a Record in an Object",
6
6
  description:
7
7
  "Deletes an existing record in an object. [API Doc](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_query.htm)",
8
- version: "0.1.2",
8
+ version: "0.1.3",
9
9
  type: "action",
10
10
  props: {
11
11
  salesForceRestApi,
@@ -6,7 +6,7 @@ export default {
6
6
  name: "Get Field Values from Object Record and optionally create one is none is found. ",
7
7
  description:
8
8
  "Finds a specified Salesforce record by a field. Optionally, create one if none is found. [API Docs](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_get_field_values.htm)",
9
- version: "0.1.2",
9
+ version: "0.1.3",
10
10
  type: "action",
11
11
  props: {
12
12
  salesForceRestApi,
@@ -5,7 +5,7 @@ export default {
5
5
  name: "Get Object Records",
6
6
  description:
7
7
  "Retrieves all records in an object or a record in an object by the given ID or criteria. [API Doc](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_get_field_values.htm)",
8
- version: "0.1.2",
8
+ version: "0.1.3",
9
9
  type: "action",
10
10
  props: {
11
11
  salesForceRestApi,
@@ -8,7 +8,7 @@ export default {
8
8
  Retrieve field values from a record. You can specify the fields you want to retrieve.
9
9
  See [docs](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_get_field_values.htm)
10
10
  `),
11
- version: "0.2.4",
11
+ version: "0.2.5",
12
12
  type: "action",
13
13
  props: {
14
14
  salesforce,
@@ -8,7 +8,7 @@ export default {
8
8
  Inserts blob data in Salesforce standard objects.
9
9
  See [docs](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_insert_update_blob.htm)
10
10
  `),
11
- version: "0.2.4",
11
+ version: "0.2.5",
12
12
  type: "action",
13
13
  props: {
14
14
  salesforce,
@@ -8,7 +8,7 @@ export default {
8
8
  Posts a message to the Chatter Feed.
9
9
  [See doc](https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/quickreference_post_feed_item.htm)
10
10
  `),
11
- version: "0.0.3",
11
+ version: "0.0.4",
12
12
  type: "action",
13
13
  props: {
14
14
  salesForceRestApi,
@@ -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.5",
11
+ version: "0.2.6",
12
12
  type: "action",
13
13
  props: {
14
14
  salesforce,
@@ -8,7 +8,7 @@ export default {
8
8
  Executes the specified SOSL search.
9
9
  See [docs](https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_sosl.htm)
10
10
  `),
11
- version: "0.2.4",
11
+ version: "0.2.5",
12
12
  type: "action",
13
13
  props: {
14
14
  salesforce,
@@ -1,11 +1,14 @@
1
- import salesforce from "../../salesforce_rest_api.app.mjs";
1
+ import common from "../common/base.mjs";
2
2
  import account from "../../common/sobjects/account.mjs";
3
3
  import {
4
4
  pickBy, pick,
5
5
  } from "lodash-es";
6
6
  import { toSingleLineString } from "../../common/utils.mjs";
7
7
 
8
+ const { salesforce } = common.props;
9
+
8
10
  export default {
11
+ ...common,
9
12
  key: "salesforce_rest_api-update-account",
10
13
  name: "Update Account",
11
14
  description: toSingleLineString(`
@@ -14,7 +17,7 @@ export default {
14
17
  See [Account SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_account.htm)
15
18
  and [Update Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_update_fields.htm)
16
19
  `),
17
- version: "0.2.4",
20
+ version: "0.2.5",
18
21
  type: "action",
19
22
  props: {
20
23
  salesforce,
@@ -39,8 +42,8 @@ export default {
39
42
  reloadProps: true,
40
43
  },
41
44
  },
42
- async additionalProps() {
43
- return this.salesforce.additionalProps(this.selector, account);
45
+ additionalProps() {
46
+ return this.additionalProps(this.selector, account);
44
47
  },
45
48
  async run({ $ }) {
46
49
  const data = pickBy(pick(this, [
@@ -1,11 +1,14 @@
1
- import salesforce from "../../salesforce_rest_api.app.mjs";
1
+ import common from "../common/base.mjs";
2
2
  import contact from "../../common/sobjects/contact.mjs";
3
3
  import {
4
4
  pickBy, pick,
5
5
  } from "lodash-es";
6
6
  import { toSingleLineString } from "../../common/utils.mjs";
7
7
 
8
+ const { salesforce } = common.props;
9
+
8
10
  export default {
11
+ ...common,
9
12
  key: "salesforce_rest_api-update-contact",
10
13
  name: "Update Contact",
11
14
  description: toSingleLineString(`
@@ -13,7 +16,7 @@ export default {
13
16
  See [Contact SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_contact.htm)
14
17
  and [Update Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_update_fields.htm)
15
18
  `),
16
- version: "0.2.4",
19
+ version: "0.2.5",
17
20
  type: "action",
18
21
  props: {
19
22
  salesforce,
@@ -38,8 +41,8 @@ export default {
38
41
  reloadProps: true,
39
42
  },
40
43
  },
41
- async additionalProps() {
42
- return this.salesforce.additionalProps(this.selector, contact);
44
+ additionalProps() {
45
+ return this.additionalProps(this.selector, contact);
43
46
  },
44
47
  async run({ $ }) {
45
48
  const data = pickBy(pick(this, [
@@ -1,11 +1,14 @@
1
- import salesforce from "../../salesforce_rest_api.app.mjs";
1
+ import common from "../common/base.mjs";
2
2
  import opportunity from "../../common/sobjects/opportunity.mjs";
3
3
  import {
4
4
  pickBy, pick,
5
5
  } from "lodash-es";
6
6
  import { toSingleLineString } from "../../common/utils.mjs";
7
7
 
8
+ const { salesforce } = common.props;
9
+
8
10
  export default {
11
+ ...common,
9
12
  key: "salesforce_rest_api-update-opportunity",
10
13
  name: "Update Opportunity",
11
14
  description: toSingleLineString(`
@@ -13,7 +16,7 @@ export default {
13
16
  See [Opportunity SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_opportunity.htm)
14
17
  and [Update Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_update_fields.htm)
15
18
  `),
16
- version: "0.2.4",
19
+ version: "0.2.5",
17
20
  type: "action",
18
21
  props: {
19
22
  salesforce,
@@ -50,8 +53,8 @@ export default {
50
53
  reloadProps: true,
51
54
  },
52
55
  },
53
- async additionalProps() {
54
- return this.salesforce.additionalProps(this.selector, opportunity);
56
+ additionalProps() {
57
+ return this.additionalProps(this.selector, opportunity);
55
58
  },
56
59
  async run({ $ }) {
57
60
  const data = pickBy(pick(this, [
@@ -8,7 +8,7 @@ export default {
8
8
  Updates a record of a given resource.
9
9
  [See docs here](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_update_fields.htm)
10
10
  `),
11
- version: "0.2.4",
11
+ version: "0.2.5",
12
12
  type: "action",
13
13
  props: {
14
14
  salesforce,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/salesforce_rest_api",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Pipedream Salesforce (REST API) Components",
5
5
  "main": "salesforce_rest_api.app.mjs",
6
6
  "keywords": [
@@ -183,12 +183,6 @@ export default {
183
183
  };
184
184
  return new SalesforceClient(clientOpts);
185
185
  },
186
- async additionalProps(selector, sobject) {
187
- return selector.reduce((props, prop) => ({
188
- ...props,
189
- [prop]: sobject[prop],
190
- }), {});
191
- },
192
186
  isValidSObject(sobject) {
193
187
  // Only the activity of those SObject types that have the `replicateable`
194
188
  // flag set is published via the `getUpdated` API.
@@ -51,6 +51,19 @@ export default {
51
51
  processEvent() {
52
52
  throw new Error("processEvent is not implemented");
53
53
  },
54
+ chunkArray(array, chunkSize = 25) {
55
+ return array.reduce((chunks, item, index) => {
56
+ const chunkIndex = Math.floor(index / chunkSize);
57
+
58
+ if (!chunks[chunkIndex]) {
59
+ chunks[chunkIndex] = [];
60
+ }
61
+
62
+ chunks[chunkIndex].push(item);
63
+
64
+ return chunks;
65
+ }, []);
66
+ },
54
67
  getRelativeObjectUrl(id, historyObjectType) {
55
68
  const {
56
69
  salesforce,
@@ -73,6 +86,38 @@ export default {
73
86
  ...args,
74
87
  });
75
88
  },
89
+ makeChunkBatchRequests({
90
+ ids, objectType, ...args
91
+ } = {}) {
92
+ const {
93
+ batchRequest,
94
+ chunkArray,
95
+ } = this;
96
+
97
+ const chunks = chunkArray(ids);
98
+ const promises = chunks.map((ids) => batchRequest({
99
+ data: {
100
+ batchRequests: this.getBatchRequests(ids, objectType),
101
+ ...args?.data,
102
+ },
103
+ ...args,
104
+ }));
105
+ return Promise.all(promises);
106
+ },
107
+ getChunkBatchResults(responses) {
108
+ return responses.reduce((acc, { results }) => [
109
+ ...acc,
110
+ ...results,
111
+ ], []);
112
+ },
113
+ async makeChunkBatchRequestsAndGetResults(args) {
114
+ const {
115
+ makeChunkBatchRequests,
116
+ getChunkBatchResults,
117
+ } = this;
118
+ const responses = await makeChunkBatchRequests(args);
119
+ return getChunkBatchResults(responses);
120
+ },
76
121
  },
77
122
  async run(event) {
78
123
  const startTimestamp = this.getLatestDateCovered();
@@ -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. See Salesforce's guide on setting up [Outbound Messaging](https://sforce.co/3JbZJom). Set the Outbound Message's Endpoint URL to the endpoint of the created source. The \"Send Session ID\" option must be enabled for validating outbound messages from Salesforce.",
9
- version: "0.1.3",
9
+ version: "0.1.4",
10
10
  dedupe: "unique",
11
11
  props: {
12
12
  db: "$.service.db",
@@ -8,7 +8,7 @@ export default {
8
8
  name: "New Record (of Selectable Type)",
9
9
  key: "salesforce_rest_api-new-record",
10
10
  description: "Emit new event (at regular intervals) when a record of arbitrary object type (selected as an input parameter by the user) is created. See [the docs](https://sforce.co/3yPSJZy) for more information.",
11
- version: "0.0.1",
11
+ version: "0.0.3",
12
12
  methods: {
13
13
  ...common.methods,
14
14
  isItemRelevant(item, startTimestamp, endTimestamp) {
@@ -37,6 +37,16 @@ export default {
37
37
  };
38
38
  },
39
39
  async processEvent(eventData) {
40
+ const {
41
+ salesforce,
42
+ objectType,
43
+ setLatestDateCovered,
44
+ makeChunkBatchRequestsAndGetResults,
45
+ isItemRelevant,
46
+ generateMeta,
47
+ $emit: emit,
48
+ } = this;
49
+
40
50
  const {
41
51
  startTimestamp,
42
52
  endTimestamp,
@@ -44,21 +54,19 @@ export default {
44
54
  const {
45
55
  ids,
46
56
  latestDateCovered,
47
- } = await this.salesforce.getUpdatedForObjectType(
48
- this.objectType,
57
+ } = await salesforce.getUpdatedForObjectType(
58
+ objectType,
49
59
  startTimestamp,
50
60
  endTimestamp,
51
61
  );
52
- this.setLatestDateCovered(latestDateCovered);
62
+ setLatestDateCovered(latestDateCovered);
53
63
 
54
64
  if (!ids?.length) {
55
65
  return console.log("No batch requests to send");
56
66
  }
57
67
 
58
- const { results } = await this.batchRequest({
59
- data: {
60
- batchRequests: this.getBatchRequests(ids),
61
- },
68
+ const results = await makeChunkBatchRequestsAndGetResults({
69
+ ids,
62
70
  });
63
71
 
64
72
  results
@@ -66,10 +74,10 @@ export default {
66
74
  statusCode, result: item,
67
75
  }) =>
68
76
  statusCode === 200
69
- && this.isItemRelevant(item, startTimestamp, endTimestamp))
77
+ && isItemRelevant(item, startTimestamp, endTimestamp))
70
78
  .forEach(({ result: item }) => {
71
- const meta = this.generateMeta(item);
72
- this.$emit(item, meta);
79
+ const meta = generateMeta(item);
80
+ emit(item, meta);
73
81
  });
74
82
  },
75
83
  },
@@ -7,7 +7,7 @@ export default {
7
7
  name: "New Record (Instant, of Selectable Type)",
8
8
  key: "salesforce_rest_api-new-record-instant",
9
9
  description: "Emit new event immediately after a record of arbitrary object type (selected as an input parameter by the user) is created",
10
- version: "0.0.1",
10
+ version: "0.0.2",
11
11
  hooks: {
12
12
  ...common.hooks,
13
13
  async deploy() {
@@ -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.6",
11
+ version: "0.1.8",
12
12
  methods: {
13
13
  ...common.methods,
14
14
  generateMeta(item) {
@@ -29,35 +29,43 @@ export default {
29
29
  };
30
30
  },
31
31
  async processEvent(eventData) {
32
+ const {
33
+ salesforce,
34
+ objectType,
35
+ setLatestDateCovered,
36
+ makeChunkBatchRequestsAndGetResults,
37
+ generateMeta,
38
+ $emit: emit,
39
+ } = this;
40
+
32
41
  const {
33
42
  startTimestamp,
34
43
  endTimestamp,
35
44
  } = eventData;
45
+
36
46
  const {
37
47
  ids,
38
48
  latestDateCovered,
39
- } = await this.salesforce.getUpdatedForObjectType(
40
- this.objectType,
49
+ } = await salesforce.getUpdatedForObjectType(
50
+ objectType,
41
51
  startTimestamp,
42
52
  endTimestamp,
43
53
  );
44
- this.setLatestDateCovered(latestDateCovered);
54
+ setLatestDateCovered(latestDateCovered);
45
55
 
46
56
  if (!ids?.length) {
47
57
  return console.log("No batch requests to send");
48
58
  }
49
59
 
50
- const { results } = await this.batchRequest({
51
- data: {
52
- batchRequests: this.getBatchRequests(ids),
53
- },
60
+ const results = await makeChunkBatchRequestsAndGetResults({
61
+ ids,
54
62
  });
55
63
 
56
64
  results
57
65
  .filter(({ statusCode }) => statusCode === 200)
58
66
  .forEach(({ result: item }) => {
59
- const meta = this.generateMeta(item);
60
- this.$emit(item, meta);
67
+ const meta = generateMeta(item);
68
+ emit(item, meta);
61
69
  });
62
70
  },
63
71
  },
@@ -8,7 +8,7 @@ export default {
8
8
  name: "New Updated Object (Instant, of Selectable Type)",
9
9
  key: "salesforce_rest_api-object-updated-instant",
10
10
  description: "Emit new event immediately after an object of arbitrary type (selected as an input parameter by the user) is updated",
11
- version: "0.1.3",
11
+ version: "0.1.4",
12
12
  methods: {
13
13
  ...common.methods,
14
14
  generateMeta(data) {
@@ -8,7 +8,7 @@ export default {
8
8
  name: "New Deleted Record (of Selectable Type)",
9
9
  key: "salesforce_rest_api-record-deleted",
10
10
  description: "Emit new event (at regular intervals) when a record of arbitrary object type (selected as an input parameter by the user) is deleted. [See the docs](https://sforce.co/3msDDEE) for more information.",
11
- version: "0.0.1",
11
+ version: "0.0.2",
12
12
  methods: {
13
13
  ...common.methods,
14
14
  generateMeta(item) {
@@ -8,7 +8,7 @@ export default {
8
8
  name: "New Deleted Record (Instant, of Selectable Type)",
9
9
  key: "salesforce_rest_api-record-deleted-instant",
10
10
  description: "Emit new event immediately after a record of arbitrary object type (selected as an input parameter by the user) is deleted",
11
- version: "0.0.1",
11
+ version: "0.0.2",
12
12
  methods: {
13
13
  ...common.methods,
14
14
  generateMeta(data) {
@@ -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.6",
18
+ version: "0.1.8",
19
19
  props: {
20
20
  ...common.props,
21
21
  objectType: {
@@ -130,8 +130,7 @@ export default {
130
130
  salesforce,
131
131
  _getHistoryObjectType,
132
132
  setLatestDateCovered,
133
- batchRequest,
134
- getBatchRequests,
133
+ makeChunkBatchRequestsAndGetResults,
135
134
  isRelevant,
136
135
  getUniqueParentIds,
137
136
  _getParentId,
@@ -154,11 +153,10 @@ export default {
154
153
  setLatestDateCovered((new Date(latestDateCovered)).toISOString());
155
154
 
156
155
  if (ids?.length) {
157
- ({ results: historyItemRetrievals } = await batchRequest({
158
- data: {
159
- batchRequests: getBatchRequests(ids, historyObjectType),
160
- },
161
- }));
156
+ historyItemRetrievals = await makeChunkBatchRequestsAndGetResults({
157
+ ids,
158
+ objectType: historyObjectType,
159
+ });
162
160
  }
163
161
 
164
162
  const historyItems = historyItemRetrievals
@@ -170,11 +168,9 @@ export default {
170
168
  const parentIds = getUniqueParentIds(historyItems);
171
169
 
172
170
  if (parentIds.length) {
173
- ({ results: itemRetrievals } = await batchRequest({
174
- data: {
175
- batchRequests: getBatchRequests(parentIds),
176
- },
177
- }));
171
+ itemRetrievals = await makeChunkBatchRequestsAndGetResults({
172
+ ids: parentIds,
173
+ });
178
174
  }
179
175
 
180
176
  const itemsById = itemRetrievals
@@ -9,7 +9,7 @@ export default {
9
9
  name: "New Updated Field on Record (Instant, of Selectable Type)",
10
10
  key: "salesforce_rest_api-updated-field-on-record-instant",
11
11
  description: "Emit new event immediately after a field of your choosing is updated on any record of a specified Salesforce object",
12
- version: "0.1.3",
12
+ version: "0.1.4",
13
13
  props: {
14
14
  ...common.props,
15
15
  field: {