@foxtware/mineral 1.0.5 → 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 +44 -8
- package/hosting/deployFromHostingYml.js +9 -21
- package/package.json +3 -1
- package/server.utils.js +24 -15
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/queries/metaobject
|
|
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
|
+
type
|
|
14
|
+
updatedAt
|
|
15
|
+
fields {
|
|
16
|
+
key
|
|
17
|
+
value
|
|
18
|
+
type
|
|
19
|
+
}
|
|
20
|
+
`.trim();
|
|
21
|
+
|
|
22
|
+
const identifierValidator = (identifier) => {
|
|
23
|
+
if (!identifier || typeof identifier !== 'object') {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
if (identifier.id) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
return Boolean(identifier.handle?.handle && identifier.handle?.type);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const argsWarden = new ArgsWarden([
|
|
33
|
+
['credsPayload', credsValidator],
|
|
34
|
+
['metaobjectIdentifier', identifierValidator],
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
const shopifyStorefrontMetaobjectGet = async (
|
|
38
|
+
credsPayload,
|
|
39
|
+
metaobjectIdentifier,
|
|
40
|
+
{
|
|
41
|
+
apiVersion,
|
|
42
|
+
attrs = defaultAttrs,
|
|
43
|
+
inContext,
|
|
44
|
+
fetchClient = shopifyStorefrontClient,
|
|
45
|
+
} = {},
|
|
46
|
+
) => {
|
|
47
|
+
|
|
48
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
49
|
+
credsPayload,
|
|
50
|
+
metaobjectIdentifier,
|
|
51
|
+
});
|
|
52
|
+
if (rejectResponse) {
|
|
53
|
+
return rejectResponse;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const { id, handle } = metaobjectIdentifier;
|
|
57
|
+
const inContextDirective = buildInContextDirective(inContext);
|
|
58
|
+
|
|
59
|
+
if (handle) {
|
|
60
|
+
return fetchClient.fetch({
|
|
61
|
+
requestPayload: {
|
|
62
|
+
method: 'post',
|
|
63
|
+
body: {
|
|
64
|
+
query: `
|
|
65
|
+
query StorefrontMetaobjectByHandle ($handle: MetaobjectHandleInput!)${ inContextDirective } {
|
|
66
|
+
metaobject(handle: $handle) {
|
|
67
|
+
${ attrs }
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
`,
|
|
71
|
+
variables: { handle },
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
context: {
|
|
75
|
+
credsPayload,
|
|
76
|
+
apiVersion,
|
|
77
|
+
resultPath: 'data.metaobject',
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const metaobjectGid = id.toString().startsWith('gid://')
|
|
83
|
+
? id
|
|
84
|
+
: `gid://shopify/Metaobject/${ id }`;
|
|
85
|
+
|
|
86
|
+
return fetchClient.fetch({
|
|
87
|
+
requestPayload: {
|
|
88
|
+
method: 'post',
|
|
89
|
+
body: {
|
|
90
|
+
query: `
|
|
91
|
+
query StorefrontMetaobjectById ($id: ID!)${ inContextDirective } {
|
|
92
|
+
metaobject(id: $id) {
|
|
93
|
+
${ attrs }
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
`,
|
|
97
|
+
variables: { id: metaobjectGid },
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
context: {
|
|
101
|
+
credsPayload,
|
|
102
|
+
apiVersion,
|
|
103
|
+
resultPath: 'data.metaobject',
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const funcApiConfig = {
|
|
109
|
+
argsWarden,
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
module.exports = {
|
|
113
|
+
shopifyStorefrontMetaobjectGet,
|
|
114
|
+
funcApiConfig,
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/*
|
|
118
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontMetaobjectGet" \
|
|
119
|
+
-H "Content-Type: application/json" \
|
|
120
|
+
-d '{
|
|
121
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
122
|
+
"metaobjectIdentifier": {
|
|
123
|
+
"handle": { "type": "size_chart", "handle": "mens-tees" }
|
|
124
|
+
}
|
|
125
|
+
}'
|
|
126
|
+
*/
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/queries/metaobjects
|
|
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
|
+
type
|
|
11
|
+
updatedAt
|
|
12
|
+
`.trim();
|
|
13
|
+
|
|
14
|
+
const argsWarden = new ArgsWarden([
|
|
15
|
+
['credsPayload', credsValidator],
|
|
16
|
+
['type'],
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
const shopifyStorefrontMetaobjectsGetInner = async (
|
|
20
|
+
returnGetter,
|
|
21
|
+
credsPayload,
|
|
22
|
+
type,
|
|
23
|
+
{
|
|
24
|
+
attrs = defaultAttrs,
|
|
25
|
+
...getterOptions
|
|
26
|
+
} = {},
|
|
27
|
+
) => {
|
|
28
|
+
|
|
29
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
30
|
+
credsPayload,
|
|
31
|
+
type,
|
|
32
|
+
});
|
|
33
|
+
if (rejectResponse) {
|
|
34
|
+
return rejectResponse;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const getterArgs = [
|
|
38
|
+
credsPayload,
|
|
39
|
+
'metaobject',
|
|
40
|
+
{
|
|
41
|
+
attrs,
|
|
42
|
+
type,
|
|
43
|
+
sortKeyType: 'String',
|
|
44
|
+
...getterOptions,
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
return returnGetter
|
|
49
|
+
? shopifyStorefrontGetter(...getterArgs)
|
|
50
|
+
: shopifyStorefrontGet(...getterArgs);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const funcApiConfig = {
|
|
54
|
+
argsWarden,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
module.exports = {
|
|
58
|
+
shopifyStorefrontMetaobjectsGet: (...args) => shopifyStorefrontMetaobjectsGetInner(false, ...args),
|
|
59
|
+
shopifyStorefrontMetaobjectsGetter: (...args) => shopifyStorefrontMetaobjectsGetInner(true, ...args),
|
|
60
|
+
funcApiConfig,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/*
|
|
64
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontMetaobjectsGet" \
|
|
65
|
+
-H "Content-Type: application/json" \
|
|
66
|
+
-d '{
|
|
67
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
68
|
+
"type": "example_type",
|
|
69
|
+
"options": {
|
|
70
|
+
"limit": 10
|
|
71
|
+
}
|
|
72
|
+
}'
|
|
73
|
+
*/
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
const { ArgsWarden } = require('../utils');
|
|
2
|
+
const { credsValidator } = require('../validators');
|
|
3
|
+
const {
|
|
4
|
+
shopifyStorefrontClient,
|
|
5
|
+
buildInContextDirective,
|
|
6
|
+
} = require('./shopify.utils');
|
|
7
|
+
|
|
8
|
+
const argsWarden = new ArgsWarden([
|
|
9
|
+
['credsPayload', credsValidator],
|
|
10
|
+
['mutationName'],
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
const shopifyStorefrontMutationDo = async (
|
|
14
|
+
credsPayload,
|
|
15
|
+
mutationName,
|
|
16
|
+
{
|
|
17
|
+
mutationVariables = {},
|
|
18
|
+
returnSchema = '',
|
|
19
|
+
apiVersion,
|
|
20
|
+
inContext,
|
|
21
|
+
fetchClient = shopifyStorefrontClient,
|
|
22
|
+
...clientOptions
|
|
23
|
+
} = {},
|
|
24
|
+
) => {
|
|
25
|
+
|
|
26
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
27
|
+
credsPayload,
|
|
28
|
+
mutationName,
|
|
29
|
+
});
|
|
30
|
+
if (rejectResponse) {
|
|
31
|
+
return rejectResponse;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const isCustomerMutation = mutationName.startsWith('customer');
|
|
35
|
+
const errorField = isCustomerMutation ? 'customerUserErrors' : 'userErrors';
|
|
36
|
+
|
|
37
|
+
if (!returnSchema?.includes(errorField)) {
|
|
38
|
+
returnSchema += ` ${ errorField } { field message }`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const argumentEntries = Object.entries(mutationVariables);
|
|
42
|
+
const inContextDirective = buildInContextDirective(inContext);
|
|
43
|
+
const variableDefs = argumentEntries
|
|
44
|
+
.map(([name, { type }]) => `$${ name }: ${ type }`)
|
|
45
|
+
.join(', ');
|
|
46
|
+
const argumentUses = argumentEntries
|
|
47
|
+
.map(([name]) => `${ name }: $${ name }`)
|
|
48
|
+
.join(', ');
|
|
49
|
+
|
|
50
|
+
const mutation = `
|
|
51
|
+
mutation ${ mutationName }${ variableDefs ? `(${ variableDefs })` : '' }${ inContextDirective } {
|
|
52
|
+
${ mutationName }${ argumentUses ? `(${ argumentUses })` : '' } {
|
|
53
|
+
${ returnSchema }
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
const variables = Object.fromEntries(
|
|
59
|
+
argumentEntries.map(([name, { value }]) => [name, value]),
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
return fetchClient.fetch({
|
|
63
|
+
requestPayload: {
|
|
64
|
+
method: 'post',
|
|
65
|
+
body: { query: mutation, variables },
|
|
66
|
+
},
|
|
67
|
+
context: {
|
|
68
|
+
credsPayload,
|
|
69
|
+
apiVersion,
|
|
70
|
+
resultPath: `data.${ mutationName }`,
|
|
71
|
+
},
|
|
72
|
+
...clientOptions,
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const funcApiConfig = {
|
|
77
|
+
argsWarden,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
module.exports = {
|
|
81
|
+
shopifyStorefrontMutationDo,
|
|
82
|
+
funcApiConfig,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/*
|
|
86
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontMutationDo" \
|
|
87
|
+
-H "Content-Type: application/json" \
|
|
88
|
+
-d '{
|
|
89
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
90
|
+
"mutationName": "cartCreate",
|
|
91
|
+
"options": {
|
|
92
|
+
"mutationVariables": {
|
|
93
|
+
"input": {
|
|
94
|
+
"type": "CartInput",
|
|
95
|
+
"value": {
|
|
96
|
+
"lines": [{ "merchandiseId": "gid://shopify/ProductVariant/123", "quantity": 1 }]
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"returnSchema": "cart { id checkoutUrl }"
|
|
101
|
+
}
|
|
102
|
+
}'
|
|
103
|
+
*/
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/queries/node
|
|
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
|
+
... on Product {
|
|
13
|
+
handle
|
|
14
|
+
title
|
|
15
|
+
}
|
|
16
|
+
... on Collection {
|
|
17
|
+
handle
|
|
18
|
+
title
|
|
19
|
+
}
|
|
20
|
+
... on Page {
|
|
21
|
+
handle
|
|
22
|
+
title
|
|
23
|
+
}
|
|
24
|
+
`.trim();
|
|
25
|
+
|
|
26
|
+
const argsWarden = new ArgsWarden([
|
|
27
|
+
['credsPayload', credsValidator],
|
|
28
|
+
['gid'],
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
const shopifyStorefrontNodeGet = async (
|
|
32
|
+
credsPayload,
|
|
33
|
+
gid,
|
|
34
|
+
{
|
|
35
|
+
apiVersion,
|
|
36
|
+
attrs = defaultAttrs,
|
|
37
|
+
inContext,
|
|
38
|
+
fetchClient = shopifyStorefrontClient,
|
|
39
|
+
} = {},
|
|
40
|
+
) => {
|
|
41
|
+
|
|
42
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
43
|
+
credsPayload,
|
|
44
|
+
gid,
|
|
45
|
+
});
|
|
46
|
+
if (rejectResponse) {
|
|
47
|
+
return rejectResponse;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const inContextDirective = buildInContextDirective(inContext);
|
|
51
|
+
|
|
52
|
+
return fetchClient.fetch({
|
|
53
|
+
requestPayload: {
|
|
54
|
+
method: 'post',
|
|
55
|
+
body: {
|
|
56
|
+
query: `
|
|
57
|
+
query StorefrontNode ($id: ID!)${ inContextDirective } {
|
|
58
|
+
node(id: $id) {
|
|
59
|
+
${ attrs }
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
`,
|
|
63
|
+
variables: { id: gid },
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
context: {
|
|
67
|
+
credsPayload,
|
|
68
|
+
apiVersion,
|
|
69
|
+
resultPath: 'data.node',
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const funcApiConfig = {
|
|
75
|
+
argsWarden,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
module.exports = {
|
|
79
|
+
shopifyStorefrontNodeGet,
|
|
80
|
+
funcApiConfig,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/*
|
|
84
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontNodeGet" \
|
|
85
|
+
-H "Content-Type: application/json" \
|
|
86
|
+
-d '{
|
|
87
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
88
|
+
"gid": "gid://shopify/Product/123"
|
|
89
|
+
}'
|
|
90
|
+
*/
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/queries/nodes
|
|
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
|
+
... on Product {
|
|
13
|
+
handle
|
|
14
|
+
title
|
|
15
|
+
}
|
|
16
|
+
... on Collection {
|
|
17
|
+
handle
|
|
18
|
+
title
|
|
19
|
+
}
|
|
20
|
+
`.trim();
|
|
21
|
+
|
|
22
|
+
const argsWarden = new ArgsWarden([
|
|
23
|
+
['credsPayload', credsValidator],
|
|
24
|
+
['gids'],
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
const shopifyStorefrontNodesGet = async (
|
|
28
|
+
credsPayload,
|
|
29
|
+
gids,
|
|
30
|
+
{
|
|
31
|
+
apiVersion,
|
|
32
|
+
attrs = defaultAttrs,
|
|
33
|
+
inContext,
|
|
34
|
+
fetchClient = shopifyStorefrontClient,
|
|
35
|
+
} = {},
|
|
36
|
+
) => {
|
|
37
|
+
|
|
38
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
39
|
+
credsPayload,
|
|
40
|
+
gids,
|
|
41
|
+
});
|
|
42
|
+
if (rejectResponse) {
|
|
43
|
+
return rejectResponse;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const inContextDirective = buildInContextDirective(inContext);
|
|
47
|
+
|
|
48
|
+
return fetchClient.fetch({
|
|
49
|
+
requestPayload: {
|
|
50
|
+
method: 'post',
|
|
51
|
+
body: {
|
|
52
|
+
query: `
|
|
53
|
+
query StorefrontNodes ($ids: [ID!]!)${ inContextDirective } {
|
|
54
|
+
nodes(ids: $ids) {
|
|
55
|
+
${ attrs }
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
`,
|
|
59
|
+
variables: { ids: gids },
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
context: {
|
|
63
|
+
credsPayload,
|
|
64
|
+
apiVersion,
|
|
65
|
+
resultPath: 'data.nodes',
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const funcApiConfig = {
|
|
71
|
+
argsWarden,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
module.exports = {
|
|
75
|
+
shopifyStorefrontNodesGet,
|
|
76
|
+
funcApiConfig,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/*
|
|
80
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontNodesGet" \
|
|
81
|
+
-H "Content-Type: application/json" \
|
|
82
|
+
-d '{
|
|
83
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
84
|
+
"gids": ["gid://shopify/Product/123", "gid://shopify/Collection/456"]
|
|
85
|
+
}'
|
|
86
|
+
*/
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/queries/page
|
|
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
|
+
body
|
|
15
|
+
bodySummary
|
|
16
|
+
`.trim();
|
|
17
|
+
|
|
18
|
+
const identifierValidator = (identifier) => objHasAny(identifier, ['id', 'handle']);
|
|
19
|
+
|
|
20
|
+
const argsWarden = new ArgsWarden([
|
|
21
|
+
['credsPayload', credsValidator],
|
|
22
|
+
['pageIdentifier', identifierValidator],
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
const shopifyStorefrontPageGet = async (
|
|
26
|
+
credsPayload,
|
|
27
|
+
pageIdentifier,
|
|
28
|
+
{
|
|
29
|
+
apiVersion,
|
|
30
|
+
attrs = defaultAttrs,
|
|
31
|
+
inContext,
|
|
32
|
+
fetchClient = shopifyStorefrontClient,
|
|
33
|
+
} = {},
|
|
34
|
+
) => {
|
|
35
|
+
|
|
36
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
37
|
+
credsPayload,
|
|
38
|
+
pageIdentifier,
|
|
39
|
+
});
|
|
40
|
+
if (rejectResponse) {
|
|
41
|
+
return rejectResponse;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const { id, handle } = pageIdentifier;
|
|
45
|
+
const inContextDirective = buildInContextDirective(inContext);
|
|
46
|
+
|
|
47
|
+
const useHandle = Boolean(handle);
|
|
48
|
+
const queryName = useHandle ? 'StorefrontPageByHandle' : 'StorefrontPageById';
|
|
49
|
+
const argDecl = useHandle ? '$handle: String!' : '$id: ID!';
|
|
50
|
+
const argUse = useHandle ? 'handle: $handle' : 'id: $id';
|
|
51
|
+
const variables = useHandle
|
|
52
|
+
? { handle }
|
|
53
|
+
: { id: id.toString().startsWith('gid://') ? id : `gid://shopify/Page/${ id }` };
|
|
54
|
+
|
|
55
|
+
return fetchClient.fetch({
|
|
56
|
+
requestPayload: {
|
|
57
|
+
method: 'post',
|
|
58
|
+
body: {
|
|
59
|
+
query: `
|
|
60
|
+
query ${ queryName } (${ argDecl })${ inContextDirective } {
|
|
61
|
+
page(${ argUse }) {
|
|
62
|
+
${ attrs }
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
`,
|
|
66
|
+
variables,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
context: {
|
|
70
|
+
credsPayload,
|
|
71
|
+
apiVersion,
|
|
72
|
+
resultPath: 'data.page',
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const funcApiConfig = {
|
|
78
|
+
argsWarden,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
module.exports = {
|
|
82
|
+
shopifyStorefrontPageGet,
|
|
83
|
+
funcApiConfig,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/*
|
|
87
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontPageGet" \
|
|
88
|
+
-H "Content-Type: application/json" \
|
|
89
|
+
-d '{
|
|
90
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
91
|
+
"pageIdentifier": { "handle": "example" }
|
|
92
|
+
}'
|
|
93
|
+
*/
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/queries/pages
|
|
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 shopifyStorefrontPagesGetInner = 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
|
+
'page',
|
|
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
|
+
shopifyStorefrontPagesGet: (...args) => shopifyStorefrontPagesGetInner(false, ...args),
|
|
53
|
+
shopifyStorefrontPagesGetter: (...args) => shopifyStorefrontPagesGetInner(true, ...args),
|
|
54
|
+
funcApiConfig,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/*
|
|
58
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontPagesGet" \
|
|
59
|
+
-H "Content-Type: application/json" \
|
|
60
|
+
-d '{
|
|
61
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
62
|
+
"options": {
|
|
63
|
+
"limit": 10
|
|
64
|
+
}
|
|
65
|
+
}'
|
|
66
|
+
*/
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/queries/paymentSettings
|
|
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
|
+
acceptedCardBrands
|
|
12
|
+
cardVaultUrl
|
|
13
|
+
countryCode
|
|
14
|
+
currencyCode
|
|
15
|
+
enabledPresentmentCurrencies
|
|
16
|
+
shopifyPaymentsAccountId
|
|
17
|
+
supportedDigitalWallets
|
|
18
|
+
`.trim();
|
|
19
|
+
|
|
20
|
+
const argsWarden = new ArgsWarden([
|
|
21
|
+
['credsPayload', credsValidator],
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
const shopifyStorefrontPaymentSettingsGet = async (
|
|
25
|
+
credsPayload,
|
|
26
|
+
{
|
|
27
|
+
apiVersion,
|
|
28
|
+
attrs = defaultAttrs,
|
|
29
|
+
inContext,
|
|
30
|
+
fetchClient = shopifyStorefrontClient,
|
|
31
|
+
} = {},
|
|
32
|
+
) => {
|
|
33
|
+
|
|
34
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
35
|
+
credsPayload,
|
|
36
|
+
});
|
|
37
|
+
if (rejectResponse) {
|
|
38
|
+
return rejectResponse;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const inContextDirective = buildInContextDirective(inContext);
|
|
42
|
+
|
|
43
|
+
return fetchClient.fetch({
|
|
44
|
+
requestPayload: {
|
|
45
|
+
method: 'post',
|
|
46
|
+
body: {
|
|
47
|
+
query: `
|
|
48
|
+
query StorefrontPaymentSettings${ inContextDirective } {
|
|
49
|
+
paymentSettings {
|
|
50
|
+
${ attrs }
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
`,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
context: {
|
|
57
|
+
credsPayload,
|
|
58
|
+
apiVersion,
|
|
59
|
+
resultPath: 'data.paymentSettings',
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const funcApiConfig = {
|
|
65
|
+
argsWarden,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
module.exports = {
|
|
69
|
+
shopifyStorefrontPaymentSettingsGet,
|
|
70
|
+
funcApiConfig,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/*
|
|
74
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontPaymentSettingsGet" \
|
|
75
|
+
-H "Content-Type: application/json" \
|
|
76
|
+
-d '{
|
|
77
|
+
"credsPayload": { "credsPath": "shopify.au" }
|
|
78
|
+
}'
|
|
79
|
+
*/
|