@tool-bridge/server 0.1.1 → 0.3.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-V6446SVY.js +792 -0
- package/dist/alt_text_generator_ai-HV7JZPDT.js +72 -0
- package/dist/amap-TTTVB6WS.js +755 -0
- package/dist/anthropic-JH3RA363.js +224 -0
- package/dist/apify-ETNN7ITU.js +262 -0
- package/dist/brave_search-3DDR2MMB.js +322 -0
- package/dist/chunk-CSJEZHQO.js +252 -0
- package/dist/chunk-JLTYA2B3.js +20121 -0
- package/dist/chunk-K7FVSFUX.js +333 -0
- package/dist/{chunk-MQEYFCJB.js → chunk-KGYJEEBI.js} +2770 -21574
- package/dist/circleci-MX3TX3HC.js +409 -0
- package/dist/clerk-MRPORVF4.js +1036 -0
- package/dist/cloudflare_dns-OWP7DD7L.js +605 -0
- package/dist/cohere-GPECP66S.js +197 -0
- package/dist/confluence-BN7LZ6BC.js +436 -0
- package/dist/convertapi-SBEOFOFQ.js +161 -0
- package/dist/currencyapi-P2YY7Y7P.js +306 -0
- package/dist/deepseek-MWB3NYIN.js +205 -0
- package/dist/docker_hub-3JSCIGQ3.js +946 -0
- package/dist/dropbox-RFIBDAXO.js +1308 -0
- package/dist/dub-YVP57ELQ.js +706 -0
- package/dist/e2b-NFSUHTZR.js +305 -0
- package/dist/exa-KTDY6IV3.js +360 -0
- package/dist/fal_ai-OCUENLNQ.js +405 -0
- package/dist/feishu-5CWBQ7E5.js +225 -0
- package/dist/feishu_custom_bot-ZJR22OK6.js +240 -0
- package/dist/figma-YULGANSA.js +798 -0
- package/dist/firehydrant-2V6YSYAP.js +573 -0
- package/dist/fixer-LTCDB3CJ.js +171 -0
- package/dist/fly-IXPKMAML.js +478 -0
- package/dist/front-KRFB4M5X.js +379 -0
- package/dist/geocodio-VVURKYHQ.js +236 -0
- package/dist/ghost-6J2RIOUB.js +341 -0
- package/dist/github-5Z6KQRYH.js +5410 -0
- package/dist/gmail-KU4NZ7VA.js +1894 -0
- package/dist/googlecalendar-X44DFFXG.js +2539 -0
- package/dist/googledocs-WSGLPKSF.js +1322 -0
- package/dist/grafana-4PKSSDXY.js +817 -0
- package/dist/graphhopper-DF65ZNGK.js +336 -0
- package/dist/index.d.ts +181 -2
- package/dist/index.js +2 -1
- package/dist/ip2proxy-UCAQ5P2J.js +118 -0
- package/dist/ipgeolocation_io-UX6FCA2S.js +333 -0
- package/dist/ipqualityscore-MKTRXIZJ.js +287 -0
- package/dist/jina_ai-MRHPCSV5.js +119 -0
- package/dist/jira-EG7ZPOIW.js +627 -0
- package/dist/langsmith-FNO3RCOZ.js +597 -0
- package/dist/lemlist-SN6BJHSG.js +298 -0
- package/dist/linear-H3VU4PSD.js +2163 -0
- package/dist/logsnag-OY2JJT2H.js +167 -0
- package/dist/main.js +246 -2
- package/dist/mattermost-C5SQ7PGD.js +320 -0
- package/dist/mem0-LMLE5BFC.js +567 -0
- package/dist/memos-UWFAMBZC.js +781 -0
- package/dist/metabase-SRYDSDJ6.js +365 -0
- package/dist/mistral_ai-YNIJ7VDM.js +1195 -0
- package/dist/mother_duck-CPGOFEXE.js +322 -0
- package/dist/ngrok-CDJFBSOM.js +375 -0
- package/dist/notes-DIVFH3P3.js +109 -0
- package/dist/notion-HGDKS4HK.js +945 -0
- package/dist/open_exchange_rates-COHHYJDD.js +216 -0
- package/dist/openai-4TRT66GW.js +795 -0
- package/dist/opengraph_io-YKVW4PXI.js +377 -0
- package/dist/openrouter-6CV7B7V5.js +444 -0
- package/dist/outline-YWDUK5F7.js +604 -0
- package/dist/paddle-MEU7HWDZ.js +464 -0
- package/dist/perplexity-MRQUDBIC.js +238 -0
- package/dist/pinecone-JI7X2TAF.js +599 -0
- package/dist/pipedrive-6JQPAW23.js +453 -0
- package/dist/polar-7BF56CMC.js +400 -0
- package/dist/posthog-YPU5ADEN.js +3462 -0
- package/dist/postmark-BEU5OFKU.js +441 -0
- package/dist/prerender-UT5GOOZH.js +180 -0
- package/dist/pubmed-3SGOE24Q.js +1052 -0
- package/dist/railway-CEK4GLRQ.js +452 -0
- package/dist/readwise-DXQUQU67.js +482 -0
- package/dist/render-7TGAU5AW.js +473 -0
- package/dist/replicate-VICFSQ5A.js +347 -0
- package/dist/resend-3E76WK3O.js +100 -0
- package/dist/rootly-36GY46BY.js +345 -0
- package/dist/scrapfly-VDVUYAHX.js +289 -0
- package/dist/scrapingbee-3KTPMAVY.js +247 -0
- package/dist/screenshot_fyi-LKG62C3J.js +116 -0
- package/dist/semantic_scholar-4WREECYO.js +626 -0
- package/dist/sentry-HUQTGXOV.js +1139 -0
- package/dist/shodan-SGRKU4KS.js +303 -0
- package/dist/shopify-YCZ4L5HT.js +620 -0
- package/dist/stripe-OEBKMELB.js +583 -0
- package/dist/supabase-I3DBY7L4.js +937 -0
- package/dist/tavily-B2YHCNRD.js +349 -0
- package/dist/telegram-2VYJELZX.js +1773 -0
- package/dist/telnyx-HHXD3CXL.js +237 -0
- package/dist/todoist-PHFDEEIS.js +672 -0
- package/dist/trello-WUSAK6YN.js +1091 -0
- package/dist/turso-FW56U2B3.js +432 -0
- package/dist/twilio-M5JI7XHA.js +321 -0
- package/dist/umami-HAYODRC4.js +411 -0
- package/dist/unsplash-EDPTNEHJ.js +364 -0
- package/dist/upstash_redis-GC2CLIWD.js +299 -0
- package/dist/uptimerobot-XMSNYLIT.js +481 -0
- package/dist/v2ex-KU4ECD65.js +672 -0
- package/dist/vercel-THPCEFHW.js +1096 -0
- package/dist/wolfram_alpha_api-WHHTH4GU.js +212 -0
- package/dist/wordpress-O6TQEQNF.js +822 -0
- package/dist/workos-A3VHHWI3.js +681 -0
- package/dist/zhihu-BJAI64YJ.js +273 -0
- package/package.json +5 -4
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assertPublicHttpUrl,
|
|
3
|
+
createProviderPlugin,
|
|
4
|
+
guardedFetch,
|
|
5
|
+
requireApiKey,
|
|
6
|
+
upstreamError
|
|
7
|
+
} from "./chunk-CSJEZHQO.js";
|
|
8
|
+
import "./chunk-K7FVSFUX.js";
|
|
9
|
+
import {
|
|
10
|
+
TBError,
|
|
11
|
+
external_exports
|
|
12
|
+
} from "./chunk-JLTYA2B3.js";
|
|
13
|
+
import "./chunk-MLKGABMK.js";
|
|
14
|
+
|
|
15
|
+
// ../plugins/src/convertapi/schema.ts
|
|
16
|
+
var convertPdfToDocxInput = external_exports.strictObject({
|
|
17
|
+
fileUrl: external_exports.url().describe("The publicly accessible PDF URL to convert."),
|
|
18
|
+
fileName: external_exports.string().max(200).describe("The optional output file name to request from ConvertAPI. ConvertAPI appends the correct extension when needed.").optional(),
|
|
19
|
+
timeout: external_exports.int().min(10).max(1200).describe("The conversion timeout in seconds.").optional(),
|
|
20
|
+
password: external_exports.string().describe("The password used to open a protected PDF document.").optional(),
|
|
21
|
+
pageRange: external_exports.string().describe("The PDF page range to convert, for example 1-10 or 1,3,5.").optional(),
|
|
22
|
+
layout: external_exports.enum(["flowing", "continuous", "exact"]).describe("How ConvertAPI should reconstruct the PDF page layout in the DOCX output.").optional(),
|
|
23
|
+
ocrMode: external_exports.enum(["auto", "force", "never"]).describe("How ConvertAPI should apply OCR during conversion.").optional(),
|
|
24
|
+
ocrLanguage: external_exports.enum(["auto", "ar", "ca", "zh", "da", "nl", "en", "fi", "fr", "de", "el", "ko", "it", "ja", "no", "pl", "pt", "ro", "ru", "sl", "es", "sv", "tr", "ua", "th"]).describe("The OCR language code to use for text recognition, or auto for automatic detection.").optional(),
|
|
25
|
+
ocrEngine: external_exports.enum(["native", "tesseract"]).describe("The OCR engine ConvertAPI should use for text recognition.").optional(),
|
|
26
|
+
annotations: external_exports.enum(["textBox", "comment", "none"]).describe("How ConvertAPI should handle PDF annotations in the DOCX output.").optional()
|
|
27
|
+
}).describe("The input payload for converting a public PDF URL to a DOCX file with ConvertAPI.");
|
|
28
|
+
var convertPdfToDocxOutput = external_exports.strictObject({
|
|
29
|
+
conversionCost: external_exports.int().describe("The amount deducted from the ConvertAPI balance.").optional(),
|
|
30
|
+
files: external_exports.array(external_exports.strictObject({
|
|
31
|
+
fileName: external_exports.string().describe("The converted file name.").optional(),
|
|
32
|
+
fileExt: external_exports.string().describe("The converted file extension.").optional(),
|
|
33
|
+
fileSize: external_exports.int().describe("The converted file size in bytes.").optional(),
|
|
34
|
+
fileId: external_exports.string().describe("The ConvertAPI temporary file ID.").optional(),
|
|
35
|
+
url: external_exports.url().describe("The ConvertAPI temporary download URL for the converted file.").optional(),
|
|
36
|
+
transitFile: external_exports.strictObject({
|
|
37
|
+
fileId: external_exports.string().min(1).describe("The local transit file identifier.").optional(),
|
|
38
|
+
downloadUrl: external_exports.url().describe("The local URL for downloading the transit file.").optional(),
|
|
39
|
+
sizeBytes: external_exports.number().describe("The transit file size in bytes.").optional(),
|
|
40
|
+
name: external_exports.string().min(1).describe("The transit file name.").optional(),
|
|
41
|
+
mimeType: external_exports.string().min(1).describe("The transit file MIME type.").optional()
|
|
42
|
+
}).describe("A copy of a converted file stored in local transit storage.").nullable().optional()
|
|
43
|
+
}).describe("A converted file returned by ConvertAPI.")).min(1).describe("The converted DOCX files returned by ConvertAPI.")
|
|
44
|
+
}).describe("The output payload for a ConvertAPI PDF to DOCX conversion.");
|
|
45
|
+
var convertapiActions = {
|
|
46
|
+
convert_pdf_to_docx: {
|
|
47
|
+
description: "Convert a publicly accessible PDF URL to DOCX with ConvertAPI and return temporary file download URLs.",
|
|
48
|
+
effect: "write",
|
|
49
|
+
inputSchema: convertPdfToDocxInput,
|
|
50
|
+
outputSchema: external_exports.toJSONSchema(convertPdfToDocxOutput, { io: "output", unrepresentable: "any" })
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// ../plugins/src/convertapi/api.ts
|
|
55
|
+
var SERVICE = "convertapi";
|
|
56
|
+
var API_BASE = "https://v2.convertapi.com";
|
|
57
|
+
var CONVERT_PDF_TO_DOCX_PATH = "/convert/pdf/to/docx";
|
|
58
|
+
var REQUEST_TIMEOUT_MS = 12e4;
|
|
59
|
+
function toRecord(value) {
|
|
60
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
61
|
+
}
|
|
62
|
+
function text(value) {
|
|
63
|
+
return typeof value === "string" && value !== "" ? value : void 0;
|
|
64
|
+
}
|
|
65
|
+
function integer(value) {
|
|
66
|
+
return typeof value === "number" && Number.isInteger(value) ? value : void 0;
|
|
67
|
+
}
|
|
68
|
+
function errorMessage(payload, status) {
|
|
69
|
+
const record = toRecord(payload);
|
|
70
|
+
return text(record?.Message) ?? text(record?.message) ?? `ConvertAPI \u8FD4\u56DE HTTP ${status}`;
|
|
71
|
+
}
|
|
72
|
+
function convertapiError(status, message) {
|
|
73
|
+
if (status === 415) return upstreamError(400, message);
|
|
74
|
+
if (status === 503) return upstreamError(429, message);
|
|
75
|
+
if (status >= 500) return upstreamError(502, message);
|
|
76
|
+
return upstreamError(status, message);
|
|
77
|
+
}
|
|
78
|
+
async function readPayload(response) {
|
|
79
|
+
const body = await response.text();
|
|
80
|
+
if (body.trim() === "") return null;
|
|
81
|
+
try {
|
|
82
|
+
return JSON.parse(body);
|
|
83
|
+
} catch {
|
|
84
|
+
throw upstreamError(502, "ConvertAPI \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function setOptional(form, name, value) {
|
|
88
|
+
if (value !== void 0) form.set(name, String(value));
|
|
89
|
+
}
|
|
90
|
+
async function convertPdfToDocx(input, ctx) {
|
|
91
|
+
try {
|
|
92
|
+
assertPublicHttpUrl(input.fileUrl);
|
|
93
|
+
} catch {
|
|
94
|
+
throw new TBError("invalid_argument", "fileUrl \u5FC5\u987B\u662F\u516C\u7F51\u53EF\u8FBE\u7684 http(s) \u5730\u5740");
|
|
95
|
+
}
|
|
96
|
+
const form = new FormData();
|
|
97
|
+
form.set("File", input.fileUrl);
|
|
98
|
+
form.set("StoreFile", "true");
|
|
99
|
+
setOptional(form, "FileName", input.fileName);
|
|
100
|
+
setOptional(form, "Timeout", input.timeout);
|
|
101
|
+
setOptional(form, "Password", input.password);
|
|
102
|
+
setOptional(form, "PageRange", input.pageRange);
|
|
103
|
+
setOptional(form, "Layout", input.layout);
|
|
104
|
+
setOptional(form, "OcrMode", input.ocrMode);
|
|
105
|
+
setOptional(form, "OcrLanguage", input.ocrLanguage);
|
|
106
|
+
setOptional(form, "OcrEngine", input.ocrEngine);
|
|
107
|
+
setOptional(form, "Annotations", input.annotations);
|
|
108
|
+
let response;
|
|
109
|
+
try {
|
|
110
|
+
response = await guardedFetch(new URL(CONVERT_PDF_TO_DOCX_PATH, API_BASE).toString(), {
|
|
111
|
+
method: "POST",
|
|
112
|
+
headers: {
|
|
113
|
+
accept: "application/json",
|
|
114
|
+
authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
|
|
115
|
+
},
|
|
116
|
+
body: form,
|
|
117
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
118
|
+
});
|
|
119
|
+
} catch (error) {
|
|
120
|
+
if (error instanceof Error && error.name === "TimeoutError") {
|
|
121
|
+
throw upstreamError(504, `ConvertAPI ${REQUEST_TIMEOUT_MS / 1e3}s \u5185\u6CA1\u6709\u8FD4\u56DE\u8F6C\u6362\u7ED3\u679C`);
|
|
122
|
+
}
|
|
123
|
+
throw error;
|
|
124
|
+
}
|
|
125
|
+
const payload = await readPayload(response);
|
|
126
|
+
if (!response.ok) throw convertapiError(response.status, errorMessage(payload, response.status));
|
|
127
|
+
const record = toRecord(payload);
|
|
128
|
+
const rawFiles = Array.isArray(record?.Files) ? record.Files : [];
|
|
129
|
+
const files = rawFiles.map((value) => {
|
|
130
|
+
const file = toRecord(value);
|
|
131
|
+
if (file === void 0) return void 0;
|
|
132
|
+
return Object.fromEntries(Object.entries({
|
|
133
|
+
fileName: text(file.FileName),
|
|
134
|
+
fileExt: text(file.FileExt),
|
|
135
|
+
fileSize: integer(file.FileSize),
|
|
136
|
+
fileId: text(file.FileId),
|
|
137
|
+
url: text(file.Url)
|
|
138
|
+
}).filter(([, entry]) => entry !== void 0));
|
|
139
|
+
}).filter((file) => file !== void 0);
|
|
140
|
+
if (files.length === 0) {
|
|
141
|
+
throw upstreamError(502, "ConvertAPI \u7684\u6210\u529F\u54CD\u5E94\u91CC\u6CA1\u6709\u8F6C\u6362\u7ED3\u679C\u6587\u4EF6");
|
|
142
|
+
}
|
|
143
|
+
const conversionCost = integer(record?.ConversionCost);
|
|
144
|
+
return conversionCost === void 0 ? { files } : { conversionCost, files };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// ../plugins/src/convertapi/index.ts
|
|
148
|
+
function createConvertapiPlugin() {
|
|
149
|
+
return createProviderPlugin({
|
|
150
|
+
description: "ConvertAPI",
|
|
151
|
+
actions: convertapiActions,
|
|
152
|
+
handlers: {
|
|
153
|
+
convert_pdf_to_docx: convertPdfToDocx
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
var convertapi_default = createConvertapiPlugin();
|
|
158
|
+
export {
|
|
159
|
+
createConvertapiPlugin,
|
|
160
|
+
convertapi_default as default
|
|
161
|
+
};
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderPlugin,
|
|
3
|
+
guardedFetch,
|
|
4
|
+
requireApiKey,
|
|
5
|
+
upstreamError
|
|
6
|
+
} from "./chunk-CSJEZHQO.js";
|
|
7
|
+
import "./chunk-K7FVSFUX.js";
|
|
8
|
+
import {
|
|
9
|
+
external_exports
|
|
10
|
+
} from "./chunk-JLTYA2B3.js";
|
|
11
|
+
import "./chunk-MLKGABMK.js";
|
|
12
|
+
|
|
13
|
+
// ../plugins/src/currencyapi/api.ts
|
|
14
|
+
var SERVICE = "currencyapi";
|
|
15
|
+
var API_BASE = "https://api.currencyapi.com";
|
|
16
|
+
function record(value) {
|
|
17
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
18
|
+
}
|
|
19
|
+
function text(value) {
|
|
20
|
+
if (typeof value !== "string") return void 0;
|
|
21
|
+
const trimmed = value.trim();
|
|
22
|
+
return trimmed === "" ? void 0 : trimmed;
|
|
23
|
+
}
|
|
24
|
+
function errorMessage(payload) {
|
|
25
|
+
if (typeof payload === "string") return text(payload);
|
|
26
|
+
const body = record(payload);
|
|
27
|
+
return text(body?.message) ?? text(record(body?.error)?.message);
|
|
28
|
+
}
|
|
29
|
+
async function readPayload(response) {
|
|
30
|
+
const body = await response.text().catch(() => "");
|
|
31
|
+
if (body.trim() === "") return null;
|
|
32
|
+
try {
|
|
33
|
+
return JSON.parse(body);
|
|
34
|
+
} catch {
|
|
35
|
+
return body;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function requireObject(value, field) {
|
|
39
|
+
const body = record(value);
|
|
40
|
+
if (body === void 0) throw upstreamError(502, `${field} must be an object`);
|
|
41
|
+
return body;
|
|
42
|
+
}
|
|
43
|
+
async function request(ctx, path, query) {
|
|
44
|
+
const apiKey = requireApiKey(ctx, SERVICE);
|
|
45
|
+
const url = new URL(path, API_BASE);
|
|
46
|
+
for (const [key, value] of Object.entries(query ?? {})) {
|
|
47
|
+
if (value !== void 0) url.searchParams.set(key, String(value));
|
|
48
|
+
}
|
|
49
|
+
let response;
|
|
50
|
+
let payload;
|
|
51
|
+
try {
|
|
52
|
+
response = await guardedFetch(url.toString(), {
|
|
53
|
+
method: "GET",
|
|
54
|
+
// 凭证走自定义 `apikey` 头,不是 Authorization。
|
|
55
|
+
headers: { accept: "application/json", apikey: apiKey }
|
|
56
|
+
});
|
|
57
|
+
payload = await readPayload(response);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
throw upstreamError(
|
|
60
|
+
502,
|
|
61
|
+
error instanceof Error ? `currencyapi request failed: ${error.message}` : "currencyapi request failed"
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
if (!response.ok) {
|
|
65
|
+
throw upstreamError(
|
|
66
|
+
response.status,
|
|
67
|
+
errorMessage(payload) ?? `currencyapi request failed with ${response.status || 500}`
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
return requireObject(payload, "payload");
|
|
71
|
+
}
|
|
72
|
+
function requireString(value, field) {
|
|
73
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
74
|
+
throw upstreamError(502, `${field} must be a non-empty string`);
|
|
75
|
+
}
|
|
76
|
+
return value;
|
|
77
|
+
}
|
|
78
|
+
function requireInteger(value, field) {
|
|
79
|
+
if (typeof value !== "number" || !Number.isInteger(value)) throw upstreamError(502, `${field} must be an integer`);
|
|
80
|
+
return value;
|
|
81
|
+
}
|
|
82
|
+
function requireNumber(value, field) {
|
|
83
|
+
if (typeof value !== "number" || !Number.isFinite(value)) throw upstreamError(502, `${field} must be a number`);
|
|
84
|
+
return value;
|
|
85
|
+
}
|
|
86
|
+
function requireStringArray(value, field) {
|
|
87
|
+
if (!Array.isArray(value)) throw upstreamError(502, `${field} must be an array`);
|
|
88
|
+
return value.map((item) => String(item));
|
|
89
|
+
}
|
|
90
|
+
function normalizeQuotaBucket(value, field) {
|
|
91
|
+
const bucket = requireObject(value, field);
|
|
92
|
+
return {
|
|
93
|
+
total: requireInteger(bucket.total, `${field}.total`),
|
|
94
|
+
used: requireInteger(bucket.used, `${field}.used`),
|
|
95
|
+
remaining: requireInteger(bucket.remaining, `${field}.remaining`)
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function normalizeRates(payload) {
|
|
99
|
+
const meta = requireObject(payload.meta, "meta");
|
|
100
|
+
const data = requireObject(payload.data, "data");
|
|
101
|
+
return {
|
|
102
|
+
meta: { last_updated_at: requireString(meta.last_updated_at, "meta.last_updated_at") },
|
|
103
|
+
data: Object.fromEntries(Object.entries(data).map(([code, item]) => {
|
|
104
|
+
const rate = requireObject(item, `data.${code}`);
|
|
105
|
+
return [code, {
|
|
106
|
+
code: requireString(rate.code, `data.${code}.code`),
|
|
107
|
+
value: requireNumber(rate.value, `data.${code}.value`)
|
|
108
|
+
}];
|
|
109
|
+
}))
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function currenciesQuery(value) {
|
|
113
|
+
return value === void 0 || value.length === 0 ? void 0 : value.join(",");
|
|
114
|
+
}
|
|
115
|
+
async function getApiStatus(_input, ctx) {
|
|
116
|
+
const payload = await request(ctx, "/v3/status");
|
|
117
|
+
const quotas = requireObject(payload.quotas, "quotas");
|
|
118
|
+
return {
|
|
119
|
+
account_id: requireInteger(payload.account_id, "account_id"),
|
|
120
|
+
quotas: {
|
|
121
|
+
month: normalizeQuotaBucket(quotas.month, "quotas.month"),
|
|
122
|
+
grace: normalizeQuotaBucket(quotas.grace, "quotas.grace")
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
async function getSupportedCurrencies(input, ctx) {
|
|
127
|
+
const payload = await request(ctx, "/v3/currencies", {
|
|
128
|
+
currencies: currenciesQuery(input.currencies),
|
|
129
|
+
type: input.type
|
|
130
|
+
});
|
|
131
|
+
const data = requireObject(payload.data, "data");
|
|
132
|
+
return {
|
|
133
|
+
data: Object.fromEntries(Object.entries(data).map(([code, item]) => {
|
|
134
|
+
const meta = requireObject(item, `data.${code}`);
|
|
135
|
+
return [code, {
|
|
136
|
+
symbol: requireString(meta.symbol, `data.${code}.symbol`),
|
|
137
|
+
name: requireString(meta.name, `data.${code}.name`),
|
|
138
|
+
symbol_native: requireString(meta.symbol_native, `data.${code}.symbol_native`),
|
|
139
|
+
decimal_digits: requireInteger(meta.decimal_digits, `data.${code}.decimal_digits`),
|
|
140
|
+
rounding: requireNumber(meta.rounding, `data.${code}.rounding`),
|
|
141
|
+
code: requireString(meta.code, `data.${code}.code`),
|
|
142
|
+
name_plural: requireString(meta.name_plural, `data.${code}.name_plural`),
|
|
143
|
+
type: requireString(meta.type, `data.${code}.type`),
|
|
144
|
+
countries: requireStringArray(meta.countries, `data.${code}.countries`)
|
|
145
|
+
}];
|
|
146
|
+
}))
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
async function getLatestRates(input, ctx) {
|
|
150
|
+
return normalizeRates(await request(ctx, "/v3/latest", {
|
|
151
|
+
base_currency: input.base_currency,
|
|
152
|
+
currencies: currenciesQuery(input.currencies),
|
|
153
|
+
type: input.type
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
156
|
+
async function getHistoricalRates(input, ctx) {
|
|
157
|
+
return normalizeRates(await request(ctx, "/v3/historical", {
|
|
158
|
+
date: input.date,
|
|
159
|
+
base_currency: input.base_currency,
|
|
160
|
+
currencies: currenciesQuery(input.currencies),
|
|
161
|
+
type: input.type
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
164
|
+
async function convertCurrency(input, ctx) {
|
|
165
|
+
return normalizeRates(await request(ctx, "/v3/convert", {
|
|
166
|
+
value: input.value,
|
|
167
|
+
date: input.date,
|
|
168
|
+
base_currency: input.base_currency,
|
|
169
|
+
currencies: currenciesQuery(input.currencies),
|
|
170
|
+
type: input.type
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// ../plugins/src/currencyapi/schema.ts
|
|
175
|
+
var getApiStatusInput = external_exports.strictObject({}).describe("Input parameters for retrieving current currencyapi quota usage.");
|
|
176
|
+
var getApiStatusOutput = external_exports.strictObject({
|
|
177
|
+
account_id: external_exports.int().describe("currencyapi account identifier."),
|
|
178
|
+
quotas: external_exports.strictObject({
|
|
179
|
+
month: external_exports.strictObject({
|
|
180
|
+
total: external_exports.int().describe("Total quota available in the current bucket."),
|
|
181
|
+
used: external_exports.int().describe("Quota already consumed in the current bucket."),
|
|
182
|
+
remaining: external_exports.int().describe("Quota still available in the current bucket.")
|
|
183
|
+
}).describe("Usage quota bucket."),
|
|
184
|
+
grace: external_exports.strictObject({
|
|
185
|
+
total: external_exports.int().describe("Total quota available in the current bucket."),
|
|
186
|
+
used: external_exports.int().describe("Quota already consumed in the current bucket."),
|
|
187
|
+
remaining: external_exports.int().describe("Quota still available in the current bucket.")
|
|
188
|
+
}).describe("Usage quota bucket.")
|
|
189
|
+
}).describe("Quota usage information returned by currencyapi.")
|
|
190
|
+
}).describe("currencyapi account quota status.");
|
|
191
|
+
var getSupportedCurrenciesInput = external_exports.strictObject({
|
|
192
|
+
currencies: external_exports.array(external_exports.string().regex(new RegExp("^[A-Z0-9]{3,10}$")).describe("Currency code using uppercase ASCII letters or digits.")).min(1).describe("List of currency codes to include in the response.").optional(),
|
|
193
|
+
type: external_exports.enum(["fiat", "metal", "crypto"]).describe("Currency type filter. Supported values are fiat, metal, or crypto.").optional()
|
|
194
|
+
}).describe("Input parameters for retrieving supported currencies from currencyapi.");
|
|
195
|
+
var getSupportedCurrenciesOutput = external_exports.strictObject({
|
|
196
|
+
data: external_exports.record(external_exports.string(), external_exports.strictObject({
|
|
197
|
+
symbol: external_exports.string().min(1).describe("Currency symbol returned by currencyapi."),
|
|
198
|
+
name: external_exports.string().min(1).describe("Currency display name."),
|
|
199
|
+
symbol_native: external_exports.string().min(1).describe("Native currency symbol."),
|
|
200
|
+
decimal_digits: external_exports.int().describe("Number of decimal digits used by the currency."),
|
|
201
|
+
rounding: external_exports.number().describe("Currency rounding precision value."),
|
|
202
|
+
code: external_exports.string().regex(new RegExp("^[A-Z0-9]{3,10}$")).describe("Currency code using uppercase ASCII letters or digits."),
|
|
203
|
+
name_plural: external_exports.string().min(1).describe("Plural display name for the currency."),
|
|
204
|
+
type: external_exports.enum(["fiat", "metal", "crypto"]).describe("Currency type filter. Supported values are fiat, metal, or crypto."),
|
|
205
|
+
countries: external_exports.array(external_exports.string().min(1).describe("ISO country code that uses the currency.")).describe("List of ISO country codes associated with the currency.")
|
|
206
|
+
}).describe("Currency metadata returned by currencyapi.")).describe("Mapping of currency codes to currency metadata.")
|
|
207
|
+
}).describe("Supported currencies returned by currencyapi.");
|
|
208
|
+
var getLatestRatesInput = external_exports.strictObject({
|
|
209
|
+
base_currency: external_exports.string().regex(new RegExp("^[A-Z0-9]{3,10}$")).describe("Currency code using uppercase ASCII letters or digits.").optional(),
|
|
210
|
+
currencies: external_exports.array(external_exports.string().regex(new RegExp("^[A-Z0-9]{3,10}$")).describe("Currency code using uppercase ASCII letters or digits.")).min(1).describe("List of currency codes to include in the response.").optional(),
|
|
211
|
+
type: external_exports.enum(["fiat", "metal", "crypto"]).describe("Currency type filter. Supported values are fiat, metal, or crypto.").optional()
|
|
212
|
+
}).describe("Input parameters for retrieving latest exchange rates from currencyapi.");
|
|
213
|
+
var getLatestRatesOutput = external_exports.strictObject({
|
|
214
|
+
meta: external_exports.strictObject({
|
|
215
|
+
last_updated_at: external_exports.string().min(1).describe("Timestamp indicating when the dataset was last updated.")
|
|
216
|
+
}).describe("Response metadata returned by currencyapi."),
|
|
217
|
+
data: external_exports.record(external_exports.string(), external_exports.strictObject({
|
|
218
|
+
code: external_exports.string().regex(new RegExp("^[A-Z0-9]{3,10}$")).describe("Currency code using uppercase ASCII letters or digits."),
|
|
219
|
+
value: external_exports.number().describe("Exchange rate or converted value returned by currencyapi.")
|
|
220
|
+
}).describe("Exchange rate entry returned by currencyapi.")).describe("Mapping of currency codes to exchange rate entries.")
|
|
221
|
+
}).describe("Exchange rate payload returned by currencyapi.");
|
|
222
|
+
var getHistoricalRatesInput = external_exports.strictObject({
|
|
223
|
+
date: external_exports.string().regex(new RegExp("^\\d{4}-\\d{2}-\\d{2}$")).describe("Date in YYYY-MM-DD format."),
|
|
224
|
+
base_currency: external_exports.string().regex(new RegExp("^[A-Z0-9]{3,10}$")).describe("Currency code using uppercase ASCII letters or digits.").optional(),
|
|
225
|
+
currencies: external_exports.array(external_exports.string().regex(new RegExp("^[A-Z0-9]{3,10}$")).describe("Currency code using uppercase ASCII letters or digits.")).min(1).describe("List of currency codes to include in the response.").optional(),
|
|
226
|
+
type: external_exports.enum(["fiat", "metal", "crypto"]).describe("Currency type filter. Supported values are fiat, metal, or crypto.").optional()
|
|
227
|
+
}).describe("Input parameters for retrieving historical exchange rates from currencyapi.");
|
|
228
|
+
var getHistoricalRatesOutput = external_exports.strictObject({
|
|
229
|
+
meta: external_exports.strictObject({
|
|
230
|
+
last_updated_at: external_exports.string().min(1).describe("Timestamp indicating when the dataset was last updated.")
|
|
231
|
+
}).describe("Response metadata returned by currencyapi."),
|
|
232
|
+
data: external_exports.record(external_exports.string(), external_exports.strictObject({
|
|
233
|
+
code: external_exports.string().regex(new RegExp("^[A-Z0-9]{3,10}$")).describe("Currency code using uppercase ASCII letters or digits."),
|
|
234
|
+
value: external_exports.number().describe("Exchange rate or converted value returned by currencyapi.")
|
|
235
|
+
}).describe("Exchange rate entry returned by currencyapi.")).describe("Mapping of currency codes to exchange rate entries.")
|
|
236
|
+
}).describe("Exchange rate payload returned by currencyapi.");
|
|
237
|
+
var convertCurrencyInput = external_exports.strictObject({
|
|
238
|
+
value: external_exports.number().gt(0).describe("Numeric amount to convert from the base currency."),
|
|
239
|
+
date: external_exports.string().regex(new RegExp("^\\d{4}-\\d{2}-\\d{2}$")).describe("Date in YYYY-MM-DD format.").optional(),
|
|
240
|
+
base_currency: external_exports.string().regex(new RegExp("^[A-Z0-9]{3,10}$")).describe("Currency code using uppercase ASCII letters or digits.").optional(),
|
|
241
|
+
currencies: external_exports.array(external_exports.string().regex(new RegExp("^[A-Z0-9]{3,10}$")).describe("Currency code using uppercase ASCII letters or digits.")).min(1).describe("List of currency codes to include in the response.").optional(),
|
|
242
|
+
type: external_exports.enum(["fiat", "metal", "crypto"]).describe("Currency type filter. Supported values are fiat, metal, or crypto.").optional()
|
|
243
|
+
}).describe("Input parameters for converting a monetary amount with currencyapi.");
|
|
244
|
+
var convertCurrencyOutput = external_exports.strictObject({
|
|
245
|
+
meta: external_exports.strictObject({
|
|
246
|
+
last_updated_at: external_exports.string().min(1).describe("Timestamp indicating when the dataset was last updated.")
|
|
247
|
+
}).describe("Response metadata returned by currencyapi."),
|
|
248
|
+
data: external_exports.record(external_exports.string(), external_exports.strictObject({
|
|
249
|
+
code: external_exports.string().regex(new RegExp("^[A-Z0-9]{3,10}$")).describe("Currency code using uppercase ASCII letters or digits."),
|
|
250
|
+
value: external_exports.number().describe("Exchange rate or converted value returned by currencyapi.")
|
|
251
|
+
}).describe("Exchange rate entry returned by currencyapi.")).describe("Mapping of currency codes to exchange rate entries.")
|
|
252
|
+
}).describe("Exchange rate payload returned by currencyapi.");
|
|
253
|
+
var currencyapiActions = {
|
|
254
|
+
get_api_status: {
|
|
255
|
+
description: "Retrieve current currencyapi account quota usage.",
|
|
256
|
+
effect: "read",
|
|
257
|
+
inputSchema: getApiStatusInput,
|
|
258
|
+
outputSchema: external_exports.toJSONSchema(getApiStatusOutput, { io: "output", unrepresentable: "any" })
|
|
259
|
+
},
|
|
260
|
+
get_supported_currencies: {
|
|
261
|
+
description: "Retrieve supported currency metadata from currencyapi.",
|
|
262
|
+
effect: "read",
|
|
263
|
+
inputSchema: getSupportedCurrenciesInput,
|
|
264
|
+
outputSchema: external_exports.toJSONSchema(getSupportedCurrenciesOutput, { io: "output", unrepresentable: "any" })
|
|
265
|
+
},
|
|
266
|
+
get_latest_rates: {
|
|
267
|
+
description: "Retrieve the latest exchange rates from currencyapi.",
|
|
268
|
+
effect: "read",
|
|
269
|
+
inputSchema: getLatestRatesInput,
|
|
270
|
+
outputSchema: external_exports.toJSONSchema(getLatestRatesOutput, { io: "output", unrepresentable: "any" })
|
|
271
|
+
},
|
|
272
|
+
get_historical_rates: {
|
|
273
|
+
description: "Retrieve historical exchange rates for a specific date from currencyapi.",
|
|
274
|
+
effect: "read",
|
|
275
|
+
inputSchema: getHistoricalRatesInput,
|
|
276
|
+
outputSchema: external_exports.toJSONSchema(getHistoricalRatesOutput, { io: "output", unrepresentable: "any" })
|
|
277
|
+
},
|
|
278
|
+
convert_currency: {
|
|
279
|
+
description: "Convert a monetary amount into one or more currencies with currencyapi.",
|
|
280
|
+
effect: "write",
|
|
281
|
+
inputSchema: convertCurrencyInput,
|
|
282
|
+
outputSchema: external_exports.toJSONSchema(convertCurrencyOutput, { io: "output", unrepresentable: "any" })
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
// ../plugins/src/currencyapi/index.ts
|
|
287
|
+
function createCurrencyapiPlugin() {
|
|
288
|
+
return createProviderPlugin({
|
|
289
|
+
description: "currencyapi",
|
|
290
|
+
actions: currencyapiActions,
|
|
291
|
+
// 上游的 credentialValidators 打的就是 /v3/status;它只读、无入参,且不消耗汇率配额。
|
|
292
|
+
credentialProbe: "get_api_status",
|
|
293
|
+
handlers: {
|
|
294
|
+
get_api_status: getApiStatus,
|
|
295
|
+
get_supported_currencies: getSupportedCurrencies,
|
|
296
|
+
get_latest_rates: getLatestRates,
|
|
297
|
+
get_historical_rates: getHistoricalRates,
|
|
298
|
+
convert_currency: convertCurrency
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
var currencyapi_default = createCurrencyapiPlugin();
|
|
303
|
+
export {
|
|
304
|
+
createCurrencyapiPlugin,
|
|
305
|
+
currencyapi_default as default
|
|
306
|
+
};
|