@foxtware/mineral 0.1.9 → 0.1.10
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 +18 -24
- package/api/shopify/shopifyBulkMutationDo.js +211 -0
- package/api/shopify/shopifyBulkOperationGet.js +86 -0
- package/api/shopify/shopifyBulkOperationRunMutation.js +83 -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 +90 -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,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,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
|
},
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/mutations/stagedUploadsCreate
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden, ensureArray, everyIfArray } = require('../utils');
|
|
5
|
+
const { shopifyMutationDo } = require('../shopify/shopifyMutationDo');
|
|
6
|
+
|
|
7
|
+
const defaultReturnAttrs = `
|
|
8
|
+
url
|
|
9
|
+
resourceUrl
|
|
10
|
+
parameters {
|
|
11
|
+
name
|
|
12
|
+
value
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
const stagedUploadInputItemValidator = ({
|
|
17
|
+
resource,
|
|
18
|
+
filename,
|
|
19
|
+
mimeType,
|
|
20
|
+
} = {}) => Boolean(resource && filename && mimeType);
|
|
21
|
+
|
|
22
|
+
const argsWarden = new ArgsWarden([
|
|
23
|
+
['credsPayload', credsValidator],
|
|
24
|
+
['stagedUploadInput', (i) => everyIfArray(stagedUploadInputItemValidator, i)],
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
const shopifyStagedUploadCreate = async (
|
|
28
|
+
credsPayload,
|
|
29
|
+
stagedUploadInput,
|
|
30
|
+
{
|
|
31
|
+
apiVersion,
|
|
32
|
+
returnAttrs = defaultReturnAttrs,
|
|
33
|
+
} = {},
|
|
34
|
+
) => {
|
|
35
|
+
|
|
36
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
37
|
+
credsPayload,
|
|
38
|
+
stagedUploadInput,
|
|
39
|
+
});
|
|
40
|
+
if (rejectResponse) {
|
|
41
|
+
return rejectResponse;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const input = ensureArray(stagedUploadInput).map(({
|
|
45
|
+
resource,
|
|
46
|
+
filename,
|
|
47
|
+
mimeType,
|
|
48
|
+
fileSize,
|
|
49
|
+
httpMethod,
|
|
50
|
+
}) => ({
|
|
51
|
+
resource,
|
|
52
|
+
filename,
|
|
53
|
+
mimeType,
|
|
54
|
+
...fileSize && { fileSize: String(fileSize) },
|
|
55
|
+
...httpMethod && { httpMethod },
|
|
56
|
+
}));
|
|
57
|
+
|
|
58
|
+
return shopifyMutationDo(
|
|
59
|
+
credsPayload,
|
|
60
|
+
'stagedUploadsCreate',
|
|
61
|
+
{
|
|
62
|
+
mutationVariables: {
|
|
63
|
+
input: {
|
|
64
|
+
type: '[StagedUploadInput!]!',
|
|
65
|
+
value: input,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
returnSchema: `stagedTargets { ${ returnAttrs } }`,
|
|
69
|
+
apiVersion,
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const funcApiConfig = {
|
|
75
|
+
argsWarden,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
module.exports = {
|
|
79
|
+
shopifyStagedUploadCreate,
|
|
80
|
+
funcApiConfig,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/*
|
|
84
|
+
curl -X POST "http://localhost:8000/shopifyStagedUploadCreate" \
|
|
85
|
+
-H "Content-Type: application/json" \
|
|
86
|
+
-d '{
|
|
87
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
88
|
+
"stagedUploadInput": {
|
|
89
|
+
"resource": "BULK_MUTATION_VARIABLES",
|
|
90
|
+
"filename": "inputs.jsonl",
|
|
91
|
+
"mimeType": "text/jsonl",
|
|
92
|
+
"httpMethod": "POST"
|
|
93
|
+
}
|
|
94
|
+
}'
|
|
95
|
+
}'
|
|
96
|
+
*/
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/mutations/tagsAdd
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyBulkMutationDo } = require('./shopifyBulkMutationDo');
|
|
6
|
+
|
|
7
|
+
const tagsAddBulkMutation = `
|
|
8
|
+
mutation call($id: ID!, $tags: [String!]!) {
|
|
9
|
+
tagsAdd(id: $id, tags: $tags) {
|
|
10
|
+
node {
|
|
11
|
+
id
|
|
12
|
+
}
|
|
13
|
+
userErrors {
|
|
14
|
+
field
|
|
15
|
+
message
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
`.trim();
|
|
20
|
+
|
|
21
|
+
const tagsAddBulkUserErrors = (bulkResult) => {
|
|
22
|
+
return bulkResult?.data?.tagsAdd?.userErrors
|
|
23
|
+
|| bulkResult?.tagsAdd?.userErrors
|
|
24
|
+
|| [];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const argsWarden = new ArgsWarden([
|
|
28
|
+
['credsPayload', credsValidator],
|
|
29
|
+
['gids', Array.isArray],
|
|
30
|
+
['tags', Array.isArray],
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
const shopifyTagsAddBulk = async (
|
|
34
|
+
credsPayload,
|
|
35
|
+
gids,
|
|
36
|
+
tags,
|
|
37
|
+
{
|
|
38
|
+
apiVersion,
|
|
39
|
+
clientIdentifier,
|
|
40
|
+
waitForResult = true,
|
|
41
|
+
} = {},
|
|
42
|
+
) => {
|
|
43
|
+
|
|
44
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
45
|
+
credsPayload,
|
|
46
|
+
gids,
|
|
47
|
+
tags,
|
|
48
|
+
});
|
|
49
|
+
if (rejectResponse) {
|
|
50
|
+
return rejectResponse;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return shopifyBulkMutationDo(
|
|
54
|
+
credsPayload,
|
|
55
|
+
{
|
|
56
|
+
mutation: tagsAddBulkMutation,
|
|
57
|
+
input: {
|
|
58
|
+
data: gids.map((gid) => ({
|
|
59
|
+
id: gid,
|
|
60
|
+
tags,
|
|
61
|
+
})),
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
apiVersion,
|
|
66
|
+
clientIdentifier,
|
|
67
|
+
waitForResult,
|
|
68
|
+
},
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const funcApiConfig = {
|
|
73
|
+
argsWarden,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
module.exports = {
|
|
77
|
+
shopifyTagsAddBulk,
|
|
78
|
+
tagsAddBulkUserErrors,
|
|
79
|
+
funcApiConfig,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/*
|
|
83
|
+
curl -X POST "http://localhost:8000/shopifyTagsAddBulk" \
|
|
84
|
+
-H "Content-Type: application/json" \
|
|
85
|
+
-d '{
|
|
86
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
87
|
+
"gids": ["gid://shopify/Customer/123"],
|
|
88
|
+
"tags": ["aug26_migration"]
|
|
89
|
+
}'
|
|
90
|
+
*/
|
package/api/slack/slack.utils.js
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
const { SLACK_API_BASE_URL } = require('../slack/slack.constants');
|
|
2
|
+
const { resolveCreds, useBaseUrl } = require('../pipelineSteps');
|
|
2
3
|
const {
|
|
3
4
|
FetchClient,
|
|
4
|
-
Chain,
|
|
5
|
-
appendUrlToBase,
|
|
6
5
|
fetchClientCommonSteps,
|
|
7
6
|
} = require('../utils');
|
|
8
7
|
|
|
9
|
-
const
|
|
8
|
+
const useAuthHeaders = async (state) => {
|
|
10
9
|
const { requestPayload, context } = state;
|
|
11
10
|
const { creds } = context;
|
|
12
|
-
const {
|
|
13
|
-
BOT_TOKEN,
|
|
14
|
-
} = creds;
|
|
11
|
+
const { BOT_TOKEN } = creds;
|
|
15
12
|
|
|
16
13
|
return {
|
|
17
14
|
requestPayload: {
|
|
18
15
|
...requestPayload,
|
|
19
16
|
method: requestPayload.method || 'post',
|
|
20
|
-
url: appendUrlToBase(SLACK_API_BASE_URL, requestPayload.url),
|
|
21
17
|
headers: {
|
|
22
|
-
'Content-Type': 'application/json',
|
|
23
18
|
Authorization: `Bearer ${ BOT_TOKEN }`,
|
|
24
19
|
...requestPayload.headers,
|
|
25
20
|
},
|
|
@@ -27,18 +22,14 @@ const addUrlAndAuthHeaders = async (state) => {
|
|
|
27
22
|
};
|
|
28
23
|
};
|
|
29
24
|
|
|
30
|
-
|
|
31
|
-
const slackClientRequestPreparer = new Chain([
|
|
32
|
-
addUrlAndAuthHeaders,
|
|
33
|
-
]);
|
|
34
|
-
|
|
35
|
-
const slackClientResponseInterpreter = new Chain([
|
|
36
|
-
fetchClientCommonSteps.exitEarlyOnNotOk,
|
|
37
|
-
]);
|
|
38
|
-
|
|
39
25
|
const slackClient = new FetchClient({
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
pipeline: [
|
|
27
|
+
resolveCreds,
|
|
28
|
+
useBaseUrl(SLACK_API_BASE_URL),
|
|
29
|
+
useAuthHeaders,
|
|
30
|
+
'fetch',
|
|
31
|
+
fetchClientCommonSteps.exitEarlyOnNotOk,
|
|
32
|
+
],
|
|
42
33
|
});
|
|
43
34
|
|
|
44
35
|
module.exports = {
|