@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.
- package/.creds.yml.sample +43 -1
- package/AGENTS.md +6 -1
- package/README.md +1 -1
- package/api/bleckmann/.gitkeep +0 -0
- package/api/bleckmann/bleckmann.constants.js +8 -0
- package/api/bleckmann/bleckmann.utils.js +32 -0
- package/api/bleckmann/bleckmannAsnGet.js +52 -0
- package/api/bleckmann/bleckmannAsnsGet.js +65 -0
- package/api/constants.js +2 -1
- package/api/github/github.constants.js +11 -0
- package/api/github/github.utils.js +65 -0
- package/api/github/githubGet.js +144 -0
- package/api/github/githubIssueCreate.js +71 -0
- package/api/github/githubIssueGet.js +65 -0
- package/api/github/githubIssueUpdate.js +71 -0
- package/api/github/githubIssuesGet.js +74 -0
- package/api/github/githubPullRequestCreate.js +74 -0
- package/api/github/githubPullRequestGet.js +65 -0
- package/api/github/githubPullRequestMerge.js +77 -0
- package/api/github/githubPullRequestUpdate.js +72 -0
- package/api/github/githubPullRequestsGet.js +74 -0
- package/api/github/githubRepoCreate.js +80 -0
- package/api/github/githubRepoDelete.js +60 -0
- package/api/github/githubRepoGet.js +61 -0
- package/api/github/githubRepoUpdate.js +68 -0
- package/api/github/githubReposGet.js +69 -0
- package/api/github/githubUserGet.js +64 -0
- package/api/linear/linear.utils.js +9 -14
- package/api/linear/linearIssuesGet.js +9 -9
- package/api/logiwa/logiwa.utils.js +27 -25
- package/api/logiwa/logiwaInventoriesGet.js +5 -3
- package/api/logiwa/logiwaOrderGet.js +4 -2
- package/api/logiwa/logiwaOrdersGet.js +5 -3
- package/api/logiwa/logiwaProductGet.js +4 -2
- package/api/logiwa/logiwaProductsGet.js +5 -3
- package/api/logiwa/logiwaReportGetAvailableToPromise.js +5 -3
- package/api/logiwa/logiwaReportGetInventoryCalculation.js +5 -3
- package/api/logiwa/logiwaReportGetInventorySnapshot.js +5 -3
- package/api/logiwa/logiwaReportGetTotalInventory.js +5 -3
- package/api/logiwa/logiwaWebhookStatusGet.js +4 -2
- package/api/logiwa/logiwaWebhookSubscribe.js +8 -6
- package/api/logiwa/logiwaWebhookUnsubscribe.js +4 -2
- package/api/logiwa/logiwaWebhooksGet.js +4 -2
- package/api/loop/loop.constants.js +7 -0
- package/api/loop/loop.utils.js +37 -0
- package/api/loop/loopAllowlistItemsGet.js +42 -0
- package/api/loop/loopBlocklistItemsGet.js +46 -0
- package/api/loop/loopDestinationsGet.js +42 -0
- package/api/loop/loopGet.js +139 -0
- package/api/loop/loopReturnGet.js +73 -0
- package/api/loop/loopReturnsGet.js +46 -0
- package/api/peoplevox/peoplevox.constants.js +1 -1
- package/api/peoplevox/peoplevox.sessions.js +54 -0
- package/api/peoplevox/peoplevox.utils.js +67 -31
- package/api/peoplevox/peoplevoxGetSingle.js +7 -5
- package/api/peoplevox/peoplevoxOrderEdit.js +7 -5
- package/api/peoplevox/peoplevoxReportGet.js +11 -9
- package/api/pipelineSteps.js +49 -0
- package/api/shopify/shopify.utils.js +18 -24
- package/api/shopify/shopifyBulkMutationDo.js +211 -0
- package/api/shopify/shopifyBulkOperationGet.js +86 -0
- package/api/shopify/shopifyBulkOperationRunMutation.js +83 -0
- package/api/shopify/shopifyCheckoutAndAccountsConfigurationUpdate.js +79 -0
- package/api/shopify/shopifyCollectionGet.js +7 -7
- package/api/shopify/shopifyCustomerGet.js +6 -6
- package/api/shopify/shopifyGet.js +18 -13
- package/api/shopify/shopifyGetSingle.js +9 -9
- package/api/shopify/shopifyMutationDo.js +6 -6
- package/api/shopify/shopifyOrdersGet.js +11 -11
- package/api/shopify/shopifyStagedUploadCreate.js +96 -0
- package/api/shopify/shopifyTagsAdd.js +1 -1
- package/api/shopify/shopifyTagsAddBulk.js +90 -0
- package/api/shopify/shopifyTagsRemove.js +1 -1
- package/api/slack/slack.utils.js +10 -19
- package/api/slack/slackMessagePost.js +11 -11
- package/api/starshipit/starshipit.constants.js +8 -0
- package/api/starshipit/starshipit.utils.js +71 -0
- package/api/starshipit/starshipitAddressCreate.js +77 -0
- package/api/starshipit/starshipitAddressDelete.js +55 -0
- package/api/starshipit/starshipitAddressUpdate.js +69 -0
- package/api/starshipit/starshipitAddressesGet.js +52 -0
- package/api/starshipit/starshipitGet.js +146 -0
- package/api/starshipit/starshipitOrderDelete.js +102 -0
- package/api/starshipit/starshipitOrderGet.js +74 -0
- package/api/starshipit/starshipitOrderUpdate.js +109 -0
- package/api/starshipit/starshipitOrdersListShipped.js +64 -0
- package/api/starshipit/starshipitProductAdd.js +100 -0
- package/api/starshipit/starshipitProductsDelete.js +57 -0
- package/api/starshipit/starshipitProductsGet.js +49 -0
- package/api/starshipit/starshipitTrackingGet.js +69 -0
- package/api/stripe/_example.js +48 -0
- package/api/stripe/stripe.constants.js +5 -0
- package/api/stripe/stripe.utils.js +42 -0
- package/api/stripe/stripeCardCharge.js +98 -0
- package/api/stripe/stripeCardTokenCreate.js +70 -0
- package/api/stripe/stripeChargeCapture.js +63 -0
- package/api/stripe/stripeChargeCreate.js +70 -0
- package/api/stripe/stripeChargeGet.js +51 -0
- package/api/stripe/stripeChargesGet.js +52 -0
- package/api/stripe/stripeRefundCreate.js +64 -0
- package/api/stripe/stripeRefundGet.js +51 -0
- package/api/stripe/stripeRefundsGet.js +52 -0
- package/api/stripe/stripeTokenGet.js +51 -0
- package/api/stylearcade/stylearcade.constants.js +5 -0
- package/api/stylearcade/stylearcade.utils.js +40 -0
- package/api/stylearcade/stylearcadeDataGet.js +62 -0
- package/api/stylearcade/stylearcadeGet.js +133 -0
- package/api/stylearcade/stylearcadeMetadataGet.js +47 -0
- package/api/supabase/supabase.utils.js +52 -0
- package/api/supabase/supabaseRowDelete.js +95 -0
- package/api/supabase/supabaseRowGet.js +58 -0
- package/api/supabase/supabaseRowInsert.js +56 -0
- package/api/supabase/supabaseRowUpdate.js +58 -0
- package/api/supabase/supabaseRpc.js +61 -0
- package/api/supabase/supabaseTableGet.js +44 -0
- package/api/supabase/supabaseTableGetAll.js +86 -0
- package/api/threeclicks/threeclicks.constants.js +8 -0
- package/api/threeclicks/threeclicks.utils.js +119 -0
- package/api/threeclicks/threeclicksCollectionsGet.js +40 -0
- package/api/threeclicks/threeclicksGet.js +138 -0
- package/api/threeclicks/threeclicksKeycodeCreate.js +55 -0
- package/api/threeclicks/threeclicksKeycodeGet.js +47 -0
- package/api/threeclicks/threeclicksPurchaseOrderCreate.js +34 -0
- package/api/threeclicks/threeclicksPurchaseOrderCreateBulk.js +34 -0
- package/api/threeclicks/threeclicksPurchaseOrderGet.js +33 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantitiesGet.js +33 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantityCreate.js +34 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantityCreateBulk.js +34 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantityUpdate.js +46 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantityUpdateBulk.js +46 -0
- package/api/threeclicks/threeclicksPurchaseOrderUpdate.js +35 -0
- package/api/threeclicks/threeclicksPurchaseOrdersGet.js +30 -0
- package/api/threeclicks/threeclicksShipmentCreate.js +34 -0
- package/api/threeclicks/threeclicksShipmentGet.js +33 -0
- package/api/threeclicks/threeclicksShipmentOrderAdd.js +38 -0
- package/api/threeclicks/threeclicksShipmentOrderQuantityCreate.js +35 -0
- package/api/threeclicks/threeclicksShipmentQuantityUpdate.js +35 -0
- package/api/threeclicks/threeclicksShipmentStatusUpdate.js +45 -0
- package/api/threeclicks/threeclicksShipmentsGet.js +52 -0
- package/api/threeclicks/threeclicksSignatureCalculate.js +73 -0
- package/api/threeclicks/threeclicksStyleCodesGet.js +46 -0
- package/api/threeclicks/threeclicksStyleColourCreate.js +47 -0
- package/api/threeclicks/threeclicksStyleColourDelete.js +34 -0
- package/api/threeclicks/threeclicksStyleCreate.js +44 -0
- package/api/threeclicks/threeclicksStyleDelete.js +33 -0
- package/api/threeclicks/threeclicksStyleGet.js +43 -0
- package/api/threeclicks/threeclicksStylePriceUpdate.js +70 -0
- package/api/threeclicks/threeclicksStyleUpdate.js +47 -0
- package/api/threeclicks/threeclicksStylesGet.js +45 -0
- package/api/upstash/upstash.utils.js +36 -0
- package/api/upstash/upstashDel.js +46 -0
- package/api/upstash/upstashExists.js +46 -0
- package/api/upstash/upstashGet.js +46 -0
- package/api/upstash/upstashSet.js +64 -0
- package/api/utils.js +90 -76
- package/api/validators.js +1 -1
- package/api/workable/workable.constants.js +3 -0
- package/api/workable/workable.utils.js +41 -0
- package/api/workable/workableGet.js +151 -0
- package/api/workable/workableJobCandidateCreate.js +87 -0
- package/api/workable/workableJobGet.js +52 -0
- package/api/workable/workableJobMembersGet.js +52 -0
- package/api/workable/workableJobStagesGet.js +52 -0
- package/api/workable/workableJobsGet.js +78 -0
- package/api/yotpo/yotpo.utils.js +17 -22
- package/api/yotpo/yotpoCampaignsGet.js +6 -6
- package/api/yotpo/yotpoCustomerActionRecord.js +7 -7
- package/api/yotpo/yotpoCustomerAnniversaryGet.js +7 -7
- package/api/yotpo/yotpoCustomerAnniversarySet.js +7 -7
- package/api/yotpo/yotpoCustomerBirthdaySet.js +7 -7
- package/api/yotpo/yotpoCustomerGet.js +6 -6
- package/api/yotpo/yotpoCustomerPointsAdjust.js +7 -7
- package/api/yotpo/yotpoCustomerUpsert.js +7 -7
- package/api/yotpo/yotpoCustomersRecentGet.js +6 -6
- package/api/yotpo/yotpoRedemptionCreate.js +7 -7
- package/api/yotpo/yotpoRedemptionOptionsGet.js +6 -6
- package/api/yotpo/yotpoVipTiersGet.js +5 -5
- package/api/youtube/youtube.constants.js +5 -0
- package/api/youtube/youtube.utils.js +77 -0
- package/api/youtube/youtubeChannelVideosGet.js +25 -70
- package/hosting/.hosting.yml.sample +9 -11
- package/hosting/copyCredsToEnv.js +58 -2
- package/hosting/deployFromHostingYml.js +9 -2
- package/hosting/hosting.utils.js +3 -2
- package/package.json +3 -1
- package/server.utils.js +1 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// https://docs.stripe.com/api/refunds/list
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { stripeClient } = require('../stripe/stripe.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
const stripeRefundsGet = async (
|
|
12
|
+
credsPayload,
|
|
13
|
+
{
|
|
14
|
+
params,
|
|
15
|
+
} = {},
|
|
16
|
+
) => {
|
|
17
|
+
|
|
18
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
|
|
19
|
+
if (rejectResponse) {
|
|
20
|
+
return rejectResponse;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const response = await stripeClient.fetch({
|
|
24
|
+
requestPayload: {
|
|
25
|
+
url: '/refunds',
|
|
26
|
+
params,
|
|
27
|
+
},
|
|
28
|
+
context: { credsPayload },
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return response;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const funcApiConfig = {
|
|
35
|
+
argsWarden,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
module.exports = {
|
|
39
|
+
stripeRefundsGet,
|
|
40
|
+
funcApiConfig,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/*
|
|
44
|
+
curl -X POST "http://localhost:8000/stripeRefundsGet" \
|
|
45
|
+
-H "Content-Type: application/json" \
|
|
46
|
+
-d '{
|
|
47
|
+
"credsPayload": { "credsPath": "stripe" },
|
|
48
|
+
"options": {
|
|
49
|
+
"params": { "charge": "ch_123" }
|
|
50
|
+
}
|
|
51
|
+
}'
|
|
52
|
+
*/
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// https://docs.stripe.com/api/tokens/retrieve
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { stripeClient } = require('../stripe/stripe.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['tokenId'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const stripeTokenGet = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
tokenId,
|
|
15
|
+
) => {
|
|
16
|
+
|
|
17
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
18
|
+
credsPayload,
|
|
19
|
+
tokenId,
|
|
20
|
+
});
|
|
21
|
+
if (rejectResponse) {
|
|
22
|
+
return rejectResponse;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const response = await stripeClient.fetch({
|
|
26
|
+
requestPayload: {
|
|
27
|
+
url: `/tokens/${ tokenId }`,
|
|
28
|
+
},
|
|
29
|
+
context: { credsPayload },
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return response;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const funcApiConfig = {
|
|
36
|
+
argsWarden,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
module.exports = {
|
|
40
|
+
stripeTokenGet,
|
|
41
|
+
funcApiConfig,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
curl -X POST "http://localhost:8000/stripeTokenGet" \
|
|
46
|
+
-H "Content-Type: application/json" \
|
|
47
|
+
-d '{
|
|
48
|
+
"credsPayload": { "credsPath": "stripe" },
|
|
49
|
+
"tokenId": "tok_123"
|
|
50
|
+
}'
|
|
51
|
+
*/
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const { resolveCreds, useBaseUrl } = require('../pipelineSteps');
|
|
2
|
+
const {
|
|
3
|
+
FetchClient,
|
|
4
|
+
fetchClientCommonSteps,
|
|
5
|
+
} = require('../utils');
|
|
6
|
+
|
|
7
|
+
const useStylearcadeBaseUrl = async (state) => {
|
|
8
|
+
const { creds } = state.context;
|
|
9
|
+
return useBaseUrl(creds.BASE_URL)(state);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const useAuthHeaders = async (state) => {
|
|
13
|
+
const { requestPayload, context } = state;
|
|
14
|
+
const { creds } = context;
|
|
15
|
+
const { API_KEY } = creds;
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
requestPayload: {
|
|
19
|
+
...requestPayload,
|
|
20
|
+
headers: {
|
|
21
|
+
'Api-Key': API_KEY,
|
|
22
|
+
...requestPayload.headers,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const stylearcadeClient = new FetchClient({
|
|
29
|
+
pipeline: [
|
|
30
|
+
resolveCreds,
|
|
31
|
+
useStylearcadeBaseUrl,
|
|
32
|
+
useAuthHeaders,
|
|
33
|
+
'fetch',
|
|
34
|
+
fetchClientCommonSteps.exitEarlyOnNotOk,
|
|
35
|
+
],
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
module.exports = {
|
|
39
|
+
stylearcadeClient,
|
|
40
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// https://stylearcade.gitlab.io/api-docs/range-plan
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { stylearcadeGet, stylearcadeGetter } = require('../stylearcade/stylearcadeGet');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
const stylearcadeDataGet = async (
|
|
12
|
+
credsPayload,
|
|
13
|
+
options = {},
|
|
14
|
+
) => {
|
|
15
|
+
|
|
16
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
|
|
17
|
+
if (rejectResponse) {
|
|
18
|
+
return rejectResponse;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return stylearcadeGet(credsPayload, {
|
|
22
|
+
nodeName: 'records',
|
|
23
|
+
...options,
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const stylearcadeDataGetter = async (
|
|
28
|
+
credsPayload,
|
|
29
|
+
options = {},
|
|
30
|
+
) => {
|
|
31
|
+
|
|
32
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
|
|
33
|
+
if (rejectResponse) {
|
|
34
|
+
return rejectResponse;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return stylearcadeGetter(credsPayload, {
|
|
38
|
+
nodeName: 'records',
|
|
39
|
+
...options,
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const funcApiConfig = {
|
|
44
|
+
argsWarden,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
module.exports = {
|
|
48
|
+
stylearcadeDataGet,
|
|
49
|
+
stylearcadeDataGetter,
|
|
50
|
+
funcApiConfig,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/*
|
|
54
|
+
curl -X POST "http://localhost:8000/stylearcadeDataGet" \
|
|
55
|
+
-H "Content-Type: application/json" \
|
|
56
|
+
-d '{
|
|
57
|
+
"credsPayload": { "credsPath": "stylearcade" },
|
|
58
|
+
"options": {
|
|
59
|
+
"limit": 2000
|
|
60
|
+
}
|
|
61
|
+
}'
|
|
62
|
+
*/
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
const { ArgsWarden, Getter } = require('../utils');
|
|
2
|
+
const { credsValidator } = require('../validators');
|
|
3
|
+
const { stylearcadeClient } = require('../stylearcade/stylearcade.utils');
|
|
4
|
+
const { MAX_PER_PAGE } = require('../stylearcade/stylearcade.constants');
|
|
5
|
+
|
|
6
|
+
const argsWarden = new ArgsWarden([
|
|
7
|
+
['credsPayload', credsValidator],
|
|
8
|
+
]);
|
|
9
|
+
|
|
10
|
+
const stylearcadeGetPacket = async (
|
|
11
|
+
credsPayload,
|
|
12
|
+
{
|
|
13
|
+
params,
|
|
14
|
+
perPage = MAX_PER_PAGE,
|
|
15
|
+
url = '/export',
|
|
16
|
+
} = {},
|
|
17
|
+
) => {
|
|
18
|
+
return stylearcadeClient.fetch({
|
|
19
|
+
requestPayload: {
|
|
20
|
+
url,
|
|
21
|
+
params: {
|
|
22
|
+
limit: perPage,
|
|
23
|
+
...params,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
context: {
|
|
27
|
+
credsPayload,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const stylearcadeGetPaginator = async (currentParams, response) => {
|
|
33
|
+
if (!response?.ok) {
|
|
34
|
+
return [true];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const { nextCursor } = response.data || {};
|
|
38
|
+
|
|
39
|
+
if (!nextCursor) {
|
|
40
|
+
return [true];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const { args, options } = currentParams;
|
|
44
|
+
|
|
45
|
+
return [false, {
|
|
46
|
+
args,
|
|
47
|
+
options: {
|
|
48
|
+
...options,
|
|
49
|
+
params: {
|
|
50
|
+
...options.params,
|
|
51
|
+
cursor: nextCursor,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
}];
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const stylearcadeGetDigester = (response, nodeName) => {
|
|
58
|
+
if (!response?.ok) {
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return response?.data?.[nodeName] ?? [];
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const stylearcadeGet = async (
|
|
66
|
+
returnGetter,
|
|
67
|
+
|
|
68
|
+
credsPayload,
|
|
69
|
+
{
|
|
70
|
+
params,
|
|
71
|
+
perPage = MAX_PER_PAGE,
|
|
72
|
+
nodeName = 'records',
|
|
73
|
+
url = '/export',
|
|
74
|
+
...getterOptions
|
|
75
|
+
} = {},
|
|
76
|
+
) => {
|
|
77
|
+
|
|
78
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
79
|
+
credsPayload,
|
|
80
|
+
});
|
|
81
|
+
if (rejectResponse) {
|
|
82
|
+
return rejectResponse;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const getter = new Getter(
|
|
86
|
+
{
|
|
87
|
+
args: [credsPayload],
|
|
88
|
+
options: {
|
|
89
|
+
params,
|
|
90
|
+
perPage,
|
|
91
|
+
url,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
func: stylearcadeGetPacket,
|
|
96
|
+
digester: (response) => stylearcadeGetDigester(response, nodeName),
|
|
97
|
+
paginator: stylearcadeGetPaginator,
|
|
98
|
+
...getterOptions,
|
|
99
|
+
},
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
if (returnGetter) {
|
|
103
|
+
return getter;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const data = await getter.run({ returnAll: true });
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
ok: true,
|
|
110
|
+
data,
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const funcApiConfig = {
|
|
115
|
+
argsWarden,
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
module.exports = {
|
|
119
|
+
stylearcadeGet: (...args) => stylearcadeGet(false, ...args),
|
|
120
|
+
stylearcadeGetter: (...args) => stylearcadeGet(true, ...args),
|
|
121
|
+
funcApiConfig,
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/*
|
|
125
|
+
curl -X POST "http://localhost:8000/stylearcadeGet" \
|
|
126
|
+
-H "Content-Type: application/json" \
|
|
127
|
+
-d '{
|
|
128
|
+
"credsPayload": { "credsPath": "stylearcade" },
|
|
129
|
+
"options": {
|
|
130
|
+
"limit": 10
|
|
131
|
+
}
|
|
132
|
+
}'
|
|
133
|
+
*/
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// https://stylearcade.gitlab.io/api-docs/range-plan
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { stylearcadeClient } = require('../stylearcade/stylearcade.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
const stylearcadeMetadataGet = async (
|
|
12
|
+
credsPayload,
|
|
13
|
+
options = {},
|
|
14
|
+
) => {
|
|
15
|
+
|
|
16
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
|
|
17
|
+
if (rejectResponse) {
|
|
18
|
+
return rejectResponse;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return stylearcadeClient.fetch({
|
|
22
|
+
requestPayload: {
|
|
23
|
+
url: '/metadata',
|
|
24
|
+
...options.params && { params: options.params },
|
|
25
|
+
},
|
|
26
|
+
context: {
|
|
27
|
+
credsPayload,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const funcApiConfig = {
|
|
33
|
+
argsWarden,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
module.exports = {
|
|
37
|
+
stylearcadeMetadataGet,
|
|
38
|
+
funcApiConfig,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/*
|
|
42
|
+
curl -X POST "http://localhost:8000/stylearcadeMetadataGet" \
|
|
43
|
+
-H "Content-Type: application/json" \
|
|
44
|
+
-d '{
|
|
45
|
+
"credsPayload": { "credsPath": "stylearcade" }
|
|
46
|
+
}'
|
|
47
|
+
*/
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const { createClient } = require('@supabase/supabase-js');
|
|
2
|
+
const { HOSTED } = require('../constants');
|
|
3
|
+
const { credsFromPayload } = require('../utils');
|
|
4
|
+
|
|
5
|
+
const SUPABASE_INSTANCES = new Map();
|
|
6
|
+
|
|
7
|
+
const getSupabaseCacheKey = (credsPayload) => JSON.stringify(credsPayload);
|
|
8
|
+
|
|
9
|
+
const getSupabaseClient = async (credsPayload) => {
|
|
10
|
+
const key = getSupabaseCacheKey(credsPayload);
|
|
11
|
+
|
|
12
|
+
if (SUPABASE_INSTANCES.has(key)) {
|
|
13
|
+
return SUPABASE_INSTANCES.get(key);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const creds = await credsFromPayload(credsPayload);
|
|
17
|
+
const {
|
|
18
|
+
BASE_URL,
|
|
19
|
+
API_KEY,
|
|
20
|
+
} = creds;
|
|
21
|
+
|
|
22
|
+
if (!BASE_URL || !API_KEY) {
|
|
23
|
+
throw new Error('Missing Supabase creds');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const client = createClient(BASE_URL, API_KEY);
|
|
27
|
+
SUPABASE_INSTANCES.set(key, client);
|
|
28
|
+
return client;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const supabaseInterpreter = (response) => {
|
|
32
|
+
const { data, error } = response;
|
|
33
|
+
|
|
34
|
+
if (error) {
|
|
35
|
+
return {
|
|
36
|
+
ok: false,
|
|
37
|
+
error: {
|
|
38
|
+
details: error,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
ok: true,
|
|
45
|
+
data,
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
module.exports = {
|
|
50
|
+
getSupabaseClient,
|
|
51
|
+
supabaseInterpreter,
|
|
52
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
const { HOSTED } = require('../constants');
|
|
2
|
+
const { ArgsWarden } = require('../utils');
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { getSupabaseClient, supabaseInterpreter } = require('../supabase/supabase.utils');
|
|
5
|
+
|
|
6
|
+
const argsWarden = new ArgsWarden([
|
|
7
|
+
['credsPayload', credsValidator],
|
|
8
|
+
['tableName'],
|
|
9
|
+
['deleteConfig'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const supabaseRowDelete = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
tableName,
|
|
15
|
+
deleteConfig,
|
|
16
|
+
) => {
|
|
17
|
+
|
|
18
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
19
|
+
credsPayload,
|
|
20
|
+
tableName,
|
|
21
|
+
deleteConfig,
|
|
22
|
+
});
|
|
23
|
+
if (rejectResponse) {
|
|
24
|
+
return rejectResponse;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!deleteConfig || typeof deleteConfig !== 'object') {
|
|
28
|
+
return {
|
|
29
|
+
ok: false,
|
|
30
|
+
error: {
|
|
31
|
+
message: 'deleteConfig must be an object with either { field, value } or { conditions }',
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const client = await getSupabaseClient(credsPayload);
|
|
37
|
+
let queryResponse;
|
|
38
|
+
|
|
39
|
+
if (deleteConfig.conditions) {
|
|
40
|
+
if (typeof deleteConfig.conditions !== 'object') {
|
|
41
|
+
return {
|
|
42
|
+
ok: false,
|
|
43
|
+
error: {
|
|
44
|
+
message: 'conditions must be an object with field-value pairs',
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
!HOSTED && console.log('Deleting row with conditions:', deleteConfig.conditions);
|
|
50
|
+
|
|
51
|
+
let query = client.from(tableName).delete();
|
|
52
|
+
|
|
53
|
+
Object.entries(deleteConfig.conditions).forEach(([field, value]) => {
|
|
54
|
+
query = query.eq(field, value);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
queryResponse = await query.select();
|
|
58
|
+
} else if (deleteConfig.field && deleteConfig.value !== undefined) {
|
|
59
|
+
!HOSTED && console.log(`Deleting row where ${ deleteConfig.field } = ${ deleteConfig.value }`);
|
|
60
|
+
|
|
61
|
+
queryResponse = await client
|
|
62
|
+
.from(tableName)
|
|
63
|
+
.delete()
|
|
64
|
+
.eq(deleteConfig.field, deleteConfig.value)
|
|
65
|
+
.select();
|
|
66
|
+
} else {
|
|
67
|
+
return {
|
|
68
|
+
ok: false,
|
|
69
|
+
error: {
|
|
70
|
+
message: 'deleteConfig must have either { field, value } or { conditions }',
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return supabaseInterpreter(queryResponse);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const funcApiConfig = {
|
|
79
|
+
argsWarden,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
module.exports = {
|
|
83
|
+
supabaseRowDelete,
|
|
84
|
+
funcApiConfig,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/*
|
|
88
|
+
curl -X POST "http://localhost:8000/supabaseRowDelete" \
|
|
89
|
+
-H "Content-Type: application/json" \
|
|
90
|
+
-d '{
|
|
91
|
+
"credsPayload": { "credsPath": "supabase.mushroom_kingdom" },
|
|
92
|
+
"tableName": "powerups",
|
|
93
|
+
"deleteConfig": { "field": "name", "value": "fire_flower" }
|
|
94
|
+
}'
|
|
95
|
+
*/
|
|
@@ -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
|
+
['rowField'],
|
|
9
|
+
['rowValue'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const supabaseRowGet = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
tableName,
|
|
15
|
+
rowField,
|
|
16
|
+
rowValue,
|
|
17
|
+
) => {
|
|
18
|
+
|
|
19
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
20
|
+
credsPayload,
|
|
21
|
+
tableName,
|
|
22
|
+
rowField,
|
|
23
|
+
rowValue,
|
|
24
|
+
});
|
|
25
|
+
if (rejectResponse) {
|
|
26
|
+
return rejectResponse;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const client = await getSupabaseClient(credsPayload);
|
|
30
|
+
const response = await client
|
|
31
|
+
.from(tableName)
|
|
32
|
+
.select('*')
|
|
33
|
+
.eq(rowField, rowValue)
|
|
34
|
+
.single()
|
|
35
|
+
;
|
|
36
|
+
|
|
37
|
+
return supabaseInterpreter(response);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const funcApiConfig = {
|
|
41
|
+
argsWarden,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
module.exports = {
|
|
45
|
+
supabaseRowGet,
|
|
46
|
+
funcApiConfig,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/*
|
|
50
|
+
curl -X POST "http://localhost:8000/supabaseRowGet" \
|
|
51
|
+
-H "Content-Type: application/json" \
|
|
52
|
+
-d '{
|
|
53
|
+
"credsPayload": { "credsPath": "supabase.mushroom_kingdom" },
|
|
54
|
+
"tableName": "powerups",
|
|
55
|
+
"rowField": "name",
|
|
56
|
+
"rowValue": "star"
|
|
57
|
+
}'
|
|
58
|
+
*/
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
['rowObject'],
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
const supabaseRowInsert = async (
|
|
12
|
+
credsPayload,
|
|
13
|
+
tableName,
|
|
14
|
+
rowObject,
|
|
15
|
+
) => {
|
|
16
|
+
|
|
17
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
18
|
+
credsPayload,
|
|
19
|
+
tableName,
|
|
20
|
+
rowObject,
|
|
21
|
+
});
|
|
22
|
+
if (rejectResponse) {
|
|
23
|
+
return rejectResponse;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const client = await getSupabaseClient(credsPayload);
|
|
27
|
+
const response = await client
|
|
28
|
+
.from(tableName)
|
|
29
|
+
.insert(rowObject)
|
|
30
|
+
.select()
|
|
31
|
+
;
|
|
32
|
+
|
|
33
|
+
return supabaseInterpreter(response);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const funcApiConfig = {
|
|
37
|
+
argsWarden,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
module.exports = {
|
|
41
|
+
supabaseRowInsert,
|
|
42
|
+
funcApiConfig,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/*
|
|
46
|
+
curl -X POST "http://localhost:8000/supabaseRowInsert" \
|
|
47
|
+
-H "Content-Type: application/json" \
|
|
48
|
+
-d '{
|
|
49
|
+
"credsPayload": { "credsPath": "supabase.mushroom_kingdom" },
|
|
50
|
+
"tableName": "powerups",
|
|
51
|
+
"rowObject": [
|
|
52
|
+
{ "name": "mushroom", "effect": "grow", "duration_seconds": null },
|
|
53
|
+
{ "name": "star", "effect": "invincible", "duration_seconds": 10 }
|
|
54
|
+
]
|
|
55
|
+
}'
|
|
56
|
+
*/
|