@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,92 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/queries/collection
|
|
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
|
+
description
|
|
15
|
+
`.trim();
|
|
16
|
+
|
|
17
|
+
const identifierValidator = (identifier) => objHasAny(identifier, ['id', 'handle']);
|
|
18
|
+
|
|
19
|
+
const argsWarden = new ArgsWarden([
|
|
20
|
+
['credsPayload', credsValidator],
|
|
21
|
+
['collectionIdentifier', identifierValidator],
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
const shopifyStorefrontCollectionGet = async (
|
|
25
|
+
credsPayload,
|
|
26
|
+
collectionIdentifier,
|
|
27
|
+
{
|
|
28
|
+
apiVersion,
|
|
29
|
+
attrs = defaultAttrs,
|
|
30
|
+
inContext,
|
|
31
|
+
fetchClient = shopifyStorefrontClient,
|
|
32
|
+
} = {},
|
|
33
|
+
) => {
|
|
34
|
+
|
|
35
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
36
|
+
credsPayload,
|
|
37
|
+
collectionIdentifier,
|
|
38
|
+
});
|
|
39
|
+
if (rejectResponse) {
|
|
40
|
+
return rejectResponse;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const { id, handle } = collectionIdentifier;
|
|
44
|
+
const inContextDirective = buildInContextDirective(inContext);
|
|
45
|
+
|
|
46
|
+
const useHandle = Boolean(handle);
|
|
47
|
+
const queryName = useHandle ? 'StorefrontCollectionByHandle' : 'StorefrontCollectionById';
|
|
48
|
+
const argDecl = useHandle ? '$handle: String!' : '$id: ID!';
|
|
49
|
+
const argUse = useHandle ? 'handle: $handle' : 'id: $id';
|
|
50
|
+
const variables = useHandle
|
|
51
|
+
? { handle }
|
|
52
|
+
: { id: id.toString().startsWith('gid://') ? id : `gid://shopify/Collection/${ id }` };
|
|
53
|
+
|
|
54
|
+
return fetchClient.fetch({
|
|
55
|
+
requestPayload: {
|
|
56
|
+
method: 'post',
|
|
57
|
+
body: {
|
|
58
|
+
query: `
|
|
59
|
+
query ${ queryName } (${ argDecl })${ inContextDirective } {
|
|
60
|
+
collection(${ argUse }) {
|
|
61
|
+
${ attrs }
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
`,
|
|
65
|
+
variables,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
context: {
|
|
69
|
+
credsPayload,
|
|
70
|
+
apiVersion,
|
|
71
|
+
resultPath: 'data.collection',
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const funcApiConfig = {
|
|
77
|
+
argsWarden,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
module.exports = {
|
|
81
|
+
shopifyStorefrontCollectionGet,
|
|
82
|
+
funcApiConfig,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/*
|
|
86
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontCollectionGet" \
|
|
87
|
+
-H "Content-Type: application/json" \
|
|
88
|
+
-d '{
|
|
89
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
90
|
+
"collectionIdentifier": { "handle": "example" }
|
|
91
|
+
}'
|
|
92
|
+
*/
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/queries/collections
|
|
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 shopifyStorefrontCollectionsGetInner = 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
|
+
'collection',
|
|
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
|
+
shopifyStorefrontCollectionsGet: (...args) => shopifyStorefrontCollectionsGetInner(false, ...args),
|
|
53
|
+
shopifyStorefrontCollectionsGetter: (...args) => shopifyStorefrontCollectionsGetInner(true, ...args),
|
|
54
|
+
funcApiConfig,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/*
|
|
58
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontCollectionsGet" \
|
|
59
|
+
-H "Content-Type: application/json" \
|
|
60
|
+
-d '{
|
|
61
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
62
|
+
"options": {
|
|
63
|
+
"limit": 10
|
|
64
|
+
}
|
|
65
|
+
}'
|
|
66
|
+
*/
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/mutations/customerAccessTokenCreate
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyStorefrontMutationDo } = require('./shopifyStorefrontMutationDo');
|
|
6
|
+
|
|
7
|
+
const defaultReturnAccessTokenAttrs = `
|
|
8
|
+
accessToken
|
|
9
|
+
expiresAt
|
|
10
|
+
`.trim();
|
|
11
|
+
|
|
12
|
+
const argsWarden = new ArgsWarden([
|
|
13
|
+
['credsPayload', credsValidator],
|
|
14
|
+
['input'],
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
const shopifyStorefrontCustomerAccessTokenCreate = async (
|
|
18
|
+
credsPayload,
|
|
19
|
+
input,
|
|
20
|
+
{
|
|
21
|
+
apiVersion,
|
|
22
|
+
returnAccessTokenAttrs = defaultReturnAccessTokenAttrs,
|
|
23
|
+
inContext,
|
|
24
|
+
fetchClient,
|
|
25
|
+
} = {},
|
|
26
|
+
) => {
|
|
27
|
+
|
|
28
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
29
|
+
credsPayload,
|
|
30
|
+
input,
|
|
31
|
+
});
|
|
32
|
+
if (rejectResponse) {
|
|
33
|
+
return rejectResponse;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return shopifyStorefrontMutationDo(
|
|
37
|
+
credsPayload,
|
|
38
|
+
'customerAccessTokenCreate',
|
|
39
|
+
{
|
|
40
|
+
mutationVariables: {
|
|
41
|
+
input: {
|
|
42
|
+
type: 'CustomerAccessTokenCreateInput!',
|
|
43
|
+
value: input,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
returnSchema: `
|
|
47
|
+
customerAccessToken { ${ returnAccessTokenAttrs } }
|
|
48
|
+
`.trim(),
|
|
49
|
+
apiVersion,
|
|
50
|
+
inContext,
|
|
51
|
+
...fetchClient ? { fetchClient } : {},
|
|
52
|
+
},
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const funcApiConfig = {
|
|
57
|
+
argsWarden,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
module.exports = {
|
|
61
|
+
shopifyStorefrontCustomerAccessTokenCreate,
|
|
62
|
+
funcApiConfig,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/*
|
|
66
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontCustomerAccessTokenCreate" \
|
|
67
|
+
-H "Content-Type: application/json" \
|
|
68
|
+
-d '{
|
|
69
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
70
|
+
"input": {
|
|
71
|
+
"email": "buyer@example.com",
|
|
72
|
+
"password": "SecurePass123"
|
|
73
|
+
}
|
|
74
|
+
}'
|
|
75
|
+
*/
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/mutations/customerAccessTokenCreateWithMultipass
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyStorefrontMutationDo } = require('./shopifyStorefrontMutationDo');
|
|
6
|
+
|
|
7
|
+
const defaultReturnAccessTokenAttrs = `
|
|
8
|
+
accessToken
|
|
9
|
+
expiresAt
|
|
10
|
+
`.trim();
|
|
11
|
+
|
|
12
|
+
const argsWarden = new ArgsWarden([
|
|
13
|
+
['credsPayload', credsValidator],
|
|
14
|
+
['multipassToken'],
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
const shopifyStorefrontCustomerAccessTokenCreateWithMultipass = async (
|
|
18
|
+
credsPayload,
|
|
19
|
+
multipassToken,
|
|
20
|
+
{
|
|
21
|
+
apiVersion,
|
|
22
|
+
returnAccessTokenAttrs = defaultReturnAccessTokenAttrs,
|
|
23
|
+
inContext,
|
|
24
|
+
fetchClient,
|
|
25
|
+
} = {},
|
|
26
|
+
) => {
|
|
27
|
+
|
|
28
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
29
|
+
credsPayload,
|
|
30
|
+
multipassToken,
|
|
31
|
+
});
|
|
32
|
+
if (rejectResponse) {
|
|
33
|
+
return rejectResponse;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return shopifyStorefrontMutationDo(
|
|
37
|
+
credsPayload,
|
|
38
|
+
'customerAccessTokenCreateWithMultipass',
|
|
39
|
+
{
|
|
40
|
+
mutationVariables: {
|
|
41
|
+
multipassToken: {
|
|
42
|
+
type: 'String!',
|
|
43
|
+
value: multipassToken,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
returnSchema: `
|
|
47
|
+
customerAccessToken { ${ returnAccessTokenAttrs } }
|
|
48
|
+
`.trim(),
|
|
49
|
+
apiVersion,
|
|
50
|
+
inContext,
|
|
51
|
+
...fetchClient ? { fetchClient } : {},
|
|
52
|
+
},
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const funcApiConfig = {
|
|
57
|
+
argsWarden,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
module.exports = {
|
|
61
|
+
shopifyStorefrontCustomerAccessTokenCreateWithMultipass,
|
|
62
|
+
funcApiConfig,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/*
|
|
66
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontCustomerAccessTokenCreateWithMultipass" \
|
|
67
|
+
-H "Content-Type: application/json" \
|
|
68
|
+
-d '{
|
|
69
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
70
|
+
"multipassToken": "multipass-token-here"
|
|
71
|
+
}'
|
|
72
|
+
*/
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/mutations/customerAccessTokenDelete
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyStorefrontMutationDo } = require('./shopifyStorefrontMutationDo');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['customerAccessToken'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const shopifyStorefrontCustomerAccessTokenDelete = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
customerAccessToken,
|
|
15
|
+
{
|
|
16
|
+
apiVersion,
|
|
17
|
+
inContext,
|
|
18
|
+
fetchClient,
|
|
19
|
+
} = {},
|
|
20
|
+
) => {
|
|
21
|
+
|
|
22
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
23
|
+
credsPayload,
|
|
24
|
+
customerAccessToken,
|
|
25
|
+
});
|
|
26
|
+
if (rejectResponse) {
|
|
27
|
+
return rejectResponse;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return shopifyStorefrontMutationDo(
|
|
31
|
+
credsPayload,
|
|
32
|
+
'customerAccessTokenDelete',
|
|
33
|
+
{
|
|
34
|
+
mutationVariables: {
|
|
35
|
+
customerAccessToken: {
|
|
36
|
+
type: 'String!',
|
|
37
|
+
value: customerAccessToken,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
returnSchema: `
|
|
41
|
+
deletedAccessToken
|
|
42
|
+
deletedCustomerAccessTokenId
|
|
43
|
+
`.trim(),
|
|
44
|
+
apiVersion,
|
|
45
|
+
inContext,
|
|
46
|
+
...fetchClient ? { fetchClient } : {},
|
|
47
|
+
},
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const funcApiConfig = {
|
|
52
|
+
argsWarden,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
module.exports = {
|
|
56
|
+
shopifyStorefrontCustomerAccessTokenDelete,
|
|
57
|
+
funcApiConfig,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/*
|
|
61
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontCustomerAccessTokenDelete" \
|
|
62
|
+
-H "Content-Type: application/json" \
|
|
63
|
+
-d '{
|
|
64
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
65
|
+
"customerAccessToken": "shcat_xxx"
|
|
66
|
+
}'
|
|
67
|
+
*/
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/mutations/customerAccessTokenRenew
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyStorefrontMutationDo } = require('./shopifyStorefrontMutationDo');
|
|
6
|
+
|
|
7
|
+
const defaultReturnAccessTokenAttrs = `
|
|
8
|
+
accessToken
|
|
9
|
+
expiresAt
|
|
10
|
+
`.trim();
|
|
11
|
+
|
|
12
|
+
const argsWarden = new ArgsWarden([
|
|
13
|
+
['credsPayload', credsValidator],
|
|
14
|
+
['customerAccessToken'],
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
const shopifyStorefrontCustomerAccessTokenRenew = async (
|
|
18
|
+
credsPayload,
|
|
19
|
+
customerAccessToken,
|
|
20
|
+
{
|
|
21
|
+
apiVersion,
|
|
22
|
+
returnAccessTokenAttrs = defaultReturnAccessTokenAttrs,
|
|
23
|
+
inContext,
|
|
24
|
+
fetchClient,
|
|
25
|
+
} = {},
|
|
26
|
+
) => {
|
|
27
|
+
|
|
28
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
29
|
+
credsPayload,
|
|
30
|
+
customerAccessToken,
|
|
31
|
+
});
|
|
32
|
+
if (rejectResponse) {
|
|
33
|
+
return rejectResponse;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return shopifyStorefrontMutationDo(
|
|
37
|
+
credsPayload,
|
|
38
|
+
'customerAccessTokenRenew',
|
|
39
|
+
{
|
|
40
|
+
mutationVariables: {
|
|
41
|
+
customerAccessToken: {
|
|
42
|
+
type: 'String!',
|
|
43
|
+
value: customerAccessToken,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
returnSchema: `
|
|
47
|
+
customerAccessToken { ${ returnAccessTokenAttrs } }
|
|
48
|
+
`.trim(),
|
|
49
|
+
apiVersion,
|
|
50
|
+
inContext,
|
|
51
|
+
...fetchClient ? { fetchClient } : {},
|
|
52
|
+
},
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const funcApiConfig = {
|
|
57
|
+
argsWarden,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
module.exports = {
|
|
61
|
+
shopifyStorefrontCustomerAccessTokenRenew,
|
|
62
|
+
funcApiConfig,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/*
|
|
66
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontCustomerAccessTokenRenew" \
|
|
67
|
+
-H "Content-Type: application/json" \
|
|
68
|
+
-d '{
|
|
69
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
70
|
+
"customerAccessToken": "shcat_xxx"
|
|
71
|
+
}'
|
|
72
|
+
*/
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/mutations/customerActivate
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyStorefrontMutationDo } = require('./shopifyStorefrontMutationDo');
|
|
6
|
+
|
|
7
|
+
const defaultReturnCustomerAttrs = `
|
|
8
|
+
id
|
|
9
|
+
email
|
|
10
|
+
firstName
|
|
11
|
+
lastName
|
|
12
|
+
displayName
|
|
13
|
+
phone
|
|
14
|
+
`.trim();
|
|
15
|
+
|
|
16
|
+
const defaultReturnAccessTokenAttrs = `
|
|
17
|
+
accessToken
|
|
18
|
+
expiresAt
|
|
19
|
+
`.trim();
|
|
20
|
+
|
|
21
|
+
const argsWarden = new ArgsWarden([
|
|
22
|
+
['credsPayload', credsValidator],
|
|
23
|
+
['customerId'],
|
|
24
|
+
['input'],
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
const shopifyStorefrontCustomerActivate = async (
|
|
28
|
+
credsPayload,
|
|
29
|
+
customerId,
|
|
30
|
+
input,
|
|
31
|
+
{
|
|
32
|
+
apiVersion,
|
|
33
|
+
returnCustomerAttrs = defaultReturnCustomerAttrs,
|
|
34
|
+
returnAccessTokenAttrs = defaultReturnAccessTokenAttrs,
|
|
35
|
+
inContext,
|
|
36
|
+
fetchClient,
|
|
37
|
+
} = {},
|
|
38
|
+
) => {
|
|
39
|
+
|
|
40
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
41
|
+
credsPayload,
|
|
42
|
+
customerId,
|
|
43
|
+
input,
|
|
44
|
+
});
|
|
45
|
+
if (rejectResponse) {
|
|
46
|
+
return rejectResponse;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const id = customerId.toString().startsWith('gid://')
|
|
50
|
+
? customerId
|
|
51
|
+
: `gid://shopify/Customer/${ customerId }`;
|
|
52
|
+
|
|
53
|
+
return shopifyStorefrontMutationDo(
|
|
54
|
+
credsPayload,
|
|
55
|
+
'customerActivate',
|
|
56
|
+
{
|
|
57
|
+
mutationVariables: {
|
|
58
|
+
id: {
|
|
59
|
+
type: 'ID!',
|
|
60
|
+
value: id,
|
|
61
|
+
},
|
|
62
|
+
input: {
|
|
63
|
+
type: 'CustomerActivateInput!',
|
|
64
|
+
value: input,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
returnSchema: `
|
|
68
|
+
customer { ${ returnCustomerAttrs } }
|
|
69
|
+
customerAccessToken { ${ returnAccessTokenAttrs } }
|
|
70
|
+
`.trim(),
|
|
71
|
+
apiVersion,
|
|
72
|
+
inContext,
|
|
73
|
+
...fetchClient ? { fetchClient } : {},
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const funcApiConfig = {
|
|
79
|
+
argsWarden,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
module.exports = {
|
|
83
|
+
shopifyStorefrontCustomerActivate,
|
|
84
|
+
funcApiConfig,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/*
|
|
88
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontCustomerActivate" \
|
|
89
|
+
-H "Content-Type: application/json" \
|
|
90
|
+
-d '{
|
|
91
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
92
|
+
"customerId": "1234567890",
|
|
93
|
+
"input": {
|
|
94
|
+
"activationToken": "token",
|
|
95
|
+
"password": "SecurePass123"
|
|
96
|
+
}
|
|
97
|
+
}'
|
|
98
|
+
*/
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/mutations/customerActivateByUrl
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyStorefrontMutationDo } = require('./shopifyStorefrontMutationDo');
|
|
6
|
+
|
|
7
|
+
const defaultReturnCustomerAttrs = `
|
|
8
|
+
id
|
|
9
|
+
email
|
|
10
|
+
firstName
|
|
11
|
+
lastName
|
|
12
|
+
displayName
|
|
13
|
+
phone
|
|
14
|
+
`.trim();
|
|
15
|
+
|
|
16
|
+
const defaultReturnAccessTokenAttrs = `
|
|
17
|
+
accessToken
|
|
18
|
+
expiresAt
|
|
19
|
+
`.trim();
|
|
20
|
+
|
|
21
|
+
const argsWarden = new ArgsWarden([
|
|
22
|
+
['credsPayload', credsValidator],
|
|
23
|
+
['activationUrl'],
|
|
24
|
+
['password'],
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
const shopifyStorefrontCustomerActivateByUrl = async (
|
|
28
|
+
credsPayload,
|
|
29
|
+
activationUrl,
|
|
30
|
+
password,
|
|
31
|
+
{
|
|
32
|
+
apiVersion,
|
|
33
|
+
returnCustomerAttrs = defaultReturnCustomerAttrs,
|
|
34
|
+
returnAccessTokenAttrs = defaultReturnAccessTokenAttrs,
|
|
35
|
+
inContext,
|
|
36
|
+
fetchClient,
|
|
37
|
+
} = {},
|
|
38
|
+
) => {
|
|
39
|
+
|
|
40
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
41
|
+
credsPayload,
|
|
42
|
+
activationUrl,
|
|
43
|
+
password,
|
|
44
|
+
});
|
|
45
|
+
if (rejectResponse) {
|
|
46
|
+
return rejectResponse;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return shopifyStorefrontMutationDo(
|
|
50
|
+
credsPayload,
|
|
51
|
+
'customerActivateByUrl',
|
|
52
|
+
{
|
|
53
|
+
mutationVariables: {
|
|
54
|
+
activationUrl: {
|
|
55
|
+
type: 'URL!',
|
|
56
|
+
value: activationUrl,
|
|
57
|
+
},
|
|
58
|
+
password: {
|
|
59
|
+
type: 'String!',
|
|
60
|
+
value: password,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
returnSchema: `
|
|
64
|
+
customer { ${ returnCustomerAttrs } }
|
|
65
|
+
customerAccessToken { ${ returnAccessTokenAttrs } }
|
|
66
|
+
`.trim(),
|
|
67
|
+
apiVersion,
|
|
68
|
+
inContext,
|
|
69
|
+
...fetchClient ? { fetchClient } : {},
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const funcApiConfig = {
|
|
75
|
+
argsWarden,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
module.exports = {
|
|
79
|
+
shopifyStorefrontCustomerActivateByUrl,
|
|
80
|
+
funcApiConfig,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/*
|
|
84
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontCustomerActivateByUrl" \
|
|
85
|
+
-H "Content-Type: application/json" \
|
|
86
|
+
-d '{
|
|
87
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
88
|
+
"activationUrl": "https://example.com/account/activate/xxx/yyy",
|
|
89
|
+
"password": "SecurePass123"
|
|
90
|
+
}'
|
|
91
|
+
*/
|