@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,74 @@
1
+ // https://docs.github.com/en/rest/issues/issues#list-repository-issues
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
+ ['owner'],
11
+ ['repo'],
12
+ ]);
13
+
14
+ const githubIssuesGet = async (
15
+ credsPayload,
16
+ owner,
17
+ repo,
18
+ {
19
+ state,
20
+ labels,
21
+ sort,
22
+ direction,
23
+ since,
24
+ perPage,
25
+ ...getterOptions
26
+ } = {},
27
+ ) => {
28
+
29
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
30
+ credsPayload,
31
+ owner,
32
+ repo,
33
+ });
34
+ if (rejectResponse) {
35
+ return rejectResponse;
36
+ }
37
+
38
+ const params = {
39
+ ...state && { state },
40
+ ...labels && { labels },
41
+ ...sort && { sort },
42
+ ...direction && { direction },
43
+ ...since && { since },
44
+ };
45
+
46
+ return githubGet(credsPayload, `/repos/${ owner }/${ repo }/issues`, {
47
+ params,
48
+ perPage: perPage ?? MAX_PER_PAGE,
49
+ ...getterOptions,
50
+ });
51
+ };
52
+
53
+ const funcApiConfig = {
54
+ argsWarden,
55
+ };
56
+
57
+ module.exports = {
58
+ githubIssuesGet,
59
+ funcApiConfig,
60
+ };
61
+
62
+ /*
63
+ curl -X POST "http://localhost:8000/githubIssuesGet" \
64
+ -H "Content-Type: application/json" \
65
+ -d '{
66
+ "credsPayload": { "credsPath": "github" },
67
+ "owner": "GorgonFreeman",
68
+ "repo": "mineral",
69
+ "options": {
70
+ "state": "open",
71
+ "limit": 10
72
+ }
73
+ }'
74
+ */
@@ -0,0 +1,74 @@
1
+ // https://docs.github.com/en/rest/pulls/pulls#create-a-pull-request
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { githubClient } = require('../github/github.utils');
6
+
7
+ const pullRequestPayloadValidator = (pullRequestPayload) => {
8
+ return Boolean(pullRequestPayload?.head) && Boolean(pullRequestPayload?.base);
9
+ };
10
+
11
+ const argsWarden = new ArgsWarden([
12
+ ['credsPayload', credsValidator],
13
+ ['owner'],
14
+ ['repo'],
15
+ ['pullRequestPayload', pullRequestPayloadValidator],
16
+ ]);
17
+
18
+ const githubPullRequestCreate = async (
19
+ credsPayload,
20
+ owner,
21
+ repo,
22
+ pullRequestPayload,
23
+ {
24
+ apiVersion,
25
+ } = {},
26
+ ) => {
27
+
28
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
29
+ credsPayload,
30
+ owner,
31
+ repo,
32
+ pullRequestPayload,
33
+ });
34
+ if (rejectResponse) {
35
+ return rejectResponse;
36
+ }
37
+
38
+ return githubClient.fetch({
39
+ requestPayload: {
40
+ method: 'post',
41
+ url: `/repos/${ owner }/${ repo }/pulls`,
42
+ body: pullRequestPayload,
43
+ },
44
+ context: {
45
+ credsPayload,
46
+ apiVersion,
47
+ },
48
+ });
49
+ };
50
+
51
+ const funcApiConfig = {
52
+ argsWarden,
53
+ };
54
+
55
+ module.exports = {
56
+ githubPullRequestCreate,
57
+ funcApiConfig,
58
+ };
59
+
60
+ /*
61
+ curl -X POST "http://localhost:8000/githubPullRequestCreate" \
62
+ -H "Content-Type: application/json" \
63
+ -d '{
64
+ "credsPayload": { "credsPath": "github" },
65
+ "owner": "GorgonFreeman",
66
+ "repo": "mineral",
67
+ "pullRequestPayload": {
68
+ "title": "Amazing new feature",
69
+ "head": "feature-branch",
70
+ "base": "main",
71
+ "body": "Please review"
72
+ }
73
+ }'
74
+ */
@@ -0,0 +1,65 @@
1
+ // https://docs.github.com/en/rest/pulls/pulls#get-a-pull-request
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { githubClient } = require('../github/github.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['owner'],
10
+ ['repo'],
11
+ ['pullNumber'],
12
+ ]);
13
+
14
+ const githubPullRequestGet = async (
15
+ credsPayload,
16
+ owner,
17
+ repo,
18
+ pullNumber,
19
+ {
20
+ params,
21
+ apiVersion,
22
+ } = {},
23
+ ) => {
24
+
25
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
26
+ credsPayload,
27
+ owner,
28
+ repo,
29
+ pullNumber,
30
+ });
31
+ if (rejectResponse) {
32
+ return rejectResponse;
33
+ }
34
+
35
+ return githubClient.fetch({
36
+ requestPayload: {
37
+ url: `/repos/${ owner }/${ repo }/pulls/${ pullNumber }`,
38
+ params,
39
+ },
40
+ context: {
41
+ credsPayload,
42
+ apiVersion,
43
+ },
44
+ });
45
+ };
46
+
47
+ const funcApiConfig = {
48
+ argsWarden,
49
+ };
50
+
51
+ module.exports = {
52
+ githubPullRequestGet,
53
+ funcApiConfig,
54
+ };
55
+
56
+ /*
57
+ curl -X POST "http://localhost:8000/githubPullRequestGet" \
58
+ -H "Content-Type: application/json" \
59
+ -d '{
60
+ "credsPayload": { "credsPath": "github" },
61
+ "owner": "GorgonFreeman",
62
+ "repo": "mineral",
63
+ "pullNumber": 1
64
+ }'
65
+ */
@@ -0,0 +1,77 @@
1
+ // https://docs.github.com/en/rest/pulls/pulls#merge-a-pull-request
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { githubClient } = require('../github/github.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['owner'],
10
+ ['repo'],
11
+ ['pullNumber'],
12
+ ]);
13
+
14
+ const githubPullRequestMerge = async (
15
+ credsPayload,
16
+ owner,
17
+ repo,
18
+ pullNumber,
19
+ {
20
+ commitTitle,
21
+ commitMessage,
22
+ sha,
23
+ mergeMethod,
24
+ apiVersion,
25
+ } = {},
26
+ ) => {
27
+
28
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
29
+ credsPayload,
30
+ owner,
31
+ repo,
32
+ pullNumber,
33
+ });
34
+ if (rejectResponse) {
35
+ return rejectResponse;
36
+ }
37
+
38
+ return githubClient.fetch({
39
+ requestPayload: {
40
+ method: 'put',
41
+ url: `/repos/${ owner }/${ repo }/pulls/${ pullNumber }/merge`,
42
+ body: {
43
+ ...commitTitle && { commit_title: commitTitle },
44
+ ...commitMessage && { commit_message: commitMessage },
45
+ ...sha && { sha },
46
+ ...mergeMethod && { merge_method: mergeMethod },
47
+ },
48
+ },
49
+ context: {
50
+ credsPayload,
51
+ apiVersion,
52
+ },
53
+ });
54
+ };
55
+
56
+ const funcApiConfig = {
57
+ argsWarden,
58
+ };
59
+
60
+ module.exports = {
61
+ githubPullRequestMerge,
62
+ funcApiConfig,
63
+ };
64
+
65
+ /*
66
+ curl -X POST "http://localhost:8000/githubPullRequestMerge" \
67
+ -H "Content-Type: application/json" \
68
+ -d '{
69
+ "credsPayload": { "credsPath": "github" },
70
+ "owner": "GorgonFreeman",
71
+ "repo": "mineral",
72
+ "pullNumber": 1,
73
+ "options": {
74
+ "mergeMethod": "squash"
75
+ }
76
+ }'
77
+ */
@@ -0,0 +1,72 @@
1
+ // https://docs.github.com/en/rest/pulls/pulls#update-a-pull-request
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { githubClient } = require('../github/github.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['owner'],
10
+ ['repo'],
11
+ ['pullNumber'],
12
+ ['updatePayload', Boolean],
13
+ ]);
14
+
15
+ const githubPullRequestUpdate = async (
16
+ credsPayload,
17
+ owner,
18
+ repo,
19
+ pullNumber,
20
+ updatePayload,
21
+ {
22
+ apiVersion,
23
+ } = {},
24
+ ) => {
25
+
26
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
27
+ credsPayload,
28
+ owner,
29
+ repo,
30
+ pullNumber,
31
+ updatePayload,
32
+ });
33
+ if (rejectResponse) {
34
+ return rejectResponse;
35
+ }
36
+
37
+ return githubClient.fetch({
38
+ requestPayload: {
39
+ method: 'patch',
40
+ url: `/repos/${ owner }/${ repo }/pulls/${ pullNumber }`,
41
+ body: updatePayload,
42
+ },
43
+ context: {
44
+ credsPayload,
45
+ apiVersion,
46
+ },
47
+ });
48
+ };
49
+
50
+ const funcApiConfig = {
51
+ argsWarden,
52
+ };
53
+
54
+ module.exports = {
55
+ githubPullRequestUpdate,
56
+ funcApiConfig,
57
+ };
58
+
59
+ /*
60
+ curl -X POST "http://localhost:8000/githubPullRequestUpdate" \
61
+ -H "Content-Type: application/json" \
62
+ -d '{
63
+ "credsPayload": { "credsPath": "github" },
64
+ "owner": "GorgonFreeman",
65
+ "repo": "mineral",
66
+ "pullNumber": 1,
67
+ "updatePayload": {
68
+ "title": "Updated title",
69
+ "state": "open"
70
+ }
71
+ }'
72
+ */
@@ -0,0 +1,74 @@
1
+ // https://docs.github.com/en/rest/pulls/pulls#list-pull-requests
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
+ ['owner'],
11
+ ['repo'],
12
+ ]);
13
+
14
+ const githubPullRequestsGet = async (
15
+ credsPayload,
16
+ owner,
17
+ repo,
18
+ {
19
+ state,
20
+ head,
21
+ base,
22
+ sort,
23
+ direction,
24
+ perPage,
25
+ ...getterOptions
26
+ } = {},
27
+ ) => {
28
+
29
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
30
+ credsPayload,
31
+ owner,
32
+ repo,
33
+ });
34
+ if (rejectResponse) {
35
+ return rejectResponse;
36
+ }
37
+
38
+ const params = {
39
+ ...state && { state },
40
+ ...head && { head },
41
+ ...base && { base },
42
+ ...sort && { sort },
43
+ ...direction && { direction },
44
+ };
45
+
46
+ return githubGet(credsPayload, `/repos/${ owner }/${ repo }/pulls`, {
47
+ params,
48
+ perPage: perPage ?? MAX_PER_PAGE,
49
+ ...getterOptions,
50
+ });
51
+ };
52
+
53
+ const funcApiConfig = {
54
+ argsWarden,
55
+ };
56
+
57
+ module.exports = {
58
+ githubPullRequestsGet,
59
+ funcApiConfig,
60
+ };
61
+
62
+ /*
63
+ curl -X POST "http://localhost:8000/githubPullRequestsGet" \
64
+ -H "Content-Type: application/json" \
65
+ -d '{
66
+ "credsPayload": { "credsPath": "github" },
67
+ "owner": "GorgonFreeman",
68
+ "repo": "mineral",
69
+ "options": {
70
+ "state": "open",
71
+ "limit": 10
72
+ }
73
+ }'
74
+ */
@@ -0,0 +1,80 @@
1
+ // https://docs.github.com/en/rest/repos/repos#create-a-repository-for-the-authenticated-user
2
+ // https://docs.github.com/en/rest/repos/repos#create-an-organization-repository
3
+
4
+ const { ArgsWarden } = require('../utils');
5
+ const { credsValidator } = require('../validators');
6
+ const { githubClient } = require('../github/github.utils');
7
+
8
+ const repoPayloadValidator = (repoPayload) => Boolean(repoPayload?.name);
9
+
10
+ const argsWarden = new ArgsWarden([
11
+ ['credsPayload', credsValidator],
12
+ ['repoPayload', repoPayloadValidator],
13
+ ]);
14
+
15
+ const githubRepoCreate = async (
16
+ credsPayload,
17
+ repoPayload,
18
+ {
19
+ org,
20
+ apiVersion,
21
+ } = {},
22
+ ) => {
23
+
24
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
25
+ credsPayload,
26
+ repoPayload,
27
+ });
28
+ if (rejectResponse) {
29
+ return rejectResponse;
30
+ }
31
+
32
+ const url = org ? `/orgs/${ org }/repos` : '/user/repos';
33
+
34
+ return githubClient.fetch({
35
+ requestPayload: {
36
+ method: 'post',
37
+ url,
38
+ body: repoPayload,
39
+ },
40
+ context: {
41
+ credsPayload,
42
+ apiVersion,
43
+ },
44
+ });
45
+ };
46
+
47
+ const funcApiConfig = {
48
+ argsWarden,
49
+ };
50
+
51
+ module.exports = {
52
+ githubRepoCreate,
53
+ funcApiConfig,
54
+ };
55
+
56
+ /*
57
+ curl -X POST "http://localhost:8000/githubRepoCreate" \
58
+ -H "Content-Type: application/json" \
59
+ -d '{
60
+ "credsPayload": { "credsPath": "github" },
61
+ "repoPayload": {
62
+ "name": "my-new-repo",
63
+ "private": true,
64
+ "auto_init": true
65
+ }
66
+ }'
67
+
68
+ curl -X POST "http://localhost:8000/githubRepoCreate" \
69
+ -H "Content-Type: application/json" \
70
+ -d '{
71
+ "credsPayload": { "credsPath": "github" },
72
+ "repoPayload": {
73
+ "name": "my-org-repo",
74
+ "private": false
75
+ },
76
+ "options": {
77
+ "org": "GorgonFreeman"
78
+ }
79
+ }'
80
+ */
@@ -0,0 +1,60 @@
1
+ // https://docs.github.com/en/rest/repos/repos#delete-a-repository
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { githubClient } = require('../github/github.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['owner'],
10
+ ['repo'],
11
+ ]);
12
+
13
+ const githubRepoDelete = async (
14
+ credsPayload,
15
+ owner,
16
+ repo,
17
+ {
18
+ apiVersion,
19
+ } = {},
20
+ ) => {
21
+
22
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
23
+ credsPayload,
24
+ owner,
25
+ repo,
26
+ });
27
+ if (rejectResponse) {
28
+ return rejectResponse;
29
+ }
30
+
31
+ return githubClient.fetch({
32
+ requestPayload: {
33
+ method: 'delete',
34
+ url: `/repos/${ owner }/${ repo }`,
35
+ },
36
+ context: {
37
+ credsPayload,
38
+ apiVersion,
39
+ },
40
+ });
41
+ };
42
+
43
+ const funcApiConfig = {
44
+ argsWarden,
45
+ };
46
+
47
+ module.exports = {
48
+ githubRepoDelete,
49
+ funcApiConfig,
50
+ };
51
+
52
+ /*
53
+ curl -X POST "http://localhost:8000/githubRepoDelete" \
54
+ -H "Content-Type: application/json" \
55
+ -d '{
56
+ "credsPayload": { "credsPath": "github" },
57
+ "owner": "GorgonFreeman",
58
+ "repo": "my-old-repo"
59
+ }'
60
+ */
@@ -0,0 +1,61 @@
1
+ // https://docs.github.com/en/rest/repos/repos#get-a-repository
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { githubClient } = require('../github/github.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['owner'],
10
+ ['repo'],
11
+ ]);
12
+
13
+ const githubRepoGet = async (
14
+ credsPayload,
15
+ owner,
16
+ repo,
17
+ {
18
+ params,
19
+ apiVersion,
20
+ } = {},
21
+ ) => {
22
+
23
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
24
+ credsPayload,
25
+ owner,
26
+ repo,
27
+ });
28
+ if (rejectResponse) {
29
+ return rejectResponse;
30
+ }
31
+
32
+ return githubClient.fetch({
33
+ requestPayload: {
34
+ url: `/repos/${ owner }/${ repo }`,
35
+ params,
36
+ },
37
+ context: {
38
+ credsPayload,
39
+ apiVersion,
40
+ },
41
+ });
42
+ };
43
+
44
+ const funcApiConfig = {
45
+ argsWarden,
46
+ };
47
+
48
+ module.exports = {
49
+ githubRepoGet,
50
+ funcApiConfig,
51
+ };
52
+
53
+ /*
54
+ curl -X POST "http://localhost:8000/githubRepoGet" \
55
+ -H "Content-Type: application/json" \
56
+ -d '{
57
+ "credsPayload": { "credsPath": "github" },
58
+ "owner": "GorgonFreeman",
59
+ "repo": "mineral"
60
+ }'
61
+ */
@@ -0,0 +1,68 @@
1
+ // https://docs.github.com/en/rest/repos/repos#update-a-repository
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { githubClient } = require('../github/github.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['owner'],
10
+ ['repo'],
11
+ ['updatePayload', Boolean],
12
+ ]);
13
+
14
+ const githubRepoUpdate = async (
15
+ credsPayload,
16
+ owner,
17
+ repo,
18
+ updatePayload,
19
+ {
20
+ apiVersion,
21
+ } = {},
22
+ ) => {
23
+
24
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
25
+ credsPayload,
26
+ owner,
27
+ repo,
28
+ updatePayload,
29
+ });
30
+ if (rejectResponse) {
31
+ return rejectResponse;
32
+ }
33
+
34
+ return githubClient.fetch({
35
+ requestPayload: {
36
+ method: 'patch',
37
+ url: `/repos/${ owner }/${ repo }`,
38
+ body: updatePayload,
39
+ },
40
+ context: {
41
+ credsPayload,
42
+ apiVersion,
43
+ },
44
+ });
45
+ };
46
+
47
+ const funcApiConfig = {
48
+ argsWarden,
49
+ };
50
+
51
+ module.exports = {
52
+ githubRepoUpdate,
53
+ funcApiConfig,
54
+ };
55
+
56
+ /*
57
+ curl -X POST "http://localhost:8000/githubRepoUpdate" \
58
+ -H "Content-Type: application/json" \
59
+ -d '{
60
+ "credsPayload": { "credsPath": "github" },
61
+ "owner": "GorgonFreeman",
62
+ "repo": "mineral",
63
+ "updatePayload": {
64
+ "description": "Updated description",
65
+ "private": true
66
+ }
67
+ }'
68
+ */