@tool-bridge/server 0.16.0 → 0.17.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-NOSOMOVB.js} +106 -114
- package/dist/{alt_text_generator_ai-4DIRIDKL.js → alt_text_generator_ai-BHIJ4LW5.js} +25 -16
- package/dist/{amap-LGVGNPML.js → amap-QRLP4TWZ.js} +114 -123
- package/dist/{anthropic-27RFZO35.js → anthropic-IEOI36EV.js} +34 -56
- package/dist/{apify-6WLYAIAS.js → apify-3CCYTQVK.js} +31 -49
- package/dist/{brave_search-K2SVJ66F.js → brave_search-PZNYDQG7.js} +52 -77
- package/dist/chunk-JXHMDBAY.js +45 -0
- package/dist/chunk-LMLX3DJF.js +50 -0
- package/dist/{chunk-YB2FLNWI.js → chunk-RVWZN3CI.js} +2103 -1775
- package/dist/{chunk-BB6ZLMTU.js → chunk-TLNUIPFZ.js} +492 -300
- package/dist/chunk-U5UHT7CX.js +977 -0
- package/dist/chunk-U67V476Y.js +35 -0
- package/dist/chunk-WW2IMPQK.js +283 -0
- package/dist/{chunk-VK3V2WTY.js → chunk-YASUMV2K.js} +4 -6
- package/dist/{circleci-WV3ITU7Q.js → circleci-VSJ4O5FC.js} +36 -55
- package/dist/{clerk-NFQEFKS4.js → clerk-CC2JZBZI.js} +60 -80
- package/dist/{cloudflare_dns-2RK5ASBJ.js → cloudflare_dns-PJEBSEYQ.js} +90 -113
- package/dist/{cohere-5KEW7LWT.js → cohere-KBACYSPF.js} +33 -49
- package/dist/{confluence-SZE63S46.js → confluence-2PX3O7G5.js} +79 -115
- package/dist/{convertapi-QPG2JC5K.js → convertapi-BVOTD2PJ.js} +13 -16
- package/dist/{currencyapi-UO2APQRY.js → currencyapi-6ZQ2VNQ7.js} +30 -53
- package/dist/{deepseek-LJELIMM3.js → deepseek-MB3WVVTB.js} +30 -38
- package/dist/{docker_hub-2MFXSBOF.js → docker_hub-7CLQL2IJ.js} +141 -157
- package/dist/{dropbox-GQYNTTVA.js → dropbox-VFYDVUNK.js} +134 -141
- package/dist/{dub-KI2LHXST.js → dub-QN3EETJY.js} +61 -93
- package/dist/{e2b-WO6ISY3C.js → e2b-NKC3Y776.js} +39 -69
- package/dist/{exa-IZ7B3BPT.js → exa-KKZ6F25K.js} +49 -77
- package/dist/{fal_ai-LTMF36GJ.js → fal_ai-25LYJD2O.js} +37 -44
- package/dist/{feishu-WM7SLSFD.js → feishu-NRT55B3Q.js} +4 -6
- package/dist/{feishu_custom_bot-66W3MXH2.js → feishu_custom_bot-3W3XXUG4.js} +4 -5
- package/dist/{figma-2Z274VQZ.js → figma-4FLP35TC.js} +56 -81
- package/dist/{firehydrant-IFI4R65V.js → firehydrant-BLXPLZ3X.js} +40 -53
- package/dist/{fixer-BCCZEB3D.js → fixer-4OR62TGE.js} +31 -43
- package/dist/{fly-755FXYB5.js → fly-MYCKOZZK.js} +50 -66
- package/dist/{front-4FZKKXXK.js → front-3DFYVMF3.js} +43 -66
- package/dist/{geocodio-WYKDJ3DP.js → geocodio-CXMD6VKA.js} +37 -63
- package/dist/{ghost-5BNQTCOH.js → ghost-4UUE737W.js} +51 -57
- package/dist/{github-ULELF5VX.js → github-WFS2ON2N.js} +48 -41
- package/dist/{gmail-G34WT64J.js → gmail-KW7FXA7A.js} +26 -36
- package/dist/{googlecalendar-BQU255SC.js → googlecalendar-AMH5JQMC.js} +57 -78
- package/dist/{googledocs-HPCNQXYJ.js → googledocs-R5VA6CKD.js} +14 -22
- package/dist/{grafana-VOV24FIC.js → grafana-IT6DWIVB.js} +95 -122
- package/dist/{graphhopper-D5RXW6AP.js → graphhopper-TYFDJZWC.js} +32 -46
- package/dist/index.d.ts +57 -50
- package/dist/index.js +4 -3
- package/dist/{ip2proxy-DAYO7EKZ.js → ip2proxy-GJ4HXVXO.js} +35 -42
- package/dist/{ipgeolocation_io-XD4PSLII.js → ipgeolocation_io-OAGR6PRF.js} +40 -60
- package/dist/{ipqualityscore-K27QEAWK.js → ipqualityscore-BCKAMDGL.js} +30 -42
- package/dist/{jina_ai-E6UXFV2P.js → jina_ai-N3NXRVIZ.js} +32 -58
- package/dist/{jira-ZDSXGQ6W.js → jira-CHLBKWLO.js} +116 -126
- package/dist/{langsmith-TIFJRREW.js → langsmith-OIKOTPY3.js} +101 -121
- package/dist/{lemlist-DASEMJMA.js → lemlist-VAKYPKS3.js} +57 -68
- package/dist/{linear-KE6UP4SP.js → linear-Q6QTPJ5R.js} +109 -118
- package/dist/{logsnag-IMNDN4R5.js → logsnag-SQOQBTES.js} +31 -48
- package/dist/main.js +103 -102
- package/dist/{mattermost-HHHMUXQA.js → mattermost-G2KBEICM.js} +45 -62
- package/dist/{mem0-D2FGGOIY.js → mem0-D2FPLYDX.js} +72 -98
- package/dist/{memos-4OVIGFPH.js → memos-76PTWV5V.js} +68 -122
- package/dist/{metabase-33WCX5YD.js → metabase-TWSIDVBM.js} +47 -60
- package/dist/{mistral_ai-QIMZ2JYL.js → mistral_ai-TP7TQUEJ.js} +35 -40
- package/dist/{mother_duck-M6VWS2VH.js → mother_duck-UXY5THYU.js} +42 -62
- package/dist/{ngrok-Z2PKQBHH.js → ngrok-RZW2ISJK.js} +42 -58
- package/dist/{notes-SS4RPC4K.js → notes-B2I6FWK2.js} +3 -5
- package/dist/{notion-FJCNQ6I7.js → notion-QOKRUE6M.js} +83 -97
- package/dist/{open_exchange_rates-WU57WTT5.js → open_exchange_rates-ODLFWEJ7.js} +35 -39
- package/dist/{openai-JODZ4GKT.js → openai-ZPBPPPGT.js} +51 -55
- package/dist/{opengraph_io-SQRAUSV5.js → opengraph_io-EOI5UJKT.js} +61 -79
- package/dist/{openrouter-Q5XXEJZ7.js → openrouter-BUWLF3BG.js} +41 -55
- package/dist/{outline-RT2EHJ2X.js → outline-NXS3QRXO.js} +89 -104
- package/dist/{paddle-OF2V7GAC.js → paddle-T4MSKQ76.js} +34 -49
- package/dist/{perplexity-LNZEWLHG.js → perplexity-WW5N2LW7.js} +33 -50
- package/dist/{pinecone-JSJIXZYN.js → pinecone-RY5AZPQM.js} +65 -91
- package/dist/{pipedrive-D4CKVUXR.js → pipedrive-OHYQNZTU.js} +37 -59
- package/dist/{polar-M7ZYP6UR.js → polar-XZIAHXS5.js} +43 -53
- package/dist/{posthog-YV7CZOH4.js → posthog-DTPTWORY.js} +58 -77
- package/dist/{postmark-KYHLECRG.js → postmark-F4UCQKC3.js} +52 -71
- package/dist/{prerender-HCMHBKV2.js → prerender-P3Y2MLIC.js} +32 -50
- package/dist/{pubmed-WYVLCCN3.js → pubmed-RHU3GXFB.js} +28 -60
- package/dist/{railway-TWIRD5KR.js → railway-VB6SRLI6.js} +32 -39
- package/dist/{readwise-UZ467IQ7.js → readwise-DIMSKJZR.js} +62 -78
- package/dist/{render-MECUC5CC.js → render-XCCDCEEK.js} +48 -64
- package/dist/{replicate-A5MEK3SW.js → replicate-IUEOQ4JC.js} +41 -58
- package/dist/{resend-BC6EAWJQ.js → resend-N5MJZH5E.js} +27 -37
- package/dist/{rootly-ZM3QDUIS.js → rootly-25T4NBTU.js} +64 -76
- package/dist/{scrapfly-WAML42QJ.js → scrapfly-PK4XFXUA.js} +45 -51
- package/dist/{scrapingbee-DG7PET3V.js → scrapingbee-ITPBMWQU.js} +25 -33
- package/dist/{screenshot_fyi-HY6WTHIO.js → screenshot_fyi-5U6ZYPKR.js} +29 -47
- package/dist/{semantic_scholar-C5IZA7IP.js → semantic_scholar-BJGCI2MU.js} +37 -56
- package/dist/{sentry-OKBPSTDM.js → sentry-63IC263P.js} +66 -85
- package/dist/{shodan-PPC6DYU4.js → shodan-2WBIFHFN.js} +42 -53
- package/dist/{shopify-EWGUHBXO.js → shopify-XLLJRAGM.js} +32 -49
- package/dist/{stripe-6RPDPC5W.js → stripe-WLVCY3UN.js} +4 -5
- package/dist/{supabase-SK7DQ42N.js → supabase-BKNZ35ER.js} +69 -88
- package/dist/{tavily-YCG5VQMH.js → tavily-YFSDEUTL.js} +37 -62
- package/dist/{telegram-2OES5FYB.js → telegram-FC35W74G.js} +168 -177
- package/dist/{telnyx-POOSBBR4.js → telnyx-MI32XZUG.js} +30 -50
- package/dist/{todoist-M7YD6YSS.js → todoist-4ZFJKZC6.js} +77 -89
- package/dist/{trello-IS6V5W3E.js → trello-UOGFNMK4.js} +108 -122
- package/dist/{turso-RCFHUFVH.js → turso-YTSTW3ZS.js} +52 -64
- package/dist/{twilio-OS2RXFGO.js → twilio-XAJDFUQH.js} +48 -55
- package/dist/{umami-PQ2SJ2LN.js → umami-ZVIUBPAI.js} +49 -69
- package/dist/{unsplash-C6BPZO4E.js → unsplash-IU3PLDNS.js} +35 -52
- package/dist/{upstash_redis-WH6UER7H.js → upstash_redis-3EYJW7SY.js} +28 -40
- package/dist/{uptimerobot-M3YZGS6Z.js → uptimerobot-PJG2ASRU.js} +11 -12
- package/dist/{v2ex-R4JWTEHN.js → v2ex-KFQWWGFC.js} +36 -61
- package/dist/{vercel-FZVYUOQD.js → vercel-I2ZDOQRL.js} +124 -150
- package/dist/{webapi-VLM4IKVB.js → webapi-GW5QXWXE.js} +1 -1
- package/dist/{wolfram_alpha_api-2KOLO5DC.js → wolfram_alpha_api-BNXOJMB6.js} +26 -34
- package/dist/{wordpress-XRWGO6LG.js → wordpress-36D7BSMP.js} +87 -104
- package/dist/{workos-WR4NKOYL.js → workos-6X4JJRRC.js} +37 -56
- package/dist/{zhihu-BKZIB3WA.js → zhihu-CIXKCHIU.js} +35 -57
- package/package.json +5 -5
- package/dist/chunk-2O27H4Y2.js +0 -183
- package/dist/chunk-GKX72JMJ.js +0 -378
- package/dist/chunk-MLKGABMK.js +0 -9
|
@@ -1,85 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderHttpClient
|
|
3
|
+
} from "./chunk-WW2IMPQK.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-YASUMV2K.js";
|
|
13
|
+
import "./chunk-U5UHT7CX.js";
|
|
10
14
|
import {
|
|
11
15
|
external_exports
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
16
|
+
} from "./chunk-RVWZN3CI.js";
|
|
17
|
+
import "./chunk-U67V476Y.js";
|
|
14
18
|
|
|
15
19
|
// ../plugins/src/clerk/api.ts
|
|
16
20
|
var SERVICE = "clerk";
|
|
17
|
-
var
|
|
18
|
-
function text(value) {
|
|
19
|
-
if (typeof value !== "string") return void 0;
|
|
20
|
-
const trimmed = value.trim();
|
|
21
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
22
|
-
}
|
|
23
|
-
function record(value) {
|
|
24
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
25
|
-
}
|
|
21
|
+
var http = createProviderHttpClient({ baseUrl: "https://api.clerk.com/v1/", service: SERVICE });
|
|
26
22
|
function errorMessage(payload) {
|
|
27
|
-
if (typeof payload === "string") return
|
|
28
|
-
const body =
|
|
23
|
+
if (typeof payload === "string") return trimmedText(payload)?.slice(0, 200);
|
|
24
|
+
const body = asJsonObject(payload);
|
|
29
25
|
if (body === void 0) return void 0;
|
|
30
26
|
if (Array.isArray(body.errors)) {
|
|
31
|
-
const first =
|
|
32
|
-
return
|
|
33
|
-
}
|
|
34
|
-
return text(body.message) ?? text(body.error);
|
|
35
|
-
}
|
|
36
|
-
async function readPayload(response) {
|
|
37
|
-
const body = await response.text().catch(() => "");
|
|
38
|
-
if (body.trim() === "") return {};
|
|
39
|
-
try {
|
|
40
|
-
return JSON.parse(body);
|
|
41
|
-
} catch {
|
|
42
|
-
return body;
|
|
27
|
+
const first = asJsonObject(body.errors[0]);
|
|
28
|
+
return trimmedText(first?.long_message) ?? trimmedText(first?.message) ?? trimmedText(first?.code);
|
|
43
29
|
}
|
|
30
|
+
return trimmedText(body.message) ?? trimmedText(body.error);
|
|
44
31
|
}
|
|
45
32
|
async function request(ctx, path, input) {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
...input.body === void 0 ? {} : { body: JSON.stringify(input.body) }
|
|
67
|
-
});
|
|
68
|
-
} catch (error) {
|
|
69
|
-
throw upstreamError(502, error instanceof Error ? `clerk \u8BF7\u6C42\u5931\u8D25: ${error.message}` : "clerk \u8BF7\u6C42\u5931\u8D25");
|
|
70
|
-
}
|
|
71
|
-
const payload = await readPayload(response);
|
|
72
|
-
if (!response.ok) {
|
|
73
|
-
throw upstreamError(response.status, errorMessage(payload) ?? (response.statusText || `clerk \u8FD4\u56DE HTTP ${response.status}`));
|
|
74
|
-
}
|
|
75
|
-
return payload;
|
|
33
|
+
const { data } = await http.request({
|
|
34
|
+
path,
|
|
35
|
+
method: input.method,
|
|
36
|
+
query: input.query,
|
|
37
|
+
headers: {
|
|
38
|
+
accept: "application/json",
|
|
39
|
+
authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
|
|
40
|
+
},
|
|
41
|
+
...input.body === void 0 ? {} : { json: input.body },
|
|
42
|
+
invalidJson: "text",
|
|
43
|
+
mapError: ({ data: payload, status }) => upstreamError(
|
|
44
|
+
status,
|
|
45
|
+
errorMessage(payload) ?? `clerk \u8FD4\u56DE HTTP ${status}`
|
|
46
|
+
),
|
|
47
|
+
mapTransportError: ({ message }) => upstreamError(
|
|
48
|
+
502,
|
|
49
|
+
message === void 0 ? "clerk \u8BF7\u6C42\u5931\u8D25" : `clerk \u8BF7\u6C42\u5931\u8D25: ${message}`
|
|
50
|
+
)
|
|
51
|
+
});
|
|
52
|
+
return data ?? {};
|
|
76
53
|
}
|
|
77
54
|
function normalizeListUsers(payload) {
|
|
78
55
|
if (Array.isArray(payload)) return { users: payload, total_count: payload.length };
|
|
79
|
-
const body =
|
|
56
|
+
const body = asJsonObject(payload);
|
|
80
57
|
if (body !== void 0 && Array.isArray(body.data)) {
|
|
81
|
-
|
|
82
|
-
|
|
58
|
+
return {
|
|
59
|
+
users: body.data,
|
|
60
|
+
total_count: typeof body.total_count === "number" ? body.total_count : body.data.length
|
|
61
|
+
};
|
|
83
62
|
}
|
|
84
63
|
throw upstreamError(502, "clerk list_users \u8FD4\u56DE\u4E86\u975E\u9884\u671F\u5F62\u72B6");
|
|
85
64
|
}
|
|
@@ -94,10 +73,10 @@ function userFilterQuery(input) {
|
|
|
94
73
|
];
|
|
95
74
|
}
|
|
96
75
|
async function runUserStateAction(action, userId, ctx) {
|
|
97
|
-
return { user: await request(ctx,
|
|
76
|
+
return { user: await request(ctx, `users/${encodeURIComponent(userId)}/${action}`, { method: "POST" }) };
|
|
98
77
|
}
|
|
99
78
|
async function listUsers(input, ctx) {
|
|
100
|
-
|
|
79
|
+
return normalizeListUsers(await request(ctx, "users", {
|
|
101
80
|
method: "GET",
|
|
102
81
|
query: [
|
|
103
82
|
...userFilterQuery(input),
|
|
@@ -105,41 +84,42 @@ async function listUsers(input, ctx) {
|
|
|
105
84
|
["limit", input.limit],
|
|
106
85
|
["offset", input.offset]
|
|
107
86
|
]
|
|
108
|
-
});
|
|
109
|
-
return normalizeListUsers(payload);
|
|
87
|
+
}));
|
|
110
88
|
}
|
|
111
|
-
|
|
112
|
-
return request(ctx, "
|
|
89
|
+
function countUsers(input, ctx) {
|
|
90
|
+
return request(ctx, "users/count", { method: "GET", query: userFilterQuery(input) });
|
|
113
91
|
}
|
|
114
92
|
async function getUser(input, ctx) {
|
|
115
|
-
return { user: await request(ctx,
|
|
93
|
+
return { user: await request(ctx, `users/${encodeURIComponent(input.user_id)}`, { method: "GET" }) };
|
|
116
94
|
}
|
|
117
95
|
async function createUser(input, ctx) {
|
|
118
|
-
return { user: await request(ctx, "
|
|
96
|
+
return { user: await request(ctx, "users", { method: "POST", body: input }) };
|
|
119
97
|
}
|
|
120
98
|
async function updateUser(input, ctx) {
|
|
121
99
|
const { user_id, ...body } = input;
|
|
122
|
-
return { user: await request(ctx,
|
|
100
|
+
return { user: await request(ctx, `users/${encodeURIComponent(user_id)}`, { method: "PATCH", body }) };
|
|
123
101
|
}
|
|
124
102
|
async function updateUserMetadata(input, ctx) {
|
|
125
103
|
const { user_id, ...body } = input;
|
|
126
|
-
|
|
127
|
-
|
|
104
|
+
return {
|
|
105
|
+
user: await request(ctx, `users/${encodeURIComponent(user_id)}/metadata`, { method: "PATCH", body })
|
|
106
|
+
};
|
|
128
107
|
}
|
|
129
108
|
async function deleteUser(input, ctx) {
|
|
130
|
-
|
|
131
|
-
|
|
109
|
+
return {
|
|
110
|
+
deleted_object: await request(ctx, `users/${encodeURIComponent(input.user_id)}`, { method: "DELETE" })
|
|
111
|
+
};
|
|
132
112
|
}
|
|
133
|
-
|
|
113
|
+
function banUser(input, ctx) {
|
|
134
114
|
return runUserStateAction("ban", input.user_id, ctx);
|
|
135
115
|
}
|
|
136
|
-
|
|
116
|
+
function unbanUser(input, ctx) {
|
|
137
117
|
return runUserStateAction("unban", input.user_id, ctx);
|
|
138
118
|
}
|
|
139
|
-
|
|
119
|
+
function lockUser(input, ctx) {
|
|
140
120
|
return runUserStateAction("lock", input.user_id, ctx);
|
|
141
121
|
}
|
|
142
|
-
|
|
122
|
+
function unlockUser(input, ctx) {
|
|
143
123
|
return runUserStateAction("unlock", input.user_id, ctx);
|
|
144
124
|
}
|
|
145
125
|
|
|
@@ -1,52 +1,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderHttpClient
|
|
3
|
+
} from "./chunk-WW2IMPQK.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-
|
|
6
|
-
import
|
|
7
|
-
guardedFetch
|
|
8
|
-
} from "./chunk-2O27H4Y2.js";
|
|
9
|
-
import "./chunk-GKX72JMJ.js";
|
|
15
|
+
} from "./chunk-YASUMV2K.js";
|
|
16
|
+
import "./chunk-U5UHT7CX.js";
|
|
10
17
|
import {
|
|
11
18
|
TBError,
|
|
12
19
|
external_exports
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
20
|
+
} from "./chunk-RVWZN3CI.js";
|
|
21
|
+
import "./chunk-U67V476Y.js";
|
|
15
22
|
|
|
16
23
|
// ../plugins/src/cloudflare_dns/api.ts
|
|
17
24
|
var SERVICE = "cloudflare_dns";
|
|
18
25
|
var API_BASE = "https://api.cloudflare.com/client/v4";
|
|
26
|
+
var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
|
|
19
27
|
var DEFAULT_ACCOUNTS_PAGE = 1;
|
|
20
28
|
var DEFAULT_ACCOUNTS_PER_PAGE = 50;
|
|
21
|
-
function text(value) {
|
|
22
|
-
if (typeof value !== "string") return void 0;
|
|
23
|
-
const trimmed = value.trim();
|
|
24
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
25
|
-
}
|
|
26
29
|
function rawText(value) {
|
|
27
30
|
return typeof value === "string" ? value : void 0;
|
|
28
31
|
}
|
|
29
|
-
function record(value) {
|
|
30
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
31
|
-
}
|
|
32
|
-
function integer(value) {
|
|
33
|
-
return typeof value === "number" && Number.isInteger(value) ? value : void 0;
|
|
34
|
-
}
|
|
35
|
-
function boolean(value) {
|
|
36
|
-
return typeof value === "boolean" ? value : void 0;
|
|
37
|
-
}
|
|
38
32
|
function nullableText(value) {
|
|
39
|
-
return value === null ? null :
|
|
33
|
+
return value === null ? null : trimmedText(value);
|
|
40
34
|
}
|
|
41
35
|
function textArray(value) {
|
|
42
36
|
if (!Array.isArray(value)) return void 0;
|
|
43
37
|
return value.filter((item) => typeof item === "string");
|
|
44
38
|
}
|
|
45
|
-
function compact(input) {
|
|
46
|
-
return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0));
|
|
47
|
-
}
|
|
48
39
|
function requireRecord(value, label) {
|
|
49
|
-
const result =
|
|
40
|
+
const result = asJsonObject(value);
|
|
50
41
|
if (result === void 0) throw new TBError("unavailable", `${label}\u4E0D\u662F\u5BF9\u8C61`, { retryable: true });
|
|
51
42
|
return result;
|
|
52
43
|
}
|
|
@@ -55,24 +46,16 @@ function requireArray(value, label) {
|
|
|
55
46
|
return value;
|
|
56
47
|
}
|
|
57
48
|
function requireText(source, field, label) {
|
|
58
|
-
const value =
|
|
49
|
+
const value = trimmedText(source[field]);
|
|
59
50
|
if (value === void 0) {
|
|
60
51
|
throw new TBError("unavailable", `${label}\u7F3A\u5C11 ${field}`, { retryable: true });
|
|
61
52
|
}
|
|
62
53
|
return value;
|
|
63
54
|
}
|
|
64
|
-
function buildUrl(path, query) {
|
|
65
|
-
const url = new URL(`${API_BASE}${path}`);
|
|
66
|
-
for (const [key, value] of Object.entries(query ?? {})) {
|
|
67
|
-
if (value === void 0 || value === "") continue;
|
|
68
|
-
url.searchParams.set(key, String(value));
|
|
69
|
-
}
|
|
70
|
-
return url.toString();
|
|
71
|
-
}
|
|
72
55
|
function errorMessage(envelope, status) {
|
|
73
56
|
for (const source of [envelope.errors, envelope.messages]) {
|
|
74
57
|
for (const entry of Array.isArray(source) ? source : []) {
|
|
75
|
-
const message =
|
|
58
|
+
const message = trimmedText(asJsonObject(entry)?.message);
|
|
76
59
|
if (message !== void 0) return message;
|
|
77
60
|
}
|
|
78
61
|
}
|
|
@@ -80,115 +63,109 @@ function errorMessage(envelope, status) {
|
|
|
80
63
|
}
|
|
81
64
|
async function request(ctx, input) {
|
|
82
65
|
const hasBody = input.body !== void 0;
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
|
|
86
|
-
};
|
|
87
|
-
if (hasBody) headers["content-type"] = "application/json";
|
|
88
|
-
const response = await guardedFetch(buildUrl(input.path, input.query), {
|
|
66
|
+
const result = await http.request({
|
|
67
|
+
path: input.path,
|
|
89
68
|
method: input.method ?? "GET",
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
} catch (error) {
|
|
99
|
-
if (error instanceof TBError) throw error;
|
|
100
|
-
if (response.ok) {
|
|
101
|
-
throw new TBError("unavailable", "Cloudflare \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94", { retryable: true });
|
|
69
|
+
// 上游 `queryParams`:undefined / null / 空串一律不发。
|
|
70
|
+
query: Object.entries(input.query ?? {}).filter(([, value]) => value !== void 0 && value !== ""),
|
|
71
|
+
headers: { accept: "application/json", authorization: `Bearer ${requireApiKey(ctx, SERVICE)}` },
|
|
72
|
+
...hasBody ? { json: input.body } : {},
|
|
73
|
+
invalidJsonMessage: "Cloudflare \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
|
|
74
|
+
mapError: ({ bodyKind, data, status }) => {
|
|
75
|
+
if (bodyKind === "json" && asJsonObject(data) === void 0) {
|
|
76
|
+
return new TBError("unavailable", "Cloudflare \u54CD\u5E94\u4E0D\u662F\u5BF9\u8C61", { retryable: true });
|
|
102
77
|
}
|
|
78
|
+
const envelope2 = bodyKind === "json" ? data : {};
|
|
79
|
+
return upstreamError(status, errorMessage(envelope2, status));
|
|
103
80
|
}
|
|
81
|
+
});
|
|
82
|
+
const envelope = result.data === void 0 ? {} : requireRecord(result.data, "Cloudflare \u54CD\u5E94");
|
|
83
|
+
if (envelope.success === false) {
|
|
84
|
+
throw upstreamError(result.status, errorMessage(envelope, result.status));
|
|
104
85
|
}
|
|
105
|
-
|
|
106
|
-
if (!response.ok || result.success === false) {
|
|
107
|
-
throw upstreamError(response.status, errorMessage(result, response.status));
|
|
108
|
-
}
|
|
109
|
-
return result;
|
|
86
|
+
return envelope;
|
|
110
87
|
}
|
|
111
88
|
function normalizeAccount(value) {
|
|
112
89
|
const account = requireRecord(value, "Cloudflare \u8D26\u6237");
|
|
113
|
-
return
|
|
90
|
+
return compactDefined({
|
|
114
91
|
id: requireText(account, "id", "Cloudflare \u8D26\u6237"),
|
|
115
|
-
name:
|
|
116
|
-
type:
|
|
92
|
+
name: trimmedText(account.name),
|
|
93
|
+
type: trimmedText(account.type)
|
|
117
94
|
});
|
|
118
95
|
}
|
|
119
96
|
function normalizeZoneAccount(value) {
|
|
120
|
-
const account =
|
|
97
|
+
const account = asJsonObject(value);
|
|
121
98
|
if (account === void 0) return void 0;
|
|
122
|
-
return
|
|
123
|
-
id:
|
|
124
|
-
name:
|
|
125
|
-
type:
|
|
99
|
+
return compactDefined({
|
|
100
|
+
id: trimmedText(account.id),
|
|
101
|
+
name: trimmedText(account.name),
|
|
102
|
+
type: trimmedText(account.type)
|
|
126
103
|
});
|
|
127
104
|
}
|
|
128
105
|
function normalizeZone(value) {
|
|
129
106
|
const zone = requireRecord(value, "Cloudflare zone");
|
|
130
|
-
return
|
|
107
|
+
return compactDefined({
|
|
131
108
|
id: requireText(zone, "id", "Cloudflare zone"),
|
|
132
109
|
name: requireText(zone, "name", "Cloudflare zone"),
|
|
133
|
-
status:
|
|
134
|
-
type:
|
|
135
|
-
paused:
|
|
136
|
-
createdOn:
|
|
137
|
-
modifiedOn:
|
|
110
|
+
status: trimmedText(zone.status),
|
|
111
|
+
type: trimmedText(zone.type),
|
|
112
|
+
paused: booleanValue(zone.paused),
|
|
113
|
+
createdOn: trimmedText(zone.created_on),
|
|
114
|
+
modifiedOn: trimmedText(zone.modified_on),
|
|
138
115
|
nameServers: textArray(zone.name_servers),
|
|
139
116
|
originalNameServers: textArray(zone.original_name_servers),
|
|
140
117
|
account: normalizeZoneAccount(zone.account),
|
|
141
|
-
meta:
|
|
118
|
+
meta: asJsonObject(zone.meta)
|
|
142
119
|
});
|
|
143
120
|
}
|
|
144
121
|
function normalizeDnsRecord(value) {
|
|
145
122
|
const dns = requireRecord(value, "Cloudflare DNS \u8BB0\u5F55");
|
|
146
|
-
return
|
|
123
|
+
return compactDefined({
|
|
147
124
|
id: requireText(dns, "id", "Cloudflare DNS \u8BB0\u5F55"),
|
|
148
|
-
zoneId:
|
|
149
|
-
zoneName:
|
|
125
|
+
zoneId: trimmedText(dns.zone_id),
|
|
126
|
+
zoneName: trimmedText(dns.zone_name),
|
|
150
127
|
type: requireText(dns, "type", "Cloudflare DNS \u8BB0\u5F55"),
|
|
151
128
|
name: requireText(dns, "name", "Cloudflare DNS \u8BB0\u5F55"),
|
|
152
129
|
content: nullableText(dns.content),
|
|
153
|
-
ttl:
|
|
154
|
-
proxied:
|
|
155
|
-
proxiable:
|
|
156
|
-
priority:
|
|
130
|
+
ttl: integerValue(dns.ttl),
|
|
131
|
+
proxied: booleanValue(dns.proxied),
|
|
132
|
+
proxiable: booleanValue(dns.proxiable),
|
|
133
|
+
priority: integerValue(dns.priority),
|
|
157
134
|
comment: nullableText(dns.comment),
|
|
158
135
|
tags: textArray(dns.tags),
|
|
159
|
-
createdOn:
|
|
160
|
-
modifiedOn:
|
|
161
|
-
commentModifiedOn:
|
|
162
|
-
tagsModifiedOn:
|
|
163
|
-
data:
|
|
164
|
-
meta:
|
|
165
|
-
settings:
|
|
136
|
+
createdOn: trimmedText(dns.created_on),
|
|
137
|
+
modifiedOn: trimmedText(dns.modified_on),
|
|
138
|
+
commentModifiedOn: trimmedText(dns.comment_modified_on),
|
|
139
|
+
tagsModifiedOn: trimmedText(dns.tags_modified_on),
|
|
140
|
+
data: asJsonObject(dns.data),
|
|
141
|
+
meta: asJsonObject(dns.meta),
|
|
142
|
+
settings: asJsonObject(dns.settings)
|
|
166
143
|
});
|
|
167
144
|
}
|
|
168
145
|
function normalizeResultInfo(value) {
|
|
169
|
-
const info =
|
|
146
|
+
const info = asJsonObject(value);
|
|
170
147
|
if (info === void 0) return void 0;
|
|
171
|
-
return
|
|
172
|
-
page:
|
|
173
|
-
perPage:
|
|
174
|
-
count:
|
|
175
|
-
totalCount:
|
|
176
|
-
totalPages:
|
|
148
|
+
return compactDefined({
|
|
149
|
+
page: integerValue(info.page),
|
|
150
|
+
perPage: integerValue(info.per_page),
|
|
151
|
+
count: integerValue(info.count),
|
|
152
|
+
totalCount: integerValue(info.total_count),
|
|
153
|
+
totalPages: integerValue(info.total_pages)
|
|
177
154
|
});
|
|
178
155
|
}
|
|
179
156
|
function mutationBody(input) {
|
|
180
|
-
return
|
|
181
|
-
type:
|
|
182
|
-
name:
|
|
157
|
+
return compactDefined({
|
|
158
|
+
type: trimmedText(input.type),
|
|
159
|
+
name: trimmedText(input.name),
|
|
183
160
|
// content / comment 原样发:清空一个字段靠的就是发空串,trim 掉就没法表达"清空"。
|
|
184
161
|
content: rawText(input.content),
|
|
185
|
-
data:
|
|
186
|
-
ttl:
|
|
187
|
-
proxied:
|
|
188
|
-
priority:
|
|
162
|
+
data: asJsonObject(input.data),
|
|
163
|
+
ttl: integerValue(input.ttl),
|
|
164
|
+
proxied: booleanValue(input.proxied),
|
|
165
|
+
priority: integerValue(input.priority),
|
|
189
166
|
comment: rawText(input.comment),
|
|
190
167
|
tags: input.tags,
|
|
191
|
-
settings:
|
|
168
|
+
settings: asJsonObject(input.settings)
|
|
192
169
|
});
|
|
193
170
|
}
|
|
194
171
|
async function listAccounts(input, ctx) {
|
|
@@ -200,7 +177,7 @@ async function listAccounts(input, ctx) {
|
|
|
200
177
|
per_page: input.perPage ?? DEFAULT_ACCOUNTS_PER_PAGE
|
|
201
178
|
}
|
|
202
179
|
});
|
|
203
|
-
return
|
|
180
|
+
return compactDefined({
|
|
204
181
|
accounts: requireArray(envelope.result, "Cloudflare \u8D26\u6237\u5217\u8868").map((item) => normalizeAccount(item)),
|
|
205
182
|
resultInfo: normalizeResultInfo(envelope.result_info)
|
|
206
183
|
});
|
|
@@ -211,16 +188,16 @@ async function listZones(input, ctx) {
|
|
|
211
188
|
query: {
|
|
212
189
|
"page": input.page,
|
|
213
190
|
"per_page": input.perPage,
|
|
214
|
-
"name":
|
|
215
|
-
"status":
|
|
191
|
+
"name": trimmedText(input.name),
|
|
192
|
+
"status": trimmedText(input.status),
|
|
216
193
|
// 上游的过滤键就叫 `account.id`,带点,不是笔误。
|
|
217
|
-
"account.id":
|
|
194
|
+
"account.id": trimmedText(input.accountId),
|
|
218
195
|
"match": input.match,
|
|
219
|
-
"order":
|
|
196
|
+
"order": trimmedText(input.order),
|
|
220
197
|
"direction": input.direction
|
|
221
198
|
}
|
|
222
199
|
});
|
|
223
|
-
return
|
|
200
|
+
return compactDefined({
|
|
224
201
|
zones: requireArray(envelope.result, "Cloudflare zone \u5217\u8868").map((item) => normalizeZone(item)),
|
|
225
202
|
resultInfo: normalizeResultInfo(envelope.result_info)
|
|
226
203
|
});
|
|
@@ -236,15 +213,15 @@ async function listDnsRecords(input, ctx) {
|
|
|
236
213
|
page: input.page,
|
|
237
214
|
per_page: input.perPage,
|
|
238
215
|
type: input.type,
|
|
239
|
-
name:
|
|
240
|
-
content:
|
|
216
|
+
name: trimmedText(input.name),
|
|
217
|
+
content: trimmedText(input.content),
|
|
241
218
|
proxied: input.proxied,
|
|
242
219
|
match: input.match,
|
|
243
|
-
order:
|
|
220
|
+
order: trimmedText(input.order),
|
|
244
221
|
direction: input.direction
|
|
245
222
|
}
|
|
246
223
|
});
|
|
247
|
-
return
|
|
224
|
+
return compactDefined({
|
|
248
225
|
records: requireArray(envelope.result, "Cloudflare DNS \u8BB0\u5F55\u5217\u8868").map((item) => normalizeDnsRecord(item)),
|
|
249
226
|
resultInfo: normalizeResultInfo(envelope.result_info)
|
|
250
227
|
});
|
|
@@ -1,72 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderHttpClient
|
|
3
|
+
} from "./chunk-WW2IMPQK.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-YASUMV2K.js";
|
|
13
|
+
import "./chunk-U5UHT7CX.js";
|
|
10
14
|
import {
|
|
11
15
|
external_exports
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
16
|
+
} from "./chunk-RVWZN3CI.js";
|
|
17
|
+
import "./chunk-U67V476Y.js";
|
|
14
18
|
|
|
15
19
|
// ../plugins/src/cohere/api.ts
|
|
16
20
|
var SERVICE = "cohere";
|
|
17
|
-
var
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
return
|
|
22
|
-
}
|
|
23
|
-
function record(value) {
|
|
24
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
25
|
-
}
|
|
26
|
-
function errorMessage(body, status) {
|
|
27
|
-
const fallback = text(body) ?? `cohere request failed with ${status}`;
|
|
28
|
-
let payload;
|
|
29
|
-
try {
|
|
30
|
-
payload = JSON.parse(body);
|
|
31
|
-
} catch {
|
|
32
|
-
return fallback;
|
|
33
|
-
}
|
|
34
|
-
const root = record(payload);
|
|
35
|
-
return text(record(root?.error)?.message) ?? text(root?.message) ?? fallback;
|
|
36
|
-
}
|
|
37
|
-
function cohereError(status, body) {
|
|
38
|
-
return upstreamError(status === 498 ? 401 : status, errorMessage(body, status));
|
|
21
|
+
var http = createProviderHttpClient({ baseUrl: "https://api.cohere.com/", service: SERVICE });
|
|
22
|
+
function errorMessage(payload, status) {
|
|
23
|
+
const fallback = trimmedText(payload) ?? `cohere request failed with ${status}`;
|
|
24
|
+
const root = asJsonObject(payload);
|
|
25
|
+
return trimmedText(asJsonObject(root?.error)?.message) ?? trimmedText(root?.message) ?? fallback;
|
|
39
26
|
}
|
|
40
27
|
async function post(ctx, path, body) {
|
|
41
|
-
const
|
|
28
|
+
const { data } = await http.request({
|
|
29
|
+
path,
|
|
42
30
|
method: "POST",
|
|
43
31
|
headers: {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"content-type": "application/json"
|
|
32
|
+
accept: "application/json",
|
|
33
|
+
authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
|
|
47
34
|
},
|
|
48
|
-
|
|
35
|
+
json: body,
|
|
36
|
+
invalidJsonMessage: "cohere returned an invalid JSON response",
|
|
37
|
+
mapError: ({ data: payload, status }) => upstreamError(
|
|
38
|
+
status === 498 ? 401 : status,
|
|
39
|
+
errorMessage(payload, status)
|
|
40
|
+
)
|
|
49
41
|
});
|
|
50
|
-
const
|
|
51
|
-
if (!response.ok) throw cohereError(response.status, raw);
|
|
52
|
-
let payload;
|
|
53
|
-
try {
|
|
54
|
-
payload = JSON.parse(raw);
|
|
55
|
-
} catch {
|
|
56
|
-
throw upstreamError(502, "cohere returned an invalid JSON response");
|
|
57
|
-
}
|
|
58
|
-
const result = record(payload);
|
|
42
|
+
const result = asJsonObject(data);
|
|
59
43
|
if (result === void 0) throw upstreamError(502, "cohere returned an invalid JSON response");
|
|
60
44
|
return result;
|
|
61
45
|
}
|
|
62
|
-
|
|
63
|
-
return post(ctx, "
|
|
46
|
+
function chat(input, ctx) {
|
|
47
|
+
return post(ctx, "v2/chat", input);
|
|
64
48
|
}
|
|
65
|
-
|
|
66
|
-
return post(ctx, "
|
|
49
|
+
function embedTexts(input, ctx) {
|
|
50
|
+
return post(ctx, "v2/embed", input);
|
|
67
51
|
}
|
|
68
|
-
|
|
69
|
-
return post(ctx, "
|
|
52
|
+
function rerankDocuments(input, ctx) {
|
|
53
|
+
return post(ctx, "v2/rerank", input);
|
|
70
54
|
}
|
|
71
55
|
|
|
72
56
|
// ../plugins/src/cohere/schema.ts
|