@foxtware/mineral 0.1.27 → 0.1.29

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 (178) hide show
  1. package/.creds.yml.sample +29 -0
  2. package/AGENTS.md +24 -0
  3. package/_build_scripts/createNewFunction.js +26 -3
  4. package/api/dropbox/docs.md +7 -0
  5. package/api/dropbox/dropbox.constants.js +10 -0
  6. package/api/dropbox/dropbox.utils.js +67 -0
  7. package/api/dropbox/dropboxAccountGet.js +64 -0
  8. package/api/dropbox/dropboxFileCopy.js +67 -0
  9. package/api/dropbox/dropboxFileDelete.js +89 -0
  10. package/api/dropbox/dropboxFileDownload.js +139 -0
  11. package/api/dropbox/dropboxFileMetadataGet.js +100 -0
  12. package/api/dropbox/dropboxFileMove.js +67 -0
  13. package/api/dropbox/dropboxFileUpload.js +129 -0
  14. package/api/dropbox/dropboxFolderCreate.js +68 -0
  15. package/api/dropbox/dropboxFolderList.js +66 -0
  16. package/api/dropbox/dropboxGet.js +158 -0
  17. package/api/dropbox/dropboxSearch.js +161 -0
  18. package/api/dropbox/dropboxSharedLinkCreate.js +68 -0
  19. package/api/dropbox/dropboxSpaceUsageGet.js +55 -0
  20. package/api/dropbox/dropboxTemporaryLinkGet.js +75 -0
  21. package/api/fastsimon/.gitkeep +0 -0
  22. package/api/fastsimon/docs.md +14 -0
  23. package/api/fastsimon/fastsimon.constants.js +18 -0
  24. package/api/fastsimon/fastsimon.utils.js +246 -0
  25. package/api/fastsimon/fastsimonSearch.js +84 -0
  26. package/api/figma/docs.md +3 -3
  27. package/api/figma/figma.constants.js +1 -1
  28. package/api/figma/figma.utils.js +13 -2
  29. package/api/figma/figmaActivityLogsGet.js +44 -0
  30. package/api/figma/figmaAiUsageDailyGet.js +44 -0
  31. package/api/figma/figmaComponentGet.js +48 -0
  32. package/api/figma/figmaComponentSetGet.js +48 -0
  33. package/api/figma/figmaDevResourcesCreate.js +47 -0
  34. package/api/figma/figmaDevResourcesUpdate.js +47 -0
  35. package/api/figma/figmaDeveloperLogsCreate.js +47 -0
  36. package/api/figma/figmaDiscoveryGet.js +44 -0
  37. package/api/figma/figmaFileCommentCreate.js +50 -0
  38. package/api/figma/figmaFileCommentDelete.js +51 -0
  39. package/api/figma/figmaFileCommentReactionCreate.js +53 -0
  40. package/api/figma/figmaFileCommentReactionDelete.js +51 -0
  41. package/api/figma/figmaFileCommentReactionsGet.js +51 -0
  42. package/api/figma/figmaFileCommentsGet.js +48 -0
  43. package/api/figma/figmaFileComponentSetsGet.js +48 -0
  44. package/api/figma/figmaFileComponentsGet.js +48 -0
  45. package/api/figma/figmaFileDevResourceDelete.js +51 -0
  46. package/api/figma/figmaFileDevResourcesGet.js +48 -0
  47. package/api/figma/figmaFileGet.js +48 -0
  48. package/api/figma/figmaFileImageFillsGet.js +48 -0
  49. package/api/figma/figmaFileImagesGet.js +48 -0
  50. package/api/figma/figmaFileMetaGet.js +48 -0
  51. package/api/figma/figmaFileNodesGet.js +48 -0
  52. package/api/figma/figmaFileStylesGet.js +48 -0
  53. package/api/figma/figmaFileVersionsGet.js +48 -0
  54. package/api/figma/figmaFolderFilesGet.js +48 -0
  55. package/api/figma/figmaFolderFoldersGet.js +48 -0
  56. package/api/figma/figmaFolderMetaGet.js +48 -0
  57. package/api/figma/figmaGet.js +15 -63
  58. package/api/figma/figmaMeGet.js +53 -0
  59. package/api/figma/figmaOembedGet.js +44 -0
  60. package/api/figma/figmaPaymentsGet.js +44 -0
  61. package/api/figma/figmaProjectFilesGet.js +48 -0
  62. package/api/figma/figmaProjectMetaGet.js +48 -0
  63. package/api/figma/figmaStyleGet.js +48 -0
  64. package/api/figma/figmaTeamComponentSetsGet.js +48 -0
  65. package/api/figma/figmaTeamComponentsGet.js +48 -0
  66. package/api/figma/figmaTeamFoldersGet.js +48 -0
  67. package/api/figma/figmaTeamProjectsGet.js +48 -0
  68. package/api/figma/figmaTeamStylesGet.js +48 -0
  69. package/api/figma/figmaTeamWebhooksGet.js +47 -0
  70. package/api/figma/figmaVariablesLocalGet.js +48 -0
  71. package/api/figma/figmaVariablesPublishedGet.js +48 -0
  72. package/api/figma/figmaVariablesUpdate.js +50 -0
  73. package/api/figma/figmaWebhookCreate.js +47 -0
  74. package/api/figma/figmaWebhookDelete.js +48 -0
  75. package/api/figma/figmaWebhookGet.js +46 -0
  76. package/api/figma/figmaWebhookRequestsGet.js +47 -0
  77. package/api/figma/figmaWebhookUpdate.js +50 -0
  78. package/api/figma/figmaWebhooksGet.js +47 -0
  79. package/api/google/docs.md +1 -0
  80. package/api/google/google.constants.js +1 -0
  81. package/api/google/google.utils.js +21 -0
  82. package/api/google/googleanalyticsMetadataGet.js +62 -0
  83. package/api/google/googleanalyticsRealtimeReportRun.js +103 -0
  84. package/api/google/googleanalyticsReportRun.js +114 -0
  85. package/api/gorgias/gorgiasTicketCreate.js +1 -1
  86. package/api/gorgias/gorgiasTicketMessageCreate.js +1 -1
  87. package/api/gorgias/gorgiasTicketUpdate.js +1 -1
  88. package/api/linear/linearAttachmentCreate.js +1 -1
  89. package/api/linear/linearCommentCreate.js +1 -1
  90. package/api/linear/linearCommentUpdate.js +1 -1
  91. package/api/linear/linearIssueLabelCreate.js +1 -1
  92. package/api/linear/linearIssueUpdate.js +1 -1
  93. package/api/linear/linearProjectCreate.js +1 -1
  94. package/api/linear/linearProjectUpdate.js +1 -1
  95. package/api/linear/linearWebhookCreate.js +1 -1
  96. package/api/salesforce/salesforce.constants.js +13 -0
  97. package/api/salesforce/salesforce.utils.js +61 -0
  98. package/api/salesforce/salesforceAuthGet.js +115 -0
  99. package/api/salesforce/salesforceComposite.js +79 -0
  100. package/api/salesforce/salesforceCompositeBatch.js +73 -0
  101. package/api/salesforce/salesforceLimitsGet.js +55 -0
  102. package/api/salesforce/salesforceQuery.js +69 -0
  103. package/api/salesforce/salesforceQueryAll.js +62 -0
  104. package/api/salesforce/salesforceQueryMore.js +75 -0
  105. package/api/salesforce/salesforceRecentItemsGet.js +63 -0
  106. package/api/salesforce/salesforceResourcesGet.js +55 -0
  107. package/api/salesforce/salesforceSearch.js +62 -0
  108. package/api/salesforce/salesforceSobjectBasicInfoGet.js +81 -0
  109. package/api/salesforce/salesforceSobjectBlobGet.js +67 -0
  110. package/api/salesforce/salesforceSobjectCollectionCreate.js +78 -0
  111. package/api/salesforce/salesforceSobjectCollectionDelete.js +70 -0
  112. package/api/salesforce/salesforceSobjectCollectionGet.js +75 -0
  113. package/api/salesforce/salesforceSobjectCollectionUpdate.js +74 -0
  114. package/api/salesforce/salesforceSobjectCreate.js +66 -0
  115. package/api/salesforce/salesforceSobjectDelete.js +86 -0
  116. package/api/salesforce/salesforceSobjectDeleteByExternalId.js +91 -0
  117. package/api/salesforce/salesforceSobjectDeletedGet.js +71 -0
  118. package/api/salesforce/salesforceSobjectDescribe.js +81 -0
  119. package/api/salesforce/salesforceSobjectDescribeLayouts.js +64 -0
  120. package/api/salesforce/salesforceSobjectGet.js +93 -0
  121. package/api/salesforce/salesforceSobjectGetByExternalId.js +98 -0
  122. package/api/salesforce/salesforceSobjectTreeCreate.js +79 -0
  123. package/api/salesforce/salesforceSobjectUpdate.js +94 -0
  124. package/api/salesforce/salesforceSobjectUpdatedGet.js +71 -0
  125. package/api/salesforce/salesforceSobjectUpsert.js +74 -0
  126. package/api/salesforce/salesforceSobjectsDescribeGlobal.js +55 -0
  127. package/api/salesforce/salesforceVersionsGet.js +62 -0
  128. package/api/shopify/shopify.utils.js +53 -4
  129. package/api/shopify/shopifyMetaobjectCreate.js +79 -0
  130. package/api/shopify/shopifyMetaobjectDelete.js +90 -0
  131. package/api/shopify/shopifyMetaobjectGet.js +80 -0
  132. package/api/shopify/shopifyMetaobjectUpdate.js +108 -0
  133. package/api/shopify/shopifyStorefrontSearch.js +158 -0
  134. package/api/spotify/docs.md +8 -0
  135. package/api/spotify/spotify.constants.js +12 -0
  136. package/api/spotify/spotify.utils.js +106 -0
  137. package/api/spotify/spotifyAlbumGet.js +76 -0
  138. package/api/spotify/spotifyAlbumTracksGet.js +49 -0
  139. package/api/spotify/spotifyArtistAlbumsGet.js +55 -0
  140. package/api/spotify/spotifyArtistGet.js +71 -0
  141. package/api/spotify/spotifyArtistTopTracksGet.js +56 -0
  142. package/api/spotify/spotifyGet.js +171 -0
  143. package/api/spotify/spotifyMeGet.js +48 -0
  144. package/api/spotify/spotifyPlayerCurrentlyPlayingGet.js +62 -0
  145. package/api/spotify/spotifyPlayerDevicesGet.js +51 -0
  146. package/api/spotify/spotifyPlayerGet.js +63 -0
  147. package/api/spotify/spotifyPlayerNext.js +55 -0
  148. package/api/spotify/spotifyPlayerPause.js +55 -0
  149. package/api/spotify/spotifyPlayerPlay.js +70 -0
  150. package/api/spotify/spotifyPlayerPrevious.js +55 -0
  151. package/api/spotify/spotifyPlaylistCreate.js +63 -0
  152. package/api/spotify/spotifyPlaylistGet.js +91 -0
  153. package/api/spotify/spotifyPlaylistItemsAdd.js +61 -0
  154. package/api/spotify/spotifyPlaylistItemsGet.js +58 -0
  155. package/api/spotify/spotifyPlaylistItemsRemove.js +67 -0
  156. package/api/spotify/spotifyPlaylistUpdate.js +64 -0
  157. package/api/spotify/spotifyPlaylistsGet.js +47 -0
  158. package/api/spotify/spotifySavedTracksGet.js +46 -0
  159. package/api/spotify/spotifySavedTracksRemove.js +59 -0
  160. package/api/spotify/spotifySavedTracksSave.js +59 -0
  161. package/api/spotify/spotifySearch.js +174 -0
  162. package/api/spotify/spotifyTrackGet.js +76 -0
  163. package/api/tableau/tableau.constants.js +8 -0
  164. package/api/tableau/tableau.utils.js +93 -0
  165. package/api/tableau/tableauGet.js +174 -0
  166. package/api/tableau/tableauUserAdd.js +16 -94
  167. package/api/tableau/tableauUsersGet.js +46 -134
  168. package/api/tagalys/docs.md +2 -2
  169. package/api/tagalys/tagalys.constants.js +17 -0
  170. package/api/tagalys/tagalys.utils.js +125 -0
  171. package/api/tagalys/tagalysAnalyticsEventSend.js +125 -0
  172. package/api/tagalys/tagalysCollectionGet.js +100 -0
  173. package/api/tagalys/tagalysPopularSearchesGet.js +60 -0
  174. package/api/tagalys/tagalysRecommendationGet.js +109 -0
  175. package/api/tagalys/tagalysSearch.js +15 -89
  176. package/api/tagalys/tagalysSearchSuggestionsGet.js +76 -0
  177. package/package.json +2 -1
  178. package/server.js +3 -1
