@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,43 +1,32 @@
|
|
|
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
|
requireCredential,
|
|
4
14
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import
|
|
7
|
-
guardedFetch
|
|
8
|
-
} from "./chunk-2O27H4Y2.js";
|
|
9
|
-
import "./chunk-GKX72JMJ.js";
|
|
15
|
+
} from "./chunk-B4P6YZFS.js";
|
|
16
|
+
import "./chunk-SWBNHIO4.js";
|
|
10
17
|
import {
|
|
11
18
|
TBError,
|
|
12
19
|
external_exports
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
20
|
+
} from "./chunk-OKRZPQ3R.js";
|
|
21
|
+
import "./chunk-U67V476Y.js";
|
|
15
22
|
|
|
16
23
|
// ../plugins/src/confluence/api.ts
|
|
17
24
|
var SERVICE = "confluence";
|
|
18
25
|
var REQUEST_TIMEOUT_MS = 3e4;
|
|
19
26
|
var DEFAULT_LIMIT = 25;
|
|
20
|
-
|
|
21
|
-
if (typeof value !== "string") return void 0;
|
|
22
|
-
const trimmed = value.trim();
|
|
23
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
24
|
-
}
|
|
25
|
-
function record(value) {
|
|
26
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
27
|
-
}
|
|
28
|
-
function integer(value) {
|
|
29
|
-
return typeof value === "number" && Number.isInteger(value) ? value : void 0;
|
|
30
|
-
}
|
|
31
|
-
function boolean(value) {
|
|
32
|
-
return typeof value === "boolean" ? value : void 0;
|
|
33
|
-
}
|
|
34
|
-
function compact(input) {
|
|
35
|
-
return Object.fromEntries(
|
|
36
|
-
Object.entries(input).filter(([, value]) => value !== void 0)
|
|
37
|
-
);
|
|
38
|
-
}
|
|
27
|
+
var http = createProviderHttpClient({ service: SERVICE });
|
|
39
28
|
function requireRecord(value, message) {
|
|
40
|
-
const result =
|
|
29
|
+
const result = asJsonObject(value);
|
|
41
30
|
if (result === void 0) throw upstreamError(502, message);
|
|
42
31
|
return result;
|
|
43
32
|
}
|
|
@@ -65,57 +54,32 @@ function basicAuthHeader(ctx) {
|
|
|
65
54
|
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
66
55
|
return `Basic ${btoa(binary)}`;
|
|
67
56
|
}
|
|
68
|
-
function errorMessage(payload,
|
|
57
|
+
function errorMessage(payload, context) {
|
|
69
58
|
if (typeof payload === "string") {
|
|
70
59
|
const trimmed = payload.trim();
|
|
71
60
|
if (trimmed !== "") return trimmed;
|
|
72
61
|
}
|
|
73
|
-
const body =
|
|
74
|
-
const fromList = Array.isArray(body?.errors) ? body.errors.map((item) =>
|
|
75
|
-
return
|
|
62
|
+
const body = asJsonObject(payload);
|
|
63
|
+
const fromList = Array.isArray(body?.errors) ? body.errors.map((item) => trimmedText(asJsonObject(item)?.message)).find((item) => item !== void 0) : void 0;
|
|
64
|
+
return trimmedText(body?.message) ?? trimmedText(body?.errorMessage) ?? trimmedText(body?.error) ?? fromList ?? trimmedText(context.statusText) ?? "Confluence request failed";
|
|
76
65
|
}
|
|
77
66
|
async function request(ctx, options) {
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
headers,
|
|
92
|
-
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
|
93
|
-
...options.body === void 0 ? {} : { body: JSON.stringify(options.body) }
|
|
94
|
-
});
|
|
95
|
-
} catch (error) {
|
|
96
|
-
if (error instanceof TBError) throw error;
|
|
97
|
-
if (error instanceof Error && error.name === "TimeoutError") {
|
|
98
|
-
throw upstreamError(504, `Confluence request timed out after ${REQUEST_TIMEOUT_MS / 1e3} seconds`);
|
|
99
|
-
}
|
|
100
|
-
throw upstreamError(
|
|
101
|
-
502,
|
|
102
|
-
error instanceof Error ? `Confluence request failed: ${error.message}` : "Confluence request failed"
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
const raw = await response.text().catch(() => "");
|
|
106
|
-
let payload = null;
|
|
107
|
-
if (raw.trim() !== "") {
|
|
108
|
-
try {
|
|
109
|
-
payload = JSON.parse(raw);
|
|
110
|
-
} catch {
|
|
111
|
-
payload = raw;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
if (!response.ok) throw upstreamError(response.status, errorMessage(payload, response));
|
|
115
|
-
return payload;
|
|
67
|
+
const result = await http.request({
|
|
68
|
+
baseUrl: `${siteBaseUrl(ctx)}/`,
|
|
69
|
+
path: options.path,
|
|
70
|
+
method: options.method,
|
|
71
|
+
query: Object.entries(options.query ?? {}),
|
|
72
|
+
headers: { accept: "application/json", authorization: basicAuthHeader(ctx) },
|
|
73
|
+
...options.body === void 0 ? {} : { json: options.body },
|
|
74
|
+
timeoutMs: REQUEST_TIMEOUT_MS,
|
|
75
|
+
invalidJson: "text",
|
|
76
|
+
mapError: (context) => upstreamError(context.status, errorMessage(context.data, context)),
|
|
77
|
+
mapTransportError: ({ kind, message }) => kind === "timeout" ? upstreamError(504, `Confluence request timed out after ${REQUEST_TIMEOUT_MS / 1e3} seconds`) : upstreamError(502, message === void 0 ? "Confluence request failed" : `Confluence request failed: ${message}`)
|
|
78
|
+
});
|
|
79
|
+
return result.data === void 0 ? null : result.data;
|
|
116
80
|
}
|
|
117
81
|
function nextCursor(payload) {
|
|
118
|
-
const link =
|
|
82
|
+
const link = trimmedText(asJsonObject(payload._links)?.next);
|
|
119
83
|
if (link === void 0) return null;
|
|
120
84
|
const questionIndex = link.indexOf("?");
|
|
121
85
|
const search = questionIndex >= 0 ? link.slice(questionIndex) : link;
|
|
@@ -127,46 +91,46 @@ function nextCursor(payload) {
|
|
|
127
91
|
}
|
|
128
92
|
function normalizeSpace(value) {
|
|
129
93
|
const space = requireRecord(value, "Confluence space must be an object");
|
|
130
|
-
return
|
|
131
|
-
id:
|
|
132
|
-
key:
|
|
133
|
-
name:
|
|
134
|
-
type:
|
|
135
|
-
status:
|
|
136
|
-
homepageId:
|
|
94
|
+
return compactDefined({
|
|
95
|
+
id: trimmedText(space.id),
|
|
96
|
+
key: trimmedText(space.key),
|
|
97
|
+
name: trimmedText(space.name),
|
|
98
|
+
type: trimmedText(space.type),
|
|
99
|
+
status: trimmedText(space.status),
|
|
100
|
+
homepageId: trimmedText(space.homepageId ?? asJsonObject(space.homepage)?.id) ?? null,
|
|
137
101
|
raw: space
|
|
138
102
|
});
|
|
139
103
|
}
|
|
140
104
|
function normalizePage(value) {
|
|
141
105
|
const page = requireRecord(value, "Confluence page must be an object");
|
|
142
|
-
const version =
|
|
143
|
-
return
|
|
144
|
-
id:
|
|
145
|
-
status:
|
|
146
|
-
title:
|
|
147
|
-
spaceId:
|
|
148
|
-
parentId:
|
|
149
|
-
createdAt:
|
|
150
|
-
version: version === void 0 ? null :
|
|
151
|
-
number:
|
|
152
|
-
message:
|
|
153
|
-
minorEdit:
|
|
106
|
+
const version = asJsonObject(page.version);
|
|
107
|
+
return compactDefined({
|
|
108
|
+
id: trimmedText(page.id),
|
|
109
|
+
status: trimmedText(page.status),
|
|
110
|
+
title: trimmedText(page.title),
|
|
111
|
+
spaceId: trimmedText(page.spaceId),
|
|
112
|
+
parentId: trimmedText(page.parentId) ?? null,
|
|
113
|
+
createdAt: trimmedText(page.createdAt),
|
|
114
|
+
version: version === void 0 ? null : compactDefined({
|
|
115
|
+
number: integerValue(version.number),
|
|
116
|
+
message: trimmedText(version.message),
|
|
117
|
+
minorEdit: booleanValue(version.minorEdit)
|
|
154
118
|
}),
|
|
155
|
-
body:
|
|
119
|
+
body: asJsonObject(page.body) ?? null,
|
|
156
120
|
raw: page
|
|
157
121
|
});
|
|
158
122
|
}
|
|
159
123
|
function normalizeSearchResult(value) {
|
|
160
124
|
const result = requireRecord(value, "Confluence search result must be an object");
|
|
161
|
-
const content =
|
|
162
|
-
return
|
|
125
|
+
const content = asJsonObject(result.content);
|
|
126
|
+
return compactDefined({
|
|
163
127
|
// 搜索结果的字段有时挂在顶层、有时挂在 content 下,两处都要看。
|
|
164
|
-
id:
|
|
165
|
-
type:
|
|
166
|
-
title:
|
|
167
|
-
url:
|
|
168
|
-
excerpt:
|
|
169
|
-
containerTitle:
|
|
128
|
+
id: trimmedText(result.id ?? content?.id),
|
|
129
|
+
type: trimmedText(result.type ?? content?.type),
|
|
130
|
+
title: trimmedText(result.title ?? content?.title),
|
|
131
|
+
url: trimmedText(result.url ?? result.webUrl ?? result.link),
|
|
132
|
+
excerpt: trimmedText(result.excerpt),
|
|
133
|
+
containerTitle: trimmedText(asJsonObject(result.resultGlobalContainer)?.title),
|
|
170
134
|
raw: result
|
|
171
135
|
});
|
|
172
136
|
}
|
|
@@ -175,10 +139,10 @@ async function searchContent(input, ctx) {
|
|
|
175
139
|
await request(ctx, {
|
|
176
140
|
method: "GET",
|
|
177
141
|
path: "/search",
|
|
178
|
-
query:
|
|
142
|
+
query: compactDefined({
|
|
179
143
|
cql: input.cql,
|
|
180
144
|
limit: input.limit ?? DEFAULT_LIMIT,
|
|
181
|
-
cursor:
|
|
145
|
+
cursor: trimmedText(input.cursor)
|
|
182
146
|
})
|
|
183
147
|
}),
|
|
184
148
|
"Confluence search response must be an object"
|
|
@@ -191,11 +155,11 @@ async function listSpaces(input, ctx) {
|
|
|
191
155
|
await request(ctx, {
|
|
192
156
|
method: "GET",
|
|
193
157
|
path: "/spaces",
|
|
194
|
-
query:
|
|
158
|
+
query: compactDefined({
|
|
195
159
|
limit: input.limit ?? DEFAULT_LIMIT,
|
|
196
|
-
cursor:
|
|
197
|
-
type:
|
|
198
|
-
status:
|
|
160
|
+
cursor: trimmedText(input.cursor),
|
|
161
|
+
type: trimmedText(input.type),
|
|
162
|
+
status: trimmedText(input.status)
|
|
199
163
|
})
|
|
200
164
|
}),
|
|
201
165
|
"Confluence spaces response must be an object"
|
|
@@ -207,7 +171,7 @@ async function getPage(input, ctx) {
|
|
|
207
171
|
const payload = await request(ctx, {
|
|
208
172
|
method: "GET",
|
|
209
173
|
path: `/pages/${encodeURIComponent(input.pageId)}`,
|
|
210
|
-
query:
|
|
174
|
+
query: compactDefined({ "body-format": trimmedText(input.bodyFormat) })
|
|
211
175
|
});
|
|
212
176
|
return { page: normalizePage(payload) };
|
|
213
177
|
}
|
|
@@ -215,31 +179,31 @@ async function createPage(input, ctx) {
|
|
|
215
179
|
const payload = await request(ctx, {
|
|
216
180
|
method: "POST",
|
|
217
181
|
path: "/pages",
|
|
218
|
-
body:
|
|
182
|
+
body: compactDefined({
|
|
219
183
|
spaceId: input.spaceId,
|
|
220
|
-
status:
|
|
184
|
+
status: trimmedText(input.status) ?? "current",
|
|
221
185
|
title: input.title,
|
|
222
|
-
parentId:
|
|
223
|
-
body: { representation:
|
|
186
|
+
parentId: trimmedText(input.parentId),
|
|
187
|
+
body: { representation: trimmedText(input.bodyRepresentation) ?? "storage", value: input.body }
|
|
224
188
|
})
|
|
225
189
|
});
|
|
226
190
|
return { page: normalizePage(payload) };
|
|
227
191
|
}
|
|
228
192
|
async function updatePage(input, ctx) {
|
|
229
|
-
const body =
|
|
193
|
+
const body = trimmedText(input.body);
|
|
230
194
|
const payload = await request(ctx, {
|
|
231
195
|
method: "PUT",
|
|
232
196
|
path: `/pages/${encodeURIComponent(input.pageId)}`,
|
|
233
|
-
body:
|
|
197
|
+
body: compactDefined({
|
|
234
198
|
// Confluence 的 PUT 要求 body 里再带一次 id,少了会 400。
|
|
235
199
|
id: input.pageId,
|
|
236
|
-
status:
|
|
200
|
+
status: trimmedText(input.status) ?? "current",
|
|
237
201
|
title: input.title,
|
|
238
202
|
// 没给正文就整块省略 —— 发一个空 value 会把页面内容清空。
|
|
239
|
-
body: body === void 0 ? void 0 : { representation:
|
|
240
|
-
version:
|
|
203
|
+
body: body === void 0 ? void 0 : { representation: trimmedText(input.bodyRepresentation) ?? "storage", value: body },
|
|
204
|
+
version: compactDefined({
|
|
241
205
|
number: input.versionNumber,
|
|
242
|
-
message:
|
|
206
|
+
message: trimmedText(input.versionMessage),
|
|
243
207
|
minorEdit: input.minorEdit
|
|
244
208
|
})
|
|
245
209
|
})
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
asJsonObject,
|
|
3
|
+
integerValue
|
|
4
|
+
} from "./chunk-JXHMDBAY.js";
|
|
1
5
|
import {
|
|
2
6
|
createProviderPlugin,
|
|
3
7
|
requireApiKey,
|
|
4
8
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-B4P6YZFS.js";
|
|
6
10
|
import {
|
|
7
11
|
assertPublicHttpUrl,
|
|
8
12
|
guardedFetch
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-GKX72JMJ.js";
|
|
13
|
+
} from "./chunk-SWBNHIO4.js";
|
|
11
14
|
import {
|
|
12
15
|
TBError,
|
|
13
16
|
external_exports
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-OKRZPQ3R.js";
|
|
18
|
+
import "./chunk-U67V476Y.js";
|
|
16
19
|
|
|
17
20
|
// ../plugins/src/convertapi/schema.ts
|
|
18
21
|
var convertPdfToDocxInput = external_exports.strictObject({
|
|
@@ -58,17 +61,11 @@ var SERVICE = "convertapi";
|
|
|
58
61
|
var API_BASE = "https://v2.convertapi.com";
|
|
59
62
|
var CONVERT_PDF_TO_DOCX_PATH = "/convert/pdf/to/docx";
|
|
60
63
|
var REQUEST_TIMEOUT_MS = 12e4;
|
|
61
|
-
function toRecord(value) {
|
|
62
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
63
|
-
}
|
|
64
64
|
function text(value) {
|
|
65
65
|
return typeof value === "string" && value !== "" ? value : void 0;
|
|
66
66
|
}
|
|
67
|
-
function integer(value) {
|
|
68
|
-
return typeof value === "number" && Number.isInteger(value) ? value : void 0;
|
|
69
|
-
}
|
|
70
67
|
function errorMessage(payload, status) {
|
|
71
|
-
const record =
|
|
68
|
+
const record = asJsonObject(payload);
|
|
72
69
|
return text(record?.Message) ?? text(record?.message) ?? `ConvertAPI \u8FD4\u56DE HTTP ${status}`;
|
|
73
70
|
}
|
|
74
71
|
function convertapiError(status, message) {
|
|
@@ -126,15 +123,15 @@ async function convertPdfToDocx(input, ctx) {
|
|
|
126
123
|
}
|
|
127
124
|
const payload = await readPayload(response);
|
|
128
125
|
if (!response.ok) throw convertapiError(response.status, errorMessage(payload, response.status));
|
|
129
|
-
const record =
|
|
126
|
+
const record = asJsonObject(payload);
|
|
130
127
|
const rawFiles = Array.isArray(record?.Files) ? record.Files : [];
|
|
131
128
|
const files = rawFiles.map((value) => {
|
|
132
|
-
const file =
|
|
129
|
+
const file = asJsonObject(value);
|
|
133
130
|
if (file === void 0) return void 0;
|
|
134
131
|
return Object.fromEntries(Object.entries({
|
|
135
132
|
fileName: text(file.FileName),
|
|
136
133
|
fileExt: text(file.FileExt),
|
|
137
|
-
fileSize:
|
|
134
|
+
fileSize: integerValue(file.FileSize),
|
|
138
135
|
fileId: text(file.FileId),
|
|
139
136
|
url: text(file.Url)
|
|
140
137
|
}).filter(([, entry]) => entry !== void 0));
|
|
@@ -142,7 +139,7 @@ async function convertPdfToDocx(input, ctx) {
|
|
|
142
139
|
if (files.length === 0) {
|
|
143
140
|
throw upstreamError(502, "ConvertAPI \u7684\u6210\u529F\u54CD\u5E94\u91CC\u6CA1\u6709\u8F6C\u6362\u7ED3\u679C\u6587\u4EF6");
|
|
144
141
|
}
|
|
145
|
-
const conversionCost =
|
|
142
|
+
const conversionCost = integerValue(record?.ConversionCost);
|
|
146
143
|
return conversionCost === void 0 ? { files } : { conversionCost, files };
|
|
147
144
|
}
|
|
148
145
|
|
|
@@ -1,75 +1,52 @@
|
|
|
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/currencyapi/api.ts
|
|
16
20
|
var SERVICE = "currencyapi";
|
|
17
21
|
var API_BASE = "https://api.currencyapi.com";
|
|
18
|
-
|
|
19
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
20
|
-
}
|
|
21
|
-
function text(value) {
|
|
22
|
-
if (typeof value !== "string") return void 0;
|
|
23
|
-
const trimmed = value.trim();
|
|
24
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
25
|
-
}
|
|
22
|
+
var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
|
|
26
23
|
function errorMessage(payload) {
|
|
27
|
-
if (typeof payload === "string") return
|
|
28
|
-
const body =
|
|
29
|
-
return
|
|
30
|
-
}
|
|
31
|
-
async function readPayload(response) {
|
|
32
|
-
const body = await response.text().catch(() => "");
|
|
33
|
-
if (body.trim() === "") return null;
|
|
34
|
-
try {
|
|
35
|
-
return JSON.parse(body);
|
|
36
|
-
} catch {
|
|
37
|
-
return body;
|
|
38
|
-
}
|
|
24
|
+
if (typeof payload === "string") return trimmedText(payload);
|
|
25
|
+
const body = asJsonObject(payload);
|
|
26
|
+
return trimmedText(body?.message) ?? trimmedText(asJsonObject(body?.error)?.message);
|
|
39
27
|
}
|
|
40
28
|
function requireObject(value, field) {
|
|
41
|
-
const body =
|
|
29
|
+
const body = asJsonObject(value);
|
|
42
30
|
if (body === void 0) throw upstreamError(502, `${field} must be an object`);
|
|
43
31
|
return body;
|
|
44
32
|
}
|
|
45
33
|
async function request(ctx, path, query) {
|
|
46
34
|
const apiKey = requireApiKey(ctx, SERVICE);
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
headers: { accept: "application/json", apikey: apiKey }
|
|
58
|
-
});
|
|
59
|
-
payload = await readPayload(response);
|
|
60
|
-
} catch (error) {
|
|
61
|
-
throw upstreamError(
|
|
35
|
+
const { data } = await http.request({
|
|
36
|
+
path,
|
|
37
|
+
query: Object.entries(query ?? {}),
|
|
38
|
+
headers: { accept: "application/json", apikey: apiKey },
|
|
39
|
+
invalidJson: "text",
|
|
40
|
+
mapError: ({ data: payload, status }) => upstreamError(
|
|
41
|
+
status,
|
|
42
|
+
errorMessage(payload) ?? `currencyapi request failed with ${status || 500}`
|
|
43
|
+
),
|
|
44
|
+
mapTransportError: ({ message }) => upstreamError(
|
|
62
45
|
502,
|
|
63
|
-
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
throw upstreamError(
|
|
68
|
-
response.status,
|
|
69
|
-
errorMessage(payload) ?? `currencyapi request failed with ${response.status || 500}`
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
return requireObject(payload, "payload");
|
|
46
|
+
message === void 0 ? "currencyapi request failed" : `currencyapi request failed: ${message}`
|
|
47
|
+
)
|
|
48
|
+
});
|
|
49
|
+
return requireObject(data ?? null, "payload");
|
|
73
50
|
}
|
|
74
51
|
function requireString(value, field) {
|
|
75
52
|
if (typeof value !== "string" || value.trim() === "") {
|
|
@@ -1,42 +1,33 @@
|
|
|
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/deepseek/api.ts
|
|
17
22
|
var SERVICE = "deepseek";
|
|
18
23
|
var API_BASE = "https://api.deepseek.com";
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const trimmed = value.trim();
|
|
23
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
24
|
-
}
|
|
25
|
-
function record(value) {
|
|
26
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
27
|
-
}
|
|
28
|
-
function compact(input) {
|
|
29
|
-
return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0));
|
|
30
|
-
}
|
|
31
|
-
function errorMessage(raw, status) {
|
|
24
|
+
var ANTHROPIC_API_PREFIX = "/anthropic";
|
|
25
|
+
var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
|
|
26
|
+
function errorMessage(payload, bodyKind, status) {
|
|
32
27
|
const fallback = `deepseek request failed with ${status}`;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return text(nested?.message) ?? text(payload?.message) ?? text(raw) ?? fallback;
|
|
37
|
-
} catch {
|
|
38
|
-
return text(raw) ?? fallback;
|
|
39
|
-
}
|
|
28
|
+
const body = asJsonObject(payload);
|
|
29
|
+
const nested = asJsonObject(body?.error);
|
|
30
|
+
return trimmedText(nested?.message) ?? trimmedText(body?.message) ?? (bodyKind === "invalid-json" || bodyKind === "text" ? trimmedText(payload) : void 0) ?? fallback;
|
|
40
31
|
}
|
|
41
32
|
function assertStreamingDisabled(input) {
|
|
42
33
|
if (input.stream === true) {
|
|
@@ -46,18 +37,19 @@ function assertStreamingDisabled(input) {
|
|
|
46
37
|
async function request(ctx, options) {
|
|
47
38
|
const apiKey = requireApiKey(ctx, SERVICE);
|
|
48
39
|
const headers = options.anthropic === true ? { "content-type": "application/json", "x-api-key": apiKey } : { "authorization": `Bearer ${apiKey}`, "content-type": "application/json" };
|
|
49
|
-
const
|
|
40
|
+
const { data } = await http.request({
|
|
41
|
+
path: `${options.anthropic === true ? ANTHROPIC_API_PREFIX : ""}${options.path}`,
|
|
50
42
|
method: options.method ?? "GET",
|
|
51
43
|
headers,
|
|
52
|
-
...options.body === void 0 ? {} : {
|
|
44
|
+
...options.body === void 0 ? {} : { json: options.body },
|
|
45
|
+
invalidJsonMessage: "deepseek returned malformed JSON",
|
|
46
|
+
mapError: ({ bodyKind, data: payload, status }) => upstreamError(
|
|
47
|
+
status,
|
|
48
|
+
errorMessage(payload, bodyKind, status)
|
|
49
|
+
)
|
|
53
50
|
});
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
try {
|
|
57
|
-
return JSON.parse(raw);
|
|
58
|
-
} catch {
|
|
59
|
-
throw upstreamError(502, "deepseek returned malformed JSON");
|
|
60
|
-
}
|
|
51
|
+
if (data === void 0) throw upstreamError(502, "deepseek returned malformed JSON");
|
|
52
|
+
return data;
|
|
61
53
|
}
|
|
62
54
|
function listModels(_input, ctx) {
|
|
63
55
|
return request(ctx, { path: "/models" });
|
|
@@ -67,11 +59,11 @@ function getUserBalance(_input, ctx) {
|
|
|
67
59
|
}
|
|
68
60
|
function createChatCompletion(input, ctx) {
|
|
69
61
|
assertStreamingDisabled(input);
|
|
70
|
-
return request(ctx, { path: "/chat/completions", method: "POST", body:
|
|
62
|
+
return request(ctx, { path: "/chat/completions", method: "POST", body: compactDefined(input) });
|
|
71
63
|
}
|
|
72
64
|
function createAnthropicMessage(input, ctx) {
|
|
73
65
|
assertStreamingDisabled(input);
|
|
74
|
-
return request(ctx, { path: "/v1/messages", method: "POST", body:
|
|
66
|
+
return request(ctx, { path: "/v1/messages", method: "POST", body: compactDefined(input), anthropic: true });
|
|
75
67
|
}
|
|
76
68
|
|
|
77
69
|
// ../plugins/src/deepseek/schema.ts
|