@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,34 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
asJsonObject,
|
|
3
|
+
integerValue,
|
|
4
|
+
trimmedText
|
|
5
|
+
} from "./chunk-JXHMDBAY.js";
|
|
1
6
|
import {
|
|
2
7
|
createProviderPlugin,
|
|
3
8
|
requireCredential,
|
|
4
9
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-B4P6YZFS.js";
|
|
6
11
|
import {
|
|
7
12
|
guardedFetch
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-GKX72JMJ.js";
|
|
13
|
+
} from "./chunk-SWBNHIO4.js";
|
|
10
14
|
import {
|
|
11
15
|
TBError,
|
|
12
16
|
external_exports
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-OKRZPQ3R.js";
|
|
18
|
+
import "./chunk-U67V476Y.js";
|
|
15
19
|
|
|
16
20
|
// ../plugins/src/twilio/api.ts
|
|
17
21
|
var SERVICE = "twilio";
|
|
18
22
|
var API_BASE = "https://api.twilio.com/2010-04-01";
|
|
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 record(value) {
|
|
25
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
26
|
-
}
|
|
27
|
-
function integer(value) {
|
|
28
|
-
return typeof value === "number" && Number.isInteger(value) ? value : void 0;
|
|
29
|
-
}
|
|
30
23
|
function requireText(value, field) {
|
|
31
|
-
const result =
|
|
24
|
+
const result = trimmedText(value);
|
|
32
25
|
if (result === void 0) throw new TBError("invalid_argument", `${field} is required.`);
|
|
33
26
|
return result;
|
|
34
27
|
}
|
|
@@ -41,13 +34,13 @@ function basicAuthHeader(ctx) {
|
|
|
41
34
|
return `Basic ${btoa(binary)}`;
|
|
42
35
|
}
|
|
43
36
|
function errorMessage(payload, raw, status) {
|
|
44
|
-
const body =
|
|
37
|
+
const body = asJsonObject(payload);
|
|
45
38
|
if (body === void 0) {
|
|
46
39
|
const trimmed = raw.trim();
|
|
47
40
|
return trimmed === "" ? `Twilio request failed with ${status}` : trimmed;
|
|
48
41
|
}
|
|
49
|
-
const message =
|
|
50
|
-
const code =
|
|
42
|
+
const message = trimmedText(body.message) ?? trimmedText(body.detail) ?? `Twilio request failed with ${status}`;
|
|
43
|
+
const code = trimmedText(body.code) ?? integerValue(body.code)?.toString();
|
|
51
44
|
return code === void 0 ? message : `${message} (${code})`;
|
|
52
45
|
}
|
|
53
46
|
async function request(ctx, options) {
|
|
@@ -91,38 +84,38 @@ function accountPath(ctx, suffix) {
|
|
|
91
84
|
return `/Accounts/${encodeURIComponent(accountSid)}${suffix}`;
|
|
92
85
|
}
|
|
93
86
|
function normalizeAccount(payload) {
|
|
94
|
-
const account =
|
|
87
|
+
const account = asJsonObject(payload) ?? {};
|
|
95
88
|
return {
|
|
96
|
-
accountSid:
|
|
97
|
-
friendlyName:
|
|
98
|
-
status:
|
|
99
|
-
type:
|
|
89
|
+
accountSid: trimmedText(account.sid) ?? "",
|
|
90
|
+
friendlyName: trimmedText(account.friendly_name) ?? null,
|
|
91
|
+
status: trimmedText(account.status) ?? null,
|
|
92
|
+
type: trimmedText(account.type) ?? null
|
|
100
93
|
};
|
|
101
94
|
}
|
|
102
95
|
function normalizeUsageRecord(value) {
|
|
103
|
-
const usage =
|
|
96
|
+
const usage = asJsonObject(value) ?? {};
|
|
104
97
|
return {
|
|
105
|
-
accountSid:
|
|
106
|
-
category:
|
|
107
|
-
count:
|
|
108
|
-
countUnit:
|
|
109
|
-
usage:
|
|
110
|
-
usageUnit:
|
|
111
|
-
price:
|
|
112
|
-
priceUnit:
|
|
113
|
-
startDate:
|
|
114
|
-
endDate:
|
|
98
|
+
accountSid: trimmedText(usage.account_sid) ?? null,
|
|
99
|
+
category: trimmedText(usage.category) ?? null,
|
|
100
|
+
count: trimmedText(usage.count) ?? null,
|
|
101
|
+
countUnit: trimmedText(usage.count_unit) ?? null,
|
|
102
|
+
usage: trimmedText(usage.usage) ?? null,
|
|
103
|
+
usageUnit: trimmedText(usage.usage_unit) ?? null,
|
|
104
|
+
price: trimmedText(usage.price) ?? null,
|
|
105
|
+
priceUnit: trimmedText(usage.price_unit) ?? null,
|
|
106
|
+
startDate: trimmedText(usage.start_date) ?? null,
|
|
107
|
+
endDate: trimmedText(usage.end_date) ?? null
|
|
115
108
|
};
|
|
116
109
|
}
|
|
117
110
|
function normalizeMessage(payload) {
|
|
118
|
-
const message =
|
|
111
|
+
const message = asJsonObject(payload) ?? {};
|
|
119
112
|
return {
|
|
120
|
-
messageSid:
|
|
121
|
-
accountSid:
|
|
122
|
-
status:
|
|
123
|
-
to:
|
|
124
|
-
from:
|
|
125
|
-
body:
|
|
113
|
+
messageSid: trimmedText(message.sid) ?? "",
|
|
114
|
+
accountSid: trimmedText(message.account_sid) ?? null,
|
|
115
|
+
status: trimmedText(message.status) ?? null,
|
|
116
|
+
to: trimmedText(message.to) ?? null,
|
|
117
|
+
from: trimmedText(message.from) ?? null,
|
|
118
|
+
body: trimmedText(message.body) ?? null
|
|
126
119
|
};
|
|
127
120
|
}
|
|
128
121
|
function list(value) {
|
|
@@ -132,35 +125,35 @@ async function getAccount(_input, ctx) {
|
|
|
132
125
|
return normalizeAccount(await request(ctx, { path: accountPath(ctx, ".json") }));
|
|
133
126
|
}
|
|
134
127
|
async function listUsageRecords(input, ctx) {
|
|
135
|
-
const payload =
|
|
128
|
+
const payload = asJsonObject(await request(ctx, {
|
|
136
129
|
path: accountPath(ctx, "/Usage/Records.json"),
|
|
137
130
|
query: {
|
|
138
|
-
Category:
|
|
139
|
-
StartDate:
|
|
140
|
-
EndDate:
|
|
131
|
+
Category: trimmedText(input.category),
|
|
132
|
+
StartDate: trimmedText(input.startDate),
|
|
133
|
+
EndDate: trimmedText(input.endDate),
|
|
141
134
|
PageSize: input.pageSize
|
|
142
135
|
}
|
|
143
136
|
})) ?? {};
|
|
144
137
|
return {
|
|
145
138
|
usageRecords: list(payload.usage_records).map((item) => normalizeUsageRecord(item)),
|
|
146
|
-
page:
|
|
147
|
-
pageSize:
|
|
148
|
-
nextPageUri:
|
|
139
|
+
page: integerValue(payload.page) ?? null,
|
|
140
|
+
pageSize: integerValue(payload.page_size) ?? null,
|
|
141
|
+
nextPageUri: trimmedText(payload.next_page_uri) ?? null
|
|
149
142
|
};
|
|
150
143
|
}
|
|
151
144
|
async function listMessages(input, ctx) {
|
|
152
|
-
const payload =
|
|
145
|
+
const payload = asJsonObject(await request(ctx, {
|
|
153
146
|
path: accountPath(ctx, "/Messages.json"),
|
|
154
147
|
query: {
|
|
155
|
-
To:
|
|
156
|
-
From:
|
|
148
|
+
To: trimmedText(input.to),
|
|
149
|
+
From: trimmedText(input.from),
|
|
157
150
|
PageSize: input.pageSize,
|
|
158
|
-
PageToken:
|
|
151
|
+
PageToken: trimmedText(input.pageToken)
|
|
159
152
|
}
|
|
160
153
|
})) ?? {};
|
|
161
154
|
return {
|
|
162
155
|
messages: list(payload.messages).map((item) => normalizeMessage(item)),
|
|
163
|
-
nextPageUri:
|
|
156
|
+
nextPageUri: trimmedText(payload.next_page_uri) ?? null
|
|
164
157
|
};
|
|
165
158
|
}
|
|
166
159
|
async function getMessage(input, ctx) {
|
|
@@ -1,81 +1,61 @@
|
|
|
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
|
TBError,
|
|
12
16
|
external_exports
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-OKRZPQ3R.js";
|
|
18
|
+
import "./chunk-U67V476Y.js";
|
|
15
19
|
|
|
16
20
|
// ../plugins/src/umami/api.ts
|
|
17
21
|
var SERVICE = "umami";
|
|
18
22
|
var API_BASE = "https://api.umami.is";
|
|
19
|
-
|
|
20
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
21
|
-
}
|
|
22
|
-
function optionalText(value) {
|
|
23
|
-
if (typeof value !== "string") return void 0;
|
|
24
|
-
const trimmed = value.trim();
|
|
25
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
26
|
-
}
|
|
23
|
+
var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
|
|
27
24
|
function requiredText(value, field) {
|
|
28
|
-
const text =
|
|
25
|
+
const text = trimmedText(value);
|
|
29
26
|
if (text === void 0) throw new TBError("invalid_argument", `${field} \u4E0D\u80FD\u4E3A\u7A7A`);
|
|
30
27
|
return text;
|
|
31
28
|
}
|
|
32
|
-
async function readPayload(response) {
|
|
33
|
-
const text = await response.text().catch(() => "");
|
|
34
|
-
if (text.trim() === "") return null;
|
|
35
|
-
try {
|
|
36
|
-
return JSON.parse(text);
|
|
37
|
-
} catch {
|
|
38
|
-
return text;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
29
|
function errorMessage(payload) {
|
|
42
|
-
if (typeof payload === "string") return
|
|
43
|
-
const body =
|
|
30
|
+
if (typeof payload === "string") return trimmedText(payload);
|
|
31
|
+
const body = asJsonObject(payload);
|
|
44
32
|
if (body === void 0) return void 0;
|
|
45
|
-
return
|
|
33
|
+
return trimmedText(body.error) ?? trimmedText(asJsonObject(body.error)?.message) ?? trimmedText(body.message);
|
|
46
34
|
}
|
|
47
35
|
async function request(ctx, path, query = {}) {
|
|
48
36
|
const apiKey = requireApiKey(ctx, SERVICE);
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (!response.ok) {
|
|
69
|
-
throw upstreamError(
|
|
70
|
-
response.status,
|
|
71
|
-
errorMessage(payload) ?? (response.statusText || `umami \u8FD4\u56DE HTTP ${response.status}`)
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
if (typeof payload === "string") throw upstreamError(502, "umami \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94");
|
|
75
|
-
return payload;
|
|
37
|
+
const response = await http.request({
|
|
38
|
+
path,
|
|
39
|
+
query: Object.entries(query),
|
|
40
|
+
headers: {
|
|
41
|
+
accept: "application/json",
|
|
42
|
+
authorization: `Bearer ${apiKey}`
|
|
43
|
+
},
|
|
44
|
+
invalidJson: "text",
|
|
45
|
+
mapError: ({ data, status, statusText }) => upstreamError(
|
|
46
|
+
status,
|
|
47
|
+
errorMessage(data) ?? (statusText || `umami \u8FD4\u56DE HTTP ${status}`)
|
|
48
|
+
),
|
|
49
|
+
mapTransportError: ({ message }) => upstreamError(
|
|
50
|
+
502,
|
|
51
|
+
message === void 0 ? "umami \u8BF7\u6C42\u5931\u8D25" : `umami \u8BF7\u6C42\u5931\u8D25: ${message}`
|
|
52
|
+
)
|
|
53
|
+
});
|
|
54
|
+
if (response.bodyKind === "invalid-json") throw upstreamError(502, "umami \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94");
|
|
55
|
+
return response.bodyKind === "empty" ? null : response.data;
|
|
76
56
|
}
|
|
77
57
|
function responseRecord(value, field) {
|
|
78
|
-
const object =
|
|
58
|
+
const object = asJsonObject(value);
|
|
79
59
|
if (object === void 0) throw upstreamError(502, `umami \u54CD\u5E94\u7684 ${field} \u4E0D\u662F\u5BF9\u8C61`);
|
|
80
60
|
return object;
|
|
81
61
|
}
|
|
@@ -97,16 +77,16 @@ function dateRangeQuery(input) {
|
|
|
97
77
|
startAt: String(input.startAt),
|
|
98
78
|
endAt: String(input.endAt),
|
|
99
79
|
timezone: requiredText(input.timezone, "timezone"),
|
|
100
|
-
url:
|
|
101
|
-
referrer:
|
|
102
|
-
title:
|
|
103
|
-
host:
|
|
104
|
-
os:
|
|
105
|
-
browser:
|
|
106
|
-
device:
|
|
107
|
-
country:
|
|
108
|
-
region:
|
|
109
|
-
city:
|
|
80
|
+
url: trimmedText(input.url),
|
|
81
|
+
referrer: trimmedText(input.referrer),
|
|
82
|
+
title: trimmedText(input.title),
|
|
83
|
+
host: trimmedText(input.host),
|
|
84
|
+
os: trimmedText(input.os),
|
|
85
|
+
browser: trimmedText(input.browser),
|
|
86
|
+
device: trimmedText(input.device),
|
|
87
|
+
country: trimmedText(input.country),
|
|
88
|
+
region: trimmedText(input.region),
|
|
89
|
+
city: trimmedText(input.city)
|
|
110
90
|
};
|
|
111
91
|
}
|
|
112
92
|
function websitePath(websiteId, suffix = "") {
|
|
@@ -128,7 +108,7 @@ async function getCurrentUser(_input, ctx) {
|
|
|
128
108
|
}
|
|
129
109
|
async function listWebsites(input, ctx) {
|
|
130
110
|
const payload = await request(ctx, "/api/websites", {
|
|
131
|
-
query:
|
|
111
|
+
query: trimmedText(input.query),
|
|
132
112
|
page: input.page === void 0 ? void 0 : String(input.page),
|
|
133
113
|
pageSize: input.pageSize === void 0 ? void 0 : String(input.pageSize)
|
|
134
114
|
});
|
|
@@ -145,7 +125,7 @@ async function getWebsiteStats(input, ctx) {
|
|
|
145
125
|
}
|
|
146
126
|
async function getPageviews(input, ctx) {
|
|
147
127
|
const path = websitePath(input.websiteId, "/pageviews");
|
|
148
|
-
const query = { ...dateRangeQuery(input), unit:
|
|
128
|
+
const query = { ...dateRangeQuery(input), unit: trimmedText(input.unit) };
|
|
149
129
|
const pageviews = responseRecord(await request(ctx, path, query), "pageviews");
|
|
150
130
|
return { pageviews, raw: pageviews };
|
|
151
131
|
}
|
|
@@ -168,7 +148,7 @@ async function listEvents(input, ctx) {
|
|
|
168
148
|
const path = websitePath(input.websiteId, "/events");
|
|
169
149
|
const query = {
|
|
170
150
|
...dateRangeQuery(input),
|
|
171
|
-
query:
|
|
151
|
+
query: trimmedText(input.query),
|
|
172
152
|
page: input.page === void 0 ? void 0 : String(input.page),
|
|
173
153
|
pageSize: input.pageSize === void 0 ? void 0 : String(input.pageSize)
|
|
174
154
|
};
|
|
@@ -1,34 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderHttpClient
|
|
3
|
+
} from "./chunk-VLOIDU5U.js";
|
|
4
|
+
import {
|
|
5
|
+
asJsonObject,
|
|
6
|
+
finiteNumber,
|
|
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/unsplash/api.ts
|
|
17
22
|
var SERVICE = "unsplash";
|
|
18
23
|
var API_BASE = "https://api.unsplash.com";
|
|
19
|
-
|
|
20
|
-
if (typeof value !== "string") return void 0;
|
|
21
|
-
const trimmed = value.trim();
|
|
22
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
23
|
-
}
|
|
24
|
-
function record(value) {
|
|
25
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
26
|
-
}
|
|
27
|
-
function numeric(value) {
|
|
28
|
-
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
29
|
-
}
|
|
24
|
+
var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
|
|
30
25
|
function requireRecord(value, label) {
|
|
31
|
-
const result =
|
|
26
|
+
const result = asJsonObject(value);
|
|
32
27
|
if (result === void 0) {
|
|
33
28
|
throw new TBError("unavailable", `${label}\u4E0D\u662F\u5BF9\u8C61`, { retryable: true });
|
|
34
29
|
}
|
|
@@ -41,58 +36,46 @@ function objectArray(value) {
|
|
|
41
36
|
return value.map((item) => requireRecord(item, "Unsplash \u6570\u7EC4\u5143\u7D20"));
|
|
42
37
|
}
|
|
43
38
|
function requireText(value, field) {
|
|
44
|
-
const result =
|
|
39
|
+
const result = trimmedText(value);
|
|
45
40
|
if (result === void 0) throw new TBError("invalid_argument", `${field} \u4E0D\u80FD\u662F\u7A7A\u767D`);
|
|
46
41
|
return result;
|
|
47
42
|
}
|
|
48
43
|
function csv(value) {
|
|
49
44
|
if (value === void 0) return void 0;
|
|
50
|
-
const items = value.map((item) =>
|
|
45
|
+
const items = value.map((item) => trimmedText(item)).filter((item) => item !== void 0);
|
|
51
46
|
return items.length > 0 ? items.join(",") : void 0;
|
|
52
47
|
}
|
|
53
|
-
function buildUrl(path, query) {
|
|
54
|
-
const url = new URL(`${API_BASE}${path}`);
|
|
55
|
-
for (const [key, value] of Object.entries(query)) {
|
|
56
|
-
if (value !== void 0) url.searchParams.set(key, String(value));
|
|
57
|
-
}
|
|
58
|
-
return url.toString();
|
|
59
|
-
}
|
|
60
48
|
function errorMessage(payload) {
|
|
61
|
-
const body =
|
|
49
|
+
const body = asJsonObject(payload);
|
|
62
50
|
if (body === void 0) return void 0;
|
|
63
51
|
if (Array.isArray(body.errors)) {
|
|
64
52
|
for (const item of body.errors) {
|
|
65
|
-
const message =
|
|
53
|
+
const message = trimmedText(item);
|
|
66
54
|
if (message !== void 0) return message;
|
|
67
55
|
}
|
|
68
56
|
}
|
|
69
|
-
return
|
|
57
|
+
return trimmedText(body.error) ?? trimmedText(body.message);
|
|
70
58
|
}
|
|
71
59
|
async function request(ctx, path, query = {}) {
|
|
72
|
-
const response = await
|
|
73
|
-
|
|
60
|
+
const response = await http.request({
|
|
61
|
+
path,
|
|
62
|
+
query: Object.entries(query),
|
|
74
63
|
headers: {
|
|
75
64
|
"accept": "application/json",
|
|
76
65
|
// Unsplash 自有的方案名,不是 Bearer。
|
|
77
66
|
"authorization": `Client-ID ${requireApiKey(ctx, SERVICE)}`,
|
|
78
67
|
"accept-version": "v1"
|
|
79
|
-
}
|
|
68
|
+
},
|
|
69
|
+
invalidJson: "text",
|
|
70
|
+
mapError: ({ bodyKind, data, status }) => upstreamError(
|
|
71
|
+
status,
|
|
72
|
+
errorMessage(bodyKind === "json" ? data : null) ?? `Unsplash \u8FD4\u56DE HTTP ${status}`
|
|
73
|
+
)
|
|
80
74
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (body !== "") {
|
|
84
|
-
try {
|
|
85
|
-
payload = JSON.parse(body);
|
|
86
|
-
} catch {
|
|
87
|
-
if (response.ok) {
|
|
88
|
-
throw new TBError("unavailable", "Unsplash \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94", { retryable: true });
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
if (!response.ok) {
|
|
93
|
-
throw upstreamError(response.status, errorMessage(payload) ?? `Unsplash \u8FD4\u56DE HTTP ${response.status}`);
|
|
75
|
+
if (response.bodyKind === "invalid-json") {
|
|
76
|
+
throw new TBError("unavailable", "Unsplash \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94", { retryable: true });
|
|
94
77
|
}
|
|
95
|
-
return
|
|
78
|
+
return response.bodyKind === "empty" ? null : response.data;
|
|
96
79
|
}
|
|
97
80
|
async function listPhotos(input, ctx) {
|
|
98
81
|
const payload = await request(ctx, "/photos", {
|
|
@@ -116,8 +99,8 @@ async function searchPhotos(input, ctx) {
|
|
|
116
99
|
});
|
|
117
100
|
const result = requireRecord(payload, "Unsplash \u641C\u7D22\u54CD\u5E94");
|
|
118
101
|
return {
|
|
119
|
-
total:
|
|
120
|
-
totalPages:
|
|
102
|
+
total: finiteNumber(result.total) ?? 0,
|
|
103
|
+
totalPages: finiteNumber(result.total_pages) ?? 0,
|
|
121
104
|
results: objectArray(result.results)
|
|
122
105
|
};
|
|
123
106
|
}
|
|
@@ -127,7 +110,7 @@ async function getPhoto(input, ctx) {
|
|
|
127
110
|
return { photo: requireRecord(payload, "Unsplash \u7167\u7247\u54CD\u5E94") };
|
|
128
111
|
}
|
|
129
112
|
async function getRandomPhoto(input, ctx) {
|
|
130
|
-
const query =
|
|
113
|
+
const query = trimmedText(input.query);
|
|
131
114
|
const collections = csv(input.collections);
|
|
132
115
|
const topics = csv(input.topics);
|
|
133
116
|
if (query !== void 0 && (collections !== void 0 || topics !== void 0)) {
|
|
@@ -137,7 +120,7 @@ async function getRandomPhoto(input, ctx) {
|
|
|
137
120
|
query,
|
|
138
121
|
collections,
|
|
139
122
|
topics,
|
|
140
|
-
username:
|
|
123
|
+
username: trimmedText(input.username),
|
|
141
124
|
orientation: input.orientation,
|
|
142
125
|
content_filter: input.contentFilter,
|
|
143
126
|
count: input.count
|
|
@@ -1,29 +1,26 @@
|
|
|
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
|
requireCredential,
|
|
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
|
TBError,
|
|
12
16
|
external_exports
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-OKRZPQ3R.js";
|
|
18
|
+
import "./chunk-U67V476Y.js";
|
|
15
19
|
|
|
16
20
|
// ../plugins/src/upstash_redis/api.ts
|
|
17
21
|
var SERVICE = "upstash_redis";
|
|
18
22
|
var HOSTNAME_SUFFIX = ".upstash.io";
|
|
19
|
-
|
|
20
|
-
if (typeof value !== "string") return void 0;
|
|
21
|
-
const trimmed = value.trim();
|
|
22
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
23
|
-
}
|
|
24
|
-
function record(value) {
|
|
25
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
26
|
-
}
|
|
23
|
+
var http = createProviderHttpClient({ service: SERVICE });
|
|
27
24
|
function responseError(message) {
|
|
28
25
|
return new TBError("unavailable", message, { retryable: true });
|
|
29
26
|
}
|
|
@@ -54,15 +51,15 @@ function restUrl(ctx) {
|
|
|
54
51
|
return url;
|
|
55
52
|
}
|
|
56
53
|
function commandError(status, payload, fallbackBody) {
|
|
57
|
-
const body =
|
|
58
|
-
const message =
|
|
54
|
+
const body = asJsonObject(payload);
|
|
55
|
+
const message = trimmedText(body?.error) ?? trimmedText(body?.message) ?? trimmedText(fallbackBody) ?? `Upstash Redis \u8FD4\u56DE HTTP ${status}`;
|
|
59
56
|
if (isQuotaMessage(message)) return upstreamError(429, message);
|
|
60
57
|
return upstreamError(status, message);
|
|
61
58
|
}
|
|
62
59
|
function unwrap(payload) {
|
|
63
|
-
const body =
|
|
60
|
+
const body = asJsonObject(payload);
|
|
64
61
|
if (body === void 0) throw responseError("Upstash Redis \u54CD\u5E94\u4E0D\u662F\u5BF9\u8C61");
|
|
65
|
-
const error =
|
|
62
|
+
const error = trimmedText(body.error);
|
|
66
63
|
if (error !== void 0) {
|
|
67
64
|
if (isQuotaMessage(error)) throw upstreamError(429, error);
|
|
68
65
|
throw new TBError("invalid_argument", error);
|
|
@@ -71,31 +68,22 @@ function unwrap(payload) {
|
|
|
71
68
|
return body.result;
|
|
72
69
|
}
|
|
73
70
|
async function command(ctx, args) {
|
|
74
|
-
const
|
|
71
|
+
const result = await http.request({
|
|
72
|
+
baseUrl: restUrl(ctx),
|
|
73
|
+
path: "/",
|
|
75
74
|
method: "POST",
|
|
76
75
|
headers: {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"content-type": "application/json"
|
|
76
|
+
accept: "application/json",
|
|
77
|
+
authorization: `Bearer ${requireCredential(ctx, SERVICE, "restToken")}`
|
|
80
78
|
},
|
|
81
|
-
|
|
79
|
+
json: args,
|
|
80
|
+
invalidJsonMessage: "Upstash Redis \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
|
|
81
|
+
mapError: ({ data, rawText, status }) => commandError(status, data, rawText ?? "")
|
|
82
82
|
});
|
|
83
|
-
|
|
84
|
-
let payload;
|
|
85
|
-
let parsed = false;
|
|
86
|
-
if (body !== "") {
|
|
87
|
-
try {
|
|
88
|
-
payload = JSON.parse(body);
|
|
89
|
-
parsed = true;
|
|
90
|
-
} catch {
|
|
91
|
-
if (response.ok) throw responseError("Upstash Redis \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94");
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (!response.ok) throw commandError(response.status, parsed ? payload : void 0, body);
|
|
95
|
-
return unwrap(payload);
|
|
83
|
+
return unwrap(result.data);
|
|
96
84
|
}
|
|
97
85
|
function redisKey(value) {
|
|
98
|
-
const key =
|
|
86
|
+
const key = trimmedText(value);
|
|
99
87
|
if (key === void 0) throw new TBError("invalid_argument", "key \u4E0D\u80FD\u662F\u7A7A\u767D");
|
|
100
88
|
return key;
|
|
101
89
|
}
|
|
@@ -158,8 +146,8 @@ async function ttl(input, ctx) {
|
|
|
158
146
|
return { ttlSeconds: integer(result, "TTL") };
|
|
159
147
|
}
|
|
160
148
|
async function scan(input, ctx) {
|
|
161
|
-
const args = ["SCAN",
|
|
162
|
-
const match =
|
|
149
|
+
const args = ["SCAN", trimmedText(input.cursor) ?? "0"];
|
|
150
|
+
const match = trimmedText(input.match);
|
|
163
151
|
if (match !== void 0) args.push("MATCH", match);
|
|
164
152
|
if (input.count !== void 0) args.push("COUNT", input.count);
|
|
165
153
|
const page = scanPage(await command(ctx, args));
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
asJsonObject
|
|
3
|
+
} from "./chunk-JXHMDBAY.js";
|
|
1
4
|
import {
|
|
2
5
|
createProviderPlugin,
|
|
3
6
|
requireApiKey,
|
|
4
7
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-B4P6YZFS.js";
|
|
6
9
|
import {
|
|
7
10
|
guardedFetch
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-GKX72JMJ.js";
|
|
11
|
+
} from "./chunk-SWBNHIO4.js";
|
|
10
12
|
import {
|
|
11
13
|
TBError,
|
|
12
14
|
external_exports
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
+
} from "./chunk-OKRZPQ3R.js";
|
|
16
|
+
import "./chunk-U67V476Y.js";
|
|
15
17
|
|
|
16
18
|
// ../plugins/src/uptimerobot/api.ts
|
|
17
19
|
var SERVICE = "uptimerobot";
|
|
18
20
|
var API_BASE = "https://api.uptimerobot.com/v2/";
|
|
19
|
-
function record(value) {
|
|
20
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
21
|
-
}
|
|
22
21
|
function text(value) {
|
|
23
22
|
return typeof value === "string" && value !== "" ? value : void 0;
|
|
24
23
|
}
|
|
@@ -31,7 +30,7 @@ function integer(value) {
|
|
|
31
30
|
return void 0;
|
|
32
31
|
}
|
|
33
32
|
function toError(status, payload) {
|
|
34
|
-
const error =
|
|
33
|
+
const error = asJsonObject(asJsonObject(payload)?.error);
|
|
35
34
|
const message = text(error?.message) ?? (!status || status === 200 ? "uptimerobot request failed" : `uptimerobot request failed with status ${status}`);
|
|
36
35
|
const type = text(error?.type);
|
|
37
36
|
const httpStatus = status >= 400 ? status : void 0;
|
|
@@ -75,13 +74,13 @@ async function request(ctx, endpoint, body) {
|
|
|
75
74
|
}
|
|
76
75
|
const payload = await readPayload(response);
|
|
77
76
|
if (!response.ok) throw toError(response.status, payload);
|
|
78
|
-
const parsed =
|
|
77
|
+
const parsed = asJsonObject(payload);
|
|
79
78
|
if (parsed === void 0) throw upstreamError(502, "uptimerobot returned an invalid response payload");
|
|
80
79
|
if (parsed.stat !== "ok") throw toError(response.status, parsed);
|
|
81
80
|
return parsed;
|
|
82
81
|
}
|
|
83
82
|
function requireObjectPayload(value, label) {
|
|
84
|
-
const parsed =
|
|
83
|
+
const parsed = asJsonObject(value);
|
|
85
84
|
if (parsed === void 0) throw upstreamError(502, `${label} must be an object`);
|
|
86
85
|
return parsed;
|
|
87
86
|
}
|
|
@@ -172,7 +171,7 @@ async function getMonitor(input, ctx) {
|
|
|
172
171
|
setBoolean(form, "alert_contacts", input.alert_contacts);
|
|
173
172
|
const payload = await request(ctx, "getMonitors", form);
|
|
174
173
|
const monitors = requireArrayPayload(payload.monitors, "uptimerobot single monitor response");
|
|
175
|
-
const monitor =
|
|
174
|
+
const monitor = asJsonObject(monitors[0]);
|
|
176
175
|
if (monitor === void 0) throw upstreamError(404, `monitor ${input.monitor_id} was not found`);
|
|
177
176
|
return { monitor };
|
|
178
177
|
}
|