@foxtware/mineral 0.1.23 → 0.1.24

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.
@@ -1,18 +1,17 @@
1
1
  const { ArgsWarden } = require('../utils');
2
2
  const { credsValidator } = require('../validators');
3
- const { shopifyClient } = require('./shopify.utils');
3
+ const { shopifyGet, shopifyGetter } = require('./shopifyGet');
4
4
 
5
5
  const argsWarden = new ArgsWarden([
6
6
  ['credsPayload', credsValidator],
7
7
  ]);
8
8
 
9
9
  const shopifyOrdersGet = async (
10
+ returnGetter, // Always bound
11
+
10
12
  credsPayload,
11
13
  {
12
- first = 50,
13
- after,
14
- query,
15
- apiVersion,
14
+ ...getterOptions // e.g. limit
16
15
  } = {},
17
16
  ) => {
18
17
 
@@ -23,52 +22,17 @@ const shopifyOrdersGet = async (
23
22
  return rejectResponse;
24
23
  }
25
24
 
26
- const response = await shopifyClient.fetch({
27
- requestPayload: {
28
- method: 'post',
29
- body: {
30
- query: `
31
- query OrdersGet(
32
- $first: Int!,
33
- $after: String,
34
- $query: String
35
- ) {
36
- orders(
37
- first: $first,
38
- after: $after,
39
- query: $query
40
- ) {
41
- edges {
42
- node {
43
- id
44
- name
45
- createdAt
46
- displayFinancialStatus
47
- displayFulfillmentStatus
48
- }
49
- }
50
- }
51
- }
52
- `,
53
- variables: {
54
- first,
55
- after,
56
- query,
57
- },
58
- },
59
- },
60
- context: {
61
- credsPayload,
62
- apiVersion,
63
- resultPath: 'data.orders',
25
+ const getterArgs = [
26
+ credsPayload,
27
+ 'order',
28
+ {
29
+ ...getterOptions,
64
30
  },
65
- });
66
-
67
- if (!response.ok) {
68
- return response;
69
- }
31
+ ];
70
32
 
71
- return response;
33
+ return returnGetter
34
+ ? shopifyGetter(...getterArgs)
35
+ : shopifyGet(...getterArgs);
72
36
  };
73
37
 
74
38
  const funcApiConfig = {
@@ -76,6 +40,7 @@ const funcApiConfig = {
76
40
  };
77
41
 
78
42
  module.exports = {
79
- shopifyOrdersGet,
43
+ shopifyOrdersGet: (...args) => shopifyOrdersGet(false, ...args),
44
+ shopifyOrdersGetter: (...args) => shopifyOrdersGet(true, ...args),
80
45
  funcApiConfig,
81
46
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foxtware/mineral",
3
- "version": "0.1.23",
3
+ "version": "0.1.24",
4
4
  "bin": {
5
5
  "mineral": "bin/mineral.js"
6
6
  },