@tool-bridge/server 0.20.0 → 0.21.1
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-ZNWHIJMO.js → airtable-LLZDFN7M.js} +19 -16
- package/dist/{alt_text_generator_ai-X7RMDDM5.js → alt_text_generator_ai-W7O34SNG.js} +4 -4
- package/dist/{amap-3VER75VH.js → amap-VOX4T2AW.js} +4 -4
- package/dist/{anthropic-N7NTB3UC.js → anthropic-G23NN3X5.js} +23 -25
- package/dist/{apify-JB5P5AJI.js → apify-Y3SS734K.js} +20 -19
- package/dist/{brave_search-USL5OOBS.js → brave_search-ZC7OAPSZ.js} +16 -14
- package/dist/{chunk-6ANLYNFB.js → chunk-ATK45BXV.js} +1 -1
- package/dist/{chunk-6X55ALDX.js → chunk-E6JCVKW6.js} +6 -5
- package/dist/{chunk-RVUERWUZ.js → chunk-KMTT3I6D.js} +768 -1048
- package/dist/chunk-R6P4XAE5.js +248 -0
- package/dist/{chunk-3WL6EXYX.js → chunk-U7B6DS2O.js} +1 -1
- package/dist/{chunk-WIGQCP6O.js → chunk-UZM2RXZH.js} +159 -182
- package/dist/chunk-XYBU3WZH.js +71 -0
- package/dist/{circleci-LBGB25LP.js → circleci-3BAX5FCG.js} +20 -24
- package/dist/{clerk-6RX37CNZ.js → clerk-6LEM6TNU.js} +22 -21
- package/dist/{cloudflare_dns-NQGW7FHV.js → cloudflare_dns-KINYTJUD.js} +21 -17
- package/dist/{cohere-XPC2NAEW.js → cohere-XCJ5AJ6B.js} +19 -17
- package/dist/{confluence-ZUG2LT5A.js → confluence-B3EWPZVE.js} +16 -11
- package/dist/{convertapi-ZLXKWV3L.js → convertapi-EUWSQYPF.js} +3 -3
- package/dist/{currencyapi-T3A3HSOD.js → currencyapi-KVTIK3GL.js} +23 -26
- package/dist/{deepseek-NJMOD23E.js → deepseek-PC5YGNC5.js} +27 -17
- package/dist/{docker_hub-D2MQCSJ7.js → docker_hub-C3MA5FU6.js} +4 -4
- package/dist/{dropbox-MI6U3SOT.js → dropbox-XBV7Z2IR.js} +9 -8
- package/dist/{dub-P2BYBYV4.js → dub-LDOFG3HC.js} +22 -19
- package/dist/{e2b-BGKIAE54.js → e2b-JMCPSVBW.js} +20 -20
- package/dist/{exa-EUY7VV4C.js → exa-RAK7O7RD.js} +22 -25
- package/dist/{fal_ai-AAOG5FYJ.js → fal_ai-23E7JPNT.js} +18 -17
- package/dist/feishu-7QRIDUV6.js +12019 -0
- package/dist/{feishu_custom_bot-BWGMNVXF.js → feishu_custom_bot-TJ4K7QNJ.js} +3 -3
- package/dist/{figma-SJSWYCGD.js → figma-E6IX5DTH.js} +21 -23
- package/dist/{firehydrant-MOXK2PST.js → firehydrant-ZBLPQREE.js} +15 -15
- package/dist/{fixer-ISIDUDZU.js → fixer-BWON27UO.js} +4 -4
- package/dist/{fly-U4KPSGBF.js → fly-ZH3HFCZJ.js} +20 -16
- package/dist/{front-ZHM2YX2E.js → front-QCGXYEDJ.js} +20 -23
- package/dist/{geocodio-SVCCAXAV.js → geocodio-YGNI7DA4.js} +4 -4
- package/dist/{ghost-INTR7FIY.js → ghost-EVSGKH2Q.js} +4 -4
- package/dist/{github-T275VVWR.js → github-MA2BGRCJ.js} +28 -27
- package/dist/{gmail-KSSPOE67.js → gmail-E5E6AADE.js} +17 -17
- package/dist/{googlecalendar-JB5RW27L.js → googlecalendar-BTLFPXTD.js} +22 -19
- package/dist/{googledocs-G522PUGW.js → googledocs-BUHL4J2H.js} +6 -5
- package/dist/{grafana-44ZPIV5P.js → grafana-GLU2DWF2.js} +24 -25
- package/dist/{graphhopper-2MORXLOW.js → graphhopper-WSMB3TCD.js} +4 -4
- package/dist/index.d.ts +31 -30
- package/dist/index.js +4 -3
- package/dist/{ip2proxy-R4K4KEMI.js → ip2proxy-EZ64Y4ZH.js} +4 -4
- package/dist/{ipgeolocation_io-H4J55OGI.js → ipgeolocation_io-AA7HAS22.js} +4 -4
- package/dist/{ipqualityscore-XGID4OHA.js → ipqualityscore-BHJXVTJT.js} +4 -4
- package/dist/{jina_ai-7ZVDOR3Z.js → jina_ai-EFBHTBXL.js} +20 -21
- package/dist/{jira-CTIYZTT3.js → jira-HQSHAA5K.js} +20 -16
- package/dist/{langsmith-ISP567FS.js → langsmith-5W6SCT6F.js} +25 -25
- package/dist/{lemlist-OGKK272F.js → lemlist-HJWH6UMK.js} +23 -24
- package/dist/{linear-6JX4E3JI.js → linear-K7RYFYAD.js} +6 -5
- package/dist/{logsnag-BVB36ZCL.js → logsnag-4KFOHL37.js} +20 -22
- package/dist/main.js +103 -102
- package/dist/{mattermost-UECVPZGY.js → mattermost-S2BRCWLQ.js} +21 -17
- package/dist/{mem0-EUA7S2OO.js → mem0-CAW43CIC.js} +15 -15
- package/dist/{memos-BYSBJRWZ.js → memos-TWEGPKFM.js} +39 -34
- package/dist/{metabase-4JXZH3YG.js → metabase-MMSEPCOF.js} +22 -18
- package/dist/{mistral_ai-2C5BTBKW.js → mistral_ai-64BGZQHP.js} +24 -21
- package/dist/{mother_duck-ZGNNNR3X.js → mother_duck-H7PCQNZ2.js} +23 -19
- package/dist/{ngrok-NTPGMRXI.js → ngrok-GQCUGZKJ.js} +17 -22
- package/dist/{notes-KGYXX6N6.js → notes-PFMKRO33.js} +1 -1
- package/dist/{notion-EX3X2G7G.js → notion-DQWZWP4N.js} +20 -17
- package/dist/{open_exchange_rates-2V2LIGPS.js → open_exchange_rates-QMMD735E.js} +4 -4
- package/dist/{openai-KQFQPK7Z.js → openai-W6PX32NZ.js} +22 -16
- package/dist/{opengraph_io-B63SEYJY.js → opengraph_io-HNDBXYNW.js} +4 -4
- package/dist/{openrouter-62A4H62Q.js → openrouter-JJYMEAUL.js} +19 -14
- package/dist/{outline-QC33XLCK.js → outline-MCBNQZYY.js} +18 -20
- package/dist/{paddle-HDZG35Y7.js → paddle-D2SKLUDN.js} +17 -15
- package/dist/{perplexity-M7LOMJWA.js → perplexity-XIFMKUAE.js} +19 -23
- package/dist/{pinecone-Y7YCJRZM.js → pinecone-HUFTALV2.js} +19 -24
- package/dist/{pipedrive-FLJA62UX.js → pipedrive-Y2O7QGFF.js} +22 -23
- package/dist/{polar-AE55Q425.js → polar-TYTOMOSR.js} +19 -17
- package/dist/{posthog-IAY5D3YW.js → posthog-43JAR3VW.js} +29 -24
- package/dist/{postmark-NMKAXDXZ.js → postmark-KL2QJYSG.js} +19 -17
- package/dist/{prerender-CDJM7I7N.js → prerender-MENYM2TY.js} +4 -4
- package/dist/{pubmed-N437ZJOR.js → pubmed-GOXUVVH5.js} +6 -5
- package/dist/{railway-NBWYXCUM.js → railway-V2SID4WV.js} +3 -3
- package/dist/{readwise-QRO3UC3R.js → readwise-CI4GIMMJ.js} +16 -15
- package/dist/{render-NEW7SROG.js → render-SUBJ6YRZ.js} +21 -20
- package/dist/{replicate-73YQLRTY.js → replicate-756MXPYX.js} +20 -21
- package/dist/{resend-R5BAZFHZ.js → resend-ZKH3BTBI.js} +15 -11
- package/dist/{rootly-5BLALPCS.js → rootly-CD2LJHPI.js} +19 -18
- package/dist/{scrapfly-EHFLNNUZ.js → scrapfly-NSRHFDIQ.js} +4 -4
- package/dist/{scrapingbee-UXLYS72S.js → scrapingbee-OQHLAVEY.js} +4 -4
- package/dist/{screenshot_fyi-KC3NLTJ6.js → screenshot_fyi-DVWG3AXC.js} +4 -4
- package/dist/{semantic_scholar-SA5OIUWA.js → semantic_scholar-T4A252KW.js} +21 -20
- package/dist/{sentry-BAE3XLJN.js → sentry-546MNDJG.js} +22 -19
- package/dist/{shodan-FJR6MKKW.js → shodan-C3OON3Z3.js} +4 -4
- package/dist/{shopify-7OA6SLN5.js → shopify-Y2HN2MCQ.js} +23 -19
- package/dist/{stripe-MUWDZGGF.js → stripe-VE3CD3AY.js} +3 -3
- package/dist/{supabase-SWWGNWYR.js → supabase-U2SL4D63.js} +18 -17
- package/dist/{tavily-XQNJ5EDI.js → tavily-KCZHK6HE.js} +20 -20
- package/dist/{telegram-RR6JPZOG.js → telegram-3URFBCMY.js} +4 -4
- package/dist/{telnyx-7PKXOWSO.js → telnyx-CXQ4EZUX.js} +19 -19
- package/dist/{todoist-63X5IUJE.js → todoist-HNPWNYTD.js} +18 -17
- package/dist/{trello-MOG63DAI.js → trello-3W2MIXRP.js} +4 -4
- package/dist/{turso-ENWTSHDL.js → turso-2EQF7C2Z.js} +23 -30
- package/dist/{twilio-FDXUN7VX.js → twilio-4PDBJKWX.js} +6 -5
- package/dist/{umami-TM7PROWF.js → umami-5REN7TGP.js} +23 -28
- package/dist/{unsplash-NWXLKSOW.js → unsplash-EIXL424F.js} +19 -18
- package/dist/{upstash_redis-CUTQ5L2N.js → upstash_redis-G4LQBYHA.js} +17 -13
- package/dist/{uptimerobot-NNO32M3I.js → uptimerobot-KNJ3EYLY.js} +3 -3
- package/dist/{v2ex-24KMSWS7.js → v2ex-RHJ234PZ.js} +35 -18
- package/dist/{vercel-B45LPF6I.js → vercel-AS6NCIC7.js} +21 -18
- package/dist/{wolfram_alpha_api-DKJWVR6G.js → wolfram_alpha_api-3G4PUJWB.js} +4 -4
- package/dist/{wordpress-XYFSDZXY.js → wordpress-KNDAAUV7.js} +21 -17
- package/dist/{workos-BEM7EPHM.js → workos-R6UITSJ7.js} +26 -27
- package/dist/{zhihu-CFHZ4NC7.js → zhihu-AGK4HILK.js} +21 -21
- package/package.json +5 -5
- package/dist/feishu-AN5IJYOW.js +0 -231
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
createAuthedClient
|
|
3
|
+
} from "./chunk-XYBU3WZH.js";
|
|
4
|
+
import "./chunk-E6JCVKW6.js";
|
|
4
5
|
import {
|
|
5
6
|
asJsonObject,
|
|
6
7
|
trimmedText
|
|
7
8
|
} from "./chunk-JXHMDBAY.js";
|
|
8
9
|
import {
|
|
9
10
|
createProviderPlugin,
|
|
10
|
-
requireApiKey,
|
|
11
11
|
upstreamError
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-ATK45BXV.js";
|
|
13
|
+
import "./chunk-U7B6DS2O.js";
|
|
14
14
|
import {
|
|
15
15
|
TBError,
|
|
16
16
|
external_exports
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-UZM2RXZH.js";
|
|
18
18
|
import "./chunk-U67V476Y.js";
|
|
19
19
|
|
|
20
20
|
// ../plugins/src/paddle/api.ts
|
|
21
21
|
var SERVICE = "paddle";
|
|
22
22
|
var API_BASE = "https://api.paddle.com";
|
|
23
|
-
var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
|
|
24
23
|
function pathSegment(value, field) {
|
|
25
24
|
if (value === void 0) throw new TBError("invalid_argument", `${field} \u4E0D\u80FD\u4E3A\u7A7A`);
|
|
26
25
|
return encodeURIComponent(value);
|
|
@@ -42,19 +41,22 @@ function errorMessage(payload, context) {
|
|
|
42
41
|
const message = trimmedText(error?.detail) ?? trimmedText(error?.message) ?? trimmedText(data.message) ?? trimmedText(data.error);
|
|
43
42
|
return message ?? (context.statusText || `Paddle \u8FD4\u56DE HTTP ${context.status}`);
|
|
44
43
|
}
|
|
44
|
+
var http = createAuthedClient({
|
|
45
|
+
baseUrl: API_BASE,
|
|
46
|
+
service: SERVICE,
|
|
47
|
+
auth: { kind: "bearer" },
|
|
48
|
+
headers: { accept: "application/json" },
|
|
49
|
+
// string 错误体原样透出且**不 trim** —— 与标准提取的 trim 语义不同,整段覆写。
|
|
50
|
+
mapError: (context) => upstreamError(context.status, errorMessage(context.data, context))
|
|
51
|
+
});
|
|
45
52
|
async function request(ctx, input) {
|
|
46
|
-
const result = await http.request({
|
|
53
|
+
const result = await http.request(ctx, {
|
|
47
54
|
path: input.path,
|
|
48
55
|
method: input.method,
|
|
49
56
|
query: [...input.searchParams ?? []],
|
|
50
|
-
headers: {
|
|
51
|
-
accept: "application/json",
|
|
52
|
-
authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`,
|
|
53
|
-
...input.skipCount === true ? { "skip-count": "true" } : {}
|
|
54
|
-
},
|
|
57
|
+
...input.skipCount === true ? { headers: { "skip-count": "true" } } : {},
|
|
55
58
|
...input.body === void 0 ? {} : { json: input.body },
|
|
56
|
-
invalidJsonMessage: "Paddle returned malformed JSON"
|
|
57
|
-
mapError: (context) => upstreamError(context.status, errorMessage(context.data, context))
|
|
59
|
+
invalidJsonMessage: "Paddle returned malformed JSON"
|
|
58
60
|
});
|
|
59
61
|
return result.data === void 0 ? null : result.data;
|
|
60
62
|
}
|
|
@@ -1,47 +1,43 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
trimmedText
|
|
7
|
-
} from "./chunk-JXHMDBAY.js";
|
|
2
|
+
createAuthedClient
|
|
3
|
+
} from "./chunk-XYBU3WZH.js";
|
|
4
|
+
import "./chunk-E6JCVKW6.js";
|
|
5
|
+
import "./chunk-JXHMDBAY.js";
|
|
8
6
|
import {
|
|
9
7
|
createProviderPlugin,
|
|
10
|
-
requireApiKey,
|
|
11
8
|
upstreamError
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-ATK45BXV.js";
|
|
10
|
+
import "./chunk-U7B6DS2O.js";
|
|
14
11
|
import {
|
|
15
12
|
TBError,
|
|
16
13
|
external_exports
|
|
17
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-UZM2RXZH.js";
|
|
18
15
|
import "./chunk-U67V476Y.js";
|
|
19
16
|
|
|
20
17
|
// ../plugins/src/perplexity/api.ts
|
|
21
18
|
var SERVICE = "perplexity";
|
|
22
19
|
var API_BASE = "https://api.perplexity.ai";
|
|
23
|
-
var http =
|
|
20
|
+
var http = createAuthedClient({
|
|
21
|
+
baseUrl: API_BASE,
|
|
22
|
+
service: SERVICE,
|
|
23
|
+
auth: { kind: "bearer" },
|
|
24
|
+
headers: { accept: "application/json" },
|
|
25
|
+
errorMessage: {
|
|
26
|
+
keys: ["error.message", "error.detail", "message", "detail"],
|
|
27
|
+
fallback: (status) => `perplexity request failed with ${status}`
|
|
28
|
+
}
|
|
29
|
+
});
|
|
24
30
|
var EMBEDDING_MIN_DIMENSIONS = 128;
|
|
25
31
|
var EMBEDDING_MAX_DIMENSIONS = { "pplx-embed-v1-0.6b": 1024 };
|
|
26
32
|
var EMBEDDING_MAX_DIMENSIONS_FALLBACK = 2560;
|
|
27
|
-
function errorMessage(status, payload, bodyKind) {
|
|
28
|
-
const top = asJsonObject(payload);
|
|
29
|
-
const nested = asJsonObject(top?.error);
|
|
30
|
-
return trimmedText(nested?.message) ?? trimmedText(nested?.detail) ?? trimmedText(top?.message) ?? trimmedText(top?.detail) ?? (bodyKind === "invalid-json" || bodyKind === "text" ? trimmedText(payload) : void 0) ?? `perplexity request failed with ${status}`;
|
|
31
|
-
}
|
|
32
33
|
async function request(ctx, method, path, body) {
|
|
33
|
-
const
|
|
34
|
-
const { data } = await http.request({
|
|
34
|
+
const { data } = await http.request(ctx, {
|
|
35
35
|
path,
|
|
36
36
|
method,
|
|
37
|
-
headers: { accept: "application/json", authorization: `Bearer ${apiKey}` },
|
|
38
37
|
// 上游先过一道 `compactObject`;JSON.stringify 本来就丢 undefined 值,故不再重复一遍。
|
|
39
38
|
...method === "POST" ? { json: body ?? {} } : {},
|
|
40
39
|
invalidJsonMessage: "Perplexity \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
|
|
41
|
-
|
|
42
|
-
status,
|
|
43
|
-
errorMessage(status, payload, bodyKind)
|
|
44
|
-
),
|
|
40
|
+
// 消息里带着本次的 method/path,只能逐请求给,不能挪到 client 级。
|
|
45
41
|
mapTransportError: ({ message }) => upstreamError(
|
|
46
42
|
502,
|
|
47
43
|
`perplexity ${method} ${path} failed before receiving response: ${message ?? "unknown network error"}`
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
createAuthedClient
|
|
3
|
+
} from "./chunk-XYBU3WZH.js";
|
|
4
|
+
import "./chunk-E6JCVKW6.js";
|
|
4
5
|
import {
|
|
5
6
|
asJsonObject,
|
|
6
7
|
compactDefined,
|
|
@@ -8,21 +9,19 @@ import {
|
|
|
8
9
|
} from "./chunk-JXHMDBAY.js";
|
|
9
10
|
import {
|
|
10
11
|
createProviderPlugin,
|
|
11
|
-
requireApiKey,
|
|
12
12
|
upstreamError
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-ATK45BXV.js";
|
|
14
|
+
import "./chunk-U7B6DS2O.js";
|
|
15
15
|
import {
|
|
16
16
|
TBError,
|
|
17
17
|
external_exports
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-UZM2RXZH.js";
|
|
19
19
|
import "./chunk-U67V476Y.js";
|
|
20
20
|
|
|
21
21
|
// ../plugins/src/pinecone/api.ts
|
|
22
22
|
var SERVICE = "pinecone";
|
|
23
23
|
var CONTROL_API_BASE = "https://api.pinecone.io";
|
|
24
24
|
var API_VERSION = "2026-04";
|
|
25
|
-
var http = createProviderHttpClient({ service: SERVICE });
|
|
26
25
|
function requireText(value, field) {
|
|
27
26
|
const result = trimmedText(value);
|
|
28
27
|
if (result === void 0) throw new TBError("invalid_argument", `${field} is required.`);
|
|
@@ -52,14 +51,6 @@ function requireIndexHost(value) {
|
|
|
52
51
|
parsed.hash = "";
|
|
53
52
|
return parsed.origin;
|
|
54
53
|
}
|
|
55
|
-
function headers(apiKey, hasBody) {
|
|
56
|
-
return {
|
|
57
|
-
"accept": "application/json",
|
|
58
|
-
"api-key": apiKey,
|
|
59
|
-
"x-pinecone-api-version": API_VERSION,
|
|
60
|
-
...hasBody ? { "content-type": "application/json" } : {}
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
54
|
function errorMessage(payload, status) {
|
|
64
55
|
if (typeof payload === "string") {
|
|
65
56
|
const message2 = trimmedText(payload);
|
|
@@ -69,21 +60,25 @@ function errorMessage(payload, status) {
|
|
|
69
60
|
const message = trimmedText(fields?.message) ?? trimmedText(asJsonObject(fields?.error)?.message);
|
|
70
61
|
return message ?? `Pinecone request failed with status ${status}`;
|
|
71
62
|
}
|
|
63
|
+
var http = createAuthedClient({
|
|
64
|
+
service: SERVICE,
|
|
65
|
+
auth: { kind: "header", name: "api-key" },
|
|
66
|
+
// 每个请求都带 `x-pinecone-api-version`,它决定响应形状,不是可选优化项。
|
|
67
|
+
headers: { "accept": "application/json", "x-pinecone-api-version": API_VERSION },
|
|
68
|
+
mapError: ({ bodyKind, data, status }) => bodyKind === "invalid-json" ? upstreamError(502, "Pinecone returned invalid JSON") : upstreamError(status, errorMessage(data, status)),
|
|
69
|
+
mapTransportError: ({ message }) => upstreamError(
|
|
70
|
+
502,
|
|
71
|
+
message === void 0 ? "Pinecone request failed" : `Pinecone request failed: ${message}`
|
|
72
|
+
)
|
|
73
|
+
});
|
|
72
74
|
async function request(ctx, input) {
|
|
73
|
-
const
|
|
74
|
-
const result = await http.request({
|
|
75
|
+
const result = await http.request(ctx, {
|
|
75
76
|
baseUrl: `${(input.baseUrl ?? CONTROL_API_BASE).replace(/\/+$/, "")}/`,
|
|
76
77
|
path: input.path,
|
|
77
78
|
method: input.method,
|
|
78
79
|
query: Object.entries(input.query ?? {}),
|
|
79
|
-
headers: headers(apiKey, input.body !== void 0),
|
|
80
80
|
...input.body === void 0 ? {} : { json: compactDeep(input.body) },
|
|
81
|
-
invalidJsonMessage: "Pinecone returned invalid JSON"
|
|
82
|
-
mapError: ({ bodyKind, data, status }) => bodyKind === "invalid-json" ? upstreamError(502, "Pinecone returned invalid JSON") : upstreamError(status, errorMessage(data, status)),
|
|
83
|
-
mapTransportError: ({ message }) => upstreamError(
|
|
84
|
-
502,
|
|
85
|
-
message === void 0 ? "Pinecone request failed" : `Pinecone request failed: ${message}`
|
|
86
|
-
)
|
|
81
|
+
invalidJsonMessage: "Pinecone returned invalid JSON"
|
|
87
82
|
});
|
|
88
83
|
return result.data === void 0 ? {} : result.data;
|
|
89
84
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
createAuthedClient
|
|
3
|
+
} from "./chunk-XYBU3WZH.js";
|
|
4
|
+
import "./chunk-E6JCVKW6.js";
|
|
4
5
|
import {
|
|
5
6
|
asJsonObject,
|
|
6
7
|
trimmedText
|
|
7
8
|
} from "./chunk-JXHMDBAY.js";
|
|
8
9
|
import {
|
|
9
10
|
createProviderPlugin,
|
|
10
|
-
requireApiKey,
|
|
11
11
|
upstreamError
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-ATK45BXV.js";
|
|
13
|
+
import "./chunk-U7B6DS2O.js";
|
|
14
14
|
import {
|
|
15
15
|
TBError,
|
|
16
16
|
external_exports
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-UZM2RXZH.js";
|
|
18
18
|
import "./chunk-U67V476Y.js";
|
|
19
19
|
|
|
20
20
|
// ../plugins/src/pipedrive/schema.ts
|
|
@@ -260,7 +260,20 @@ var pipedriveActions = {
|
|
|
260
260
|
// ../plugins/src/pipedrive/api.ts
|
|
261
261
|
var SERVICE = "pipedrive";
|
|
262
262
|
var API_BASE = "https://api.pipedrive.com";
|
|
263
|
-
var http =
|
|
263
|
+
var http = createAuthedClient({
|
|
264
|
+
baseUrl: `${API_BASE}/`,
|
|
265
|
+
service: SERVICE,
|
|
266
|
+
auth: { kind: "header", name: "x-api-token" },
|
|
267
|
+
headers: { accept: "application/json" },
|
|
268
|
+
errorMessage: {
|
|
269
|
+
keys: ["error", "error_info", "message", "statusText"],
|
|
270
|
+
fallback: (status, statusText) => statusText || `pipedrive \u8FD4\u56DE HTTP ${status}`
|
|
271
|
+
},
|
|
272
|
+
mapTransportError: ({ message }) => upstreamError(
|
|
273
|
+
502,
|
|
274
|
+
message === void 0 ? "pipedrive \u8BF7\u6C42\u5931\u8D25" : `pipedrive \u8BF7\u6C42\u5931\u8D25: ${message}`
|
|
275
|
+
)
|
|
276
|
+
});
|
|
264
277
|
var OPERATIONS = {
|
|
265
278
|
list_persons: { method: "GET", path: "/api/v2/persons", listKey: "persons" },
|
|
266
279
|
get_person: { method: "GET", path: "/api/v2/persons/{id}", idField: "personId", itemKey: "person" },
|
|
@@ -348,27 +361,13 @@ function errorMessage(payload) {
|
|
|
348
361
|
return trimmedText(record.error) ?? trimmedText(record.error_info) ?? trimmedText(record.message) ?? trimmedText(record.statusText);
|
|
349
362
|
}
|
|
350
363
|
async function request(ctx, operation, input) {
|
|
351
|
-
const apiKey = requireApiKey(ctx, SERVICE);
|
|
352
364
|
const hasBody = operation.method === "POST" || operation.method === "PATCH";
|
|
353
|
-
const
|
|
354
|
-
"accept": "application/json",
|
|
355
|
-
"x-api-token": apiKey
|
|
356
|
-
};
|
|
357
|
-
const response = await http.request({
|
|
365
|
+
const response = await http.request(ctx, {
|
|
358
366
|
method: operation.method,
|
|
359
367
|
path: buildPath(operation, input),
|
|
360
|
-
headers,
|
|
361
368
|
...operation.method === "GET" ? { query: Object.entries(buildQuery(operation, input)) } : {},
|
|
362
369
|
...hasBody ? { json: buildBody(operation, input) } : {},
|
|
363
|
-
invalidJson: "text"
|
|
364
|
-
mapError: ({ data, status, statusText }) => upstreamError(
|
|
365
|
-
status,
|
|
366
|
-
errorMessage(data) ?? (statusText || `pipedrive \u8FD4\u56DE HTTP ${status}`)
|
|
367
|
-
),
|
|
368
|
-
mapTransportError: ({ message }) => upstreamError(
|
|
369
|
-
502,
|
|
370
|
-
message === void 0 ? "pipedrive \u8BF7\u6C42\u5931\u8D25" : `pipedrive \u8BF7\u6C42\u5931\u8D25: ${message}`
|
|
371
|
-
)
|
|
370
|
+
invalidJson: "text"
|
|
372
371
|
});
|
|
373
372
|
const record = response.bodyKind === "empty" ? {} : asJsonObject(response.data);
|
|
374
373
|
if (record === void 0) throw upstreamError(502, "pipedrive \u8FD4\u56DE\u7684\u54CD\u5E94\u4E0D\u662F JSON \u5BF9\u8C61");
|
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
createAuthedClient
|
|
3
|
+
} from "./chunk-XYBU3WZH.js";
|
|
4
|
+
import "./chunk-E6JCVKW6.js";
|
|
4
5
|
import {
|
|
5
6
|
asJsonObject,
|
|
6
7
|
trimmedText
|
|
7
8
|
} from "./chunk-JXHMDBAY.js";
|
|
8
9
|
import {
|
|
9
10
|
createProviderPlugin,
|
|
10
|
-
requireApiKey,
|
|
11
11
|
upstreamError
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-ATK45BXV.js";
|
|
13
|
+
import "./chunk-U7B6DS2O.js";
|
|
14
14
|
import {
|
|
15
15
|
TBError,
|
|
16
16
|
external_exports
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-UZM2RXZH.js";
|
|
18
18
|
import "./chunk-U67V476Y.js";
|
|
19
19
|
|
|
20
20
|
// ../plugins/src/polar/api.ts
|
|
21
21
|
var SERVICE = "polar";
|
|
22
22
|
var API_BASE = "https://api.polar.sh/v1";
|
|
23
|
-
var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
|
|
24
23
|
function requireRecord(value, label) {
|
|
25
24
|
const result = asJsonObject(value);
|
|
26
25
|
if (result === void 0) throw new TBError("unavailable", `Polar \u7684${label}\u4E0D\u662F\u5BF9\u8C61`, { retryable: true });
|
|
@@ -74,20 +73,23 @@ function errorDetail(payload) {
|
|
|
74
73
|
}
|
|
75
74
|
return trimmedText(body.message) ?? trimmedText(body.error) ?? trimmedText(body.title);
|
|
76
75
|
}
|
|
76
|
+
var http = createAuthedClient({
|
|
77
|
+
baseUrl: `${API_BASE}/`,
|
|
78
|
+
service: SERVICE,
|
|
79
|
+
auth: { kind: "bearer" },
|
|
80
|
+
headers: { accept: "application/json" },
|
|
81
|
+
// detail 可能是 FastAPI 校验错误数组(取 `detail[0].msg`),标准键序提取表达不了,整段覆写。
|
|
82
|
+
mapError: ({ data: payload, status }) => upstreamError(
|
|
83
|
+
status,
|
|
84
|
+
errorDetail(payload) ?? `Polar \u8FD4\u56DE HTTP ${status}`
|
|
85
|
+
)
|
|
86
|
+
});
|
|
77
87
|
async function request(ctx, path, query) {
|
|
78
|
-
const { data } = await http.request({
|
|
88
|
+
const { data } = await http.request(ctx, {
|
|
79
89
|
path,
|
|
80
90
|
method: "GET",
|
|
81
91
|
query,
|
|
82
|
-
|
|
83
|
-
accept: "application/json",
|
|
84
|
-
authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
|
|
85
|
-
},
|
|
86
|
-
invalidJsonMessage: "Polar \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
|
|
87
|
-
mapError: ({ data: payload, status }) => upstreamError(
|
|
88
|
-
status,
|
|
89
|
-
errorDetail(payload) ?? `Polar \u8FD4\u56DE HTTP ${status}`
|
|
90
|
-
)
|
|
92
|
+
invalidJsonMessage: "Polar \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94"
|
|
91
93
|
});
|
|
92
94
|
return data ?? null;
|
|
93
95
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
createAuthedClient
|
|
3
|
+
} from "./chunk-XYBU3WZH.js";
|
|
4
|
+
import "./chunk-E6JCVKW6.js";
|
|
4
5
|
import {
|
|
5
6
|
booleanValue,
|
|
6
7
|
compactDefined
|
|
@@ -9,20 +10,19 @@ import {
|
|
|
9
10
|
createProviderPlugin,
|
|
10
11
|
requireApiKey,
|
|
11
12
|
upstreamError
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-ATK45BXV.js";
|
|
13
14
|
import {
|
|
14
15
|
assertPublicHttpUrl
|
|
15
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-U7B6DS2O.js";
|
|
16
17
|
import {
|
|
17
18
|
TBError,
|
|
18
19
|
external_exports
|
|
19
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-UZM2RXZH.js";
|
|
20
21
|
import "./chunk-U67V476Y.js";
|
|
21
22
|
|
|
22
23
|
// ../plugins/src/posthog/api.ts
|
|
23
24
|
var SERVICE = "posthog";
|
|
24
25
|
var CURRENT_USER_PATH = "/api/users/@me/";
|
|
25
|
-
var http = createProviderHttpClient({ service: SERVICE });
|
|
26
26
|
function str(value) {
|
|
27
27
|
return typeof value === "string" ? value : void 0;
|
|
28
28
|
}
|
|
@@ -111,8 +111,8 @@ function resolveBaseUrl(ctx) {
|
|
|
111
111
|
return `${parsed.origin}${path}`;
|
|
112
112
|
}
|
|
113
113
|
function resolveAuth(ctx) {
|
|
114
|
-
|
|
115
|
-
return
|
|
114
|
+
requireApiKey(ctx, SERVICE);
|
|
115
|
+
return resolveBaseUrl(ctx);
|
|
116
116
|
}
|
|
117
117
|
function posthogError(status, payload, fallback) {
|
|
118
118
|
const body = nullableRecord(payload);
|
|
@@ -123,27 +123,32 @@ function posthogError(status, payload, fallback) {
|
|
|
123
123
|
function responsePayload(data, bodyKind) {
|
|
124
124
|
return bodyKind === "json" ? data : void 0;
|
|
125
125
|
}
|
|
126
|
+
var http = createAuthedClient({
|
|
127
|
+
service: SERVICE,
|
|
128
|
+
auth: { kind: "bearer" },
|
|
129
|
+
// 迁移前 GET 也带 content-type,保留真实 wire。
|
|
130
|
+
headers: { "content-type": "application/json" },
|
|
131
|
+
// DRF 的 attr 要拼进消息尾巴,标准键序提取表达不了,整段覆写。
|
|
132
|
+
mapError: ({ bodyKind, data, status }) => posthogError(
|
|
133
|
+
status,
|
|
134
|
+
bodyKind === "json" ? data : void 0,
|
|
135
|
+
bodyKind === "empty" ? `${SERVICE} \u8FD4\u56DE HTTP ${status}` : String(data)
|
|
136
|
+
),
|
|
137
|
+
mapTransportError: ({ message }) => new TBError(
|
|
138
|
+
"unavailable",
|
|
139
|
+
`${SERVICE} \u8BF7\u6C42\u5931\u8D25:${message ?? "undefined"}`,
|
|
140
|
+
{ retryable: true }
|
|
141
|
+
)
|
|
142
|
+
});
|
|
126
143
|
async function request(ctx, options) {
|
|
127
|
-
const
|
|
128
|
-
const result = await http.request({
|
|
129
|
-
baseUrl: `${
|
|
144
|
+
const baseUrl = resolveAuth(ctx);
|
|
145
|
+
const result = await http.request(ctx, {
|
|
146
|
+
baseUrl: `${baseUrl}/`,
|
|
130
147
|
path: options.path,
|
|
131
148
|
method: options.method ?? "GET",
|
|
132
149
|
query: Object.entries(options.query ?? {}),
|
|
133
|
-
// 迁移前 GET 也带 content-type,保留真实 wire。
|
|
134
|
-
headers: { "authorization": `Bearer ${auth.token}`, "content-type": "application/json" },
|
|
135
150
|
...options.body === void 0 ? {} : { json: options.body },
|
|
136
|
-
invalidJson: "text"
|
|
137
|
-
mapError: ({ bodyKind, data, status }) => posthogError(
|
|
138
|
-
status,
|
|
139
|
-
bodyKind === "json" ? data : void 0,
|
|
140
|
-
bodyKind === "empty" ? `${SERVICE} \u8FD4\u56DE HTTP ${status}` : String(data)
|
|
141
|
-
),
|
|
142
|
-
mapTransportError: ({ message }) => new TBError(
|
|
143
|
-
"unavailable",
|
|
144
|
-
`${SERVICE} \u8BF7\u6C42\u5931\u8D25:${message ?? "undefined"}`,
|
|
145
|
-
{ retryable: true }
|
|
146
|
-
)
|
|
151
|
+
invalidJson: "text"
|
|
147
152
|
});
|
|
148
153
|
return responsePayload(result.data, result.bodyKind);
|
|
149
154
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
createAuthedClient
|
|
3
|
+
} from "./chunk-XYBU3WZH.js";
|
|
4
|
+
import "./chunk-E6JCVKW6.js";
|
|
4
5
|
import {
|
|
5
6
|
asJsonObject,
|
|
6
7
|
compactDefined,
|
|
@@ -8,20 +9,18 @@ import {
|
|
|
8
9
|
} from "./chunk-JXHMDBAY.js";
|
|
9
10
|
import {
|
|
10
11
|
createProviderPlugin,
|
|
11
|
-
requireApiKey,
|
|
12
12
|
upstreamError
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-ATK45BXV.js";
|
|
14
|
+
import "./chunk-U7B6DS2O.js";
|
|
15
15
|
import {
|
|
16
16
|
TBError,
|
|
17
17
|
external_exports
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-UZM2RXZH.js";
|
|
19
19
|
import "./chunk-U67V476Y.js";
|
|
20
20
|
|
|
21
21
|
// ../plugins/src/postmark/api.ts
|
|
22
22
|
var SERVICE = "postmark";
|
|
23
23
|
var API_BASE = "https://api.postmarkapp.com";
|
|
24
|
-
var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
|
|
25
24
|
var INVALID_TOKEN_CODE = 10;
|
|
26
25
|
var NOT_FOUND_CODES = /* @__PURE__ */ new Set([12, 701, 1001, 1101]);
|
|
27
26
|
var ACCOUNT_BLOCKED_CODES = /* @__PURE__ */ new Set([405, 412, 413]);
|
|
@@ -47,21 +46,24 @@ function postmarkError(status, payload) {
|
|
|
47
46
|
}
|
|
48
47
|
return upstreamError(status, message);
|
|
49
48
|
}
|
|
49
|
+
var http = createAuthedClient({
|
|
50
|
+
baseUrl: API_BASE,
|
|
51
|
+
service: SERVICE,
|
|
52
|
+
auth: { kind: "header", name: "x-postmark-server-token" },
|
|
53
|
+
headers: { accept: "application/json" },
|
|
54
|
+
// ErrorCode 码表比 HTTP 状态准(见文件头),整段覆写而不用标准键序提取。
|
|
55
|
+
mapError: ({ bodyKind, data: payload, status }) => postmarkError(
|
|
56
|
+
status,
|
|
57
|
+
bodyKind === "json" ? asJsonObject(payload) ?? {} : bodyKind === "empty" ? {} : { Message: payload }
|
|
58
|
+
)
|
|
59
|
+
});
|
|
50
60
|
async function request(ctx, input) {
|
|
51
|
-
const { data } = await http.request({
|
|
61
|
+
const { data } = await http.request(ctx, {
|
|
52
62
|
path: input.path,
|
|
53
63
|
method: input.method ?? "GET",
|
|
54
64
|
query: Object.entries(input.query ?? {}),
|
|
55
|
-
headers: {
|
|
56
|
-
"accept": "application/json",
|
|
57
|
-
"x-postmark-server-token": requireApiKey(ctx, SERVICE)
|
|
58
|
-
},
|
|
59
65
|
...input.body === void 0 ? {} : { json: input.body },
|
|
60
|
-
invalidJsonMessage: "Postmark \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94"
|
|
61
|
-
mapError: ({ bodyKind, data: payload, status }) => postmarkError(
|
|
62
|
-
status,
|
|
63
|
-
bodyKind === "json" ? asJsonObject(payload) ?? {} : bodyKind === "empty" ? {} : { Message: payload }
|
|
64
|
-
)
|
|
66
|
+
invalidJsonMessage: "Postmark \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94"
|
|
65
67
|
});
|
|
66
68
|
if (data === void 0) throw responseError("Postmark \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94");
|
|
67
69
|
return data;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createProviderHttpClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-E6JCVKW6.js";
|
|
4
4
|
import {
|
|
5
5
|
asJsonObject,
|
|
6
6
|
trimmedText
|
|
@@ -9,12 +9,12 @@ import {
|
|
|
9
9
|
createProviderPlugin,
|
|
10
10
|
requireApiKey,
|
|
11
11
|
upstreamError
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-ATK45BXV.js";
|
|
13
|
+
import "./chunk-U7B6DS2O.js";
|
|
14
14
|
import {
|
|
15
15
|
TBError,
|
|
16
16
|
external_exports
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-UZM2RXZH.js";
|
|
18
18
|
import "./chunk-U67V476Y.js";
|
|
19
19
|
|
|
20
20
|
// ../plugins/src/prerender/api.ts
|
|
@@ -8,14 +8,15 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
createProviderPlugin,
|
|
10
10
|
upstreamError
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ATK45BXV.js";
|
|
12
12
|
import {
|
|
13
13
|
guardedFetch
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-U7B6DS2O.js";
|
|
15
15
|
import {
|
|
16
16
|
TBError,
|
|
17
|
-
external_exports
|
|
18
|
-
|
|
17
|
+
external_exports,
|
|
18
|
+
isTBError
|
|
19
|
+
} from "./chunk-UZM2RXZH.js";
|
|
19
20
|
import "./chunk-U67V476Y.js";
|
|
20
21
|
|
|
21
22
|
// ../plugins/src/pubmed/api.ts
|
|
@@ -142,7 +143,7 @@ async function requestText(input) {
|
|
|
142
143
|
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
143
144
|
});
|
|
144
145
|
} catch (error) {
|
|
145
|
-
if (error
|
|
146
|
+
if (isTBError(error)) throw error;
|
|
146
147
|
if (error instanceof Error && error.name === "TimeoutError") {
|
|
147
148
|
throw upstreamError(504, `${input.source} request timed out`);
|
|
148
149
|
}
|
|
@@ -7,14 +7,14 @@ import {
|
|
|
7
7
|
createProviderPlugin,
|
|
8
8
|
requireApiKey,
|
|
9
9
|
upstreamError
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ATK45BXV.js";
|
|
11
11
|
import {
|
|
12
12
|
guardedFetch
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-U7B6DS2O.js";
|
|
14
14
|
import {
|
|
15
15
|
TBError,
|
|
16
16
|
external_exports
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-UZM2RXZH.js";
|
|
18
18
|
import "./chunk-U67V476Y.js";
|
|
19
19
|
|
|
20
20
|
// ../plugins/src/railway/api.ts
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
createAuthedClient
|
|
3
|
+
} from "./chunk-XYBU3WZH.js";
|
|
4
|
+
import "./chunk-E6JCVKW6.js";
|
|
4
5
|
import {
|
|
5
6
|
asJsonObject,
|
|
6
7
|
compactDefined,
|
|
@@ -9,20 +10,18 @@ import {
|
|
|
9
10
|
} from "./chunk-JXHMDBAY.js";
|
|
10
11
|
import {
|
|
11
12
|
createProviderPlugin,
|
|
12
|
-
requireApiKey,
|
|
13
13
|
upstreamError
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-ATK45BXV.js";
|
|
15
|
+
import "./chunk-U7B6DS2O.js";
|
|
16
16
|
import {
|
|
17
17
|
TBError,
|
|
18
18
|
external_exports
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-UZM2RXZH.js";
|
|
20
20
|
import "./chunk-U67V476Y.js";
|
|
21
21
|
|
|
22
22
|
// ../plugins/src/readwise/api.ts
|
|
23
23
|
var SERVICE = "readwise";
|
|
24
24
|
var API_BASE = "https://readwise.io/api";
|
|
25
|
-
var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
|
|
26
25
|
function readArray(value) {
|
|
27
26
|
return Array.isArray(value) ? value : [];
|
|
28
27
|
}
|
|
@@ -40,19 +39,21 @@ function errorMessage(payload, status) {
|
|
|
40
39
|
}
|
|
41
40
|
return `Readwise request failed with status ${status}`;
|
|
42
41
|
}
|
|
42
|
+
var http = createAuthedClient({
|
|
43
|
+
baseUrl: `${API_BASE}/`,
|
|
44
|
+
service: SERVICE,
|
|
45
|
+
// Readwise 用的是 `Token <key>`,不是 Bearer —— 写成 Bearer 会一直 401。
|
|
46
|
+
auth: { kind: "token" },
|
|
47
|
+
headers: { accept: "application/json" },
|
|
48
|
+
mapError: ({ bodyKind, data, status }) => bodyKind === "invalid-json" ? new TBError("unavailable", "Readwise \u8FD4\u56DE\u4E86\u975E\u6CD5 JSON", { retryable: true }) : upstreamError(status, errorMessage(data, status))
|
|
49
|
+
});
|
|
43
50
|
async function request(ctx, input) {
|
|
44
|
-
const response = await http.request({
|
|
51
|
+
const response = await http.request(ctx, {
|
|
45
52
|
method: input.method ?? "GET",
|
|
46
53
|
path: input.path,
|
|
47
54
|
query: Object.entries(input.query ?? {}),
|
|
48
|
-
headers: {
|
|
49
|
-
accept: "application/json",
|
|
50
|
-
// Readwise 用的是 `Token <key>`,不是 Bearer —— 写成 Bearer 会一直 401。
|
|
51
|
-
authorization: `Token ${requireApiKey(ctx, SERVICE)}`
|
|
52
|
-
},
|
|
53
55
|
...input.body === void 0 ? {} : { json: input.body },
|
|
54
|
-
invalidJsonMessage: "Readwise \u8FD4\u56DE\u4E86\u975E\u6CD5 JSON"
|
|
55
|
-
mapError: ({ bodyKind, data, status }) => bodyKind === "invalid-json" ? new TBError("unavailable", "Readwise \u8FD4\u56DE\u4E86\u975E\u6CD5 JSON", { retryable: true }) : upstreamError(status, errorMessage(data, status))
|
|
56
|
+
invalidJsonMessage: "Readwise \u8FD4\u56DE\u4E86\u975E\u6CD5 JSON"
|
|
56
57
|
});
|
|
57
58
|
return response.bodyKind === "empty" ? {} : response.data;
|
|
58
59
|
}
|