@pipedream/salesforce_rest_api 1.2.1 → 1.3.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.
Files changed (64) hide show
  1. package/README.md +92 -0
  2. package/actions/add-contact-to-campaign/add-contact-to-campaign.mjs +25 -25
  3. package/actions/add-lead-to-campaign/add-lead-to-campaign.mjs +25 -24
  4. package/actions/common/base-create-update.mjs +108 -0
  5. package/actions/convert-soap-xml-to-json/convert-soap-xml-to-json.mjs +11 -3
  6. package/actions/create-account/create-account.mjs +33 -36
  7. package/actions/create-attachment/create-attachment.mjs +36 -50
  8. package/actions/create-campaign/create-campaign.mjs +41 -37
  9. package/actions/create-case/create-case.mjs +41 -37
  10. package/actions/create-casecomment/create-casecomment.mjs +26 -38
  11. package/actions/create-contact/create-contact.mjs +38 -35
  12. package/actions/create-event/create-event.mjs +57 -66
  13. package/actions/create-lead/create-lead.mjs +34 -42
  14. package/actions/create-note/create-note.mjs +24 -43
  15. package/actions/create-opportunity/create-opportunity.mjs +38 -47
  16. package/actions/create-record/create-record.mjs +49 -15
  17. package/actions/create-task/create-task.mjs +50 -42
  18. package/actions/create-user/create-user.mjs +33 -196
  19. package/actions/delete-opportunity/delete-opportunity.mjs +17 -13
  20. package/actions/delete-record/delete-record.mjs +18 -16
  21. package/actions/find-records/find-records.mjs +41 -26
  22. package/actions/insert-blob-data/insert-blob-data.mjs +3 -7
  23. package/actions/post-feed-to-chatter/post-feed-to-chatter.mjs +45 -20
  24. package/actions/search-string/search-string.mjs +22 -20
  25. package/actions/soql-search/soql-search.mjs +13 -8
  26. package/actions/sosl-search/sosl-search.mjs +19 -9
  27. package/actions/update-account/update-account.mjs +54 -41
  28. package/actions/update-contact/update-contact.mjs +59 -40
  29. package/actions/update-opportunity/update-opportunity.mjs +56 -54
  30. package/actions/update-record/update-record.mjs +67 -20
  31. package/common/all-sobjects.mjs +3812 -0
  32. package/common/constants-props.mjs +1539 -0
  33. package/common/props-async-options.mjs +154 -0
  34. package/common/props-utils.mjs +88 -31
  35. package/common/sobjects/account.mjs +349 -22
  36. package/common/sobjects/attachment.mjs +56 -17
  37. package/common/sobjects/campaign.mjs +125 -23
  38. package/common/sobjects/case.mjs +193 -13
  39. package/common/sobjects/caseComment.mjs +28 -4
  40. package/common/sobjects/contact.mjs +207 -43
  41. package/common/sobjects/event.mjs +218 -18
  42. package/common/sobjects/lead.mjs +245 -22
  43. package/common/sobjects/note.mjs +37 -14
  44. package/common/sobjects/opportunity.mjs +148 -22
  45. package/common/sobjects/task.mjs +240 -19
  46. package/common/sobjects/user.mjs +965 -0
  47. package/package.json +2 -2
  48. package/salesforce_rest_api.app.mjs +72 -249
  49. package/sources/common-webhook-methods.mjs +71 -0
  50. package/sources/common.mjs +85 -22
  51. package/sources/new-outbound-message/new-outbound-message.mjs +11 -3
  52. package/sources/new-record-instant/new-record-instant.mjs +95 -7
  53. package/sources/record-deleted-instant/record-deleted-instant.mjs +40 -5
  54. package/sources/record-updated-instant/record-updated-instant.mjs +137 -5
  55. package/actions/common/base.mjs +0 -18
  56. package/actions/find-create-record/find-create-record.mjs +0 -89
  57. package/actions/get-sobject-fields-values/get-sobject-fields-values.mjs +0 -57
  58. package/common/utils.mjs +0 -51
  59. package/sources/common-instant.mjs +0 -146
  60. package/sources/new-record/new-record.mjs +0 -91
  61. package/sources/record-deleted/record-deleted.mjs +0 -51
  62. package/sources/record-updated/record-updated.mjs +0 -94
  63. package/sources/updated-field-on-record/updated-field-on-record.mjs +0 -161
  64. package/sources/updated-field-on-record-instant/updated-field-on-record-instant.mjs +0 -76
