@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { logDeep, ArgsWarden } = require('../utils');
|
|
2
2
|
const { credsValidator } = require('../validators');
|
|
3
3
|
const { shopifyClient } = require('./shopify.utils');
|
|
4
4
|
|
|
@@ -21,12 +21,11 @@ const shopifyOrdersGet = async (
|
|
|
21
21
|
return rejectResponse;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
const creds = await credsFromPayload(credsPayload);
|
|
25
|
-
|
|
26
24
|
const response = await shopifyClient.fetch({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
requestPayload: {
|
|
26
|
+
method: 'post',
|
|
27
|
+
body: {
|
|
28
|
+
query: `
|
|
30
29
|
query OrdersGet(
|
|
31
30
|
$first: Int!,
|
|
32
31
|
$after: String,
|
|
@@ -49,14 +48,15 @@ const shopifyOrdersGet = async (
|
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
`,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
variables: {
|
|
52
|
+
first,
|
|
53
|
+
after,
|
|
54
|
+
query,
|
|
55
|
+
},
|
|
56
56
|
},
|
|
57
57
|
},
|
|
58
58
|
context: {
|
|
59
|
-
|
|
59
|
+
credsPayload,
|
|
60
60
|
apiVersion,
|
|
61
61
|
resultPath: 'data.orders',
|
|
62
62
|
},
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/mutations/stagedUploadsCreate
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden, ensureArray, everyIfArray } = require('../utils');
|
|
5
|
+
const { shopifyMutationDo } = require('../shopify/shopifyMutationDo');
|
|
6
|
+
|
|
7
|
+
const defaultReturnAttrs = `
|
|
8
|
+
url
|
|
9
|
+
resourceUrl
|
|
10
|
+
parameters {
|
|
11
|
+
name
|
|
12
|
+
value
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
const stagedUploadInputItemValidator = ({
|
|
17
|
+
resource,
|
|
18
|
+
filename,
|
|
19
|
+
mimeType,
|
|
20
|
+
} = {}) => Boolean(resource && filename && mimeType);
|
|
21
|
+
|
|
22
|
+
const argsWarden = new ArgsWarden([
|
|
23
|
+
['credsPayload', credsValidator],
|
|
24
|
+
['stagedUploadInput', (i) => everyIfArray(stagedUploadInputItemValidator, i)],
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
const shopifyStagedUploadCreate = async (
|
|
28
|
+
credsPayload,
|
|
29
|
+
stagedUploadInput,
|
|
30
|
+
{
|
|
31
|
+
apiVersion,
|
|
32
|
+
returnAttrs = defaultReturnAttrs,
|
|
33
|
+
} = {},
|
|
34
|
+
) => {
|
|
35
|
+
|
|
36
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
37
|
+
credsPayload,
|
|
38
|
+
stagedUploadInput,
|
|
39
|
+
});
|
|
40
|
+
if (rejectResponse) {
|
|
41
|
+
return rejectResponse;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const input = ensureArray(stagedUploadInput).map(({
|
|
45
|
+
resource,
|
|
46
|
+
filename,
|
|
47
|
+
mimeType,
|
|
48
|
+
fileSize,
|
|
49
|
+
httpMethod,
|
|
50
|
+
}) => ({
|
|
51
|
+
resource,
|
|
52
|
+
filename,
|
|
53
|
+
mimeType,
|
|
54
|
+
...fileSize && { fileSize: String(fileSize) },
|
|
55
|
+
...httpMethod && { httpMethod },
|
|
56
|
+
}));
|
|
57
|
+
|
|
58
|
+
return shopifyMutationDo(
|
|
59
|
+
credsPayload,
|
|
60
|
+
'stagedUploadsCreate',
|
|
61
|
+
{
|
|
62
|
+
mutationVariables: {
|
|
63
|
+
input: {
|
|
64
|
+
type: '[StagedUploadInput!]!',
|
|
65
|
+
value: input,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
returnSchema: `stagedTargets { ${ returnAttrs } }`,
|
|
69
|
+
apiVersion,
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const funcApiConfig = {
|
|
75
|
+
argsWarden,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
module.exports = {
|
|
79
|
+
shopifyStagedUploadCreate,
|
|
80
|
+
funcApiConfig,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/*
|
|
84
|
+
curl -X POST "http://localhost:8000/shopifyStagedUploadCreate" \
|
|
85
|
+
-H "Content-Type: application/json" \
|
|
86
|
+
-d '{
|
|
87
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
88
|
+
"stagedUploadInput": {
|
|
89
|
+
"resource": "BULK_MUTATION_VARIABLES",
|
|
90
|
+
"filename": "inputs.jsonl",
|
|
91
|
+
"mimeType": "text/jsonl",
|
|
92
|
+
"httpMethod": "POST"
|
|
93
|
+
}
|
|
94
|
+
}'
|
|
95
|
+
}'
|
|
96
|
+
*/
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/mutations/tagsAdd
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyBulkMutationDo } = require('./shopifyBulkMutationDo');
|
|
6
|
+
|
|
7
|
+
const tagsAddBulkMutation = `
|
|
8
|
+
mutation call($id: ID!, $tags: [String!]!) {
|
|
9
|
+
tagsAdd(id: $id, tags: $tags) {
|
|
10
|
+
node {
|
|
11
|
+
id
|
|
12
|
+
}
|
|
13
|
+
userErrors {
|
|
14
|
+
field
|
|
15
|
+
message
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
`.trim();
|
|
20
|
+
|
|
21
|
+
const tagsAddBulkUserErrors = (bulkResult) => {
|
|
22
|
+
return bulkResult?.data?.tagsAdd?.userErrors
|
|
23
|
+
|| bulkResult?.tagsAdd?.userErrors
|
|
24
|
+
|| [];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const argsWarden = new ArgsWarden([
|
|
28
|
+
['credsPayload', credsValidator],
|
|
29
|
+
['gids', Array.isArray],
|
|
30
|
+
['tags', Array.isArray],
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
const shopifyTagsAddBulk = async (
|
|
34
|
+
credsPayload,
|
|
35
|
+
gids,
|
|
36
|
+
tags,
|
|
37
|
+
{
|
|
38
|
+
apiVersion,
|
|
39
|
+
clientIdentifier,
|
|
40
|
+
waitForResult = true,
|
|
41
|
+
} = {},
|
|
42
|
+
) => {
|
|
43
|
+
|
|
44
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
45
|
+
credsPayload,
|
|
46
|
+
gids,
|
|
47
|
+
tags,
|
|
48
|
+
});
|
|
49
|
+
if (rejectResponse) {
|
|
50
|
+
return rejectResponse;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return shopifyBulkMutationDo(
|
|
54
|
+
credsPayload,
|
|
55
|
+
{
|
|
56
|
+
mutation: tagsAddBulkMutation,
|
|
57
|
+
input: {
|
|
58
|
+
data: gids.map((gid) => ({
|
|
59
|
+
id: gid,
|
|
60
|
+
tags,
|
|
61
|
+
})),
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
apiVersion,
|
|
66
|
+
clientIdentifier,
|
|
67
|
+
waitForResult,
|
|
68
|
+
},
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const funcApiConfig = {
|
|
73
|
+
argsWarden,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
module.exports = {
|
|
77
|
+
shopifyTagsAddBulk,
|
|
78
|
+
tagsAddBulkUserErrors,
|
|
79
|
+
funcApiConfig,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/*
|
|
83
|
+
curl -X POST "http://localhost:8000/shopifyTagsAddBulk" \
|
|
84
|
+
-H "Content-Type: application/json" \
|
|
85
|
+
-d '{
|
|
86
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
87
|
+
"gids": ["gid://shopify/Customer/123"],
|
|
88
|
+
"tags": ["aug26_migration"]
|
|
89
|
+
}'
|
|
90
|
+
*/
|
package/api/slack/slack.utils.js
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
const { SLACK_API_BASE_URL } = require('../slack/slack.constants');
|
|
2
|
+
const { resolveCreds, useBaseUrl } = require('../pipelineSteps');
|
|
2
3
|
const {
|
|
3
4
|
FetchClient,
|
|
4
|
-
Chain,
|
|
5
|
-
appendUrlToBase,
|
|
6
5
|
fetchClientCommonSteps,
|
|
7
6
|
} = require('../utils');
|
|
8
7
|
|
|
9
|
-
const
|
|
8
|
+
const useAuthHeaders = async (state) => {
|
|
10
9
|
const { requestPayload, context } = state;
|
|
11
10
|
const { creds } = context;
|
|
12
|
-
const {
|
|
13
|
-
BOT_TOKEN,
|
|
14
|
-
} = creds;
|
|
11
|
+
const { BOT_TOKEN } = creds;
|
|
15
12
|
|
|
16
13
|
return {
|
|
17
14
|
requestPayload: {
|
|
18
15
|
...requestPayload,
|
|
19
16
|
method: requestPayload.method || 'post',
|
|
20
|
-
url: appendUrlToBase(SLACK_API_BASE_URL, requestPayload.url),
|
|
21
17
|
headers: {
|
|
22
|
-
'Content-Type': 'application/json',
|
|
23
18
|
Authorization: `Bearer ${ BOT_TOKEN }`,
|
|
24
19
|
...requestPayload.headers,
|
|
25
20
|
},
|
|
@@ -27,18 +22,14 @@ const addUrlAndAuthHeaders = async (state) => {
|
|
|
27
22
|
};
|
|
28
23
|
};
|
|
29
24
|
|
|
30
|
-
|
|
31
|
-
const slackClientRequestPreparer = new Chain([
|
|
32
|
-
addUrlAndAuthHeaders,
|
|
33
|
-
]);
|
|
34
|
-
|
|
35
|
-
const slackClientResponseInterpreter = new Chain([
|
|
36
|
-
fetchClientCommonSteps.exitEarlyOnNotOk,
|
|
37
|
-
]);
|
|
38
|
-
|
|
39
25
|
const slackClient = new FetchClient({
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
pipeline: [
|
|
27
|
+
resolveCreds,
|
|
28
|
+
useBaseUrl(SLACK_API_BASE_URL),
|
|
29
|
+
useAuthHeaders,
|
|
30
|
+
'fetch',
|
|
31
|
+
fetchClientCommonSteps.exitEarlyOnNotOk,
|
|
32
|
+
],
|
|
42
33
|
});
|
|
43
34
|
|
|
44
35
|
module.exports = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// https://docs.slack.dev/reference/methods/chat.postmessage
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { objHasAny, ArgsWarden } = require('../utils');
|
|
4
4
|
const { credsValidator } = require('../validators');
|
|
5
5
|
const { slackClient } = require('../slack/slack.utils');
|
|
6
6
|
|
|
@@ -36,8 +36,6 @@ const slackMessagePost = async (
|
|
|
36
36
|
return rejectResponse;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
const creds = await credsFromPayload(credsPayload);
|
|
40
|
-
|
|
41
39
|
const {
|
|
42
40
|
channelName,
|
|
43
41
|
channelId,
|
|
@@ -50,15 +48,17 @@ const slackMessagePost = async (
|
|
|
50
48
|
} = messagePayload;
|
|
51
49
|
|
|
52
50
|
const response = await slackClient.fetch({
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
51
|
+
requestPayload: {
|
|
52
|
+
url: '/chat.postMessage',
|
|
53
|
+
method: 'post',
|
|
54
|
+
body: {
|
|
55
|
+
channel: channelId || channelName,
|
|
56
|
+
...text && { text },
|
|
57
|
+
...blocks && { blocks },
|
|
58
|
+
...markdownText && { markdown_text: markdownText },
|
|
59
|
+
},
|
|
60
60
|
},
|
|
61
|
-
context: {
|
|
61
|
+
context: { credsPayload },
|
|
62
62
|
inspect,
|
|
63
63
|
});
|
|
64
64
|
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const { BASE_URL } = require('../starshipit/starshipit.constants');
|
|
2
|
+
const { resolveCreds, useBaseUrl } = require('../pipelineSteps');
|
|
3
|
+
const {
|
|
4
|
+
FetchClient,
|
|
5
|
+
fetchClientCommonSteps,
|
|
6
|
+
} = require('../utils');
|
|
7
|
+
|
|
8
|
+
const interpretStarshipitResponse = async (state) => {
|
|
9
|
+
const { response } = state;
|
|
10
|
+
|
|
11
|
+
const { success, results, errors } = response.data;
|
|
12
|
+
|
|
13
|
+
if (!success) {
|
|
14
|
+
const firstError = errors?.[0];
|
|
15
|
+
|
|
16
|
+
// TODO: Consider removing data if errors
|
|
17
|
+
return {
|
|
18
|
+
response: {
|
|
19
|
+
...response,
|
|
20
|
+
ok: false,
|
|
21
|
+
error: {
|
|
22
|
+
message: firstError?.message,
|
|
23
|
+
details: errors,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
breakChain: true,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
response: {
|
|
32
|
+
...response,
|
|
33
|
+
data: results ?? response.data,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const useAuthHeaders = async (state) => {
|
|
39
|
+
const { requestPayload, context } = state;
|
|
40
|
+
const { creds } = context;
|
|
41
|
+
const {
|
|
42
|
+
API_KEY,
|
|
43
|
+
SUB_KEY,
|
|
44
|
+
} = creds;
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
requestPayload: {
|
|
48
|
+
...requestPayload,
|
|
49
|
+
headers: {
|
|
50
|
+
'StarShipIT-Api-Key': API_KEY,
|
|
51
|
+
'Ocp-Apim-Subscription-Key': SUB_KEY,
|
|
52
|
+
...requestPayload.headers,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const starshipitClient = new FetchClient({
|
|
59
|
+
pipeline: [
|
|
60
|
+
resolveCreds,
|
|
61
|
+
useBaseUrl(BASE_URL),
|
|
62
|
+
useAuthHeaders,
|
|
63
|
+
'fetch',
|
|
64
|
+
fetchClientCommonSteps.exitEarlyOnNotOk,
|
|
65
|
+
interpretStarshipitResponse,
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
module.exports = {
|
|
70
|
+
starshipitClient,
|
|
71
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// https://api-docs.starshipit.com/#f577d747-7227-432f-bbc2-d9e2db08578f
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { starshipitClient } = require('../starshipit/starshipit.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['addressPayload'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const starshipitAddressCreate = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
addressPayload,
|
|
15
|
+
) => {
|
|
16
|
+
|
|
17
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
18
|
+
credsPayload,
|
|
19
|
+
addressPayload,
|
|
20
|
+
});
|
|
21
|
+
if (rejectResponse) {
|
|
22
|
+
return rejectResponse;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const response = await starshipitClient.fetch({
|
|
26
|
+
requestPayload: {
|
|
27
|
+
url: '/addressbook',
|
|
28
|
+
method: 'post',
|
|
29
|
+
body: {
|
|
30
|
+
address: addressPayload,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
context: {
|
|
34
|
+
credsPayload,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
if (!response?.ok) {
|
|
39
|
+
return response;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const { id, address } = response.data || {};
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
...response,
|
|
46
|
+
data: {
|
|
47
|
+
id,
|
|
48
|
+
...address,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const funcApiConfig = {
|
|
54
|
+
argsWarden,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
module.exports = {
|
|
58
|
+
starshipitAddressCreate,
|
|
59
|
+
funcApiConfig,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/*
|
|
63
|
+
curl -X POST "http://localhost:8000/starshipitAddressCreate" \
|
|
64
|
+
-H "Content-Type: application/json" \
|
|
65
|
+
-d '{
|
|
66
|
+
"credsPayload": { "credsPath": "starshipit.acc" },
|
|
67
|
+
"addressPayload": {
|
|
68
|
+
"name": "John Doe",
|
|
69
|
+
"street": "123 Main St",
|
|
70
|
+
"suburb": "Wherever",
|
|
71
|
+
"city": "Sydney",
|
|
72
|
+
"state": "NSW",
|
|
73
|
+
"post_code": "2000",
|
|
74
|
+
"country": "Australia"
|
|
75
|
+
}
|
|
76
|
+
}'
|
|
77
|
+
*/
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// https://api-docs.starshipit.com/#0cd0b1b0-7ba4-4da3-8c94-67cb4e020a6d
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { starshipitClient } = require('../starshipit/starshipit.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['addressId'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const starshipitAddressDelete = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
addressId,
|
|
15
|
+
) => {
|
|
16
|
+
|
|
17
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
18
|
+
credsPayload,
|
|
19
|
+
addressId,
|
|
20
|
+
});
|
|
21
|
+
if (rejectResponse) {
|
|
22
|
+
return rejectResponse;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return starshipitClient.fetch({
|
|
26
|
+
requestPayload: {
|
|
27
|
+
url: '/addressbook/delete',
|
|
28
|
+
method: 'post',
|
|
29
|
+
body: {
|
|
30
|
+
address_ids: [addressId],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
context: {
|
|
34
|
+
credsPayload,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const funcApiConfig = {
|
|
40
|
+
argsWarden,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
module.exports = {
|
|
44
|
+
starshipitAddressDelete,
|
|
45
|
+
funcApiConfig,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/*
|
|
49
|
+
curl -X POST "http://localhost:8000/starshipitAddressDelete" \
|
|
50
|
+
-H "Content-Type: application/json" \
|
|
51
|
+
-d '{
|
|
52
|
+
"credsPayload": { "credsPath": "starshipit.acc" },
|
|
53
|
+
"addressId": "14824686"
|
|
54
|
+
}'
|
|
55
|
+
*/
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// https://api-docs.starshipit.com/#4ff9ae6f-fadb-4c50-9087-467c2e336f93
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { starshipitClient } = require('../starshipit/starshipit.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['addressId'],
|
|
10
|
+
['updatePayload'],
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
const starshipitAddressUpdate = async (
|
|
14
|
+
credsPayload,
|
|
15
|
+
addressId,
|
|
16
|
+
updatePayload,
|
|
17
|
+
) => {
|
|
18
|
+
|
|
19
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
20
|
+
credsPayload,
|
|
21
|
+
addressId,
|
|
22
|
+
updatePayload,
|
|
23
|
+
});
|
|
24
|
+
if (rejectResponse) {
|
|
25
|
+
return rejectResponse;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const response = await starshipitClient.fetch({
|
|
29
|
+
requestPayload: {
|
|
30
|
+
url: '/addressbook/update',
|
|
31
|
+
method: 'post',
|
|
32
|
+
body: {
|
|
33
|
+
id: addressId,
|
|
34
|
+
address: updatePayload,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
context: {
|
|
38
|
+
credsPayload,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (!response?.ok) {
|
|
43
|
+
return response;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
...response,
|
|
48
|
+
data: response.data?.address ?? response.data,
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const funcApiConfig = {
|
|
53
|
+
argsWarden,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
module.exports = {
|
|
57
|
+
starshipitAddressUpdate,
|
|
58
|
+
funcApiConfig,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
curl -X POST "http://localhost:8000/starshipitAddressUpdate" \
|
|
63
|
+
-H "Content-Type: application/json" \
|
|
64
|
+
-d '{
|
|
65
|
+
"credsPayload": { "credsPath": "starshipit.acc" },
|
|
66
|
+
"addressId": 14824685,
|
|
67
|
+
"updatePayload": { "name": "Batman" }
|
|
68
|
+
}'
|
|
69
|
+
*/
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const { ArgsWarden } = require('../utils');
|
|
2
|
+
const { credsValidator } = require('../validators');
|
|
3
|
+
const { starshipitGet } = require('../starshipit/starshipitGet');
|
|
4
|
+
|
|
5
|
+
const argsWarden = new ArgsWarden([
|
|
6
|
+
['credsPayload', credsValidator],
|
|
7
|
+
]);
|
|
8
|
+
|
|
9
|
+
const starshipitAddressesGet = async (
|
|
10
|
+
credsPayload,
|
|
11
|
+
{
|
|
12
|
+
page = 1,
|
|
13
|
+
perPage,
|
|
14
|
+
sort,
|
|
15
|
+
sortDirection,
|
|
16
|
+
...getterOptions
|
|
17
|
+
} = {},
|
|
18
|
+
) => {
|
|
19
|
+
|
|
20
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
|
|
21
|
+
if (rejectResponse) {
|
|
22
|
+
return rejectResponse;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return starshipitGet(credsPayload, '/addressbook/filtered', {
|
|
26
|
+
nodeName: 'addresses',
|
|
27
|
+
params: {
|
|
28
|
+
...page && { page },
|
|
29
|
+
...perPage && { page_size: perPage },
|
|
30
|
+
...sort && { sort },
|
|
31
|
+
...sortDirection && { sort_direction: sortDirection },
|
|
32
|
+
},
|
|
33
|
+
...getterOptions,
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const funcApiConfig = {
|
|
38
|
+
argsWarden,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
module.exports = {
|
|
42
|
+
starshipitAddressesGet,
|
|
43
|
+
funcApiConfig,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/*
|
|
47
|
+
curl -X POST "http://localhost:8000/starshipitAddressesGet" \
|
|
48
|
+
-H "Content-Type: application/json" \
|
|
49
|
+
-d '{
|
|
50
|
+
"credsPayload": { "credsPath": "starshipit.acc" }
|
|
51
|
+
}'
|
|
52
|
+
*/
|