@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.
- package/.creds.yml.sample +29 -0
- package/AGENTS.md +24 -0
- package/_build_scripts/createNewFunction.js +26 -3
- package/api/dropbox/docs.md +7 -0
- package/api/dropbox/dropbox.constants.js +10 -0
- package/api/dropbox/dropbox.utils.js +67 -0
- package/api/dropbox/dropboxAccountGet.js +64 -0
- package/api/dropbox/dropboxFileCopy.js +67 -0
- package/api/dropbox/dropboxFileDelete.js +89 -0
- package/api/dropbox/dropboxFileDownload.js +139 -0
- package/api/dropbox/dropboxFileMetadataGet.js +100 -0
- package/api/dropbox/dropboxFileMove.js +67 -0
- package/api/dropbox/dropboxFileUpload.js +129 -0
- package/api/dropbox/dropboxFolderCreate.js +68 -0
- package/api/dropbox/dropboxFolderList.js +66 -0
- package/api/dropbox/dropboxGet.js +158 -0
- package/api/dropbox/dropboxSearch.js +161 -0
- package/api/dropbox/dropboxSharedLinkCreate.js +68 -0
- package/api/dropbox/dropboxSpaceUsageGet.js +55 -0
- package/api/dropbox/dropboxTemporaryLinkGet.js +75 -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/google/docs.md +1 -0
- package/api/google/google.constants.js +1 -0
- package/api/google/google.utils.js +21 -0
- package/api/google/googleanalyticsMetadataGet.js +62 -0
- package/api/google/googleanalyticsRealtimeReportRun.js +103 -0
- package/api/google/googleanalyticsReportRun.js +114 -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/shopify.utils.js +53 -4
- package/api/shopify/shopifyMetaobjectCreate.js +79 -0
- package/api/shopify/shopifyMetaobjectDelete.js +90 -0
- package/api/shopify/shopifyMetaobjectGet.js +80 -0
- package/api/shopify/shopifyMetaobjectUpdate.js +108 -0
- package/api/shopify/shopifyStorefrontSearch.js +158 -0
- package/api/spotify/docs.md +8 -0
- package/api/spotify/spotify.constants.js +12 -0
- package/api/spotify/spotify.utils.js +106 -0
- package/api/spotify/spotifyAlbumGet.js +76 -0
- package/api/spotify/spotifyAlbumTracksGet.js +49 -0
- package/api/spotify/spotifyArtistAlbumsGet.js +55 -0
- package/api/spotify/spotifyArtistGet.js +71 -0
- package/api/spotify/spotifyArtistTopTracksGet.js +56 -0
- package/api/spotify/spotifyGet.js +171 -0
- package/api/spotify/spotifyMeGet.js +48 -0
- package/api/spotify/spotifyPlayerCurrentlyPlayingGet.js +62 -0
- package/api/spotify/spotifyPlayerDevicesGet.js +51 -0
- package/api/spotify/spotifyPlayerGet.js +63 -0
- package/api/spotify/spotifyPlayerNext.js +55 -0
- package/api/spotify/spotifyPlayerPause.js +55 -0
- package/api/spotify/spotifyPlayerPlay.js +70 -0
- package/api/spotify/spotifyPlayerPrevious.js +55 -0
- package/api/spotify/spotifyPlaylistCreate.js +63 -0
- package/api/spotify/spotifyPlaylistGet.js +91 -0
- package/api/spotify/spotifyPlaylistItemsAdd.js +61 -0
- package/api/spotify/spotifyPlaylistItemsGet.js +58 -0
- package/api/spotify/spotifyPlaylistItemsRemove.js +67 -0
- package/api/spotify/spotifyPlaylistUpdate.js +64 -0
- package/api/spotify/spotifyPlaylistsGet.js +47 -0
- package/api/spotify/spotifySavedTracksGet.js +46 -0
- package/api/spotify/spotifySavedTracksRemove.js +59 -0
- package/api/spotify/spotifySavedTracksSave.js +59 -0
- package/api/spotify/spotifySearch.js +174 -0
- package/api/spotify/spotifyTrackGet.js +76 -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 +15 -89
- package/api/tagalys/tagalysSearchSuggestionsGet.js +76 -0
- package/package.json +2 -1
- package/server.js +3 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_retrieve.htm
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden, actionSingleOrMultiple, 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
|
+
['sobjectType'],
|
|
10
|
+
['id'],
|
|
11
|
+
['record'],
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
const salesforceSobjectUpdateSingle = async (
|
|
15
|
+
credsPayload,
|
|
16
|
+
sobjectType,
|
|
17
|
+
id,
|
|
18
|
+
record,
|
|
19
|
+
{
|
|
20
|
+
apiVersion,
|
|
21
|
+
inspect = false,
|
|
22
|
+
fetchClient = salesforceClient,
|
|
23
|
+
} = {},
|
|
24
|
+
) => {
|
|
25
|
+
|
|
26
|
+
return fetchClient.fetch({
|
|
27
|
+
requestPayload: {
|
|
28
|
+
method: 'patch',
|
|
29
|
+
url: `/sobjects/${ sobjectType }/${ id }`,
|
|
30
|
+
body: record,
|
|
31
|
+
},
|
|
32
|
+
context: {
|
|
33
|
+
credsPayload,
|
|
34
|
+
apiVersion,
|
|
35
|
+
},
|
|
36
|
+
inspect,
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const salesforceSobjectUpdate = async (
|
|
41
|
+
credsPayload,
|
|
42
|
+
sobjectType,
|
|
43
|
+
id,
|
|
44
|
+
record,
|
|
45
|
+
{
|
|
46
|
+
queueRunOptions,
|
|
47
|
+
...options
|
|
48
|
+
} = {},
|
|
49
|
+
) => {
|
|
50
|
+
|
|
51
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
52
|
+
credsPayload,
|
|
53
|
+
sobjectType,
|
|
54
|
+
id,
|
|
55
|
+
record,
|
|
56
|
+
});
|
|
57
|
+
if (rejectResponse) {
|
|
58
|
+
return rejectResponse;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return actionSingleOrMultiple(
|
|
62
|
+
id,
|
|
63
|
+
salesforceSobjectUpdateSingle,
|
|
64
|
+
(idItem) => ({
|
|
65
|
+
args: [credsPayload, sobjectType, idItem, record, options],
|
|
66
|
+
}),
|
|
67
|
+
{
|
|
68
|
+
...(queueRunOptions ? { queueRunOptions } : {}),
|
|
69
|
+
},
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const funcApiConfig = {
|
|
74
|
+
argsWarden,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
module.exports = {
|
|
78
|
+
salesforceSobjectUpdate,
|
|
79
|
+
salesforceSobjectUpdateSingle,
|
|
80
|
+
funcApiConfig,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/*
|
|
84
|
+
curl -X POST "http://localhost:8000/salesforceSobjectUpdate" \
|
|
85
|
+
-H "Content-Type: application/json" \
|
|
86
|
+
-d '{
|
|
87
|
+
"credsPayload": { "credsPath": "salesforce" },
|
|
88
|
+
"sobjectType": "Account",
|
|
89
|
+
"id": "001xx000003DGb2AAG",
|
|
90
|
+
"record": {
|
|
91
|
+
"Name": "Updated Account"
|
|
92
|
+
}
|
|
93
|
+
}'
|
|
94
|
+
*/
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_getupdated.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
|
+
['sobjectType'],
|
|
10
|
+
['start'],
|
|
11
|
+
['end'],
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
const salesforceSobjectUpdatedGet = async (
|
|
15
|
+
credsPayload,
|
|
16
|
+
sobjectType,
|
|
17
|
+
start,
|
|
18
|
+
end,
|
|
19
|
+
{
|
|
20
|
+
apiVersion,
|
|
21
|
+
inspect = false,
|
|
22
|
+
fetchClient = salesforceClient,
|
|
23
|
+
} = {},
|
|
24
|
+
) => {
|
|
25
|
+
|
|
26
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
27
|
+
credsPayload,
|
|
28
|
+
sobjectType,
|
|
29
|
+
start,
|
|
30
|
+
end,
|
|
31
|
+
});
|
|
32
|
+
if (rejectResponse) {
|
|
33
|
+
return rejectResponse;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return fetchClient.fetch({
|
|
37
|
+
requestPayload: {
|
|
38
|
+
method: 'get',
|
|
39
|
+
url: `/sobjects/${ sobjectType }/updated`,
|
|
40
|
+
params: {
|
|
41
|
+
start,
|
|
42
|
+
end,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
context: {
|
|
46
|
+
credsPayload,
|
|
47
|
+
apiVersion,
|
|
48
|
+
},
|
|
49
|
+
inspect,
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const funcApiConfig = {
|
|
54
|
+
argsWarden,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
module.exports = {
|
|
58
|
+
salesforceSobjectUpdatedGet,
|
|
59
|
+
funcApiConfig,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/*
|
|
63
|
+
curl -X POST "http://localhost:8000/salesforceSobjectUpdatedGet" \
|
|
64
|
+
-H "Content-Type: application/json" \
|
|
65
|
+
-d '{
|
|
66
|
+
"credsPayload": { "credsPath": "salesforce" },
|
|
67
|
+
"sobjectType": "Account",
|
|
68
|
+
"start": "2026-01-01T00:00:00+00:00",
|
|
69
|
+
"end": "2026-01-02T00:00:00+00:00"
|
|
70
|
+
}'
|
|
71
|
+
*/
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_upsert.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
|
+
['sobjectType'],
|
|
10
|
+
['externalIdField'],
|
|
11
|
+
['externalId'],
|
|
12
|
+
['record'],
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
const salesforceSobjectUpsert = async (
|
|
16
|
+
credsPayload,
|
|
17
|
+
sobjectType,
|
|
18
|
+
externalIdField,
|
|
19
|
+
externalId,
|
|
20
|
+
record,
|
|
21
|
+
{
|
|
22
|
+
apiVersion,
|
|
23
|
+
inspect = false,
|
|
24
|
+
fetchClient = salesforceClient,
|
|
25
|
+
} = {},
|
|
26
|
+
) => {
|
|
27
|
+
|
|
28
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
29
|
+
credsPayload,
|
|
30
|
+
sobjectType,
|
|
31
|
+
externalIdField,
|
|
32
|
+
externalId,
|
|
33
|
+
record,
|
|
34
|
+
});
|
|
35
|
+
if (rejectResponse) {
|
|
36
|
+
return rejectResponse;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return fetchClient.fetch({
|
|
40
|
+
requestPayload: {
|
|
41
|
+
method: 'patch',
|
|
42
|
+
url: `/sobjects/${ sobjectType }/${ externalIdField }/${ encodeURIComponent(externalId) }`,
|
|
43
|
+
body: record,
|
|
44
|
+
},
|
|
45
|
+
context: {
|
|
46
|
+
credsPayload,
|
|
47
|
+
apiVersion,
|
|
48
|
+
},
|
|
49
|
+
inspect,
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const funcApiConfig = {
|
|
54
|
+
argsWarden,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
module.exports = {
|
|
58
|
+
salesforceSobjectUpsert,
|
|
59
|
+
funcApiConfig,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/*
|
|
63
|
+
curl -X POST "http://localhost:8000/salesforceSobjectUpsert" \
|
|
64
|
+
-H "Content-Type: application/json" \
|
|
65
|
+
-d '{
|
|
66
|
+
"credsPayload": { "credsPath": "salesforce" },
|
|
67
|
+
"sobjectType": "Account",
|
|
68
|
+
"externalIdField": "External_Id__c",
|
|
69
|
+
"externalId": "ext-123",
|
|
70
|
+
"record": {
|
|
71
|
+
"Name": "Upserted Account"
|
|
72
|
+
}
|
|
73
|
+
}'
|
|
74
|
+
*/
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_describeGlobal.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 salesforceSobjectsDescribeGlobal = 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: '/sobjects',
|
|
31
|
+
},
|
|
32
|
+
context: {
|
|
33
|
+
credsPayload,
|
|
34
|
+
apiVersion,
|
|
35
|
+
},
|
|
36
|
+
inspect,
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const funcApiConfig = {
|
|
41
|
+
argsWarden,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
module.exports = {
|
|
45
|
+
salesforceSobjectsDescribeGlobal,
|
|
46
|
+
funcApiConfig,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/*
|
|
50
|
+
curl -X POST "http://localhost:8000/salesforceSobjectsDescribeGlobal" \
|
|
51
|
+
-H "Content-Type: application/json" \
|
|
52
|
+
-d '{
|
|
53
|
+
"credsPayload": { "credsPath": "salesforce" }
|
|
54
|
+
}'
|
|
55
|
+
*/
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_versions.htm
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
ArgsWarden,
|
|
5
|
+
appendUrlToBase,
|
|
6
|
+
customFetch,
|
|
7
|
+
} = require('../utils');
|
|
8
|
+
const { credsValidator } = require('../validators');
|
|
9
|
+
const { salesforceAuthGet } = require('../salesforce/salesforceAuthGet');
|
|
10
|
+
|
|
11
|
+
const argsWarden = new ArgsWarden([
|
|
12
|
+
['credsPayload', credsValidator],
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
// Versions live at {instance}/services/data/ (no vXX.X segment).
|
|
16
|
+
const salesforceVersionsGet = async (
|
|
17
|
+
credsPayload,
|
|
18
|
+
) => {
|
|
19
|
+
|
|
20
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
21
|
+
credsPayload,
|
|
22
|
+
});
|
|
23
|
+
if (rejectResponse) {
|
|
24
|
+
return rejectResponse;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const authResponse = await salesforceAuthGet(credsPayload);
|
|
28
|
+
if (!authResponse.ok) {
|
|
29
|
+
return authResponse;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
access_token,
|
|
34
|
+
instance_url,
|
|
35
|
+
} = authResponse.data;
|
|
36
|
+
|
|
37
|
+
const url = appendUrlToBase(instance_url, '/services/data');
|
|
38
|
+
|
|
39
|
+
return customFetch(url, {
|
|
40
|
+
method: 'get',
|
|
41
|
+
headers: {
|
|
42
|
+
Authorization: `Bearer ${ access_token }`,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const funcApiConfig = {
|
|
48
|
+
argsWarden,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
module.exports = {
|
|
52
|
+
salesforceVersionsGet,
|
|
53
|
+
funcApiConfig,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/*
|
|
57
|
+
curl -X POST "http://localhost:8000/salesforceVersionsGet" \
|
|
58
|
+
-H "Content-Type: application/json" \
|
|
59
|
+
-d '{
|
|
60
|
+
"credsPayload": { "credsPath": "salesforce" }
|
|
61
|
+
}'
|
|
62
|
+
*/
|
|
@@ -76,6 +76,31 @@ const useUrlAndAuthHeaders = async (state) => {
|
|
|
76
76
|
};
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
+
const useStorefrontUrlAndAuthHeaders = async (state) => {
|
|
80
|
+
const { requestPayload, context } = state;
|
|
81
|
+
const {
|
|
82
|
+
apiVersion = DEFAULT_API_VERSION,
|
|
83
|
+
creds,
|
|
84
|
+
} = context;
|
|
85
|
+
const {
|
|
86
|
+
STORE_HANDLE,
|
|
87
|
+
STOREFRONT_API_KEY,
|
|
88
|
+
} = creds;
|
|
89
|
+
|
|
90
|
+
const baseUrl = `https://${ STORE_HANDLE }.myshopify.com/api/${ apiVersion }/graphql.json`;
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
requestPayload: {
|
|
94
|
+
...requestPayload,
|
|
95
|
+
url: appendUrlToBase(baseUrl, requestPayload.url),
|
|
96
|
+
headers: {
|
|
97
|
+
'X-Shopify-Storefront-Access-Token': STOREFRONT_API_KEY,
|
|
98
|
+
...requestPayload.headers,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
|
|
79
104
|
const movePageInfoToMeta = async (state) => {
|
|
80
105
|
const { response, context } = state;
|
|
81
106
|
const { resultPath } = context ?? {};
|
|
@@ -86,15 +111,23 @@ const movePageInfoToMeta = async (state) => {
|
|
|
86
111
|
|
|
87
112
|
const connection = objectDigNodeAtPath(response.data, pathAsArray(resultPath));
|
|
88
113
|
|
|
89
|
-
if (!connection
|
|
114
|
+
if (!connection || typeof connection !== 'object') {
|
|
115
|
+
return {};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const meta = {
|
|
119
|
+
...connection.pageInfo ? { pageInfo: connection.pageInfo } : {},
|
|
120
|
+
...connection.totalCount !== undefined ? { totalCount: connection.totalCount } : {},
|
|
121
|
+
...connection.productFilters !== undefined ? { productFilters: connection.productFilters } : {},
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
if (!Object.keys(meta).length) {
|
|
90
125
|
return {};
|
|
91
126
|
}
|
|
92
127
|
|
|
93
128
|
return {
|
|
94
129
|
response: {
|
|
95
|
-
meta
|
|
96
|
-
pageInfo: connection.pageInfo,
|
|
97
|
-
},
|
|
130
|
+
meta,
|
|
98
131
|
},
|
|
99
132
|
};
|
|
100
133
|
};
|
|
@@ -188,7 +221,23 @@ const shopifyClient = new FetchClient({
|
|
|
188
221
|
],
|
|
189
222
|
});
|
|
190
223
|
|
|
224
|
+
const shopifyStorefrontClient = new FetchClient({
|
|
225
|
+
pipeline: [
|
|
226
|
+
resolveCreds,
|
|
227
|
+
useStorefrontUrlAndAuthHeaders,
|
|
228
|
+
'fetch',
|
|
229
|
+
movePageInfoToMeta,
|
|
230
|
+
fetchClientCommonSteps.stripEdgesAndNodes,
|
|
231
|
+
fetchClientCommonSteps.collapseDataWithOneValue,
|
|
232
|
+
fetchClientCommonSteps.exitEarlyOnNotOk,
|
|
233
|
+
fetchClientCommonSteps.exitEarlyOnGraphqlErrors,
|
|
234
|
+
fetchClientCommonSteps.digToPath,
|
|
235
|
+
handleMutationUserErrors,
|
|
236
|
+
],
|
|
237
|
+
});
|
|
238
|
+
|
|
191
239
|
module.exports = {
|
|
192
240
|
parseShopifyJsonl,
|
|
193
241
|
shopifyClient,
|
|
242
|
+
shopifyStorefrontClient,
|
|
194
243
|
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/mutations/metaobjectCreate
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyMutationDo } = require('../shopify/shopifyMutationDo');
|
|
6
|
+
|
|
7
|
+
const metaobjectInputValidator = (metaobjectInput) => Boolean(metaobjectInput?.type);
|
|
8
|
+
|
|
9
|
+
const argsWarden = new ArgsWarden([
|
|
10
|
+
['credsPayload', credsValidator],
|
|
11
|
+
['metaobjectInput', metaobjectInputValidator],
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
const defaultReturnMetaobjectAttrs = 'id handle type updatedAt capabilities { publishable { status } }';
|
|
15
|
+
|
|
16
|
+
const shopifyMetaobjectCreate = async (
|
|
17
|
+
credsPayload,
|
|
18
|
+
metaobjectInput,
|
|
19
|
+
{
|
|
20
|
+
apiVersion,
|
|
21
|
+
returnMetaobjectAttrs = defaultReturnMetaobjectAttrs,
|
|
22
|
+
} = {},
|
|
23
|
+
) => {
|
|
24
|
+
|
|
25
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
26
|
+
credsPayload,
|
|
27
|
+
metaobjectInput,
|
|
28
|
+
});
|
|
29
|
+
if (rejectResponse) {
|
|
30
|
+
return rejectResponse;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return shopifyMutationDo(
|
|
34
|
+
credsPayload,
|
|
35
|
+
'metaobjectCreate',
|
|
36
|
+
{
|
|
37
|
+
mutationVariables: {
|
|
38
|
+
metaobject: {
|
|
39
|
+
type: 'MetaobjectCreateInput!',
|
|
40
|
+
value: metaobjectInput,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
returnSchema: `metaobject { ${ returnMetaobjectAttrs } }`,
|
|
44
|
+
apiVersion,
|
|
45
|
+
},
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const funcApiConfig = {
|
|
50
|
+
argsWarden,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
module.exports = {
|
|
54
|
+
shopifyMetaobjectCreate,
|
|
55
|
+
funcApiConfig,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/*
|
|
59
|
+
curl -X POST "http://localhost:8000/shopifyMetaobjectCreate" \
|
|
60
|
+
-H "Content-Type: application/json" \
|
|
61
|
+
-d '{
|
|
62
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
63
|
+
"metaobjectInput": {
|
|
64
|
+
"type": "catalog_filter_blacklist",
|
|
65
|
+
"handle": "collection-blacklist-example",
|
|
66
|
+
"capabilities": {
|
|
67
|
+
"publishable": {
|
|
68
|
+
"status": "ACTIVE"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"fields": [
|
|
72
|
+
{ "key": "internal_name", "value": "Blacklist Category > \"Example\"" },
|
|
73
|
+
{ "key": "source_filter", "value": "Category" },
|
|
74
|
+
{ "key": "values", "value": "[\"Example\"]" },
|
|
75
|
+
{ "key": "enabled", "value": "true" }
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
}'
|
|
79
|
+
*/
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/mutations/metaobjectDelete
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { actionSingleOrMultiple, ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyMutationDo } = require('../shopify/shopifyMutationDo');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['metaobjectId'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const shopifyMetaobjectDeleteSingle = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
metaobjectId,
|
|
15
|
+
{
|
|
16
|
+
apiVersion,
|
|
17
|
+
returnSchema = 'deletedId',
|
|
18
|
+
} = {},
|
|
19
|
+
) => {
|
|
20
|
+
|
|
21
|
+
return shopifyMutationDo(
|
|
22
|
+
credsPayload,
|
|
23
|
+
'metaobjectDelete',
|
|
24
|
+
{
|
|
25
|
+
mutationVariables: {
|
|
26
|
+
id: {
|
|
27
|
+
type: 'ID!',
|
|
28
|
+
value: `gid://shopify/Metaobject/${ metaobjectId }`,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
returnSchema,
|
|
32
|
+
apiVersion,
|
|
33
|
+
},
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const shopifyMetaobjectDelete = async (
|
|
38
|
+
credsPayload,
|
|
39
|
+
metaobjectId,
|
|
40
|
+
{
|
|
41
|
+
queueRunOptions,
|
|
42
|
+
apiVersion,
|
|
43
|
+
returnSchema = 'deletedId',
|
|
44
|
+
} = {},
|
|
45
|
+
) => {
|
|
46
|
+
|
|
47
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
48
|
+
credsPayload,
|
|
49
|
+
metaobjectId,
|
|
50
|
+
});
|
|
51
|
+
if (rejectResponse) {
|
|
52
|
+
return rejectResponse;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return actionSingleOrMultiple(
|
|
56
|
+
metaobjectId,
|
|
57
|
+
shopifyMetaobjectDeleteSingle,
|
|
58
|
+
(metaobjectIdItem) => ({
|
|
59
|
+
args: [credsPayload, metaobjectIdItem, { apiVersion, returnSchema }],
|
|
60
|
+
}),
|
|
61
|
+
{
|
|
62
|
+
...(queueRunOptions ? { queueRunOptions } : {}),
|
|
63
|
+
},
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const funcApiConfig = {
|
|
68
|
+
argsWarden,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
module.exports = {
|
|
72
|
+
shopifyMetaobjectDelete,
|
|
73
|
+
funcApiConfig,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/*
|
|
77
|
+
curl -X POST "http://localhost:8000/shopifyMetaobjectDelete" \
|
|
78
|
+
-H "Content-Type: application/json" \
|
|
79
|
+
-d '{
|
|
80
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
81
|
+
"metaobjectId": "215094820924"
|
|
82
|
+
}'
|
|
83
|
+
|
|
84
|
+
curl -X POST "http://localhost:8000/shopifyMetaobjectDelete" \
|
|
85
|
+
-H "Content-Type: application/json" \
|
|
86
|
+
-d '{
|
|
87
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
88
|
+
"metaobjectId": ["215094820924", "215094820925"]
|
|
89
|
+
}'
|
|
90
|
+
*/
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/queries/metaobject
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { actionSingleOrMultiple, ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyGetSingle } = require('../shopify/shopifyGetSingle');
|
|
6
|
+
|
|
7
|
+
const defaultAttrs = 'id handle type updatedAt capabilities { publishable { status } } fields { key value type }';
|
|
8
|
+
|
|
9
|
+
const argsWarden = new ArgsWarden([
|
|
10
|
+
['credsPayload', credsValidator],
|
|
11
|
+
['metaobjectId'],
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
const shopifyMetaobjectGetSingle = async (
|
|
15
|
+
credsPayload,
|
|
16
|
+
metaobjectId,
|
|
17
|
+
{
|
|
18
|
+
apiVersion,
|
|
19
|
+
attrs = defaultAttrs,
|
|
20
|
+
} = {},
|
|
21
|
+
) => {
|
|
22
|
+
|
|
23
|
+
return shopifyGetSingle(
|
|
24
|
+
credsPayload,
|
|
25
|
+
'metaobject',
|
|
26
|
+
metaobjectId,
|
|
27
|
+
{
|
|
28
|
+
apiVersion,
|
|
29
|
+
attrs,
|
|
30
|
+
},
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const shopifyMetaobjectGet = async (
|
|
35
|
+
credsPayload,
|
|
36
|
+
metaobjectId,
|
|
37
|
+
{
|
|
38
|
+
queueRunOptions,
|
|
39
|
+
apiVersion,
|
|
40
|
+
attrs = defaultAttrs,
|
|
41
|
+
} = {},
|
|
42
|
+
) => {
|
|
43
|
+
|
|
44
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
45
|
+
credsPayload,
|
|
46
|
+
metaobjectId,
|
|
47
|
+
});
|
|
48
|
+
if (rejectResponse) {
|
|
49
|
+
return rejectResponse;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return actionSingleOrMultiple(
|
|
53
|
+
metaobjectId,
|
|
54
|
+
shopifyMetaobjectGetSingle,
|
|
55
|
+
(metaobjectIdItem) => ({
|
|
56
|
+
args: [credsPayload, metaobjectIdItem, { apiVersion, attrs }],
|
|
57
|
+
}),
|
|
58
|
+
{
|
|
59
|
+
...(queueRunOptions ? { queueRunOptions } : {}),
|
|
60
|
+
},
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const funcApiConfig = {
|
|
65
|
+
argsWarden,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
module.exports = {
|
|
69
|
+
shopifyMetaobjectGet,
|
|
70
|
+
funcApiConfig,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/*
|
|
74
|
+
curl -X POST "http://localhost:8000/shopifyMetaobjectGet" \
|
|
75
|
+
-H "Content-Type: application/json" \
|
|
76
|
+
-d '{
|
|
77
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
78
|
+
"metaobjectId": "207864102984"
|
|
79
|
+
}'
|
|
80
|
+
*/
|