@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,138 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/queries/predictiveSearch
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
+ products {
12
+ id
13
+ handle
14
+ title
15
+ }
16
+ collections {
17
+ id
18
+ handle
19
+ title
20
+ }
21
+ pages {
22
+ id
23
+ handle
24
+ title
25
+ }
26
+ articles {
27
+ id
28
+ handle
29
+ title
30
+ }
31
+ queries {
32
+ text
33
+ styledText
34
+ }
35
+ `.trim();
36
+
37
+ const argsWarden = new ArgsWarden([
38
+ ['credsPayload', credsValidator],
39
+ ['query'],
40
+ ]);
41
+
42
+ const shopifyStorefrontPredictiveSearch = async (
43
+ credsPayload,
44
+ query,
45
+ {
46
+ apiVersion,
47
+ attrs = defaultAttrs,
48
+ limit,
49
+ limitScope,
50
+ types,
51
+ searchableFields,
52
+ unavailableProducts,
53
+ inContext,
54
+ fetchClient = shopifyStorefrontClient,
55
+ } = {},
56
+ ) => {
57
+
58
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
59
+ credsPayload,
60
+ query,
61
+ });
62
+ if (rejectResponse) {
63
+ return rejectResponse;
64
+ }
65
+
66
+ const inContextDirective = buildInContextDirective(inContext);
67
+
68
+ const queryTypeDeclaration = [
69
+ '$query: String!',
70
+ ...limit !== undefined ? ['$limit: Int'] : [],
71
+ ...limitScope ? ['$limitScope: PredictiveSearchLimitScope'] : [],
72
+ ...types ? ['$types: [PredictiveSearchType!]'] : [],
73
+ ...searchableFields ? ['$searchableFields: [SearchableField!]'] : [],
74
+ ...unavailableProducts ? ['$unavailableProducts: SearchUnavailableProductsType'] : [],
75
+ ].join('\n');
76
+
77
+ const queryVariableDeclaration = [
78
+ 'query: $query',
79
+ ...limit !== undefined ? ['limit: $limit'] : [],
80
+ ...limitScope ? ['limitScope: $limitScope'] : [],
81
+ ...types ? ['types: $types'] : [],
82
+ ...searchableFields ? ['searchableFields: $searchableFields'] : [],
83
+ ...unavailableProducts ? ['unavailableProducts: $unavailableProducts'] : [],
84
+ ].join('\n');
85
+
86
+ const variables = {
87
+ query,
88
+ ...limit !== undefined && { limit },
89
+ ...limitScope && { limitScope },
90
+ ...types && { types },
91
+ ...searchableFields && { searchableFields },
92
+ ...unavailableProducts && { unavailableProducts },
93
+ };
94
+
95
+ return fetchClient.fetch({
96
+ requestPayload: {
97
+ method: 'post',
98
+ body: {
99
+ query: `
100
+ query StorefrontPredictiveSearch (
101
+ ${ queryTypeDeclaration }
102
+ )${ inContextDirective } {
103
+ predictiveSearch(
104
+ ${ queryVariableDeclaration }
105
+ ) {
106
+ ${ attrs }
107
+ }
108
+ }
109
+ `,
110
+ variables,
111
+ },
112
+ },
113
+ context: {
114
+ credsPayload,
115
+ apiVersion,
116
+ resultPath: 'data.predictiveSearch',
117
+ },
118
+ });
119
+ };
120
+
121
+ const funcApiConfig = {
122
+ argsWarden,
123
+ };
124
+
125
+ module.exports = {
126
+ shopifyStorefrontPredictiveSearch,
127
+ funcApiConfig,
128
+ };
129
+
130
+ /*
131
+ curl -X POST "http://localhost:8000/shopifyStorefrontPredictiveSearch" \
132
+ -H "Content-Type: application/json" \
133
+ -d '{
134
+ "credsPayload": { "credsPath": "shopify.au" },
135
+ "query": "dress",
136
+ "options": { "limit": 5, "types": ["PRODUCT"] }
137
+ }'
138
+ */
@@ -0,0 +1,94 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/queries/product
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden, objHasAny } = require('../utils');
5
+ const {
6
+ shopifyStorefrontClient,
7
+ buildInContextDirective,
8
+ } = require('./shopify.utils');
9
+
10
+ const defaultAttrs = `
11
+ id
12
+ handle
13
+ title
14
+ availableForSale
15
+ productType
16
+ vendor
17
+ `.trim();
18
+
19
+ const identifierValidator = (identifier) => objHasAny(identifier, ['id', 'handle']);
20
+
21
+ const argsWarden = new ArgsWarden([
22
+ ['credsPayload', credsValidator],
23
+ ['productIdentifier', identifierValidator],
24
+ ]);
25
+
26
+ const shopifyStorefrontProductGet = async (
27
+ credsPayload,
28
+ productIdentifier,
29
+ {
30
+ apiVersion,
31
+ attrs = defaultAttrs,
32
+ inContext,
33
+ fetchClient = shopifyStorefrontClient,
34
+ } = {},
35
+ ) => {
36
+
37
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
38
+ credsPayload,
39
+ productIdentifier,
40
+ });
41
+ if (rejectResponse) {
42
+ return rejectResponse;
43
+ }
44
+
45
+ const { id, handle } = productIdentifier;
46
+ const inContextDirective = buildInContextDirective(inContext);
47
+
48
+ const useHandle = Boolean(handle);
49
+ const queryName = useHandle ? 'StorefrontProductByHandle' : 'StorefrontProductById';
50
+ const argDecl = useHandle ? '$handle: String!' : '$id: ID!';
51
+ const argUse = useHandle ? 'handle: $handle' : 'id: $id';
52
+ const variables = useHandle
53
+ ? { handle }
54
+ : { id: id.toString().startsWith('gid://') ? id : `gid://shopify/Product/${ id }` };
55
+
56
+ return fetchClient.fetch({
57
+ requestPayload: {
58
+ method: 'post',
59
+ body: {
60
+ query: `
61
+ query ${ queryName } (${ argDecl })${ inContextDirective } {
62
+ product(${ argUse }) {
63
+ ${ attrs }
64
+ }
65
+ }
66
+ `,
67
+ variables,
68
+ },
69
+ },
70
+ context: {
71
+ credsPayload,
72
+ apiVersion,
73
+ resultPath: 'data.product',
74
+ },
75
+ });
76
+ };
77
+
78
+ const funcApiConfig = {
79
+ argsWarden,
80
+ };
81
+
82
+ module.exports = {
83
+ shopifyStorefrontProductGet,
84
+ funcApiConfig,
85
+ };
86
+
87
+ /*
88
+ curl -X POST "http://localhost:8000/shopifyStorefrontProductGet" \
89
+ -H "Content-Type: application/json" \
90
+ -d '{
91
+ "credsPayload": { "credsPath": "shopify.au" },
92
+ "productIdentifier": { "handle": "offstage-hoodie-moon" }
93
+ }'
94
+ */
@@ -0,0 +1,112 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/queries/productRecommendations
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden, objHasAny } = require('../utils');
5
+ const {
6
+ shopifyStorefrontClient,
7
+ buildInContextDirective,
8
+ } = require('./shopify.utils');
9
+
10
+ const defaultAttrs = `
11
+ id
12
+ handle
13
+ title
14
+ availableForSale
15
+ `.trim();
16
+
17
+ const identifierValidator = (identifier) => objHasAny(identifier, ['productId', 'productHandle']);
18
+
19
+ const argsWarden = new ArgsWarden([
20
+ ['credsPayload', credsValidator],
21
+ ['productIdentifier', identifierValidator],
22
+ ]);
23
+
24
+ const shopifyStorefrontProductRecommendationsGet = async (
25
+ credsPayload,
26
+ productIdentifier,
27
+ {
28
+ apiVersion,
29
+ attrs = defaultAttrs,
30
+ intent,
31
+ inContext,
32
+ fetchClient = shopifyStorefrontClient,
33
+ } = {},
34
+ ) => {
35
+
36
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
37
+ credsPayload,
38
+ productIdentifier,
39
+ });
40
+ if (rejectResponse) {
41
+ return rejectResponse;
42
+ }
43
+
44
+ const { productId, productHandle } = productIdentifier;
45
+ const inContextDirective = buildInContextDirective(inContext);
46
+
47
+ const queryTypeDeclaration = [
48
+ ...productHandle ? ['$productHandle: String'] : [],
49
+ ...productId ? ['$productId: ID'] : [],
50
+ ...intent ? ['$intent: ProductRecommendationIntent'] : [],
51
+ ].join('\n');
52
+
53
+ const queryVariableDeclaration = [
54
+ ...productHandle ? ['productHandle: $productHandle'] : [],
55
+ ...productId ? ['productId: $productId'] : [],
56
+ ...intent ? ['intent: $intent'] : [],
57
+ ].join('\n');
58
+
59
+ const variables = {
60
+ ...productHandle && { productHandle },
61
+ ...productId && {
62
+ productId: productId.toString().startsWith('gid://')
63
+ ? productId
64
+ : `gid://shopify/Product/${ productId }`,
65
+ },
66
+ ...intent && { intent },
67
+ };
68
+
69
+ return fetchClient.fetch({
70
+ requestPayload: {
71
+ method: 'post',
72
+ body: {
73
+ query: `
74
+ query StorefrontProductRecommendations (
75
+ ${ queryTypeDeclaration }
76
+ )${ inContextDirective } {
77
+ productRecommendations(
78
+ ${ queryVariableDeclaration }
79
+ ) {
80
+ ${ attrs }
81
+ }
82
+ }
83
+ `,
84
+ variables,
85
+ },
86
+ },
87
+ context: {
88
+ credsPayload,
89
+ apiVersion,
90
+ resultPath: 'data.productRecommendations',
91
+ },
92
+ });
93
+ };
94
+
95
+ const funcApiConfig = {
96
+ argsWarden,
97
+ };
98
+
99
+ module.exports = {
100
+ shopifyStorefrontProductRecommendationsGet,
101
+ funcApiConfig,
102
+ };
103
+
104
+ /*
105
+ curl -X POST "http://localhost:8000/shopifyStorefrontProductRecommendationsGet" \
106
+ -H "Content-Type: application/json" \
107
+ -d '{
108
+ "credsPayload": { "credsPath": "shopify.au" },
109
+ "productIdentifier": { "productHandle": "offstage-hoodie-moon" },
110
+ "options": { "intent": "RELATED" }
111
+ }'
112
+ */
@@ -0,0 +1,80 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/queries/productTags
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { MAX_PER_PAGE } = require('./shopify.constants');
6
+ const {
7
+ shopifyStorefrontClient,
8
+ buildInContextDirective,
9
+ } = require('./shopify.utils');
10
+
11
+ const argsWarden = new ArgsWarden([
12
+ ['credsPayload', credsValidator],
13
+ ]);
14
+
15
+ const shopifyStorefrontProductTagsGet = async (
16
+ credsPayload,
17
+ {
18
+ apiVersion,
19
+ first = MAX_PER_PAGE,
20
+ inContext,
21
+ fetchClient = shopifyStorefrontClient,
22
+ } = {},
23
+ ) => {
24
+
25
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
26
+ credsPayload,
27
+ });
28
+ if (rejectResponse) {
29
+ return rejectResponse;
30
+ }
31
+
32
+ const inContextDirective = buildInContextDirective(inContext);
33
+
34
+ return fetchClient.fetch({
35
+ requestPayload: {
36
+ method: 'post',
37
+ body: {
38
+ query: `
39
+ query StorefrontProductTagsGet ($first: Int!)${ inContextDirective } {
40
+ productTags(first: $first) {
41
+ edges {
42
+ node
43
+ }
44
+ pageInfo {
45
+ hasNextPage
46
+ endCursor
47
+ }
48
+ }
49
+ }
50
+ `,
51
+ variables: {
52
+ first,
53
+ },
54
+ },
55
+ },
56
+ context: {
57
+ credsPayload,
58
+ apiVersion,
59
+ resultPath: 'data.productTags',
60
+ },
61
+ });
62
+ };
63
+
64
+ const funcApiConfig = {
65
+ argsWarden,
66
+ };
67
+
68
+ module.exports = {
69
+ shopifyStorefrontProductTagsGet,
70
+ funcApiConfig,
71
+ };
72
+
73
+ /*
74
+ curl -X POST "http://localhost:8000/shopifyStorefrontProductTagsGet" \
75
+ -H "Content-Type: application/json" \
76
+ -d '{
77
+ "credsPayload": { "credsPath": "shopify.au" },
78
+ "options": { "first": 50 }
79
+ }'
80
+ */
@@ -0,0 +1,80 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/queries/productTypes
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { MAX_PER_PAGE } = require('./shopify.constants');
6
+ const {
7
+ shopifyStorefrontClient,
8
+ buildInContextDirective,
9
+ } = require('./shopify.utils');
10
+
11
+ const argsWarden = new ArgsWarden([
12
+ ['credsPayload', credsValidator],
13
+ ]);
14
+
15
+ const shopifyStorefrontProductTypesGet = async (
16
+ credsPayload,
17
+ {
18
+ apiVersion,
19
+ first = MAX_PER_PAGE,
20
+ inContext,
21
+ fetchClient = shopifyStorefrontClient,
22
+ } = {},
23
+ ) => {
24
+
25
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
26
+ credsPayload,
27
+ });
28
+ if (rejectResponse) {
29
+ return rejectResponse;
30
+ }
31
+
32
+ const inContextDirective = buildInContextDirective(inContext);
33
+
34
+ return fetchClient.fetch({
35
+ requestPayload: {
36
+ method: 'post',
37
+ body: {
38
+ query: `
39
+ query StorefrontProductTypesGet ($first: Int!)${ inContextDirective } {
40
+ productTypes(first: $first) {
41
+ edges {
42
+ node
43
+ }
44
+ pageInfo {
45
+ hasNextPage
46
+ endCursor
47
+ }
48
+ }
49
+ }
50
+ `,
51
+ variables: {
52
+ first,
53
+ },
54
+ },
55
+ },
56
+ context: {
57
+ credsPayload,
58
+ apiVersion,
59
+ resultPath: 'data.productTypes',
60
+ },
61
+ });
62
+ };
63
+
64
+ const funcApiConfig = {
65
+ argsWarden,
66
+ };
67
+
68
+ module.exports = {
69
+ shopifyStorefrontProductTypesGet,
70
+ funcApiConfig,
71
+ };
72
+
73
+ /*
74
+ curl -X POST "http://localhost:8000/shopifyStorefrontProductTypesGet" \
75
+ -H "Content-Type: application/json" \
76
+ -d '{
77
+ "credsPayload": { "credsPath": "shopify.au" },
78
+ "options": { "first": 50 }
79
+ }'
80
+ */
@@ -0,0 +1,76 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/queries/products
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { shopifyStorefrontGet, shopifyStorefrontGetter } = require('./shopifyStorefrontGet');
6
+
7
+ const defaultAttrs = `
8
+ id
9
+ handle
10
+ title
11
+ availableForSale
12
+ `.trim();
13
+
14
+ const argsWarden = new ArgsWarden([
15
+ ['credsPayload', credsValidator],
16
+ ]);
17
+
18
+ const shopifyStorefrontProductsGetInner = async (
19
+ returnGetter,
20
+ credsPayload,
21
+ {
22
+ attrs = defaultAttrs,
23
+ ...getterOptions
24
+ } = {},
25
+ ) => {
26
+
27
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
28
+ credsPayload,
29
+ });
30
+ if (rejectResponse) {
31
+ return rejectResponse;
32
+ }
33
+
34
+ const getterArgs = [
35
+ credsPayload,
36
+ 'product',
37
+ {
38
+ attrs,
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
+ shopifyStorefrontProductsGet: (...args) => shopifyStorefrontProductsGetInner(false, ...args),
54
+ shopifyStorefrontProductsGetter: (...args) => shopifyStorefrontProductsGetInner(true, ...args),
55
+ funcApiConfig,
56
+ };
57
+
58
+ /*
59
+ curl -X POST "http://localhost:8000/shopifyStorefrontProductsGet" \
60
+ -H "Content-Type: application/json" \
61
+ -d '{
62
+ "credsPayload": { "credsPath": "shopify.au" },
63
+ "options": {
64
+ "attrs": "id handle title description descriptionHtml availableForSale productType vendor tags createdAt updatedAt publishedAt onlineStoreUrl isGiftCard requiresSellingPlan totalInventory seo { title description } featuredImage { id url altText width height } priceRange { minVariantPrice { amount currencyCode } maxVariantPrice { amount currencyCode } } compareAtPriceRange { minVariantPrice { amount currencyCode } maxVariantPrice { amount currencyCode } } options { id name values } images(first: 5) { edges { node { id url altText width height } } } media(first: 5) { edges { node { mediaContentType ... on MediaImage { id image { url altText width height } } } } } variants(first: 20) { edges { node { id title sku barcode availableForSale quantityAvailable currentlyNotInStock requiresComponents selectedOptions { name value } image { id url altText width height } price { amount currencyCode } compareAtPrice { amount currencyCode } unitPrice { amount currencyCode } weight weightUnit } } } sellingPlanGroups(first: 5) { edges { node { name sellingPlans(first: 5) { edges { node { id name description options { name value } } } } } } } category { id name ancestors { id name } } metafields(identifiers: [{namespace: \"shopify\", key: \"color-pattern\"}, {namespace: \"shopify\", key: \"target-gender\"}, {namespace: \"shopify\", key: \"age-group\"}, {namespace: \"shopify\", key: \"fabric\"}, {namespace: \"shopify\", key: \"neckline\"}, {namespace: \"shopify\", key: \"sleeve-length-type\"}, {namespace: \"shopify\", key: \"clothing-features\"}, {namespace: \"shopify\", key: \"dress-occasion\"}]) { id namespace key type value }"
65
+ }
66
+ }'
67
+
68
+ curl -X POST "http://localhost:8000/shopifyStorefrontProductsGet" \
69
+ -H "Content-Type: application/json" \
70
+ -d '{
71
+ "credsPayload": { "credsPath": "shopify.au" },
72
+ "options": {
73
+ "attrs": "id handle title description descriptionHtml availableForSale productType vendor tags createdAt updatedAt publishedAt onlineStoreUrl isGiftCard requiresSellingPlan totalInventory seo { title description } featuredImage { id url altText width height } priceRange { minVariantPrice { amount currencyCode } maxVariantPrice { amount currencyCode } } compareAtPriceRange { minVariantPrice { amount currencyCode } maxVariantPrice { amount currencyCode } } options { id name values } images(first: 5) { edges { node { id url altText width height } } } media(first: 5) { edges { node { mediaContentType ... on MediaImage { id image { url altText width height } } } } } variants(first: 20) { edges { node { id title sku barcode availableForSale quantityAvailable currentlyNotInStock requiresComponents selectedOptions { name value } image { id url altText width height } price { amount currencyCode } compareAtPrice { amount currencyCode } unitPrice { amount currencyCode } weight weightUnit } } } sellingPlanGroups(first: 5) { edges { node { name sellingPlans(first: 5) { edges { node { id name description options { name value } } } } } } } category { id name ancestors { id name } } metafields(identifiers: [{namespace: \"shopify\", key: \"color-pattern\"}, {namespace: \"shopify\", key: \"target-gender\"}, {namespace: \"shopify\", key: \"age-group\"}, {namespace: \"shopify\", key: \"fabric\"}, {namespace: \"shopify\", key: \"neckline\"}, {namespace: \"shopify\", key: \"sleeve-length-type\"}, {namespace: \"shopify\", key: \"clothing-features\"}, {namespace: \"shopify\", key: \"dress-occasion\"}]) { id namespace key type value }"
74
+ }
75
+ }'
76
+ */
@@ -0,0 +1,75 @@
1
+ // https://shopify.dev/docs/api/storefront/latest/queries/publicApiVersions
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
+ handle
12
+ displayName
13
+ supported
14
+ `.trim();
15
+
16
+ const argsWarden = new ArgsWarden([
17
+ ['credsPayload', credsValidator],
18
+ ]);
19
+
20
+ const shopifyStorefrontPublicApiVersionsGet = async (
21
+ credsPayload,
22
+ {
23
+ apiVersion,
24
+ attrs = defaultAttrs,
25
+ inContext,
26
+ fetchClient = shopifyStorefrontClient,
27
+ } = {},
28
+ ) => {
29
+
30
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
31
+ credsPayload,
32
+ });
33
+ if (rejectResponse) {
34
+ return rejectResponse;
35
+ }
36
+
37
+ const inContextDirective = buildInContextDirective(inContext);
38
+
39
+ return fetchClient.fetch({
40
+ requestPayload: {
41
+ method: 'post',
42
+ body: {
43
+ query: `
44
+ query StorefrontPublicApiVersions${ inContextDirective } {
45
+ publicApiVersions {
46
+ ${ attrs }
47
+ }
48
+ }
49
+ `,
50
+ },
51
+ },
52
+ context: {
53
+ credsPayload,
54
+ apiVersion,
55
+ resultPath: 'data.publicApiVersions',
56
+ },
57
+ });
58
+ };
59
+
60
+ const funcApiConfig = {
61
+ argsWarden,
62
+ };
63
+
64
+ module.exports = {
65
+ shopifyStorefrontPublicApiVersionsGet,
66
+ funcApiConfig,
67
+ };
68
+
69
+ /*
70
+ curl -X POST "http://localhost:8000/shopifyStorefrontPublicApiVersionsGet" \
71
+ -H "Content-Type: application/json" \
72
+ -d '{
73
+ "credsPayload": { "credsPath": "shopify.au" }
74
+ }'
75
+ */
@@ -2,7 +2,10 @@
2
2
 
3
3
  const { credsValidator } = require('../validators');
4
4
  const { ArgsWarden } = require('../utils');
5
- const { shopifyStorefrontClient } = require('./shopify.utils');
5
+ const {
6
+ shopifyStorefrontClient,
7
+ buildInContextDirective,
8
+ } = require('./shopify.utils');
6
9
  const { MAX_PER_PAGE } = require('./shopify.constants');
7
10
 
8
11
  const defaultAttrs = `
@@ -42,6 +45,7 @@ const shopifyStorefrontSearch = async (
42
45
  prefix,
43
46
  productFilters,
44
47
  unavailableProducts,
48
+ inContext,
45
49
  fetchClient = shopifyStorefrontClient,
46
50
  } = {},
47
51
  ) => {
@@ -54,6 +58,8 @@ const shopifyStorefrontSearch = async (
54
58
  return rejectResponse;
55
59
  }
56
60
 
61
+ const inContextDirective = buildInContextDirective(inContext);
62
+
57
63
  const queryTypeDeclaration = [
58
64
  '$query: String!',
59
65
  '$first: Int!',
@@ -97,7 +103,7 @@ const shopifyStorefrontSearch = async (
97
103
  query: `
98
104
  query StorefrontSearch (
99
105
  ${ queryTypeDeclaration }
100
- ) {
106
+ )${ inContextDirective } {
101
107
  search(
102
108
  ${ queryVariableDeclaration }
103
109
  ) {