@foxtware/mineral 0.1.9 → 0.1.11
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 +27 -6
- package/AGENTS.md +6 -1
- package/README.md +1 -1
- package/api/bleckmann/.gitkeep +0 -0
- package/api/bleckmann/bleckmann.constants.js +8 -0
- package/api/bleckmann/bleckmann.utils.js +32 -0
- package/api/bleckmann/bleckmannAsnGet.js +52 -0
- package/api/bleckmann/bleckmannAsnsGet.js +65 -0
- package/api/constants.js +2 -1
- package/api/github/github.constants.js +11 -0
- package/api/github/github.utils.js +65 -0
- package/api/github/githubGet.js +144 -0
- package/api/github/githubIssueCreate.js +71 -0
- package/api/github/githubIssueGet.js +65 -0
- package/api/github/githubIssueUpdate.js +71 -0
- package/api/github/githubIssuesGet.js +74 -0
- package/api/github/githubPullRequestCreate.js +74 -0
- package/api/github/githubPullRequestGet.js +65 -0
- package/api/github/githubPullRequestMerge.js +77 -0
- package/api/github/githubPullRequestUpdate.js +72 -0
- package/api/github/githubPullRequestsGet.js +74 -0
- package/api/github/githubRepoCreate.js +80 -0
- package/api/github/githubRepoDelete.js +60 -0
- package/api/github/githubRepoGet.js +61 -0
- package/api/github/githubRepoUpdate.js +68 -0
- package/api/github/githubReposGet.js +69 -0
- package/api/github/githubUserGet.js +64 -0
- package/api/linear/linear.utils.js +9 -14
- package/api/linear/linearIssuesGet.js +9 -9
- package/api/logiwa/logiwa.utils.js +27 -25
- package/api/logiwa/logiwaInventoriesGet.js +5 -3
- package/api/logiwa/logiwaOrderGet.js +4 -2
- package/api/logiwa/logiwaOrdersGet.js +5 -3
- package/api/logiwa/logiwaProductGet.js +4 -2
- package/api/logiwa/logiwaProductsGet.js +5 -3
- package/api/logiwa/logiwaReportGetAvailableToPromise.js +5 -3
- package/api/logiwa/logiwaReportGetInventoryCalculation.js +5 -3
- package/api/logiwa/logiwaReportGetInventorySnapshot.js +5 -3
- package/api/logiwa/logiwaReportGetTotalInventory.js +5 -3
- package/api/logiwa/logiwaWebhookStatusGet.js +4 -2
- package/api/logiwa/logiwaWebhookSubscribe.js +8 -6
- package/api/logiwa/logiwaWebhookUnsubscribe.js +4 -2
- package/api/logiwa/logiwaWebhooksGet.js +4 -2
- package/api/loop/loop.utils.js +9 -15
- package/api/loop/loopGet.js +20 -24
- package/api/loop/loopReturnGet.js +6 -6
- package/api/peoplevox/peoplevox.constants.js +1 -1
- package/api/peoplevox/peoplevox.sessions.js +0 -33
- package/api/peoplevox/peoplevox.utils.js +63 -19
- package/api/peoplevox/peoplevoxGetSingle.js +7 -5
- package/api/peoplevox/peoplevoxOrderEdit.js +7 -5
- package/api/peoplevox/peoplevoxReportGet.js +11 -9
- package/api/pipelineSteps.js +49 -0
- package/api/shopify/shopify.utils.js +93 -22
- package/api/shopify/shopifyBulkMutationDo.js +211 -0
- package/api/shopify/shopifyBulkOperationGet.js +86 -0
- package/api/shopify/shopifyBulkOperationRunMutation.js +83 -0
- package/api/shopify/shopifyBulkOperationRunQuery.js +70 -0
- package/api/shopify/shopifyBulkQueryDo.js +127 -0
- package/api/shopify/shopifyCheckoutAndAccountsConfigurationUpdate.js +79 -0
- package/api/shopify/shopifyCollectionGet.js +6 -6
- package/api/shopify/shopifyCustomerGet.js +6 -6
- package/api/shopify/shopifyGet.js +18 -13
- package/api/shopify/shopifyGetSingle.js +9 -9
- package/api/shopify/shopifyMutationDo.js +6 -6
- package/api/shopify/shopifyOrdersGet.js +11 -11
- package/api/shopify/shopifyStagedUploadCreate.js +96 -0
- package/api/shopify/shopifyTagsAddBulk.js +77 -0
- package/api/slack/slack.utils.js +10 -19
- package/api/slack/slackMessagePost.js +11 -11
- package/api/starshipit/starshipit.constants.js +8 -0
- package/api/starshipit/starshipit.utils.js +71 -0
- package/api/starshipit/starshipitAddressCreate.js +77 -0
- package/api/starshipit/starshipitAddressDelete.js +55 -0
- package/api/starshipit/starshipitAddressUpdate.js +69 -0
- package/api/starshipit/starshipitAddressesGet.js +52 -0
- package/api/starshipit/starshipitGet.js +146 -0
- package/api/starshipit/starshipitOrderDelete.js +102 -0
- package/api/starshipit/starshipitOrderGet.js +74 -0
- package/api/starshipit/starshipitOrderUpdate.js +109 -0
- package/api/starshipit/starshipitOrdersListShipped.js +64 -0
- package/api/starshipit/starshipitProductAdd.js +100 -0
- package/api/starshipit/starshipitProductsDelete.js +57 -0
- package/api/starshipit/starshipitProductsGet.js +49 -0
- package/api/starshipit/starshipitTrackingGet.js +69 -0
- package/api/stripe/_example.js +7 -7
- package/api/stripe/stripe.utils.js +9 -14
- package/api/stripe/stripeCardTokenCreate.js +11 -11
- package/api/stripe/stripeChargeCapture.js +11 -11
- package/api/stripe/stripeChargeCreate.js +11 -11
- package/api/stripe/stripeChargeGet.js +5 -5
- package/api/stripe/stripeChargesGet.js +6 -6
- package/api/stripe/stripeRefundCreate.js +10 -10
- package/api/stripe/stripeRefundGet.js +5 -5
- package/api/stripe/stripeRefundsGet.js +6 -6
- package/api/stripe/stripeTokenGet.js +5 -5
- package/api/stylearcade/stylearcade.constants.js +5 -0
- package/api/stylearcade/stylearcade.utils.js +40 -0
- package/api/stylearcade/stylearcadeDataGet.js +62 -0
- package/api/stylearcade/stylearcadeGet.js +133 -0
- package/api/stylearcade/stylearcadeMetadataGet.js +47 -0
- package/api/threeclicks/threeclicks.constants.js +8 -0
- package/api/threeclicks/threeclicks.utils.js +119 -0
- package/api/threeclicks/threeclicksCollectionsGet.js +40 -0
- package/api/threeclicks/threeclicksGet.js +138 -0
- package/api/threeclicks/threeclicksKeycodeCreate.js +55 -0
- package/api/threeclicks/threeclicksKeycodeGet.js +47 -0
- package/api/threeclicks/threeclicksPurchaseOrderCreate.js +34 -0
- package/api/threeclicks/threeclicksPurchaseOrderCreateBulk.js +34 -0
- package/api/threeclicks/threeclicksPurchaseOrderGet.js +33 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantitiesGet.js +33 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantityCreate.js +34 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantityCreateBulk.js +34 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantityUpdate.js +46 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantityUpdateBulk.js +46 -0
- package/api/threeclicks/threeclicksPurchaseOrderUpdate.js +35 -0
- package/api/threeclicks/threeclicksPurchaseOrdersGet.js +30 -0
- package/api/threeclicks/threeclicksShipmentCreate.js +34 -0
- package/api/threeclicks/threeclicksShipmentGet.js +33 -0
- package/api/threeclicks/threeclicksShipmentOrderAdd.js +38 -0
- package/api/threeclicks/threeclicksShipmentOrderQuantityCreate.js +35 -0
- package/api/threeclicks/threeclicksShipmentQuantityUpdate.js +35 -0
- package/api/threeclicks/threeclicksShipmentStatusUpdate.js +45 -0
- package/api/threeclicks/threeclicksShipmentsGet.js +52 -0
- package/api/threeclicks/threeclicksSignatureCalculate.js +73 -0
- package/api/threeclicks/threeclicksStyleCodesGet.js +46 -0
- package/api/threeclicks/threeclicksStyleColourCreate.js +47 -0
- package/api/threeclicks/threeclicksStyleColourDelete.js +34 -0
- package/api/threeclicks/threeclicksStyleCreate.js +44 -0
- package/api/threeclicks/threeclicksStyleDelete.js +33 -0
- package/api/threeclicks/threeclicksStyleGet.js +43 -0
- package/api/threeclicks/threeclicksStylePriceUpdate.js +70 -0
- package/api/threeclicks/threeclicksStyleUpdate.js +47 -0
- package/api/threeclicks/threeclicksStylesGet.js +45 -0
- package/api/utils.js +85 -117
- package/api/validators.js +1 -1
- package/api/workable/workable.utils.js +8 -13
- package/api/workable/workableGet.js +16 -11
- package/api/workable/workableJobCandidateCreate.js +10 -10
- package/api/workable/workableJobGet.js +5 -5
- package/api/workable/workableJobMembersGet.js +5 -5
- package/api/workable/workableJobStagesGet.js +5 -5
- package/api/yotpo/yotpo.utils.js +17 -22
- package/api/yotpo/yotpoCampaignsGet.js +6 -6
- package/api/yotpo/yotpoCustomerActionRecord.js +7 -7
- package/api/yotpo/yotpoCustomerAnniversaryGet.js +7 -7
- package/api/yotpo/yotpoCustomerAnniversarySet.js +7 -7
- package/api/yotpo/yotpoCustomerBirthdaySet.js +7 -7
- package/api/yotpo/yotpoCustomerGet.js +6 -6
- package/api/yotpo/yotpoCustomerPointsAdjust.js +7 -7
- package/api/yotpo/yotpoCustomerUpsert.js +7 -7
- package/api/yotpo/yotpoCustomersRecentGet.js +6 -6
- package/api/yotpo/yotpoRedemptionCreate.js +7 -7
- package/api/yotpo/yotpoRedemptionOptionsGet.js +6 -6
- package/api/yotpo/yotpoVipTiersGet.js +5 -5
- package/api/youtube/youtube.constants.js +5 -0
- package/api/youtube/youtube.utils.js +77 -0
- package/api/youtube/youtubeChannelVideosGet.js +25 -70
- package/package.json +1 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/queries/bulkOperation
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden, actionSingleOrMultiple } = require('../utils');
|
|
5
|
+
const { shopifyGetSingle } = require('./shopifyGetSingle');
|
|
6
|
+
|
|
7
|
+
const defaultAttrs = `
|
|
8
|
+
id
|
|
9
|
+
status
|
|
10
|
+
type
|
|
11
|
+
objectCount
|
|
12
|
+
url
|
|
13
|
+
errorCode
|
|
14
|
+
`.trim();
|
|
15
|
+
|
|
16
|
+
const argsWarden = new ArgsWarden([
|
|
17
|
+
['credsPayload', credsValidator],
|
|
18
|
+
['bulkOperationId'],
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
const shopifyBulkOperationGetSingle = async (
|
|
22
|
+
credsPayload,
|
|
23
|
+
bulkOperationId,
|
|
24
|
+
{
|
|
25
|
+
apiVersion,
|
|
26
|
+
attrs = defaultAttrs,
|
|
27
|
+
} = {},
|
|
28
|
+
) => {
|
|
29
|
+
return shopifyGetSingle(
|
|
30
|
+
credsPayload,
|
|
31
|
+
'bulkOperation',
|
|
32
|
+
bulkOperationId,
|
|
33
|
+
{
|
|
34
|
+
apiVersion,
|
|
35
|
+
attrs,
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const shopifyBulkOperationGet = async (
|
|
41
|
+
credsPayload,
|
|
42
|
+
bulkOperationId,
|
|
43
|
+
{
|
|
44
|
+
queueRunOptions,
|
|
45
|
+
apiVersion,
|
|
46
|
+
attrs = defaultAttrs,
|
|
47
|
+
} = {},
|
|
48
|
+
) => {
|
|
49
|
+
|
|
50
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
51
|
+
credsPayload,
|
|
52
|
+
bulkOperationId,
|
|
53
|
+
});
|
|
54
|
+
if (rejectResponse) {
|
|
55
|
+
return rejectResponse;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return actionSingleOrMultiple(
|
|
59
|
+
bulkOperationId,
|
|
60
|
+
shopifyBulkOperationGetSingle,
|
|
61
|
+
(bulkOperationIdItem) => ({
|
|
62
|
+
args: [credsPayload, bulkOperationIdItem, { apiVersion, attrs }],
|
|
63
|
+
}),
|
|
64
|
+
{
|
|
65
|
+
...(queueRunOptions ? { queueRunOptions } : {}),
|
|
66
|
+
},
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const funcApiConfig = {
|
|
71
|
+
argsWarden,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
module.exports = {
|
|
75
|
+
shopifyBulkOperationGet,
|
|
76
|
+
funcApiConfig,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/*
|
|
80
|
+
curl -X POST "http://localhost:8000/shopifyBulkOperationGet" \
|
|
81
|
+
-H "Content-Type: application/json" \
|
|
82
|
+
-d '{
|
|
83
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
84
|
+
"bulkOperationId": "3525975375944"
|
|
85
|
+
}'
|
|
86
|
+
*/
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/mutations/bulkOperationRunMutation
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyMutationDo } = require('./shopifyMutationDo');
|
|
6
|
+
|
|
7
|
+
const defaultReturnAttrs = `
|
|
8
|
+
id
|
|
9
|
+
type
|
|
10
|
+
status
|
|
11
|
+
objectCount
|
|
12
|
+
url
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
const argsWarden = new ArgsWarden([
|
|
16
|
+
['credsPayload', credsValidator],
|
|
17
|
+
['mutation'],
|
|
18
|
+
['stagedUploadPath'],
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
const shopifyBulkOperationRunMutation = async (
|
|
22
|
+
credsPayload,
|
|
23
|
+
mutation,
|
|
24
|
+
stagedUploadPath,
|
|
25
|
+
{
|
|
26
|
+
apiVersion,
|
|
27
|
+
returnAttrs = defaultReturnAttrs,
|
|
28
|
+
clientIdentifier,
|
|
29
|
+
} = {},
|
|
30
|
+
) => {
|
|
31
|
+
|
|
32
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
33
|
+
credsPayload,
|
|
34
|
+
mutation,
|
|
35
|
+
stagedUploadPath,
|
|
36
|
+
});
|
|
37
|
+
if (rejectResponse) {
|
|
38
|
+
return rejectResponse;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return shopifyMutationDo(
|
|
42
|
+
credsPayload,
|
|
43
|
+
'bulkOperationRunMutation',
|
|
44
|
+
{
|
|
45
|
+
mutationVariables: {
|
|
46
|
+
mutation: {
|
|
47
|
+
type: 'String!',
|
|
48
|
+
value: mutation,
|
|
49
|
+
},
|
|
50
|
+
stagedUploadPath: {
|
|
51
|
+
type: 'String!',
|
|
52
|
+
value: stagedUploadPath,
|
|
53
|
+
},
|
|
54
|
+
...clientIdentifier && {
|
|
55
|
+
clientIdentifier: {
|
|
56
|
+
type: 'String',
|
|
57
|
+
value: clientIdentifier,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
returnSchema: `bulkOperation { ${ returnAttrs } }`,
|
|
62
|
+
apiVersion,
|
|
63
|
+
},
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const funcApiConfig = {
|
|
68
|
+
argsWarden,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
module.exports = {
|
|
72
|
+
shopifyBulkOperationRunMutation,
|
|
73
|
+
funcApiConfig,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/*
|
|
77
|
+
curl -X POST "http://localhost:8000/shopifyBulkOperationRunMutation" \
|
|
78
|
+
-H "Content-Type: application/json" \
|
|
79
|
+
-d '{
|
|
80
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
81
|
+
"arg": "1234"
|
|
82
|
+
}'
|
|
83
|
+
*/
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/mutations/bulkoperationrunquery
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyMutationDo } = require('./shopifyMutationDo');
|
|
6
|
+
|
|
7
|
+
const defaultReturnAttrs = `
|
|
8
|
+
id
|
|
9
|
+
type
|
|
10
|
+
status
|
|
11
|
+
objectCount
|
|
12
|
+
url
|
|
13
|
+
errorCode
|
|
14
|
+
`.trim();
|
|
15
|
+
|
|
16
|
+
const argsWarden = new ArgsWarden([
|
|
17
|
+
['credsPayload', credsValidator],
|
|
18
|
+
['query'],
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
const shopifyBulkOperationRunQuery = async (
|
|
22
|
+
credsPayload,
|
|
23
|
+
query,
|
|
24
|
+
{
|
|
25
|
+
apiVersion,
|
|
26
|
+
returnAttrs = defaultReturnAttrs,
|
|
27
|
+
} = {},
|
|
28
|
+
) => {
|
|
29
|
+
|
|
30
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
31
|
+
credsPayload,
|
|
32
|
+
query,
|
|
33
|
+
});
|
|
34
|
+
if (rejectResponse) {
|
|
35
|
+
return rejectResponse;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return shopifyMutationDo(
|
|
39
|
+
credsPayload,
|
|
40
|
+
'bulkOperationRunQuery',
|
|
41
|
+
{
|
|
42
|
+
mutationVariables: {
|
|
43
|
+
query: {
|
|
44
|
+
type: 'String!',
|
|
45
|
+
value: query,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
returnSchema: `bulkOperation { ${ returnAttrs } }`,
|
|
49
|
+
apiVersion,
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const funcApiConfig = {
|
|
55
|
+
argsWarden,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
module.exports = {
|
|
59
|
+
shopifyBulkOperationRunQuery,
|
|
60
|
+
funcApiConfig,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/*
|
|
64
|
+
curl -X POST "http://localhost:8000/shopifyBulkOperationRunQuery" \
|
|
65
|
+
-H "Content-Type: application/json" \
|
|
66
|
+
-d '{
|
|
67
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
68
|
+
"query": "{ products { edges { node { id title handle } } } }"
|
|
69
|
+
}'
|
|
70
|
+
*/
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
const { credsValidator } = require('../validators');
|
|
2
|
+
const {
|
|
3
|
+
ArgsWarden,
|
|
4
|
+
customFetch,
|
|
5
|
+
gidToId,
|
|
6
|
+
wait,
|
|
7
|
+
} = require('../utils');
|
|
8
|
+
const { parseShopifyJsonl } = require('./shopify.utils');
|
|
9
|
+
const { shopifyBulkOperationGet } = require('./shopifyBulkOperationGet');
|
|
10
|
+
const { shopifyBulkOperationRunQuery } = require('./shopifyBulkOperationRunQuery');
|
|
11
|
+
|
|
12
|
+
const bulkOpAttrs = `
|
|
13
|
+
id
|
|
14
|
+
status
|
|
15
|
+
type
|
|
16
|
+
objectCount
|
|
17
|
+
url
|
|
18
|
+
errorCode
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
const argsWarden = new ArgsWarden([
|
|
22
|
+
['credsPayload', credsValidator],
|
|
23
|
+
['query'],
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
const shopifyBulkQueryDo = async (
|
|
27
|
+
credsPayload,
|
|
28
|
+
query,
|
|
29
|
+
{
|
|
30
|
+
apiVersion,
|
|
31
|
+
waitForResult = true,
|
|
32
|
+
} = {},
|
|
33
|
+
) => {
|
|
34
|
+
|
|
35
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
36
|
+
credsPayload,
|
|
37
|
+
query,
|
|
38
|
+
});
|
|
39
|
+
if (rejectResponse) {
|
|
40
|
+
return rejectResponse;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const queryRunResponse = await shopifyBulkOperationRunQuery(
|
|
44
|
+
credsPayload,
|
|
45
|
+
query,
|
|
46
|
+
{
|
|
47
|
+
apiVersion,
|
|
48
|
+
returnAttrs: bulkOpAttrs,
|
|
49
|
+
},
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
if (!waitForResult) {
|
|
53
|
+
return queryRunResponse;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!queryRunResponse.ok) {
|
|
57
|
+
return queryRunResponse;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let bulkOperation = queryRunResponse.data.bulkOperation;
|
|
61
|
+
let bulkOperationId = gidToId(bulkOperation.id);
|
|
62
|
+
|
|
63
|
+
while (['CREATED', 'RUNNING'].includes(bulkOperation?.status)) {
|
|
64
|
+
|
|
65
|
+
if (bulkOperation) {
|
|
66
|
+
await wait(5000);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const operationResponse = await shopifyBulkOperationGet(
|
|
70
|
+
credsPayload,
|
|
71
|
+
bulkOperationId,
|
|
72
|
+
{
|
|
73
|
+
apiVersion,
|
|
74
|
+
attrs: bulkOpAttrs,
|
|
75
|
+
},
|
|
76
|
+
);
|
|
77
|
+
if (!operationResponse.ok) {
|
|
78
|
+
return operationResponse;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
bulkOperation = operationResponse.data;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (bulkOperation.status !== 'COMPLETED') {
|
|
85
|
+
return {
|
|
86
|
+
ok: false,
|
|
87
|
+
error: {
|
|
88
|
+
code: 'BULK_OPERATION_FAILED',
|
|
89
|
+
message: `Bulk operation failed with status ${ bulkOperation.status }`,
|
|
90
|
+
details: bulkOperation,
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const resultsResponse = await customFetch(bulkOperation.url);
|
|
96
|
+
if (!resultsResponse.ok) {
|
|
97
|
+
return resultsResponse;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const results = parseShopifyJsonl(resultsResponse.data);
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
ok: true,
|
|
104
|
+
data: results,
|
|
105
|
+
meta: {
|
|
106
|
+
bulkOperation,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const funcApiConfig = {
|
|
112
|
+
argsWarden,
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
module.exports = {
|
|
116
|
+
shopifyBulkQueryDo,
|
|
117
|
+
funcApiConfig,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/*
|
|
121
|
+
curl -X POST "http://localhost:8000/shopifyBulkQueryDo" \
|
|
122
|
+
-H "Content-Type: application/json" \
|
|
123
|
+
-d '{
|
|
124
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
125
|
+
"query": "{ products { edges { node { id title handle } } } }"
|
|
126
|
+
}'
|
|
127
|
+
*/
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/mutations/checkoutAndAccountsConfigurationUpdate
|
|
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
|
+
['configurationId'],
|
|
10
|
+
['updatePayload'],
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
const defaultReturnConfigurationAttrs = 'id name isPublished updatedAt';
|
|
14
|
+
|
|
15
|
+
const shopifyCheckoutAndAccountsConfigurationUpdate = async (
|
|
16
|
+
credsPayload,
|
|
17
|
+
configurationId,
|
|
18
|
+
updatePayload,
|
|
19
|
+
{
|
|
20
|
+
apiVersion,
|
|
21
|
+
returnConfigurationAttrs = defaultReturnConfigurationAttrs,
|
|
22
|
+
} = {},
|
|
23
|
+
) => {
|
|
24
|
+
|
|
25
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
26
|
+
credsPayload,
|
|
27
|
+
configurationId,
|
|
28
|
+
updatePayload,
|
|
29
|
+
});
|
|
30
|
+
if (rejectResponse) {
|
|
31
|
+
return rejectResponse;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return shopifyMutationDo(
|
|
35
|
+
credsPayload,
|
|
36
|
+
'checkoutAndAccountsConfigurationUpdate',
|
|
37
|
+
{
|
|
38
|
+
mutationVariables: {
|
|
39
|
+
id: {
|
|
40
|
+
type: 'ID!',
|
|
41
|
+
value: `gid://shopify/CheckoutAndAccountsConfiguration/${ configurationId }`,
|
|
42
|
+
},
|
|
43
|
+
configuration: {
|
|
44
|
+
type: 'CheckoutAndAccountsConfigurationInput!',
|
|
45
|
+
value: updatePayload,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
returnSchema: `configuration { ${ returnConfigurationAttrs } }`,
|
|
49
|
+
apiVersion,
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const funcApiConfig = {
|
|
55
|
+
argsWarden,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
module.exports = {
|
|
59
|
+
shopifyCheckoutAndAccountsConfigurationUpdate,
|
|
60
|
+
funcApiConfig,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/*
|
|
64
|
+
curl -X POST "http://localhost:8000/shopifyCheckoutAndAccountsConfigurationUpdate" \
|
|
65
|
+
-H "Content-Type: application/json" \
|
|
66
|
+
-d '{
|
|
67
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
68
|
+
"configurationId": "123456789",
|
|
69
|
+
"updatePayload": {
|
|
70
|
+
"branding": {
|
|
71
|
+
"designTokens": {
|
|
72
|
+
"cornerRadius": {
|
|
73
|
+
"large": "LARGE"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}'
|
|
79
|
+
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// https://shopify.dev/docs/api/admin-graphql/latest/queries/collection
|
|
2
2
|
|
|
3
3
|
const { credsValidator } = require('../validators');
|
|
4
|
-
const { ArgsWarden, objHasAny
|
|
4
|
+
const { ArgsWarden, objHasAny } = require('../utils');
|
|
5
5
|
const { shopifyGetSingle } = require('../shopify/shopifyGetSingle');
|
|
6
6
|
const { shopifyClient } = require('../shopify/shopify.utils');
|
|
7
7
|
|
|
@@ -42,8 +42,6 @@ const shopifyCollectionGet = async (
|
|
|
42
42
|
|
|
43
43
|
if (!id) {
|
|
44
44
|
|
|
45
|
-
const creds = await credsFromPayload(credsPayload);
|
|
46
|
-
|
|
47
45
|
const query = `
|
|
48
46
|
query GetCollectionByIdentifier ($identifier: CollectionIdentifierInput!) {
|
|
49
47
|
collection: collectionByIdentifier(identifier: $identifier) {
|
|
@@ -60,10 +58,12 @@ const shopifyCollectionGet = async (
|
|
|
60
58
|
};
|
|
61
59
|
|
|
62
60
|
const response = await shopifyClient.fetch({
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
requestPayload: {
|
|
62
|
+
method: 'post',
|
|
63
|
+
body: { query, variables },
|
|
64
|
+
},
|
|
65
65
|
context: {
|
|
66
|
-
|
|
66
|
+
credsPayload,
|
|
67
67
|
apiVersion,
|
|
68
68
|
resultPath: 'data.collection',
|
|
69
69
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// https://shopify.dev/docs/api/admin-graphql/latest/queries/customer
|
|
2
2
|
|
|
3
3
|
const { credsValidator } = require('../validators');
|
|
4
|
-
const { objHasAny,
|
|
4
|
+
const { objHasAny, ArgsWarden } = require('../utils');
|
|
5
5
|
const { shopifyGetSingle } = require('../shopify/shopifyGetSingle');
|
|
6
6
|
const { shopifyClient } = require('../shopify/shopify.utils');
|
|
7
7
|
|
|
@@ -44,8 +44,6 @@ const shopifyCustomerGet = async (
|
|
|
44
44
|
|
|
45
45
|
if (!customerId) {
|
|
46
46
|
|
|
47
|
-
const creds = await credsFromPayload(credsPayload);
|
|
48
|
-
|
|
49
47
|
const query = `
|
|
50
48
|
query GetCustomerByIdentifier ($identifier: CustomerIdentifierInput!) {
|
|
51
49
|
customer: customerByIdentifier(identifier: $identifier) {
|
|
@@ -63,10 +61,12 @@ const shopifyCustomerGet = async (
|
|
|
63
61
|
};
|
|
64
62
|
|
|
65
63
|
const response = await shopifyClient.fetch({
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
requestPayload: {
|
|
65
|
+
method: 'post',
|
|
66
|
+
body: { query, variables },
|
|
67
|
+
},
|
|
68
68
|
context: {
|
|
69
|
-
|
|
69
|
+
credsPayload,
|
|
70
70
|
apiVersion,
|
|
71
71
|
resultPath: 'data.customer',
|
|
72
72
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { Getter, capitaliseString, ArgsWarden } = require('../utils');
|
|
2
2
|
const { credsValidator } = require('../validators');
|
|
3
3
|
const { shopifyClient } = require('./shopify.utils');
|
|
4
4
|
const { MAX_PER_PAGE } = require('./shopify.constants');
|
|
@@ -11,7 +11,7 @@ const argsWarden = new ArgsWarden([
|
|
|
11
11
|
const shopifyGetPacket = async (
|
|
12
12
|
// options on the main function can become args on the packet get if they have defaults
|
|
13
13
|
// TODO: Consider where defaults should lie
|
|
14
|
-
|
|
14
|
+
credsPayload,
|
|
15
15
|
resource,
|
|
16
16
|
resources,
|
|
17
17
|
attrs,
|
|
@@ -108,9 +108,10 @@ const shopifyGetPacket = async (
|
|
|
108
108
|
};
|
|
109
109
|
|
|
110
110
|
return await shopifyClient.fetch({
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
requestPayload: {
|
|
112
|
+
method: 'post',
|
|
113
|
+
body: {
|
|
114
|
+
query: `
|
|
114
115
|
query Get${ Resources } (
|
|
115
116
|
${ queryTypeDeclaration }
|
|
116
117
|
) {
|
|
@@ -129,10 +130,11 @@ const shopifyGetPacket = async (
|
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
132
|
`,
|
|
132
|
-
|
|
133
|
+
variables,
|
|
134
|
+
},
|
|
133
135
|
},
|
|
134
136
|
context: {
|
|
135
|
-
|
|
137
|
+
credsPayload,
|
|
136
138
|
apiVersion,
|
|
137
139
|
resultPath: `data.${ resources }`,
|
|
138
140
|
},
|
|
@@ -231,14 +233,12 @@ const shopifyGet = async (
|
|
|
231
233
|
return rejectResponse;
|
|
232
234
|
}
|
|
233
235
|
|
|
234
|
-
const creds = await credsFromPayload(credsPayload);
|
|
235
|
-
|
|
236
236
|
const getter = new Getter(
|
|
237
237
|
{
|
|
238
238
|
args: [
|
|
239
|
-
|
|
240
|
-
resource,
|
|
241
|
-
resources,
|
|
239
|
+
credsPayload,
|
|
240
|
+
resource,
|
|
241
|
+
resources,
|
|
242
242
|
attrs,
|
|
243
243
|
],
|
|
244
244
|
options: {
|
|
@@ -276,7 +276,12 @@ const shopifyGet = async (
|
|
|
276
276
|
return getter;
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
-
|
|
279
|
+
const data = await getter.run({ returnAll: true });
|
|
280
|
+
|
|
281
|
+
return {
|
|
282
|
+
ok: true,
|
|
283
|
+
data,
|
|
284
|
+
};
|
|
280
285
|
};
|
|
281
286
|
|
|
282
287
|
const funcApiConfig = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { capitaliseString, ArgsWarden } = require('../utils');
|
|
2
2
|
const { credsValidator } = require('../validators');
|
|
3
3
|
const { shopifyClient } = require('./shopify.utils');
|
|
4
4
|
|
|
@@ -35,8 +35,6 @@ const shopifyGetSingle = async (
|
|
|
35
35
|
return rejectResponse;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
const creds = await credsFromPayload(credsPayload);
|
|
39
|
-
|
|
40
38
|
const Resource = capitaliseString(resource);
|
|
41
39
|
const usesId = !resourcesNotRequiringId.includes(resource);
|
|
42
40
|
|
|
@@ -49,15 +47,17 @@ const shopifyGetSingle = async (
|
|
|
49
47
|
`;
|
|
50
48
|
|
|
51
49
|
const response = await shopifyClient.fetch({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
requestPayload: {
|
|
51
|
+
method: 'post',
|
|
52
|
+
body: {
|
|
53
|
+
query,
|
|
54
|
+
variables: {
|
|
55
|
+
...(usesId ? { id: `gid://shopify/${ gidType || Resource }/${ id }` } : {}),
|
|
56
|
+
},
|
|
57
57
|
},
|
|
58
58
|
},
|
|
59
59
|
context: {
|
|
60
|
-
|
|
60
|
+
credsPayload,
|
|
61
61
|
apiVersion,
|
|
62
62
|
resultPath: `data.${ resource }`,
|
|
63
63
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { logDeep, ArgsWarden } = require('../utils');
|
|
2
2
|
const { credsValidator } = require('../validators');
|
|
3
3
|
const { shopifyClient } = require('./shopify.utils');
|
|
4
4
|
|
|
@@ -27,8 +27,6 @@ const shopifyMutationDo = async (
|
|
|
27
27
|
returnSchema += ' userErrors { field message }';
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const creds = await credsFromPayload(credsPayload);
|
|
31
|
-
|
|
32
30
|
const mutation = `
|
|
33
31
|
mutation ${ mutationName }(${ Object.entries(mutationVariables).map(([name, { type }]) => `$${ name }: ${ type }`).join(', ') }) {
|
|
34
32
|
${ mutationName }(${ Object.keys(mutationVariables).map(name => `${ name }: $${ name }`).join(', ') }) {
|
|
@@ -47,10 +45,12 @@ const shopifyMutationDo = async (
|
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
const response = await shopifyClient.fetch({
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
requestPayload: {
|
|
49
|
+
method: 'post',
|
|
50
|
+
body: { query: mutation, variables },
|
|
51
|
+
},
|
|
52
52
|
context: {
|
|
53
|
-
|
|
53
|
+
credsPayload,
|
|
54
54
|
apiVersion,
|
|
55
55
|
resultPath: `data.${ mutationName }`,
|
|
56
56
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { logDeep, ArgsWarden } = require('../utils');
|
|
2
2
|
const { credsValidator } = require('../validators');
|
|
3
3
|
const { shopifyClient } = require('./shopify.utils');
|
|
4
4
|
|
|
@@ -21,12 +21,11 @@ const shopifyOrdersGet = async (
|
|
|
21
21
|
return rejectResponse;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
const creds = await credsFromPayload(credsPayload);
|
|
25
|
-
|
|
26
24
|
const response = await shopifyClient.fetch({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
requestPayload: {
|
|
26
|
+
method: 'post',
|
|
27
|
+
body: {
|
|
28
|
+
query: `
|
|
30
29
|
query OrdersGet(
|
|
31
30
|
$first: Int!,
|
|
32
31
|
$after: String,
|
|
@@ -49,14 +48,15 @@ const shopifyOrdersGet = async (
|
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
`,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
variables: {
|
|
52
|
+
first,
|
|
53
|
+
after,
|
|
54
|
+
query,
|
|
55
|
+
},
|
|
56
56
|
},
|
|
57
57
|
},
|
|
58
58
|
context: {
|
|
59
|
-
|
|
59
|
+
credsPayload,
|
|
60
60
|
apiVersion,
|
|
61
61
|
resultPath: 'data.orders',
|
|
62
62
|
},
|