@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.
Files changed (87) hide show
  1. package/.creds.yml.sample +1 -0
  2. package/_build_scripts/createNewFunction.js +23 -41
  3. package/api/UTILS.md +1 -1
  4. package/api/bleckmann/bleckmannPickticketGet.js +4 -2
  5. package/api/github/githubActionsSecretCreateOrUpdate.js +139 -0
  6. package/api/github/githubActionsSecretPublicKeyGet.js +59 -0
  7. package/api/google/googlecalendarEventCreate.js +2 -0
  8. package/api/linear/linearTeamGet.js +6 -3
  9. package/api/shopify/shopify.constants.js +25 -0
  10. package/api/shopify/shopify.utils.js +41 -6
  11. package/api/shopify/shopifyInventoryQuantitiesSet.js +164 -0
  12. package/api/shopify/shopifyMutationDo.js +12 -6
  13. package/api/shopify/shopifyShopGet.js +68 -0
  14. package/api/shopify/shopifyStorefrontArticleGet.js +86 -0
  15. package/api/shopify/shopifyStorefrontArticlesGet.js +67 -0
  16. package/api/shopify/shopifyStorefrontBlogGet.js +110 -0
  17. package/api/shopify/shopifyStorefrontBlogsGet.js +66 -0
  18. package/api/shopify/shopifyStorefrontCartAttributesUpdate.js +87 -0
  19. package/api/shopify/shopifyStorefrontCartBuyerIdentityUpdate.js +87 -0
  20. package/api/shopify/shopifyStorefrontCartCreate.js +83 -0
  21. package/api/shopify/shopifyStorefrontCartDeliveryAddressesAdd.js +87 -0
  22. package/api/shopify/shopifyStorefrontCartDeliveryAddressesRemove.js +87 -0
  23. package/api/shopify/shopifyStorefrontCartDeliveryAddressesReplace.js +87 -0
  24. package/api/shopify/shopifyStorefrontCartDeliveryAddressesUpdate.js +87 -0
  25. package/api/shopify/shopifyStorefrontCartDiscountCodesUpdate.js +87 -0
  26. package/api/shopify/shopifyStorefrontCartGet.js +100 -0
  27. package/api/shopify/shopifyStorefrontCartGiftCardCodesAdd.js +87 -0
  28. package/api/shopify/shopifyStorefrontCartGiftCardCodesRemove.js +87 -0
  29. package/api/shopify/shopifyStorefrontCartGiftCardCodesUpdate.js +87 -0
  30. package/api/shopify/shopifyStorefrontCartLinesAdd.js +87 -0
  31. package/api/shopify/shopifyStorefrontCartLinesRemove.js +87 -0
  32. package/api/shopify/shopifyStorefrontCartLinesUpdate.js +87 -0
  33. package/api/shopify/shopifyStorefrontCartMetafieldDelete.js +69 -0
  34. package/api/shopify/shopifyStorefrontCartMetafieldsSet.js +80 -0
  35. package/api/shopify/shopifyStorefrontCartNoteUpdate.js +87 -0
  36. package/api/shopify/shopifyStorefrontCartSelectedDeliveryOptionsUpdate.js +87 -0
  37. package/api/shopify/shopifyStorefrontCollectionGet.js +92 -0
  38. package/api/shopify/shopifyStorefrontCollectionsGet.js +66 -0
  39. package/api/shopify/shopifyStorefrontCustomerAccessTokenCreate.js +75 -0
  40. package/api/shopify/shopifyStorefrontCustomerAccessTokenCreateWithMultipass.js +72 -0
  41. package/api/shopify/shopifyStorefrontCustomerAccessTokenDelete.js +67 -0
  42. package/api/shopify/shopifyStorefrontCustomerAccessTokenRenew.js +72 -0
  43. package/api/shopify/shopifyStorefrontCustomerActivate.js +98 -0
  44. package/api/shopify/shopifyStorefrontCustomerActivateByUrl.js +91 -0
  45. package/api/shopify/shopifyStorefrontCustomerAddressCreate.js +94 -0
  46. package/api/shopify/shopifyStorefrontCustomerAddressDelete.js +78 -0
  47. package/api/shopify/shopifyStorefrontCustomerAddressUpdate.js +101 -0
  48. package/api/shopify/shopifyStorefrontCustomerCreate.js +79 -0
  49. package/api/shopify/shopifyStorefrontCustomerDefaultAddressUpdate.js +89 -0
  50. package/api/shopify/shopifyStorefrontCustomerGet.js +92 -0
  51. package/api/shopify/shopifyStorefrontCustomerRecover.js +64 -0
  52. package/api/shopify/shopifyStorefrontCustomerReset.js +98 -0
  53. package/api/shopify/shopifyStorefrontCustomerResetByUrl.js +91 -0
  54. package/api/shopify/shopifyStorefrontCustomerUpdate.js +93 -0
  55. package/api/shopify/shopifyStorefrontGet.js +233 -0
  56. package/api/shopify/shopifyStorefrontLocalizationGet.js +98 -0
  57. package/api/shopify/shopifyStorefrontLocationsGet.js +70 -0
  58. package/api/shopify/shopifyStorefrontMenuGet.js +93 -0
  59. package/api/shopify/shopifyStorefrontMetaobjectGet.js +126 -0
  60. package/api/shopify/shopifyStorefrontMetaobjectsGet.js +73 -0
  61. package/api/shopify/shopifyStorefrontMutationDo.js +103 -0
  62. package/api/shopify/shopifyStorefrontNodeGet.js +90 -0
  63. package/api/shopify/shopifyStorefrontNodesGet.js +86 -0
  64. package/api/shopify/shopifyStorefrontPageGet.js +93 -0
  65. package/api/shopify/shopifyStorefrontPagesGet.js +66 -0
  66. package/api/shopify/shopifyStorefrontPaymentSettingsGet.js +79 -0
  67. package/api/shopify/shopifyStorefrontPredictiveSearch.js +138 -0
  68. package/api/shopify/shopifyStorefrontProductGet.js +94 -0
  69. package/api/shopify/shopifyStorefrontProductRecommendationsGet.js +112 -0
  70. package/api/shopify/shopifyStorefrontProductTagsGet.js +80 -0
  71. package/api/shopify/shopifyStorefrontProductTypesGet.js +80 -0
  72. package/api/shopify/shopifyStorefrontProductsGet.js +76 -0
  73. package/api/shopify/shopifyStorefrontPublicApiVersionsGet.js +75 -0
  74. package/api/shopify/shopifyStorefrontSearch.js +8 -2
  75. package/api/shopify/shopifyStorefrontShopGet.js +81 -0
  76. package/api/shopify/shopifyStorefrontShopPayPaymentRequestSessionCreate.js +91 -0
  77. package/api/shopify/shopifyStorefrontShopPayPaymentRequestSessionSubmit.js +95 -0
  78. package/api/shopify/shopifyStorefrontSitemapGet.js +98 -0
  79. package/api/shopify/shopifyStorefrontUrlRedirectsGet.js +67 -0
  80. package/api/slack/docs.md +4 -0
  81. package/api/slack/slack.utils.js +36 -2
  82. package/api/slack/slackMessagePost.js +11 -3
  83. package/api/slack/slackMessagesSearch.js +81 -0
  84. package/api/utils.js +47 -10
  85. package/hosting/deployFromHostingYml.js +9 -21
  86. package/package.json +3 -1
  87. package/server.utils.js +24 -15
