@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/cartDeliveryAddressesAdd
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
+ ['addresses'],
22
+ ]);
23
+
24
+ const shopifyStorefrontCartDeliveryAddressesAdd = async (
25
+ credsPayload,
26
+ cartId,
27
+ addresses,
28
+ {
29
+ apiVersion,
30
+ returnCartAttrs = defaultReturnCartAttrs,
31
+ inContext,
32
+ fetchClient,
33
+ } = {},
34
+ ) => {
35
+
36
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
37
+ credsPayload,
38
+ cartId,
39
+ addresses
40
+ });
41
+ if (rejectResponse) {
42
+ return rejectResponse;
43
+ }
44
+
45
+ return shopifyStorefrontMutationDo(
46
+ credsPayload,
47
+ 'cartDeliveryAddressesAdd',
48
+ {
49
+ mutationVariables: {
50
+ cartId: {
51
+ type: 'ID!',
52
+ value: cartId,
53
+ },
54
+ addresses: {
55
+ type: '[CartSelectableAddressInput!]!',
56
+ value: addresses,
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
+ shopifyStorefrontCartDeliveryAddressesAdd,
76
+ funcApiConfig,
77
+ };
78
+
79
+ /*
80
+ curl -X POST "http://localhost:8000/shopifyStorefrontCartDeliveryAddressesAdd" \
81
+ -H "Content-Type: application/json" \
82
+ -d '{
83
+ "credsPayload": { "credsPath": "shopify.au" },
84
+ "cartId": "gid://shopify/Cart/c1-xxx?key=yyy",
85
+ "addresses": [{"address":{"deliveryAddress":{"address1":"1 Main St","city":"Sydney","countryCode":"AU","zip":"2000"}}}],
86
+ }'
87
+ */
@@ -0,0 +1,87 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/mutations/cartDeliveryAddressesRemove
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
+ ['addressIds'],
22
+ ]);
23
+
24
+ const shopifyStorefrontCartDeliveryAddressesRemove = async (
25
+ credsPayload,
26
+ cartId,
27
+ addressIds,
28
+ {
29
+ apiVersion,
30
+ returnCartAttrs = defaultReturnCartAttrs,
31
+ inContext,
32
+ fetchClient,
33
+ } = {},
34
+ ) => {
35
+
36
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
37
+ credsPayload,
38
+ cartId,
39
+ addressIds
40
+ });
41
+ if (rejectResponse) {
42
+ return rejectResponse;
43
+ }
44
+
45
+ return shopifyStorefrontMutationDo(
46
+ credsPayload,
47
+ 'cartDeliveryAddressesRemove',
48
+ {
49
+ mutationVariables: {
50
+ cartId: {
51
+ type: 'ID!',
52
+ value: cartId,
53
+ },
54
+ addressIds: {
55
+ type: '[ID!]!',
56
+ value: addressIds,
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
+ shopifyStorefrontCartDeliveryAddressesRemove,
76
+ funcApiConfig,
77
+ };
78
+
79
+ /*
80
+ curl -X POST "http://localhost:8000/shopifyStorefrontCartDeliveryAddressesRemove" \
81
+ -H "Content-Type: application/json" \
82
+ -d '{
83
+ "credsPayload": { "credsPath": "shopify.au" },
84
+ "cartId": "gid://shopify/Cart/c1-xxx?key=yyy",
85
+ "addressIds": ["gid://shopify/CartSelectableAddress/xxx"],
86
+ }'
87
+ */
@@ -0,0 +1,87 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/mutations/cartDeliveryAddressesReplace
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
+ ['addresses'],
22
+ ]);
23
+
24
+ const shopifyStorefrontCartDeliveryAddressesReplace = async (
25
+ credsPayload,
26
+ cartId,
27
+ addresses,
28
+ {
29
+ apiVersion,
30
+ returnCartAttrs = defaultReturnCartAttrs,
31
+ inContext,
32
+ fetchClient,
33
+ } = {},
34
+ ) => {
35
+
36
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
37
+ credsPayload,
38
+ cartId,
39
+ addresses
40
+ });
41
+ if (rejectResponse) {
42
+ return rejectResponse;
43
+ }
44
+
45
+ return shopifyStorefrontMutationDo(
46
+ credsPayload,
47
+ 'cartDeliveryAddressesReplace',
48
+ {
49
+ mutationVariables: {
50
+ cartId: {
51
+ type: 'ID!',
52
+ value: cartId,
53
+ },
54
+ addresses: {
55
+ type: '[CartSelectableAddressInput!]!',
56
+ value: addresses,
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
+ shopifyStorefrontCartDeliveryAddressesReplace,
76
+ funcApiConfig,
77
+ };
78
+
79
+ /*
80
+ curl -X POST "http://localhost:8000/shopifyStorefrontCartDeliveryAddressesReplace" \
81
+ -H "Content-Type: application/json" \
82
+ -d '{
83
+ "credsPayload": { "credsPath": "shopify.au" },
84
+ "cartId": "gid://shopify/Cart/c1-xxx?key=yyy",
85
+ "addresses": [{"address":{"deliveryAddress":{"address1":"1 Main St","city":"Sydney","countryCode":"AU","zip":"2000"}}}],
86
+ }'
87
+ */
@@ -0,0 +1,87 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/mutations/cartDeliveryAddressesUpdate
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
+ ['addresses'],
22
+ ]);
23
+
24
+ const shopifyStorefrontCartDeliveryAddressesUpdate = async (
25
+ credsPayload,
26
+ cartId,
27
+ addresses,
28
+ {
29
+ apiVersion,
30
+ returnCartAttrs = defaultReturnCartAttrs,
31
+ inContext,
32
+ fetchClient,
33
+ } = {},
34
+ ) => {
35
+
36
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
37
+ credsPayload,
38
+ cartId,
39
+ addresses
40
+ });
41
+ if (rejectResponse) {
42
+ return rejectResponse;
43
+ }
44
+
45
+ return shopifyStorefrontMutationDo(
46
+ credsPayload,
47
+ 'cartDeliveryAddressesUpdate',
48
+ {
49
+ mutationVariables: {
50
+ cartId: {
51
+ type: 'ID!',
52
+ value: cartId,
53
+ },
54
+ addresses: {
55
+ type: '[CartSelectableAddressUpdateInput!]!',
56
+ value: addresses,
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
+ shopifyStorefrontCartDeliveryAddressesUpdate,
76
+ funcApiConfig,
77
+ };
78
+
79
+ /*
80
+ curl -X POST "http://localhost:8000/shopifyStorefrontCartDeliveryAddressesUpdate" \
81
+ -H "Content-Type: application/json" \
82
+ -d '{
83
+ "credsPayload": { "credsPath": "shopify.au" },
84
+ "cartId": "gid://shopify/Cart/c1-xxx?key=yyy",
85
+ "addresses": [{"id":"gid://shopify/CartSelectableAddress/xxx","address":{"deliveryAddress":{"city":"Melbourne"}}}],
86
+ }'
87
+ */
@@ -0,0 +1,87 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/mutations/cartDiscountCodesUpdate
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
+ ['discountCodes'],
22
+ ]);
23
+
24
+ const shopifyStorefrontCartDiscountCodesUpdate = async (
25
+ credsPayload,
26
+ cartId,
27
+ discountCodes,
28
+ {
29
+ apiVersion,
30
+ returnCartAttrs = defaultReturnCartAttrs,
31
+ inContext,
32
+ fetchClient,
33
+ } = {},
34
+ ) => {
35
+
36
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
37
+ credsPayload,
38
+ cartId,
39
+ discountCodes
40
+ });
41
+ if (rejectResponse) {
42
+ return rejectResponse;
43
+ }
44
+
45
+ return shopifyStorefrontMutationDo(
46
+ credsPayload,
47
+ 'cartDiscountCodesUpdate',
48
+ {
49
+ mutationVariables: {
50
+ cartId: {
51
+ type: 'ID!',
52
+ value: cartId,
53
+ },
54
+ discountCodes: {
55
+ type: '[String!]',
56
+ value: discountCodes,
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
+ shopifyStorefrontCartDiscountCodesUpdate,
76
+ funcApiConfig,
77
+ };
78
+
79
+ /*
80
+ curl -X POST "http://localhost:8000/shopifyStorefrontCartDiscountCodesUpdate" \
81
+ -H "Content-Type: application/json" \
82
+ -d '{
83
+ "credsPayload": { "credsPath": "shopify.au" },
84
+ "cartId": "gid://shopify/Cart/c1-xxx?key=yyy",
85
+ "discountCodes": ["SAVE10"],
86
+ }'
87
+ */
@@ -0,0 +1,100 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/queries/cart
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
+ checkoutUrl
13
+ totalQuantity
14
+ note
15
+ cost {
16
+ totalAmount { amount currencyCode }
17
+ subtotalAmount { amount currencyCode }
18
+ }
19
+ lines(first: 50) {
20
+ edges {
21
+ node {
22
+ id
23
+ quantity
24
+ merchandise {
25
+ ... on ProductVariant {
26
+ id
27
+ title
28
+ product { id handle title }
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
34
+ `.trim();
35
+
36
+ const argsWarden = new ArgsWarden([
37
+ ['credsPayload', credsValidator],
38
+ ['cartId'],
39
+ ]);
40
+
41
+ const shopifyStorefrontCartGet = async (
42
+ credsPayload,
43
+ cartId,
44
+ {
45
+ apiVersion,
46
+ attrs = defaultAttrs,
47
+ inContext,
48
+ fetchClient = shopifyStorefrontClient,
49
+ } = {},
50
+ ) => {
51
+
52
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
53
+ credsPayload,
54
+ cartId,
55
+ });
56
+ if (rejectResponse) {
57
+ return rejectResponse;
58
+ }
59
+
60
+ const inContextDirective = buildInContextDirective(inContext);
61
+
62
+ return fetchClient.fetch({
63
+ requestPayload: {
64
+ method: 'post',
65
+ body: {
66
+ query: `
67
+ query StorefrontCart ($id: ID!)${ inContextDirective } {
68
+ cart(id: $id) {
69
+ ${ attrs }
70
+ }
71
+ }
72
+ `,
73
+ variables: { id: cartId },
74
+ },
75
+ },
76
+ context: {
77
+ credsPayload,
78
+ apiVersion,
79
+ resultPath: 'data.cart',
80
+ },
81
+ });
82
+ };
83
+
84
+ const funcApiConfig = {
85
+ argsWarden,
86
+ };
87
+
88
+ module.exports = {
89
+ shopifyStorefrontCartGet,
90
+ funcApiConfig,
91
+ };
92
+
93
+ /*
94
+ curl -X POST "http://localhost:8000/shopifyStorefrontCartGet" \
95
+ -H "Content-Type: application/json" \
96
+ -d '{
97
+ "credsPayload": { "credsPath": "shopify.au" },
98
+ "cartId": "gid://shopify/Cart/c1-xxx?key=yyy"
99
+ }'
100
+ */
@@ -0,0 +1,87 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/mutations/cartGiftCardCodesAdd
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 shopifyStorefrontCartGiftCardCodesAdd = 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
+ 'cartGiftCardCodesAdd',
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
+ shopifyStorefrontCartGiftCardCodesAdd,
76
+ funcApiConfig,
77
+ };
78
+
79
+ /*
80
+ curl -X POST "http://localhost:8000/shopifyStorefrontCartGiftCardCodesAdd" \
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/cartGiftCardCodesRemove
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
+ ['appliedGiftCardIds'],
22
+ ]);
23
+
24
+ const shopifyStorefrontCartGiftCardCodesRemove = async (
25
+ credsPayload,
26
+ cartId,
27
+ appliedGiftCardIds,
28
+ {
29
+ apiVersion,
30
+ returnCartAttrs = defaultReturnCartAttrs,
31
+ inContext,
32
+ fetchClient,
33
+ } = {},
34
+ ) => {
35
+
36
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
37
+ credsPayload,
38
+ cartId,
39
+ appliedGiftCardIds
40
+ });
41
+ if (rejectResponse) {
42
+ return rejectResponse;
43
+ }
44
+
45
+ return shopifyStorefrontMutationDo(
46
+ credsPayload,
47
+ 'cartGiftCardCodesRemove',
48
+ {
49
+ mutationVariables: {
50
+ cartId: {
51
+ type: 'ID!',
52
+ value: cartId,
53
+ },
54
+ appliedGiftCardIds: {
55
+ type: '[ID!]!',
56
+ value: appliedGiftCardIds,
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
+ shopifyStorefrontCartGiftCardCodesRemove,
76
+ funcApiConfig,
77
+ };
78
+
79
+ /*
80
+ curl -X POST "http://localhost:8000/shopifyStorefrontCartGiftCardCodesRemove" \
81
+ -H "Content-Type: application/json" \
82
+ -d '{
83
+ "credsPayload": { "credsPath": "shopify.au" },
84
+ "cartId": "gid://shopify/Cart/c1-xxx?key=yyy",
85
+ "appliedGiftCardIds": ["gid://shopify/AppliedGiftCard/xxx"],
86
+ }'
87
+ */