@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,21 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderHttpClient
|
|
3
|
+
} from "./chunk-WW2IMPQK.js";
|
|
4
|
+
import {
|
|
5
|
+
asJsonObject,
|
|
6
|
+
compactDefined,
|
|
7
|
+
trimmedText
|
|
8
|
+
} from "./chunk-JXHMDBAY.js";
|
|
1
9
|
import {
|
|
2
10
|
createProviderPlugin,
|
|
3
11
|
requireApiKey,
|
|
4
12
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import
|
|
7
|
-
guardedFetch
|
|
8
|
-
} from "./chunk-2O27H4Y2.js";
|
|
9
|
-
import "./chunk-GKX72JMJ.js";
|
|
13
|
+
} from "./chunk-YASUMV2K.js";
|
|
14
|
+
import "./chunk-U5UHT7CX.js";
|
|
10
15
|
import {
|
|
11
16
|
TBError,
|
|
12
17
|
external_exports
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-RVWZN3CI.js";
|
|
19
|
+
import "./chunk-U67V476Y.js";
|
|
15
20
|
|
|
16
21
|
// ../plugins/src/supabase/api.ts
|
|
17
22
|
var SERVICE = "supabase";
|
|
18
23
|
var API_BASE = "https://api.supabase.com/v1";
|
|
24
|
+
var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
|
|
19
25
|
var PROJECT_STATUSES = /* @__PURE__ */ new Set([
|
|
20
26
|
"ACTIVE_HEALTHY",
|
|
21
27
|
"ACTIVE_UNHEALTHY",
|
|
@@ -34,19 +40,8 @@ var PROJECT_STATUSES = /* @__PURE__ */ new Set([
|
|
|
34
40
|
"RESIZING"
|
|
35
41
|
]);
|
|
36
42
|
var API_KEY_TYPES = /* @__PURE__ */ new Set(["legacy", "publishable", "secret", "unknown"]);
|
|
37
|
-
function text(value) {
|
|
38
|
-
if (typeof value !== "string") return void 0;
|
|
39
|
-
const trimmed = value.trim();
|
|
40
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
41
|
-
}
|
|
42
43
|
function nullableText(value) {
|
|
43
|
-
return value === null ? null :
|
|
44
|
-
}
|
|
45
|
-
function record(value) {
|
|
46
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
47
|
-
}
|
|
48
|
-
function compact(input) {
|
|
49
|
-
return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0));
|
|
44
|
+
return value === null ? null : trimmedText(value);
|
|
50
45
|
}
|
|
51
46
|
function inputError(message) {
|
|
52
47
|
return new TBError("invalid_argument", message);
|
|
@@ -55,12 +50,12 @@ function malformed(message) {
|
|
|
55
50
|
return new TBError("unavailable", `malformed supabase response: ${message}`, { retryable: true });
|
|
56
51
|
}
|
|
57
52
|
function requireInputText(value, field) {
|
|
58
|
-
const result =
|
|
53
|
+
const result = trimmedText(value);
|
|
59
54
|
if (result === void 0) throw inputError(`${field} is required.`);
|
|
60
55
|
return result;
|
|
61
56
|
}
|
|
62
57
|
function requireRecord(value, label) {
|
|
63
|
-
const result =
|
|
58
|
+
const result = asJsonObject(value);
|
|
64
59
|
if (result === void 0) throw malformed(`missing ${label}`);
|
|
65
60
|
return result;
|
|
66
61
|
}
|
|
@@ -69,7 +64,7 @@ function requireArray(value, label) {
|
|
|
69
64
|
return value;
|
|
70
65
|
}
|
|
71
66
|
function requireField(value, field) {
|
|
72
|
-
const result =
|
|
67
|
+
const result = trimmedText(value);
|
|
73
68
|
if (result === void 0) throw malformed(`missing ${field}`);
|
|
74
69
|
return result;
|
|
75
70
|
}
|
|
@@ -83,45 +78,31 @@ function requireNumber(value, field) {
|
|
|
83
78
|
return parsed;
|
|
84
79
|
}
|
|
85
80
|
function errorMessage(status, payload) {
|
|
86
|
-
const detail =
|
|
81
|
+
const detail = asJsonObject(payload);
|
|
87
82
|
if (detail === void 0) return `supabase request failed with ${status}`;
|
|
88
|
-
const code =
|
|
83
|
+
const code = trimmedText(detail.code) ?? trimmedText(detail.error);
|
|
89
84
|
if (code === "invalid_grant") return "supabase grant is invalid or expired";
|
|
90
|
-
return
|
|
85
|
+
return trimmedText(detail.message) ?? trimmedText(detail.msg) ?? trimmedText(detail.error_description) ?? `supabase request failed with ${status}`;
|
|
91
86
|
}
|
|
92
87
|
async function request(ctx, input) {
|
|
93
|
-
const url = new URL(`${API_BASE}${input.path}`);
|
|
94
|
-
for (const [key, value] of Object.entries(input.query ?? {})) {
|
|
95
|
-
if (value === void 0) continue;
|
|
96
|
-
if (Array.isArray(value)) {
|
|
97
|
-
for (const item of value) url.searchParams.append(key, item);
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
url.searchParams.set(key, String(value));
|
|
101
|
-
}
|
|
102
88
|
const hasBody = input.body !== void 0;
|
|
103
|
-
const
|
|
89
|
+
const { data } = await http.request({
|
|
90
|
+
path: input.path,
|
|
104
91
|
method: input.method ?? "GET",
|
|
92
|
+
// health 的 services 靠**重复同名参数**表达;statuses 那种逗号串在调用处就拼好了。
|
|
93
|
+
query: Object.entries(input.query ?? {}),
|
|
105
94
|
headers: {
|
|
106
95
|
accept: "application/json",
|
|
107
|
-
authorization: `Bearer ${requireApiKey(ctx, SERVICE)}
|
|
108
|
-
...hasBody ? { "content-type": "application/json" } : {}
|
|
96
|
+
authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
|
|
109
97
|
},
|
|
110
|
-
|
|
98
|
+
...hasBody ? { json: input.body } : {},
|
|
99
|
+
invalidJsonMessage: "malformed supabase response: malformed supabase json response",
|
|
100
|
+
mapError: ({ data: payload2, status }) => upstreamError(
|
|
101
|
+
status,
|
|
102
|
+
errorMessage(status, typeof payload2 === "string" ? { message: payload2 } : payload2)
|
|
103
|
+
)
|
|
111
104
|
});
|
|
112
|
-
const
|
|
113
|
-
let payload;
|
|
114
|
-
if (raw.trim() === "") {
|
|
115
|
-
payload = null;
|
|
116
|
-
} else {
|
|
117
|
-
try {
|
|
118
|
-
payload = JSON.parse(raw);
|
|
119
|
-
} catch {
|
|
120
|
-
if (response.ok) throw malformed("malformed supabase json response");
|
|
121
|
-
payload = { message: raw };
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
if (!response.ok) throw upstreamError(response.status, errorMessage(response.status, payload));
|
|
105
|
+
const payload = data ?? null;
|
|
125
106
|
if (payload === null && input.allowEmpty !== true) throw malformed("empty body");
|
|
126
107
|
return payload;
|
|
127
108
|
}
|
|
@@ -142,35 +123,35 @@ function normalizeOrganization(payload) {
|
|
|
142
123
|
}
|
|
143
124
|
function normalizeOrganizationDetail(payload) {
|
|
144
125
|
const item = requireRecord(payload, "organization");
|
|
145
|
-
return
|
|
126
|
+
return compactDefined({
|
|
146
127
|
...item,
|
|
147
128
|
id: requireField(item.id, "organization.id"),
|
|
148
129
|
name: requireField(item.name, "organization.name"),
|
|
149
|
-
plan:
|
|
130
|
+
plan: trimmedText(item.plan)
|
|
150
131
|
});
|
|
151
132
|
}
|
|
152
133
|
function normalizeOrganizationMember(payload) {
|
|
153
134
|
const item = requireRecord(payload, "member");
|
|
154
|
-
return
|
|
135
|
+
return compactDefined({
|
|
155
136
|
...item,
|
|
156
137
|
userId: requireField(item.user_id, "member.user_id"),
|
|
157
138
|
userName: requireField(item.user_name, "member.user_name"),
|
|
158
|
-
email:
|
|
139
|
+
email: trimmedText(item.email),
|
|
159
140
|
roleName: requireField(item.role_name, "member.role_name"),
|
|
160
141
|
mfaEnabled: requireBoolean(item.mfa_enabled, "member.mfa_enabled")
|
|
161
142
|
});
|
|
162
143
|
}
|
|
163
144
|
function normalizeOrganizationProject(payload) {
|
|
164
145
|
const item = requireRecord(payload, "organization project");
|
|
165
|
-
return
|
|
146
|
+
return compactDefined({
|
|
166
147
|
...item,
|
|
167
148
|
ref: requireField(item.ref, "organizationProject.ref"),
|
|
168
149
|
name: requireField(item.name, "organizationProject.name"),
|
|
169
|
-
cloudProvider:
|
|
150
|
+
cloudProvider: trimmedText(item.cloud_provider),
|
|
170
151
|
region: requireField(item.region, "organizationProject.region"),
|
|
171
152
|
isBranch: typeof item.is_branch === "boolean" ? item.is_branch : void 0,
|
|
172
153
|
status: normalizeProjectStatus(requireField(item.status, "organizationProject.status")) ?? "UNKNOWN",
|
|
173
|
-
insertedAt:
|
|
154
|
+
insertedAt: trimmedText(item.inserted_at),
|
|
174
155
|
databases: Array.isArray(item.databases) ? item.databases.map((entry) => requireRecord(entry, "database")) : void 0
|
|
175
156
|
});
|
|
176
157
|
}
|
|
@@ -185,9 +166,9 @@ function normalizePagination(payload) {
|
|
|
185
166
|
function normalizeProjectDatabaseSummary(payload) {
|
|
186
167
|
if (payload === void 0 || payload === null) return void 0;
|
|
187
168
|
const item = requireRecord(payload, "project.database");
|
|
188
|
-
return
|
|
189
|
-
host:
|
|
190
|
-
version:
|
|
169
|
+
return compactDefined({
|
|
170
|
+
host: trimmedText(item.host),
|
|
171
|
+
version: trimmedText(item.version),
|
|
191
172
|
postgresEngine: nullableText(item.postgres_engine),
|
|
192
173
|
releaseChannel: nullableText(item.release_channel)
|
|
193
174
|
});
|
|
@@ -208,7 +189,7 @@ function normalizeProjectSummary(payload) {
|
|
|
208
189
|
organizationId: requireField(item.organization_id, "project.organization_id"),
|
|
209
190
|
name: requireField(item.name, "project.name"),
|
|
210
191
|
region: requireField(item.region, "project.region"),
|
|
211
|
-
status: normalizeProjectStatus(
|
|
192
|
+
status: normalizeProjectStatus(trimmedText(item.status)),
|
|
212
193
|
createdAt: requireField(item.created_at, "project.created_at"),
|
|
213
194
|
database: normalizeProjectDatabaseSummary(item.database)
|
|
214
195
|
};
|
|
@@ -229,17 +210,17 @@ function normalizeProjectDetail(payload) {
|
|
|
229
210
|
}
|
|
230
211
|
function normalizeApiKey(payload) {
|
|
231
212
|
const item = requireRecord(payload, "api key");
|
|
232
|
-
return
|
|
213
|
+
return compactDefined({
|
|
233
214
|
id: requireField(item.id, "apiKey.id"),
|
|
234
215
|
name: requireField(item.name, "apiKey.name"),
|
|
235
216
|
type: normalizeApiKeyType(requireField(item.type, "apiKey.type")),
|
|
236
217
|
prefix: requireField(item.prefix, "apiKey.prefix"),
|
|
237
218
|
hash: requireField(item.hash, "apiKey.hash"),
|
|
238
219
|
description: nullableText(item.description),
|
|
239
|
-
apiKey:
|
|
240
|
-
insertedAt:
|
|
241
|
-
updatedAt:
|
|
242
|
-
secretJwtTemplate: item.secret_jwt_template === null ? null :
|
|
220
|
+
apiKey: trimmedText(item.api_key),
|
|
221
|
+
insertedAt: trimmedText(item.inserted_at),
|
|
222
|
+
updatedAt: trimmedText(item.updated_at),
|
|
223
|
+
secretJwtTemplate: item.secret_jwt_template === null ? null : asJsonObject(item.secret_jwt_template)
|
|
243
224
|
});
|
|
244
225
|
}
|
|
245
226
|
function normalizeApiKeyList(payload) {
|
|
@@ -250,21 +231,21 @@ function normalizeApiKeyList(payload) {
|
|
|
250
231
|
}
|
|
251
232
|
function normalizeSecret(payload) {
|
|
252
233
|
const item = requireRecord(payload, "secret");
|
|
253
|
-
return
|
|
234
|
+
return compactDefined({
|
|
254
235
|
name: requireField(item.name, "secret.name"),
|
|
255
|
-
value:
|
|
256
|
-
updatedAt:
|
|
236
|
+
value: trimmedText(item.value),
|
|
237
|
+
updatedAt: trimmedText(item.updated_at)
|
|
257
238
|
});
|
|
258
239
|
}
|
|
259
240
|
function normalizeHealthService(payload) {
|
|
260
241
|
const item = requireRecord(payload, "health");
|
|
261
|
-
return
|
|
242
|
+
return compactDefined({
|
|
262
243
|
...item,
|
|
263
244
|
name: requireField(item.name, "health.name"),
|
|
264
245
|
healthy: requireBoolean(item.healthy, "health.healthy"),
|
|
265
246
|
status: requireField(item.status, "health.status"),
|
|
266
|
-
error:
|
|
267
|
-
info: item.info === null ? null :
|
|
247
|
+
error: trimmedText(item.error),
|
|
248
|
+
info: item.info === null ? null : asJsonObject(item.info)
|
|
268
249
|
});
|
|
269
250
|
}
|
|
270
251
|
function normalizeRecordList(payload, label) {
|
|
@@ -273,7 +254,7 @@ function normalizeRecordList(payload, label) {
|
|
|
273
254
|
function secretInputList(payload) {
|
|
274
255
|
if (!Array.isArray(payload)) throw inputError("supabase secrets input must be an array");
|
|
275
256
|
return payload.map((entry) => {
|
|
276
|
-
const item =
|
|
257
|
+
const item = asJsonObject(entry);
|
|
277
258
|
if (item === void 0) throw inputError("secret is required.");
|
|
278
259
|
return {
|
|
279
260
|
name: requireInputText(item.name, "secret.name"),
|
|
@@ -309,8 +290,8 @@ async function listOrganizationProjects(input, ctx) {
|
|
|
309
290
|
query: {
|
|
310
291
|
offset: input.offset,
|
|
311
292
|
limit: input.limit,
|
|
312
|
-
search:
|
|
313
|
-
sort:
|
|
293
|
+
search: trimmedText(input.search),
|
|
294
|
+
sort: trimmedText(input.sort),
|
|
314
295
|
// statuses 是**逗号串**(不像 services 那样重复同名参数)。
|
|
315
296
|
statuses: input.statuses === void 0 ? void 0 : input.statuses.join(",")
|
|
316
297
|
}
|
|
@@ -333,9 +314,9 @@ async function listAvailableRegions(input, ctx) {
|
|
|
333
314
|
const payload = await request(ctx, {
|
|
334
315
|
path: "/projects/available-regions",
|
|
335
316
|
query: {
|
|
336
|
-
organization_slug:
|
|
337
|
-
continent:
|
|
338
|
-
desired_instance_size:
|
|
317
|
+
organization_slug: trimmedText(input.organizationSlug),
|
|
318
|
+
continent: trimmedText(input.continent),
|
|
319
|
+
desired_instance_size: trimmedText(input.desiredInstanceSize)
|
|
339
320
|
}
|
|
340
321
|
});
|
|
341
322
|
return { regions: requireRecord(payload, "regions") };
|
|
@@ -373,7 +354,7 @@ async function getProjectApiKey(input, ctx) {
|
|
|
373
354
|
}
|
|
374
355
|
async function createProjectApiKey(input, ctx) {
|
|
375
356
|
const ref = requireInputText(input.projectRef, "projectRef");
|
|
376
|
-
const type =
|
|
357
|
+
const type = trimmedText(input.type);
|
|
377
358
|
if (input.secretJwtTemplate !== void 0 && type !== "secret") {
|
|
378
359
|
throw inputError("secretJwtTemplate is only supported for secret API keys");
|
|
379
360
|
}
|
|
@@ -381,12 +362,12 @@ async function createProjectApiKey(input, ctx) {
|
|
|
381
362
|
method: "POST",
|
|
382
363
|
path: `/projects/${encodeURIComponent(ref)}/api-keys`,
|
|
383
364
|
query: { reveal: revealFlag(input.reveal) },
|
|
384
|
-
body:
|
|
385
|
-
name:
|
|
365
|
+
body: compactDefined({
|
|
366
|
+
name: trimmedText(input.name),
|
|
386
367
|
type,
|
|
387
368
|
// description 不去空白:上游用 optionalRawString 原样发(空串是合法的"没有描述")。
|
|
388
369
|
description: typeof input.description === "string" ? input.description : void 0,
|
|
389
|
-
secret_jwt_template:
|
|
370
|
+
secret_jwt_template: asJsonObject(input.secretJwtTemplate)
|
|
390
371
|
})
|
|
391
372
|
});
|
|
392
373
|
return { apiKey: normalizeApiKey(payload) };
|
|
@@ -402,10 +383,10 @@ async function updateProjectApiKey(input, ctx) {
|
|
|
402
383
|
path: `/projects/${encodeURIComponent(ref)}/api-keys/${encodeURIComponent(apiKeyId)}`,
|
|
403
384
|
query: { reveal: revealFlag(input.reveal) },
|
|
404
385
|
// description 与 secret_jwt_template 是三态字段:未给不改、null 清空、有值改成它。
|
|
405
|
-
body:
|
|
406
|
-
name:
|
|
386
|
+
body: compactDefined({
|
|
387
|
+
name: trimmedText(input.name),
|
|
407
388
|
description: typeof input.description === "string" || input.description === null ? input.description : void 0,
|
|
408
|
-
secret_jwt_template: input.secretJwtTemplate === null ? null :
|
|
389
|
+
secret_jwt_template: input.secretJwtTemplate === null ? null : asJsonObject(input.secretJwtTemplate)
|
|
409
390
|
})
|
|
410
391
|
});
|
|
411
392
|
return { apiKey: normalizeApiKey(payload) };
|
|
@@ -419,7 +400,7 @@ async function deleteProjectApiKey(input, ctx) {
|
|
|
419
400
|
query: {
|
|
420
401
|
reveal: revealFlag(input.reveal),
|
|
421
402
|
was_compromised: input.wasCompromised,
|
|
422
|
-
reason:
|
|
403
|
+
reason: trimmedText(input.reason)
|
|
423
404
|
}
|
|
424
405
|
});
|
|
425
406
|
return { apiKey: normalizeApiKey(payload) };
|
|
@@ -470,7 +451,7 @@ async function runReadOnlyQuery(input, ctx) {
|
|
|
470
451
|
const result = await request(ctx, {
|
|
471
452
|
method: "POST",
|
|
472
453
|
path: `/projects/${encodeURIComponent(ref)}/database/query/read-only`,
|
|
473
|
-
body:
|
|
454
|
+
body: compactDefined({
|
|
474
455
|
// SQL 不去空白:缩进与换行是语义的一部分(上游 optionalRawString)。
|
|
475
456
|
query: typeof input.query === "string" ? input.query : void 0,
|
|
476
457
|
parameters: Array.isArray(input.parameters) ? input.parameters : void 0
|
|
@@ -1,92 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderHttpClient
|
|
3
|
+
} from "./chunk-WW2IMPQK.js";
|
|
4
|
+
import {
|
|
5
|
+
asJsonObject,
|
|
6
|
+
messageFrom
|
|
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
|
-
TBError,
|
|
12
15
|
external_exports
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
16
|
+
} from "./chunk-RVWZN3CI.js";
|
|
17
|
+
import "./chunk-U67V476Y.js";
|
|
15
18
|
|
|
16
19
|
// ../plugins/src/tavily/api.ts
|
|
17
20
|
var SERVICE = "tavily";
|
|
18
|
-
var API_BASE = "https://api.tavily.com";
|
|
19
21
|
var REQUEST_TIMEOUT_MS = 3e4;
|
|
20
|
-
|
|
21
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
22
|
-
}
|
|
23
|
-
function text(value) {
|
|
24
|
-
if (typeof value !== "string") return void 0;
|
|
25
|
-
const trimmed = value.trim();
|
|
26
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
27
|
-
}
|
|
28
|
-
function errorMessage(payload, status) {
|
|
29
|
-
if (typeof payload === "string" && payload.trim() !== "") return payload;
|
|
30
|
-
const body = record(payload);
|
|
31
|
-
return text(body?.detail) ?? text(body?.error) ?? text(body?.message) ?? `Tavily \u8FD4\u56DE HTTP ${status}`;
|
|
32
|
-
}
|
|
22
|
+
var http = createProviderHttpClient({ baseUrl: "https://api.tavily.com/", service: SERVICE });
|
|
33
23
|
async function request(ctx, options) {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
throw upstreamError(502, error instanceof Error ? `Tavily \u8BF7\u6C42\u5931\u8D25:${error.message}` : "Tavily \u8BF7\u6C42\u5931\u8D25");
|
|
53
|
-
}
|
|
54
|
-
const raw = await response.text().catch(() => "");
|
|
55
|
-
let payload = null;
|
|
56
|
-
if (raw !== "") {
|
|
57
|
-
try {
|
|
58
|
-
payload = JSON.parse(raw);
|
|
59
|
-
} catch {
|
|
60
|
-
if (response.ok) throw upstreamError(502, "Tavily \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94");
|
|
61
|
-
payload = raw;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (!response.ok) throw upstreamError(response.status, errorMessage(payload, response.status));
|
|
65
|
-
if (raw === "") return {};
|
|
66
|
-
const result = record(payload);
|
|
24
|
+
const { data } = await http.request({
|
|
25
|
+
path: options.path,
|
|
26
|
+
method: options.method,
|
|
27
|
+
headers: {
|
|
28
|
+
accept: "application/json",
|
|
29
|
+
authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
|
|
30
|
+
},
|
|
31
|
+
...options.body === void 0 ? {} : { json: options.body },
|
|
32
|
+
timeoutMs: REQUEST_TIMEOUT_MS,
|
|
33
|
+
invalidJsonMessage: "Tavily \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
|
|
34
|
+
mapError: ({ data: payload, status }) => upstreamError(
|
|
35
|
+
status,
|
|
36
|
+
messageFrom(payload, ["detail", "error", "message"], `Tavily \u8FD4\u56DE HTTP ${status}`)
|
|
37
|
+
),
|
|
38
|
+
mapTransportError: ({ kind, message }) => kind === "timeout" ? upstreamError(504, `Tavily ${REQUEST_TIMEOUT_MS / 1e3}s \u5185\u6CA1\u6709\u8FD4\u56DE`) : upstreamError(502, message === void 0 ? "Tavily \u8BF7\u6C42\u5931\u8D25" : `Tavily \u8BF7\u6C42\u5931\u8D25:${message}`)
|
|
39
|
+
});
|
|
40
|
+
if (data === void 0) return {};
|
|
41
|
+
const result = asJsonObject(data);
|
|
67
42
|
if (result === void 0) throw upstreamError(502, "Tavily \u54CD\u5E94\u4E0D\u662F\u5BF9\u8C61");
|
|
68
43
|
return result;
|
|
69
44
|
}
|
|
70
45
|
function search(input, ctx) {
|
|
71
|
-
return request(ctx, { method: "POST", path: "
|
|
46
|
+
return request(ctx, { method: "POST", path: "search", body: input });
|
|
72
47
|
}
|
|
73
48
|
function extract(input, ctx) {
|
|
74
|
-
return request(ctx, { method: "POST", path: "
|
|
49
|
+
return request(ctx, { method: "POST", path: "extract", body: input });
|
|
75
50
|
}
|
|
76
51
|
function map(input, ctx) {
|
|
77
|
-
return request(ctx, { method: "POST", path: "
|
|
52
|
+
return request(ctx, { method: "POST", path: "map", body: input });
|
|
78
53
|
}
|
|
79
54
|
function crawl(input, ctx) {
|
|
80
|
-
return request(ctx, { method: "POST", path: "
|
|
55
|
+
return request(ctx, { method: "POST", path: "crawl", body: input });
|
|
81
56
|
}
|
|
82
57
|
function createResearch(input, ctx) {
|
|
83
|
-
return request(ctx, { method: "POST", path: "
|
|
58
|
+
return request(ctx, { method: "POST", path: "research", body: input });
|
|
84
59
|
}
|
|
85
60
|
function getResearch(input, ctx) {
|
|
86
|
-
return request(ctx, { method: "GET", path:
|
|
61
|
+
return request(ctx, { method: "GET", path: `research/${encodeURIComponent(input.request_id)}` });
|
|
87
62
|
}
|
|
88
63
|
function getUsage(_input, ctx) {
|
|
89
|
-
return request(ctx, { method: "GET", path: "
|
|
64
|
+
return request(ctx, { method: "GET", path: "usage" });
|
|
90
65
|
}
|
|
91
66
|
|
|
92
67
|
// ../plugins/src/tavily/schema.ts
|