@foxtware/mineral 0.1.0
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 +21 -0
- package/AGENTS.md +13 -0
- package/README.md +52 -0
- package/_build_scripts/copyCredsToEnv.js +45 -0
- package/_build_scripts/createNewFunction.js +361 -0
- package/_docs/standard_response_examples.md +67 -0
- package/api/_example.js +45 -0
- package/api/constants.js +3 -0
- package/api/linear/linear.constants.js +5 -0
- package/api/linear/linear.utils.js +43 -0
- package/api/linear/linearIssuesGet.js +106 -0
- package/api/peoplevox/.gitkeep +0 -0
- package/api/peoplevox/_example.js +49 -0
- package/api/peoplevox/peoplevox.constants.js +3 -0
- package/api/peoplevox/peoplevox.utils.js +191 -0
- package/api/peoplevox/peoplevoxAuthGet.js +99 -0
- package/api/peoplevox/peoplevoxGetSingle.js +119 -0
- package/api/peoplevox/peoplevoxOrderEdit.js +82 -0
- package/api/peoplevox/peoplevoxOrderGet.js +60 -0
- package/api/peoplevox/peoplevoxReportGet.js +76 -0
- package/api/shopify/.gitkeep +0 -0
- package/api/shopify/_example.create.js +69 -0
- package/api/shopify/_example.getsingle.js +55 -0
- package/api/shopify/_example.js +45 -0
- package/api/shopify/_example.mutation.js +58 -0
- package/api/shopify/shopify.constants.js +7 -0
- package/api/shopify/shopify.utils.js +123 -0
- package/api/shopify/shopifyCollectionGet.js +109 -0
- package/api/shopify/shopifyCustomerCreate.js +71 -0
- package/api/shopify/shopifyCustomerGet.js +112 -0
- package/api/shopify/shopifyCustomerMarketingConsentUpdateEmail.js +84 -0
- package/api/shopify/shopifyCustomerUpdate.js +75 -0
- package/api/shopify/shopifyCustomersGet.js +50 -0
- package/api/shopify/shopifyGet.js +309 -0
- package/api/shopify/shopifyGetSingle.js +106 -0
- package/api/shopify/shopifyGiftCardCreate.js +95 -0
- package/api/shopify/shopifyGiftCardDeactivate.js +58 -0
- package/api/shopify/shopifyMetafieldsSet.js +100 -0
- package/api/shopify/shopifyMutationDo.js +95 -0
- package/api/shopify/shopifyOrderGet.js +123 -0
- package/api/shopify/shopifyOrdersGet.js +80 -0
- package/api/shopify/shopifyPageDelete.js +59 -0
- package/api/shopify/shopifyPageGet.js +57 -0
- package/api/shopify/shopifyPageUpdate.js +79 -0
- package/api/shopify/shopifyTagsAdd.js +94 -0
- package/api/shopify/shopifyTagsRemove.js +94 -0
- package/api/shopify/shopifyThemeDelete.js +87 -0
- package/api/shopify/shopifyThemeDuplicate.js +70 -0
- package/api/shopify/shopifyThemeGet.js +59 -0
- package/api/shopify/shopifyThemeUpdate.js +71 -0
- package/api/shopify/shopifyThemesGet.js +63 -0
- package/api/utils.js +1166 -0
- package/api/validators.js +12 -0
- package/api/yotpo/yotpo.constants.js +7 -0
- package/api/yotpo/yotpo.utils.js +47 -0
- package/api/yotpo/yotpoCampaignsGet.js +75 -0
- package/api/yotpo/yotpoCustomerActionRecord.js +95 -0
- package/api/yotpo/yotpoCustomerAnniversaryGet.js +60 -0
- package/api/yotpo/yotpoCustomerAnniversarySet.js +78 -0
- package/api/yotpo/yotpoCustomerBirthdaySet.js +91 -0
- package/api/yotpo/yotpoCustomerGet.js +104 -0
- package/api/yotpo/yotpoCustomerPointsAdjust.js +89 -0
- package/api/yotpo/yotpoCustomerUpsert.js +91 -0
- package/api/yotpo/yotpoCustomersRecentGet.js +62 -0
- package/api/yotpo/yotpoRedemptionCreate.js +96 -0
- package/api/yotpo/yotpoRedemptionOptionsGet.js +78 -0
- package/api/yotpo/yotpoVipTiersGet.js +51 -0
- package/api/youtube/youtubeChannelVideosGet.js +249 -0
- package/bin/mineral.js +5 -0
- package/package.json +24 -0
- package/server.js +196 -0
- package/server.utils.js +228 -0
- package/test.js +19 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/queries/page
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyGetSingle } = require('../shopify/shopifyGetSingle');
|
|
6
|
+
|
|
7
|
+
const defaultAttrs = 'id title handle templateSuffix';
|
|
8
|
+
|
|
9
|
+
const argsWarden = new ArgsWarden([
|
|
10
|
+
['credsPayload', credsValidator],
|
|
11
|
+
['pageId', Boolean],
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
const shopifyPageGet = async (
|
|
15
|
+
credsPayload,
|
|
16
|
+
pageId,
|
|
17
|
+
{
|
|
18
|
+
apiVersion,
|
|
19
|
+
attrs = defaultAttrs,
|
|
20
|
+
} = {},
|
|
21
|
+
) => {
|
|
22
|
+
|
|
23
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload, pageId });
|
|
24
|
+
if (rejectResponse) {
|
|
25
|
+
return rejectResponse;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return shopifyGetSingle(
|
|
29
|
+
credsPayload,
|
|
30
|
+
'page',
|
|
31
|
+
pageId,
|
|
32
|
+
{
|
|
33
|
+
apiVersion,
|
|
34
|
+
attrs,
|
|
35
|
+
},
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const funcApiConfig = {
|
|
40
|
+
argsWarden,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
module.exports = {
|
|
44
|
+
shopifyPageGet,
|
|
45
|
+
funcApiConfig,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/*
|
|
49
|
+
curl -X POST "http://localhost:8000/shopifyPageGet" \
|
|
50
|
+
-H "Content-Type: application/json" \
|
|
51
|
+
-d '{
|
|
52
|
+
"credsPayload": {
|
|
53
|
+
"credsPath": "shopify.au"
|
|
54
|
+
},
|
|
55
|
+
"pageId": "104188477512"
|
|
56
|
+
}'
|
|
57
|
+
*/
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/mutations/pageUpdate
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyMutationDo } = require('../shopify/shopifyMutationDo');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['pageId'],
|
|
10
|
+
['updatePayload'],
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
const shopifyPageUpdate = async (
|
|
14
|
+
credsPayload,
|
|
15
|
+
pageId,
|
|
16
|
+
updatePayload,
|
|
17
|
+
/*
|
|
18
|
+
body,
|
|
19
|
+
title,
|
|
20
|
+
handle,
|
|
21
|
+
redirectNewHandle,
|
|
22
|
+
isPublished,
|
|
23
|
+
publishDate,
|
|
24
|
+
metafields,
|
|
25
|
+
templateSuffix,
|
|
26
|
+
*/
|
|
27
|
+
{
|
|
28
|
+
apiVersion,
|
|
29
|
+
returnPageAttrs = 'title handle templateSuffix',
|
|
30
|
+
} = {},
|
|
31
|
+
) => {
|
|
32
|
+
|
|
33
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload, pageId, updatePayload });
|
|
34
|
+
if (rejectResponse) {
|
|
35
|
+
return rejectResponse;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return shopifyMutationDo(
|
|
39
|
+
credsPayload,
|
|
40
|
+
'pageUpdate',
|
|
41
|
+
{
|
|
42
|
+
mutationVariables: {
|
|
43
|
+
id: {
|
|
44
|
+
type: 'ID!',
|
|
45
|
+
value: `gid://shopify/Page/${ pageId }`,
|
|
46
|
+
},
|
|
47
|
+
page: {
|
|
48
|
+
type: 'PageUpdateInput!',
|
|
49
|
+
value: updatePayload,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
returnSchema: `page { ${ returnPageAttrs } }`,
|
|
53
|
+
apiVersion,
|
|
54
|
+
},
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const funcApiConfig = {
|
|
59
|
+
argsWarden,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
module.exports = {
|
|
63
|
+
shopifyPageUpdate,
|
|
64
|
+
funcApiConfig,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/*
|
|
68
|
+
curl -X POST "http://localhost:8000/shopifyPageUpdate" \
|
|
69
|
+
-H "Content-Type: application/json" \
|
|
70
|
+
-d '{
|
|
71
|
+
"credsPayload": {
|
|
72
|
+
"credsPath": "shopify.au"
|
|
73
|
+
},
|
|
74
|
+
"pageId": "104188477512",
|
|
75
|
+
"updatePayload": {
|
|
76
|
+
"templateSuffix": "styleguide"
|
|
77
|
+
}
|
|
78
|
+
}'
|
|
79
|
+
*/
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/mutations/tagsAdd
|
|
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
|
+
['gid'],
|
|
10
|
+
['tags', Array],
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
const defaultAttrs = 'id';
|
|
14
|
+
|
|
15
|
+
const shopifyTagsAddSingle = async (
|
|
16
|
+
credsPayload,
|
|
17
|
+
gid,
|
|
18
|
+
tags,
|
|
19
|
+
{
|
|
20
|
+
apiVersion,
|
|
21
|
+
returnAttrs = defaultAttrs,
|
|
22
|
+
} = {},
|
|
23
|
+
) => {
|
|
24
|
+
|
|
25
|
+
return shopifyMutationDo(
|
|
26
|
+
credsPayload,
|
|
27
|
+
'tagsAdd',
|
|
28
|
+
{
|
|
29
|
+
mutationVariables: {
|
|
30
|
+
id: {
|
|
31
|
+
type: 'ID!',
|
|
32
|
+
value: gid,
|
|
33
|
+
},
|
|
34
|
+
tags: {
|
|
35
|
+
type: '[String!]!',
|
|
36
|
+
value: tags,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
returnSchema: `node { ${ returnAttrs } }`,
|
|
40
|
+
apiVersion,
|
|
41
|
+
},
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const shopifyTagsAdd = async (
|
|
46
|
+
credsPayload,
|
|
47
|
+
gid,
|
|
48
|
+
tags,
|
|
49
|
+
{
|
|
50
|
+
queueRunOptions,
|
|
51
|
+
apiVersion,
|
|
52
|
+
returnAttrs = defaultAttrs,
|
|
53
|
+
} = {},
|
|
54
|
+
) => {
|
|
55
|
+
|
|
56
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
57
|
+
credsPayload,
|
|
58
|
+
gid,
|
|
59
|
+
tags,
|
|
60
|
+
});
|
|
61
|
+
if (rejectResponse) {
|
|
62
|
+
return rejectResponse;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return actionSingleOrMultiple(
|
|
66
|
+
gid,
|
|
67
|
+
shopifyTagsAddSingle,
|
|
68
|
+
(gidItem) => ({
|
|
69
|
+
args: [credsPayload, gidItem, tags, { apiVersion, returnAttrs }],
|
|
70
|
+
}),
|
|
71
|
+
{
|
|
72
|
+
...(queueRunOptions ? { queueRunOptions } : {}),
|
|
73
|
+
},
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const funcApiConfig = {
|
|
78
|
+
argsWarden,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
module.exports = {
|
|
82
|
+
shopifyTagsAdd,
|
|
83
|
+
funcApiConfig,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/*
|
|
87
|
+
curl -X POST "http://localhost:8000/shopifyTagsAdd" \
|
|
88
|
+
-H "Content-Type: application/json" \
|
|
89
|
+
-d '{
|
|
90
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
91
|
+
"gid": "gid://shopify/Product/6981195825224",
|
|
92
|
+
"tags": ["watermelon", "banana"]
|
|
93
|
+
}'
|
|
94
|
+
*/
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/mutations/tagsRemove
|
|
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
|
+
['gid'],
|
|
10
|
+
['tags', Array],
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
const defaultAttrs = 'id';
|
|
14
|
+
|
|
15
|
+
const shopifyTagsRemoveSingle = async (
|
|
16
|
+
credsPayload,
|
|
17
|
+
gid,
|
|
18
|
+
tags,
|
|
19
|
+
{
|
|
20
|
+
apiVersion,
|
|
21
|
+
returnAttrs = defaultAttrs,
|
|
22
|
+
} = {},
|
|
23
|
+
) => {
|
|
24
|
+
|
|
25
|
+
return shopifyMutationDo(
|
|
26
|
+
credsPayload,
|
|
27
|
+
'tagsRemove',
|
|
28
|
+
{
|
|
29
|
+
mutationVariables: {
|
|
30
|
+
id: {
|
|
31
|
+
type: 'ID!',
|
|
32
|
+
value: gid,
|
|
33
|
+
},
|
|
34
|
+
tags: {
|
|
35
|
+
type: '[String!]!',
|
|
36
|
+
value: tags,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
returnSchema: `node { ${ returnAttrs } }`,
|
|
40
|
+
apiVersion,
|
|
41
|
+
},
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const shopifyTagsRemove = async (
|
|
46
|
+
credsPayload,
|
|
47
|
+
gid,
|
|
48
|
+
tags,
|
|
49
|
+
{
|
|
50
|
+
queueRunOptions,
|
|
51
|
+
apiVersion,
|
|
52
|
+
returnAttrs = defaultAttrs,
|
|
53
|
+
} = {},
|
|
54
|
+
) => {
|
|
55
|
+
|
|
56
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
57
|
+
credsPayload,
|
|
58
|
+
gid,
|
|
59
|
+
tags,
|
|
60
|
+
});
|
|
61
|
+
if (rejectResponse) {
|
|
62
|
+
return rejectResponse;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return actionSingleOrMultiple(
|
|
66
|
+
gid,
|
|
67
|
+
shopifyTagsRemoveSingle,
|
|
68
|
+
(gidItem) => ({
|
|
69
|
+
args: [credsPayload, gidItem, tags, { apiVersion, returnAttrs }],
|
|
70
|
+
}),
|
|
71
|
+
{
|
|
72
|
+
...(queueRunOptions ? { queueRunOptions } : {}),
|
|
73
|
+
},
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const funcApiConfig = {
|
|
78
|
+
argsWarden,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
module.exports = {
|
|
82
|
+
shopifyTagsRemove,
|
|
83
|
+
funcApiConfig,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/*
|
|
87
|
+
curl -X POST "http://localhost:8000/shopifyTagsRemove" \
|
|
88
|
+
-H "Content-Type: application/json" \
|
|
89
|
+
-d '{
|
|
90
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
91
|
+
"gid": "gid://shopify/Product/6981195825224",
|
|
92
|
+
"tags": ["watermelon", "banana"]
|
|
93
|
+
}'
|
|
94
|
+
*/
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/mutations/themeDelete
|
|
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
|
+
['themeId'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const shopifyThemeDeleteSingle = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
themeId,
|
|
15
|
+
{
|
|
16
|
+
apiVersion,
|
|
17
|
+
returnSchema = 'deletedThemeId',
|
|
18
|
+
} = {},
|
|
19
|
+
) => {
|
|
20
|
+
|
|
21
|
+
return shopifyMutationDo(
|
|
22
|
+
credsPayload,
|
|
23
|
+
'themeDelete',
|
|
24
|
+
{
|
|
25
|
+
mutationVariables: {
|
|
26
|
+
id: {
|
|
27
|
+
type: 'ID!',
|
|
28
|
+
value: `gid://shopify/OnlineStoreTheme/${ themeId }`,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
returnSchema,
|
|
32
|
+
apiVersion,
|
|
33
|
+
},
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const shopifyThemeDelete = async (
|
|
38
|
+
credsPayload,
|
|
39
|
+
themeId,
|
|
40
|
+
{
|
|
41
|
+
queueRunOptions,
|
|
42
|
+
apiVersion,
|
|
43
|
+
returnSchema = 'deletedThemeId',
|
|
44
|
+
} = {},
|
|
45
|
+
) => {
|
|
46
|
+
|
|
47
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload, themeId });
|
|
48
|
+
if (rejectResponse) {
|
|
49
|
+
return rejectResponse;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return actionSingleOrMultiple(
|
|
53
|
+
themeId,
|
|
54
|
+
shopifyThemeDeleteSingle,
|
|
55
|
+
(themeIdItem) => ({
|
|
56
|
+
args: [credsPayload, themeIdItem, { apiVersion, returnSchema }],
|
|
57
|
+
}),
|
|
58
|
+
{
|
|
59
|
+
...(queueRunOptions ? { queueRunOptions } : {}),
|
|
60
|
+
},
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const funcApiConfig = {
|
|
65
|
+
argsWarden,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
module.exports = {
|
|
69
|
+
shopifyThemeDelete,
|
|
70
|
+
funcApiConfig,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/*
|
|
74
|
+
curl -X POST "http://localhost:8000/shopifyThemeDelete" \
|
|
75
|
+
-H "Content-Type: application/json" \
|
|
76
|
+
-d '{
|
|
77
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
78
|
+
"themeId": "1234567890"
|
|
79
|
+
}'
|
|
80
|
+
|
|
81
|
+
curl -X POST "http://localhost:8000/shopifyThemeDelete" \
|
|
82
|
+
-H "Content-Type: application/json" \
|
|
83
|
+
-d '{
|
|
84
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
85
|
+
"themeId": ["1234567890", "0987654321"]
|
|
86
|
+
}'
|
|
87
|
+
*/
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/mutations/themeDuplicate
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyMutationDo } = require('../shopify/shopifyMutationDo');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['themeId'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const shopifyThemeDuplicate = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
themeId,
|
|
15
|
+
{
|
|
16
|
+
apiVersion,
|
|
17
|
+
name,
|
|
18
|
+
returnThemeAttrs = 'id name role createdAt',
|
|
19
|
+
} = {},
|
|
20
|
+
) => {
|
|
21
|
+
|
|
22
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload, themeId });
|
|
23
|
+
if (rejectResponse) {
|
|
24
|
+
return rejectResponse;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const mutationVariables = {
|
|
28
|
+
id: {
|
|
29
|
+
type: 'ID!',
|
|
30
|
+
value: `gid://shopify/OnlineStoreTheme/${ themeId }`,
|
|
31
|
+
},
|
|
32
|
+
...name && {
|
|
33
|
+
name: {
|
|
34
|
+
type: 'String',
|
|
35
|
+
value: name,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return shopifyMutationDo(
|
|
41
|
+
credsPayload,
|
|
42
|
+
'themeDuplicate',
|
|
43
|
+
{
|
|
44
|
+
mutationVariables,
|
|
45
|
+
returnSchema: `newTheme { ${ returnThemeAttrs } }`,
|
|
46
|
+
apiVersion,
|
|
47
|
+
},
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const funcApiConfig = {
|
|
52
|
+
argsWarden,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
module.exports = {
|
|
56
|
+
shopifyThemeDuplicate,
|
|
57
|
+
funcApiConfig,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/*
|
|
61
|
+
curl -X POST "http://localhost:8000/shopifyThemeDuplicate" \
|
|
62
|
+
-H "Content-Type: application/json" \
|
|
63
|
+
-d '{
|
|
64
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
65
|
+
"themeId": "129840808008",
|
|
66
|
+
"options": {
|
|
67
|
+
"name": "There'\''s no I in theme"
|
|
68
|
+
}
|
|
69
|
+
}'
|
|
70
|
+
*/
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/queries/theme
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden, objHasAny } = require('../utils');
|
|
5
|
+
const { shopifyGetSingle } = require('../shopify/shopifyGetSingle');
|
|
6
|
+
|
|
7
|
+
const defaultAttrs = 'id name role createdAt updatedAt';
|
|
8
|
+
|
|
9
|
+
const argsWarden = new ArgsWarden([
|
|
10
|
+
['credsPayload', credsValidator],
|
|
11
|
+
['themeId'],
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
const shopifyThemeGet = async (
|
|
15
|
+
credsPayload,
|
|
16
|
+
themeId,
|
|
17
|
+
{
|
|
18
|
+
apiVersion,
|
|
19
|
+
attrs = defaultAttrs,
|
|
20
|
+
} = {},
|
|
21
|
+
) => {
|
|
22
|
+
|
|
23
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
24
|
+
credsPayload,
|
|
25
|
+
themeId,
|
|
26
|
+
});
|
|
27
|
+
if (rejectResponse) {
|
|
28
|
+
return rejectResponse;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return shopifyGetSingle(
|
|
32
|
+
credsPayload,
|
|
33
|
+
'theme',
|
|
34
|
+
themeId,
|
|
35
|
+
{
|
|
36
|
+
apiVersion,
|
|
37
|
+
attrs,
|
|
38
|
+
gidType: 'OnlineStoreTheme',
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const funcApiConfig = {
|
|
44
|
+
argsWarden,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
module.exports = {
|
|
48
|
+
shopifyThemeGet,
|
|
49
|
+
funcApiConfig,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/*
|
|
53
|
+
curl -X POST "http://localhost:8000/shopifyThemeGet" \
|
|
54
|
+
-H "Content-Type: application/json" \
|
|
55
|
+
-d '{
|
|
56
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
57
|
+
"themeId": "129840808008"
|
|
58
|
+
}'
|
|
59
|
+
*/
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/mutations/themeUpdate
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyMutationDo } = require('../shopify/shopifyMutationDo');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['themeId'],
|
|
10
|
+
['updatePayload'],
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
const shopifyThemeUpdate = async (
|
|
14
|
+
credsPayload,
|
|
15
|
+
themeId,
|
|
16
|
+
updatePayload,
|
|
17
|
+
{
|
|
18
|
+
apiVersion,
|
|
19
|
+
returnThemeAttrs = 'id name role createdAt updatedAt',
|
|
20
|
+
} = {},
|
|
21
|
+
) => {
|
|
22
|
+
|
|
23
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
24
|
+
credsPayload,
|
|
25
|
+
themeId,
|
|
26
|
+
updatePayload,
|
|
27
|
+
});
|
|
28
|
+
if (rejectResponse) {
|
|
29
|
+
return rejectResponse;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return shopifyMutationDo(
|
|
33
|
+
credsPayload,
|
|
34
|
+
'themeUpdate',
|
|
35
|
+
{
|
|
36
|
+
mutationVariables: {
|
|
37
|
+
id: {
|
|
38
|
+
type: 'ID!',
|
|
39
|
+
value: `gid://shopify/OnlineStoreTheme/${ themeId }`,
|
|
40
|
+
},
|
|
41
|
+
input: {
|
|
42
|
+
type: 'OnlineStoreThemeInput!',
|
|
43
|
+
value: updatePayload,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
returnSchema: `theme { ${ returnThemeAttrs } }`,
|
|
47
|
+
apiVersion,
|
|
48
|
+
},
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const funcApiConfig = {
|
|
53
|
+
argsWarden,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
module.exports = {
|
|
57
|
+
shopifyThemeUpdate,
|
|
58
|
+
funcApiConfig,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
curl -X POST "http://localhost:8000/shopifyThemeUpdate" \
|
|
63
|
+
-H "Content-Type: application/json" \
|
|
64
|
+
-d '{
|
|
65
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
66
|
+
"themeId": "129840808008",
|
|
67
|
+
"updatePayload": {
|
|
68
|
+
"name": "The me theme"
|
|
69
|
+
}
|
|
70
|
+
}'
|
|
71
|
+
*/
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/queries/themes
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyGet } = require('../shopify/shopifyGet');
|
|
6
|
+
|
|
7
|
+
const defaultAttrs = 'id name role createdAt updatedAt';
|
|
8
|
+
|
|
9
|
+
const argsWarden = new ArgsWarden([
|
|
10
|
+
['credsPayload', credsValidator],
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
const shopifyThemesGet = async (
|
|
14
|
+
credsPayload,
|
|
15
|
+
{
|
|
16
|
+
apiVersion,
|
|
17
|
+
attrs = defaultAttrs,
|
|
18
|
+
...getterOptions
|
|
19
|
+
} = {},
|
|
20
|
+
) => {
|
|
21
|
+
|
|
22
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
|
|
23
|
+
if (rejectResponse) {
|
|
24
|
+
return rejectResponse;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return shopifyGet(
|
|
28
|
+
credsPayload,
|
|
29
|
+
'theme',
|
|
30
|
+
{
|
|
31
|
+
apiVersion,
|
|
32
|
+
attrs,
|
|
33
|
+
...getterOptions,
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const funcApiConfig = {
|
|
39
|
+
argsWarden,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
module.exports = {
|
|
43
|
+
shopifyThemesGet,
|
|
44
|
+
funcApiConfig,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/*
|
|
48
|
+
curl -X POST "http://localhost:8000/shopifyThemesGet" \
|
|
49
|
+
-H "Content-Type: application/json" \
|
|
50
|
+
-d '{
|
|
51
|
+
"credsPayload": { "credsPath": "shopify.au" }
|
|
52
|
+
}'
|
|
53
|
+
|
|
54
|
+
curl -X POST "http://localhost:8000/shopifyThemesGet" \
|
|
55
|
+
-H "Content-Type: application/json" \
|
|
56
|
+
-d '{
|
|
57
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
58
|
+
"options": {
|
|
59
|
+
"roles": ["MAIN"],
|
|
60
|
+
"attrs": "id name role"
|
|
61
|
+
}
|
|
62
|
+
}'
|
|
63
|
+
*/
|