@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.
- package/.creds.yml.sample +22 -4
- package/AGENTS.md +17 -0
- package/api/fastsimon/.gitkeep +0 -0
- package/api/fastsimon/docs.md +14 -0
- package/api/fastsimon/fastsimon.constants.js +18 -0
- package/api/fastsimon/fastsimon.utils.js +246 -0
- package/api/fastsimon/fastsimonSearch.js +84 -0
- package/api/figma/docs.md +3 -3
- package/api/figma/figma.constants.js +1 -1
- package/api/figma/figma.utils.js +13 -2
- package/api/figma/figmaActivityLogsGet.js +44 -0
- package/api/figma/figmaAiUsageDailyGet.js +44 -0
- package/api/figma/figmaComponentGet.js +48 -0
- package/api/figma/figmaComponentSetGet.js +48 -0
- package/api/figma/figmaDevResourcesCreate.js +47 -0
- package/api/figma/figmaDevResourcesUpdate.js +47 -0
- package/api/figma/figmaDeveloperLogsCreate.js +47 -0
- package/api/figma/figmaDiscoveryGet.js +44 -0
- package/api/figma/figmaFileCommentCreate.js +50 -0
- package/api/figma/figmaFileCommentDelete.js +51 -0
- package/api/figma/figmaFileCommentReactionCreate.js +53 -0
- package/api/figma/figmaFileCommentReactionDelete.js +51 -0
- package/api/figma/figmaFileCommentReactionsGet.js +51 -0
- package/api/figma/figmaFileCommentsGet.js +48 -0
- package/api/figma/figmaFileComponentSetsGet.js +48 -0
- package/api/figma/figmaFileComponentsGet.js +48 -0
- package/api/figma/figmaFileDevResourceDelete.js +51 -0
- package/api/figma/figmaFileDevResourcesGet.js +48 -0
- package/api/figma/figmaFileGet.js +48 -0
- package/api/figma/figmaFileImageFillsGet.js +48 -0
- package/api/figma/figmaFileImagesGet.js +48 -0
- package/api/figma/figmaFileMetaGet.js +48 -0
- package/api/figma/figmaFileNodesGet.js +48 -0
- package/api/figma/figmaFileStylesGet.js +48 -0
- package/api/figma/figmaFileVersionsGet.js +48 -0
- package/api/figma/figmaFolderFilesGet.js +48 -0
- package/api/figma/figmaFolderFoldersGet.js +48 -0
- package/api/figma/figmaFolderMetaGet.js +48 -0
- package/api/figma/figmaGet.js +15 -63
- package/api/figma/figmaMeGet.js +53 -0
- package/api/figma/figmaOembedGet.js +44 -0
- package/api/figma/figmaPaymentsGet.js +44 -0
- package/api/figma/figmaProjectFilesGet.js +48 -0
- package/api/figma/figmaProjectMetaGet.js +48 -0
- package/api/figma/figmaStyleGet.js +48 -0
- package/api/figma/figmaTeamComponentSetsGet.js +48 -0
- package/api/figma/figmaTeamComponentsGet.js +48 -0
- package/api/figma/figmaTeamFoldersGet.js +48 -0
- package/api/figma/figmaTeamProjectsGet.js +48 -0
- package/api/figma/figmaTeamStylesGet.js +48 -0
- package/api/figma/figmaTeamWebhooksGet.js +47 -0
- package/api/figma/figmaVariablesLocalGet.js +48 -0
- package/api/figma/figmaVariablesPublishedGet.js +48 -0
- package/api/figma/figmaVariablesUpdate.js +50 -0
- package/api/figma/figmaWebhookCreate.js +47 -0
- package/api/figma/figmaWebhookDelete.js +48 -0
- package/api/figma/figmaWebhookGet.js +46 -0
- package/api/figma/figmaWebhookRequestsGet.js +47 -0
- package/api/figma/figmaWebhookUpdate.js +50 -0
- package/api/figma/figmaWebhooksGet.js +47 -0
- package/api/gorgias/gorgiasTicketCreate.js +1 -1
- package/api/gorgias/gorgiasTicketMessageCreate.js +1 -1
- package/api/gorgias/gorgiasTicketUpdate.js +1 -1
- package/api/linear/linearAttachmentCreate.js +1 -1
- package/api/linear/linearCommentCreate.js +1 -1
- package/api/linear/linearCommentUpdate.js +1 -1
- package/api/linear/linearIssueLabelCreate.js +1 -1
- package/api/linear/linearIssueUpdate.js +1 -1
- package/api/linear/linearProjectCreate.js +1 -1
- package/api/linear/linearProjectUpdate.js +1 -1
- package/api/linear/linearWebhookCreate.js +1 -1
- package/api/salesforce/salesforce.constants.js +13 -0
- package/api/salesforce/salesforce.utils.js +61 -0
- package/api/salesforce/salesforceAuthGet.js +115 -0
- package/api/salesforce/salesforceComposite.js +79 -0
- package/api/salesforce/salesforceCompositeBatch.js +73 -0
- package/api/salesforce/salesforceLimitsGet.js +55 -0
- package/api/salesforce/salesforceQuery.js +69 -0
- package/api/salesforce/salesforceQueryAll.js +62 -0
- package/api/salesforce/salesforceQueryMore.js +75 -0
- package/api/salesforce/salesforceRecentItemsGet.js +63 -0
- package/api/salesforce/salesforceResourcesGet.js +55 -0
- package/api/salesforce/salesforceSearch.js +62 -0
- package/api/salesforce/salesforceSobjectBasicInfoGet.js +81 -0
- package/api/salesforce/salesforceSobjectBlobGet.js +67 -0
- package/api/salesforce/salesforceSobjectCollectionCreate.js +78 -0
- package/api/salesforce/salesforceSobjectCollectionDelete.js +70 -0
- package/api/salesforce/salesforceSobjectCollectionGet.js +75 -0
- package/api/salesforce/salesforceSobjectCollectionUpdate.js +74 -0
- package/api/salesforce/salesforceSobjectCreate.js +66 -0
- package/api/salesforce/salesforceSobjectDelete.js +86 -0
- package/api/salesforce/salesforceSobjectDeleteByExternalId.js +91 -0
- package/api/salesforce/salesforceSobjectDeletedGet.js +71 -0
- package/api/salesforce/salesforceSobjectDescribe.js +81 -0
- package/api/salesforce/salesforceSobjectDescribeLayouts.js +64 -0
- package/api/salesforce/salesforceSobjectGet.js +93 -0
- package/api/salesforce/salesforceSobjectGetByExternalId.js +98 -0
- package/api/salesforce/salesforceSobjectTreeCreate.js +79 -0
- package/api/salesforce/salesforceSobjectUpdate.js +94 -0
- package/api/salesforce/salesforceSobjectUpdatedGet.js +71 -0
- package/api/salesforce/salesforceSobjectUpsert.js +74 -0
- package/api/salesforce/salesforceSobjectsDescribeGlobal.js +55 -0
- package/api/salesforce/salesforceVersionsGet.js +62 -0
- package/api/shopify/shopifyMetaobjectCreate.js +72 -0
- package/api/tableau/tableau.constants.js +8 -0
- package/api/tableau/tableau.utils.js +93 -0
- package/api/tableau/tableauGet.js +174 -0
- package/api/tableau/tableauUserAdd.js +16 -94
- package/api/tableau/tableauUsersGet.js +46 -134
- package/api/tagalys/docs.md +2 -2
- package/api/tagalys/tagalys.constants.js +17 -0
- package/api/tagalys/tagalys.utils.js +125 -0
- package/api/tagalys/tagalysAnalyticsEventSend.js +125 -0
- package/api/tagalys/tagalysCollectionGet.js +100 -0
- package/api/tagalys/tagalysPopularSearchesGet.js +60 -0
- package/api/tagalys/tagalysRecommendationGet.js +109 -0
- package/api/tagalys/tagalysSearch.js +82 -0
- package/api/tagalys/tagalysSearchSuggestionsGet.js +76 -0
- 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
|
+
};
|
|
@@ -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
|
+
*/
|