@tool-bridge/server 0.16.0 → 0.19.0
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/dist/{airtable-S3T4TAN7.js → airtable-23JBIM6X.js} +106 -114
- package/dist/{alt_text_generator_ai-4DIRIDKL.js → alt_text_generator_ai-ADWBTCIH.js} +25 -16
- package/dist/{amap-LGVGNPML.js → amap-CYQCYW2Z.js} +114 -123
- package/dist/{anthropic-27RFZO35.js → anthropic-5P62HDNR.js} +34 -56
- package/dist/{apify-6WLYAIAS.js → apify-54RZUAGW.js} +31 -49
- package/dist/{brave_search-K2SVJ66F.js → brave_search-AHJ6FTD5.js} +52 -77
- package/dist/{chunk-VK3V2WTY.js → chunk-B4P6YZFS.js} +4 -6
- package/dist/{chunk-BB6ZLMTU.js → chunk-CLEZ6YQ6.js} +2600 -481
- package/dist/chunk-JXHMDBAY.js +45 -0
- package/dist/chunk-LMLX3DJF.js +50 -0
- package/dist/{chunk-YB2FLNWI.js → chunk-OKRZPQ3R.js} +2558 -1926
- package/dist/chunk-SWBNHIO4.js +977 -0
- package/dist/chunk-U67V476Y.js +35 -0
- package/dist/chunk-VLOIDU5U.js +283 -0
- package/dist/{circleci-WV3ITU7Q.js → circleci-UM3NSQJ3.js} +36 -55
- package/dist/{clerk-NFQEFKS4.js → clerk-FE5LQ2CZ.js} +60 -80
- package/dist/{cloudflare_dns-2RK5ASBJ.js → cloudflare_dns-KEZABKUT.js} +90 -113
- package/dist/{cohere-5KEW7LWT.js → cohere-4IPJADXP.js} +33 -49
- package/dist/{confluence-SZE63S46.js → confluence-56QEKNQI.js} +79 -115
- package/dist/{convertapi-QPG2JC5K.js → convertapi-3QRM5K5T.js} +13 -16
- package/dist/{currencyapi-UO2APQRY.js → currencyapi-L6G4OND5.js} +30 -53
- package/dist/{deepseek-LJELIMM3.js → deepseek-LGC6HBFG.js} +30 -38
- package/dist/{docker_hub-2MFXSBOF.js → docker_hub-XDMK3BIU.js} +141 -157
- package/dist/{dropbox-GQYNTTVA.js → dropbox-4QARMFZU.js} +134 -141
- package/dist/{dub-KI2LHXST.js → dub-C6JSJKOT.js} +61 -93
- package/dist/{e2b-WO6ISY3C.js → e2b-6A6TVACJ.js} +39 -69
- package/dist/{exa-IZ7B3BPT.js → exa-SIWWW6AA.js} +49 -77
- package/dist/{fal_ai-LTMF36GJ.js → fal_ai-3IJXOKSP.js} +37 -44
- package/dist/{feishu-WM7SLSFD.js → feishu-L4KDA4DC.js} +4 -6
- package/dist/{feishu_custom_bot-66W3MXH2.js → feishu_custom_bot-SDM75H4P.js} +4 -5
- package/dist/{figma-2Z274VQZ.js → figma-6DD436DN.js} +56 -81
- package/dist/{firehydrant-IFI4R65V.js → firehydrant-SYSGYB3R.js} +40 -53
- package/dist/{fixer-BCCZEB3D.js → fixer-FZG7ASTF.js} +31 -43
- package/dist/{fly-755FXYB5.js → fly-HMRCZBUC.js} +50 -66
- package/dist/{front-4FZKKXXK.js → front-FAFSD7I3.js} +43 -66
- package/dist/{geocodio-WYKDJ3DP.js → geocodio-4D3TWENM.js} +37 -63
- package/dist/{ghost-5BNQTCOH.js → ghost-OSO2FOZS.js} +51 -57
- package/dist/{github-ULELF5VX.js → github-OR4I4RHE.js} +48 -41
- package/dist/{gmail-G34WT64J.js → gmail-5AOPJ63E.js} +26 -36
- package/dist/{googlecalendar-BQU255SC.js → googlecalendar-SOJIJUWH.js} +57 -78
- package/dist/{googledocs-HPCNQXYJ.js → googledocs-QSKN5TLN.js} +14 -22
- package/dist/{grafana-VOV24FIC.js → grafana-R3AIZM7M.js} +95 -122
- package/dist/{graphhopper-D5RXW6AP.js → graphhopper-4CR3QOAX.js} +32 -46
- package/dist/index.d.ts +108 -56
- package/dist/index.js +4 -3
- package/dist/{ip2proxy-DAYO7EKZ.js → ip2proxy-OBCG6X6J.js} +35 -42
- package/dist/{ipgeolocation_io-XD4PSLII.js → ipgeolocation_io-NHH3DTQW.js} +40 -60
- package/dist/{ipqualityscore-K27QEAWK.js → ipqualityscore-7POMCBEC.js} +30 -42
- package/dist/{jina_ai-E6UXFV2P.js → jina_ai-YXVKROV4.js} +32 -58
- package/dist/{jira-ZDSXGQ6W.js → jira-LADO3VJU.js} +116 -126
- package/dist/{langsmith-TIFJRREW.js → langsmith-XZ6UAQFU.js} +101 -121
- package/dist/{lemlist-DASEMJMA.js → lemlist-P74GLNE7.js} +57 -68
- package/dist/{linear-KE6UP4SP.js → linear-CXJ7D37A.js} +109 -118
- package/dist/{logsnag-IMNDN4R5.js → logsnag-EVVHWFLK.js} +31 -48
- package/dist/main.js +103 -102
- package/dist/{mattermost-HHHMUXQA.js → mattermost-WG2MRGBD.js} +45 -62
- package/dist/{mem0-D2FGGOIY.js → mem0-HQWUKG6U.js} +72 -98
- package/dist/{memos-4OVIGFPH.js → memos-SQMJIFOE.js} +68 -122
- package/dist/{metabase-33WCX5YD.js → metabase-E27G2DZI.js} +47 -60
- package/dist/{mistral_ai-QIMZ2JYL.js → mistral_ai-MIL63NIT.js} +35 -40
- package/dist/{mother_duck-M6VWS2VH.js → mother_duck-AIZVCBNR.js} +42 -62
- package/dist/{ngrok-Z2PKQBHH.js → ngrok-XS4DVIQS.js} +42 -58
- package/dist/{notes-SS4RPC4K.js → notes-JEOUSL2Y.js} +3 -5
- package/dist/{notion-FJCNQ6I7.js → notion-U4EZVDW2.js} +83 -97
- package/dist/{open_exchange_rates-WU57WTT5.js → open_exchange_rates-AZSQEYEJ.js} +35 -39
- package/dist/{openai-JODZ4GKT.js → openai-HW3SYMTQ.js} +51 -55
- package/dist/{opengraph_io-SQRAUSV5.js → opengraph_io-QX74MAEL.js} +61 -79
- package/dist/{openrouter-Q5XXEJZ7.js → openrouter-OXSKYL6N.js} +41 -55
- package/dist/{outline-RT2EHJ2X.js → outline-CCQAPDSW.js} +89 -104
- package/dist/{paddle-OF2V7GAC.js → paddle-6KQPSSCK.js} +34 -49
- package/dist/{perplexity-LNZEWLHG.js → perplexity-2TXO7IQE.js} +33 -50
- package/dist/{pinecone-JSJIXZYN.js → pinecone-YOO7NULI.js} +65 -91
- package/dist/{pipedrive-D4CKVUXR.js → pipedrive-Q6RIFIFP.js} +37 -59
- package/dist/{polar-M7ZYP6UR.js → polar-KUMGCES3.js} +43 -53
- package/dist/{posthog-YV7CZOH4.js → posthog-VXQHBSMB.js} +58 -77
- package/dist/{postmark-KYHLECRG.js → postmark-YLIPF52S.js} +52 -71
- package/dist/{prerender-HCMHBKV2.js → prerender-CRY7UJN5.js} +32 -50
- package/dist/{pubmed-WYVLCCN3.js → pubmed-3Z4T5AM7.js} +28 -60
- package/dist/{railway-TWIRD5KR.js → railway-BP37IGFL.js} +32 -39
- package/dist/{readwise-UZ467IQ7.js → readwise-HTKICF4K.js} +62 -78
- package/dist/{render-MECUC5CC.js → render-WIVTUXJH.js} +48 -64
- package/dist/{replicate-A5MEK3SW.js → replicate-JJYPA43D.js} +41 -58
- package/dist/{resend-BC6EAWJQ.js → resend-TKHZVG7A.js} +27 -37
- package/dist/{rootly-ZM3QDUIS.js → rootly-FRSZLG5U.js} +64 -76
- package/dist/{scrapfly-WAML42QJ.js → scrapfly-M5WXGQWE.js} +45 -51
- package/dist/{scrapingbee-DG7PET3V.js → scrapingbee-PMXNLLBK.js} +25 -33
- package/dist/{screenshot_fyi-HY6WTHIO.js → screenshot_fyi-HFW4TAOH.js} +29 -47
- package/dist/{semantic_scholar-C5IZA7IP.js → semantic_scholar-KXVH2VZQ.js} +37 -56
- package/dist/{sentry-OKBPSTDM.js → sentry-WWOT2LRX.js} +66 -85
- package/dist/{shodan-PPC6DYU4.js → shodan-FY635H35.js} +42 -53
- package/dist/{shopify-EWGUHBXO.js → shopify-HQLBVSA5.js} +32 -49
- package/dist/{stripe-6RPDPC5W.js → stripe-GJN2GOHB.js} +4 -5
- package/dist/{supabase-SK7DQ42N.js → supabase-BBNZGQU6.js} +69 -88
- package/dist/{tavily-YCG5VQMH.js → tavily-DPENIBOG.js} +37 -62
- package/dist/{telegram-2OES5FYB.js → telegram-L4NONG6H.js} +168 -177
- package/dist/{telnyx-POOSBBR4.js → telnyx-H67MAEZS.js} +30 -50
- package/dist/{todoist-M7YD6YSS.js → todoist-G2BSP4DX.js} +77 -89
- package/dist/{trello-IS6V5W3E.js → trello-7WMVFDG2.js} +108 -122
- package/dist/{turso-RCFHUFVH.js → turso-ZUAESFC2.js} +52 -64
- package/dist/{twilio-OS2RXFGO.js → twilio-EYFYIX3B.js} +48 -55
- package/dist/{umami-PQ2SJ2LN.js → umami-AXAUDUVF.js} +49 -69
- package/dist/{unsplash-C6BPZO4E.js → unsplash-UCQAWPLR.js} +35 -52
- package/dist/{upstash_redis-WH6UER7H.js → upstash_redis-ZPZ4ASU6.js} +28 -40
- package/dist/{uptimerobot-M3YZGS6Z.js → uptimerobot-4QVKKUD5.js} +11 -12
- package/dist/{v2ex-R4JWTEHN.js → v2ex-VGEFJTYC.js} +36 -61
- package/dist/{vercel-FZVYUOQD.js → vercel-JME4TSCN.js} +124 -150
- package/dist/{webapi-VLM4IKVB.js → webapi-GW5QXWXE.js} +1 -1
- package/dist/{wolfram_alpha_api-2KOLO5DC.js → wolfram_alpha_api-TRGU2MDG.js} +26 -34
- package/dist/{wordpress-XRWGO6LG.js → wordpress-WRUKLCZR.js} +87 -104
- package/dist/{workos-WR4NKOYL.js → workos-ZDW4EHS4.js} +37 -56
- package/dist/{zhihu-BKZIB3WA.js → zhihu-4VI67CWU.js} +35 -57
- package/package.json +3 -3
- package/dist/chunk-2O27H4Y2.js +0 -183
- package/dist/chunk-GKX72JMJ.js +0 -378
- package/dist/chunk-MLKGABMK.js +0 -9
|
@@ -1,40 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderHttpClient
|
|
3
|
+
} from "./chunk-VLOIDU5U.js";
|
|
4
|
+
import {
|
|
5
|
+
asJsonObject,
|
|
6
|
+
trimmedText
|
|
7
|
+
} from "./chunk-JXHMDBAY.js";
|
|
1
8
|
import {
|
|
2
9
|
createProviderPlugin,
|
|
3
10
|
requireApiKey,
|
|
4
11
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import
|
|
7
|
-
guardedFetch
|
|
8
|
-
} from "./chunk-2O27H4Y2.js";
|
|
9
|
-
import "./chunk-GKX72JMJ.js";
|
|
12
|
+
} from "./chunk-B4P6YZFS.js";
|
|
13
|
+
import "./chunk-SWBNHIO4.js";
|
|
10
14
|
import {
|
|
11
15
|
TBError,
|
|
12
16
|
external_exports
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-OKRZPQ3R.js";
|
|
18
|
+
import "./chunk-U67V476Y.js";
|
|
15
19
|
|
|
16
20
|
// ../plugins/src/fixer/api.ts
|
|
17
21
|
var SERVICE = "fixer";
|
|
18
22
|
var API_BASE = "https://data.fixer.io/api";
|
|
19
|
-
|
|
20
|
-
if (typeof value !== "string") return void 0;
|
|
21
|
-
const trimmed = value.trim();
|
|
22
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
23
|
-
}
|
|
24
|
-
function record(value) {
|
|
25
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
26
|
-
}
|
|
23
|
+
var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
|
|
27
24
|
function errorMessage(payload) {
|
|
28
|
-
const body =
|
|
25
|
+
const body = asJsonObject(payload);
|
|
29
26
|
if (body === void 0) return void 0;
|
|
30
|
-
const error =
|
|
31
|
-
return
|
|
27
|
+
const error = asJsonObject(body.error);
|
|
28
|
+
return trimmedText(error?.info) ?? trimmedText(error?.type) ?? trimmedText(body.message);
|
|
32
29
|
}
|
|
33
30
|
function errorType(payload) {
|
|
34
|
-
return
|
|
31
|
+
return trimmedText(asJsonObject(asJsonObject(payload)?.error)?.type);
|
|
35
32
|
}
|
|
36
33
|
function isErrorPayload(payload) {
|
|
37
|
-
const body =
|
|
34
|
+
const body = asJsonObject(payload);
|
|
38
35
|
return body === void 0 ? false : body.success === false || body.error !== void 0;
|
|
39
36
|
}
|
|
40
37
|
var CREDENTIAL_ERROR_TYPES = /* @__PURE__ */ new Set(["invalid_access_key", "missing_access_key"]);
|
|
@@ -58,31 +55,22 @@ function toError(status, payload) {
|
|
|
58
55
|
}
|
|
59
56
|
return upstreamError(status, message);
|
|
60
57
|
}
|
|
61
|
-
async function readPayload(response) {
|
|
62
|
-
const body = await response.text();
|
|
63
|
-
if (body === "") return null;
|
|
64
|
-
try {
|
|
65
|
-
return JSON.parse(body);
|
|
66
|
-
} catch {
|
|
67
|
-
throw upstreamError(502, "Fixer returned an invalid JSON response");
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
58
|
async function request(ctx, path, query = {}) {
|
|
71
59
|
const apiKey = requireApiKey(ctx, SERVICE);
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
const payload =
|
|
84
|
-
if (
|
|
85
|
-
const body =
|
|
60
|
+
const requestQuery = [["access_key", apiKey], ...Object.entries(query)];
|
|
61
|
+
const { data, status } = await http.request({
|
|
62
|
+
path: path.replace(/^\//, ""),
|
|
63
|
+
query: requestQuery,
|
|
64
|
+
invalidJsonMessage: "Fixer returned an invalid JSON response",
|
|
65
|
+
mapError: ({ bodyKind, data: payload2, status: responseStatus }) => bodyKind === "invalid-json" ? upstreamError(502, "Fixer returned an invalid JSON response") : toError(responseStatus, payload2),
|
|
66
|
+
mapTransportError: ({ message }) => upstreamError(
|
|
67
|
+
502,
|
|
68
|
+
message === void 0 ? "Fixer request failed" : `Fixer request failed: ${message}`
|
|
69
|
+
)
|
|
70
|
+
});
|
|
71
|
+
const payload = data ?? null;
|
|
72
|
+
if (isErrorPayload(payload)) throw toError(status, payload);
|
|
73
|
+
const body = asJsonObject(payload);
|
|
86
74
|
if (body === void 0) throw upstreamError(502, "Fixer returned an invalid JSON response");
|
|
87
75
|
return body;
|
|
88
76
|
}
|
|
@@ -1,59 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderHttpClient
|
|
3
|
+
} from "./chunk-VLOIDU5U.js";
|
|
4
|
+
import {
|
|
5
|
+
asJsonObject,
|
|
6
|
+
compactDefined,
|
|
7
|
+
trimmedText
|
|
8
|
+
} from "./chunk-JXHMDBAY.js";
|
|
1
9
|
import {
|
|
2
10
|
createProviderPlugin,
|
|
3
11
|
requireApiKey,
|
|
4
12
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import
|
|
7
|
-
guardedFetch
|
|
8
|
-
} from "./chunk-2O27H4Y2.js";
|
|
9
|
-
import "./chunk-GKX72JMJ.js";
|
|
13
|
+
} from "./chunk-B4P6YZFS.js";
|
|
14
|
+
import "./chunk-SWBNHIO4.js";
|
|
10
15
|
import {
|
|
11
16
|
TBError,
|
|
12
17
|
external_exports
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-OKRZPQ3R.js";
|
|
19
|
+
import "./chunk-U67V476Y.js";
|
|
15
20
|
|
|
16
21
|
// ../plugins/src/fly/api.ts
|
|
17
22
|
var SERVICE = "fly";
|
|
18
23
|
var API_BASE = "https://api.machines.dev/v1/";
|
|
19
|
-
|
|
20
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
21
|
-
}
|
|
22
|
-
function text(value) {
|
|
23
|
-
if (typeof value !== "string") return void 0;
|
|
24
|
-
const trimmed = value.trim();
|
|
25
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
26
|
-
}
|
|
24
|
+
var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
|
|
27
25
|
function requireText(value, field) {
|
|
28
|
-
const result =
|
|
26
|
+
const result = trimmedText(value);
|
|
29
27
|
if (result === void 0) throw new TBError("invalid_argument", `${field} is required`);
|
|
30
28
|
return result;
|
|
31
29
|
}
|
|
32
|
-
function compact(input) {
|
|
33
|
-
return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0));
|
|
34
|
-
}
|
|
35
30
|
function optionalBody(input) {
|
|
36
|
-
const body =
|
|
31
|
+
const body = compactDefined(input);
|
|
37
32
|
return Object.keys(body).length === 0 ? void 0 : body;
|
|
38
33
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
return url.toString();
|
|
46
|
-
}
|
|
47
|
-
function headers(apiKey, hasBody) {
|
|
48
|
-
return {
|
|
49
|
-
accept: "application/json",
|
|
50
|
-
authorization: `Bearer ${apiKey}`,
|
|
51
|
-
...hasBody ? { "content-type": "application/json" } : {}
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function readPayload(response, body) {
|
|
55
|
-
if (body === "") return void 0;
|
|
56
|
-
const contentType = (response.headers.get("content-type") ?? "").toLowerCase();
|
|
34
|
+
function flyPayload(data, bodyKind, headers) {
|
|
35
|
+
if (bodyKind === "empty") return void 0;
|
|
36
|
+
if (bodyKind === "json") return data;
|
|
37
|
+
const body = String(data);
|
|
38
|
+
const contentType = (headers.get("content-type") ?? "").toLowerCase();
|
|
57
39
|
const trimmed = body.trim();
|
|
58
40
|
if (contentType.includes("application/json") || trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
59
41
|
try {
|
|
@@ -66,13 +48,13 @@ function readPayload(response, body) {
|
|
|
66
48
|
}
|
|
67
49
|
function errorMessage(payload, status) {
|
|
68
50
|
if (typeof payload === "string") {
|
|
69
|
-
const message =
|
|
51
|
+
const message = trimmedText(payload);
|
|
70
52
|
if (message !== void 0) return message;
|
|
71
53
|
}
|
|
72
|
-
const fields =
|
|
54
|
+
const fields = asJsonObject(payload);
|
|
73
55
|
if (fields !== void 0) {
|
|
74
56
|
for (const key of ["error", "message", "details"]) {
|
|
75
|
-
const message =
|
|
57
|
+
const message = trimmedText(fields[key]);
|
|
76
58
|
if (message !== void 0) return message;
|
|
77
59
|
}
|
|
78
60
|
}
|
|
@@ -80,20 +62,22 @@ function errorMessage(payload, status) {
|
|
|
80
62
|
}
|
|
81
63
|
async function request(ctx, input) {
|
|
82
64
|
const apiKey = requireApiKey(ctx, SERVICE);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
65
|
+
const result = await http.request({
|
|
66
|
+
path: input.path,
|
|
67
|
+
method: input.method,
|
|
68
|
+
// 空串与 undefined 同等对待:Fly 把 `?region=` 当成真的按空 region 过滤。
|
|
69
|
+
query: Object.entries(input.query ?? {}).filter(([, value]) => value !== void 0 && value !== ""),
|
|
70
|
+
headers: { accept: "application/json", authorization: `Bearer ${apiKey}` },
|
|
71
|
+
...input.body === void 0 ? {} : { json: input.body },
|
|
72
|
+
invalidJson: "text",
|
|
73
|
+
responseType: "auto",
|
|
74
|
+
mapError: (context) => upstreamError(
|
|
75
|
+
context.status,
|
|
76
|
+
errorMessage(flyPayload(context.data, context.bodyKind, context.headers), context.status)
|
|
77
|
+
),
|
|
78
|
+
mapTransportError: ({ message }) => upstreamError(502, message ?? "Fly.io request failed")
|
|
79
|
+
});
|
|
80
|
+
const payload = flyPayload(result.data, result.bodyKind, result.headers);
|
|
97
81
|
if (input.expectJson === false) return payload;
|
|
98
82
|
if (payload === void 0) {
|
|
99
83
|
throw upstreamError(502, "Fly.io returned an empty response");
|
|
@@ -109,7 +93,7 @@ async function listApps(input, ctx) {
|
|
|
109
93
|
return request(ctx, {
|
|
110
94
|
method: "GET",
|
|
111
95
|
path: "apps",
|
|
112
|
-
query: { org_slug: requireText(input.org_slug, "org_slug"), app_role:
|
|
96
|
+
query: { org_slug: requireText(input.org_slug, "org_slug"), app_role: trimmedText(input.app_role) }
|
|
113
97
|
});
|
|
114
98
|
}
|
|
115
99
|
async function getApp(input, ctx) {
|
|
@@ -125,8 +109,8 @@ async function listMachines(input, ctx) {
|
|
|
125
109
|
query: {
|
|
126
110
|
// 显式 false 不发:Fly 只认这两个开关的"出现即为真",带上 `=false` 反而会被当成开启。
|
|
127
111
|
include_deleted: input.include_deleted === true ? true : void 0,
|
|
128
|
-
region:
|
|
129
|
-
state:
|
|
112
|
+
region: trimmedText(input.region),
|
|
113
|
+
state: trimmedText(input.state),
|
|
130
114
|
summary: input.summary === true ? true : void 0
|
|
131
115
|
}
|
|
132
116
|
});
|
|
@@ -137,13 +121,13 @@ async function createMachine(input, ctx) {
|
|
|
137
121
|
method: "POST",
|
|
138
122
|
path: `apps/${app}/machines`,
|
|
139
123
|
// app_name 只进路径,不进请求体 —— 故这里是逐字段列举而不是整体透传。
|
|
140
|
-
body:
|
|
124
|
+
body: compactDefined({
|
|
141
125
|
config: input.config,
|
|
142
126
|
lease_ttl: input.lease_ttl,
|
|
143
127
|
lsvd: input.lsvd,
|
|
144
128
|
min_secrets_version: input.min_secrets_version,
|
|
145
|
-
name:
|
|
146
|
-
region:
|
|
129
|
+
name: trimmedText(input.name),
|
|
130
|
+
region: trimmedText(input.region),
|
|
147
131
|
skip_launch: input.skip_launch,
|
|
148
132
|
skip_secrets: input.skip_secrets,
|
|
149
133
|
skip_service_registration: input.skip_service_registration
|
|
@@ -163,7 +147,7 @@ async function stopMachine(input, ctx) {
|
|
|
163
147
|
expectJson: false,
|
|
164
148
|
path: `${machinePath(input)}/stop`,
|
|
165
149
|
// stop 的 signal/timeout 在 body 里(restart 的同名两参在 query 里,别对调)。
|
|
166
|
-
body: optionalBody({ signal:
|
|
150
|
+
body: optionalBody({ signal: trimmedText(input.signal), timeout: trimmedText(input.timeout) })
|
|
167
151
|
});
|
|
168
152
|
return { ok: true };
|
|
169
153
|
}
|
|
@@ -173,7 +157,7 @@ async function restartMachine(input, ctx) {
|
|
|
173
157
|
expectJson: false,
|
|
174
158
|
path: `${machinePath(input)}/restart`,
|
|
175
159
|
// restart 的 signal/timeout 在 query 里(stop 的同名两参在 body 里,别对调)。
|
|
176
|
-
query: { signal:
|
|
160
|
+
query: { signal: trimmedText(input.signal), timeout: trimmedText(input.timeout) }
|
|
177
161
|
});
|
|
178
162
|
return { ok: true };
|
|
179
163
|
}
|
|
@@ -182,10 +166,10 @@ async function waitForMachine(input, ctx) {
|
|
|
182
166
|
method: "GET",
|
|
183
167
|
path: `${machinePath(input)}/wait`,
|
|
184
168
|
query: {
|
|
185
|
-
from_event_id:
|
|
186
|
-
state:
|
|
169
|
+
from_event_id: trimmedText(input.from_event_id),
|
|
170
|
+
state: trimmedText(input.state),
|
|
187
171
|
timeout: typeof input.timeout === "number" ? input.timeout : void 0,
|
|
188
|
-
version:
|
|
172
|
+
version: trimmedText(input.version)
|
|
189
173
|
}
|
|
190
174
|
});
|
|
191
175
|
}
|
|
@@ -1,93 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderHttpClient
|
|
3
|
+
} from "./chunk-VLOIDU5U.js";
|
|
4
|
+
import {
|
|
5
|
+
asJsonObject,
|
|
6
|
+
trimmedText
|
|
7
|
+
} from "./chunk-JXHMDBAY.js";
|
|
1
8
|
import {
|
|
2
9
|
createProviderPlugin,
|
|
3
10
|
requireApiKey,
|
|
4
11
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import
|
|
7
|
-
guardedFetch
|
|
8
|
-
} from "./chunk-2O27H4Y2.js";
|
|
9
|
-
import "./chunk-GKX72JMJ.js";
|
|
12
|
+
} from "./chunk-B4P6YZFS.js";
|
|
13
|
+
import "./chunk-SWBNHIO4.js";
|
|
10
14
|
import {
|
|
11
15
|
external_exports
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
16
|
+
} from "./chunk-OKRZPQ3R.js";
|
|
17
|
+
import "./chunk-U67V476Y.js";
|
|
14
18
|
|
|
15
19
|
// ../plugins/src/front/api.ts
|
|
16
20
|
var SERVICE = "front";
|
|
17
21
|
var API_BASE = "https://api2.frontapp.com";
|
|
18
22
|
var REQUEST_TIMEOUT_MS = 15e3;
|
|
19
|
-
|
|
20
|
-
if (typeof value !== "string") return void 0;
|
|
21
|
-
const trimmed = value.trim();
|
|
22
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
23
|
-
}
|
|
24
|
-
function record(value) {
|
|
25
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
26
|
-
}
|
|
27
|
-
async function readPayload(response) {
|
|
28
|
-
const body = await response.text().catch(() => "");
|
|
29
|
-
if (body.trim() === "") return {};
|
|
30
|
-
try {
|
|
31
|
-
return JSON.parse(body);
|
|
32
|
-
} catch {
|
|
33
|
-
return body;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
23
|
+
var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
|
|
36
24
|
function errorMessage(payload) {
|
|
37
|
-
if (typeof payload === "string") return
|
|
38
|
-
const body =
|
|
25
|
+
if (typeof payload === "string") return trimmedText(payload);
|
|
26
|
+
const body = asJsonObject(payload);
|
|
39
27
|
if (body === void 0) return void 0;
|
|
40
|
-
const nested =
|
|
41
|
-
return
|
|
28
|
+
const nested = asJsonObject(body.error);
|
|
29
|
+
return trimmedText(body.message) ?? trimmedText(body._error) ?? trimmedText(body.error) ?? trimmedText(nested?.message);
|
|
42
30
|
}
|
|
43
31
|
async function request(ctx, path, input) {
|
|
44
32
|
const apiKey = requireApiKey(ctx, SERVICE);
|
|
45
|
-
const
|
|
33
|
+
const query = [];
|
|
46
34
|
for (const [key, value] of input.query ?? []) {
|
|
47
|
-
if (typeof value === "string" && value !== "")
|
|
48
|
-
else if (typeof value === "number")
|
|
35
|
+
if (typeof value === "string" && value !== "") query.push([key, value]);
|
|
36
|
+
else if (typeof value === "number") query.push([key, value]);
|
|
49
37
|
}
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (timeoutSignal.aborted) throw upstreamError(504, "front \u8BF7\u6C42\u8D85\u65F6");
|
|
66
|
-
throw upstreamError(502, error instanceof Error ? `front \u8BF7\u6C42\u5931\u8D25: ${error.message}` : "front \u8BF7\u6C42\u5931\u8D25");
|
|
67
|
-
}
|
|
68
|
-
const payload = await readPayload(response);
|
|
69
|
-
if (!response.ok) {
|
|
70
|
-
throw upstreamError(
|
|
71
|
-
response.status,
|
|
72
|
-
errorMessage(payload) ?? (response.statusText || `front \u8FD4\u56DE HTTP ${response.status}`)
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
return payload;
|
|
38
|
+
const { data } = await http.request({
|
|
39
|
+
path,
|
|
40
|
+
method: input.method,
|
|
41
|
+
query,
|
|
42
|
+
headers: { accept: "application/json", authorization: `Bearer ${apiKey}` },
|
|
43
|
+
...input.body === void 0 ? {} : { json: input.body },
|
|
44
|
+
timeoutMs: REQUEST_TIMEOUT_MS,
|
|
45
|
+
invalidJson: "text",
|
|
46
|
+
mapError: ({ data: payload, status }) => upstreamError(
|
|
47
|
+
status,
|
|
48
|
+
errorMessage(payload) ?? `front \u8FD4\u56DE HTTP ${status}`
|
|
49
|
+
),
|
|
50
|
+
mapTransportError: ({ kind, message }) => kind === "timeout" ? upstreamError(504, "front \u8BF7\u6C42\u8D85\u65F6") : upstreamError(502, message === void 0 ? "front \u8BF7\u6C42\u5931\u8D25" : `front \u8BF7\u6C42\u5931\u8D25: ${message}`)
|
|
51
|
+
});
|
|
52
|
+
return data ?? {};
|
|
76
53
|
}
|
|
77
54
|
function readResults(payload) {
|
|
78
|
-
const body =
|
|
55
|
+
const body = asJsonObject(payload);
|
|
79
56
|
if (body === void 0) throw upstreamError(502, "front response must be an object");
|
|
80
57
|
if (!Array.isArray(body._results)) throw upstreamError(502, "front response is missing _results");
|
|
81
58
|
return body._results;
|
|
82
59
|
}
|
|
83
60
|
function requiredString(value, fieldName) {
|
|
84
|
-
const result =
|
|
61
|
+
const result = trimmedText(value);
|
|
85
62
|
if (result === void 0) throw upstreamError(502, `${fieldName} is required`);
|
|
86
63
|
return result;
|
|
87
64
|
}
|
|
88
65
|
function nullableString(value) {
|
|
89
66
|
if (value === null || value === void 0) return null;
|
|
90
|
-
return
|
|
67
|
+
return trimmedText(value) ?? null;
|
|
91
68
|
}
|
|
92
69
|
function requiredBoolean(value, fieldName) {
|
|
93
70
|
if (typeof value !== "boolean") throw upstreamError(502, `${fieldName} must be a boolean`);
|
|
@@ -102,7 +79,7 @@ function readStringArray(value) {
|
|
|
102
79
|
return readArray(value).map((item) => requiredString(item, "array item"));
|
|
103
80
|
}
|
|
104
81
|
function readObject(value, name) {
|
|
105
|
-
const body =
|
|
82
|
+
const body = asJsonObject(value);
|
|
106
83
|
if (body === void 0) throw upstreamError(502, `${name} must be an object`);
|
|
107
84
|
return body;
|
|
108
85
|
}
|
|
@@ -131,7 +108,7 @@ function normalizeContact(value) {
|
|
|
131
108
|
links: readStringArray(body.links),
|
|
132
109
|
lists: readArray(body.lists).map((item) => normalizeContactList(item)),
|
|
133
110
|
handles: readArray(body.handles).map((item) => normalizeContactHandle(item)),
|
|
134
|
-
customFields:
|
|
111
|
+
customFields: asJsonObject(body.custom_fields) ?? {},
|
|
135
112
|
isPrivate: requiredBoolean(body.is_private, "contact.is_private")
|
|
136
113
|
};
|
|
137
114
|
}
|
|
@@ -147,7 +124,7 @@ function normalizeTeammate(value) {
|
|
|
147
124
|
isAvailable: requiredBoolean(body.is_available, "teammate.is_available"),
|
|
148
125
|
isBlocked: requiredBoolean(body.is_blocked, "teammate.is_blocked"),
|
|
149
126
|
type: requiredString(body.type, "teammate.type"),
|
|
150
|
-
customFields:
|
|
127
|
+
customFields: asJsonObject(body.custom_fields) ?? {}
|
|
151
128
|
};
|
|
152
129
|
}
|
|
153
130
|
function extractPageToken(next) {
|
|
@@ -160,14 +137,14 @@ function extractPageToken(next) {
|
|
|
160
137
|
}
|
|
161
138
|
function normalizePagination(payload) {
|
|
162
139
|
const body = readObject(payload, "front list response");
|
|
163
|
-
const next =
|
|
140
|
+
const next = trimmedText(asJsonObject(body._pagination)?.next) ?? null;
|
|
164
141
|
return { next, nextPageToken: extractPageToken(next) };
|
|
165
142
|
}
|
|
166
143
|
function buildContactBody(contact, handles) {
|
|
167
144
|
const body = {};
|
|
168
|
-
const name =
|
|
145
|
+
const name = trimmedText(contact.name);
|
|
169
146
|
if (name !== void 0) body.name = name;
|
|
170
|
-
const description =
|
|
147
|
+
const description = trimmedText(contact.description);
|
|
171
148
|
if (description !== void 0) body.description = description;
|
|
172
149
|
if (contact.links !== void 0) body.links = readStringArray(contact.links);
|
|
173
150
|
if (contact.listNames !== void 0) body.list_names = readStringArray(contact.listNames);
|
|
@@ -1,72 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderHttpClient
|
|
3
|
+
} from "./chunk-VLOIDU5U.js";
|
|
4
|
+
import {
|
|
5
|
+
messageFrom
|
|
6
|
+
} from "./chunk-JXHMDBAY.js";
|
|
1
7
|
import {
|
|
2
8
|
createProviderPlugin,
|
|
3
9
|
requireApiKey,
|
|
4
10
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import
|
|
7
|
-
guardedFetch
|
|
8
|
-
} from "./chunk-2O27H4Y2.js";
|
|
9
|
-
import "./chunk-GKX72JMJ.js";
|
|
11
|
+
} from "./chunk-B4P6YZFS.js";
|
|
12
|
+
import "./chunk-SWBNHIO4.js";
|
|
10
13
|
import {
|
|
11
14
|
TBError,
|
|
12
15
|
external_exports
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
16
|
+
} from "./chunk-OKRZPQ3R.js";
|
|
17
|
+
import "./chunk-U67V476Y.js";
|
|
15
18
|
|
|
16
19
|
// ../plugins/src/geocodio/api.ts
|
|
17
20
|
var SERVICE = "geocodio";
|
|
18
|
-
var
|
|
19
|
-
var API_VERSION = "v1.12";
|
|
20
|
-
function record(value) {
|
|
21
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
22
|
-
}
|
|
23
|
-
function text(value) {
|
|
24
|
-
if (typeof value !== "string") return void 0;
|
|
25
|
-
const trimmed = value.trim();
|
|
26
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
27
|
-
}
|
|
28
|
-
function errorMessage(payload) {
|
|
29
|
-
if (typeof payload === "string") return text(payload);
|
|
30
|
-
const body = record(payload);
|
|
31
|
-
return text(body?.error) ?? text(body?.message);
|
|
32
|
-
}
|
|
33
|
-
async function readPayload(response) {
|
|
34
|
-
const body = await response.text().catch(() => "");
|
|
35
|
-
if (body === "") return null;
|
|
36
|
-
try {
|
|
37
|
-
return JSON.parse(body);
|
|
38
|
-
} catch {
|
|
39
|
-
return body;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
21
|
+
var http = createProviderHttpClient({ baseUrl: "https://api.geocod.io/v1.12/", service: SERVICE });
|
|
42
22
|
async function request(ctx, path, query, body) {
|
|
43
23
|
const apiKey = requireApiKey(ctx, SERVICE);
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
payload
|
|
54
|
-
|
|
55
|
-
|
|
24
|
+
const pairs = [
|
|
25
|
+
...Object.entries(query),
|
|
26
|
+
["api_key", apiKey]
|
|
27
|
+
];
|
|
28
|
+
const { data } = await http.request({
|
|
29
|
+
path,
|
|
30
|
+
query: pairs,
|
|
31
|
+
...body === void 0 ? {} : { method: "POST", json: body },
|
|
32
|
+
invalidJson: "text",
|
|
33
|
+
mapError: ({ data: payload, status }) => upstreamError(
|
|
34
|
+
status === 0 ? 502 : status,
|
|
35
|
+
messageFrom(payload, ["error", "message"], "Geocodio request failed")
|
|
36
|
+
),
|
|
37
|
+
mapTransportError: ({ message }) => upstreamError(
|
|
56
38
|
502,
|
|
57
|
-
|
|
58
|
-
)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
throw upstreamError(
|
|
62
|
-
// 上游对状态为 0 的响应兜底成 502;这里保持同样的兜底。
|
|
63
|
-
response.status === 0 ? 502 : response.status,
|
|
64
|
-
errorMessage(payload) ?? (response.statusText || "Geocodio request failed")
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
return payload;
|
|
39
|
+
message === void 0 ? "Geocodio request failed" : `Geocodio request failed: ${message}`
|
|
40
|
+
)
|
|
41
|
+
});
|
|
42
|
+
return data ?? null;
|
|
68
43
|
}
|
|
69
|
-
|
|
44
|
+
function singleGeocode(input, ctx) {
|
|
70
45
|
const hasAny = [
|
|
71
46
|
input.q,
|
|
72
47
|
input.street,
|
|
@@ -78,7 +53,7 @@ async function singleGeocode(input, ctx) {
|
|
|
78
53
|
input.county
|
|
79
54
|
].some((value) => value !== void 0 && value.trim() !== "");
|
|
80
55
|
if (!hasAny) throw new TBError("invalid_argument", "q or at least one address component is required");
|
|
81
|
-
return request(ctx, "
|
|
56
|
+
return request(ctx, "geocode", {
|
|
82
57
|
q: input.q,
|
|
83
58
|
street: input.street,
|
|
84
59
|
street2: input.street2,
|
|
@@ -92,20 +67,19 @@ async function singleGeocode(input, ctx) {
|
|
|
92
67
|
format: input.format
|
|
93
68
|
});
|
|
94
69
|
}
|
|
95
|
-
|
|
96
|
-
return request(ctx, "
|
|
70
|
+
function geocodeBatch(input, ctx) {
|
|
71
|
+
return request(ctx, "geocode", { fields: input.fields, limit: input.limit }, input.addresses);
|
|
97
72
|
}
|
|
98
|
-
|
|
99
|
-
return request(ctx, "
|
|
100
|
-
// 反向查询的坐标拼成一个 `lat,lng` 字符串塞进 q,没有独立的 lat/lng 参数。
|
|
73
|
+
function singleReverseGeocode(input, ctx) {
|
|
74
|
+
return request(ctx, "reverse", {
|
|
101
75
|
q: `${input.lat},${input.lng}`,
|
|
102
76
|
fields: input.fields,
|
|
103
77
|
limit: input.limit,
|
|
104
78
|
format: input.format
|
|
105
79
|
});
|
|
106
80
|
}
|
|
107
|
-
|
|
108
|
-
return request(ctx, "
|
|
81
|
+
function batchReverseGeocode(input, ctx) {
|
|
82
|
+
return request(ctx, "reverse", { fields: input.fields, limit: input.limit }, input.coordinates);
|
|
109
83
|
}
|
|
110
84
|
|
|
111
85
|
// ../plugins/src/geocodio/schema.ts
|