@foxtware/mineral 0.1.8 → 0.1.10

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 (186) hide show
  1. package/.creds.yml.sample +43 -1
  2. package/AGENTS.md +6 -1
  3. package/README.md +1 -1
  4. package/api/bleckmann/.gitkeep +0 -0
  5. package/api/bleckmann/bleckmann.constants.js +8 -0
  6. package/api/bleckmann/bleckmann.utils.js +32 -0
  7. package/api/bleckmann/bleckmannAsnGet.js +52 -0
  8. package/api/bleckmann/bleckmannAsnsGet.js +65 -0
  9. package/api/constants.js +2 -1
  10. package/api/github/github.constants.js +11 -0
  11. package/api/github/github.utils.js +65 -0
  12. package/api/github/githubGet.js +144 -0
  13. package/api/github/githubIssueCreate.js +71 -0
  14. package/api/github/githubIssueGet.js +65 -0
  15. package/api/github/githubIssueUpdate.js +71 -0
  16. package/api/github/githubIssuesGet.js +74 -0
  17. package/api/github/githubPullRequestCreate.js +74 -0
  18. package/api/github/githubPullRequestGet.js +65 -0
  19. package/api/github/githubPullRequestMerge.js +77 -0
  20. package/api/github/githubPullRequestUpdate.js +72 -0
  21. package/api/github/githubPullRequestsGet.js +74 -0
  22. package/api/github/githubRepoCreate.js +80 -0
  23. package/api/github/githubRepoDelete.js +60 -0
  24. package/api/github/githubRepoGet.js +61 -0
  25. package/api/github/githubRepoUpdate.js +68 -0
  26. package/api/github/githubReposGet.js +69 -0
  27. package/api/github/githubUserGet.js +64 -0
  28. package/api/linear/linear.utils.js +9 -14
  29. package/api/linear/linearIssuesGet.js +9 -9
  30. package/api/logiwa/logiwa.utils.js +27 -25
  31. package/api/logiwa/logiwaInventoriesGet.js +5 -3
  32. package/api/logiwa/logiwaOrderGet.js +4 -2
  33. package/api/logiwa/logiwaOrdersGet.js +5 -3
  34. package/api/logiwa/logiwaProductGet.js +4 -2
  35. package/api/logiwa/logiwaProductsGet.js +5 -3
  36. package/api/logiwa/logiwaReportGetAvailableToPromise.js +5 -3
  37. package/api/logiwa/logiwaReportGetInventoryCalculation.js +5 -3
  38. package/api/logiwa/logiwaReportGetInventorySnapshot.js +5 -3
  39. package/api/logiwa/logiwaReportGetTotalInventory.js +5 -3
  40. package/api/logiwa/logiwaWebhookStatusGet.js +4 -2
  41. package/api/logiwa/logiwaWebhookSubscribe.js +8 -6
  42. package/api/logiwa/logiwaWebhookUnsubscribe.js +4 -2
  43. package/api/logiwa/logiwaWebhooksGet.js +4 -2
  44. package/api/loop/loop.constants.js +7 -0
  45. package/api/loop/loop.utils.js +37 -0
  46. package/api/loop/loopAllowlistItemsGet.js +42 -0
  47. package/api/loop/loopBlocklistItemsGet.js +46 -0
  48. package/api/loop/loopDestinationsGet.js +42 -0
  49. package/api/loop/loopGet.js +139 -0
  50. package/api/loop/loopReturnGet.js +73 -0
  51. package/api/loop/loopReturnsGet.js +46 -0
  52. package/api/peoplevox/peoplevox.constants.js +1 -1
  53. package/api/peoplevox/peoplevox.sessions.js +54 -0
  54. package/api/peoplevox/peoplevox.utils.js +67 -31
  55. package/api/peoplevox/peoplevoxGetSingle.js +7 -5
  56. package/api/peoplevox/peoplevoxOrderEdit.js +7 -5
  57. package/api/peoplevox/peoplevoxReportGet.js +11 -9
  58. package/api/pipelineSteps.js +49 -0
  59. package/api/shopify/shopify.utils.js +18 -24
  60. package/api/shopify/shopifyBulkMutationDo.js +211 -0
  61. package/api/shopify/shopifyBulkOperationGet.js +86 -0
  62. package/api/shopify/shopifyBulkOperationRunMutation.js +83 -0
  63. package/api/shopify/shopifyCheckoutAndAccountsConfigurationUpdate.js +79 -0
  64. package/api/shopify/shopifyCollectionGet.js +7 -7
  65. package/api/shopify/shopifyCustomerGet.js +6 -6
  66. package/api/shopify/shopifyGet.js +18 -13
  67. package/api/shopify/shopifyGetSingle.js +9 -9
  68. package/api/shopify/shopifyMutationDo.js +6 -6
  69. package/api/shopify/shopifyOrdersGet.js +11 -11
  70. package/api/shopify/shopifyStagedUploadCreate.js +96 -0
  71. package/api/shopify/shopifyTagsAdd.js +1 -1
  72. package/api/shopify/shopifyTagsAddBulk.js +90 -0
  73. package/api/shopify/shopifyTagsRemove.js +1 -1
  74. package/api/slack/slack.utils.js +10 -19
  75. package/api/slack/slackMessagePost.js +11 -11
  76. package/api/starshipit/starshipit.constants.js +8 -0
  77. package/api/starshipit/starshipit.utils.js +71 -0
  78. package/api/starshipit/starshipitAddressCreate.js +77 -0
  79. package/api/starshipit/starshipitAddressDelete.js +55 -0
  80. package/api/starshipit/starshipitAddressUpdate.js +69 -0
  81. package/api/starshipit/starshipitAddressesGet.js +52 -0
  82. package/api/starshipit/starshipitGet.js +146 -0
  83. package/api/starshipit/starshipitOrderDelete.js +102 -0
  84. package/api/starshipit/starshipitOrderGet.js +74 -0
  85. package/api/starshipit/starshipitOrderUpdate.js +109 -0
  86. package/api/starshipit/starshipitOrdersListShipped.js +64 -0
  87. package/api/starshipit/starshipitProductAdd.js +100 -0
  88. package/api/starshipit/starshipitProductsDelete.js +57 -0
  89. package/api/starshipit/starshipitProductsGet.js +49 -0
  90. package/api/starshipit/starshipitTrackingGet.js +69 -0
  91. package/api/stripe/_example.js +48 -0
  92. package/api/stripe/stripe.constants.js +5 -0
  93. package/api/stripe/stripe.utils.js +42 -0
  94. package/api/stripe/stripeCardCharge.js +98 -0
  95. package/api/stripe/stripeCardTokenCreate.js +70 -0
  96. package/api/stripe/stripeChargeCapture.js +63 -0
  97. package/api/stripe/stripeChargeCreate.js +70 -0
  98. package/api/stripe/stripeChargeGet.js +51 -0
  99. package/api/stripe/stripeChargesGet.js +52 -0
  100. package/api/stripe/stripeRefundCreate.js +64 -0
  101. package/api/stripe/stripeRefundGet.js +51 -0
  102. package/api/stripe/stripeRefundsGet.js +52 -0
  103. package/api/stripe/stripeTokenGet.js +51 -0
  104. package/api/stylearcade/stylearcade.constants.js +5 -0
  105. package/api/stylearcade/stylearcade.utils.js +40 -0
  106. package/api/stylearcade/stylearcadeDataGet.js +62 -0
  107. package/api/stylearcade/stylearcadeGet.js +133 -0
  108. package/api/stylearcade/stylearcadeMetadataGet.js +47 -0
  109. package/api/supabase/supabase.utils.js +52 -0
  110. package/api/supabase/supabaseRowDelete.js +95 -0
  111. package/api/supabase/supabaseRowGet.js +58 -0
  112. package/api/supabase/supabaseRowInsert.js +56 -0
  113. package/api/supabase/supabaseRowUpdate.js +58 -0
  114. package/api/supabase/supabaseRpc.js +61 -0
  115. package/api/supabase/supabaseTableGet.js +44 -0
  116. package/api/supabase/supabaseTableGetAll.js +86 -0
  117. package/api/threeclicks/threeclicks.constants.js +8 -0
  118. package/api/threeclicks/threeclicks.utils.js +119 -0
  119. package/api/threeclicks/threeclicksCollectionsGet.js +40 -0
  120. package/api/threeclicks/threeclicksGet.js +138 -0
  121. package/api/threeclicks/threeclicksKeycodeCreate.js +55 -0
  122. package/api/threeclicks/threeclicksKeycodeGet.js +47 -0
  123. package/api/threeclicks/threeclicksPurchaseOrderCreate.js +34 -0
  124. package/api/threeclicks/threeclicksPurchaseOrderCreateBulk.js +34 -0
  125. package/api/threeclicks/threeclicksPurchaseOrderGet.js +33 -0
  126. package/api/threeclicks/threeclicksPurchaseOrderQuantitiesGet.js +33 -0
  127. package/api/threeclicks/threeclicksPurchaseOrderQuantityCreate.js +34 -0
  128. package/api/threeclicks/threeclicksPurchaseOrderQuantityCreateBulk.js +34 -0
  129. package/api/threeclicks/threeclicksPurchaseOrderQuantityUpdate.js +46 -0
  130. package/api/threeclicks/threeclicksPurchaseOrderQuantityUpdateBulk.js +46 -0
  131. package/api/threeclicks/threeclicksPurchaseOrderUpdate.js +35 -0
  132. package/api/threeclicks/threeclicksPurchaseOrdersGet.js +30 -0
  133. package/api/threeclicks/threeclicksShipmentCreate.js +34 -0
  134. package/api/threeclicks/threeclicksShipmentGet.js +33 -0
  135. package/api/threeclicks/threeclicksShipmentOrderAdd.js +38 -0
  136. package/api/threeclicks/threeclicksShipmentOrderQuantityCreate.js +35 -0
  137. package/api/threeclicks/threeclicksShipmentQuantityUpdate.js +35 -0
  138. package/api/threeclicks/threeclicksShipmentStatusUpdate.js +45 -0
  139. package/api/threeclicks/threeclicksShipmentsGet.js +52 -0
  140. package/api/threeclicks/threeclicksSignatureCalculate.js +73 -0
  141. package/api/threeclicks/threeclicksStyleCodesGet.js +46 -0
  142. package/api/threeclicks/threeclicksStyleColourCreate.js +47 -0
  143. package/api/threeclicks/threeclicksStyleColourDelete.js +34 -0
  144. package/api/threeclicks/threeclicksStyleCreate.js +44 -0
  145. package/api/threeclicks/threeclicksStyleDelete.js +33 -0
  146. package/api/threeclicks/threeclicksStyleGet.js +43 -0
  147. package/api/threeclicks/threeclicksStylePriceUpdate.js +70 -0
  148. package/api/threeclicks/threeclicksStyleUpdate.js +47 -0
  149. package/api/threeclicks/threeclicksStylesGet.js +45 -0
  150. package/api/upstash/upstash.utils.js +36 -0
  151. package/api/upstash/upstashDel.js +46 -0
  152. package/api/upstash/upstashExists.js +46 -0
  153. package/api/upstash/upstashGet.js +46 -0
  154. package/api/upstash/upstashSet.js +64 -0
  155. package/api/utils.js +90 -76
  156. package/api/validators.js +1 -1
  157. package/api/workable/workable.constants.js +3 -0
  158. package/api/workable/workable.utils.js +41 -0
  159. package/api/workable/workableGet.js +151 -0
  160. package/api/workable/workableJobCandidateCreate.js +87 -0
  161. package/api/workable/workableJobGet.js +52 -0
  162. package/api/workable/workableJobMembersGet.js +52 -0
  163. package/api/workable/workableJobStagesGet.js +52 -0
  164. package/api/workable/workableJobsGet.js +78 -0
  165. package/api/yotpo/yotpo.utils.js +17 -22
  166. package/api/yotpo/yotpoCampaignsGet.js +6 -6
  167. package/api/yotpo/yotpoCustomerActionRecord.js +7 -7
  168. package/api/yotpo/yotpoCustomerAnniversaryGet.js +7 -7
  169. package/api/yotpo/yotpoCustomerAnniversarySet.js +7 -7
  170. package/api/yotpo/yotpoCustomerBirthdaySet.js +7 -7
  171. package/api/yotpo/yotpoCustomerGet.js +6 -6
  172. package/api/yotpo/yotpoCustomerPointsAdjust.js +7 -7
  173. package/api/yotpo/yotpoCustomerUpsert.js +7 -7
  174. package/api/yotpo/yotpoCustomersRecentGet.js +6 -6
  175. package/api/yotpo/yotpoRedemptionCreate.js +7 -7
  176. package/api/yotpo/yotpoRedemptionOptionsGet.js +6 -6
  177. package/api/yotpo/yotpoVipTiersGet.js +5 -5
  178. package/api/youtube/youtube.constants.js +5 -0
  179. package/api/youtube/youtube.utils.js +77 -0
  180. package/api/youtube/youtubeChannelVideosGet.js +25 -70
  181. package/hosting/.hosting.yml.sample +9 -11
  182. package/hosting/copyCredsToEnv.js +58 -2
  183. package/hosting/deployFromHostingYml.js +9 -2
  184. package/hosting/hosting.utils.js +3 -2
  185. package/package.json +3 -1
  186. package/server.utils.js +1 -0