@@ -0,0 +1,87 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/mutations/cartGiftCardCodesUpdate
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { shopifyStorefrontMutationDo } = require('./shopifyStorefrontMutationDo');
6
+
7
+ const defaultReturnCartAttrs = `
8
+ id
9
+ checkoutUrl
10
+ totalQuantity
11
+ note
12
+ cost {
13
+ totalAmount { amount currencyCode }
14
+ subtotalAmount { amount currencyCode }
15
+ }
16
+ `.trim();
17
+
18
+ const argsWarden = new ArgsWarden([
19
+ ['credsPayload', credsValidator],
20
+ ['cartId'],
21
+ ['giftCardCodes'],
22
+ ]);
23
+
24
+ const shopifyStorefrontCartGiftCardCodesUpdate = async (
25
+ credsPayload,
26
+ cartId,
27
+ giftCardCodes,
28
+ {
29
+ apiVersion,
30
+ returnCartAttrs = defaultReturnCartAttrs,
31
+ inContext,
32
+ fetchClient,
33
+ } = {},
34
+ ) => {
35
+
36
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
37
+ credsPayload,
38
+ cartId,
39
+ giftCardCodes
40
+ });
41
+ if (rejectResponse) {
42
+ return rejectResponse;
43
+ }
44
+
45
+ return shopifyStorefrontMutationDo(
46
+ credsPayload,
47
+ 'cartGiftCardCodesUpdate',
48
+ {
49
+ mutationVariables: {
50
+ cartId: {
51
+ type: 'ID!',
52
+ value: cartId,
53
+ },
54
+ giftCardCodes: {
55
+ type: '[String!]!',
56
+ value: giftCardCodes,
57
+ },
58
+ },
59
+ returnSchema: `
60
+ cart { ${ returnCartAttrs } }
61
+ warnings { code message }
62
+ `.trim(),
63
+ apiVersion,
64
+ inContext,
65
+ ...fetchClient ? { fetchClient } : {},
66
+ },
67
+ );
68
+ };
69
+
70
+ const funcApiConfig = {
71
+ argsWarden,
72
+ };
73
+
74
+ module.exports = {
75
+ shopifyStorefrontCartGiftCardCodesUpdate,
76
+ funcApiConfig,
77
+ };
78
+
79
+ /*
80
+ curl -X POST "http://localhost:8000/shopifyStorefrontCartGiftCardCodesUpdate" \
81
+ -H "Content-Type: application/json" \
82
+ -d '{
83
+ "credsPayload": { "credsPath": "shopify.au" },
84
+ "cartId": "gid://shopify/Cart/c1-xxx?key=yyy",
85
+ "giftCardCodes": ["ABCD-EFGH-IJKL"],
86
+ }'
87
+ */
@@ -0,0 +1,87 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/mutations/cartLinesAdd
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { shopifyStorefrontMutationDo } = require('./shopifyStorefrontMutationDo');
6
+
7
+ const defaultReturnCartAttrs = `
8
+ id
9
+ checkoutUrl
10
+ totalQuantity
11
+ note
12
+ cost {
13
+ totalAmount { amount currencyCode }
14
+ subtotalAmount { amount currencyCode }
15
+ }
16
+ `.trim();
17
+
18
+ const argsWarden = new ArgsWarden([
19
+ ['credsPayload', credsValidator],
20
+ ['cartId'],
21
+ ['lines'],
22
+ ]);
23
+
24
+ const shopifyStorefrontCartLinesAdd = async (
25
+ credsPayload,
26
+ cartId,
27
+ lines,
28
+ {
29
+ apiVersion,
30
+ returnCartAttrs = defaultReturnCartAttrs,
31
+ inContext,
32
+ fetchClient,
33
+ } = {},
34
+ ) => {
35
+
36
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
37
+ credsPayload,
38
+ cartId,
39
+ lines
40
+ });
41
+ if (rejectResponse) {
42
+ return rejectResponse;
43
+ }
44
+
45
+ return shopifyStorefrontMutationDo(
46
+ credsPayload,
47
+ 'cartLinesAdd',
48
+ {
49
+ mutationVariables: {
50
+ cartId: {
51
+ type: 'ID!',
52
+ value: cartId,
53
+ },
54
+ lines: {
55
+ type: '[CartLineInput!]!',
56
+ value: lines,
57
+ },
58
+ },
59
+ returnSchema: `
60
+ cart { ${ returnCartAttrs } }
61
+ warnings { code message }
62
+ `.trim(),
63
+ apiVersion,
64
+ inContext,
65
+ ...fetchClient ? { fetchClient } : {},
66
+ },
67
+ );
68
+ };
69
+
70
+ const funcApiConfig = {
71
+ argsWarden,
72
+ };
73
+
74
+ module.exports = {
75
+ shopifyStorefrontCartLinesAdd,
76
+ funcApiConfig,
77
+ };
78
+
79
+ /*
80
+ curl -X POST "http://localhost:8000/shopifyStorefrontCartLinesAdd" \
81
+ -H "Content-Type: application/json" \
82
+ -d '{
83
+ "credsPayload": { "credsPath": "shopify.au" },
84
+ "cartId": "gid://shopify/Cart/c1-xxx?key=yyy",
85
+ "lines": [{"merchandiseId":"gid://shopify/ProductVariant/123","quantity":1}],
86
+ }'
87
+ */
@@ -0,0 +1,87 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/mutations/cartLinesRemove
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { shopifyStorefrontMutationDo } = require('./shopifyStorefrontMutationDo');
6
+
7
+ const defaultReturnCartAttrs = `
8
+ id
9
+ checkoutUrl
10
+ totalQuantity
11
+ note
12
+ cost {
13
+ totalAmount { amount currencyCode }
14
+ subtotalAmount { amount currencyCode }
15
+ }
16
+ `.trim();
17
+
18
+ const argsWarden = new ArgsWarden([
19
+ ['credsPayload', credsValidator],
20
+ ['cartId'],
21
+ ['lineIds'],
22
+ ]);
23
+
24
+ const shopifyStorefrontCartLinesRemove = async (
25
+ credsPayload,
26
+ cartId,
27
+ lineIds,
28
+ {
29
+ apiVersion,
30
+ returnCartAttrs = defaultReturnCartAttrs,
31
+ inContext,
32
+ fetchClient,
33
+ } = {},
34
+ ) => {
35
+
36
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
37
+ credsPayload,
38
+ cartId,
39
+ lineIds
40
+ });
41
+ if (rejectResponse) {
42
+ return rejectResponse;
43
+ }
44
+
45
+ return shopifyStorefrontMutationDo(
46
+ credsPayload,
47
+ 'cartLinesRemove',
48
+ {
49
+ mutationVariables: {
50
+ cartId: {
51
+ type: 'ID!',
52
+ value: cartId,
53
+ },
54
+ lineIds: {
55
+ type: '[ID!]!',
56
+ value: lineIds,
57
+ },
58
+ },
59
+ returnSchema: `
60
+ cart { ${ returnCartAttrs } }
61
+ warnings { code message }
62
+ `.trim(),
63
+ apiVersion,
64
+ inContext,
65
+ ...fetchClient ? { fetchClient } : {},
66
+ },
67
+ );
68
+ };
69
+
70
+ const funcApiConfig = {
71
+ argsWarden,
72
+ };
73
+
74
+ module.exports = {
75
+ shopifyStorefrontCartLinesRemove,
76
+ funcApiConfig,
77
+ };
78
+
79
+ /*
80
+ curl -X POST "http://localhost:8000/shopifyStorefrontCartLinesRemove" \
81
+ -H "Content-Type: application/json" \
82
+ -d '{
83
+ "credsPayload": { "credsPath": "shopify.au" },
84
+ "cartId": "gid://shopify/Cart/c1-xxx?key=yyy",
85
+ "lineIds": ["gid://shopify/CartLine/xxx"],
86
+ }'
87
+ */
@@ -0,0 +1,87 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/mutations/cartLinesUpdate
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { shopifyStorefrontMutationDo } = require('./shopifyStorefrontMutationDo');
6
+
7
+ const defaultReturnCartAttrs = `
8
+ id
9
+ checkoutUrl
10
+ totalQuantity
11
+ note
12
+ cost {
13
+ totalAmount { amount currencyCode }
14
+ subtotalAmount { amount currencyCode }
15
+ }
16
+ `.trim();
17
+
18
+ const argsWarden = new ArgsWarden([
19
+ ['credsPayload', credsValidator],
20
+ ['cartId'],
21
+ ['lines'],
22
+ ]);
23
+
24
+ const shopifyStorefrontCartLinesUpdate = async (
25
+ credsPayload,
26
+ cartId,
27
+ lines,
28
+ {
29
+ apiVersion,
30
+ returnCartAttrs = defaultReturnCartAttrs,
31
+ inContext,
32
+ fetchClient,
33
+ } = {},
34
+ ) => {
35
+
36
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
37
+ credsPayload,
38
+ cartId,
39
+ lines
40
+ });
41
+ if (rejectResponse) {
42
+ return rejectResponse;
43
+ }
44
+
45
+ return shopifyStorefrontMutationDo(
46
+ credsPayload,
47
+ 'cartLinesUpdate',
48
+ {
49
+ mutationVariables: {
50
+ cartId: {
51
+ type: 'ID!',
52
+ value: cartId,
53
+ },
54
+ lines: {
55
+ type: '[CartLineUpdateInput!]!',
56
+ value: lines,
57
+ },
58
+ },
59
+ returnSchema: `
60
+ cart { ${ returnCartAttrs } }
61
+ warnings { code message }
62
+ `.trim(),
63
+ apiVersion,
64
+ inContext,
65
+ ...fetchClient ? { fetchClient } : {},
66
+ },
67
+ );
68
+ };
69
+
70
+ const funcApiConfig = {
71
+ argsWarden,
72
+ };
73
+
74
+ module.exports = {
75
+ shopifyStorefrontCartLinesUpdate,
76
+ funcApiConfig,
77
+ };
78
+
79
+ /*
80
+ curl -X POST "http://localhost:8000/shopifyStorefrontCartLinesUpdate" \
81
+ -H "Content-Type: application/json" \
82
+ -d '{
83
+ "credsPayload": { "credsPath": "shopify.au" },
84
+ "cartId": "gid://shopify/Cart/c1-xxx?key=yyy",
85
+ "lines": [{"id":"gid://shopify/CartLine/xxx","quantity":2}],
86
+ }'
87
+ */
@@ -0,0 +1,69 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/mutations/cartMetafieldDelete
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
+ ['input'],
10
+ ]);
11
+
12
+ const shopifyStorefrontCartMetafieldDelete = async (
13
+ credsPayload,
14
+ input,
15
+ {
16
+ apiVersion,
17
+ inContext,
18
+ fetchClient,
19
+ } = {},
20
+ ) => {
21
+
22
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
23
+ credsPayload,
24
+ input,
25
+ });
26
+ if (rejectResponse) {
27
+ return rejectResponse;
28
+ }
29
+
30
+ return shopifyStorefrontMutationDo(
31
+ credsPayload,
32
+ 'cartMetafieldDelete',
33
+ {
34
+ mutationVariables: {
35
+ input: {
36
+ type: 'CartMetafieldDeleteInput!',
37
+ value: input,
38
+ },
39
+ },
40
+ returnSchema: `
41
+ deletedId
42
+ `.trim(),
43
+ apiVersion,
44
+ inContext,
45
+ ...fetchClient ? { fetchClient } : {},
46
+ },
47
+ );
48
+ };
49
+
50
+ const funcApiConfig = {
51
+ argsWarden,
52
+ };
53
+
54
+ module.exports = {
55
+ shopifyStorefrontCartMetafieldDelete,
56
+ funcApiConfig,
57
+ };
58
+
59
+ /*
60
+ curl -X POST "http://localhost:8000/shopifyStorefrontCartMetafieldDelete" \
61
+ -H "Content-Type: application/json" \
62
+ -d '{
63
+ "credsPayload": { "credsPath": "shopify.au" },
64
+ "input": {
65
+ "ownerId": "gid://shopify/Cart/c1-xxx?key=yyy",
66
+ "key": "custom.note"
67
+ }
68
+ }'
69
+ */
@@ -0,0 +1,80 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/mutations/cartMetafieldsSet
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { shopifyStorefrontMutationDo } = require('./shopifyStorefrontMutationDo');
6
+
7
+ const defaultReturnMetafieldAttrs = `
8
+ id
9
+ namespace
10
+ key
11
+ value
12
+ type
13
+ `.trim();
14
+
15
+ const argsWarden = new ArgsWarden([
16
+ ['credsPayload', credsValidator],
17
+ ['metafields'],
18
+ ]);
19
+
20
+ const shopifyStorefrontCartMetafieldsSet = async (
21
+ credsPayload,
22
+ metafields,
23
+ {
24
+ apiVersion,
25
+ returnMetafieldAttrs = defaultReturnMetafieldAttrs,
26
+ inContext,
27
+ fetchClient,
28
+ } = {},
29
+ ) => {
30
+
31
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
32
+ credsPayload,
33
+ metafields,
34
+ });
35
+ if (rejectResponse) {
36
+ return rejectResponse;
37
+ }
38
+
39
+ return shopifyStorefrontMutationDo(
40
+ credsPayload,
41
+ 'cartMetafieldsSet',
42
+ {
43
+ mutationVariables: {
44
+ metafields: {
45
+ type: '[CartMetafieldsSetInput!]!',
46
+ value: metafields,
47
+ },
48
+ },
49
+ returnSchema: `
50
+ metafields { ${ returnMetafieldAttrs } }
51
+ `.trim(),
52
+ apiVersion,
53
+ inContext,
54
+ ...fetchClient ? { fetchClient } : {},
55
+ },
56
+ );
57
+ };
58
+
59
+ const funcApiConfig = {
60
+ argsWarden,
61
+ };
62
+
63
+ module.exports = {
64
+ shopifyStorefrontCartMetafieldsSet,
65
+ funcApiConfig,
66
+ };
67
+
68
+ /*
69
+ curl -X POST "http://localhost:8000/shopifyStorefrontCartMetafieldsSet" \
70
+ -H "Content-Type: application/json" \
71
+ -d '{
72
+ "credsPayload": { "credsPath": "shopify.au" },
73
+ "metafields": [{
74
+ "ownerId": "gid://shopify/Cart/c1-xxx?key=yyy",
75
+ "key": "custom.note",
76
+ "type": "single_line_text_field",
77
+ "value": "hello"
78
+ }]
79
+ }'
80
+ */
@@ -0,0 +1,87 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/mutations/cartNoteUpdate
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { shopifyStorefrontMutationDo } = require('./shopifyStorefrontMutationDo');
6
+
7
+ const defaultReturnCartAttrs = `
8
+ id
9
+ checkoutUrl
10
+ totalQuantity
11
+ note
12
+ cost {
13
+ totalAmount { amount currencyCode }
14
+ subtotalAmount { amount currencyCode }
15
+ }
16
+ `.trim();
17
+
18
+ const argsWarden = new ArgsWarden([
19
+ ['credsPayload', credsValidator],
20
+ ['cartId'],
21
+ ['note'],
22
+ ]);
23
+
24
+ const shopifyStorefrontCartNoteUpdate = async (
25
+ credsPayload,
26
+ cartId,
27
+ note,
28
+ {
29
+ apiVersion,
30
+ returnCartAttrs = defaultReturnCartAttrs,
31
+ inContext,
32
+ fetchClient,
33
+ } = {},
34
+ ) => {
35
+
36
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
37
+ credsPayload,
38
+ cartId,
39
+ note
40
+ });
41
+ if (rejectResponse) {
42
+ return rejectResponse;
43
+ }
44
+
45
+ return shopifyStorefrontMutationDo(
46
+ credsPayload,
47
+ 'cartNoteUpdate',
48
+ {
49
+ mutationVariables: {
50
+ cartId: {
51
+ type: 'ID!',
52
+ value: cartId,
53
+ },
54
+ note: {
55
+ type: 'String!',
56
+ value: note,
57
+ },
58
+ },
59
+ returnSchema: `
60
+ cart { ${ returnCartAttrs } }
61
+ warnings { code message }
62
+ `.trim(),
63
+ apiVersion,
64
+ inContext,
65
+ ...fetchClient ? { fetchClient } : {},
66
+ },
67
+ );
68
+ };
69
+
70
+ const funcApiConfig = {
71
+ argsWarden,
72
+ };
73
+
74
+ module.exports = {
75
+ shopifyStorefrontCartNoteUpdate,
76
+ funcApiConfig,
77
+ };
78
+
79
+ /*
80
+ curl -X POST "http://localhost:8000/shopifyStorefrontCartNoteUpdate" \
81
+ -H "Content-Type: application/json" \
82
+ -d '{
83
+ "credsPayload": { "credsPath": "shopify.au" },
84
+ "cartId": "gid://shopify/Cart/c1-xxx?key=yyy",
85
+ "note": "Please gift wrap",
86
+ }'
87
+ */
@@ -0,0 +1,87 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/mutations/cartSelectedDeliveryOptionsUpdate
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { shopifyStorefrontMutationDo } = require('./shopifyStorefrontMutationDo');
6
+
7
+ const defaultReturnCartAttrs = `
8
+ id
9
+ checkoutUrl
10
+ totalQuantity
11
+ note
12
+ cost {
13
+ totalAmount { amount currencyCode }
14
+ subtotalAmount { amount currencyCode }
15
+ }
16
+ `.trim();
17
+
18
+ const argsWarden = new ArgsWarden([
19
+ ['credsPayload', credsValidator],
20
+ ['cartId'],
21
+ ['selectedDeliveryOptions'],
22
+ ]);
23
+
24
+ const shopifyStorefrontCartSelectedDeliveryOptionsUpdate = async (
25
+ credsPayload,
26
+ cartId,
27
+ selectedDeliveryOptions,
28
+ {
29
+ apiVersion,
30
+ returnCartAttrs = defaultReturnCartAttrs,
31
+ inContext,
32
+ fetchClient,
33
+ } = {},
34
+ ) => {
35
+
36
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
37
+ credsPayload,
38
+ cartId,
39
+ selectedDeliveryOptions
40
+ });
41
+ if (rejectResponse) {
42
+ return rejectResponse;
43
+ }
44
+
45
+ return shopifyStorefrontMutationDo(
46
+ credsPayload,
47
+ 'cartSelectedDeliveryOptionsUpdate',
48
+ {
49
+ mutationVariables: {
50
+ cartId: {
51
+ type: 'ID!',
52
+ value: cartId,
53
+ },
54
+ selectedDeliveryOptions: {
55
+ type: '[CartSelectedDeliveryOptionInput!]!',
56
+ value: selectedDeliveryOptions,
57
+ },
58
+ },
59
+ returnSchema: `
60
+ cart { ${ returnCartAttrs } }
61
+ warnings { code message }
62
+ `.trim(),
63
+ apiVersion,
64
+ inContext,
65
+ ...fetchClient ? { fetchClient } : {},
66
+ },
67
+ );
68
+ };
69
+
70
+ const funcApiConfig = {
71
+ argsWarden,
72
+ };
73
+
74
+ module.exports = {
75
+ shopifyStorefrontCartSelectedDeliveryOptionsUpdate,
76
+ funcApiConfig,
77
+ };
78
+
79
+ /*
80
+ curl -X POST "http://localhost:8000/shopifyStorefrontCartSelectedDeliveryOptionsUpdate" \
81
+ -H "Content-Type: application/json" \
82
+ -d '{
83
+ "credsPayload": { "credsPath": "shopify.au" },
84
+ "cartId": "gid://shopify/Cart/c1-xxx?key=yyy",
85
+ "selectedDeliveryOptions": [{"deliveryGroupId":"gid://shopify/CartDeliveryGroup/xxx","deliveryOptionHandle":"standard"}],
86
+ }'
87
+ */