@@ -1,75 +1,77 @@
1
- import common from "../common/base.mjs";
1
+ import common, { getProps } from "../common/base-create-update.mjs";
2
2
  import opportunity from "../../common/sobjects/opportunity.mjs";
3
- import {
4
- pickBy, pick,
5
- } from "lodash-es";
6
- import { toSingleLineString } from "../../common/utils.mjs";
3
+ import { docsLink } from "../create-opportunity/create-opportunity.mjs";
7
4
 
8
- const { salesforce } = common.props;
5
+ const {
6
+ salesforce, ...props
7
+ } = getProps({
8
+ createOrUpdate: "update",
9
+ objType: opportunity,
10
+ docsLink,
11
+ showDateInfo: true,
12
+ });
9
13
 
10
14
  export default {
11
15
  ...common,
12
16
  key: "salesforce_rest_api-update-opportunity",
13
17
  name: "Update Opportunity",
14
- description: toSingleLineString(`
15
- Updates an opportunity, which represents an opportunity, which is a sale or pending deal.
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
- and [Update Record](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_update_fields.htm)
18
- `),
19
- version: "0.2.7",
18
+ description: `Updates an opportunity. [See the documentation](${docsLink})`,
19
+ version: "0.3.0",
20
20
  type: "action",
21
- props: {
22
- salesforce,
23
- OpportunityId: {
24
- type: "string",
25
- label: "Opportunity ID",
26
- description: "ID of the Opportunity to update.",
27
- },
28
- CloseDate: {
29
- type: "string",
30
- label: "CloseDate",
31
- description: "Date when the opportunity is expected to close.",
32
- optional: true,
33
- },
34
- Name: {
35
- type: "string",
36
- label: "Name",
37
- description: "A name for this opportunity. Limit: 120 characters.",
38
- optional: true,
21
+ methods: {
22
+ ...common.methods,
23
+ getObjectType() {
24
+ return "Opportunity";
39
25
  },
40
- StageName: {
41
- type: "string",
42
- label: "StageName",
43
- description: "Current stage of this record. The StageName field controls several other fields on an opportunity. Each of the fields can be directly set or implied by changing the StageName field. In addition, the StageName field is a picklist, so it has additional members in the returned describeSObjectResult to indicate how it affects the other fields. To obtain the stage name values in the picklist, query the OpportunityStage object. If the StageName is updated, then the ForecastCategoryName, IsClosed, IsWon, and Probability are automatically updated based on the stage-category mapping.",
44
- optional: true,
26
+ getAdvancedProps() {
27
+ return opportunity.extraProps;
45
28
  },
46
- selector: {
29
+ },
30
+ props: {
31
+ salesforce,
32
+ opportunityId: {
47
33
  propDefinition: [
48
34
  salesforce,
49
- "fieldSelector",
35
+ "recordId",
36
+ () => ({
37
+ objType: "Opportunity",
38
+ nameField: "Name",
39
+ }),
50
40
  ],
51
- description: `${salesforce.propDefinitions.fieldSelector.description} Opportunity`,
52
- options: () => Object.keys(opportunity),
53
- reloadProps: true,
41
+ label: "Opportunity ID",
42
+ description: "The Opportunity to update.",
54
43
  },
55
- },
56
- additionalProps() {
57
- return this.additionalProps(this.selector, opportunity);
44
+ ...props,
58
45
  },
59
46
  async run({ $ }) {
60
- const data = pickBy(pick(this, [
61
- "OpportunityId",
62
- "CloseDate",
63
- "Name",
64
- "StageName",
65
- ...this.selector,
66
- ]));
67
- const response = await this.salesforce.updateOpportunity({
47
+ /* eslint-disable no-unused-vars */
48
+ const {
49
+ salesforce,
50
+ getAdvancedProps,
51
+ getObjectType,
52
+ getAdditionalFields,
53
+ formatDateTimeProps,
54
+ opportunityId,
55
+ useAdvancedProps,
56
+ docsInfo,
57
+ dateInfo,
58
+ additionalFields,
59
+ CloseDate,
60
+ ...data
61
+ } = this;
62
+ /* eslint-enable no-unused-vars */
63
+ const response = await salesforce.updateRecord("Opportunity", {
68
64
  $,
69
- id: this.OpportunityId,
70
- data,
65
+ id: opportunityId,
66
+ data: {
67
+ ...data,
68
+ ...formatDateTimeProps({
69
+ CloseDate,
70
+ }),
71
+ ...getAdditionalFields(),
72
+ },
71
73
  });
72
- $.export("$summary", `Successfully updated opportunity ${this.OpportunityId}`);
74
+ $.export("$summary", `Successfully updated opportunity (ID: ${opportunityId})`);
73
75
  return response;
74
76
  },
75
77
  };
@@ -1,46 +1,93 @@
1
+ import {
2
+ convertFieldsToProps, getAdditionalFields,
3
+ } from "../../common/props-utils.mjs";
1
4
  import salesforce from "../../salesforce_rest_api.app.mjs";
2
- import { toSingleLineString } from "../../common/utils.mjs";
5
+ import { additionalFields } from "../common/base-create-update.mjs";
3
6
 
4
7
  export default {
5
8
  key: "salesforce_rest_api-update-record",
6
9
  name: "Update Record",
7
- description: toSingleLineString(`
8
- Updates a record of a given resource.
9
- [See docs here](https://developer.salesforce.com/docs/atlas.en-us.228.0.api_rest.meta/api_rest/dome_update_fields.htm)
10
- `),
11
- version: "0.2.7",
10
+ description: "Update fields of a record. [See the documentation](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_update_fields.htm)",
11
+ version: "0.3.0",
12
12
  type: "action",
13
13
  props: {
14
14
  salesforce,
15
- objectType: {
15
+ sobjectType: {
16
16
  propDefinition: [
17
17
  salesforce,
18
18
  "objectType",
19
19
  ],
20
- description: "SObject Type of record to be updated",
20
+ description: "The type of object to update a record of.",
21
+
21
22
  },
22
- sobjectId: {
23
+ recordId: {
23
24
  propDefinition: [
24
25
  salesforce,
25
- "sobjectId",
26
+ "recordId",
26
27
  (c) => ({
27
- objectType: c.objectType,
28
+ objType: c.sobjectType,
28
29
  }),
29
30
  ],
30
- description: "ID of the SObject record to be updated",
31
+ description:
32
+ "The record to update.",
31
33
  },
32
- sobject: {
33
- type: "object",
34
- label: "SObject fields and values",
35
- description: "SObject record data to patch",
34
+ fieldsToUpdate: {
35
+ propDefinition: [
36
+ salesforce,
37
+ "fieldsToUpdate",
38
+ (c) => ({
39
+ objType: c.sobjectType,
40
+ }),
41
+ ],
42
+ reloadProps: true,
36
43
  },
37
44
  },
45
+ methods: {
46
+ getAdditionalFields,
47
+ convertFieldsToProps,
48
+ },
49
+ async additionalProps() {
50
+ const {
51
+ sobjectType, fieldsToUpdate,
52
+ } = this;
53
+ const fields = await this.salesforce.getFieldsForObjectType(sobjectType);
54
+
55
+ const selectedFields = fields.filter(({ name }) => fieldsToUpdate.includes(name));
56
+ const selectedFieldProps = this.convertFieldsToProps(selectedFields);
57
+
58
+ return {
59
+ docsInfo: {
60
+ type: "alert",
61
+ alertType: "info",
62
+ content: `[See the documentation](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_${sobjectType.toLowerCase()}.htm) for information on all available fields.`,
63
+ },
64
+ ...selectedFieldProps,
65
+ additionalFields,
66
+ };
67
+ },
38
68
  async run({ $ }) {
39
- await this.salesforce.updateRecord(this.objectType, {
69
+ /* eslint-disable no-unused-vars */
70
+ const {
71
+ salesforce,
72
+ sobjectType,
73
+ recordId,
74
+ fieldsToUpdate,
75
+ getAdditionalFields: getData,
76
+ convertFieldsToProps,
77
+ docsInfo,
78
+ additionalFields,
79
+ ...data
80
+ } = this;
81
+ /* eslint-enable no-unused-vars */
82
+ const response = await this.salesforce.updateRecord(sobjectType, {
40
83
  $,
41
- id: this.sobjectId,
42
- data: this.sobject,
84
+ id: recordId,
85
+ data: {
86
+ ...data,
87
+ ...getData(),
88
+ },
43
89
  });
44
- $.export("$summary", `Updated record ${this.objectType}`);
90
+ $.export("$summary", `Successfully updated ${sobjectType} record (ID: ${recordId})`);
91
+ return response;
45
92
  },
46
93
  };