@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,58 @@
1
+ const { ArgsWarden } = require('../utils');
2
+ const { credsValidator } = require('../validators');
3
+ const { getSupabaseClient, supabaseInterpreter } = require('../supabase/supabase.utils');
4
+
5
+ const argsWarden = new ArgsWarden([
6
+ ['credsPayload', credsValidator],
7
+ ['tableName'],
8
+ ['match'],
9
+ ['updatePayload'],
10
+ ]);
11
+
12
+ const supabaseRowUpdate = async (
13
+ credsPayload,
14
+ tableName,
15
+ match,
16
+ updatePayload,
17
+ ) => {
18
+
19
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
20
+ credsPayload,
21
+ tableName,
22
+ match,
23
+ updatePayload,
24
+ });
25
+ if (rejectResponse) {
26
+ return rejectResponse;
27
+ }
28
+
29
+ const client = await getSupabaseClient(credsPayload);
30
+ const response = await client
31
+ .from(tableName)
32
+ .update(updatePayload)
33
+ .match(match)
34
+ .select()
35
+ ;
36
+
37
+ return supabaseInterpreter(response);
38
+ };
39
+
40
+ const funcApiConfig = {
41
+ argsWarden,
42
+ };
43
+
44
+ module.exports = {
45
+ supabaseRowUpdate,
46
+ funcApiConfig,
47
+ };
48
+
49
+ /*
50
+ curl -X POST "http://localhost:8000/supabaseRowUpdate" \
51
+ -H "Content-Type: application/json" \
52
+ -d '{
53
+ "credsPayload": { "credsPath": "supabase.mushroom_kingdom" },
54
+ "tableName": "powerups",
55
+ "match": { "name": "star" },
56
+ "updatePayload": { "duration_seconds": 12 }
57
+ }'
58
+ */
@@ -0,0 +1,61 @@
1
+ // https://supabase.com/docs/reference/javascript/rpc
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { getSupabaseClient, supabaseInterpreter } = require('../supabase/supabase.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['rpcName'],
10
+ ]);
11
+
12
+ const supabaseRpc = async (
13
+ credsPayload,
14
+ rpcName,
15
+ {
16
+ rpcArgs,
17
+ rpcOptions,
18
+ useMaybeSingle = false,
19
+ } = {},
20
+ ) => {
21
+
22
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
23
+ credsPayload,
24
+ rpcName,
25
+ });
26
+ if (rejectResponse) {
27
+ return rejectResponse;
28
+ }
29
+
30
+ const client = await getSupabaseClient(credsPayload);
31
+ let query = client.rpc(rpcName, rpcArgs, rpcOptions);
32
+
33
+ if (useMaybeSingle) {
34
+ query = query.maybeSingle();
35
+ }
36
+
37
+ const response = await query;
38
+ return supabaseInterpreter(response);
39
+ };
40
+
41
+ const funcApiConfig = {
42
+ argsWarden,
43
+ };
44
+
45
+ module.exports = {
46
+ supabaseRpc,
47
+ funcApiConfig,
48
+ };
49
+
50
+ /*
51
+ curl -X POST "http://localhost:8000/supabaseRpc" \
52
+ -H "Content-Type: application/json" \
53
+ -d '{
54
+ "credsPayload": { "credsPath": "supabase.mushroom_kingdom" },
55
+ "rpcName": "grant_powerup",
56
+ "options": {
57
+ "rpcArgs": { "player": "mario", "powerup": "1up_mushroom" },
58
+ "useMaybeSingle": true
59
+ }
60
+ }'
61
+ */
@@ -0,0 +1,44 @@
1
+ const { ArgsWarden } = require('../utils');
2
+ const { credsValidator } = require('../validators');
3
+ const { getSupabaseClient, supabaseInterpreter } = require('../supabase/supabase.utils');
4
+
5
+ const argsWarden = new ArgsWarden([
6
+ ['credsPayload', credsValidator],
7
+ ['tableName'],
8
+ ]);
9
+
10
+ const supabaseTableGet = async (
11
+ credsPayload,
12
+ tableName,
13
+ ) => {
14
+
15
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
16
+ credsPayload,
17
+ tableName,
18
+ });
19
+ if (rejectResponse) {
20
+ return rejectResponse;
21
+ }
22
+
23
+ const client = await getSupabaseClient(credsPayload);
24
+ const response = await client.from(tableName).select('*');
25
+ return supabaseInterpreter(response);
26
+ };
27
+
28
+ const funcApiConfig = {
29
+ argsWarden,
30
+ };
31
+
32
+ module.exports = {
33
+ supabaseTableGet,
34
+ funcApiConfig,
35
+ };
36
+
37
+ /*
38
+ curl -X POST "http://localhost:8000/supabaseTableGet" \
39
+ -H "Content-Type: application/json" \
40
+ -d '{
41
+ "credsPayload": { "credsPath": "supabase.mushroom_kingdom" },
42
+ "tableName": "powerups"
43
+ }'
44
+ */
@@ -0,0 +1,86 @@
1
+ const { HOSTED } = require('../constants');
2
+ const { ArgsWarden } = require('../utils');
3
+ const { credsValidator } = require('../validators');
4
+ const { getSupabaseClient } = require('../supabase/supabase.utils');
5
+
6
+ const argsWarden = new ArgsWarden([
7
+ ['credsPayload', credsValidator],
8
+ ['tableName'],
9
+ ]);
10
+
11
+ const supabaseTableGetAll = async (
12
+ credsPayload,
13
+ tableName,
14
+ {
15
+ orderBy = 'id',
16
+ } = {},
17
+ ) => {
18
+
19
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
20
+ credsPayload,
21
+ tableName,
22
+ });
23
+ if (rejectResponse) {
24
+ return rejectResponse;
25
+ }
26
+
27
+ const client = await getSupabaseClient(credsPayload);
28
+
29
+ const rowsCountResponse = await client.from(tableName).select('*', { count: 'exact', head: true });
30
+ const { count: rowsCount } = rowsCountResponse;
31
+
32
+ const PAGE_SIZE = 1000;
33
+ let rowsFetched = 0;
34
+ let rows = [];
35
+
36
+ while (rowsFetched < rowsCount) {
37
+ const pageRowsResponse = await client
38
+ .from(tableName)
39
+ .select('*')
40
+ .order(orderBy)
41
+ .range(rowsFetched, (rowsFetched + PAGE_SIZE) - 1)
42
+ ;
43
+ const { data, error } = pageRowsResponse;
44
+
45
+ if (error) {
46
+ return {
47
+ ok: false,
48
+ error: {
49
+ message: error.message,
50
+ },
51
+ };
52
+ }
53
+
54
+ if (!data) {
55
+ break;
56
+ }
57
+
58
+ rows.push(...data);
59
+ rowsFetched += PAGE_SIZE;
60
+ !HOSTED && console.log(`${ rows.length } / ${ rowsCount }`);
61
+ }
62
+
63
+ return {
64
+ ok: true,
65
+ data: rows,
66
+ };
67
+ };
68
+
69
+ const funcApiConfig = {
70
+ argsWarden,
71
+ };
72
+
73
+ module.exports = {
74
+ supabaseTableGetAll,
75
+ funcApiConfig,
76
+ };
77
+
78
+ /*
79
+ curl -X POST "http://localhost:8000/supabaseTableGetAll" \
80
+ -H "Content-Type: application/json" \
81
+ -d '{
82
+ "credsPayload": { "credsPath": "supabase.mushroom_kingdom" },
83
+ "tableName": "powerups",
84
+ "options": { "orderBy": "name" }
85
+ }'
86
+ */
@@ -0,0 +1,8 @@
1
+ const API_BASE_PATH = '/api-user/v1';
2
+
3
+ const API_REFERENCE_URL = 'https://g40-server.instance.3clickscloud.com/swagger-ui/index.html';
4
+
5
+ module.exports = {
6
+ API_BASE_PATH,
7
+ API_REFERENCE_URL,
8
+ };
@@ -0,0 +1,119 @@
1
+ const crypto = require('crypto');
2
+ const { API_BASE_PATH } = require('../threeclicks/threeclicks.constants');
3
+ const { resolveCreds } = require('../pipelineSteps');
4
+ const {
5
+ FetchClient,
6
+ appendUrlToBase,
7
+ fetchClientCommonSteps,
8
+ } = require('../utils');
9
+
10
+ const nowAsUnixTimestamp = () => Math.floor(Date.now() / 1000);
11
+
12
+ const threeclicksSignatureCalculate = ({
13
+ creds,
14
+ method,
15
+ data,
16
+ }) => {
17
+ const {
18
+ API_KEY,
19
+ API_SECRET,
20
+ } = creds;
21
+
22
+ const timestamp = nowAsUnixTimestamp();
23
+ const stitchedString = `${ API_KEY }${ API_SECRET }${ method }${
24
+ data ? JSON.stringify(data) : ''
25
+ }${ timestamp }`;
26
+
27
+ const signature = crypto
28
+ .createHmac('sha256', API_SECRET)
29
+ .update(stitchedString)
30
+ .digest('hex');
31
+
32
+ return {
33
+ signature,
34
+ timestamp,
35
+ };
36
+ };
37
+
38
+ const getSignatureData = (requestPayload) => {
39
+ const method = (requestPayload.method || 'get').toLowerCase();
40
+
41
+ if (method === 'get') {
42
+ return requestPayload.params ?? {};
43
+ }
44
+
45
+ return requestPayload.body ?? {};
46
+ };
47
+
48
+ const useThreeclicksUrlAndAuth = async (state) => {
49
+ const { requestPayload, context } = state;
50
+ const { creds } = context;
51
+ const {
52
+ API_KEY,
53
+ API_DOMAIN,
54
+ } = creds;
55
+
56
+ const method = (requestPayload.method || 'get').toLowerCase();
57
+ const signatureData = getSignatureData({
58
+ ...requestPayload,
59
+ method,
60
+ });
61
+
62
+ const { signature, timestamp } = threeclicksSignatureCalculate({
63
+ creds,
64
+ method,
65
+ data: signatureData,
66
+ });
67
+
68
+ const baseUrl = `https://${ API_DOMAIN }${ API_BASE_PATH }`;
69
+
70
+ return {
71
+ requestPayload: {
72
+ ...requestPayload,
73
+ method,
74
+ url: appendUrlToBase(baseUrl, requestPayload.url),
75
+ headers: {
76
+ 'X-Api-Key': API_KEY,
77
+ 'X-Api-Signature': signature,
78
+ 'X-Api-Timestamp': String(timestamp),
79
+ ...requestPayload.headers,
80
+ },
81
+ },
82
+ };
83
+ };
84
+
85
+ const interpretThreeclicksResponse = async (state) => {
86
+ const { response } = state;
87
+ const { success, message } = response?.data?.result ?? {};
88
+
89
+ if (response?.ok && success === false) {
90
+ return {
91
+ response: {
92
+ ok: false,
93
+ error: {
94
+ message,
95
+ details: response.data?.result,
96
+ },
97
+ },
98
+ breakChain: true,
99
+ };
100
+ }
101
+
102
+ return {};
103
+ };
104
+
105
+ const threeclicksClient = new FetchClient({
106
+ pipeline: [
107
+ resolveCreds,
108
+ useThreeclicksUrlAndAuth,
109
+ 'fetch',
110
+ fetchClientCommonSteps.exitEarlyOnNotOk,
111
+ interpretThreeclicksResponse,
112
+ ],
113
+ });
114
+
115
+ module.exports = {
116
+ threeclicksClient,
117
+ threeclicksSignatureCalculate,
118
+ getSignatureData,
119
+ };
@@ -0,0 +1,40 @@
1
+ // https://g40-server.instance.3clickscloud.com/swagger-ui/index.html#operations-v1_-_Site_Settings_>_Style-list_5
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { threeclicksClient } = require('../threeclicks/threeclicks.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ]);
10
+
11
+ const threeclicksCollectionsGet = async (credsPayload) => {
12
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
13
+ if (rejectResponse) return rejectResponse;
14
+ return threeclicksClient.fetch({
15
+ requestPayload: {
16
+ url: '/site-settings/style/collection',
17
+ method: 'get',
18
+ },
19
+ context: {
20
+ credsPayload,
21
+ },
22
+ });
23
+ };
24
+
25
+ const funcApiConfig = {
26
+ argsWarden,
27
+ };
28
+
29
+ module.exports = {
30
+ threeclicksCollectionsGet,
31
+ funcApiConfig,
32
+ };
33
+
34
+ /*
35
+ curl -X POST "http://localhost:8000/threeclicksCollectionsGet" \
36
+ -H "Content-Type: application/json" \
37
+ -d '{
38
+ "credsPayload": { "credsPath": "threeclicks" }
39
+ }'
40
+ */
@@ -0,0 +1,138 @@
1
+ // https://g40-server.instance.3clickscloud.com/swagger-ui/index.html#operations-tag-v1_-_Search_>_Advanced
2
+
3
+ const { ArgsWarden, Getter } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { threeclicksClient } = require('../threeclicks/threeclicks.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['url'],
10
+ ]);
11
+
12
+ const threeclicksGetPacket = async (
13
+ credsPayload,
14
+ url,
15
+ {
16
+ params,
17
+ page = '1',
18
+ } = {},
19
+ ) => {
20
+ const paramsWithPage = {
21
+ ...params,
22
+ page: String(page),
23
+ };
24
+
25
+ return threeclicksClient.fetch({
26
+ requestPayload: {
27
+ url,
28
+ method: 'get',
29
+ params: paramsWithPage,
30
+ },
31
+ context: {
32
+ credsPayload,
33
+ },
34
+ });
35
+ };
36
+
37
+ const threeclicksGetPaginator = async (currentParams, response) => {
38
+ if (!response?.ok) {
39
+ return [true];
40
+ }
41
+
42
+ const pageCount = response?.data?.content?.pagination_data?.page_count;
43
+ const currentPage = parseInt(currentParams.options.page, 10);
44
+
45
+ if (!pageCount || currentPage >= pageCount) {
46
+ return [true];
47
+ }
48
+
49
+ const { args, options } = currentParams;
50
+
51
+ return [false, {
52
+ args,
53
+ options: {
54
+ ...options,
55
+ page: String(currentPage + 1),
56
+ },
57
+ }];
58
+ };
59
+
60
+ const threeclicksGetDigester = (response) => {
61
+ if (!response?.ok) {
62
+ return [];
63
+ }
64
+
65
+ return response?.data?.content?.pagination_data?.result_data ?? [];
66
+ };
67
+
68
+ const threeclicksGet = async (
69
+ returnGetter,
70
+
71
+ credsPayload,
72
+ url,
73
+ {
74
+ params,
75
+ page = '1',
76
+ ...getterOptions
77
+ } = {},
78
+ ) => {
79
+
80
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
81
+ credsPayload,
82
+ url,
83
+ });
84
+ if (rejectResponse) {
85
+ return rejectResponse;
86
+ }
87
+
88
+ const getter = new Getter(
89
+ {
90
+ args: [credsPayload, url],
91
+ options: {
92
+ params,
93
+ page,
94
+ },
95
+ },
96
+ {
97
+ func: threeclicksGetPacket,
98
+ digester: threeclicksGetDigester,
99
+ paginator: threeclicksGetPaginator,
100
+ ...getterOptions,
101
+ },
102
+ );
103
+
104
+ if (returnGetter) {
105
+ return getter;
106
+ }
107
+
108
+ const data = await getter.run({ returnAll: true });
109
+
110
+ return {
111
+ ok: true,
112
+ data,
113
+ };
114
+ };
115
+
116
+ const funcApiConfig = {
117
+ argsWarden,
118
+ };
119
+
120
+ module.exports = {
121
+ threeclicksGet: (...args) => threeclicksGet(false, ...args),
122
+ threeclicksGetter: (...args) => threeclicksGet(true, ...args),
123
+ funcApiConfig,
124
+ };
125
+
126
+ /*
127
+ curl -X POST "http://localhost:8000/threeclicksGet" \
128
+ -H "Content-Type: application/json" \
129
+ -d '{
130
+ "credsPayload": { "credsPath": "threeclicks" },
131
+ "url": "/search/advanced/style",
132
+ "options": {
133
+ "params": {
134
+ "mode": "all"
135
+ }
136
+ }
137
+ }'
138
+ */
@@ -0,0 +1,55 @@
1
+ // https://g40-server.instance.3clickscloud.com/swagger-ui/index.html#operations-v1_-_Style_>_Codes-keycodeCreate
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { threeclicksClient } = require('../threeclicks/threeclicks.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['styleNumber'],
10
+ ['styleColoursizeId'],
11
+ ['size'],
12
+ ]);
13
+
14
+ const threeclicksKeycodeCreate = async (
15
+ credsPayload,
16
+ styleNumber,
17
+ styleColoursizeId,
18
+ size,
19
+ {
20
+ keycode = `${ styleNumber }-${ size }`,
21
+ } = {},
22
+ ) => {
23
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
24
+ credsPayload,
25
+ styleNumber,
26
+ styleColoursizeId,
27
+ size,
28
+ });
29
+ if (rejectResponse) return rejectResponse;
30
+
31
+ return threeclicksClient.fetch({
32
+ requestPayload: {
33
+ url: '/style/codes/keycode',
34
+ method: 'post',
35
+ body: {
36
+ size,
37
+ style_coloursize_id: styleColoursizeId,
38
+ style_number: styleNumber,
39
+ keycode,
40
+ },
41
+ },
42
+ context: {
43
+ credsPayload,
44
+ },
45
+ });
46
+ };
47
+
48
+ const funcApiConfig = {
49
+ argsWarden,
50
+ };
51
+
52
+ module.exports = {
53
+ threeclicksKeycodeCreate,
54
+ funcApiConfig,
55
+ };
@@ -0,0 +1,47 @@
1
+ // https://g40-server.instance.3clickscloud.com/swagger-ui/index.html#operations-v1_-_Style_>_Codes-keycodeGet_1
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { threeclicksClient } = require('../threeclicks/threeclicks.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['styleNumber'],
10
+ ['styleColoursizeId'],
11
+ ['size'],
12
+ ]);
13
+
14
+ const threeclicksKeycodeGet = async (credsPayload, styleNumber, styleColoursizeId, size) => {
15
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
16
+ credsPayload,
17
+ styleNumber,
18
+ styleColoursizeId,
19
+ size,
20
+ });
21
+ if (rejectResponse) return rejectResponse;
22
+
23
+ const params = {
24
+ size,
25
+ style_coloursize_id: styleColoursizeId,
26
+ };
27
+
28
+ return threeclicksClient.fetch({
29
+ requestPayload: {
30
+ url: `/style/codes/keycode/${ styleNumber }`,
31
+ method: 'get',
32
+ params,
33
+ },
34
+ context: {
35
+ credsPayload,
36
+ },
37
+ });
38
+ };
39
+
40
+ const funcApiConfig = {
41
+ argsWarden,
42
+ };
43
+
44
+ module.exports = {
45
+ threeclicksKeycodeGet,
46
+ funcApiConfig,
47
+ };
@@ -0,0 +1,34 @@
1
+ // https://g40-server.instance.3clickscloud.com/swagger-ui/index.html#operations-v1_-_Order-createNormal
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { threeclicksClient } = require('../threeclicks/threeclicks.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['orderPayload'],
10
+ ]);
11
+
12
+ const threeclicksPurchaseOrderCreate = async (credsPayload, orderPayload) => {
13
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload, orderPayload });
14
+ if (rejectResponse) return rejectResponse;
15
+ return threeclicksClient.fetch({
16
+ requestPayload: {
17
+ url: '/order/normal',
18
+ method: 'post',
19
+ body: orderPayload ,
20
+ },
21
+ context: {
22
+ credsPayload,
23
+ },
24
+ });
25
+ };
26
+
27
+ const funcApiConfig = {
28
+ argsWarden,
29
+ };
30
+
31
+ module.exports = {
32
+ threeclicksPurchaseOrderCreate,
33
+ funcApiConfig,
34
+ };