@foxtware/mineral 1.0.5 → 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 +44 -8
  85. package/hosting/deployFromHostingYml.js +9 -21
  86. package/package.json +3 -1
  87. package/server.utils.js +24 -15
@@ -0,0 +1,94 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/mutations/customerAddressCreate
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { shopifyStorefrontMutationDo } = require('./shopifyStorefrontMutationDo');
6
+
7
+ const defaultReturnAddressAttrs = `
8
+ id
9
+ address1
10
+ address2
11
+ city
12
+ company
13
+ country
14
+ firstName
15
+ lastName
16
+ phone
17
+ province
18
+ zip
19
+ `.trim();
20
+
21
+ const argsWarden = new ArgsWarden([
22
+ ['credsPayload', credsValidator],
23
+ ['customerAccessToken'],
24
+ ['address'],
25
+ ]);
26
+
27
+ const shopifyStorefrontCustomerAddressCreate = async (
28
+ credsPayload,
29
+ customerAccessToken,
30
+ address,
31
+ {
32
+ apiVersion,
33
+ returnAddressAttrs = defaultReturnAddressAttrs,
34
+ inContext,
35
+ fetchClient,
36
+ } = {},
37
+ ) => {
38
+
39
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
40
+ credsPayload,
41
+ customerAccessToken,
42
+ address,
43
+ });
44
+ if (rejectResponse) {
45
+ return rejectResponse;
46
+ }
47
+
48
+ return shopifyStorefrontMutationDo(
49
+ credsPayload,
50
+ 'customerAddressCreate',
51
+ {
52
+ mutationVariables: {
53
+ customerAccessToken: {
54
+ type: 'String!',
55
+ value: customerAccessToken,
56
+ },
57
+ address: {
58
+ type: 'MailingAddressInput!',
59
+ value: address,
60
+ },
61
+ },
62
+ returnSchema: `
63
+ customerAddress { ${ returnAddressAttrs } }
64
+ `.trim(),
65
+ apiVersion,
66
+ inContext,
67
+ ...fetchClient ? { fetchClient } : {},
68
+ },
69
+ );
70
+ };
71
+
72
+ const funcApiConfig = {
73
+ argsWarden,
74
+ };
75
+
76
+ module.exports = {
77
+ shopifyStorefrontCustomerAddressCreate,
78
+ funcApiConfig,
79
+ };
80
+
81
+ /*
82
+ curl -X POST "http://localhost:8000/shopifyStorefrontCustomerAddressCreate" \
83
+ -H "Content-Type: application/json" \
84
+ -d '{
85
+ "credsPayload": { "credsPath": "shopify.au" },
86
+ "customerAccessToken": "shcat_xxx",
87
+ "address": {
88
+ "address1": "1 Main St",
89
+ "city": "Sydney",
90
+ "country": "Australia",
91
+ "zip": "2000"
92
+ }
93
+ }'
94
+ */
@@ -0,0 +1,78 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/mutations/customerAddressDelete
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
+ ['customerAccessToken'],
10
+ ['addressId'],
11
+ ]);
12
+
13
+ const shopifyStorefrontCustomerAddressDelete = async (
14
+ credsPayload,
15
+ customerAccessToken,
16
+ addressId,
17
+ {
18
+ apiVersion,
19
+ inContext,
20
+ fetchClient,
21
+ } = {},
22
+ ) => {
23
+
24
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
25
+ credsPayload,
26
+ customerAccessToken,
27
+ addressId,
28
+ });
29
+ if (rejectResponse) {
30
+ return rejectResponse;
31
+ }
32
+
33
+ const id = addressId.toString().startsWith('gid://')
34
+ ? addressId
35
+ : `gid://shopify/MailingAddress/${ addressId }?model_name=CustomerAddress`;
36
+
37
+ return shopifyStorefrontMutationDo(
38
+ credsPayload,
39
+ 'customerAddressDelete',
40
+ {
41
+ mutationVariables: {
42
+ customerAccessToken: {
43
+ type: 'String!',
44
+ value: customerAccessToken,
45
+ },
46
+ id: {
47
+ type: 'ID!',
48
+ value: id,
49
+ },
50
+ },
51
+ returnSchema: `
52
+ deletedCustomerAddressId
53
+ `.trim(),
54
+ apiVersion,
55
+ inContext,
56
+ ...fetchClient ? { fetchClient } : {},
57
+ },
58
+ );
59
+ };
60
+
61
+ const funcApiConfig = {
62
+ argsWarden,
63
+ };
64
+
65
+ module.exports = {
66
+ shopifyStorefrontCustomerAddressDelete,
67
+ funcApiConfig,
68
+ };
69
+
70
+ /*
71
+ curl -X POST "http://localhost:8000/shopifyStorefrontCustomerAddressDelete" \
72
+ -H "Content-Type: application/json" \
73
+ -d '{
74
+ "credsPayload": { "credsPath": "shopify.au" },
75
+ "customerAccessToken": "shcat_xxx",
76
+ "addressId": "gid://shopify/MailingAddress/123?model_name=CustomerAddress"
77
+ }'
78
+ */
@@ -0,0 +1,101 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/mutations/customerAddressUpdate
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { shopifyStorefrontMutationDo } = require('./shopifyStorefrontMutationDo');
6
+
7
+ const defaultReturnAddressAttrs = `
8
+ id
9
+ address1
10
+ address2
11
+ city
12
+ company
13
+ country
14
+ firstName
15
+ lastName
16
+ phone
17
+ province
18
+ zip
19
+ `.trim();
20
+
21
+ const argsWarden = new ArgsWarden([
22
+ ['credsPayload', credsValidator],
23
+ ['customerAccessToken'],
24
+ ['addressId'],
25
+ ['address'],
26
+ ]);
27
+
28
+ const shopifyStorefrontCustomerAddressUpdate = async (
29
+ credsPayload,
30
+ customerAccessToken,
31
+ addressId,
32
+ address,
33
+ {
34
+ apiVersion,
35
+ returnAddressAttrs = defaultReturnAddressAttrs,
36
+ inContext,
37
+ fetchClient,
38
+ } = {},
39
+ ) => {
40
+
41
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
42
+ credsPayload,
43
+ customerAccessToken,
44
+ addressId,
45
+ address,
46
+ });
47
+ if (rejectResponse) {
48
+ return rejectResponse;
49
+ }
50
+
51
+ const id = addressId.toString().startsWith('gid://')
52
+ ? addressId
53
+ : `gid://shopify/MailingAddress/${ addressId }?model_name=CustomerAddress`;
54
+
55
+ return shopifyStorefrontMutationDo(
56
+ credsPayload,
57
+ 'customerAddressUpdate',
58
+ {
59
+ mutationVariables: {
60
+ customerAccessToken: {
61
+ type: 'String!',
62
+ value: customerAccessToken,
63
+ },
64
+ id: {
65
+ type: 'ID!',
66
+ value: id,
67
+ },
68
+ address: {
69
+ type: 'MailingAddressInput!',
70
+ value: address,
71
+ },
72
+ },
73
+ returnSchema: `
74
+ customerAddress { ${ returnAddressAttrs } }
75
+ `.trim(),
76
+ apiVersion,
77
+ inContext,
78
+ ...fetchClient ? { fetchClient } : {},
79
+ },
80
+ );
81
+ };
82
+
83
+ const funcApiConfig = {
84
+ argsWarden,
85
+ };
86
+
87
+ module.exports = {
88
+ shopifyStorefrontCustomerAddressUpdate,
89
+ funcApiConfig,
90
+ };
91
+
92
+ /*
93
+ curl -X POST "http://localhost:8000/shopifyStorefrontCustomerAddressUpdate" \
94
+ -H "Content-Type: application/json" \
95
+ -d '{
96
+ "credsPayload": { "credsPath": "shopify.au" },
97
+ "customerAccessToken": "shcat_xxx",
98
+ "addressId": "gid://shopify/MailingAddress/123?model_name=CustomerAddress",
99
+ "address": { "city": "Melbourne" }
100
+ }'
101
+ */
@@ -0,0 +1,79 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/mutations/customerCreate
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { shopifyStorefrontMutationDo } = require('./shopifyStorefrontMutationDo');
6
+
7
+ const defaultReturnCustomerAttrs = `
8
+ id
9
+ email
10
+ firstName
11
+ lastName
12
+ displayName
13
+ phone
14
+ `.trim();
15
+
16
+ const argsWarden = new ArgsWarden([
17
+ ['credsPayload', credsValidator],
18
+ ['input'],
19
+ ]);
20
+
21
+ const shopifyStorefrontCustomerCreate = async (
22
+ credsPayload,
23
+ input,
24
+ {
25
+ apiVersion,
26
+ returnCustomerAttrs = defaultReturnCustomerAttrs,
27
+ inContext,
28
+ fetchClient,
29
+ } = {},
30
+ ) => {
31
+
32
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
33
+ credsPayload,
34
+ input,
35
+ });
36
+ if (rejectResponse) {
37
+ return rejectResponse;
38
+ }
39
+
40
+ return shopifyStorefrontMutationDo(
41
+ credsPayload,
42
+ 'customerCreate',
43
+ {
44
+ mutationVariables: {
45
+ input: {
46
+ type: 'CustomerCreateInput!',
47
+ value: input,
48
+ },
49
+ },
50
+ returnSchema: `
51
+ customer { ${ returnCustomerAttrs } }
52
+ `.trim(),
53
+ apiVersion,
54
+ inContext,
55
+ ...fetchClient ? { fetchClient } : {},
56
+ },
57
+ );
58
+ };
59
+
60
+ const funcApiConfig = {
61
+ argsWarden,
62
+ };
63
+
64
+ module.exports = {
65
+ shopifyStorefrontCustomerCreate,
66
+ funcApiConfig,
67
+ };
68
+
69
+ /*
70
+ curl -X POST "http://localhost:8000/shopifyStorefrontCustomerCreate" \
71
+ -H "Content-Type: application/json" \
72
+ -d '{
73
+ "credsPayload": { "credsPath": "shopify.au" },
74
+ "input": {
75
+ "email": "buyer@example.com",
76
+ "password": "SecurePass123"
77
+ }
78
+ }'
79
+ */
@@ -0,0 +1,89 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/mutations/customerDefaultAddressUpdate
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { shopifyStorefrontMutationDo } = require('./shopifyStorefrontMutationDo');
6
+
7
+ const defaultReturnCustomerAttrs = `
8
+ id
9
+ email
10
+ firstName
11
+ lastName
12
+ displayName
13
+ phone
14
+ defaultAddress { id address1 city }
15
+ `.trim();
16
+
17
+ const argsWarden = new ArgsWarden([
18
+ ['credsPayload', credsValidator],
19
+ ['customerAccessToken'],
20
+ ['addressId'],
21
+ ]);
22
+
23
+ const shopifyStorefrontCustomerDefaultAddressUpdate = async (
24
+ credsPayload,
25
+ customerAccessToken,
26
+ addressId,
27
+ {
28
+ apiVersion,
29
+ returnCustomerAttrs = defaultReturnCustomerAttrs,
30
+ inContext,
31
+ fetchClient,
32
+ } = {},
33
+ ) => {
34
+
35
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
36
+ credsPayload,
37
+ customerAccessToken,
38
+ addressId,
39
+ });
40
+ if (rejectResponse) {
41
+ return rejectResponse;
42
+ }
43
+
44
+ const id = addressId.toString().startsWith('gid://')
45
+ ? addressId
46
+ : `gid://shopify/MailingAddress/${ addressId }?model_name=CustomerAddress`;
47
+
48
+ return shopifyStorefrontMutationDo(
49
+ credsPayload,
50
+ 'customerDefaultAddressUpdate',
51
+ {
52
+ mutationVariables: {
53
+ customerAccessToken: {
54
+ type: 'String!',
55
+ value: customerAccessToken,
56
+ },
57
+ addressId: {
58
+ type: 'ID!',
59
+ value: id,
60
+ },
61
+ },
62
+ returnSchema: `
63
+ customer { ${ returnCustomerAttrs } }
64
+ `.trim(),
65
+ apiVersion,
66
+ inContext,
67
+ ...fetchClient ? { fetchClient } : {},
68
+ },
69
+ );
70
+ };
71
+
72
+ const funcApiConfig = {
73
+ argsWarden,
74
+ };
75
+
76
+ module.exports = {
77
+ shopifyStorefrontCustomerDefaultAddressUpdate,
78
+ funcApiConfig,
79
+ };
80
+
81
+ /*
82
+ curl -X POST "http://localhost:8000/shopifyStorefrontCustomerDefaultAddressUpdate" \
83
+ -H "Content-Type: application/json" \
84
+ -d '{
85
+ "credsPayload": { "credsPath": "shopify.au" },
86
+ "customerAccessToken": "shcat_xxx",
87
+ "addressId": "gid://shopify/MailingAddress/123?model_name=CustomerAddress"
88
+ }'
89
+ */
@@ -0,0 +1,92 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/queries/customer
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
+ firstName
13
+ lastName
14
+ displayName
15
+ email
16
+ phone
17
+ acceptsMarketing
18
+ createdAt
19
+ updatedAt
20
+ defaultAddress {
21
+ id
22
+ address1
23
+ city
24
+ country
25
+ }
26
+ `.trim();
27
+
28
+ const argsWarden = new ArgsWarden([
29
+ ['credsPayload', credsValidator],
30
+ ['customerAccessToken'],
31
+ ]);
32
+
33
+ const shopifyStorefrontCustomerGet = async (
34
+ credsPayload,
35
+ customerAccessToken,
36
+ {
37
+ apiVersion,
38
+ attrs = defaultAttrs,
39
+ inContext,
40
+ fetchClient = shopifyStorefrontClient,
41
+ } = {},
42
+ ) => {
43
+
44
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
45
+ credsPayload,
46
+ customerAccessToken,
47
+ });
48
+ if (rejectResponse) {
49
+ return rejectResponse;
50
+ }
51
+
52
+ const inContextDirective = buildInContextDirective(inContext);
53
+
54
+ return fetchClient.fetch({
55
+ requestPayload: {
56
+ method: 'post',
57
+ body: {
58
+ query: `
59
+ query StorefrontCustomer ($customerAccessToken: String!)${ inContextDirective } {
60
+ customer(customerAccessToken: $customerAccessToken) {
61
+ ${ attrs }
62
+ }
63
+ }
64
+ `,
65
+ variables: { customerAccessToken },
66
+ },
67
+ },
68
+ context: {
69
+ credsPayload,
70
+ apiVersion,
71
+ resultPath: 'data.customer',
72
+ },
73
+ });
74
+ };
75
+
76
+ const funcApiConfig = {
77
+ argsWarden,
78
+ };
79
+
80
+ module.exports = {
81
+ shopifyStorefrontCustomerGet,
82
+ funcApiConfig,
83
+ };
84
+
85
+ /*
86
+ curl -X POST "http://localhost:8000/shopifyStorefrontCustomerGet" \
87
+ -H "Content-Type: application/json" \
88
+ -d '{
89
+ "credsPayload": { "credsPath": "shopify.au" },
90
+ "customerAccessToken": "shcat_xxx"
91
+ }'
92
+ */
@@ -0,0 +1,64 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/mutations/customerRecover
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
+ ['email'],
10
+ ]);
11
+
12
+ const shopifyStorefrontCustomerRecover = async (
13
+ credsPayload,
14
+ email,
15
+ {
16
+ apiVersion,
17
+ inContext,
18
+ fetchClient,
19
+ } = {},
20
+ ) => {
21
+
22
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
23
+ credsPayload,
24
+ email,
25
+ });
26
+ if (rejectResponse) {
27
+ return rejectResponse;
28
+ }
29
+
30
+ return shopifyStorefrontMutationDo(
31
+ credsPayload,
32
+ 'customerRecover',
33
+ {
34
+ mutationVariables: {
35
+ email: {
36
+ type: 'String!',
37
+ value: email,
38
+ },
39
+ },
40
+ returnSchema: '',
41
+ apiVersion,
42
+ inContext,
43
+ ...fetchClient ? { fetchClient } : {},
44
+ },
45
+ );
46
+ };
47
+
48
+ const funcApiConfig = {
49
+ argsWarden,
50
+ };
51
+
52
+ module.exports = {
53
+ shopifyStorefrontCustomerRecover,
54
+ funcApiConfig,
55
+ };
56
+
57
+ /*
58
+ curl -X POST "http://localhost:8000/shopifyStorefrontCustomerRecover" \
59
+ -H "Content-Type: application/json" \
60
+ -d '{
61
+ "credsPayload": { "credsPath": "shopify.au" },
62
+ "email": "buyer@example.com"
63
+ }'
64
+ */
@@ -0,0 +1,98 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/mutations/customerReset
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { shopifyStorefrontMutationDo } = require('./shopifyStorefrontMutationDo');
6
+
7
+ const defaultReturnCustomerAttrs = `
8
+ id
9
+ email
10
+ firstName
11
+ lastName
12
+ displayName
13
+ phone
14
+ `.trim();
15
+
16
+ const defaultReturnAccessTokenAttrs = `
17
+ accessToken
18
+ expiresAt
19
+ `.trim();
20
+
21
+ const argsWarden = new ArgsWarden([
22
+ ['credsPayload', credsValidator],
23
+ ['customerId'],
24
+ ['input'],
25
+ ]);
26
+
27
+ const shopifyStorefrontCustomerReset = async (
28
+ credsPayload,
29
+ customerId,
30
+ input,
31
+ {
32
+ apiVersion,
33
+ returnCustomerAttrs = defaultReturnCustomerAttrs,
34
+ returnAccessTokenAttrs = defaultReturnAccessTokenAttrs,
35
+ inContext,
36
+ fetchClient,
37
+ } = {},
38
+ ) => {
39
+
40
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
41
+ credsPayload,
42
+ customerId,
43
+ input,
44
+ });
45
+ if (rejectResponse) {
46
+ return rejectResponse;
47
+ }
48
+
49
+ const id = customerId.toString().startsWith('gid://')
50
+ ? customerId
51
+ : `gid://shopify/Customer/${ customerId }`;
52
+
53
+ return shopifyStorefrontMutationDo(
54
+ credsPayload,
55
+ 'customerReset',
56
+ {
57
+ mutationVariables: {
58
+ id: {
59
+ type: 'ID!',
60
+ value: id,
61
+ },
62
+ input: {
63
+ type: 'CustomerResetInput!',
64
+ value: input,
65
+ },
66
+ },
67
+ returnSchema: `
68
+ customer { ${ returnCustomerAttrs } }
69
+ customerAccessToken { ${ returnAccessTokenAttrs } }
70
+ `.trim(),
71
+ apiVersion,
72
+ inContext,
73
+ ...fetchClient ? { fetchClient } : {},
74
+ },
75
+ );
76
+ };
77
+
78
+ const funcApiConfig = {
79
+ argsWarden,
80
+ };
81
+
82
+ module.exports = {
83
+ shopifyStorefrontCustomerReset,
84
+ funcApiConfig,
85
+ };
86
+
87
+ /*
88
+ curl -X POST "http://localhost:8000/shopifyStorefrontCustomerReset" \
89
+ -H "Content-Type: application/json" \
90
+ -d '{
91
+ "credsPayload": { "credsPath": "shopify.au" },
92
+ "customerId": "1234567890",
93
+ "input": {
94
+ "resetToken": "token",
95
+ "password": "NewSecurePass123"
96
+ }
97
+ }'
98
+ */