@foxtware/mineral 0.1.28 → 0.1.30
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 +35 -2
- package/AGENTS.md +7 -0
- package/_build_scripts/createNewFunction.js +26 -3
- package/api/dpd/docs.md +6 -0
- package/api/dpd/dpd.constants.js +9 -0
- package/api/dpd/dpd.utils.js +145 -0
- package/api/dpd/dpdTrackingGet.js +64 -0
- 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/fedex/docs.md +6 -0
- package/api/fedex/fedex.constants.js +11 -0
- package/api/fedex/fedex.utils.js +151 -0
- package/api/fedex/fedexTrackingGet.js +76 -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/paypal/docs.md +14 -0
- package/api/paypal/paypal.constants.js +13 -0
- package/api/paypal/paypal.utils.js +166 -0
- package/api/paypal/paypalAccessTokenGet.js +81 -0
- package/api/paypal/paypalAuthorizationCapture.js +75 -0
- package/api/paypal/paypalAuthorizationGet.js +57 -0
- package/api/paypal/paypalBalancesGet.js +65 -0
- package/api/paypal/paypalCaptureGet.js +57 -0
- package/api/paypal/paypalCaptureRefund.js +78 -0
- package/api/paypal/paypalOrderAuthorize.js +69 -0
- package/api/paypal/paypalOrderCapture.js +69 -0
- package/api/paypal/paypalOrderCreate.js +81 -0
- package/api/paypal/paypalOrderGet.js +57 -0
- package/api/paypal/paypalRefundGet.js +57 -0
- package/api/paypal/paypalTransactionsGet.js +101 -0
- package/api/paypal/paypalUserInfoGet.js +62 -0
- package/api/royalmail/docs.md +6 -0
- package/api/royalmail/royalmail.constants.js +7 -0
- package/api/royalmail/royalmail.utils.js +55 -0
- package/api/royalmail/royalmailTrackingGet.js +70 -0
- package/api/shopify/shopify.utils.js +65 -4
- package/api/shopify/shopifyMetaobjectCreate.js +13 -6
- 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/starshipit/starshipitProductUpdate.js +102 -0
- package/api/starshipit/starshipitProductsGet.js +2 -2
- package/api/stylearcade/stylearcadeGet.js +5 -2
- package/api/utils.js +39 -0
- package/package.json +1 -1
- package/server.js +3 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// https://developer.paypal.com/docs/api/transaction-search/v1/#transactions_get
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { paypalClient } = require('../paypal/paypal.utils');
|
|
6
|
+
const { DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE } = require('../paypal/paypal.constants');
|
|
7
|
+
|
|
8
|
+
const argsWarden = new ArgsWarden([
|
|
9
|
+
['credsPayload', credsValidator],
|
|
10
|
+
['startDate'],
|
|
11
|
+
['endDate'],
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* List transactions for the account (Transaction Search API).
|
|
16
|
+
* startDate / endDate are ISO-8601 (e.g. 2024-01-01T00:00:00Z).
|
|
17
|
+
* Date range must be ≤ 31 days per PayPal rules.
|
|
18
|
+
*/
|
|
19
|
+
const paypalTransactionsGet = async (
|
|
20
|
+
credsPayload,
|
|
21
|
+
startDate,
|
|
22
|
+
endDate,
|
|
23
|
+
{
|
|
24
|
+
transactionId,
|
|
25
|
+
transactionStatus,
|
|
26
|
+
transactionType,
|
|
27
|
+
paymentInstrumentType,
|
|
28
|
+
page = 1,
|
|
29
|
+
pageSize = DEFAULT_PAGE_SIZE,
|
|
30
|
+
fields,
|
|
31
|
+
balanceAffectingRecordsOnly,
|
|
32
|
+
storeId,
|
|
33
|
+
terminalId,
|
|
34
|
+
fetchClient = paypalClient,
|
|
35
|
+
} = {},
|
|
36
|
+
) => {
|
|
37
|
+
|
|
38
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
39
|
+
credsPayload,
|
|
40
|
+
startDate,
|
|
41
|
+
endDate,
|
|
42
|
+
});
|
|
43
|
+
if (rejectResponse) {
|
|
44
|
+
return rejectResponse;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const size = Math.min(Number(pageSize) || DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE);
|
|
48
|
+
|
|
49
|
+
const response = await fetchClient.fetch({
|
|
50
|
+
requestPayload: {
|
|
51
|
+
method: 'get',
|
|
52
|
+
url: '/v1/reporting/transactions',
|
|
53
|
+
params: {
|
|
54
|
+
start_date: startDate,
|
|
55
|
+
end_date: endDate,
|
|
56
|
+
page: Number(page) || 1,
|
|
57
|
+
page_size: size,
|
|
58
|
+
...(transactionId ? { transaction_id: transactionId } : {}),
|
|
59
|
+
...(transactionStatus ? { transaction_status: transactionStatus } : {}),
|
|
60
|
+
...(transactionType ? { transaction_type: transactionType } : {}),
|
|
61
|
+
...(paymentInstrumentType
|
|
62
|
+
? { payment_instrument_type: paymentInstrumentType }
|
|
63
|
+
: {}),
|
|
64
|
+
...(fields ? { fields } : {}),
|
|
65
|
+
...(balanceAffectingRecordsOnly !== undefined
|
|
66
|
+
? { balance_affecting_records_only: balanceAffectingRecordsOnly }
|
|
67
|
+
: {}),
|
|
68
|
+
...(storeId ? { store_id: storeId } : {}),
|
|
69
|
+
...(terminalId ? { terminal_id: terminalId } : {}),
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
context: {
|
|
73
|
+
credsPayload,
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
return response;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const funcApiConfig = {
|
|
81
|
+
argsWarden,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
module.exports = {
|
|
85
|
+
paypalTransactionsGet,
|
|
86
|
+
funcApiConfig,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/*
|
|
90
|
+
curl -X POST "http://localhost:8000/paypalTransactionsGet" \
|
|
91
|
+
-H "Content-Type: application/json" \
|
|
92
|
+
-d '{
|
|
93
|
+
"credsPayload": { "credsPath": "paypal" },
|
|
94
|
+
"startDate": "2026-01-01T00:00:00Z",
|
|
95
|
+
"endDate": "2026-01-31T23:59:59Z",
|
|
96
|
+
"options": {
|
|
97
|
+
"page": 1,
|
|
98
|
+
"pageSize": 100
|
|
99
|
+
}
|
|
100
|
+
}'
|
|
101
|
+
*/
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// https://developer.paypal.com/docs/api/identity/v1/#userinfo_get
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { paypalClient } = require('../paypal/paypal.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Show OpenID Connect user profile details for the token subject.
|
|
13
|
+
* Client-credentials tokens may return limited claims; user-consent
|
|
14
|
+
* tokens with openid scopes return the full profile.
|
|
15
|
+
*/
|
|
16
|
+
const paypalUserInfoGet = async (
|
|
17
|
+
credsPayload,
|
|
18
|
+
{
|
|
19
|
+
schema = 'openid',
|
|
20
|
+
fetchClient = paypalClient,
|
|
21
|
+
} = {},
|
|
22
|
+
) => {
|
|
23
|
+
|
|
24
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
25
|
+
credsPayload,
|
|
26
|
+
});
|
|
27
|
+
if (rejectResponse) {
|
|
28
|
+
return rejectResponse;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const response = await fetchClient.fetch({
|
|
32
|
+
requestPayload: {
|
|
33
|
+
method: 'get',
|
|
34
|
+
url: '/v1/identity/openidconnect/userinfo',
|
|
35
|
+
params: {
|
|
36
|
+
schema,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
context: {
|
|
40
|
+
credsPayload,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return response;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const funcApiConfig = {
|
|
48
|
+
argsWarden,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
module.exports = {
|
|
52
|
+
paypalUserInfoGet,
|
|
53
|
+
funcApiConfig,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/*
|
|
57
|
+
curl -X POST "http://localhost:8000/paypalUserInfoGet" \
|
|
58
|
+
-H "Content-Type: application/json" \
|
|
59
|
+
-d '{
|
|
60
|
+
"credsPayload": { "credsPath": "paypal" }
|
|
61
|
+
}'
|
|
62
|
+
*/
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Royal Mail
|
|
2
|
+
|
|
3
|
+
- [Royal Mail APIs](https://www.royalmail.com/business/tools-services/apis)
|
|
4
|
+
- [Tracking API V2](https://developer.royalmail.net/product/175625/api/76888)
|
|
5
|
+
|
|
6
|
+
Royal Mail provides a REST Tracking API V2 at `https://api.royalmail.net`. Server-side tracking uses `X-IBM-Client-Id` and `X-IBM-Client-Secret` credentials issued through the Royal Mail API Developer Portal, plus the `X-Accept-RMG-Terms: yes` header. The API supports summary, history, and proof-of-delivery data for mailpieces.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const { resolveCreds, useBaseUrl } = require('../pipelineSteps');
|
|
2
|
+
const {
|
|
3
|
+
FetchClient,
|
|
4
|
+
fetchClientCommonSteps,
|
|
5
|
+
} = require('../utils');
|
|
6
|
+
const { ROYALMAIL_API_BASE_URL } = require('./royalmail.constants');
|
|
7
|
+
|
|
8
|
+
const useAuthHeaders = async (state) => {
|
|
9
|
+
const { requestPayload, context } = state;
|
|
10
|
+
const { creds } = context;
|
|
11
|
+
const {
|
|
12
|
+
CLIENT_ID,
|
|
13
|
+
CLIENT_SECRET,
|
|
14
|
+
} = creds || {};
|
|
15
|
+
|
|
16
|
+
if (!CLIENT_ID || !CLIENT_SECRET) {
|
|
17
|
+
return {
|
|
18
|
+
breakChain: true,
|
|
19
|
+
response: {
|
|
20
|
+
ok: false,
|
|
21
|
+
error: {
|
|
22
|
+
code: 'ROYALMAIL_AUTH_CONFIG_ERROR',
|
|
23
|
+
message: 'Royal Mail creds require CLIENT_ID and CLIENT_SECRET',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
requestPayload: {
|
|
31
|
+
...requestPayload,
|
|
32
|
+
headers: {
|
|
33
|
+
Accept: 'application/json',
|
|
34
|
+
'X-Accept-RMG-Terms': 'yes',
|
|
35
|
+
'X-IBM-Client-Id': CLIENT_ID,
|
|
36
|
+
'X-IBM-Client-Secret': CLIENT_SECRET,
|
|
37
|
+
...requestPayload.headers,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const royalmailClient = new FetchClient({
|
|
44
|
+
pipeline: [
|
|
45
|
+
resolveCreds,
|
|
46
|
+
useBaseUrl(ROYALMAIL_API_BASE_URL),
|
|
47
|
+
useAuthHeaders,
|
|
48
|
+
'fetch',
|
|
49
|
+
fetchClientCommonSteps.exitEarlyOnNotOk,
|
|
50
|
+
],
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
module.exports = {
|
|
54
|
+
royalmailClient,
|
|
55
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// https://developer.royalmail.net/product/175625/api/76888
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden, objHasAny } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { ROYALMAIL_TRACKING_PATH } = require('./royalmail.constants');
|
|
6
|
+
const { royalmailClient } = require('./royalmail.utils');
|
|
7
|
+
|
|
8
|
+
const trackingIdentifierValidator = (trackingIdentifier) => {
|
|
9
|
+
return objHasAny(trackingIdentifier, [
|
|
10
|
+
'trackingNumber',
|
|
11
|
+
]);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const argsWarden = new ArgsWarden([
|
|
15
|
+
['credsPayload', credsValidator],
|
|
16
|
+
['trackingIdentifier', trackingIdentifierValidator],
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
const royalmailTrackingGet = async (
|
|
20
|
+
credsPayload,
|
|
21
|
+
trackingIdentifier,
|
|
22
|
+
{
|
|
23
|
+
operation = 'summary',
|
|
24
|
+
fetchClient = royalmailClient,
|
|
25
|
+
} = {},
|
|
26
|
+
) => {
|
|
27
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
28
|
+
credsPayload,
|
|
29
|
+
trackingIdentifier,
|
|
30
|
+
});
|
|
31
|
+
if (rejectResponse) {
|
|
32
|
+
return rejectResponse;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const {
|
|
36
|
+
trackingNumber,
|
|
37
|
+
} = trackingIdentifier;
|
|
38
|
+
const operationPath = operation === 'summary'
|
|
39
|
+
? `${ ROYALMAIL_TRACKING_PATH }/summary?mailPieceId=${ encodeURIComponent(trackingNumber) }`
|
|
40
|
+
: `${ ROYALMAIL_TRACKING_PATH }/mailPieces/${ encodeURIComponent(trackingNumber) }/${ operation }`;
|
|
41
|
+
|
|
42
|
+
return fetchClient.fetch({
|
|
43
|
+
requestPayload: {
|
|
44
|
+
url: operationPath,
|
|
45
|
+
},
|
|
46
|
+
context: {
|
|
47
|
+
credsPayload,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const funcApiConfig = {
|
|
53
|
+
argsWarden,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
module.exports = {
|
|
57
|
+
royalmailTrackingGet,
|
|
58
|
+
funcApiConfig,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
curl -X POST "http://localhost:8000/royalmailTrackingGet" \
|
|
63
|
+
-H "Content-Type: application/json" \
|
|
64
|
+
-d '{
|
|
65
|
+
"credsPayload": { "credsPath": "royalmail" },
|
|
66
|
+
"trackingIdentifier": {
|
|
67
|
+
"trackingNumber": "AA123456789GB"
|
|
68
|
+
}
|
|
69
|
+
}'
|
|
70
|
+
*/
|
|
@@ -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,35 @@ 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
|
+
|
|
239
|
+
const shopifyProductFlattenMetafields = (product) => {
|
|
240
|
+
// If property begins with mf, try to flatten to property.value
|
|
241
|
+
const flattenedProduct = { ...product };
|
|
242
|
+
for (const [key, value] of Object.entries(product)) {
|
|
243
|
+
if (key.startsWith('mf')) {
|
|
244
|
+
flattenedProduct[key] = value?.value ?? value;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return flattenedProduct;
|
|
248
|
+
};
|
|
249
|
+
|
|
191
250
|
module.exports = {
|
|
192
251
|
parseShopifyJsonl,
|
|
193
252
|
shopifyClient,
|
|
253
|
+
shopifyStorefrontClient,
|
|
254
|
+
shopifyProductFlattenMetafields,
|
|
194
255
|
};
|
|
@@ -11,7 +11,7 @@ const argsWarden = new ArgsWarden([
|
|
|
11
11
|
['metaobjectInput', metaobjectInputValidator],
|
|
12
12
|
]);
|
|
13
13
|
|
|
14
|
-
const defaultReturnMetaobjectAttrs = 'id handle type updatedAt';
|
|
14
|
+
const defaultReturnMetaobjectAttrs = 'id handle type updatedAt capabilities { publishable { status } }';
|
|
15
15
|
|
|
16
16
|
const shopifyMetaobjectCreate = async (
|
|
17
17
|
credsPayload,
|
|
@@ -59,13 +59,20 @@ module.exports = {
|
|
|
59
59
|
curl -X POST "http://localhost:8000/shopifyMetaobjectCreate" \
|
|
60
60
|
-H "Content-Type: application/json" \
|
|
61
61
|
-d '{
|
|
62
|
-
"credsPayload": { "credsPath": "shopify.
|
|
62
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
63
63
|
"metaobjectInput": {
|
|
64
|
-
"type": "
|
|
65
|
-
"handle": "
|
|
64
|
+
"type": "catalog_filter_blacklist",
|
|
65
|
+
"handle": "collection-blacklist-example",
|
|
66
|
+
"capabilities": {
|
|
67
|
+
"publishable": {
|
|
68
|
+
"status": "ACTIVE"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
66
71
|
"fields": [
|
|
67
|
-
{ "key": "
|
|
68
|
-
{ "key": "
|
|
72
|
+
{ "key": "internal_name", "value": "Blacklist Category > \"Example\"" },
|
|
73
|
+
{ "key": "source_filter", "value": "Category" },
|
|
74
|
+
{ "key": "values", "value": "[\"Example\"]" },
|
|
75
|
+
{ "key": "enabled", "value": "true" }
|
|
69
76
|
]
|
|
70
77
|
}
|
|
71
78
|
}'
|
|
@@ -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
|
+
*/
|