@foxtware/mineral 0.1.26 → 0.1.28

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 (119) hide show
  1. package/.creds.yml.sample +22 -4
  2. package/AGENTS.md +17 -0
  3. package/api/fastsimon/.gitkeep +0 -0
  4. package/api/fastsimon/docs.md +14 -0
  5. package/api/fastsimon/fastsimon.constants.js +18 -0
  6. package/api/fastsimon/fastsimon.utils.js +246 -0
  7. package/api/fastsimon/fastsimonSearch.js +84 -0
  8. package/api/figma/docs.md +3 -3
  9. package/api/figma/figma.constants.js +1 -1
  10. package/api/figma/figma.utils.js +13 -2
  11. package/api/figma/figmaActivityLogsGet.js +44 -0
  12. package/api/figma/figmaAiUsageDailyGet.js +44 -0
  13. package/api/figma/figmaComponentGet.js +48 -0
  14. package/api/figma/figmaComponentSetGet.js +48 -0
  15. package/api/figma/figmaDevResourcesCreate.js +47 -0
  16. package/api/figma/figmaDevResourcesUpdate.js +47 -0
  17. package/api/figma/figmaDeveloperLogsCreate.js +47 -0
  18. package/api/figma/figmaDiscoveryGet.js +44 -0
  19. package/api/figma/figmaFileCommentCreate.js +50 -0
  20. package/api/figma/figmaFileCommentDelete.js +51 -0
  21. package/api/figma/figmaFileCommentReactionCreate.js +53 -0
  22. package/api/figma/figmaFileCommentReactionDelete.js +51 -0
  23. package/api/figma/figmaFileCommentReactionsGet.js +51 -0
  24. package/api/figma/figmaFileCommentsGet.js +48 -0
  25. package/api/figma/figmaFileComponentSetsGet.js +48 -0
  26. package/api/figma/figmaFileComponentsGet.js +48 -0
  27. package/api/figma/figmaFileDevResourceDelete.js +51 -0
  28. package/api/figma/figmaFileDevResourcesGet.js +48 -0
  29. package/api/figma/figmaFileGet.js +48 -0
  30. package/api/figma/figmaFileImageFillsGet.js +48 -0
  31. package/api/figma/figmaFileImagesGet.js +48 -0
  32. package/api/figma/figmaFileMetaGet.js +48 -0
  33. package/api/figma/figmaFileNodesGet.js +48 -0
  34. package/api/figma/figmaFileStylesGet.js +48 -0
  35. package/api/figma/figmaFileVersionsGet.js +48 -0
  36. package/api/figma/figmaFolderFilesGet.js +48 -0
  37. package/api/figma/figmaFolderFoldersGet.js +48 -0
  38. package/api/figma/figmaFolderMetaGet.js +48 -0
  39. package/api/figma/figmaGet.js +15 -63
  40. package/api/figma/figmaMeGet.js +53 -0
  41. package/api/figma/figmaOembedGet.js +44 -0
  42. package/api/figma/figmaPaymentsGet.js +44 -0
  43. package/api/figma/figmaProjectFilesGet.js +48 -0
  44. package/api/figma/figmaProjectMetaGet.js +48 -0
  45. package/api/figma/figmaStyleGet.js +48 -0
  46. package/api/figma/figmaTeamComponentSetsGet.js +48 -0
  47. package/api/figma/figmaTeamComponentsGet.js +48 -0
  48. package/api/figma/figmaTeamFoldersGet.js +48 -0
  49. package/api/figma/figmaTeamProjectsGet.js +48 -0
  50. package/api/figma/figmaTeamStylesGet.js +48 -0
  51. package/api/figma/figmaTeamWebhooksGet.js +47 -0
  52. package/api/figma/figmaVariablesLocalGet.js +48 -0
  53. package/api/figma/figmaVariablesPublishedGet.js +48 -0
  54. package/api/figma/figmaVariablesUpdate.js +50 -0
  55. package/api/figma/figmaWebhookCreate.js +47 -0
  56. package/api/figma/figmaWebhookDelete.js +48 -0
  57. package/api/figma/figmaWebhookGet.js +46 -0
  58. package/api/figma/figmaWebhookRequestsGet.js +47 -0
  59. package/api/figma/figmaWebhookUpdate.js +50 -0
  60. package/api/figma/figmaWebhooksGet.js +47 -0
  61. package/api/gorgias/gorgiasTicketCreate.js +1 -1
  62. package/api/gorgias/gorgiasTicketMessageCreate.js +1 -1
  63. package/api/gorgias/gorgiasTicketUpdate.js +1 -1
  64. package/api/linear/linearAttachmentCreate.js +1 -1
  65. package/api/linear/linearCommentCreate.js +1 -1
  66. package/api/linear/linearCommentUpdate.js +1 -1
  67. package/api/linear/linearIssueLabelCreate.js +1 -1
  68. package/api/linear/linearIssueUpdate.js +1 -1
  69. package/api/linear/linearProjectCreate.js +1 -1
  70. package/api/linear/linearProjectUpdate.js +1 -1
  71. package/api/linear/linearWebhookCreate.js +1 -1
  72. package/api/salesforce/salesforce.constants.js +13 -0
  73. package/api/salesforce/salesforce.utils.js +61 -0
  74. package/api/salesforce/salesforceAuthGet.js +115 -0
  75. package/api/salesforce/salesforceComposite.js +79 -0
  76. package/api/salesforce/salesforceCompositeBatch.js +73 -0
  77. package/api/salesforce/salesforceLimitsGet.js +55 -0
  78. package/api/salesforce/salesforceQuery.js +69 -0
  79. package/api/salesforce/salesforceQueryAll.js +62 -0
  80. package/api/salesforce/salesforceQueryMore.js +75 -0
  81. package/api/salesforce/salesforceRecentItemsGet.js +63 -0
  82. package/api/salesforce/salesforceResourcesGet.js +55 -0
  83. package/api/salesforce/salesforceSearch.js +62 -0
  84. package/api/salesforce/salesforceSobjectBasicInfoGet.js +81 -0
  85. package/api/salesforce/salesforceSobjectBlobGet.js +67 -0
  86. package/api/salesforce/salesforceSobjectCollectionCreate.js +78 -0
  87. package/api/salesforce/salesforceSobjectCollectionDelete.js +70 -0
  88. package/api/salesforce/salesforceSobjectCollectionGet.js +75 -0
  89. package/api/salesforce/salesforceSobjectCollectionUpdate.js +74 -0
  90. package/api/salesforce/salesforceSobjectCreate.js +66 -0
  91. package/api/salesforce/salesforceSobjectDelete.js +86 -0
  92. package/api/salesforce/salesforceSobjectDeleteByExternalId.js +91 -0
  93. package/api/salesforce/salesforceSobjectDeletedGet.js +71 -0
  94. package/api/salesforce/salesforceSobjectDescribe.js +81 -0
  95. package/api/salesforce/salesforceSobjectDescribeLayouts.js +64 -0
  96. package/api/salesforce/salesforceSobjectGet.js +93 -0
  97. package/api/salesforce/salesforceSobjectGetByExternalId.js +98 -0
  98. package/api/salesforce/salesforceSobjectTreeCreate.js +79 -0
  99. package/api/salesforce/salesforceSobjectUpdate.js +94 -0
  100. package/api/salesforce/salesforceSobjectUpdatedGet.js +71 -0
  101. package/api/salesforce/salesforceSobjectUpsert.js +74 -0
  102. package/api/salesforce/salesforceSobjectsDescribeGlobal.js +55 -0
  103. package/api/salesforce/salesforceVersionsGet.js +62 -0
  104. package/api/shopify/shopifyMetaobjectCreate.js +72 -0
  105. package/api/tableau/tableau.constants.js +8 -0
  106. package/api/tableau/tableau.utils.js +93 -0
  107. package/api/tableau/tableauGet.js +174 -0
  108. package/api/tableau/tableauUserAdd.js +16 -94
  109. package/api/tableau/tableauUsersGet.js +46 -134
  110. package/api/tagalys/docs.md +2 -2
  111. package/api/tagalys/tagalys.constants.js +17 -0
  112. package/api/tagalys/tagalys.utils.js +125 -0
  113. package/api/tagalys/tagalysAnalyticsEventSend.js +125 -0
  114. package/api/tagalys/tagalysCollectionGet.js +100 -0
  115. package/api/tagalys/tagalysPopularSearchesGet.js +60 -0
  116. package/api/tagalys/tagalysRecommendationGet.js +109 -0
  117. package/api/tagalys/tagalysSearch.js +82 -0
  118. package/api/tagalys/tagalysSearchSuggestionsGet.js +76 -0
  119. package/package.json +2 -1