@@ -0,0 +1,69 @@
1
+ // https://docs.github.com/en/rest/repos/repos#list-repositories-for-the-authenticated-user
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { githubGet } = require('../github/githubGet');
6
+ const { MAX_PER_PAGE } = require('../github/github.constants');
7
+
8
+ const argsWarden = new ArgsWarden([
9
+ ['credsPayload', credsValidator],
10
+ ]);
11
+
12
+ const githubReposGet = async (
13
+ credsPayload,
14
+ {
15
+ org,
16
+ type,
17
+ sort,
18
+ direction,
19
+ perPage,
20
+ ...getterOptions
21
+ } = {},
22
+ ) => {
23
+
24
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
25
+ if (rejectResponse) {
26
+ return rejectResponse;
27
+ }
28
+
29
+ const url = org ? `/orgs/${ org }/repos` : '/user/repos';
30
+
31
+ const params = {
32
+ ...type && { type },
33
+ ...sort && { sort },
34
+ ...direction && { direction },
35
+ };
36
+
37
+ return githubGet(credsPayload, url, {
38
+ params,
39
+ perPage: perPage ?? MAX_PER_PAGE,
40
+ ...getterOptions,
41
+ });
42
+ };
43
+
44
+ const funcApiConfig = {
45
+ argsWarden,
46
+ };
47
+
48
+ module.exports = {
49
+ githubReposGet,
50
+ funcApiConfig,
51
+ };
52
+
53
+ /*
54
+ curl -X POST "http://localhost:8000/githubReposGet" \
55
+ -H "Content-Type: application/json" \
56
+ -d '{
57
+ "credsPayload": { "credsPath": "github" }
58
+ }'
59
+
60
+ curl -X POST "http://localhost:8000/githubReposGet" \
61
+ -H "Content-Type: application/json" \
62
+ -d '{
63
+ "credsPayload": { "credsPath": "github" },
64
+ "options": {
65
+ "org": "GorgonFreeman",
66
+ "limit": 10
67
+ }
68
+ }'
69
+ */
@@ -0,0 +1,64 @@
1
+ // https://docs.github.com/en/rest/users/users#get-the-authenticated-user
2
+ // https://docs.github.com/en/rest/users/users#get-a-user
3
+
4
+ const { ArgsWarden } = require('../utils');
5
+ const { credsValidator } = require('../validators');
6
+ const { githubClient } = require('../github/github.utils');
7
+
8
+ const argsWarden = new ArgsWarden([
9
+ ['credsPayload', credsValidator],
10
+ ]);
11
+
12
+ const githubUserGet = async (
13
+ credsPayload,
14
+ {
15
+ username,
16
+ params,
17
+ apiVersion,
18
+ } = {},
19
+ ) => {
20
+
21
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
22
+ if (rejectResponse) {
23
+ return rejectResponse;
24
+ }
25
+
26
+ const url = username ? `/users/${ username }` : '/user';
27
+
28
+ return githubClient.fetch({
29
+ requestPayload: {
30
+ url,
31
+ params,
32
+ },
33
+ context: {
34
+ credsPayload,
35
+ apiVersion,
36
+ },
37
+ });
38
+ };
39
+
40
+ const funcApiConfig = {
41
+ argsWarden,
42
+ };
43
+
44
+ module.exports = {
45
+ githubUserGet,
46
+ funcApiConfig,
47
+ };
48
+
49
+ /*
50
+ curl -X POST "http://localhost:8000/githubUserGet" \
51
+ -H "Content-Type: application/json" \
52
+ -d '{
53
+ "credsPayload": { "credsPath": "github" }
54
+ }'
55
+
56
+ curl -X POST "http://localhost:8000/githubUserGet" \
57
+ -H "Content-Type: application/json" \
58
+ -d '{
59
+ "credsPayload": { "credsPath": "github" },
60
+ "options": {
61
+ "username": "GorgonFreeman"
62
+ }
63
+ }'
64
+ */
@@ -1,11 +1,11 @@
1
1
  const { LINEAR_GRAPHQL_URL } = require('../linear/linear.constants');
