@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,17 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
bytesToBase64
|
|
3
|
+
} from "./chunk-LMLX3DJF.js";
|
|
4
|
+
import {
|
|
5
|
+
asJsonObject,
|
|
6
|
+
compactDefined
|
|
7
|
+
} from "./chunk-JXHMDBAY.js";
|
|
1
8
|
import {
|
|
2
9
|
createProviderPlugin,
|
|
3
10
|
requireApiKey,
|
|
4
11
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-B4P6YZFS.js";
|
|
6
13
|
import {
|
|
7
14
|
guardedFetch
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-GKX72JMJ.js";
|
|
15
|
+
} from "./chunk-SWBNHIO4.js";
|
|
10
16
|
import {
|
|
11
17
|
TBError,
|
|
12
18
|
external_exports
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
19
|
+
} from "./chunk-OKRZPQ3R.js";
|
|
20
|
+
import "./chunk-U67V476Y.js";
|
|
15
21
|
|
|
16
22
|
// ../plugins/src/googledocs/api/shared.ts
|
|
17
23
|
var SERVICE = "googledocs";
|
|
@@ -20,7 +26,6 @@ var DRIVE_API_BASE = "https://www.googleapis.com/drive/v3";
|
|
|
20
26
|
var SHEETS_API_BASE = "https://sheets.googleapis.com/v4";
|
|
21
27
|
var REQUEST_TIMEOUT_MS = 3e4;
|
|
22
28
|
var MAX_ERROR_MESSAGE_LENGTH = 500;
|
|
23
|
-
var BASE64_CHUNK = 8192;
|
|
24
29
|
var RATE_LIMIT_REASONS = /* @__PURE__ */ new Set([
|
|
25
30
|
"rateLimitExceeded",
|
|
26
31
|
"userRateLimitExceeded",
|
|
@@ -41,17 +46,11 @@ var DRIVE_FILE_FIELDS = [
|
|
|
41
46
|
"starred",
|
|
42
47
|
"trashed"
|
|
43
48
|
].join(",");
|
|
44
|
-
|
|
45
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
46
|
-
}
|
|
49
|
+
var record = asJsonObject;
|
|
47
50
|
function optionalText(value) {
|
|
48
51
|
return value === void 0 || value === "" ? void 0 : value;
|
|
49
52
|
}
|
|
50
|
-
|
|
51
|
-
return Object.fromEntries(
|
|
52
|
-
Object.entries(input).filter((entry) => entry[1] !== void 0)
|
|
53
|
-
);
|
|
54
|
-
}
|
|
53
|
+
var compact = compactDefined;
|
|
55
54
|
function requireRecord(value, label) {
|
|
56
55
|
const result = record(value);
|
|
57
56
|
if (result === void 0) throw new TBError("unavailable", `${label}\u4E0D\u662F\u5BF9\u8C61`, { retryable: true });
|
|
@@ -183,13 +182,6 @@ async function requestJson(ctx, input) {
|
|
|
183
182
|
async function requestRecord(ctx, input) {
|
|
184
183
|
return requireRecord(await requestJson(ctx, input), "Google Docs \u54CD\u5E94");
|
|
185
184
|
}
|
|
186
|
-
function base64(bytes) {
|
|
187
|
-
let binary = "";
|
|
188
|
-
for (let offset = 0; offset < bytes.length; offset += BASE64_CHUNK) {
|
|
189
|
-
binary += String.fromCharCode(...bytes.subarray(offset, offset + BASE64_CHUNK));
|
|
190
|
-
}
|
|
191
|
-
return btoa(binary);
|
|
192
|
-
}
|
|
193
185
|
async function runBatch(ctx, documentId, requests, writeControl) {
|
|
194
186
|
const payload = await requestRecord(ctx, {
|
|
195
187
|
url: `${DOCS_API_BASE}/documents/${documentId}:batchUpdate`,
|
|
@@ -617,7 +609,7 @@ async function exportDocumentAsPdf(input, ctx) {
|
|
|
617
609
|
fileId,
|
|
618
610
|
filename: filename === void 0 ? `${fileId}.pdf` : filename.endsWith(".pdf") ? filename : `${filename}.pdf`,
|
|
619
611
|
mimeType: "application/pdf",
|
|
620
|
-
dataBase64:
|
|
612
|
+
dataBase64: bytesToBase64(bytes),
|
|
621
613
|
sizeBytes: bytes.byteLength
|
|
622
614
|
};
|
|
623
615
|
}
|
|
@@ -1,18 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderHttpClient
|
|
3
|
+
} from "./chunk-VLOIDU5U.js";
|
|
4
|
+
import {
|
|
5
|
+
asJsonObject,
|
|
6
|
+
booleanValue,
|
|
7
|
+
compactDefined,
|
|
8
|
+
integerValue,
|
|
9
|
+
trimmedText
|
|
10
|
+
} from "./chunk-JXHMDBAY.js";
|
|
1
11
|
import {
|
|
2
12
|
createProviderPlugin,
|
|
3
13
|
requireApiKey,
|
|
4
14
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-B4P6YZFS.js";
|
|
6
16
|
import {
|
|
7
|
-
assertPublicHttpUrl
|
|
8
|
-
|
|
9
|
-
} from "./chunk-2O27H4Y2.js";
|
|
10
|
-
import "./chunk-GKX72JMJ.js";
|
|
17
|
+
assertPublicHttpUrl
|
|
18
|
+
} from "./chunk-SWBNHIO4.js";
|
|
11
19
|
import {
|
|
12
20
|
TBError,
|
|
13
21
|
external_exports
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
22
|
+
} from "./chunk-OKRZPQ3R.js";
|
|
23
|
+
import "./chunk-U67V476Y.js";
|
|
16
24
|
|
|
17
25
|
// ../plugins/src/grafana/api.ts
|
|
18
26
|
var SERVICE = "grafana";
|
|
@@ -25,47 +33,29 @@ var API_GROUPS = {
|
|
|
25
33
|
folders: "folder.grafana.app"
|
|
26
34
|
};
|
|
27
35
|
var API_VERSION_CACHE_MAX = 256;
|
|
36
|
+
var http = createProviderHttpClient({ service: SERVICE });
|
|
28
37
|
var apiVersionCache = /* @__PURE__ */ new Map();
|
|
29
|
-
function record(value) {
|
|
30
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
31
|
-
}
|
|
32
|
-
function text(value) {
|
|
33
|
-
if (typeof value !== "string") return void 0;
|
|
34
|
-
const trimmed = value.trim();
|
|
35
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
36
|
-
}
|
|
37
|
-
function integer(value) {
|
|
38
|
-
return typeof value === "number" && Number.isInteger(value) ? value : void 0;
|
|
39
|
-
}
|
|
40
|
-
function boolean(value) {
|
|
41
|
-
return typeof value === "boolean" ? value : void 0;
|
|
42
|
-
}
|
|
43
|
-
function compact(input) {
|
|
44
|
-
return Object.fromEntries(
|
|
45
|
-
Object.entries(input).filter(([, value]) => value !== void 0)
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
38
|
function requireText(value, field) {
|
|
49
|
-
const result =
|
|
39
|
+
const result = trimmedText(value);
|
|
50
40
|
if (result === void 0) throw new TBError("invalid_argument", `${field} is required`);
|
|
51
41
|
return result;
|
|
52
42
|
}
|
|
53
43
|
function requireObject(value, field) {
|
|
54
|
-
const object =
|
|
44
|
+
const object = asJsonObject(value);
|
|
55
45
|
if (object === void 0) throw new TBError("invalid_argument", `${field} object is required`);
|
|
56
46
|
return object;
|
|
57
47
|
}
|
|
58
48
|
function objectArray(value) {
|
|
59
49
|
if (!Array.isArray(value)) return [];
|
|
60
50
|
return value.flatMap((item) => {
|
|
61
|
-
const fields =
|
|
51
|
+
const fields = asJsonObject(item);
|
|
62
52
|
return fields === void 0 ? [] : [fields];
|
|
63
53
|
});
|
|
64
54
|
}
|
|
65
55
|
function stringArray(value) {
|
|
66
56
|
if (value === void 0) return void 0;
|
|
67
57
|
return value.flatMap((item) => {
|
|
68
|
-
const trimmed =
|
|
58
|
+
const trimmed = trimmedText(item);
|
|
69
59
|
return trimmed === void 0 ? [] : [trimmed];
|
|
70
60
|
});
|
|
71
61
|
}
|
|
@@ -75,7 +65,7 @@ function configError(message) {
|
|
|
75
65
|
function resolveBaseUrl(ctx) {
|
|
76
66
|
const configured = ctx.config?.baseUrl;
|
|
77
67
|
if (configured !== void 0 && typeof configured !== "string") throw configError("\u5FC5\u987B\u662F\u5B57\u7B26\u4E32");
|
|
78
|
-
const candidate =
|
|
68
|
+
const candidate = trimmedText(configured);
|
|
79
69
|
if (candidate === void 0) {
|
|
80
70
|
throw configError(
|
|
81
71
|
"\u662F\u5FC5\u914D\u9879:\u7ED9\u6302\u8F7D\u8282\u70B9\u914D providerConfig.baseUrl \u6307\u5411\u4F60\u7684 Grafana \u5B9E\u4F8B(\u5982 https://your-stack.grafana.net)\u3002Grafana \u6CA1\u6709\u516C\u5171\u7F3A\u7701\u5730\u5740,\u62FF\u4E0D\u5230\u5B83\u65E0\u6CD5\u51FA\u7AD9"
|
|
@@ -99,53 +89,36 @@ function resolveTarget(ctx) {
|
|
|
99
89
|
return { apiKey: requireApiKey(ctx, SERVICE), baseUrl: resolveBaseUrl(ctx) };
|
|
100
90
|
}
|
|
101
91
|
function errorMessage(payload, status, statusText) {
|
|
102
|
-
const direct =
|
|
92
|
+
const direct = trimmedText(payload);
|
|
103
93
|
if (direct !== void 0) return direct;
|
|
104
|
-
const fields =
|
|
105
|
-
const message =
|
|
106
|
-
return message ??
|
|
107
|
-
}
|
|
108
|
-
function buildUrl(baseUrl, input) {
|
|
109
|
-
const url = new URL(input.path.replace(/^\/+/, ""), `${baseUrl}/`);
|
|
110
|
-
for (const [key, value] of Object.entries(input.query ?? {})) {
|
|
111
|
-
if (value !== void 0) url.searchParams.set(key, String(value));
|
|
112
|
-
}
|
|
113
|
-
for (const [key, values] of Object.entries(input.multiValueQuery ?? {})) {
|
|
114
|
-
for (const value of values ?? []) url.searchParams.append(key, value);
|
|
115
|
-
}
|
|
116
|
-
return url.toString();
|
|
117
|
-
}
|
|
118
|
-
function readPayload(body) {
|
|
119
|
-
if (body.trim() === "") return null;
|
|
120
|
-
try {
|
|
121
|
-
return JSON.parse(body);
|
|
122
|
-
} catch {
|
|
123
|
-
return body;
|
|
124
|
-
}
|
|
94
|
+
const fields = asJsonObject(payload);
|
|
95
|
+
const message = trimmedText(fields?.message) ?? trimmedText(fields?.error) ?? trimmedText(fields?.detail) ?? trimmedText(fields?.title);
|
|
96
|
+
return message ?? trimmedText(statusText) ?? `Grafana request failed with ${status}`;
|
|
125
97
|
}
|
|
126
98
|
async function request(target, input) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
99
|
+
const query = [
|
|
100
|
+
...Object.entries(input.query ?? {}),
|
|
101
|
+
...Object.entries(input.multiValueQuery ?? {})
|
|
102
|
+
];
|
|
103
|
+
const result = await http.request({
|
|
104
|
+
// 尾斜杠保住实例部署上下文路径(`/grafana`);薄层再强制 path 不得换 origin。
|
|
105
|
+
baseUrl: `${target.baseUrl}/`,
|
|
106
|
+
path: input.path,
|
|
107
|
+
method: input.method,
|
|
108
|
+
query,
|
|
109
|
+
headers: { accept: "application/json", authorization: `Bearer ${target.apiKey}` },
|
|
110
|
+
...input.body === void 0 ? {} : { json: input.body },
|
|
111
|
+
invalidJson: "text",
|
|
112
|
+
mapError: ({ data, status, statusText }) => upstreamError(
|
|
113
|
+
status,
|
|
114
|
+
errorMessage(data, status, statusText)
|
|
115
|
+
),
|
|
116
|
+
mapTransportError: ({ message }) => upstreamError(
|
|
117
|
+
502,
|
|
118
|
+
`Grafana request failed: ${message ?? "unknown network error"}`
|
|
119
|
+
)
|
|
120
|
+
});
|
|
121
|
+
return result.data === void 0 ? null : result.data;
|
|
149
122
|
}
|
|
150
123
|
function cacheApiVersion(key, version) {
|
|
151
124
|
apiVersionCache.delete(key);
|
|
@@ -161,7 +134,7 @@ async function resolveApiVersion(target, group) {
|
|
|
161
134
|
if (cached !== void 0) return cached;
|
|
162
135
|
try {
|
|
163
136
|
const payload = await request(target, { method: "GET", path: `/apis/${group}` });
|
|
164
|
-
const served = new Set(objectArray(
|
|
137
|
+
const served = new Set(objectArray(asJsonObject(payload)?.versions).map((entry) => trimmedText(entry.version)).filter((version) => version !== void 0));
|
|
165
138
|
const match = API_VERSION_PREFERENCE.find((version) => served.has(version));
|
|
166
139
|
if (match !== void 0) {
|
|
167
140
|
cacheApiVersion(key, match);
|
|
@@ -174,7 +147,7 @@ async function resolveApiVersion(target, group) {
|
|
|
174
147
|
async function appPath(target, resource, namespace) {
|
|
175
148
|
const group = API_GROUPS[resource];
|
|
176
149
|
const version = await resolveApiVersion(target, group);
|
|
177
|
-
const ns = encodeURIComponent(
|
|
150
|
+
const ns = encodeURIComponent(trimmedText(namespace) ?? DEFAULT_NAMESPACE);
|
|
178
151
|
return `/apis/${group}/${version}/namespaces/${ns}/${resource}`;
|
|
179
152
|
}
|
|
180
153
|
async function appResourcePath(target, resource, namespace, uid) {
|
|
@@ -183,56 +156,56 @@ async function appResourcePath(target, resource, namespace, uid) {
|
|
|
183
156
|
}
|
|
184
157
|
function resourceBody(input) {
|
|
185
158
|
return {
|
|
186
|
-
metadata:
|
|
187
|
-
name:
|
|
188
|
-
generateName:
|
|
189
|
-
resourceVersion:
|
|
159
|
+
metadata: compactDefined({
|
|
160
|
+
name: trimmedText(input.uid),
|
|
161
|
+
generateName: trimmedText(input.generateName),
|
|
162
|
+
resourceVersion: trimmedText(input.resourceVersion),
|
|
190
163
|
annotations: input.parent === void 0 ? void 0 : { [FOLDER_PARENT_ANNOTATION]: input.parent }
|
|
191
164
|
}),
|
|
192
165
|
spec: input.spec
|
|
193
166
|
};
|
|
194
167
|
}
|
|
195
168
|
function normalizeAppResource(value, parentKey) {
|
|
196
|
-
const fields =
|
|
197
|
-
const metadata =
|
|
198
|
-
const spec =
|
|
199
|
-
const annotations =
|
|
169
|
+
const fields = asJsonObject(value) ?? {};
|
|
170
|
+
const metadata = asJsonObject(fields.metadata) ?? {};
|
|
171
|
+
const spec = asJsonObject(fields.spec) ?? {};
|
|
172
|
+
const annotations = asJsonObject(metadata.annotations) ?? {};
|
|
200
173
|
return {
|
|
201
|
-
uid:
|
|
202
|
-
title:
|
|
203
|
-
namespace:
|
|
204
|
-
resourceVersion:
|
|
205
|
-
[parentKey]:
|
|
174
|
+
uid: trimmedText(metadata.name) ?? trimmedText(metadata.uid) ?? null,
|
|
175
|
+
title: trimmedText(spec.title) ?? null,
|
|
176
|
+
namespace: trimmedText(metadata.namespace) ?? null,
|
|
177
|
+
resourceVersion: trimmedText(metadata.resourceVersion) ?? null,
|
|
178
|
+
[parentKey]: trimmedText(annotations[FOLDER_PARENT_ANNOTATION]) ?? null,
|
|
206
179
|
raw: fields
|
|
207
180
|
};
|
|
208
181
|
}
|
|
209
182
|
function normalizeSearchItem(value) {
|
|
210
183
|
return {
|
|
211
184
|
...value,
|
|
212
|
-
id:
|
|
213
|
-
uid:
|
|
214
|
-
title:
|
|
215
|
-
type:
|
|
216
|
-
url:
|
|
217
|
-
isStarred:
|
|
185
|
+
id: integerValue(value.id) ?? null,
|
|
186
|
+
uid: trimmedText(value.uid) ?? null,
|
|
187
|
+
title: trimmedText(value.title) ?? null,
|
|
188
|
+
type: trimmedText(value.type) ?? null,
|
|
189
|
+
url: trimmedText(value.url) ?? null,
|
|
190
|
+
isStarred: booleanValue(value.isStarred) ?? null
|
|
218
191
|
};
|
|
219
192
|
}
|
|
220
193
|
function normalizeDataSource(value) {
|
|
221
|
-
const fields =
|
|
194
|
+
const fields = asJsonObject(value) ?? {};
|
|
222
195
|
return {
|
|
223
196
|
...fields,
|
|
224
|
-
id:
|
|
225
|
-
uid:
|
|
226
|
-
name:
|
|
227
|
-
type:
|
|
228
|
-
access:
|
|
229
|
-
url:
|
|
230
|
-
isDefault:
|
|
231
|
-
readOnly:
|
|
197
|
+
id: integerValue(fields.id) ?? null,
|
|
198
|
+
uid: trimmedText(fields.uid) ?? null,
|
|
199
|
+
name: trimmedText(fields.name) ?? null,
|
|
200
|
+
type: trimmedText(fields.type) ?? null,
|
|
201
|
+
access: trimmedText(fields.access) ?? null,
|
|
202
|
+
url: trimmedText(fields.url) ?? null,
|
|
203
|
+
isDefault: booleanValue(fields.isDefault) ?? null,
|
|
204
|
+
readOnly: booleanValue(fields.readOnly) ?? null
|
|
232
205
|
};
|
|
233
206
|
}
|
|
234
207
|
function deleted(payload) {
|
|
235
|
-
return { deleted: true, raw:
|
|
208
|
+
return { deleted: true, raw: asJsonObject(payload) ?? null };
|
|
236
209
|
}
|
|
237
210
|
function dataSourcePath(uid) {
|
|
238
211
|
return `/api/datasources/uid/${encodeURIComponent(requireText(uid, "uid"))}`;
|
|
@@ -243,12 +216,12 @@ async function listFolders(input, ctx) {
|
|
|
243
216
|
method: "GET",
|
|
244
217
|
path: await appPath(target, "folders", input.namespace),
|
|
245
218
|
// Kubernetes 风格的分页:游标叫 `continue`,入参里叫 `continueToken`。
|
|
246
|
-
query:
|
|
219
|
+
query: compactDefined({ limit: input.limit, continue: trimmedText(input.continueToken) })
|
|
247
220
|
});
|
|
248
|
-
const fields =
|
|
221
|
+
const fields = asJsonObject(payload) ?? {};
|
|
249
222
|
return {
|
|
250
223
|
folders: objectArray(fields.items).map((item) => normalizeAppResource(item, "parentUid")),
|
|
251
|
-
continueToken:
|
|
224
|
+
continueToken: trimmedText(asJsonObject(fields.metadata)?.continue) ?? null,
|
|
252
225
|
raw: fields
|
|
253
226
|
};
|
|
254
227
|
}
|
|
@@ -268,7 +241,7 @@ async function createFolder(input, ctx) {
|
|
|
268
241
|
body: resourceBody({
|
|
269
242
|
uid: input.uid,
|
|
270
243
|
generateName: input.generateName,
|
|
271
|
-
parent:
|
|
244
|
+
parent: trimmedText(input.parentUid),
|
|
272
245
|
spec: { title: requireText(input.title, "title") }
|
|
273
246
|
})
|
|
274
247
|
});
|
|
@@ -284,7 +257,7 @@ async function updateFolder(input, ctx) {
|
|
|
284
257
|
body: resourceBody({
|
|
285
258
|
uid,
|
|
286
259
|
resourceVersion: input.resourceVersion,
|
|
287
|
-
parent:
|
|
260
|
+
parent: trimmedText(input.parentUid),
|
|
288
261
|
spec: { title: requireText(input.title, "title") }
|
|
289
262
|
})
|
|
290
263
|
});
|
|
@@ -302,9 +275,9 @@ async function searchDashboards(input, ctx) {
|
|
|
302
275
|
const payload = await request(resolveTarget(ctx), {
|
|
303
276
|
method: "GET",
|
|
304
277
|
path: "/api/search",
|
|
305
|
-
query:
|
|
306
|
-
query:
|
|
307
|
-
type:
|
|
278
|
+
query: compactDefined({
|
|
279
|
+
query: trimmedText(input.query),
|
|
280
|
+
type: trimmedText(input.type),
|
|
308
281
|
starred: input.starred,
|
|
309
282
|
limit: input.limit,
|
|
310
283
|
page: input.page
|
|
@@ -334,7 +307,7 @@ async function createDashboard(input, ctx) {
|
|
|
334
307
|
body: resourceBody({
|
|
335
308
|
uid: input.uid,
|
|
336
309
|
generateName: input.generateName,
|
|
337
|
-
parent:
|
|
310
|
+
parent: trimmedText(input.folderUid),
|
|
338
311
|
spec: requireObject(input.spec, "spec")
|
|
339
312
|
})
|
|
340
313
|
});
|
|
@@ -349,7 +322,7 @@ async function updateDashboard(input, ctx) {
|
|
|
349
322
|
body: resourceBody({
|
|
350
323
|
uid,
|
|
351
324
|
resourceVersion: input.resourceVersion,
|
|
352
|
-
parent:
|
|
325
|
+
parent: trimmedText(input.folderUid),
|
|
353
326
|
spec: requireObject(input.spec, "spec")
|
|
354
327
|
})
|
|
355
328
|
});
|
|
@@ -379,8 +352,8 @@ async function createDataSource(input, ctx) {
|
|
|
379
352
|
body: requireObject(input.dataSource, "dataSource")
|
|
380
353
|
});
|
|
381
354
|
return {
|
|
382
|
-
dataSource: normalizeDataSource(
|
|
383
|
-
raw:
|
|
355
|
+
dataSource: normalizeDataSource(asJsonObject(payload)?.datasource ?? payload),
|
|
356
|
+
raw: asJsonObject(payload) ?? {}
|
|
384
357
|
};
|
|
385
358
|
}
|
|
386
359
|
async function updateDataSource(input, ctx) {
|
|
@@ -390,8 +363,8 @@ async function updateDataSource(input, ctx) {
|
|
|
390
363
|
body: requireObject(input.dataSource, "dataSource")
|
|
391
364
|
});
|
|
392
365
|
return {
|
|
393
|
-
dataSource: normalizeDataSource(
|
|
394
|
-
raw:
|
|
366
|
+
dataSource: normalizeDataSource(asJsonObject(payload)?.datasource ?? payload),
|
|
367
|
+
raw: asJsonObject(payload) ?? {}
|
|
395
368
|
};
|
|
396
369
|
}
|
|
397
370
|
async function deleteDataSource(input, ctx) {
|
|
@@ -408,14 +381,14 @@ async function getAlertRule(input, ctx) {
|
|
|
408
381
|
method: "GET",
|
|
409
382
|
path: `/api/v1/provisioning/alert-rules/${uid}`
|
|
410
383
|
});
|
|
411
|
-
return { alertRule:
|
|
384
|
+
return { alertRule: asJsonObject(payload) ?? {} };
|
|
412
385
|
}
|
|
413
386
|
async function listAlertInstances(input, ctx) {
|
|
414
387
|
const payload = await request(resolveTarget(ctx), {
|
|
415
388
|
method: "GET",
|
|
416
389
|
// 内置 Alertmanager 的 v2 端点,与 App Platform 的版本协商无关。
|
|
417
390
|
path: "/api/alertmanager/grafana/api/v2/alerts",
|
|
418
|
-
query:
|
|
391
|
+
query: compactDefined({ active: input.active, silenced: input.silenced, inhibited: input.inhibited })
|
|
419
392
|
});
|
|
420
393
|
return { alertInstances: objectArray(payload) };
|
|
421
394
|
}
|
|
@@ -1,75 +1,61 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderHttpClient
|
|
3
|
+
} from "./chunk-VLOIDU5U.js";
|
|
4
|
+
import {
|
|
5
|
+
asJsonObject
|
|
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/graphhopper/api.ts
|
|
17
20
|
var SERVICE = "graphhopper";
|
|
18
21
|
var API_BASE = "https://graphhopper.com";
|
|
19
22
|
var API_PREFIX = "/api/1";
|
|
20
|
-
|
|
21
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
22
|
-
}
|
|
23
|
+
var http = createProviderHttpClient({ baseUrl: `${API_BASE}${API_PREFIX}/`, service: SERVICE });
|
|
23
24
|
function text(value) {
|
|
24
25
|
return typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
25
26
|
}
|
|
26
|
-
function errorMessage(payload,
|
|
27
|
+
function errorMessage(payload, context) {
|
|
27
28
|
if (typeof payload === "string" && payload.trim() !== "") return payload;
|
|
28
|
-
const body =
|
|
29
|
+
const body = asJsonObject(payload);
|
|
29
30
|
if (body !== void 0) {
|
|
30
31
|
const direct = text(body.message) ?? text(body.error) ?? text(body.details);
|
|
31
32
|
if (direct !== void 0) return direct;
|
|
32
33
|
if (Array.isArray(body.hints)) {
|
|
33
34
|
for (const hint of body.hints) {
|
|
34
|
-
const message = text(
|
|
35
|
+
const message = text(asJsonObject(hint)?.message);
|
|
35
36
|
if (message !== void 0) return message;
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
|
-
return text(
|
|
40
|
+
return text(context.statusText) ?? "GraphHopper request failed";
|
|
40
41
|
}
|
|
41
42
|
async function request(ctx, path, query) {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
});
|
|
59
|
-
const raw = await response.text();
|
|
60
|
-
if (raw.trim() !== "") {
|
|
61
|
-
try {
|
|
62
|
-
payload = JSON.parse(raw);
|
|
63
|
-
} catch {
|
|
64
|
-
payload = raw;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
} catch (error) {
|
|
68
|
-
const message = error instanceof Error ? `GraphHopper request failed: ${error.message}` : "GraphHopper request failed";
|
|
69
|
-
throw upstreamError(502, message);
|
|
70
|
-
}
|
|
71
|
-
if (!response.ok) throw upstreamError(response.status, errorMessage(payload, response));
|
|
72
|
-
return payload;
|
|
43
|
+
const result = await http.request({
|
|
44
|
+
path,
|
|
45
|
+
method: "GET",
|
|
46
|
+
query: [
|
|
47
|
+
...Object.entries(query),
|
|
48
|
+
["key", requireApiKey(ctx, SERVICE)]
|
|
49
|
+
],
|
|
50
|
+
headers: { accept: "application/json" },
|
|
51
|
+
invalidJson: "text",
|
|
52
|
+
mapError: (context) => upstreamError(context.status, errorMessage(context.data, context)),
|
|
53
|
+
mapTransportError: ({ message }) => upstreamError(
|
|
54
|
+
502,
|
|
55
|
+
message === void 0 ? "GraphHopper request failed" : `GraphHopper request failed: ${message}`
|
|
56
|
+
)
|
|
57
|
+
});
|
|
58
|
+
return result.bodyKind === "empty" ? null : result.data;
|
|
73
59
|
}
|
|
74
60
|
async function calculateRoute(input, ctx) {
|
|
75
61
|
return request(ctx, "/route", {
|
|
@@ -159,7 +145,7 @@ async function computeIsochrone(input, ctx) {
|
|
|
159
145
|
async function listProfiles(_input, ctx) {
|
|
160
146
|
const payload = await request(ctx, "/profiles", {});
|
|
161
147
|
if (Array.isArray(payload)) return { profiles: payload };
|
|
162
|
-
const profiles =
|
|
148
|
+
const profiles = asJsonObject(payload)?.profiles;
|
|
163
149
|
return { profiles: Array.isArray(profiles) ? profiles : [] };
|
|
164
150
|
}
|
|
165
151
|
|