@@ -0,0 +1,48 @@
1
+ // https://developers.figma.com/docs/rest-api/webhooks-endpoints/
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { figmaClient } = require('../figma/figma.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['webhookId'],
10
+ ]);
11
+
12
+ const figmaWebhookDelete = async (
13
+ credsPayload,
14
+ webhookId,
15
+ {
16
+ params,
17
+ fetchClient = figmaClient,
18
+ } = {},
19
+ ) => {
20
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
21
+ credsPayload,
22
+ webhookId,
23
+ });
24
+ if (rejectResponse) {
25
+ return rejectResponse;
26
+ }
27
+
28
+ return fetchClient.fetch({
29
+ requestPayload: {
30
+ method: 'delete',
31
+ url: `/v2/webhooks/${ webhookId }`,
32
+
33
+
34
+ },
35
+ context: {
36
+ credsPayload,
37
+ },
38
+ });
39
+ };
40
+
41
+ const funcApiConfig = {
42
+ argsWarden,
43
+ };
44
+
45
+ module.exports = {
46
+ figmaWebhookDelete,
47
+ funcApiConfig,
48
+ };
@@ -0,0 +1,46 @@
1
+ // https://developers.figma.com/docs/rest-api/webhooks-endpoints/
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { figmaClient } = require('../figma/figma.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['webhookId'],
10
+ ]);
11
+
12
+ const figmaWebhookGet = async (
13
+ credsPayload,
14
+ webhookId,
15
+ {
16
+ params,
17
+ fetchClient = figmaClient,
18
+ } = {},
19
+ ) => {
20
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
21
+ credsPayload,
22
+ webhookId
23
+ });
24
+ if (rejectResponse) {
25
+ return rejectResponse;
26
+ }
27
+
28
+ return fetchClient.fetch({
29
+ requestPayload: {
30
+ method: 'get',
31
+ url: `/v2/webhooks/${ webhookId }`,
32
+ },
33
+ context: {
34
+ credsPayload,
35
+ },
36
+ });
37
+ };
38
+
39
+ const funcApiConfig = {
40
+ argsWarden,
41
+ };
42
+
43
+ module.exports = {
44
+ figmaWebhookGet,
45
+ funcApiConfig,
46
+ };
@@ -0,0 +1,47 @@
1
+ // https://developers.figma.com/docs/rest-api/webhooks-endpoints/
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { figmaClient } = require('../figma/figma.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['webhookId'],
10
+ ]);
11
+
12
+ const figmaWebhookRequestsGet = async (
13
+ credsPayload,
14
+ webhookId,
15
+ {
16
+ params,
17
+ fetchClient = figmaClient,
18
+ } = {},
19
+ ) => {
20
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
21
+ credsPayload,
22
+ webhookId
23
+ });
24
+ if (rejectResponse) {
25
+ return rejectResponse;
26
+ }
27
+
28
+ return fetchClient.fetch({
29
+ requestPayload: {
30
+ method: 'get',
31
+ url: `/v2/webhooks/${ webhookId }/requests`,
32
+ params,
33
+ },
34
+ context: {
35
+ credsPayload,
36
+ },
37
+ });
38
+ };
39
+
40
+ const funcApiConfig = {
41
+ argsWarden,
42
+ };
43
+
44
+ module.exports = {
45
+ figmaWebhookRequestsGet,
46
+ funcApiConfig,
47
+ };
@@ -0,0 +1,50 @@
1
+ // https://developers.figma.com/docs/rest-api/webhooks-endpoints/
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { figmaClient } = require('../figma/figma.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['webhookId'],
10
+ ['webhookPayload', Boolean],
11
+ ]);
12
+
13
+ const figmaWebhookUpdate = async (
14
+ credsPayload,
15
+ webhookId,
16
+ webhookPayload,
17
+ {
18
+ params,
19
+ fetchClient = figmaClient,
20
+ } = {},
21
+ ) => {
22
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
23
+ credsPayload,
24
+ webhookId,
25
+ webhookPayload
26
+ });
27
+ if (rejectResponse) {
28
+ return rejectResponse;
29
+ }
30
+
31
+ return fetchClient.fetch({
32
+ requestPayload: {
33
+ method: 'put',
34
+ url: `/v2/webhooks/${ webhookId }`,
35
+ body: webhookPayload,
36
+ },
37
+ context: {
38
+ credsPayload,
39
+ },
40
+ });
41
+ };
42
+
43
+ const funcApiConfig = {
44
+ argsWarden,
45
+ };
46
+
47
+ module.exports = {
48
+ figmaWebhookUpdate,
49
+ funcApiConfig,
50
+ };
@@ -0,0 +1,47 @@
1
+ // https://developers.figma.com/docs/rest-api/webhooks-endpoints/
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { figmaClient } = require('../figma/figma.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ]);
10
+
11
+ const figmaWebhooksGet = async (
12
+ credsPayload,
13
+
14
+ {
15
+ params,
16
+ fetchClient = figmaClient,
17
+ } = {},
18
+ ) => {
19
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
20
+ credsPayload,
21
+
22
+ });
23
+ if (rejectResponse) {
24
+ return rejectResponse;
25
+ }
26
+
27
+ return fetchClient.fetch({
28
+ requestPayload: {
29
+ method: 'get',
30
+ url: `/v2/webhooks`,
31
+ params,
32
+
33
+ },
34
+ context: {
35
+ credsPayload,
36
+ },
37
+ });
38
+ };
39
+
40
+ const funcApiConfig = {
41
+ argsWarden,
42
+ };
43
+
44
+ module.exports = {
45
+ figmaWebhooksGet,
46
+ funcApiConfig,
47
+ };
@@ -6,7 +6,7 @@ const { gorgiasClient } = require('../gorgias/gorgias.utils');
6
6
 
7
7
  const argsWarden = new ArgsWarden([
8
8
  ['credsPayload', credsValidator],
9
- ['ticketBody', valueProvided],
9
+ ['ticketBody'],
10
10
  ]);
11
11
 
12
12
  const gorgiasTicketCreate = async (
@@ -7,7 +7,7 @@ const { gorgiasClient } = require('../gorgias/gorgias.utils');
7
7
  const argsWarden = new ArgsWarden([
8
8
  ['credsPayload', credsValidator],
9
9
  ['ticketId'],
10
- ['messageBody', valueProvided],
10
+ ['messageBody'],
11
11
  ]);
12
12
 
13
13
  const gorgiasTicketMessageCreate = async (
@@ -7,7 +7,7 @@ const { gorgiasClient } = require('../gorgias/gorgias.utils');
7
7
  const argsWarden = new ArgsWarden([
8
8
  ['credsPayload', credsValidator],
9
9
  ['ticketId'],
10
- ['ticketBody', valueProvided],
10
+ ['ticketBody'],
11
11
  ]);
12
12
 
13
13
  const gorgiasTicketUpdate = 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 linearAttachmentCreate = 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 linearCommentCreate = 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 linearCommentUpdate = 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 linearIssueLabelCreate = 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 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
+ */