@foxtware/mineral 1.0.4 → 1.0.7
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 +1 -0
- package/_build_scripts/createNewFunction.js +23 -41
- package/api/UTILS.md +1 -1
- package/api/bleckmann/bleckmannPickticketGet.js +4 -2
- package/api/github/githubActionsSecretCreateOrUpdate.js +139 -0
- package/api/github/githubActionsSecretPublicKeyGet.js +59 -0
- package/api/google/googlecalendarEventCreate.js +2 -0
- package/api/linear/linearTeamGet.js +6 -3
- package/api/shopify/shopify.constants.js +25 -0
- package/api/shopify/shopify.utils.js +41 -6
- package/api/shopify/shopifyInventoryQuantitiesSet.js +164 -0
- package/api/shopify/shopifyMutationDo.js +12 -6
- package/api/shopify/shopifyShopGet.js +68 -0
- package/api/shopify/shopifyStorefrontArticleGet.js +86 -0
- package/api/shopify/shopifyStorefrontArticlesGet.js +67 -0
- package/api/shopify/shopifyStorefrontBlogGet.js +110 -0
- package/api/shopify/shopifyStorefrontBlogsGet.js +66 -0
- package/api/shopify/shopifyStorefrontCartAttributesUpdate.js +87 -0
- package/api/shopify/shopifyStorefrontCartBuyerIdentityUpdate.js +87 -0
- package/api/shopify/shopifyStorefrontCartCreate.js +83 -0
- package/api/shopify/shopifyStorefrontCartDeliveryAddressesAdd.js +87 -0
- package/api/shopify/shopifyStorefrontCartDeliveryAddressesRemove.js +87 -0
- package/api/shopify/shopifyStorefrontCartDeliveryAddressesReplace.js +87 -0
- package/api/shopify/shopifyStorefrontCartDeliveryAddressesUpdate.js +87 -0
- package/api/shopify/shopifyStorefrontCartDiscountCodesUpdate.js +87 -0
- package/api/shopify/shopifyStorefrontCartGet.js +100 -0
- package/api/shopify/shopifyStorefrontCartGiftCardCodesAdd.js +87 -0
- package/api/shopify/shopifyStorefrontCartGiftCardCodesRemove.js +87 -0
- package/api/shopify/shopifyStorefrontCartGiftCardCodesUpdate.js +87 -0
- package/api/shopify/shopifyStorefrontCartLinesAdd.js +87 -0
- package/api/shopify/shopifyStorefrontCartLinesRemove.js +87 -0
- package/api/shopify/shopifyStorefrontCartLinesUpdate.js +87 -0
- package/api/shopify/shopifyStorefrontCartMetafieldDelete.js +69 -0
- package/api/shopify/shopifyStorefrontCartMetafieldsSet.js +80 -0
- package/api/shopify/shopifyStorefrontCartNoteUpdate.js +87 -0
- package/api/shopify/shopifyStorefrontCartSelectedDeliveryOptionsUpdate.js +87 -0
- package/api/shopify/shopifyStorefrontCollectionGet.js +92 -0
- package/api/shopify/shopifyStorefrontCollectionsGet.js +66 -0
- package/api/shopify/shopifyStorefrontCustomerAccessTokenCreate.js +75 -0
- package/api/shopify/shopifyStorefrontCustomerAccessTokenCreateWithMultipass.js +72 -0
- package/api/shopify/shopifyStorefrontCustomerAccessTokenDelete.js +67 -0
- package/api/shopify/shopifyStorefrontCustomerAccessTokenRenew.js +72 -0
- package/api/shopify/shopifyStorefrontCustomerActivate.js +98 -0
- package/api/shopify/shopifyStorefrontCustomerActivateByUrl.js +91 -0
- package/api/shopify/shopifyStorefrontCustomerAddressCreate.js +94 -0
- package/api/shopify/shopifyStorefrontCustomerAddressDelete.js +78 -0
- package/api/shopify/shopifyStorefrontCustomerAddressUpdate.js +101 -0
- package/api/shopify/shopifyStorefrontCustomerCreate.js +79 -0
- package/api/shopify/shopifyStorefrontCustomerDefaultAddressUpdate.js +89 -0
- package/api/shopify/shopifyStorefrontCustomerGet.js +92 -0
- package/api/shopify/shopifyStorefrontCustomerRecover.js +64 -0
- package/api/shopify/shopifyStorefrontCustomerReset.js +98 -0
- package/api/shopify/shopifyStorefrontCustomerResetByUrl.js +91 -0
- package/api/shopify/shopifyStorefrontCustomerUpdate.js +93 -0
- package/api/shopify/shopifyStorefrontGet.js +233 -0
- package/api/shopify/shopifyStorefrontLocalizationGet.js +98 -0
- package/api/shopify/shopifyStorefrontLocationsGet.js +70 -0
- package/api/shopify/shopifyStorefrontMenuGet.js +93 -0
- package/api/shopify/shopifyStorefrontMetaobjectGet.js +126 -0
- package/api/shopify/shopifyStorefrontMetaobjectsGet.js +73 -0
- package/api/shopify/shopifyStorefrontMutationDo.js +103 -0
- package/api/shopify/shopifyStorefrontNodeGet.js +90 -0
- package/api/shopify/shopifyStorefrontNodesGet.js +86 -0
- package/api/shopify/shopifyStorefrontPageGet.js +93 -0
- package/api/shopify/shopifyStorefrontPagesGet.js +66 -0
- package/api/shopify/shopifyStorefrontPaymentSettingsGet.js +79 -0
- package/api/shopify/shopifyStorefrontPredictiveSearch.js +138 -0
- package/api/shopify/shopifyStorefrontProductGet.js +94 -0
- package/api/shopify/shopifyStorefrontProductRecommendationsGet.js +112 -0
- package/api/shopify/shopifyStorefrontProductTagsGet.js +80 -0
- package/api/shopify/shopifyStorefrontProductTypesGet.js +80 -0
- package/api/shopify/shopifyStorefrontProductsGet.js +76 -0
- package/api/shopify/shopifyStorefrontPublicApiVersionsGet.js +75 -0
- package/api/shopify/shopifyStorefrontSearch.js +8 -2
- package/api/shopify/shopifyStorefrontShopGet.js +81 -0
- package/api/shopify/shopifyStorefrontShopPayPaymentRequestSessionCreate.js +91 -0
- package/api/shopify/shopifyStorefrontShopPayPaymentRequestSessionSubmit.js +95 -0
- package/api/shopify/shopifyStorefrontSitemapGet.js +98 -0
- package/api/shopify/shopifyStorefrontUrlRedirectsGet.js +67 -0
- package/api/slack/docs.md +4 -0
- package/api/slack/slack.utils.js +36 -2
- package/api/slack/slackMessagePost.js +11 -3
- package/api/slack/slackMessagesSearch.js +81 -0
- package/api/utils.js +47 -10
- package/hosting/deployFromHostingYml.js +9 -21
- package/package.json +3 -1
- package/server.utils.js +24 -15
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/queries/shop
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyGetSingle } = require('../shopify/shopifyGetSingle');
|
|
6
|
+
|
|
7
|
+
const defaultAttrs = `
|
|
8
|
+
id
|
|
9
|
+
name
|
|
10
|
+
myshopifyDomain
|
|
11
|
+
primaryDomain { host url }
|
|
12
|
+
`.trim();
|
|
13
|
+
|
|
14
|
+
const argsWarden = new ArgsWarden([
|
|
15
|
+
['credsPayload', credsValidator],
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
const shopifyShopGet = async (
|
|
19
|
+
credsPayload,
|
|
20
|
+
{
|
|
21
|
+
apiVersion,
|
|
22
|
+
attrs = defaultAttrs,
|
|
23
|
+
} = {},
|
|
24
|
+
) => {
|
|
25
|
+
|
|
26
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
27
|
+
credsPayload,
|
|
28
|
+
});
|
|
29
|
+
if (rejectResponse) {
|
|
30
|
+
return rejectResponse;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return shopifyGetSingle(
|
|
34
|
+
credsPayload,
|
|
35
|
+
'shop',
|
|
36
|
+
null,
|
|
37
|
+
{
|
|
38
|
+
apiVersion,
|
|
39
|
+
attrs,
|
|
40
|
+
},
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const funcApiConfig = {
|
|
45
|
+
argsWarden,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
module.exports = {
|
|
49
|
+
shopifyShopGet,
|
|
50
|
+
funcApiConfig,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/*
|
|
54
|
+
curl -X POST "http://localhost:8000/shopifyShopGet" \
|
|
55
|
+
-H "Content-Type: application/json" \
|
|
56
|
+
-d '{
|
|
57
|
+
"credsPayload": { "credsPath": "shopify.au" }
|
|
58
|
+
}'
|
|
59
|
+
|
|
60
|
+
curl -X POST "http://localhost:8000/shopifyShopGet" \
|
|
61
|
+
-H "Content-Type: application/json" \
|
|
62
|
+
-d '{
|
|
63
|
+
"credsPayload": { "credsPath": "shopify.staging" },
|
|
64
|
+
"options": {
|
|
65
|
+
"attrs": "id name metafield(namespace: \\"custom\\", key: \\"stores_audit\\") { id namespace key type value }"
|
|
66
|
+
}
|
|
67
|
+
}'
|
|
68
|
+
*/
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/queries/article
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const {
|
|
6
|
+
shopifyStorefrontClient,
|
|
7
|
+
buildInContextDirective,
|
|
8
|
+
} = require('./shopify.utils');
|
|
9
|
+
|
|
10
|
+
const defaultAttrs = `
|
|
11
|
+
id
|
|
12
|
+
handle
|
|
13
|
+
title
|
|
14
|
+
content
|
|
15
|
+
excerpt
|
|
16
|
+
publishedAt
|
|
17
|
+
`.trim();
|
|
18
|
+
|
|
19
|
+
const argsWarden = new ArgsWarden([
|
|
20
|
+
['credsPayload', credsValidator],
|
|
21
|
+
['articleId'],
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
const shopifyStorefrontArticleGet = async (
|
|
25
|
+
credsPayload,
|
|
26
|
+
articleId,
|
|
27
|
+
{
|
|
28
|
+
apiVersion,
|
|
29
|
+
attrs = defaultAttrs,
|
|
30
|
+
inContext,
|
|
31
|
+
fetchClient = shopifyStorefrontClient,
|
|
32
|
+
} = {},
|
|
33
|
+
) => {
|
|
34
|
+
|
|
35
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
36
|
+
credsPayload,
|
|
37
|
+
articleId,
|
|
38
|
+
});
|
|
39
|
+
if (rejectResponse) {
|
|
40
|
+
return rejectResponse;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const inContextDirective = buildInContextDirective(inContext);
|
|
44
|
+
const id = articleId.toString().startsWith('gid://')
|
|
45
|
+
? articleId
|
|
46
|
+
: `gid://shopify/Article/${ articleId }`;
|
|
47
|
+
|
|
48
|
+
return fetchClient.fetch({
|
|
49
|
+
requestPayload: {
|
|
50
|
+
method: 'post',
|
|
51
|
+
body: {
|
|
52
|
+
query: `
|
|
53
|
+
query StorefrontArticleById ($id: ID!)${ inContextDirective } {
|
|
54
|
+
article(id: $id) {
|
|
55
|
+
${ attrs }
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
`,
|
|
59
|
+
variables: { id },
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
context: {
|
|
63
|
+
credsPayload,
|
|
64
|
+
apiVersion,
|
|
65
|
+
resultPath: 'data.article',
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const funcApiConfig = {
|
|
71
|
+
argsWarden,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
module.exports = {
|
|
75
|
+
shopifyStorefrontArticleGet,
|
|
76
|
+
funcApiConfig,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/*
|
|
80
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontArticleGet" \
|
|
81
|
+
-H "Content-Type: application/json" \
|
|
82
|
+
-d '{
|
|
83
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
84
|
+
"articleId": "1234567890"
|
|
85
|
+
}'
|
|
86
|
+
*/
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/queries/articles
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { shopifyStorefrontGet, shopifyStorefrontGetter } = require('./shopifyStorefrontGet');
|
|
6
|
+
|
|
7
|
+
const defaultAttrs = `
|
|
8
|
+
id
|
|
9
|
+
handle
|
|
10
|
+
title
|
|
11
|
+
publishedAt
|
|
12
|
+
`.trim();
|
|
13
|
+
|
|
14
|
+
const argsWarden = new ArgsWarden([
|
|
15
|
+
['credsPayload', credsValidator],
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
const shopifyStorefrontArticlesGetInner = async (
|
|
19
|
+
returnGetter,
|
|
20
|
+
credsPayload,
|
|
21
|
+
{
|
|
22
|
+
attrs = defaultAttrs,
|
|
23
|
+
...getterOptions
|
|
24
|
+
} = {},
|
|
25
|
+
) => {
|
|
26
|
+
|
|
27
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
28
|
+
credsPayload,
|
|
29
|
+
});
|
|
30
|
+
if (rejectResponse) {
|
|
31
|
+
return rejectResponse;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const getterArgs = [
|
|
35
|
+
credsPayload,
|
|
36
|
+
'article',
|
|
37
|
+
{
|
|
38
|
+
attrs,
|
|
39
|
+
...getterOptions,
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
return returnGetter
|
|
44
|
+
? shopifyStorefrontGetter(...getterArgs)
|
|
45
|
+
: shopifyStorefrontGet(...getterArgs);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const funcApiConfig = {
|
|
49
|
+
argsWarden,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
module.exports = {
|
|
53
|
+
shopifyStorefrontArticlesGet: (...args) => shopifyStorefrontArticlesGetInner(false, ...args),
|
|
54
|
+
shopifyStorefrontArticlesGetter: (...args) => shopifyStorefrontArticlesGetInner(true, ...args),
|
|
55
|
+
funcApiConfig,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/*
|
|
59
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontArticlesGet" \
|
|
60
|
+
-H "Content-Type: application/json" \
|
|
61
|
+
-d '{
|
|
62
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
63
|
+
"options": {
|
|
64
|
+
"limit": 10
|
|
65
|
+
}
|
|
66
|
+
}'
|
|
67
|
+
*/
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/queries/blog
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden, objHasAny } = require('../utils');
|
|
5
|
+
const {
|
|
6
|
+
shopifyStorefrontClient,
|
|
7
|
+
buildInContextDirective,
|
|
8
|
+
} = require('./shopify.utils');
|
|
9
|
+
|
|
10
|
+
const defaultAttrs = `
|
|
11
|
+
id
|
|
12
|
+
handle
|
|
13
|
+
title
|
|
14
|
+
`.trim();
|
|
15
|
+
|
|
16
|
+
const identifierValidator = (identifier) => objHasAny(identifier, ['id', 'handle']);
|
|
17
|
+
|
|
18
|
+
const argsWarden = new ArgsWarden([
|
|
19
|
+
['credsPayload', credsValidator],
|
|
20
|
+
['blogIdentifier', identifierValidator],
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
const shopifyStorefrontBlogGet = async (
|
|
24
|
+
credsPayload,
|
|
25
|
+
blogIdentifier,
|
|
26
|
+
{
|
|
27
|
+
apiVersion,
|
|
28
|
+
attrs = defaultAttrs,
|
|
29
|
+
inContext,
|
|
30
|
+
fetchClient = shopifyStorefrontClient,
|
|
31
|
+
} = {},
|
|
32
|
+
) => {
|
|
33
|
+
|
|
34
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
35
|
+
credsPayload,
|
|
36
|
+
blogIdentifier,
|
|
37
|
+
});
|
|
38
|
+
if (rejectResponse) {
|
|
39
|
+
return rejectResponse;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const { id, handle } = blogIdentifier;
|
|
43
|
+
const inContextDirective = buildInContextDirective(inContext);
|
|
44
|
+
|
|
45
|
+
if (handle) {
|
|
46
|
+
return fetchClient.fetch({
|
|
47
|
+
requestPayload: {
|
|
48
|
+
method: 'post',
|
|
49
|
+
body: {
|
|
50
|
+
query: `
|
|
51
|
+
query StorefrontBlogByHandle ($handle: String!)${ inContextDirective } {
|
|
52
|
+
blog: blogByHandle(handle: $handle) {
|
|
53
|
+
${ attrs }
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
`,
|
|
57
|
+
variables: { handle },
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
context: {
|
|
61
|
+
credsPayload,
|
|
62
|
+
apiVersion,
|
|
63
|
+
resultPath: 'data.blog',
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const blogGid = id.toString().startsWith('gid://')
|
|
69
|
+
? id
|
|
70
|
+
: `gid://shopify/Blog/${ id }`;
|
|
71
|
+
|
|
72
|
+
return fetchClient.fetch({
|
|
73
|
+
requestPayload: {
|
|
74
|
+
method: 'post',
|
|
75
|
+
body: {
|
|
76
|
+
query: `
|
|
77
|
+
query StorefrontBlogById ($id: ID!)${ inContextDirective } {
|
|
78
|
+
blog(id: $id) {
|
|
79
|
+
${ attrs }
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
`,
|
|
83
|
+
variables: { id: blogGid },
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
context: {
|
|
87
|
+
credsPayload,
|
|
88
|
+
apiVersion,
|
|
89
|
+
resultPath: 'data.blog',
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const funcApiConfig = {
|
|
95
|
+
argsWarden,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
module.exports = {
|
|
99
|
+
shopifyStorefrontBlogGet,
|
|
100
|
+
funcApiConfig,
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/*
|
|
104
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontBlogGet" \
|
|
105
|
+
-H "Content-Type: application/json" \
|
|
106
|
+
-d '{
|
|
107
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
108
|
+
"blogIdentifier": { "handle": "news" }
|
|
109
|
+
}'
|
|
110
|
+
*/
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/queries/blogs
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { shopifyStorefrontGet, shopifyStorefrontGetter } = require('./shopifyStorefrontGet');
|
|
6
|
+
|
|
7
|
+
const defaultAttrs = `
|
|
8
|
+
id
|
|
9
|
+
handle
|
|
10
|
+
title
|
|
11
|
+
`.trim();
|
|
12
|
+
|
|
13
|
+
const argsWarden = new ArgsWarden([
|
|
14
|
+
['credsPayload', credsValidator],
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
const shopifyStorefrontBlogsGetInner = async (
|
|
18
|
+
returnGetter,
|
|
19
|
+
credsPayload,
|
|
20
|
+
{
|
|
21
|
+
attrs = defaultAttrs,
|
|
22
|
+
...getterOptions
|
|
23
|
+
} = {},
|
|
24
|
+
) => {
|
|
25
|
+
|
|
26
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
27
|
+
credsPayload,
|
|
28
|
+
});
|
|
29
|
+
if (rejectResponse) {
|
|
30
|
+
return rejectResponse;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const getterArgs = [
|
|
34
|
+
credsPayload,
|
|
35
|
+
'blog',
|
|
36
|
+
{
|
|
37
|
+
attrs,
|
|
38
|
+
...getterOptions,
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
return returnGetter
|
|
43
|
+
? shopifyStorefrontGetter(...getterArgs)
|
|
44
|
+
: shopifyStorefrontGet(...getterArgs);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const funcApiConfig = {
|
|
48
|
+
argsWarden,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
module.exports = {
|
|
52
|
+
shopifyStorefrontBlogsGet: (...args) => shopifyStorefrontBlogsGetInner(false, ...args),
|
|
53
|
+
shopifyStorefrontBlogsGetter: (...args) => shopifyStorefrontBlogsGetInner(true, ...args),
|
|
54
|
+
funcApiConfig,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/*
|
|
58
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontBlogsGet" \
|
|
59
|
+
-H "Content-Type: application/json" \
|
|
60
|
+
-d '{
|
|
61
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
62
|
+
"options": {
|
|
63
|
+
"limit": 10
|
|
64
|
+
}
|
|
65
|
+
}'
|
|
66
|
+
*/
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/mutations/cartAttributesUpdate
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyStorefrontMutationDo } = require('./shopifyStorefrontMutationDo');
|
|
6
|
+
|
|
7
|
+
const defaultReturnCartAttrs = `
|
|
8
|
+
id
|
|
9
|
+
checkoutUrl
|
|
10
|
+
totalQuantity
|
|
11
|
+
note
|
|
12
|
+
cost {
|
|
13
|
+
totalAmount { amount currencyCode }
|
|
14
|
+
subtotalAmount { amount currencyCode }
|
|
15
|
+
}
|
|
16
|
+
`.trim();
|
|
17
|
+
|
|
18
|
+
const argsWarden = new ArgsWarden([
|
|
19
|
+
['credsPayload', credsValidator],
|
|
20
|
+
['cartId'],
|
|
21
|
+
['attributes'],
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
const shopifyStorefrontCartAttributesUpdate = async (
|
|
25
|
+
credsPayload,
|
|
26
|
+
cartId,
|
|
27
|
+
attributes,
|
|
28
|
+
{
|
|
29
|
+
apiVersion,
|
|
30
|
+
returnCartAttrs = defaultReturnCartAttrs,
|
|
31
|
+
inContext,
|
|
32
|
+
fetchClient,
|
|
33
|
+
} = {},
|
|
34
|
+
) => {
|
|
35
|
+
|
|
36
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
37
|
+
credsPayload,
|
|
38
|
+
cartId,
|
|
39
|
+
attributes
|
|
40
|
+
});
|
|
41
|
+
if (rejectResponse) {
|
|
42
|
+
return rejectResponse;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return shopifyStorefrontMutationDo(
|
|
46
|
+
credsPayload,
|
|
47
|
+
'cartAttributesUpdate',
|
|
48
|
+
{
|
|
49
|
+
mutationVariables: {
|
|
50
|
+
cartId: {
|
|
51
|
+
type: 'ID!',
|
|
52
|
+
value: cartId,
|
|
53
|
+
},
|
|
54
|
+
attributes: {
|
|
55
|
+
type: '[AttributeInput!]!',
|
|
56
|
+
value: attributes,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
returnSchema: `
|
|
60
|
+
cart { ${ returnCartAttrs } }
|
|
61
|
+
warnings { code message }
|
|
62
|
+
`.trim(),
|
|
63
|
+
apiVersion,
|
|
64
|
+
inContext,
|
|
65
|
+
...fetchClient ? { fetchClient } : {},
|
|
66
|
+
},
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const funcApiConfig = {
|
|
71
|
+
argsWarden,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
module.exports = {
|
|
75
|
+
shopifyStorefrontCartAttributesUpdate,
|
|
76
|
+
funcApiConfig,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/*
|
|
80
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontCartAttributesUpdate" \
|
|
81
|
+
-H "Content-Type: application/json" \
|
|
82
|
+
-d '{
|
|
83
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
84
|
+
"cartId": "gid://shopify/Cart/c1-xxx?key=yyy",
|
|
85
|
+
"attributes": [{"key":"gift","value":"true"}],
|
|
86
|
+
}'
|
|
87
|
+
*/
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/mutations/cartBuyerIdentityUpdate
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyStorefrontMutationDo } = require('./shopifyStorefrontMutationDo');
|
|
6
|
+
|
|
7
|
+
const defaultReturnCartAttrs = `
|
|
8
|
+
id
|
|
9
|
+
checkoutUrl
|
|
10
|
+
totalQuantity
|
|
11
|
+
note
|
|
12
|
+
cost {
|
|
13
|
+
totalAmount { amount currencyCode }
|
|
14
|
+
subtotalAmount { amount currencyCode }
|
|
15
|
+
}
|
|
16
|
+
`.trim();
|
|
17
|
+
|
|
18
|
+
const argsWarden = new ArgsWarden([
|
|
19
|
+
['credsPayload', credsValidator],
|
|
20
|
+
['cartId'],
|
|
21
|
+
['buyerIdentity'],
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
const shopifyStorefrontCartBuyerIdentityUpdate = async (
|
|
25
|
+
credsPayload,
|
|
26
|
+
cartId,
|
|
27
|
+
buyerIdentity,
|
|
28
|
+
{
|
|
29
|
+
apiVersion,
|
|
30
|
+
returnCartAttrs = defaultReturnCartAttrs,
|
|
31
|
+
inContext,
|
|
32
|
+
fetchClient,
|
|
33
|
+
} = {},
|
|
34
|
+
) => {
|
|
35
|
+
|
|
36
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
37
|
+
credsPayload,
|
|
38
|
+
cartId,
|
|
39
|
+
buyerIdentity
|
|
40
|
+
});
|
|
41
|
+
if (rejectResponse) {
|
|
42
|
+
return rejectResponse;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return shopifyStorefrontMutationDo(
|
|
46
|
+
credsPayload,
|
|
47
|
+
'cartBuyerIdentityUpdate',
|
|
48
|
+
{
|
|
49
|
+
mutationVariables: {
|
|
50
|
+
cartId: {
|
|
51
|
+
type: 'ID!',
|
|
52
|
+
value: cartId,
|
|
53
|
+
},
|
|
54
|
+
buyerIdentity: {
|
|
55
|
+
type: 'CartBuyerIdentityInput!',
|
|
56
|
+
value: buyerIdentity,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
returnSchema: `
|
|
60
|
+
cart { ${ returnCartAttrs } }
|
|
61
|
+
warnings { code message }
|
|
62
|
+
`.trim(),
|
|
63
|
+
apiVersion,
|
|
64
|
+
inContext,
|
|
65
|
+
...fetchClient ? { fetchClient } : {},
|
|
66
|
+
},
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const funcApiConfig = {
|
|
71
|
+
argsWarden,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
module.exports = {
|
|
75
|
+
shopifyStorefrontCartBuyerIdentityUpdate,
|
|
76
|
+
funcApiConfig,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/*
|
|
80
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontCartBuyerIdentityUpdate" \
|
|
81
|
+
-H "Content-Type: application/json" \
|
|
82
|
+
-d '{
|
|
83
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
84
|
+
"cartId": "gid://shopify/Cart/c1-xxx?key=yyy",
|
|
85
|
+
"buyerIdentity": {"countryCode":"AU"},
|
|
86
|
+
}'
|
|
87
|
+
*/
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/mutations/cartCreate
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyStorefrontMutationDo } = require('./shopifyStorefrontMutationDo');
|
|
6
|
+
|
|
7
|
+
const defaultReturnCartAttrs = `
|
|
8
|
+
id
|
|
9
|
+
checkoutUrl
|
|
10
|
+
totalQuantity
|
|
11
|
+
note
|
|
12
|
+
cost {
|
|
13
|
+
totalAmount { amount currencyCode }
|
|
14
|
+
subtotalAmount { amount currencyCode }
|
|
15
|
+
}
|
|
16
|
+
`.trim();
|
|
17
|
+
|
|
18
|
+
const argsWarden = new ArgsWarden([
|
|
19
|
+
['credsPayload', credsValidator],
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
const shopifyStorefrontCartCreate = async (
|
|
23
|
+
credsPayload,
|
|
24
|
+
{
|
|
25
|
+
apiVersion,
|
|
26
|
+
input,
|
|
27
|
+
returnCartAttrs = defaultReturnCartAttrs,
|
|
28
|
+
inContext,
|
|
29
|
+
fetchClient,
|
|
30
|
+
} = {},
|
|
31
|
+
) => {
|
|
32
|
+
|
|
33
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
34
|
+
credsPayload,
|
|
35
|
+
});
|
|
36
|
+
if (rejectResponse) {
|
|
37
|
+
return rejectResponse;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return shopifyStorefrontMutationDo(
|
|
41
|
+
credsPayload,
|
|
42
|
+
'cartCreate',
|
|
43
|
+
{
|
|
44
|
+
mutationVariables: {
|
|
45
|
+
...input !== undefined && {
|
|
46
|
+
input: {
|
|
47
|
+
type: 'CartInput',
|
|
48
|
+
value: input,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
returnSchema: `
|
|
53
|
+
cart { ${ returnCartAttrs } }
|
|
54
|
+
warnings { code message }
|
|
55
|
+
`.trim(),
|
|
56
|
+
apiVersion,
|
|
57
|
+
inContext,
|
|
58
|
+
...fetchClient ? { fetchClient } : {},
|
|
59
|
+
},
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const funcApiConfig = {
|
|
64
|
+
argsWarden,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
module.exports = {
|
|
68
|
+
shopifyStorefrontCartCreate,
|
|
69
|
+
funcApiConfig,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/*
|
|
73
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontCartCreate" \
|
|
74
|
+
-H "Content-Type: application/json" \
|
|
75
|
+
-d '{
|
|
76
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
77
|
+
"options": {
|
|
78
|
+
"input": {
|
|
79
|
+
"lines": [{ "merchandiseId": "gid://shopify/ProductVariant/123", "quantity": 1 }]
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}'
|
|
83
|
+
*/
|