2
+ const { resolveCreds } = require('../pipelineSteps');
2
3
  const {
3
4
  FetchClient,
4
- Chain,
5
5
  fetchClientCommonSteps,
6
6
  } = require('../utils');
7
7
 
8
- const addUrlAndAuthHeaders = async (state) => {
8
+ const useAuthHeaders = async (state) => {
9
9
  const { requestPayload, context } = state;
10
10
  const { creds } = context;
11
11
  const { API_KEY } = creds;
@@ -16,7 +16,6 @@ const addUrlAndAuthHeaders = async (state) => {
16
16
  url: requestPayload.url || LINEAR_GRAPHQL_URL,
17
17
  method: requestPayload.method || 'post',
18
18
  headers: {
19
- 'Content-Type': 'application/json',
20
19
  Authorization: API_KEY,
21
20
  ...requestPayload.headers,
22
21
  },
@@ -24,18 +23,14 @@ const addUrlAndAuthHeaders = async (state) => {
24
23
  };
25
24
  };
26
25
 
27
- const linearClientRequestPreparer = new Chain([
28
- addUrlAndAuthHeaders,
29
- ]);
30
-
31
- const linearClientResponseInterpreter = new Chain([
32
- fetchClientCommonSteps.exitEarlyOnNotOk,
33
- fetchClientCommonSteps.exitEarlyOnGraphqlErrors,
34
- ]);
35
-
36
26
  const linearClient = new FetchClient({
37
- requestPreparer: linearClientRequestPreparer,
38
- responseInterpreter: linearClientResponseInterpreter,
27
+ pipeline: [
28
+ resolveCreds,
29
+ useAuthHeaders,
30
+ 'fetch',
31
+ fetchClientCommonSteps.exitEarlyOnNotOk,
32
+ fetchClientCommonSteps.exitEarlyOnGraphqlErrors,
33
+ ],
39
34
  });
40
35
 
41
36
  module.exports = {
@@ -1,6 +1,6 @@
1
1
  // https://linear.app/developers/graphql
2
2
 
3
- const { credsFromPayload, ArgsWarden } = require('../utils');
3
+ const { ArgsWarden } = require('../utils');
4
4
  const { credsValidator } = require('../validators');
5
5
  const { linearClient } = require('../linear/linear.utils');
6
6
 
@@ -24,15 +24,14 @@ const linearIssuesGet = async (
24
24
  return rejectResponse;
25
25
  }
26
26
 
27
- const creds = await credsFromPayload(credsPayload);
28
-
29
27
  const filter = teamId
30
28
  ? { team: { id: { eq: teamId } } }
31
29
  : undefined;
32
30
 
33
31
  const response = await linearClient.fetch({
34
- body: {
35
- query: `
32
+ requestPayload: {
33
+ body: {
34
+ query: `
36
35
  query IssuesGet($first: Int!, $filter: IssueFilter) {
37
36
  issues(first: $first, filter: $filter) {
38
37
  nodes {
@@ -58,12 +57,13 @@ const linearIssuesGet = async (
58
57
  }
59
58
  }
60
59
  `,
61
- variables: {
62
- first,
63
- ...(filter && { filter }),
60
+ variables: {
61
+ first,
62
+ ...(filter && { filter }),
63
+ },
64
64
  },
65
65
  },
66
- context: { creds },
66
+ context: { credsPayload },
67
67
  inspect,
68
68
  });
69
69
 
@@ -1,31 +1,37 @@
1
1
  const { DEFAULT_API_VERSION } = require('../logiwa/logiwa.constants');
2
2
  const { logiwaAuthGet } = require('../logiwa/logiwaAuthGet');
3
+ const { resolveCreds } = require('../pipelineSteps');
3
4
  const {
4
5
  FetchClient,
5
- Chain,
6
6
  appendUrlToBase,
7
- credsFromPayload,
8
7
  fetchClientCommonSteps,
9
8
  } = require('../utils');
10
9
 
11
- const addUrlAndAuthHeaders = async (state) => {
10
+ const useUrlAndAuthHeaders = async (state) => {
12
11
  const { requestPayload, context } = state;
13
- const { credsPayload, apiVersion = DEFAULT_API_VERSION } = context;
14
-
15
- const creds = context.creds ?? await credsFromPayload(credsPayload);
16
- const authResponse = await logiwaAuthGet(credsPayload);
17
- const { data } = authResponse;
18
- const { token } = data;
19
-
20
- // TODO: Handle failed auth
21
-
12
+ const {
13
+ apiVersion = DEFAULT_API_VERSION,
14
+ creds,
15
+ } = context;
16
+
17
+ const authResponse = await logiwaAuthGet(
18
+ { credsObject: creds },
19
+ { apiVersion },
20
+ );
21
+
22
+ if (!authResponse?.ok) {
23
+ return {
24
+ breakChain: true,
25
+ response: authResponse,
26
+ };
27
+ }
28
+
29
+ const { token } = authResponse.data;
22
30
  const { BASE_URL } = creds;
23
31
 
24
32
  return {
25
- context: {
26
- creds,
27
- },
28
33
  requestPayload: {
34
+ ...requestPayload,
29
35
  url: appendUrlToBase(`${ BASE_URL }/${ apiVersion }`, requestPayload.url),
30
36
  headers: {
31
37
  Authorization: `Bearer ${ token }`,
@@ -35,17 +41,13 @@ const addUrlAndAuthHeaders = async (state) => {
35
41
  };
36
42
  };
37
43
 
38
- const logiwaClientRequestPreparer = new Chain([
39
- addUrlAndAuthHeaders,
40
- ]);
41
-
42
- const logiwaClientResponseInterpreter = new Chain([
43
- fetchClientCommonSteps.exitEarlyOnNotOk,
44
- ]);
45
-
46
44
  const logiwaClient = new FetchClient({
47
- requestPreparer: logiwaClientRequestPreparer,
48
- responseInterpreter: logiwaClientResponseInterpreter,
45
+ pipeline: [
46
+ resolveCreds,
47
+ useUrlAndAuthHeaders,
48
+ 'fetch',
49
+ fetchClientCommonSteps.exitEarlyOnNotOk,
50
+ ],
49
51
  });
50
52
 
51
53
  module.exports = {
@@ -39,9 +39,11 @@ const logiwaInventoriesGet = async (
39
39
  };
40
40
 
41
41
  return logiwaClient.fetch({
42
- method: 'get',
43
- url: `/Inventory/list/i/${ page }/s/${ perPage }`,
44
- params,
42
+ requestPayload: {
43
+ method: 'get',
44
+ url: `/Inventory/list/i/${ page }/s/${ perPage }`,
45
+ params,
46
+ },
45
47
  context: {
46
48
  credsPayload,
47
49
  apiVersion,
@@ -26,8 +26,10 @@ const logiwaOrderGet = async (
26
26
  }
27
27
 
28
28
  return logiwaClient.fetch({
29
- method: 'get',
30
- url: `/ShipmentOrder/${ orderId }`,
29
+ requestPayload: {
30
+ method: 'get',
31
+ url: `/ShipmentOrder/${ orderId }`,
32
+ },
31
33
  context: {
32
34
  credsPayload,
33
35
  apiVersion,
@@ -57,9 +57,11 @@ const logiwaOrdersGet = async (
57
57
  };
58
58
 
59
59
  return logiwaClient.fetch({
60
- method: 'get',
61
- url: `/ShipmentOrder/list/i/${ page }/s/${ perPage }`,
62
- params,
60
+ requestPayload: {
61
+ method: 'get',
62
+ url: `/ShipmentOrder/list/i/${ page }/s/${ perPage }`,
63
+ params,
64
+ },
63
65
  context: {
64
66
  credsPayload,
65
67
  apiVersion,
@@ -26,8 +26,10 @@ const logiwaProductGet = async (
26
26
  }
27
27
 
28
28
  return logiwaClient.fetch({
29
- method: 'get',
30
- url: `/Product/detail/${ productId }`,
29
+ requestPayload: {
30
+ method: 'get',
31
+ url: `/Product/detail/${ productId }`,
32
+ },
31
33
  context: {
32
34
  credsPayload,
33
35
  apiVersion,
@@ -45,9 +45,11 @@ const logiwaProductsGet = async (
45
45
  };
46
46
 
47
47
  return logiwaClient.fetch({
48
- method: 'get',
49
- url: `/Product/list/i/${ page }/s/${ perPage }`,
50
- params,
48
+ requestPayload: {
49
+ method: 'get',
50
+ url: `/Product/list/i/${ page }/s/${ perPage }`,
51
+ params,
52
+ },
51
53
  context: {
52
54
  credsPayload,
53
55
  apiVersion,
@@ -100,9 +100,11 @@ const logiwaReportGetAvailableToPromiseSingle = async (
100
100
  }
101
101
 
102
102
  return logiwaClient.fetch({
103
- method: 'get',
104
- url: `/Report/AvailableToPromise/i/${ page }/s/${ perPage }`,
105
- params,
103
+ requestPayload: {
104
+ method: 'get',
105
+ url: `/Report/AvailableToPromise/i/${ page }/s/${ perPage }`,
106
+ params,
107
+ },
106
108
  context: {
107
109
  credsPayload,
108
110
  apiVersion,
@@ -33,9 +33,11 @@ const logiwaReportGetInventoryCalculation = async (
33
33
  };
34
34
 
35
35
  return logiwaClient.fetch({
36
- method: 'get',
37
- url: `/Report/InventoryCalculation/i/${ page }/s/${ perPage }`,
38
- params,
36
+ requestPayload: {
37
+ method: 'get',
38
+ url: `/Report/InventoryCalculation/i/${ page }/s/${ perPage }`,
39
+ params,
40
+ },
39
41
  context: {
40
42
  credsPayload,
41
43
  apiVersion,
@@ -37,9 +37,11 @@ const logiwaReportGetInventorySnapshot = async (
37
37
  };
38
38
 
39
39
  return logiwaClient.fetch({
40
- method: 'get',
41
- url: `/Report/InventorySnapshot/i/${ page }/s/${ perPage }`,
42
- params,
40
+ requestPayload: {
41
+ method: 'get',
42
+ url: `/Report/InventorySnapshot/i/${ page }/s/${ perPage }`,
43
+ params,
44
+ },
43
45
  context: {
44
46
  credsPayload,
45
47
  apiVersion,
@@ -43,9 +43,11 @@ const logiwaReportGetTotalInventory = async (
43
43
  };
44
44
 
45
45
  return logiwaClient.fetch({
46
- method: 'get',
47
- url: `/Report/TotalInventory/i/${ page }/s/${ perPage }`,
48
- params,
46
+ requestPayload: {
47
+ method: 'get',
48
+ url: `/Report/TotalInventory/i/${ page }/s/${ perPage }`,
49
+ params,
50
+ },
49
51
  context: {
50
52
  credsPayload,
51
53
  apiVersion,
@@ -26,8 +26,10 @@ const logiwaWebhookStatusGet = async (
26
26
  }
27
27
 
28
28
  return logiwaClient.fetch({
29
- method: 'get',
30
- url: `/Webhook/status/${ subscriptionId }`,
29
+ requestPayload: {
30
+ method: 'get',
31
+ url: `/Webhook/status/${ subscriptionId }`,
32
+ },
31
33
  context: {
32
34
  credsPayload,
33
35
  apiVersion,
@@ -30,12 +30,14 @@ const logiwaWebhookSubscribe = async (
30
30
  }
31
31
 
32
32
  return logiwaClient.fetch({
33
- method: 'post',
34
- url: '/Webhook/create',
35
- body: {
36
- topic,
37
- address: url,
38
- ...(clientIdentifier ? { clientIdentifier } : { ignoreClient: true }),
33
+ requestPayload: {
34
+ method: 'post',
35
+ url: '/Webhook/create',
36
+ body: {
37
+ topic,
38
+ address: url,
39
+ ...(clientIdentifier ? { clientIdentifier } : { ignoreClient: true }),
40
+ },
39
41
  },
40
42
  context: {
41
43
  credsPayload,
@@ -26,8 +26,10 @@ const logiwaWebhookUnsubscribe = async (
26
26
  }
27
27
 
28
28
  return logiwaClient.fetch({
29
- method: 'delete',
30
- url: `/Webhook/unsubscribe/${ subscriptionId }`,
29
+ requestPayload: {
30
+ method: 'delete',
31
+ url: `/Webhook/unsubscribe/${ subscriptionId }`,
32
+ },
31
33
  context: {
32
34
  credsPayload,
33
35
  apiVersion,
@@ -21,8 +21,10 @@ const logiwaWebhooksGet = async (
21
21
  }
22
22
 
23
23
  return logiwaClient.fetch({
24
- method: 'get',
25
- url: '/Webhook/list',
24
+ requestPayload: {
25
+ method: 'get',
26
+ url: '/Webhook/list',
27
+ },
26
28
  context: {
27
29
  credsPayload,
28
30
  apiVersion,
@@ -0,0 +1,7 @@
1
+ const LOOP_API_BASE_URL = 'https://api.loopreturns.com/api/v1';
2
+ const MAX_PER_PAGE = 750;
3
+
4
+ module.exports = {
5
+ LOOP_API_BASE_URL,
6
+ MAX_PER_PAGE,
7
+ };
@@ -0,0 +1,37 @@
1
+ const { LOOP_API_BASE_URL } = require('../loop/loop.constants');
2
+ const { resolveCreds, useBaseUrl } = require('../pipelineSteps');
3
+ const {
4
+ FetchClient,
5
+ fetchClientCommonSteps,
6
+ } = require('../utils');
7
+
8
+ // TODO: Allow creds failure (e.g. missing API_KEY → INVALID_CREDS before fetch)
9
+ const useAuthHeaders = async (state) => {
10
+ const { requestPayload, context } = state;
11
+ const { creds } = context;
12
+ const { API_KEY } = creds;
13
+
14
+ return {
15
+ requestPayload: {
16
+ ...requestPayload,
17
+ headers: {
18
+ 'X-Authorization': API_KEY,
19
+ ...requestPayload.headers,
20
+ },
21
+ },
22
+ };
23
+ };
24
+
25
+ const loopClient = new FetchClient({
26
+ pipeline: [
27
+ resolveCreds,
28
+ useBaseUrl(LOOP_API_BASE_URL),
29
+ useAuthHeaders,
30
+ 'fetch',
31
+ fetchClientCommonSteps.exitEarlyOnNotOk,
32
+ ],
33
+ });
34
+
35
+ module.exports = {
36
+ loopClient,
37
+ };
@@ -0,0 +1,42 @@
1
+ const { ArgsWarden } = require('../utils');
2
+ const { credsValidator } = require('../validators');
3
+ const { loopGet } = require('../loop/loopGet');
4
+
5
+ const argsWarden = new ArgsWarden([
6
+ ['credsPayload', credsValidator],
7
+ ]);
8
+
9
+ const loopAllowlistItemsGet = async (
10
+ credsPayload,
11
+ {
12
+ ...getterOptions
13
+ } = {},
14
+ ) => {
15
+
16
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
17
+ if (rejectResponse) {
18
+ return rejectResponse;
19
+ }
20
+
21
+ return loopGet(credsPayload, '/allowlists', {
22
+ resultsKey: 'data',
23
+ ...getterOptions,
24
+ });
25
+ };
26
+
27
+ const funcApiConfig = {
28
+ argsWarden,
29
+ };
30
+
31
+ module.exports = {
32
+ loopAllowlistItemsGet,
33
+ funcApiConfig,
34
+ };
35
+
36
+ /*
37
+ curl -X POST "http://localhost:8000/loopAllowlistItemsGet" \
38
+ -H "Content-Type: application/json" \
39
+ -d '{
40
+ "credsPayload": { "credsPath": "loop.au" }
41
+ }'
42
+ */
@@ -0,0 +1,46 @@
1
+ const { ArgsWarden } = require('../utils');
2
+ const { credsValidator } = require('../validators');
3
+ const { loopGet } = require('../loop/loopGet');
4
+
5
+ const argsWarden = new ArgsWarden([
6
+ ['credsPayload', credsValidator],
7
+ ]);
8
+
9
+ const loopBlocklistItemsGet = async (
10
+ credsPayload,
11
+ {
12
+ ...getterOptions
13
+ } = {},
14
+ ) => {
15
+
16
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
17
+ if (rejectResponse) {
18
+ return rejectResponse;
19
+ }
20
+
21
+ return loopGet(credsPayload, '/blocklists', {
22
+ resultsKey: 'data',
23
+ ...getterOptions,
24
+ });
25
+ };
26
+
27
+ const funcApiConfig = {
28
+ argsWarden,
29
+ };
30
+
31
+ module.exports = {
32
+ loopBlocklistItemsGet,
33
+ funcApiConfig,
34
+ };
35
+
36
+ /*
37
+ curl -X POST "http://localhost:8000/loopBlocklistItemsGet" \
38
+ -H "Content-Type: application/json" \
39
+ -d '{
40
+ "credsPayload": { "credsPath": "loop.au" },
41
+ "options": {
42
+ "limit": 20,
43
+ "perPage": 7
44
+ }
45
+ }'
46
+ */