@@ -7,7 +7,7 @@ const { linearClient } = require('../linear/linear.utils');
7
7
  const argsWarden = new ArgsWarden([
8
8
  ['credsPayload', credsValidator],
9
9
  ['id'],
10
- ['input', valueProvided],
10
+ ['input'],
11
11
  ]);
12
12
 
13
13
  const linearIssueUpdate = async (
@@ -6,7 +6,7 @@ const { linearClient } = require('../linear/linear.utils');
6
6
 
7
7
  const argsWarden = new ArgsWarden([
8
8
  ['credsPayload', credsValidator],
9
- ['input', valueProvided],
9
+ ['input'],
10
10
  ]);
11
11
 
12
12
  const linearProjectCreate = async (
@@ -7,7 +7,7 @@ const { linearClient } = require('../linear/linear.utils');
7
7
  const argsWarden = new ArgsWarden([
8
8
  ['credsPayload', credsValidator],
9
9
  ['id'],
10
- ['input', valueProvided],
10
+ ['input'],
11
11
  ]);
12
12
 
13
13
  const linearProjectUpdate = async (
@@ -6,7 +6,7 @@ const { linearClient } = require('../linear/linear.utils');
6
6
 
7
7
  const argsWarden = new ArgsWarden([
8
8
  ['credsPayload', credsValidator],
9
- ['input', valueProvided],
9
+ ['input'],
10
10
  ]);
11
11
 
12
12
  const linearWebhookCreate = async (
@@ -0,0 +1,13 @@
1
+ const DEFAULT_API_VERSION = '62.0';
2
+ const DEFAULT_LOGIN_URL = 'https://login.salesforce.com';
3
+
4
+ // Query result page size is controlled by SOQL; next page uses nextRecordsUrl.
5
+ // SObject list endpoints typically allow up to 2000 in some contexts; REST query
6
+ // uses the default batch size (often 2000 max via headers / tooling).
7
+ const MAX_PER_PAGE = 2000;
8
+
9
+ module.exports = {
10
+ DEFAULT_API_VERSION,
11
+ DEFAULT_LOGIN_URL,
12
+ MAX_PER_PAGE,
13
+ };
@@ -0,0 +1,61 @@
1
+ const { DEFAULT_API_VERSION } = require('../salesforce/salesforce.constants');
2
+ const { salesforceAuthGet } = require('../salesforce/salesforceAuthGet');
3
+ const { resolveCreds } = require('../pipelineSteps');
4
+ const {
5
+ FetchClient,
6
+ appendUrlToBase,
7
+ fetchClientCommonSteps,
8
+ } = require('../utils');
9
+
10
+ const useUrlAndAuthHeaders = async (state) => {
11
+ const { requestPayload, context } = state;
12
+ const {
13
+ apiVersion = DEFAULT_API_VERSION,
14
+ creds,
15
+ } = context;
16
+
17
+ const authResponse = await salesforceAuthGet({
18
+ credsObject: creds,
19
+ });
20
+
21
+ if (!authResponse?.ok) {
22
+ return {
23
+ breakChain: true,
24
+ response: authResponse,
25
+ };
26
+ }
27
+
28
+ const {
29
+ access_token,
30
+ instance_url,
31
+ } = authResponse.data;
32
+
33
+ const dataBase = appendUrlToBase(
34
+ instance_url,
35
+ `/services/data/v${ apiVersion }`,
36
+ );
37
+
38
+ return {
39
+ requestPayload: {
40
+ ...requestPayload,
41
+ url: appendUrlToBase(dataBase, requestPayload.url),
42
+ headers: {
43
+ Authorization: `Bearer ${ access_token }`,
44
+ ...requestPayload.headers,
45
+ },
46
+ },
47
+ };
48
+ };
49
+
50
+ const salesforceClient = new FetchClient({
51
+ pipeline: [
52
+ resolveCreds,
53
+ useUrlAndAuthHeaders,
54
+ 'fetch',
55
+ fetchClientCommonSteps.exitEarlyOnNotOk,
56
+ ],
57
+ });
58
+
59
+ module.exports = {
60
+ salesforceClient,
61
+ };
@@ -0,0 +1,115 @@
1
+ // https://help.salesforce.com/s/articleView?id=xcloud.remoteaccess_oauth_client_credentials_flow_ca.htm
2
+ // https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_understanding_authentication.htm
3
+
4
+ const {
5
+ ArgsWarden,
6
+ appendUrlToBase,
7
+ credsFromPayload,
8
+ customFetch,
9
+ } = require('../utils');
10
+ const { credsValidator } = require('../validators');
11
+ const { DEFAULT_LOGIN_URL } = require('../salesforce/salesforce.constants');
12
+
13
+ const argsWarden = new ArgsWarden([
14
+ ['credsPayload', credsValidator],
15
+ ]);
16
+
17
+ const salesforceAuthGet = async (
18
+ credsPayload,
19
+ ) => {
20
+
21
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
22
+ credsPayload,
23
+ });
24
+ if (rejectResponse) {
25
+ return rejectResponse;
26
+ }
27
+
28
+ const creds = await credsFromPayload(credsPayload);
29
+ const {
30
+ ACCESS_TOKEN,
31
+ INSTANCE_URL,
32
+ CLIENT_ID,
33
+ CLIENT_SECRET,
34
+ LOGIN_URL = DEFAULT_LOGIN_URL,
35
+ } = creds ?? {};
36
+
37
+ if (ACCESS_TOKEN && INSTANCE_URL) {
38
+ return {
39
+ ok: true,
40
+ data: {
41
+ access_token: ACCESS_TOKEN,
42
+ instance_url: INSTANCE_URL,
43
+ },
44
+ };
45
+ }
46
+
47
+ if (!CLIENT_ID || !CLIENT_SECRET) {
48
+ return {
49
+ ok: false,
50
+ error: {
51
+ code: 'INVALID_CREDS',
52
+ message: 'Provide ACCESS_TOKEN and INSTANCE_URL, or CLIENT_ID and CLIENT_SECRET for client credentials.',
53
+ },
54
+ };
55
+ }
56
+
57
+ const tokenUrl = appendUrlToBase(LOGIN_URL, '/services/oauth2/token');
58
+
59
+ const tokenResponse = await customFetch(tokenUrl, {
60
+ method: 'post',
61
+ headers: {
62
+ 'Content-Type': 'application/x-www-form-urlencoded',
63
+ },
64
+ body: new URLSearchParams({
65
+ grant_type: 'client_credentials',
66
+ client_id: CLIENT_ID,
67
+ client_secret: CLIENT_SECRET,
68
+ }),
69
+ });
70
+
71
+ if (!tokenResponse.ok) {
72
+ return tokenResponse;
73
+ }
74
+
75
+ const {
76
+ access_token,
77
+ instance_url,
78
+ } = tokenResponse.data ?? {};
79
+
80
+ if (!access_token || !instance_url) {
81
+ return {
82
+ ok: false,
83
+ error: {
84
+ code: 'AUTH_FAILED',
85
+ message: 'Salesforce did not return access_token and instance_url.',
86
+ details: tokenResponse.data,
87
+ },
88
+ };
89
+ }
90
+
91
+ return {
92
+ ok: true,
93
+ data: {
94
+ access_token,
95
+ instance_url,
96
+ },
97
+ };
98
+ };
99
+
100
+ const funcApiConfig = {
101
+ argsWarden,
102
+ };
103
+
104
+ module.exports = {
105
+ salesforceAuthGet,
106
+ funcApiConfig,
107
+ };
108
+
109
+ /*
110
+ curl -X POST "http://localhost:8000/salesforceAuthGet" \
111
+ -H "Content-Type: application/json" \
112
+ -d '{
113
+ "credsPayload": { "credsPath": "salesforce" }
114
+ }'
115
+ */
@@ -0,0 +1,79 @@
1
+ // https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_composite_composite.htm
2
+
3
+ const { ArgsWarden, valueProvided } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { salesforceClient } = require('../salesforce/salesforce.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['compositeRequest'],
10
+ ]);
11
+
12
+ const salesforceComposite = async (
13
+ credsPayload,
14
+ compositeRequest,
15
+ {
16
+ allOrNone,
17
+ collateSubrequests,
18
+ apiVersion,
19
+ inspect = false,
20
+ fetchClient = salesforceClient,
21
+ } = {},
22
+ ) => {
23
+
24
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
25
+ credsPayload,
26
+ compositeRequest,
27
+ });
28
+ if (rejectResponse) {
29
+ return rejectResponse;
30
+ }
31
+
32
+ const body = {
33
+ compositeRequest,
34
+ };
35
+ if (allOrNone !== undefined) {
36
+ body.allOrNone = allOrNone;
37
+ }
38
+ if (collateSubrequests !== undefined) {
39
+ body.collateSubrequests = collateSubrequests;
40
+ }
41
+
42
+ return fetchClient.fetch({
43
+ requestPayload: {
44
+ method: 'post',
45
+ url: '/composite',
46
+ body,
47
+ },
48
+ context: {
49
+ credsPayload,
50
+ apiVersion,
51
+ },
52
+ inspect,
53
+ });
54
+ };
55
+
56
+ const funcApiConfig = {
57
+ argsWarden,
58
+ };
59
+
60
+ module.exports = {
61
+ salesforceComposite,
62
+ funcApiConfig,
63
+ };
64
+
65
+ /*
66
+ curl -X POST "http://localhost:8000/salesforceComposite" \
67
+ -H "Content-Type: application/json" \
68
+ -d '{
69
+ "credsPayload": { "credsPath": "salesforce" },
70
+ "compositeRequest": [
71
+ {
72
+ "method": "GET",
73
+ "url": "/services/data/v62.0/sobjects/Account/001xx000003DGb2AAG",
74
+ "referenceId": "refAccount"
75
+ }
76
+ ],
77
+ "options": { "allOrNone": true }
78
+ }'
79
+ */
@@ -0,0 +1,73 @@
1
+ // https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_composite_batch.htm
2
+
3
+ const { ArgsWarden, valueProvided } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { salesforceClient } = require('../salesforce/salesforce.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['batchRequests'],
10
+ ]);
11
+
12
+ const salesforceCompositeBatch = async (
13
+ credsPayload,
14
+ batchRequests,
15
+ {
16
+ haltOnError,
17
+ apiVersion,
18
+ inspect = false,
19
+ fetchClient = salesforceClient,
20
+ } = {},
21
+ ) => {
22
+
23
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
24
+ credsPayload,
25
+ batchRequests,
26
+ });
27
+ if (rejectResponse) {
28
+ return rejectResponse;
29
+ }
30
+
31
+ const body = {
32
+ batchRequests,
33
+ };
34
+ if (haltOnError !== undefined) {
35
+ body.haltOnError = haltOnError;
36
+ }
37
+
38
+ return fetchClient.fetch({
39
+ requestPayload: {
40
+ method: 'post',
41
+ url: '/composite/batch',
42
+ body,
43
+ },
44
+ context: {
45
+ credsPayload,
46
+ apiVersion,
47
+ },
48
+ inspect,
49
+ });
50
+ };
51
+
52
+ const funcApiConfig = {
53
+ argsWarden,
54
+ };
55
+
56
+ module.exports = {
57
+ salesforceCompositeBatch,
58
+ funcApiConfig,
59
+ };
60
+
61
+ /*
62
+ curl -X POST "http://localhost:8000/salesforceCompositeBatch" \
63
+ -H "Content-Type: application/json" \
64
+ -d '{
65
+ "credsPayload": { "credsPath": "salesforce" },
66
+ "batchRequests": [
67
+ {
68
+ "method": "GET",
69
+ "url": "v62.0/sobjects/Account/describe"
70
+ }
71
+ ]
72
+ }'
73
+ */
@@ -0,0 +1,55 @@
1
+ // https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_limits.htm
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { salesforceClient } = require('../salesforce/salesforce.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ]);
10
+
11
+ const salesforceLimitsGet = async (
12
+ credsPayload,
13
+ {
14
+ apiVersion,
15
+ inspect = false,
16
+ fetchClient = salesforceClient,
17
+ } = {},
18
+ ) => {
19
+
20
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
21
+ credsPayload,
22
+ });
23
+ if (rejectResponse) {
24
+ return rejectResponse;
25
+ }
26
+
27
+ return fetchClient.fetch({
28
+ requestPayload: {
29
+ method: 'get',
30
+ url: '/limits',
31
+ },
32
+ context: {
33
+ credsPayload,
34
+ apiVersion,
35
+ },
36
+ inspect,
37
+ });
38
+ };
39
+
40
+ const funcApiConfig = {
41
+ argsWarden,
42
+ };
43
+
44
+ module.exports = {
45
+ salesforceLimitsGet,
46
+ funcApiConfig,
47
+ };
48
+
49
+ /*
50
+ curl -X POST "http://localhost:8000/salesforceLimitsGet" \
51
+ -H "Content-Type: application/json" \
52
+ -d '{
53
+ "credsPayload": { "credsPath": "salesforce" }
54
+ }'
55
+ */
@@ -0,0 +1,69 @@
1
+ // https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query.htm
2
+
3
+ const { ArgsWarden, valueProvided } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { salesforceClient } = require('../salesforce/salesforce.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['soql'],
10
+ ]);
11
+
12
+ const salesforceQuery = async (
13
+ credsPayload,
14
+ soql,
15
+ {
16
+ apiVersion,
17
+ inspect = false,
18
+ fetchClient = salesforceClient,
19
+ } = {},
20
+ ) => {
21
+
22
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
23
+ credsPayload,
24
+ soql,
25
+ });
26
+ if (rejectResponse) {
27
+ return rejectResponse;
28
+ }
29
+
30
+ return fetchClient.fetch({
31
+ requestPayload: {
32
+ method: 'get',
33
+ url: '/query',
34
+ params: {
35
+ q: soql,
36
+ },
37
+ },
38
+ context: {
39
+ credsPayload,
40
+ apiVersion,
41
+ },
42
+ inspect,
43
+ });
44
+ };
45
+
46
+ const funcApiConfig = {
47
+ argsWarden,
48
+ };
49
+
50
+ module.exports = {
51
+ salesforceQuery,
52
+ funcApiConfig,
53
+ };
54
+
55
+ /*
56
+ curl -X POST "http://localhost:8000/salesforceQuery" \
57
+ -H "Content-Type: application/json" \
58
+ -d '{
59
+ "credsPayload": { "credsPath": "salesforce" },
60
+ "soql": "SELECT Id, Name FROM Account LIMIT 5"
61
+ }'
62
+
63
+ curl -X POST "http://localhost:8000/salesforceQuery" \
64
+ -H "Content-Type: application/json" \
65
+ -d '{
66
+ "credsPayload": {"credsPath": "salesforce"},
67
+ "soql": "SELECT Id, Name, Email, Phone, Account.Name FROM Contact ORDER BY LastModifiedDate DESC LIMIT 10"
68
+ }'
69
+ */
@@ -0,0 +1,62 @@
1
+ // https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_queryall.htm
2
+
3
+ const { ArgsWarden, valueProvided } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { salesforceClient } = require('../salesforce/salesforce.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['soql'],
10
+ ]);
11
+
12
+ const salesforceQueryAll = async (
13
+ credsPayload,
14
+ soql,
15
+ {
16
+ apiVersion,
17
+ inspect = false,
18
+ fetchClient = salesforceClient,
19
+ } = {},
20
+ ) => {
21
+
22
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
23
+ credsPayload,
24
+ soql,
25
+ });
26
+ if (rejectResponse) {
27
+ return rejectResponse;
28
+ }
29
+
30
+ return fetchClient.fetch({
31
+ requestPayload: {
32
+ method: 'get',
33
+ url: '/queryAll',
34
+ params: {
35
+ q: soql,
36
+ },
37
+ },
38
+ context: {
39
+ credsPayload,
40
+ apiVersion,
41
+ },
42
+ inspect,
43
+ });
44
+ };
45
+
46
+ const funcApiConfig = {
47
+ argsWarden,
48
+ };
49
+
50
+ module.exports = {
51
+ salesforceQueryAll,
52
+ funcApiConfig,
53
+ };
54
+
55
+ /*
56
+ curl -X POST "http://localhost:8000/salesforceQueryAll" \
57
+ -H "Content-Type: application/json" \
58
+ -d '{
59
+ "credsPayload": { "credsPath": "salesforce" },
60
+ "soql": "SELECT Id, Name, IsDeleted FROM Account WHERE IsDeleted = true"
61
+ }'
62
+ */
@@ -0,0 +1,75 @@
1
+ // https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query_more.htm
2
+
3
+ const { ArgsWarden, valueProvided } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { salesforceClient } = require('../salesforce/salesforce.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['nextRecordsUrl'],
10
+ ]);
11
+
12
+ /**
13
+ * nextRecordsUrl from a prior query response is typically
14
+ * /services/data/vXX.X/query/{locator}. The client prefixes
15
+ * {instance}/services/data/v{version}, so strip down to /query/...
16
+ */
17
+ const pathFromNextRecordsUrl = (nextRecordsUrl) => {
18
+ const match = String(nextRecordsUrl).match(/\/services\/data\/v[\d.]+(\/.*)$/i);
19
+ if (match) {
20
+ return match[1];
21
+ }
22
+ if (String(nextRecordsUrl).startsWith('/query')) {
23
+ return nextRecordsUrl;
24
+ }
25
+ return `/query/${ nextRecordsUrl }`;
26
+ };
27
+
28
+ const salesforceQueryMore = async (
29
+ credsPayload,
30
+ nextRecordsUrl,
31
+ {
32
+ apiVersion,
33
+ inspect = false,
34
+ fetchClient = salesforceClient,
35
+ } = {},
36
+ ) => {
37
+
38
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
39
+ credsPayload,
40
+ nextRecordsUrl,
41
+ });
42
+ if (rejectResponse) {
43
+ return rejectResponse;
44
+ }
45
+
46
+ return fetchClient.fetch({
47
+ requestPayload: {
48
+ method: 'get',
49
+ url: pathFromNextRecordsUrl(nextRecordsUrl),
50
+ },
51
+ context: {
52
+ credsPayload,
53
+ apiVersion,
54
+ },
55
+ inspect,
56
+ });
57
+ };
58
+
59
+ const funcApiConfig = {
60
+ argsWarden,
61
+ };
62
+
63
+ module.exports = {
64
+ salesforceQueryMore,
65
+ funcApiConfig,
66
+ };
67
+
68
+ /*
69
+ curl -X POST "http://localhost:8000/salesforceQueryMore" \
70
+ -H "Content-Type: application/json" \
71
+ -d '{
72
+ "credsPayload": { "credsPath": "salesforce" },
73
+ "nextRecordsUrl": "/services/data/v62.0/query/01gxx000000xxxx-2000"
74
+ }'
75
+ */
@@ -0,0 +1,63 @@
1
+ // https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_recent_items.htm
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { salesforceClient } = require('../salesforce/salesforce.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ]);
10
+
11
+ const salesforceRecentItemsGet = async (
12
+ credsPayload,
13
+ {
14
+ limit,
15
+ apiVersion,
16
+ inspect = false,
17
+ fetchClient = salesforceClient,
18
+ } = {},
19
+ ) => {
20
+
21
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
22
+ credsPayload,
23
+ });
24
+ if (rejectResponse) {
25
+ return rejectResponse;
26
+ }
27
+
28
+ const params = {};
29
+ if (limit !== undefined) {
30
+ params.limit = limit;
31
+ }
32
+
33
+ return fetchClient.fetch({
34
+ requestPayload: {
35
+ method: 'get',
36
+ url: '/recent',
37
+ params,
38
+ },
39
+ context: {
40
+ credsPayload,
41
+ apiVersion,
42
+ },
43
+ inspect,
44
+ });
45
+ };
46
+
47
+ const funcApiConfig = {
48
+ argsWarden,
49
+ };
50
+
51
+ module.exports = {
52
+ salesforceRecentItemsGet,
53
+ funcApiConfig,
54
+ };
55
+
56
+ /*
57
+ curl -X POST "http://localhost:8000/salesforceRecentItemsGet" \
58
+ -H "Content-Type: application/json" \
59
+ -d '{
60
+ "credsPayload": { "credsPath": "salesforce" },
61
+ "options": { "limit": 10 }
62
+ }'
63
+ */