@foxtware/mineral 1.0.4 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.creds.yml.sample +1 -0
- package/_build_scripts/createNewFunction.js +23 -41
- package/api/UTILS.md +1 -1
- package/api/bleckmann/bleckmannPickticketGet.js +4 -2
- package/api/github/githubActionsSecretCreateOrUpdate.js +139 -0
- package/api/github/githubActionsSecretPublicKeyGet.js +59 -0
- package/api/google/googlecalendarEventCreate.js +2 -0
- package/api/linear/linearTeamGet.js +6 -3
- package/api/shopify/shopify.constants.js +25 -0
- package/api/shopify/shopify.utils.js +41 -6
- package/api/shopify/shopifyInventoryQuantitiesSet.js +164 -0
- package/api/shopify/shopifyMutationDo.js +12 -6
- package/api/shopify/shopifyShopGet.js +68 -0
- package/api/shopify/shopifyStorefrontArticleGet.js +86 -0
- package/api/shopify/shopifyStorefrontArticlesGet.js +67 -0
- package/api/shopify/shopifyStorefrontBlogGet.js +110 -0
- package/api/shopify/shopifyStorefrontBlogsGet.js +66 -0
- package/api/shopify/shopifyStorefrontCartAttributesUpdate.js +87 -0
- package/api/shopify/shopifyStorefrontCartBuyerIdentityUpdate.js +87 -0
- package/api/shopify/shopifyStorefrontCartCreate.js +83 -0
- package/api/shopify/shopifyStorefrontCartDeliveryAddressesAdd.js +87 -0
- package/api/shopify/shopifyStorefrontCartDeliveryAddressesRemove.js +87 -0
- package/api/shopify/shopifyStorefrontCartDeliveryAddressesReplace.js +87 -0
- package/api/shopify/shopifyStorefrontCartDeliveryAddressesUpdate.js +87 -0
- package/api/shopify/shopifyStorefrontCartDiscountCodesUpdate.js +87 -0
- package/api/shopify/shopifyStorefrontCartGet.js +100 -0
- package/api/shopify/shopifyStorefrontCartGiftCardCodesAdd.js +87 -0
- package/api/shopify/shopifyStorefrontCartGiftCardCodesRemove.js +87 -0
- package/api/shopify/shopifyStorefrontCartGiftCardCodesUpdate.js +87 -0
- package/api/shopify/shopifyStorefrontCartLinesAdd.js +87 -0
- package/api/shopify/shopifyStorefrontCartLinesRemove.js +87 -0
- package/api/shopify/shopifyStorefrontCartLinesUpdate.js +87 -0
- package/api/shopify/shopifyStorefrontCartMetafieldDelete.js +69 -0
- package/api/shopify/shopifyStorefrontCartMetafieldsSet.js +80 -0
- package/api/shopify/shopifyStorefrontCartNoteUpdate.js +87 -0
- package/api/shopify/shopifyStorefrontCartSelectedDeliveryOptionsUpdate.js +87 -0
- package/api/shopify/shopifyStorefrontCollectionGet.js +92 -0
- package/api/shopify/shopifyStorefrontCollectionsGet.js +66 -0
- package/api/shopify/shopifyStorefrontCustomerAccessTokenCreate.js +75 -0
- package/api/shopify/shopifyStorefrontCustomerAccessTokenCreateWithMultipass.js +72 -0
- package/api/shopify/shopifyStorefrontCustomerAccessTokenDelete.js +67 -0
- package/api/shopify/shopifyStorefrontCustomerAccessTokenRenew.js +72 -0
- package/api/shopify/shopifyStorefrontCustomerActivate.js +98 -0
- package/api/shopify/shopifyStorefrontCustomerActivateByUrl.js +91 -0
- package/api/shopify/shopifyStorefrontCustomerAddressCreate.js +94 -0
- package/api/shopify/shopifyStorefrontCustomerAddressDelete.js +78 -0
- package/api/shopify/shopifyStorefrontCustomerAddressUpdate.js +101 -0
- package/api/shopify/shopifyStorefrontCustomerCreate.js +79 -0
- package/api/shopify/shopifyStorefrontCustomerDefaultAddressUpdate.js +89 -0
- package/api/shopify/shopifyStorefrontCustomerGet.js +92 -0
- package/api/shopify/shopifyStorefrontCustomerRecover.js +64 -0
- package/api/shopify/shopifyStorefrontCustomerReset.js +98 -0
- package/api/shopify/shopifyStorefrontCustomerResetByUrl.js +91 -0
- package/api/shopify/shopifyStorefrontCustomerUpdate.js +93 -0
- package/api/shopify/shopifyStorefrontGet.js +233 -0
- package/api/shopify/shopifyStorefrontLocalizationGet.js +98 -0
- package/api/shopify/shopifyStorefrontLocationsGet.js +70 -0
- package/api/shopify/shopifyStorefrontMenuGet.js +93 -0
- package/api/shopify/shopifyStorefrontMetaobjectGet.js +126 -0
- package/api/shopify/shopifyStorefrontMetaobjectsGet.js +73 -0
- package/api/shopify/shopifyStorefrontMutationDo.js +103 -0
- package/api/shopify/shopifyStorefrontNodeGet.js +90 -0
- package/api/shopify/shopifyStorefrontNodesGet.js +86 -0
- package/api/shopify/shopifyStorefrontPageGet.js +93 -0
- package/api/shopify/shopifyStorefrontPagesGet.js +66 -0
- package/api/shopify/shopifyStorefrontPaymentSettingsGet.js +79 -0
- package/api/shopify/shopifyStorefrontPredictiveSearch.js +138 -0
- package/api/shopify/shopifyStorefrontProductGet.js +94 -0
- package/api/shopify/shopifyStorefrontProductRecommendationsGet.js +112 -0
- package/api/shopify/shopifyStorefrontProductTagsGet.js +80 -0
- package/api/shopify/shopifyStorefrontProductTypesGet.js +80 -0
- package/api/shopify/shopifyStorefrontProductsGet.js +76 -0
- package/api/shopify/shopifyStorefrontPublicApiVersionsGet.js +75 -0
- package/api/shopify/shopifyStorefrontSearch.js +8 -2
- package/api/shopify/shopifyStorefrontShopGet.js +81 -0
- package/api/shopify/shopifyStorefrontShopPayPaymentRequestSessionCreate.js +91 -0
- package/api/shopify/shopifyStorefrontShopPayPaymentRequestSessionSubmit.js +95 -0
- package/api/shopify/shopifyStorefrontSitemapGet.js +98 -0
- package/api/shopify/shopifyStorefrontUrlRedirectsGet.js +67 -0
- package/api/slack/docs.md +4 -0
- package/api/slack/slack.utils.js +36 -2
- package/api/slack/slackMessagePost.js +11 -3
- package/api/slack/slackMessagesSearch.js +81 -0
- package/api/utils.js +47 -10
- package/hosting/deployFromHostingYml.js +9 -21
- package/package.json +3 -1
- package/server.utils.js +24 -15
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/queries/shop
|
|
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
|
+
name
|
|
13
|
+
description
|
|
14
|
+
primaryDomain { url host }
|
|
15
|
+
moneyFormat
|
|
16
|
+
paymentSettings {
|
|
17
|
+
currencyCode
|
|
18
|
+
acceptedCardBrands
|
|
19
|
+
}
|
|
20
|
+
`.trim();
|
|
21
|
+
|
|
22
|
+
const argsWarden = new ArgsWarden([
|
|
23
|
+
['credsPayload', credsValidator],
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
const shopifyStorefrontShopGet = async (
|
|
27
|
+
credsPayload,
|
|
28
|
+
{
|
|
29
|
+
apiVersion,
|
|
30
|
+
attrs = defaultAttrs,
|
|
31
|
+
inContext,
|
|
32
|
+
fetchClient = shopifyStorefrontClient,
|
|
33
|
+
} = {},
|
|
34
|
+
) => {
|
|
35
|
+
|
|
36
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
37
|
+
credsPayload,
|
|
38
|
+
});
|
|
39
|
+
if (rejectResponse) {
|
|
40
|
+
return rejectResponse;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const inContextDirective = buildInContextDirective(inContext);
|
|
44
|
+
|
|
45
|
+
return fetchClient.fetch({
|
|
46
|
+
requestPayload: {
|
|
47
|
+
method: 'post',
|
|
48
|
+
body: {
|
|
49
|
+
query: `
|
|
50
|
+
query StorefrontShop${ inContextDirective } {
|
|
51
|
+
shop {
|
|
52
|
+
${ attrs }
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
`,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
context: {
|
|
59
|
+
credsPayload,
|
|
60
|
+
apiVersion,
|
|
61
|
+
resultPath: 'data.shop',
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const funcApiConfig = {
|
|
67
|
+
argsWarden,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
module.exports = {
|
|
71
|
+
shopifyStorefrontShopGet,
|
|
72
|
+
funcApiConfig,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/*
|
|
76
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontShopGet" \
|
|
77
|
+
-H "Content-Type: application/json" \
|
|
78
|
+
-d '{
|
|
79
|
+
"credsPayload": { "credsPath": "shopify.au" }
|
|
80
|
+
}'
|
|
81
|
+
*/
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/mutations/shopPayPaymentRequestSessionCreate
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyStorefrontMutationDo } = require('./shopifyStorefrontMutationDo');
|
|
6
|
+
|
|
7
|
+
const defaultReturnSessionAttrs = `
|
|
8
|
+
id
|
|
9
|
+
sourceIdentifier
|
|
10
|
+
checkoutUrl
|
|
11
|
+
paymentRequest {
|
|
12
|
+
total {
|
|
13
|
+
amount
|
|
14
|
+
currencyCode
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
`.trim();
|
|
18
|
+
|
|
19
|
+
const argsWarden = new ArgsWarden([
|
|
20
|
+
['credsPayload', credsValidator],
|
|
21
|
+
['sourceIdentifier'],
|
|
22
|
+
['paymentRequest'],
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
const shopifyStorefrontShopPayPaymentRequestSessionCreate = async (
|
|
26
|
+
credsPayload,
|
|
27
|
+
sourceIdentifier,
|
|
28
|
+
paymentRequest,
|
|
29
|
+
{
|
|
30
|
+
apiVersion,
|
|
31
|
+
returnSessionAttrs = defaultReturnSessionAttrs,
|
|
32
|
+
inContext,
|
|
33
|
+
fetchClient,
|
|
34
|
+
} = {},
|
|
35
|
+
) => {
|
|
36
|
+
|
|
37
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
38
|
+
credsPayload,
|
|
39
|
+
sourceIdentifier,
|
|
40
|
+
paymentRequest,
|
|
41
|
+
});
|
|
42
|
+
if (rejectResponse) {
|
|
43
|
+
return rejectResponse;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return shopifyStorefrontMutationDo(
|
|
47
|
+
credsPayload,
|
|
48
|
+
'shopPayPaymentRequestSessionCreate',
|
|
49
|
+
{
|
|
50
|
+
mutationVariables: {
|
|
51
|
+
sourceIdentifier: {
|
|
52
|
+
type: 'String!',
|
|
53
|
+
value: sourceIdentifier,
|
|
54
|
+
},
|
|
55
|
+
paymentRequest: {
|
|
56
|
+
type: 'ShopPayPaymentRequestInput!',
|
|
57
|
+
value: paymentRequest,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
returnSchema: `
|
|
61
|
+
shopPayPaymentRequestSession { ${ returnSessionAttrs } }
|
|
62
|
+
userErrors { field message code }
|
|
63
|
+
`.trim(),
|
|
64
|
+
apiVersion,
|
|
65
|
+
inContext,
|
|
66
|
+
...fetchClient ? { fetchClient } : {},
|
|
67
|
+
},
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const funcApiConfig = {
|
|
72
|
+
argsWarden,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
module.exports = {
|
|
76
|
+
shopifyStorefrontShopPayPaymentRequestSessionCreate,
|
|
77
|
+
funcApiConfig,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/*
|
|
81
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontShopPayPaymentRequestSessionCreate" \
|
|
82
|
+
-H "Content-Type: application/json" \
|
|
83
|
+
-d '{
|
|
84
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
85
|
+
"sourceIdentifier": "order-123",
|
|
86
|
+
"paymentRequest": {
|
|
87
|
+
"total": { "amount": "10.00", "currencyCode": "AUD" },
|
|
88
|
+
"lineItems": [{ "label": "Item", "amount": { "amount": "10.00", "currencyCode": "AUD" }, "quantity": 1 }]
|
|
89
|
+
}
|
|
90
|
+
}'
|
|
91
|
+
*/
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/mutations/shopPayPaymentRequestSessionSubmit
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyStorefrontMutationDo } = require('./shopifyStorefrontMutationDo');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['token'],
|
|
10
|
+
['paymentRequest'],
|
|
11
|
+
['idempotencyKey'],
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
const shopifyStorefrontShopPayPaymentRequestSessionSubmit = async (
|
|
15
|
+
credsPayload,
|
|
16
|
+
token,
|
|
17
|
+
paymentRequest,
|
|
18
|
+
idempotencyKey,
|
|
19
|
+
{
|
|
20
|
+
apiVersion,
|
|
21
|
+
orderName,
|
|
22
|
+
inContext,
|
|
23
|
+
fetchClient,
|
|
24
|
+
} = {},
|
|
25
|
+
) => {
|
|
26
|
+
|
|
27
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
28
|
+
credsPayload,
|
|
29
|
+
token,
|
|
30
|
+
paymentRequest,
|
|
31
|
+
idempotencyKey,
|
|
32
|
+
});
|
|
33
|
+
if (rejectResponse) {
|
|
34
|
+
return rejectResponse;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return shopifyStorefrontMutationDo(
|
|
38
|
+
credsPayload,
|
|
39
|
+
'shopPayPaymentRequestSessionSubmit',
|
|
40
|
+
{
|
|
41
|
+
mutationVariables: {
|
|
42
|
+
token: {
|
|
43
|
+
type: 'String!',
|
|
44
|
+
value: token,
|
|
45
|
+
},
|
|
46
|
+
paymentRequest: {
|
|
47
|
+
type: 'ShopPayPaymentRequestInput!',
|
|
48
|
+
value: paymentRequest,
|
|
49
|
+
},
|
|
50
|
+
idempotencyKey: {
|
|
51
|
+
type: 'String!',
|
|
52
|
+
value: idempotencyKey,
|
|
53
|
+
},
|
|
54
|
+
...orderName !== undefined && {
|
|
55
|
+
orderName: {
|
|
56
|
+
type: 'String',
|
|
57
|
+
value: orderName,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
returnSchema: `
|
|
62
|
+
paymentRequestReceipt {
|
|
63
|
+
token
|
|
64
|
+
processingStatusType
|
|
65
|
+
}
|
|
66
|
+
userErrors { field message code }
|
|
67
|
+
`.trim(),
|
|
68
|
+
apiVersion,
|
|
69
|
+
inContext,
|
|
70
|
+
...fetchClient ? { fetchClient } : {},
|
|
71
|
+
},
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const funcApiConfig = {
|
|
76
|
+
argsWarden,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
module.exports = {
|
|
80
|
+
shopifyStorefrontShopPayPaymentRequestSessionSubmit,
|
|
81
|
+
funcApiConfig,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/*
|
|
85
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontShopPayPaymentRequestSessionSubmit" \
|
|
86
|
+
-H "Content-Type: application/json" \
|
|
87
|
+
-d '{
|
|
88
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
89
|
+
"token": "session-token",
|
|
90
|
+
"paymentRequest": {
|
|
91
|
+
"total": { "amount": "10.00", "currencyCode": "AUD" }
|
|
92
|
+
},
|
|
93
|
+
"idempotencyKey": "unique-key-123"
|
|
94
|
+
}'
|
|
95
|
+
*/
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/queries/sitemap
|
|
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
|
+
pagesCount {
|
|
12
|
+
count
|
|
13
|
+
precision
|
|
14
|
+
}
|
|
15
|
+
`.trim();
|
|
16
|
+
|
|
17
|
+
const argsWarden = new ArgsWarden([
|
|
18
|
+
['credsPayload', credsValidator],
|
|
19
|
+
['type'],
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
const shopifyStorefrontSitemapGet = async (
|
|
23
|
+
credsPayload,
|
|
24
|
+
type,
|
|
25
|
+
{
|
|
26
|
+
apiVersion,
|
|
27
|
+
attrs = defaultAttrs,
|
|
28
|
+
page,
|
|
29
|
+
inContext,
|
|
30
|
+
fetchClient = shopifyStorefrontClient,
|
|
31
|
+
} = {},
|
|
32
|
+
) => {
|
|
33
|
+
|
|
34
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
35
|
+
credsPayload,
|
|
36
|
+
type,
|
|
37
|
+
});
|
|
38
|
+
if (rejectResponse) {
|
|
39
|
+
return rejectResponse;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const inContextDirective = buildInContextDirective(inContext);
|
|
43
|
+
|
|
44
|
+
const resourcesBlock = page !== undefined ? `
|
|
45
|
+
resources(page: ${ page }) {
|
|
46
|
+
items {
|
|
47
|
+
... on SitemapResource {
|
|
48
|
+
handle
|
|
49
|
+
updatedAt
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
pageInfo {
|
|
53
|
+
hasNextPage
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
` : '';
|
|
57
|
+
|
|
58
|
+
return fetchClient.fetch({
|
|
59
|
+
requestPayload: {
|
|
60
|
+
method: 'post',
|
|
61
|
+
body: {
|
|
62
|
+
query: `
|
|
63
|
+
query StorefrontSitemap ($type: SitemapType!)${ inContextDirective } {
|
|
64
|
+
sitemap(type: $type) {
|
|
65
|
+
${ attrs }
|
|
66
|
+
${ resourcesBlock }
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
`,
|
|
70
|
+
variables: { type },
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
context: {
|
|
74
|
+
credsPayload,
|
|
75
|
+
apiVersion,
|
|
76
|
+
resultPath: 'data.sitemap',
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const funcApiConfig = {
|
|
82
|
+
argsWarden,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
module.exports = {
|
|
86
|
+
shopifyStorefrontSitemapGet,
|
|
87
|
+
funcApiConfig,
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/*
|
|
91
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontSitemapGet" \
|
|
92
|
+
-H "Content-Type: application/json" \
|
|
93
|
+
-d '{
|
|
94
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
95
|
+
"type": "PRODUCT",
|
|
96
|
+
"options": { "page": 1 }
|
|
97
|
+
}'
|
|
98
|
+
*/
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/storefront/latest/queries/urlRedirects
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { shopifyStorefrontGet, shopifyStorefrontGetter } = require('./shopifyStorefrontGet');
|
|
6
|
+
|
|
7
|
+
const defaultAttrs = `
|
|
8
|
+
id
|
|
9
|
+
path
|
|
10
|
+
target
|
|
11
|
+
`.trim();
|
|
12
|
+
|
|
13
|
+
const argsWarden = new ArgsWarden([
|
|
14
|
+
['credsPayload', credsValidator],
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
const shopifyStorefrontUrlRedirectsGetInner = 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
|
+
'urlRedirect',
|
|
36
|
+
{
|
|
37
|
+
attrs,
|
|
38
|
+
resources: 'urlRedirects',
|
|
39
|
+
...getterOptions,
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
return returnGetter
|
|
44
|
+
? shopifyStorefrontGetter(...getterArgs)
|
|
45
|
+
: shopifyStorefrontGet(...getterArgs);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const funcApiConfig = {
|
|
49
|
+
argsWarden,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
module.exports = {
|
|
53
|
+
shopifyStorefrontUrlRedirectsGet: (...args) => shopifyStorefrontUrlRedirectsGetInner(false, ...args),
|
|
54
|
+
shopifyStorefrontUrlRedirectsGetter: (...args) => shopifyStorefrontUrlRedirectsGetInner(true, ...args),
|
|
55
|
+
funcApiConfig,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/*
|
|
59
|
+
curl -X POST "http://localhost:8000/shopifyStorefrontUrlRedirectsGet" \
|
|
60
|
+
-H "Content-Type: application/json" \
|
|
61
|
+
-d '{
|
|
62
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
63
|
+
"options": {
|
|
64
|
+
"limit": 10
|
|
65
|
+
}
|
|
66
|
+
}'
|
|
67
|
+
*/
|
package/api/slack/slack.utils.js
CHANGED
|
@@ -5,17 +5,50 @@ const {
|
|
|
5
5
|
fetchClientCommonSteps,
|
|
6
6
|
} = require('../utils');
|
|
7
7
|
|
|
8
|
+
const TOKEN_KEYS_BY_TYPE = {
|
|
9
|
+
bot: 'BOT_TOKEN',
|
|
10
|
+
user: 'USER_TOKEN',
|
|
11
|
+
};
|
|
12
|
+
|
|
8
13
|
const useAuthHeaders = async (state) => {
|
|
9
14
|
const { requestPayload, context } = state;
|
|
10
15
|
const { creds } = context;
|
|
11
|
-
const
|
|
16
|
+
const useTokenType = context.useTokenType || 'bot';
|
|
17
|
+
const tokenKey = TOKEN_KEYS_BY_TYPE[useTokenType];
|
|
18
|
+
|
|
19
|
+
if (!tokenKey) {
|
|
20
|
+
return {
|
|
21
|
+
breakChain: true,
|
|
22
|
+
response: {
|
|
23
|
+
ok: false,
|
|
24
|
+
error: {
|
|
25
|
+
code: 'INVALID_USE_TOKEN_TYPE',
|
|
26
|
+
message: `useTokenType must be 'bot' or 'user', got '${ useTokenType }'`,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const token = creds?.[tokenKey];
|
|
33
|
+
if (!token) {
|
|
34
|
+
return {
|
|
35
|
+
breakChain: true,
|
|
36
|
+
response: {
|
|
37
|
+
ok: false,
|
|
38
|
+
error: {
|
|
39
|
+
code: 'NO_SLACK_TOKEN',
|
|
40
|
+
message: `slack creds missing ${ tokenKey }`,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
12
45
|
|
|
13
46
|
return {
|
|
14
47
|
requestPayload: {
|
|
15
48
|
...requestPayload,
|
|
16
49
|
method: requestPayload.method || 'post',
|
|
17
50
|
headers: {
|
|
18
|
-
Authorization: `Bearer ${
|
|
51
|
+
Authorization: `Bearer ${ token }`,
|
|
19
52
|
...requestPayload.headers,
|
|
20
53
|
},
|
|
21
54
|
},
|
|
@@ -34,4 +67,5 @@ const slackClient = new FetchClient({
|
|
|
34
67
|
|
|
35
68
|
module.exports = {
|
|
36
69
|
slackClient,
|
|
70
|
+
TOKEN_KEYS_BY_TYPE,
|
|
37
71
|
};
|
|
@@ -23,7 +23,9 @@ const slackMessagePost = async (
|
|
|
23
23
|
channelIdentifier,
|
|
24
24
|
messagePayload,
|
|
25
25
|
{
|
|
26
|
+
useTokenType = 'bot',
|
|
26
27
|
inspect = false,
|
|
28
|
+
fetchClient = slackClient,
|
|
27
29
|
} = {},
|
|
28
30
|
) => {
|
|
29
31
|
|
|
@@ -47,7 +49,7 @@ const slackMessagePost = async (
|
|
|
47
49
|
markdownText,
|
|
48
50
|
} = messagePayload;
|
|
49
51
|
|
|
50
|
-
const response = await
|
|
52
|
+
const response = await fetchClient.fetch({
|
|
51
53
|
requestPayload: {
|
|
52
54
|
url: '/chat.postMessage',
|
|
53
55
|
method: 'post',
|
|
@@ -58,7 +60,10 @@ const slackMessagePost = async (
|
|
|
58
60
|
...markdownText && { markdown_text: markdownText },
|
|
59
61
|
},
|
|
60
62
|
},
|
|
61
|
-
context: {
|
|
63
|
+
context: {
|
|
64
|
+
credsPayload,
|
|
65
|
+
useTokenType,
|
|
66
|
+
},
|
|
62
67
|
inspect,
|
|
63
68
|
});
|
|
64
69
|
|
|
@@ -80,6 +85,9 @@ curl -X POST "http://localhost:8000/slackMessagePost" \
|
|
|
80
85
|
-d '{
|
|
81
86
|
"credsPayload": { "credsPath": "slack" },
|
|
82
87
|
"channelIdentifier": { "channelName": "#hidden_testing" },
|
|
83
|
-
"messagePayload": { "text": "new number, who dis?" }
|
|
88
|
+
"messagePayload": { "text": "new number, who dis?" },
|
|
89
|
+
"options": {
|
|
90
|
+
"useTokenType": "bot"
|
|
91
|
+
}
|
|
84
92
|
}'
|
|
85
93
|
*/
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// https://docs.slack.dev/reference/methods/search.messages
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { slackClient } = require('../slack/slack.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['query'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const slackMessagesSearch = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
query,
|
|
15
|
+
{
|
|
16
|
+
count,
|
|
17
|
+
page,
|
|
18
|
+
sort,
|
|
19
|
+
sortDir,
|
|
20
|
+
highlight,
|
|
21
|
+
useTokenType = 'user',
|
|
22
|
+
inspect = false,
|
|
23
|
+
fetchClient = slackClient,
|
|
24
|
+
} = {},
|
|
25
|
+
) => {
|
|
26
|
+
|
|
27
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
28
|
+
credsPayload,
|
|
29
|
+
query,
|
|
30
|
+
});
|
|
31
|
+
if (rejectResponse) {
|
|
32
|
+
return rejectResponse;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const searchParams = new URLSearchParams({
|
|
36
|
+
query,
|
|
37
|
+
...count != null && { count: String(count) },
|
|
38
|
+
...page != null && { page: String(page) },
|
|
39
|
+
...sort && { sort },
|
|
40
|
+
...sortDir && { sort_dir: sortDir },
|
|
41
|
+
...highlight != null && { highlight: String(highlight) },
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const response = await fetchClient.fetch({
|
|
45
|
+
requestPayload: {
|
|
46
|
+
url: `/search.messages?${ searchParams }`,
|
|
47
|
+
method: 'get',
|
|
48
|
+
},
|
|
49
|
+
context: {
|
|
50
|
+
credsPayload,
|
|
51
|
+
useTokenType,
|
|
52
|
+
},
|
|
53
|
+
inspect,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return response;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const funcApiConfig = {
|
|
60
|
+
argsWarden,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
module.exports = {
|
|
64
|
+
slackMessagesSearch,
|
|
65
|
+
funcApiConfig,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/*
|
|
69
|
+
curl -X POST "http://localhost:8000/slackMessagesSearch" \
|
|
70
|
+
-H "Content-Type: application/json" \
|
|
71
|
+
-d '{
|
|
72
|
+
"credsPayload": { "credsPath": "slack" },
|
|
73
|
+
"query": "in:#project_canada_migration",
|
|
74
|
+
"options": {
|
|
75
|
+
"count": 5,
|
|
76
|
+
"sort": "timestamp",
|
|
77
|
+
"sortDir": "desc",
|
|
78
|
+
"useTokenType": "user"
|
|
79
|
+
}
|
|
80
|
+
}'
|
|
81
|
+
*/
|