@pipedream/salesforce_rest_api 1.0.1 → 1.0.3
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/README.md +27 -16
- package/actions/add-contact-to-campaign/add-contact-to-campaign.mjs +1 -1
- package/actions/add-lead-to-campaign/add-lead-to-campaign.mjs +1 -1
- package/actions/convert-soap-xml-to-json/convert-soap-xml-to-json.mjs +1 -1
- package/actions/create-account/create-account.mjs +1 -1
- package/actions/create-attachment/create-attachment.mjs +1 -1
- package/actions/create-campaign/create-campaign.mjs +1 -1
- package/actions/create-case/create-case.mjs +1 -1
- package/actions/create-casecomment/create-casecomment.mjs +1 -1
- package/actions/create-contact/create-contact.mjs +1 -1
- package/actions/create-event/create-event.mjs +1 -1
- package/actions/create-lead/create-lead.mjs +1 -1
- package/actions/create-note/create-note.mjs +1 -1
- package/actions/create-opportunity/create-opportunity.mjs +1 -1
- package/actions/create-record/create-record.mjs +1 -1
- package/actions/create-task/create-task.mjs +1 -1
- package/actions/delete-opportunity/delete-opportunity.mjs +1 -1
- package/actions/delete-record/delete-record.mjs +1 -1
- package/actions/find-create-record/find-create-record.mjs +1 -1
- package/actions/find-records/find-records.mjs +1 -1
- package/actions/get-sobject-fields-values/get-sobject-fields-values.mjs +1 -1
- package/actions/insert-blob-data/insert-blob-data.mjs +1 -1
- package/actions/post-feed-to-chatter/post-feed-to-chatter.mjs +1 -1
- package/actions/soql-search/soql-search.mjs +1 -1
- package/actions/sosl-search/sosl-search.mjs +1 -1
- package/actions/update-account/update-account.mjs +1 -1
- package/actions/update-contact/update-contact.mjs +1 -1
- package/actions/update-opportunity/update-opportunity.mjs +1 -1
- package/actions/update-record/update-record.mjs +1 -1
- package/common/constants.mjs +4 -0
- package/package.json +1 -1
- package/salesforce_rest_api.app.mjs +15 -32
- package/sources/common-instant.mjs +29 -13
- package/sources/common.mjs +60 -15
- package/sources/new-outbound-message/new-outbound-message.mjs +1 -1
- package/sources/new-record/new-record.mjs +53 -39
- package/sources/new-record-instant/new-record-instant.mjs +1 -1
- package/sources/object-updated/object-updated.mjs +56 -28
- package/sources/object-updated-instant/object-updated-instant.mjs +1 -1
- package/sources/record-deleted/record-deleted.mjs +1 -1
- package/sources/record-deleted-instant/record-deleted-instant.mjs +1 -1
- package/sources/updated-field-on-record/updated-field-on-record.mjs +77 -116
- package/sources/updated-field-on-record-instant/updated-field-on-record-instant.mjs +1 -1
package/README.md
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
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
|
-
##
|
|
5
|
+
## Prerequisite: Salesforce Edition with API Access
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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.
|
|
11
19
|
|
|
12
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.
|
|
13
21
|
|
|
@@ -18,13 +26,10 @@ Here is a step-by-step on how to do this:
|
|
|
18
26
|
1. Navigate to your Salesforce instance, and click the Setup wheel in the top-right corner.
|
|
19
27
|
2. Under the Administration tab on the lefthand sidebar, click Users --> Permission Sets.
|
|
20
28
|
3. On the Permissions Set page, click New.
|
|
21
|
-
4. Create a new permission set, give it a label, API name, and description. Example:
|
|
29
|
+
4. Create a new permission set, give it a label, API name, and description. Example: <br>
|
|
22
30
|
**Label**: Pipedream API Access
|
|
23
31
|
**API Name**: Pipedream
|
|
24
|
-
**Description**: Adds a set of permissions required for Pipedream
|
|
25
|
-
- Apex REST Services
|
|
26
|
-
- API Enabled
|
|
27
|
-
- Author Apex
|
|
32
|
+
**Description**: Adds a set of permissions required for Pipedream.
|
|
28
33
|
|
|
29
34
|
<img src="https://res.cloudinary.com/dpenc2lit/image/upload/v1702598220/Screenshot_2023-12-14_at_2.57.21_PM_dfgsrw.png" width=500>
|
|
30
35
|
|
|
@@ -36,13 +41,18 @@ Here is a step-by-step on how to do this:
|
|
|
36
41
|
6. From System Permissions, click Edit.
|
|
37
42
|
<img src="https://res.cloudinary.com/dpenc2lit/image/upload/v1702598417/Screenshot_2023-12-14_at_3.01.38_PM_pvbopv.png" width=500>
|
|
38
43
|
|
|
39
|
-
7. Select the following
|
|
40
|
-
- Apex REST Services
|
|
44
|
+
7. Select the following permission, and click Save.
|
|
41
45
|
- API Enabled
|
|
42
|
-
|
|
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
|
|
43
53
|
<img src="https://res.cloudinary.com/dpenc2lit/image/upload/v1702598514/Screenshot_2023-12-14_at_3.48.50_PM_pcychy.png" width=500>
|
|
44
54
|
|
|
45
|
-
8. The list of added permissions should look like this, and click save again.
|
|
55
|
+
8. The list of added permissions (6) should look like this, and click save again.
|
|
46
56
|
<img src="https://res.cloudinary.com/dpenc2lit/image/upload/v1702598417/Screenshot_2023-12-14_at_3.10.17_PM_urgge8.png" width=500>
|
|
47
57
|
|
|
48
58
|
**Add Permission Set to User**
|
|
@@ -53,7 +63,8 @@ Here is a step-by-step on how to do this:
|
|
|
53
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.
|
|
54
64
|
<img src="https://res.cloudinary.com/dpenc2lit/image/upload/v1702598514/Screenshot_2023-12-14_at_3.52.42_PM_w4ge4p.png" width=500>
|
|
55
65
|
|
|
56
|
-
11. You should now be able to use
|
|
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
|
+
|
|
57
68
|
|
|
58
69
|
# Troubleshooting
|
|
59
70
|
|
|
@@ -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.
|
|
15
|
+
version: "0.0.5",
|
|
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.
|
|
15
|
+
version: "0.0.5",
|
|
16
16
|
type: "action",
|
|
17
17
|
props: {
|
|
18
18
|
salesForceRestApi,
|
|
@@ -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.
|
|
8
|
+
version: "0.0.4",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
salesforce_rest_api,
|
|
@@ -17,7 +17,7 @@ export default {
|
|
|
17
17
|
See [Account SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_account.htm)
|
|
18
18
|
and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
|
|
19
19
|
`),
|
|
20
|
-
version: "0.2.
|
|
20
|
+
version: "0.2.6",
|
|
21
21
|
type: "action",
|
|
22
22
|
props: {
|
|
23
23
|
salesforce,
|
|
@@ -16,7 +16,7 @@ export default {
|
|
|
16
16
|
See [Attachment SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_attachment.htm)
|
|
17
17
|
and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
|
|
18
18
|
`),
|
|
19
|
-
version: "0.3.
|
|
19
|
+
version: "0.3.6",
|
|
20
20
|
type: "action",
|
|
21
21
|
props: {
|
|
22
22
|
salesforce,
|
|
@@ -16,7 +16,7 @@ export default {
|
|
|
16
16
|
See [Campaign SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_campaign.htm)
|
|
17
17
|
and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
|
|
18
18
|
`),
|
|
19
|
-
version: "0.2.
|
|
19
|
+
version: "0.2.6",
|
|
20
20
|
type: "action",
|
|
21
21
|
props: {
|
|
22
22
|
salesforce,
|
|
@@ -16,7 +16,7 @@ export default {
|
|
|
16
16
|
See [Case SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_case.htm)
|
|
17
17
|
and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
|
|
18
18
|
`),
|
|
19
|
-
version: "0.2.
|
|
19
|
+
version: "0.2.6",
|
|
20
20
|
type: "action",
|
|
21
21
|
props: {
|
|
22
22
|
salesforce,
|
|
@@ -16,7 +16,7 @@ export default {
|
|
|
16
16
|
See [CaseComment SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_casecomment.htm)
|
|
17
17
|
and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
|
|
18
18
|
`),
|
|
19
|
-
version: "0.2.
|
|
19
|
+
version: "0.2.6",
|
|
20
20
|
type: "action",
|
|
21
21
|
props: {
|
|
22
22
|
salesforce,
|
|
@@ -16,7 +16,7 @@ export default {
|
|
|
16
16
|
See [Contact SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_contact.htm)
|
|
17
17
|
and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
|
|
18
18
|
`),
|
|
19
|
-
version: "0.2.
|
|
19
|
+
version: "0.2.6",
|
|
20
20
|
type: "action",
|
|
21
21
|
props: {
|
|
22
22
|
salesforce,
|
|
@@ -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.
|
|
14
|
+
version: "0.2.6",
|
|
15
15
|
type: "action",
|
|
16
16
|
props: {
|
|
17
17
|
salesforce,
|
|
@@ -16,7 +16,7 @@ export default {
|
|
|
16
16
|
See [Lead SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_lead.htm)
|
|
17
17
|
and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
|
|
18
18
|
`),
|
|
19
|
-
version: "0.2.
|
|
19
|
+
version: "0.2.6",
|
|
20
20
|
type: "action",
|
|
21
21
|
props: {
|
|
22
22
|
salesforce,
|
|
@@ -16,7 +16,7 @@ export default {
|
|
|
16
16
|
See [Note SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_note.htm)
|
|
17
17
|
and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
|
|
18
18
|
`),
|
|
19
|
-
version: "0.2.
|
|
19
|
+
version: "0.2.6",
|
|
20
20
|
type: "action",
|
|
21
21
|
props: {
|
|
22
22
|
salesforce,
|
|
@@ -16,7 +16,7 @@ export default {
|
|
|
16
16
|
See [Opportunity SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_opportunity.htm)
|
|
17
17
|
and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
|
|
18
18
|
`),
|
|
19
|
-
version: "0.2.
|
|
19
|
+
version: "0.2.6",
|
|
20
20
|
type: "action",
|
|
21
21
|
props: {
|
|
22
22
|
salesforce,
|
|
@@ -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.
|
|
11
|
+
version: "0.2.6",
|
|
12
12
|
type: "action",
|
|
13
13
|
props: {
|
|
14
14
|
salesforce,
|
|
@@ -16,7 +16,7 @@ export default {
|
|
|
16
16
|
See [Task SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_task.htm)
|
|
17
17
|
and [Create Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_sobject_create.htm)
|
|
18
18
|
`),
|
|
19
|
-
version: "0.3.
|
|
19
|
+
version: "0.3.6",
|
|
20
20
|
type: "action",
|
|
21
21
|
props: {
|
|
22
22
|
salesforce,
|
|
@@ -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.
|
|
12
|
+
version: "0.2.6",
|
|
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.
|
|
8
|
+
version: "0.1.4",
|
|
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.
|
|
9
|
+
version: "0.1.4",
|
|
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.
|
|
8
|
+
version: "0.1.4",
|
|
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.
|
|
11
|
+
version: "0.2.6",
|
|
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.
|
|
11
|
+
version: "0.2.6",
|
|
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.
|
|
11
|
+
version: "0.0.5",
|
|
12
12
|
type: "action",
|
|
13
13
|
props: {
|
|
14
14
|
salesForceRestApi,
|
|
@@ -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.
|
|
11
|
+
version: "0.2.6",
|
|
12
12
|
type: "action",
|
|
13
13
|
props: {
|
|
14
14
|
salesforce,
|
|
@@ -17,7 +17,7 @@ export default {
|
|
|
17
17
|
See [Account SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_account.htm)
|
|
18
18
|
and [Update Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_update_fields.htm)
|
|
19
19
|
`),
|
|
20
|
-
version: "0.2.
|
|
20
|
+
version: "0.2.6",
|
|
21
21
|
type: "action",
|
|
22
22
|
props: {
|
|
23
23
|
salesforce,
|
|
@@ -16,7 +16,7 @@ export default {
|
|
|
16
16
|
See [Contact SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_contact.htm)
|
|
17
17
|
and [Update Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_update_fields.htm)
|
|
18
18
|
`),
|
|
19
|
-
version: "0.2.
|
|
19
|
+
version: "0.2.6",
|
|
20
20
|
type: "action",
|
|
21
21
|
props: {
|
|
22
22
|
salesforce,
|
|
@@ -16,7 +16,7 @@ export default {
|
|
|
16
16
|
See [Opportunity SObject](https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_opportunity.htm)
|
|
17
17
|
and [Update Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_update_fields.htm)
|
|
18
18
|
`),
|
|
19
|
-
version: "0.2.
|
|
19
|
+
version: "0.2.6",
|
|
20
20
|
type: "action",
|
|
21
21
|
props: {
|
|
22
22
|
salesforce,
|
|
@@ -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.
|
|
11
|
+
version: "0.2.6",
|
|
12
12
|
type: "action",
|
|
13
13
|
props: {
|
|
14
14
|
salesforce,
|
package/common/constants.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { axios } from "@pipedream/platform";
|
|
2
|
-
import salesforceWebhooks from "salesforce-webhooks";
|
|
3
|
-
const { SalesforceClient } = salesforceWebhooks;
|
|
4
2
|
|
|
5
3
|
export default {
|
|
6
4
|
type: "app",
|
|
@@ -23,14 +21,21 @@ export default {
|
|
|
23
21
|
type: "string",
|
|
24
22
|
label: "SObject Type",
|
|
25
23
|
description: "Standard object type of the record to get field values from",
|
|
26
|
-
async options(
|
|
24
|
+
async options({
|
|
25
|
+
page,
|
|
26
|
+
filter = this.isValidSObject,
|
|
27
|
+
mapper = ({
|
|
28
|
+
label, name: value,
|
|
29
|
+
}) => ({
|
|
30
|
+
label,
|
|
31
|
+
value,
|
|
32
|
+
}),
|
|
33
|
+
}) {
|
|
34
|
+
if (page !== 0) {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
27
37
|
const { sobjects } = await this.listSObjectTypes();
|
|
28
|
-
return sobjects
|
|
29
|
-
.filter(this.isValidSObject)
|
|
30
|
-
.map((sobject) => ({
|
|
31
|
-
label: sobject.label,
|
|
32
|
-
value: sobject.name,
|
|
33
|
-
}));
|
|
38
|
+
return sobjects.filter(filter).map(mapper);
|
|
34
39
|
},
|
|
35
40
|
},
|
|
36
41
|
field: {
|
|
@@ -175,14 +180,6 @@ export default {
|
|
|
175
180
|
// Remove milliseconds from date ISO string
|
|
176
181
|
return dateString.replace(/\.[0-9]{3}/, "");
|
|
177
182
|
},
|
|
178
|
-
_getSalesforceClient() {
|
|
179
|
-
const clientOpts = {
|
|
180
|
-
apiVersion: this._apiVersion(),
|
|
181
|
-
authToken: this._authToken(),
|
|
182
|
-
instance: this._subdomain(),
|
|
183
|
-
};
|
|
184
|
-
return new SalesforceClient(clientOpts);
|
|
185
|
-
},
|
|
186
183
|
isValidSObject(sobject) {
|
|
187
184
|
// Only the activity of those SObject types that have the `replicateable`
|
|
188
185
|
// flag set is published via the `getUpdated` API.
|
|
@@ -196,21 +193,6 @@ export default {
|
|
|
196
193
|
sobject.name.includes("History")
|
|
197
194
|
);
|
|
198
195
|
},
|
|
199
|
-
async createWebhook(endpointUrl, sObjectType, event, secretToken, opts) {
|
|
200
|
-
const client = this._getSalesforceClient();
|
|
201
|
-
const webhookOpts = {
|
|
202
|
-
endpointUrl,
|
|
203
|
-
sObjectType,
|
|
204
|
-
event,
|
|
205
|
-
secretToken,
|
|
206
|
-
...opts,
|
|
207
|
-
};
|
|
208
|
-
return client.createWebhook(webhookOpts);
|
|
209
|
-
},
|
|
210
|
-
async deleteWebhook(webhookData) {
|
|
211
|
-
const client = this._getSalesforceClient();
|
|
212
|
-
return client.deleteWebhook(webhookData);
|
|
213
|
-
},
|
|
214
196
|
async listSObjectTypes() {
|
|
215
197
|
const url = this._sObjectsApiUrl();
|
|
216
198
|
return this._makeRequest({
|
|
@@ -226,6 +208,7 @@ export default {
|
|
|
226
208
|
async getNameFieldForObjectType(objectType) {
|
|
227
209
|
const url = this._sObjectTypeDescriptionApiUrl(objectType);
|
|
228
210
|
const data = await this._makeRequest({
|
|
211
|
+
debug: true,
|
|
229
212
|
url,
|
|
230
213
|
});
|
|
231
214
|
const nameField = data.fields.find((f) => f.nameField);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from "uuid";
|
|
2
|
-
|
|
3
2
|
import salesforce from "../salesforce_rest_api.app.mjs";
|
|
3
|
+
import salesforceWebhooks from "salesforce-webhooks";
|
|
4
|
+
|
|
5
|
+
const { SalesforceClient } = salesforceWebhooks;
|
|
4
6
|
|
|
5
7
|
export default {
|
|
6
8
|
dedupe: "unique",
|
|
@@ -31,19 +33,17 @@ export default {
|
|
|
31
33
|
const secretToken = uuidv4();
|
|
32
34
|
let webhookData;
|
|
33
35
|
try {
|
|
34
|
-
webhookData = await this.
|
|
35
|
-
this.http.endpoint,
|
|
36
|
-
this.objectType,
|
|
37
|
-
this.getEventType(),
|
|
36
|
+
webhookData = await this.createWebhook({
|
|
37
|
+
endpointUrl: this.http.endpoint,
|
|
38
|
+
sObjectType: this.objectType,
|
|
39
|
+
event: this.getEventType(),
|
|
38
40
|
secretToken,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
);
|
|
41
|
+
fieldsToCheck: this.getFieldsToCheck(),
|
|
42
|
+
fieldsToCheckMode: this.getFieldsToCheckMode(),
|
|
43
|
+
skipValidation: true, // neccessary for custom objects
|
|
44
|
+
});
|
|
45
45
|
} catch (err) {
|
|
46
|
-
console.log("Create webhook error:", err
|
|
46
|
+
console.log("Create webhook error:", err);
|
|
47
47
|
throw err;
|
|
48
48
|
}
|
|
49
49
|
this._setSecretToken(secretToken);
|
|
@@ -52,10 +52,26 @@ export default {
|
|
|
52
52
|
async deactivate() {
|
|
53
53
|
// Create the webhook from the Salesforce platform
|
|
54
54
|
const webhookData = this._getWebhookData();
|
|
55
|
-
await this.
|
|
55
|
+
await this.deleteWebhook(webhookData);
|
|
56
56
|
},
|
|
57
57
|
},
|
|
58
58
|
methods: {
|
|
59
|
+
getClient() {
|
|
60
|
+
const { salesforce } = this;
|
|
61
|
+
return new SalesforceClient({
|
|
62
|
+
apiVersion: salesforce._apiVersion(),
|
|
63
|
+
authToken: salesforce._authToken(),
|
|
64
|
+
instance: salesforce._subdomain(),
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
createWebhook(args = {}) {
|
|
68
|
+
const client = this.getClient();
|
|
69
|
+
return client.createWebhook(args);
|
|
70
|
+
},
|
|
71
|
+
deleteWebhook(args = {}) {
|
|
72
|
+
const client = this.getClient();
|
|
73
|
+
return client.deleteWebhook(args);
|
|
74
|
+
},
|
|
59
75
|
_getSecretToken() {
|
|
60
76
|
return this.db.get("secretToken");
|
|
61
77
|
},
|
package/sources/common.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
|
|
2
2
|
import salesforce from "../salesforce_rest_api.app.mjs";
|
|
3
|
+
import constants from "../common/constants.mjs";
|
|
3
4
|
|
|
4
5
|
export default {
|
|
5
6
|
dedupe: "unique",
|
|
@@ -36,6 +37,12 @@ export default {
|
|
|
36
37
|
},
|
|
37
38
|
},
|
|
38
39
|
methods: {
|
|
40
|
+
getObjectTypeColumns() {
|
|
41
|
+
return this.db.get("columns") ?? [];
|
|
42
|
+
},
|
|
43
|
+
setObjectTypeColumns(columns) {
|
|
44
|
+
this.db.set("columns", columns);
|
|
45
|
+
},
|
|
39
46
|
getLatestDateCovered() {
|
|
40
47
|
return this.db.get("latestDateCovered");
|
|
41
48
|
},
|
|
@@ -51,28 +58,66 @@ export default {
|
|
|
51
58
|
processEvent() {
|
|
52
59
|
throw new Error("processEvent is not implemented");
|
|
53
60
|
},
|
|
54
|
-
|
|
55
|
-
const {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
getBatchRequests(ids, historyObjectType) {
|
|
62
|
-
return ids.map((id) => ({
|
|
63
|
-
method: "GET",
|
|
64
|
-
url: this.getRelativeObjectUrl(id, historyObjectType),
|
|
65
|
-
}));
|
|
61
|
+
getObjectTypeDescription(objectType) {
|
|
62
|
+
const { salesforce } = this;
|
|
63
|
+
return salesforce._makeRequest({
|
|
64
|
+
debug: true,
|
|
65
|
+
url: salesforce._sObjectTypeDescriptionApiUrl(objectType),
|
|
66
|
+
});
|
|
66
67
|
},
|
|
67
|
-
|
|
68
|
+
query({
|
|
69
|
+
query, ...args
|
|
70
|
+
} = {}) {
|
|
68
71
|
const { salesforce } = this;
|
|
72
|
+
const baseUrl = salesforce._baseApiVersionUrl();
|
|
69
73
|
return salesforce._makeRequest({
|
|
74
|
+
url: `${baseUrl}/query/?q=${encodeURIComponent(query)}`,
|
|
75
|
+
...args,
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
queryObjects({
|
|
79
|
+
objectType, columns,
|
|
80
|
+
startTimestamp, endTimestamp,
|
|
81
|
+
dateFieldName = constants.FIELD_NAME.CREATED_DATE,
|
|
82
|
+
limit = 100, offset = 0, ...args
|
|
83
|
+
} = {}) {
|
|
84
|
+
return this.query({
|
|
70
85
|
debug: true,
|
|
71
|
-
|
|
72
|
-
|
|
86
|
+
query: `
|
|
87
|
+
SELECT ${columns.join(", ")}
|
|
88
|
+
FROM ${objectType}
|
|
89
|
+
WHERE ${dateFieldName} > ${startTimestamp} AND ${dateFieldName} <= ${endTimestamp}
|
|
90
|
+
ORDER BY ${dateFieldName} DESC
|
|
91
|
+
LIMIT ${limit} OFFSET ${offset}
|
|
92
|
+
`,
|
|
73
93
|
...args,
|
|
74
94
|
});
|
|
75
95
|
},
|
|
96
|
+
async paginate({
|
|
97
|
+
fn = this.queryObjects, limit = 100, offset = 0, maxRecords = 4000, ...args
|
|
98
|
+
} = {}) {
|
|
99
|
+
let records = [];
|
|
100
|
+
let nextRecords = [];
|
|
101
|
+
|
|
102
|
+
do {
|
|
103
|
+
({ records: nextRecords } =
|
|
104
|
+
await fn({
|
|
105
|
+
...args,
|
|
106
|
+
offset,
|
|
107
|
+
limit,
|
|
108
|
+
}));
|
|
109
|
+
|
|
110
|
+
records = [
|
|
111
|
+
...records,
|
|
112
|
+
...nextRecords,
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
offset += limit;
|
|
116
|
+
|
|
117
|
+
} while (records.length < maxRecords && nextRecords.length === limit);
|
|
118
|
+
|
|
119
|
+
return records;
|
|
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.
|
|
9
|
+
version: "0.1.5",
|
|
10
10
|
dedupe: "unique",
|
|
11
11
|
props: {
|
|
12
12
|
db: "$.service.db",
|
|
@@ -4,72 +4,86 @@ import common from "../common.mjs";
|
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
...common,
|
|
7
|
+
dedupe: "greatest",
|
|
7
8
|
type: "source",
|
|
8
9
|
name: "New Record (of Selectable Type)",
|
|
9
10
|
key: "salesforce_rest_api-new-record",
|
|
10
11
|
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.
|
|
12
|
+
version: "0.0.4",
|
|
13
|
+
hooks: {
|
|
14
|
+
...common.hooks,
|
|
15
|
+
async activate() {
|
|
16
|
+
const {
|
|
17
|
+
objectType,
|
|
18
|
+
getObjectTypeDescription,
|
|
19
|
+
setObjectTypeColumns,
|
|
20
|
+
} = this;
|
|
21
|
+
|
|
22
|
+
await common.hooks.activate.call(this);
|
|
23
|
+
|
|
24
|
+
const { fields } = await getObjectTypeDescription(objectType);
|
|
25
|
+
const columns = fields.map(({ name }) => name);
|
|
26
|
+
|
|
27
|
+
setObjectTypeColumns(columns);
|
|
28
|
+
},
|
|
29
|
+
},
|
|
12
30
|
methods: {
|
|
13
31
|
...common.methods,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
const startDate = Date.parse(startTimestamp);
|
|
19
|
-
const endDate = Date.parse(endTimestamp);
|
|
20
|
-
const createdDate = Date.parse(item.CreatedDate);
|
|
21
|
-
return startDate <= createdDate && endDate >= createdDate;
|
|
22
|
-
},
|
|
23
|
-
generateMeta(item) {
|
|
24
|
-
const nameField = this.getNameField();
|
|
32
|
+
generateMeta(item, fieldName) {
|
|
33
|
+
const { objectType } = this;
|
|
25
34
|
const {
|
|
26
35
|
CreatedDate: createdDate,
|
|
36
|
+
[fieldName]: name,
|
|
27
37
|
Id: id,
|
|
28
|
-
[nameField]: name,
|
|
29
38
|
} = item;
|
|
30
|
-
const entityType = startCase(
|
|
39
|
+
const entityType = startCase(objectType);
|
|
31
40
|
const summary = `New ${entityType} created: ${name}`;
|
|
32
41
|
const ts = Date.parse(createdDate);
|
|
33
42
|
return {
|
|
34
|
-
id
|
|
43
|
+
id: `${id}-${ts}`,
|
|
35
44
|
summary,
|
|
36
45
|
ts,
|
|
37
46
|
};
|
|
38
47
|
},
|
|
39
48
|
async processEvent(eventData) {
|
|
49
|
+
const {
|
|
50
|
+
paginate,
|
|
51
|
+
objectType,
|
|
52
|
+
setLatestDateCovered,
|
|
53
|
+
getObjectTypeColumns,
|
|
54
|
+
getNameField,
|
|
55
|
+
generateMeta,
|
|
56
|
+
$emit: emit,
|
|
57
|
+
} = this;
|
|
58
|
+
|
|
40
59
|
const {
|
|
41
60
|
startTimestamp,
|
|
42
61
|
endTimestamp,
|
|
43
62
|
} = eventData;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
63
|
+
|
|
64
|
+
const fieldName = getNameField();
|
|
65
|
+
const columns = getObjectTypeColumns();
|
|
66
|
+
|
|
67
|
+
const events = await paginate({
|
|
68
|
+
objectType,
|
|
49
69
|
startTimestamp,
|
|
50
70
|
endTimestamp,
|
|
51
|
-
|
|
52
|
-
|
|
71
|
+
columns,
|
|
72
|
+
});
|
|
53
73
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
74
|
+
const [
|
|
75
|
+
latestEvent,
|
|
76
|
+
] = events;
|
|
57
77
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
},
|
|
62
|
-
});
|
|
78
|
+
if (latestEvent?.CreatedDate) {
|
|
79
|
+
setLatestDateCovered((new Date(latestEvent.CreatedDate)).toISOString());
|
|
80
|
+
}
|
|
63
81
|
|
|
64
|
-
|
|
65
|
-
.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
&& this.isItemRelevant(item, startTimestamp, endTimestamp))
|
|
70
|
-
.forEach(({ result: item }) => {
|
|
71
|
-
const meta = this.generateMeta(item);
|
|
72
|
-
this.$emit(item, meta);
|
|
82
|
+
Array.from(events)
|
|
83
|
+
.reverse()
|
|
84
|
+
.forEach((item) => {
|
|
85
|
+
const meta = generateMeta(item, fieldName);
|
|
86
|
+
emit(item, meta);
|
|
73
87
|
});
|
|
74
88
|
},
|
|
75
89
|
},
|
|
@@ -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.
|
|
10
|
+
version: "0.0.3",
|
|
11
11
|
hooks: {
|
|
12
12
|
...common.hooks,
|
|
13
13
|
async deploy() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import startCase from "lodash/startCase.js";
|
|
2
|
-
|
|
3
2
|
import common from "../common.mjs";
|
|
3
|
+
import constants from "../../common/constants.mjs";
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
...common,
|
|
@@ -8,56 +8,84 @@ 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.
|
|
11
|
+
version: "0.1.9",
|
|
12
|
+
hooks: {
|
|
13
|
+
...common.hooks,
|
|
14
|
+
async activate() {
|
|
15
|
+
const {
|
|
16
|
+
objectType,
|
|
17
|
+
getObjectTypeDescription,
|
|
18
|
+
setObjectTypeColumns,
|
|
19
|
+
} = this;
|
|
20
|
+
|
|
21
|
+
await common.hooks.activate.call(this);
|
|
22
|
+
|
|
23
|
+
const { fields } = await getObjectTypeDescription(objectType);
|
|
24
|
+
const columns = fields.map(({ name }) => name);
|
|
25
|
+
|
|
26
|
+
setObjectTypeColumns(columns);
|
|
27
|
+
},
|
|
28
|
+
},
|
|
12
29
|
methods: {
|
|
13
30
|
...common.methods,
|
|
14
|
-
generateMeta(item) {
|
|
15
|
-
const
|
|
31
|
+
generateMeta(item, fieldName) {
|
|
32
|
+
const { objectType } = this;
|
|
33
|
+
|
|
16
34
|
const {
|
|
17
35
|
LastModifiedDate: lastModifiedDate,
|
|
36
|
+
[fieldName]: name,
|
|
18
37
|
Id: id,
|
|
19
|
-
[nameField]: name,
|
|
20
38
|
} = item;
|
|
21
|
-
|
|
39
|
+
|
|
40
|
+
const entityType = startCase(objectType);
|
|
22
41
|
const summary = `${entityType} updated: ${name}`;
|
|
23
42
|
const ts = Date.parse(lastModifiedDate);
|
|
24
|
-
const compositeId = `${id}-${ts}`;
|
|
25
43
|
return {
|
|
26
|
-
id:
|
|
44
|
+
id: `${id}-${ts}`,
|
|
27
45
|
summary,
|
|
28
46
|
ts,
|
|
29
47
|
};
|
|
30
48
|
},
|
|
31
49
|
async processEvent(eventData) {
|
|
50
|
+
const {
|
|
51
|
+
getNameField,
|
|
52
|
+
getObjectTypeColumns,
|
|
53
|
+
paginate,
|
|
54
|
+
objectType,
|
|
55
|
+
setLatestDateCovered,
|
|
56
|
+
generateMeta,
|
|
57
|
+
$emit: emit,
|
|
58
|
+
} = this;
|
|
59
|
+
|
|
32
60
|
const {
|
|
33
61
|
startTimestamp,
|
|
34
62
|
endTimestamp,
|
|
35
63
|
} = eventData;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
64
|
+
|
|
65
|
+
const fieldName = getNameField();
|
|
66
|
+
const columns = getObjectTypeColumns();
|
|
67
|
+
|
|
68
|
+
const events = await paginate({
|
|
69
|
+
objectType,
|
|
41
70
|
startTimestamp,
|
|
42
71
|
endTimestamp,
|
|
43
|
-
|
|
44
|
-
|
|
72
|
+
columns,
|
|
73
|
+
dateFieldName: constants.FIELD_NAME.LAST_MODIFIED_DATE,
|
|
74
|
+
});
|
|
45
75
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
76
|
+
const [
|
|
77
|
+
latestEvent,
|
|
78
|
+
] = events;
|
|
49
79
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
},
|
|
54
|
-
});
|
|
80
|
+
if (latestEvent?.LastModifiedDate) {
|
|
81
|
+
setLatestDateCovered((new Date(latestEvent.LastModifiedDate)).toISOString());
|
|
82
|
+
}
|
|
55
83
|
|
|
56
|
-
|
|
57
|
-
.
|
|
58
|
-
.forEach((
|
|
59
|
-
const meta =
|
|
60
|
-
|
|
84
|
+
Array.from(events)
|
|
85
|
+
.reverse()
|
|
86
|
+
.forEach((item) => {
|
|
87
|
+
const meta = generateMeta(item, fieldName);
|
|
88
|
+
emit(item, meta);
|
|
61
89
|
});
|
|
62
90
|
},
|
|
63
91
|
},
|
|
@@ -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.
|
|
11
|
+
version: "0.1.5",
|
|
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.
|
|
11
|
+
version: "0.0.3",
|
|
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.
|
|
11
|
+
version: "0.0.3",
|
|
12
12
|
methods: {
|
|
13
13
|
...common.methods,
|
|
14
14
|
generateMeta(data) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import words from "lodash/words.js";
|
|
3
2
|
import common from "../common.mjs";
|
|
3
|
+
|
|
4
4
|
const { salesforce } = common.props;
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -11,38 +11,29 @@ const { salesforce } = common.props;
|
|
|
11
11
|
*/
|
|
12
12
|
export default {
|
|
13
13
|
...common,
|
|
14
|
+
dedupe: "greatest",
|
|
14
15
|
type: "source",
|
|
15
16
|
name: "New Updated Field on Record (of Selectable Type)",
|
|
16
17
|
key: "salesforce_rest_api-updated-field-on-record",
|
|
17
18
|
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.
|
|
19
|
+
version: "0.1.9",
|
|
19
20
|
props: {
|
|
20
21
|
...common.props,
|
|
21
22
|
objectType: {
|
|
22
23
|
type: common.props.objectType.type,
|
|
23
24
|
label: common.props.objectType.label,
|
|
24
25
|
description: common.props.objectType.description,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const options = sobjects
|
|
37
|
-
.filter(this.isValidSObject)
|
|
38
|
-
.map((sobject) => ({
|
|
39
|
-
label: sobjects.find((o) => o.name === sobject.associateParentEntity).label,
|
|
40
|
-
value: sobject.associateParentEntity,
|
|
41
|
-
}));
|
|
42
|
-
return {
|
|
43
|
-
options,
|
|
44
|
-
};
|
|
45
|
-
},
|
|
26
|
+
propDefinition: [
|
|
27
|
+
salesforce,
|
|
28
|
+
"objectType",
|
|
29
|
+
() => ({
|
|
30
|
+
filter: ({
|
|
31
|
+
replicateable,
|
|
32
|
+
associateEntityType,
|
|
33
|
+
}) => replicateable && associateEntityType === "History",
|
|
34
|
+
mapper: ({ associateParentEntity: value }) => words(value).join(" "),
|
|
35
|
+
}),
|
|
36
|
+
],
|
|
46
37
|
},
|
|
47
38
|
field: {
|
|
48
39
|
propDefinition: [
|
|
@@ -64,62 +55,64 @@ export default {
|
|
|
64
55
|
hooks: {
|
|
65
56
|
...common.hooks,
|
|
66
57
|
async activate() {
|
|
58
|
+
const {
|
|
59
|
+
objectType,
|
|
60
|
+
getObjectTypeDescription,
|
|
61
|
+
setHistoryObjectType,
|
|
62
|
+
setObjectTypeColumns,
|
|
63
|
+
} = this;
|
|
64
|
+
|
|
67
65
|
await common.hooks.activate.call(this);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
66
|
+
|
|
67
|
+
const historyObjectType = `${objectType}History`;
|
|
68
|
+
|
|
69
|
+
const { fields } = await getObjectTypeDescription(historyObjectType);
|
|
70
|
+
const columns = fields.map(({ name }) => name);
|
|
71
|
+
|
|
72
|
+
setHistoryObjectType(historyObjectType);
|
|
73
|
+
setObjectTypeColumns(columns);
|
|
73
74
|
},
|
|
74
75
|
},
|
|
75
76
|
methods: {
|
|
76
77
|
...common.methods,
|
|
77
|
-
|
|
78
|
+
getHistoryObjectType() {
|
|
78
79
|
return this.db.get("historyObjectType");
|
|
79
80
|
},
|
|
80
|
-
|
|
81
|
+
setHistoryObjectType(historyObjectType) {
|
|
81
82
|
this.db.set("historyObjectType", historyObjectType);
|
|
82
83
|
},
|
|
83
|
-
_getParentId(item) {
|
|
84
|
-
const parentIdKey = `${this.objectType}Id`;
|
|
85
|
-
return item[parentIdKey] ?? item["ParentId"];
|
|
86
|
-
},
|
|
87
|
-
getUniqueParentIds(items) {
|
|
88
|
-
// To fetch associated sObject records only once, create a set of the "parent IDs" of the
|
|
89
|
-
// history object records
|
|
90
|
-
const parentIdSet = new Set(items.map(this._getParentId).filter((id) => id));
|
|
91
|
-
return Array.from(parentIdSet);
|
|
92
|
-
},
|
|
93
|
-
isValidSObject(sobject) {
|
|
94
|
-
// Only the activity of those SObject types that have the `replicateable`
|
|
95
|
-
// flag set is published via the `getUpdated` API.
|
|
96
|
-
//
|
|
97
|
-
// See the API docs here: https://sforce.co/3gDy3uP
|
|
98
|
-
return sobject.replicateable && this.salesforce.isHistorySObject(sobject);
|
|
99
|
-
},
|
|
100
84
|
isRelevant(item) {
|
|
101
|
-
const
|
|
102
|
-
|
|
85
|
+
const {
|
|
86
|
+
field,
|
|
87
|
+
fieldUpdatedTo,
|
|
88
|
+
} = this;
|
|
89
|
+
|
|
90
|
+
const isFieldRelevant =
|
|
91
|
+
item.Field === field
|
|
92
|
+
|| item.Field === `${item.DataType}${field}`;
|
|
93
|
+
|
|
94
|
+
const isFieldValueRelevant =
|
|
95
|
+
!fieldUpdatedTo
|
|
96
|
+
|| item.NewValue === fieldUpdatedTo;
|
|
97
|
+
|
|
103
98
|
return isFieldRelevant && isFieldValueRelevant;
|
|
104
99
|
},
|
|
105
100
|
generateMeta(event) {
|
|
106
|
-
const nameField = this.getNameField();
|
|
107
101
|
const {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
} =
|
|
111
|
-
|
|
102
|
+
objectType,
|
|
103
|
+
field,
|
|
104
|
+
} = this;
|
|
105
|
+
|
|
112
106
|
const {
|
|
113
|
-
Id: id,
|
|
114
107
|
CreatedDate: createdDate,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
108
|
+
Id: id,
|
|
109
|
+
[`${objectType}Id`]: objectId,
|
|
110
|
+
} = event;
|
|
111
|
+
|
|
118
112
|
const ts = Date.parse(createdDate);
|
|
119
|
-
const compositeId = `${id}-${ts}`;
|
|
120
113
|
return {
|
|
121
|
-
id:
|
|
122
|
-
summary
|
|
114
|
+
id: `${id}-${ts}`,
|
|
115
|
+
summary: `${field} on ${objectType}: ${objectId}`,
|
|
123
116
|
ts,
|
|
124
117
|
};
|
|
125
118
|
},
|
|
@@ -127,72 +120,40 @@ export default {
|
|
|
127
120
|
startTimestamp, endTimestamp,
|
|
128
121
|
}) {
|
|
129
122
|
const {
|
|
130
|
-
|
|
131
|
-
|
|
123
|
+
getHistoryObjectType,
|
|
124
|
+
getObjectTypeColumns,
|
|
132
125
|
setLatestDateCovered,
|
|
133
|
-
batchRequest,
|
|
134
|
-
getBatchRequests,
|
|
135
126
|
isRelevant,
|
|
136
|
-
|
|
137
|
-
_getParentId,
|
|
127
|
+
paginate,
|
|
138
128
|
generateMeta,
|
|
139
129
|
$emit: emit,
|
|
140
130
|
} = this;
|
|
141
131
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const {
|
|
146
|
-
|
|
147
|
-
latestDateCovered,
|
|
148
|
-
} = await salesforce.getUpdatedForObjectType(
|
|
149
|
-
historyObjectType,
|
|
132
|
+
const objectType = getHistoryObjectType();
|
|
133
|
+
const columns = getObjectTypeColumns();
|
|
134
|
+
|
|
135
|
+
const events = await paginate({
|
|
136
|
+
objectType,
|
|
150
137
|
startTimestamp,
|
|
151
138
|
endTimestamp,
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
setLatestDateCovered((new Date(latestDateCovered)).toISOString());
|
|
155
|
-
|
|
156
|
-
if (ids?.length) {
|
|
157
|
-
({ results: historyItemRetrievals } = await batchRequest({
|
|
158
|
-
data: {
|
|
159
|
-
batchRequests: getBatchRequests(ids, historyObjectType),
|
|
160
|
-
},
|
|
161
|
-
}));
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
const historyItems = historyItemRetrievals
|
|
165
|
-
.filter(({
|
|
166
|
-
statusCode, result: item,
|
|
167
|
-
}) => statusCode === 200 && isRelevant(item))
|
|
168
|
-
.map(({ result: item }) => item);
|
|
139
|
+
columns,
|
|
140
|
+
});
|
|
169
141
|
|
|
170
|
-
const
|
|
142
|
+
const [
|
|
143
|
+
latestEvent,
|
|
144
|
+
] = events;
|
|
171
145
|
|
|
172
|
-
if (
|
|
173
|
-
(
|
|
174
|
-
data: {
|
|
175
|
-
batchRequests: getBatchRequests(parentIds),
|
|
176
|
-
},
|
|
177
|
-
}));
|
|
146
|
+
if (latestEvent?.CreatedDate) {
|
|
147
|
+
setLatestDateCovered((new Date(latestEvent.CreatedDate)).toISOString());
|
|
178
148
|
}
|
|
179
149
|
|
|
180
|
-
|
|
181
|
-
.
|
|
182
|
-
.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const events = historyItems.map((item) => ({
|
|
188
|
-
update: item,
|
|
189
|
-
record: itemsById[_getParentId(item)],
|
|
190
|
-
}));
|
|
191
|
-
|
|
192
|
-
events.forEach((event) => {
|
|
193
|
-
const meta = generateMeta(event);
|
|
194
|
-
emit(event, meta);
|
|
195
|
-
});
|
|
150
|
+
Array.from(events)
|
|
151
|
+
.reverse()
|
|
152
|
+
.filter(isRelevant)
|
|
153
|
+
.forEach((event) => {
|
|
154
|
+
const meta = generateMeta(event);
|
|
155
|
+
emit(event, meta);
|
|
156
|
+
});
|
|
196
157
|
},
|
|
197
158
|
},
|
|
198
159
|
};
|
|
@@ -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.
|
|
12
|
+
version: "0.1.5",
|
|
13
13
|
props: {
|
|
14
14
|
...common.props,
|
|
15
15
|
field: {
|