@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,364 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderPlugin,
|
|
3
|
+
guardedFetch,
|
|
4
|
+
requireApiKey,
|
|
5
|
+
upstreamError
|
|
6
|
+
} from "./chunk-CSJEZHQO.js";
|
|
7
|
+
import "./chunk-K7FVSFUX.js";
|
|
8
|
+
import {
|
|
9
|
+
TBError,
|
|
10
|
+
external_exports
|
|
11
|
+
} from "./chunk-JLTYA2B3.js";
|
|
12
|
+
import "./chunk-MLKGABMK.js";
|
|
13
|
+
|
|
14
|
+
// ../plugins/src/unsplash/api.ts
|
|
15
|
+
var SERVICE = "unsplash";
|
|
16
|
+
var API_BASE = "https://api.unsplash.com";
|
|
17
|
+
function text(value) {
|
|
18
|
+
if (typeof value !== "string") return void 0;
|
|
19
|
+
const trimmed = value.trim();
|
|
20
|
+
return trimmed === "" ? void 0 : trimmed;
|
|
21
|
+
}
|
|
22
|
+
function record(value) {
|
|
23
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
24
|
+
}
|
|
25
|
+
function numeric(value) {
|
|
26
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
27
|
+
}
|
|
28
|
+
function requireRecord(value, label) {
|
|
29
|
+
const result = record(value);
|
|
30
|
+
if (result === void 0) {
|
|
31
|
+
throw new TBError("unavailable", `${label}\u4E0D\u662F\u5BF9\u8C61`, { retryable: true });
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
function objectArray(value) {
|
|
36
|
+
if (!Array.isArray(value)) {
|
|
37
|
+
throw new TBError("unavailable", "Unsplash \u54CD\u5E94\u4E0D\u662F\u6570\u7EC4", { retryable: true });
|
|
38
|
+
}
|
|
39
|
+
return value.map((item) => requireRecord(item, "Unsplash \u6570\u7EC4\u5143\u7D20"));
|
|
40
|
+
}
|
|
41
|
+
function requireText(value, field) {
|
|
42
|
+
const result = text(value);
|
|
43
|
+
if (result === void 0) throw new TBError("invalid_argument", `${field} \u4E0D\u80FD\u662F\u7A7A\u767D`);
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
function csv(value) {
|
|
47
|
+
if (value === void 0) return void 0;
|
|
48
|
+
const items = value.map((item) => text(item)).filter((item) => item !== void 0);
|
|
49
|
+
return items.length > 0 ? items.join(",") : void 0;
|
|
50
|
+
}
|
|
51
|
+
function buildUrl(path, query) {
|
|
52
|
+
const url = new URL(`${API_BASE}${path}`);
|
|
53
|
+
for (const [key, value] of Object.entries(query)) {
|
|
54
|
+
if (value !== void 0) url.searchParams.set(key, String(value));
|
|
55
|
+
}
|
|
56
|
+
return url.toString();
|
|
57
|
+
}
|
|
58
|
+
function errorMessage(payload) {
|
|
59
|
+
const body = record(payload);
|
|
60
|
+
if (body === void 0) return void 0;
|
|
61
|
+
if (Array.isArray(body.errors)) {
|
|
62
|
+
for (const item of body.errors) {
|
|
63
|
+
const message = text(item);
|
|
64
|
+
if (message !== void 0) return message;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return text(body.error) ?? text(body.message);
|
|
68
|
+
}
|
|
69
|
+
async function request(ctx, path, query = {}) {
|
|
70
|
+
const response = await guardedFetch(buildUrl(path, query), {
|
|
71
|
+
method: "GET",
|
|
72
|
+
headers: {
|
|
73
|
+
"accept": "application/json",
|
|
74
|
+
// Unsplash 自有的方案名,不是 Bearer。
|
|
75
|
+
"authorization": `Client-ID ${requireApiKey(ctx, SERVICE)}`,
|
|
76
|
+
"accept-version": "v1"
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
const body = await response.text();
|
|
80
|
+
let payload = null;
|
|
81
|
+
if (body !== "") {
|
|
82
|
+
try {
|
|
83
|
+
payload = JSON.parse(body);
|
|
84
|
+
} catch {
|
|
85
|
+
if (response.ok) {
|
|
86
|
+
throw new TBError("unavailable", "Unsplash \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94", { retryable: true });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (!response.ok) {
|
|
91
|
+
throw upstreamError(response.status, errorMessage(payload) ?? `Unsplash \u8FD4\u56DE HTTP ${response.status}`);
|
|
92
|
+
}
|
|
93
|
+
return payload;
|
|
94
|
+
}
|
|
95
|
+
async function listPhotos(input, ctx) {
|
|
96
|
+
const payload = await request(ctx, "/photos", {
|
|
97
|
+
page: input.page,
|
|
98
|
+
per_page: input.perPage,
|
|
99
|
+
order_by: input.orderBy
|
|
100
|
+
});
|
|
101
|
+
return { photos: objectArray(payload) };
|
|
102
|
+
}
|
|
103
|
+
async function searchPhotos(input, ctx) {
|
|
104
|
+
const payload = await request(ctx, "/search/photos", {
|
|
105
|
+
// 参数名是 `query`,不是各家搜索 API 常见的 `q`。
|
|
106
|
+
query: requireText(input.query, "query"),
|
|
107
|
+
page: input.page,
|
|
108
|
+
per_page: input.perPage,
|
|
109
|
+
order_by: input.orderBy,
|
|
110
|
+
color: input.color,
|
|
111
|
+
orientation: input.orientation,
|
|
112
|
+
content_filter: input.contentFilter,
|
|
113
|
+
collections: csv(input.collections)
|
|
114
|
+
});
|
|
115
|
+
const result = requireRecord(payload, "Unsplash \u641C\u7D22\u54CD\u5E94");
|
|
116
|
+
return {
|
|
117
|
+
total: numeric(result.total) ?? 0,
|
|
118
|
+
totalPages: numeric(result.total_pages) ?? 0,
|
|
119
|
+
results: objectArray(result.results)
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
async function getPhoto(input, ctx) {
|
|
123
|
+
const id = requireText(input.id, "id");
|
|
124
|
+
const payload = await request(ctx, `/photos/${encodeURIComponent(id)}`);
|
|
125
|
+
return { photo: requireRecord(payload, "Unsplash \u7167\u7247\u54CD\u5E94") };
|
|
126
|
+
}
|
|
127
|
+
async function getRandomPhoto(input, ctx) {
|
|
128
|
+
const query = text(input.query);
|
|
129
|
+
const collections = csv(input.collections);
|
|
130
|
+
const topics = csv(input.topics);
|
|
131
|
+
if (query !== void 0 && (collections !== void 0 || topics !== void 0)) {
|
|
132
|
+
throw new TBError("invalid_argument", "get_random_photo \u7684 query \u4E0D\u80FD\u4E0E collections \u6216 topics \u540C\u65F6\u4F7F\u7528");
|
|
133
|
+
}
|
|
134
|
+
const payload = await request(ctx, "/photos/random", {
|
|
135
|
+
query,
|
|
136
|
+
collections,
|
|
137
|
+
topics,
|
|
138
|
+
username: text(input.username),
|
|
139
|
+
orientation: input.orientation,
|
|
140
|
+
content_filter: input.contentFilter,
|
|
141
|
+
count: input.count
|
|
142
|
+
});
|
|
143
|
+
return {
|
|
144
|
+
photos: Array.isArray(payload) ? objectArray(payload) : [requireRecord(payload, "Unsplash \u968F\u673A\u7167\u7247\u54CD\u5E94")]
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
async function listTopics(input, ctx) {
|
|
148
|
+
const payload = await request(ctx, "/topics", {
|
|
149
|
+
page: input.page,
|
|
150
|
+
per_page: input.perPage,
|
|
151
|
+
order_by: input.orderBy
|
|
152
|
+
});
|
|
153
|
+
return { topics: objectArray(payload) };
|
|
154
|
+
}
|
|
155
|
+
async function getTopicPhotos(input, ctx) {
|
|
156
|
+
const topic = requireText(input.topicIdOrSlug, "topicIdOrSlug");
|
|
157
|
+
const payload = await request(ctx, `/topics/${encodeURIComponent(topic)}/photos`, {
|
|
158
|
+
page: input.page,
|
|
159
|
+
per_page: input.perPage,
|
|
160
|
+
orientation: input.orientation,
|
|
161
|
+
order_by: input.orderBy
|
|
162
|
+
});
|
|
163
|
+
return { photos: objectArray(payload) };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// ../plugins/src/unsplash/schema.ts
|
|
167
|
+
var listPhotosInput = external_exports.strictObject({
|
|
168
|
+
page: external_exports.int().min(1).describe("The 1-based page number to retrieve.").optional(),
|
|
169
|
+
perPage: external_exports.int().min(1).max(30).describe("The number of items to return per page, between 1 and 30.").optional(),
|
|
170
|
+
orderBy: external_exports.enum(["latest", "oldest", "popular"]).describe("The sort order supported by the Unsplash photo listing endpoints.").optional()
|
|
171
|
+
}).describe("The input payload for listing the latest public photos from Unsplash.");
|
|
172
|
+
var listPhotosOutput = external_exports.strictObject({
|
|
173
|
+
photos: external_exports.array(external_exports.strictObject({
|
|
174
|
+
id: external_exports.string().describe("The unique identifier of the photo."),
|
|
175
|
+
slug: external_exports.string().describe("The public slug of the photo.").optional(),
|
|
176
|
+
description: external_exports.string().describe("The description of the photo when Unsplash provides it.").nullable().optional(),
|
|
177
|
+
alt_description: external_exports.string().describe("The alternative description of the photo when Unsplash provides it.").nullable().optional(),
|
|
178
|
+
width: external_exports.number().describe("The width of the photo in pixels.").optional(),
|
|
179
|
+
height: external_exports.number().describe("The height of the photo in pixels.").optional(),
|
|
180
|
+
color: external_exports.string().describe("The representative HEX color of the photo.").optional(),
|
|
181
|
+
blur_hash: external_exports.string().describe("The blur hash value of the photo.").optional(),
|
|
182
|
+
urls: external_exports.looseObject({}).describe("The photo URLs returned by Unsplash in multiple sizes.").optional(),
|
|
183
|
+
links: external_exports.looseObject({}).describe("The related links attached to the Unsplash photo resource.").optional(),
|
|
184
|
+
user: external_exports.looseObject({}).describe("The user metadata attached to the photo.").optional()
|
|
185
|
+
}).describe("A summary photo resource returned by Unsplash.")).describe("The public photo summaries returned by Unsplash.")
|
|
186
|
+
}).describe("The latest public photos returned by Unsplash.");
|
|
187
|
+
var searchPhotosInput = external_exports.strictObject({
|
|
188
|
+
query: external_exports.string().min(1).describe("The search query to run against Unsplash photos."),
|
|
189
|
+
page: external_exports.int().min(1).describe("The 1-based page number to retrieve.").optional(),
|
|
190
|
+
perPage: external_exports.int().min(1).max(30).describe("The number of items to return per page, between 1 and 30.").optional(),
|
|
191
|
+
orderBy: external_exports.enum(["relevant", "latest"]).describe("The sort order supported by the Unsplash photo search endpoint.").optional(),
|
|
192
|
+
color: external_exports.enum(["black_and_white", "black", "white", "yellow", "orange", "red", "purple", "magenta", "green", "teal", "blue"]).describe("The color filter to apply to photo search results.").optional(),
|
|
193
|
+
orientation: external_exports.enum(["landscape", "portrait", "squarish"]).describe("The photo orientation filter to apply.").optional(),
|
|
194
|
+
contentFilter: external_exports.enum(["low", "high"]).describe("The safety filter level to apply to supported Unsplash requests.").optional(),
|
|
195
|
+
collections: external_exports.array(external_exports.string().min(1).describe("One identifier value.")).min(1).describe("The collection identifiers to filter the search results by.").optional()
|
|
196
|
+
}).describe("The input payload for searching photos on Unsplash.");
|
|
197
|
+
var searchPhotosOutput = external_exports.strictObject({
|
|
198
|
+
total: external_exports.number().describe("The total number of matching photo results."),
|
|
199
|
+
totalPages: external_exports.number().describe("The total number of result pages."),
|
|
200
|
+
results: external_exports.array(external_exports.strictObject({
|
|
201
|
+
id: external_exports.string().describe("The unique identifier of the photo."),
|
|
202
|
+
slug: external_exports.string().describe("The public slug of the photo.").optional(),
|
|
203
|
+
description: external_exports.string().describe("The description of the photo when Unsplash provides it.").nullable().optional(),
|
|
204
|
+
alt_description: external_exports.string().describe("The alternative description of the photo when Unsplash provides it.").nullable().optional(),
|
|
205
|
+
width: external_exports.number().describe("The width of the photo in pixels.").optional(),
|
|
206
|
+
height: external_exports.number().describe("The height of the photo in pixels.").optional(),
|
|
207
|
+
color: external_exports.string().describe("The representative HEX color of the photo.").optional(),
|
|
208
|
+
blur_hash: external_exports.string().describe("The blur hash value of the photo.").optional(),
|
|
209
|
+
urls: external_exports.looseObject({}).describe("The photo URLs returned by Unsplash in multiple sizes.").optional(),
|
|
210
|
+
links: external_exports.looseObject({}).describe("The related links attached to the Unsplash photo resource.").optional(),
|
|
211
|
+
user: external_exports.looseObject({}).describe("The user metadata attached to the photo.").optional()
|
|
212
|
+
}).describe("A summary photo resource returned by Unsplash.")).describe("The matching photo summaries returned by Unsplash.")
|
|
213
|
+
}).describe("The photo search results returned by Unsplash.");
|
|
214
|
+
var getPhotoInput = external_exports.strictObject({
|
|
215
|
+
id: external_exports.string().min(1).describe("The Unsplash photo identifier to retrieve.")
|
|
216
|
+
}).describe("The input payload for fetching a single Unsplash photo.");
|
|
217
|
+
var getPhotoOutput = external_exports.strictObject({
|
|
218
|
+
photo: external_exports.strictObject({
|
|
219
|
+
id: external_exports.string().describe("The unique identifier of the photo."),
|
|
220
|
+
slug: external_exports.string().describe("The public slug of the photo.").optional(),
|
|
221
|
+
description: external_exports.string().describe("The description of the photo when Unsplash provides it.").nullable().optional(),
|
|
222
|
+
alt_description: external_exports.string().describe("The alternative description of the photo when Unsplash provides it.").nullable().optional(),
|
|
223
|
+
width: external_exports.number().describe("The width of the photo in pixels.").optional(),
|
|
224
|
+
height: external_exports.number().describe("The height of the photo in pixels.").optional(),
|
|
225
|
+
color: external_exports.string().describe("The representative HEX color of the photo.").optional(),
|
|
226
|
+
blur_hash: external_exports.string().describe("The blur hash value of the photo.").optional(),
|
|
227
|
+
urls: external_exports.looseObject({}).describe("The photo URLs returned by Unsplash in multiple sizes.").optional(),
|
|
228
|
+
links: external_exports.looseObject({}).describe("The related links attached to the Unsplash photo resource.").optional(),
|
|
229
|
+
user: external_exports.looseObject({}).describe("The user metadata attached to the photo.").optional(),
|
|
230
|
+
created_at: external_exports.string().describe("The creation timestamp of the photo.").optional(),
|
|
231
|
+
liked_by_user: external_exports.boolean().describe("Whether the authenticated user liked the photo.").optional(),
|
|
232
|
+
likes: external_exports.number().describe("The total number of likes on the photo.").optional(),
|
|
233
|
+
current_user_collections: external_exports.array(external_exports.looseObject({}).describe("One current user collection reference.")).describe("The current user collections returned with the photo.").optional()
|
|
234
|
+
}).describe("A detailed photo resource returned by Unsplash.")
|
|
235
|
+
}).describe("The detailed photo payload returned by Unsplash.");
|
|
236
|
+
var getRandomPhotoInput = external_exports.strictObject({
|
|
237
|
+
query: external_exports.string().min(1).describe("The search query used to constrain the random photo.").optional(),
|
|
238
|
+
collections: external_exports.array(external_exports.string().min(1).describe("One identifier value.")).min(1).describe("The collection identifiers used to constrain the random photo.").optional(),
|
|
239
|
+
topics: external_exports.array(external_exports.string().min(1).describe("One identifier value.")).min(1).describe("The topic identifiers used to constrain the random photo.").optional(),
|
|
240
|
+
username: external_exports.string().min(1).describe("The username used to constrain the random photo.").optional(),
|
|
241
|
+
orientation: external_exports.enum(["landscape", "portrait", "squarish"]).describe("The photo orientation filter to apply.").optional(),
|
|
242
|
+
contentFilter: external_exports.enum(["low", "high"]).describe("The safety filter level to apply to supported Unsplash requests.").optional(),
|
|
243
|
+
count: external_exports.int().min(1).max(30).describe("The number of random photos to request, between 1 and 30.").optional()
|
|
244
|
+
}).describe("The input payload for fetching one or more random Unsplash photos.");
|
|
245
|
+
var getRandomPhotoOutput = external_exports.strictObject({
|
|
246
|
+
photos: external_exports.array(external_exports.strictObject({
|
|
247
|
+
id: external_exports.string().describe("The unique identifier of the photo."),
|
|
248
|
+
slug: external_exports.string().describe("The public slug of the photo.").optional(),
|
|
249
|
+
description: external_exports.string().describe("The description of the photo when Unsplash provides it.").nullable().optional(),
|
|
250
|
+
alt_description: external_exports.string().describe("The alternative description of the photo when Unsplash provides it.").nullable().optional(),
|
|
251
|
+
width: external_exports.number().describe("The width of the photo in pixels.").optional(),
|
|
252
|
+
height: external_exports.number().describe("The height of the photo in pixels.").optional(),
|
|
253
|
+
color: external_exports.string().describe("The representative HEX color of the photo.").optional(),
|
|
254
|
+
blur_hash: external_exports.string().describe("The blur hash value of the photo.").optional(),
|
|
255
|
+
urls: external_exports.looseObject({}).describe("The photo URLs returned by Unsplash in multiple sizes.").optional(),
|
|
256
|
+
links: external_exports.looseObject({}).describe("The related links attached to the Unsplash photo resource.").optional(),
|
|
257
|
+
user: external_exports.looseObject({}).describe("The user metadata attached to the photo.").optional(),
|
|
258
|
+
created_at: external_exports.string().describe("The creation timestamp of the photo.").optional(),
|
|
259
|
+
liked_by_user: external_exports.boolean().describe("Whether the authenticated user liked the photo.").optional(),
|
|
260
|
+
likes: external_exports.number().describe("The total number of likes on the photo.").optional(),
|
|
261
|
+
current_user_collections: external_exports.array(external_exports.looseObject({}).describe("One current user collection reference.")).describe("The current user collections returned with the photo.").optional()
|
|
262
|
+
}).describe("A detailed photo resource returned by Unsplash.")).describe("The random photo resources returned by Unsplash.")
|
|
263
|
+
}).describe("The normalized random photo payload returned by Unsplash.");
|
|
264
|
+
var listTopicsInput = external_exports.strictObject({
|
|
265
|
+
page: external_exports.int().min(1).describe("The 1-based page number to retrieve.").optional(),
|
|
266
|
+
perPage: external_exports.int().min(1).max(30).describe("The number of items to return per page, between 1 and 30.").optional(),
|
|
267
|
+
orderBy: external_exports.enum(["position", "latest", "oldest", "popular"]).describe("The sort order supported by the Unsplash topic listing endpoint.").optional()
|
|
268
|
+
}).describe("The input payload for listing Unsplash topics.");
|
|
269
|
+
var listTopicsOutput = external_exports.strictObject({
|
|
270
|
+
topics: external_exports.array(external_exports.strictObject({
|
|
271
|
+
id: external_exports.string().describe("The unique identifier of the topic."),
|
|
272
|
+
slug: external_exports.string().describe("The topic slug.").optional(),
|
|
273
|
+
title: external_exports.string().describe("The display title of the topic."),
|
|
274
|
+
description: external_exports.string().describe("The description of the topic when Unsplash provides it.").nullable().optional(),
|
|
275
|
+
featured: external_exports.boolean().describe("Whether the topic is marked as featured.").optional(),
|
|
276
|
+
total_photos: external_exports.number().describe("The total number of photos in the topic.").optional(),
|
|
277
|
+
links: external_exports.looseObject({}).describe("The related links attached to the Unsplash topic resource.").optional(),
|
|
278
|
+
cover_photo: external_exports.looseObject({}).describe("The cover photo attached to the topic when Unsplash provides it.").optional()
|
|
279
|
+
}).describe("A topic resource returned by Unsplash.")).describe("The topics returned by Unsplash.")
|
|
280
|
+
}).describe("The topic listing returned by Unsplash.");
|
|
281
|
+
var getTopicPhotosInput = external_exports.strictObject({
|
|
282
|
+
topicIdOrSlug: external_exports.string().min(1).describe("The topic identifier or slug to read photos from."),
|
|
283
|
+
page: external_exports.int().min(1).describe("The 1-based page number to retrieve.").optional(),
|
|
284
|
+
perPage: external_exports.int().min(1).max(30).describe("The number of items to return per page, between 1 and 30.").optional(),
|
|
285
|
+
orientation: external_exports.enum(["landscape", "portrait", "squarish"]).describe("The photo orientation filter to apply.").optional(),
|
|
286
|
+
orderBy: external_exports.enum(["latest", "oldest", "popular"]).describe("The sort order supported by the Unsplash photo listing endpoints.").optional()
|
|
287
|
+
}).describe("The input payload for listing photos from an Unsplash topic.");
|
|
288
|
+
var getTopicPhotosOutput = external_exports.strictObject({
|
|
289
|
+
photos: external_exports.array(external_exports.strictObject({
|
|
290
|
+
id: external_exports.string().describe("The unique identifier of the photo."),
|
|
291
|
+
slug: external_exports.string().describe("The public slug of the photo.").optional(),
|
|
292
|
+
description: external_exports.string().describe("The description of the photo when Unsplash provides it.").nullable().optional(),
|
|
293
|
+
alt_description: external_exports.string().describe("The alternative description of the photo when Unsplash provides it.").nullable().optional(),
|
|
294
|
+
width: external_exports.number().describe("The width of the photo in pixels.").optional(),
|
|
295
|
+
height: external_exports.number().describe("The height of the photo in pixels.").optional(),
|
|
296
|
+
color: external_exports.string().describe("The representative HEX color of the photo.").optional(),
|
|
297
|
+
blur_hash: external_exports.string().describe("The blur hash value of the photo.").optional(),
|
|
298
|
+
urls: external_exports.looseObject({}).describe("The photo URLs returned by Unsplash in multiple sizes.").optional(),
|
|
299
|
+
links: external_exports.looseObject({}).describe("The related links attached to the Unsplash photo resource.").optional(),
|
|
300
|
+
user: external_exports.looseObject({}).describe("The user metadata attached to the photo.").optional()
|
|
301
|
+
}).describe("A summary photo resource returned by Unsplash.")).describe("The photo summaries returned for the requested Unsplash topic.")
|
|
302
|
+
}).describe("The topic photo listing returned by Unsplash.");
|
|
303
|
+
var unsplashActions = {
|
|
304
|
+
list_photos: {
|
|
305
|
+
description: "List the latest public photos from Unsplash.",
|
|
306
|
+
effect: "read",
|
|
307
|
+
inputSchema: listPhotosInput,
|
|
308
|
+
outputSchema: external_exports.toJSONSchema(listPhotosOutput, { io: "output", unrepresentable: "any" })
|
|
309
|
+
},
|
|
310
|
+
search_photos: {
|
|
311
|
+
description: "Search photos on Unsplash using keyword and filter inputs.",
|
|
312
|
+
effect: "read",
|
|
313
|
+
inputSchema: searchPhotosInput,
|
|
314
|
+
outputSchema: external_exports.toJSONSchema(searchPhotosOutput, { io: "output", unrepresentable: "any" })
|
|
315
|
+
},
|
|
316
|
+
get_photo: {
|
|
317
|
+
description: "Fetch the detailed payload for a single Unsplash photo.",
|
|
318
|
+
effect: "read",
|
|
319
|
+
inputSchema: getPhotoInput,
|
|
320
|
+
outputSchema: external_exports.toJSONSchema(getPhotoOutput, { io: "output", unrepresentable: "any" })
|
|
321
|
+
},
|
|
322
|
+
get_random_photo: {
|
|
323
|
+
description: "Fetch one or more random Unsplash photos using optional filters.",
|
|
324
|
+
effect: "read",
|
|
325
|
+
inputSchema: getRandomPhotoInput,
|
|
326
|
+
outputSchema: external_exports.toJSONSchema(getRandomPhotoOutput, { io: "output", unrepresentable: "any" })
|
|
327
|
+
},
|
|
328
|
+
list_topics: {
|
|
329
|
+
description: "List topics curated by Unsplash.",
|
|
330
|
+
effect: "read",
|
|
331
|
+
inputSchema: listTopicsInput,
|
|
332
|
+
outputSchema: external_exports.toJSONSchema(listTopicsOutput, { io: "output", unrepresentable: "any" })
|
|
333
|
+
},
|
|
334
|
+
get_topic_photos: {
|
|
335
|
+
description: "List photos from a specific Unsplash topic.",
|
|
336
|
+
effect: "read",
|
|
337
|
+
inputSchema: getTopicPhotosInput,
|
|
338
|
+
outputSchema: external_exports.toJSONSchema(getTopicPhotosOutput, { io: "output", unrepresentable: "any" })
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
// ../plugins/src/unsplash/index.ts
|
|
343
|
+
function createUnsplashPlugin() {
|
|
344
|
+
return createProviderPlugin({
|
|
345
|
+
description: "Unsplash",
|
|
346
|
+
actions: unsplashActions,
|
|
347
|
+
// 上游 `credentialValidators.apiKey` 打的就是 `/photos?page=1&per_page=1`,
|
|
348
|
+
// 对应这里的 list_photos:read、无必填入参,平台空参调它即可验证 access key。
|
|
349
|
+
credentialProbe: "list_photos",
|
|
350
|
+
handlers: {
|
|
351
|
+
list_photos: listPhotos,
|
|
352
|
+
search_photos: searchPhotos,
|
|
353
|
+
get_photo: getPhoto,
|
|
354
|
+
get_random_photo: getRandomPhoto,
|
|
355
|
+
list_topics: listTopics,
|
|
356
|
+
get_topic_photos: getTopicPhotos
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
var unsplash_default = createUnsplashPlugin();
|
|
361
|
+
export {
|
|
362
|
+
createUnsplashPlugin,
|
|
363
|
+
unsplash_default as default
|
|
364
|
+
};
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderPlugin,
|
|
3
|
+
guardedFetch,
|
|
4
|
+
requireCredential,
|
|
5
|
+
upstreamError
|
|
6
|
+
} from "./chunk-CSJEZHQO.js";
|
|
7
|
+
import "./chunk-K7FVSFUX.js";
|
|
8
|
+
import {
|
|
9
|
+
TBError,
|
|
10
|
+
external_exports
|
|
11
|
+
} from "./chunk-JLTYA2B3.js";
|
|
12
|
+
import "./chunk-MLKGABMK.js";
|
|
13
|
+
|
|
14
|
+
// ../plugins/src/upstash_redis/api.ts
|
|
15
|
+
var SERVICE = "upstash_redis";
|
|
16
|
+
var HOSTNAME_SUFFIX = ".upstash.io";
|
|
17
|
+
function text(value) {
|
|
18
|
+
if (typeof value !== "string") return void 0;
|
|
19
|
+
const trimmed = value.trim();
|
|
20
|
+
return trimmed === "" ? void 0 : trimmed;
|
|
21
|
+
}
|
|
22
|
+
function record(value) {
|
|
23
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
24
|
+
}
|
|
25
|
+
function responseError(message) {
|
|
26
|
+
return new TBError("unavailable", message, { retryable: true });
|
|
27
|
+
}
|
|
28
|
+
function configError(message) {
|
|
29
|
+
return new TBError("invalid_argument", `${SERVICE} \u7684 restUrl ${message}`);
|
|
30
|
+
}
|
|
31
|
+
function isQuotaMessage(message) {
|
|
32
|
+
const normalized = message.toLowerCase();
|
|
33
|
+
return normalized.includes("limit exceeded") || normalized.includes("connections exceeded");
|
|
34
|
+
}
|
|
35
|
+
function restUrl(ctx) {
|
|
36
|
+
const raw = requireCredential(ctx, SERVICE, "restUrl");
|
|
37
|
+
let url;
|
|
38
|
+
try {
|
|
39
|
+
url = new URL(raw.trim());
|
|
40
|
+
} catch {
|
|
41
|
+
throw configError("\u4E0D\u662F\u5408\u6CD5 URL");
|
|
42
|
+
}
|
|
43
|
+
if (url.protocol !== "https:") throw configError("\u5FC5\u987B\u7528 https");
|
|
44
|
+
if (url.username !== "" || url.password !== "") throw configError("\u4E0D\u80FD\u5E26\u7528\u6237\u540D\u6216\u5BC6\u7801");
|
|
45
|
+
if (url.port !== "") throw configError("\u4E0D\u80FD\u5E26\u7AEF\u53E3");
|
|
46
|
+
if (url.pathname !== "/" || url.search !== "" || url.hash !== "") {
|
|
47
|
+
throw configError("\u4E0D\u80FD\u5E26\u8DEF\u5F84\u3001\u67E5\u8BE2\u4E32\u6216\u7247\u6BB5");
|
|
48
|
+
}
|
|
49
|
+
if (!url.hostname.endsWith(HOSTNAME_SUFFIX)) {
|
|
50
|
+
throw configError(`\u5FC5\u987B\u662F\u5B98\u65B9 ${HOSTNAME_SUFFIX} \u7AEF\u70B9`);
|
|
51
|
+
}
|
|
52
|
+
return url;
|
|
53
|
+
}
|
|
54
|
+
function commandError(status, payload, fallbackBody) {
|
|
55
|
+
const body = record(payload);
|
|
56
|
+
const message = text(body?.error) ?? text(body?.message) ?? text(fallbackBody) ?? `Upstash Redis \u8FD4\u56DE HTTP ${status}`;
|
|
57
|
+
if (isQuotaMessage(message)) return upstreamError(429, message);
|
|
58
|
+
return upstreamError(status, message);
|
|
59
|
+
}
|
|
60
|
+
function unwrap(payload) {
|
|
61
|
+
const body = record(payload);
|
|
62
|
+
if (body === void 0) throw responseError("Upstash Redis \u54CD\u5E94\u4E0D\u662F\u5BF9\u8C61");
|
|
63
|
+
const error = text(body.error);
|
|
64
|
+
if (error !== void 0) {
|
|
65
|
+
if (isQuotaMessage(error)) throw upstreamError(429, error);
|
|
66
|
+
throw new TBError("invalid_argument", error);
|
|
67
|
+
}
|
|
68
|
+
if (!Object.hasOwn(body, "result")) throw responseError("Upstash Redis \u54CD\u5E94\u7F3A result");
|
|
69
|
+
return body.result;
|
|
70
|
+
}
|
|
71
|
+
async function command(ctx, args) {
|
|
72
|
+
const response = await guardedFetch(restUrl(ctx), {
|
|
73
|
+
method: "POST",
|
|
74
|
+
headers: {
|
|
75
|
+
"accept": "application/json",
|
|
76
|
+
"authorization": `Bearer ${requireCredential(ctx, SERVICE, "restToken")}`,
|
|
77
|
+
"content-type": "application/json"
|
|
78
|
+
},
|
|
79
|
+
body: JSON.stringify(args)
|
|
80
|
+
});
|
|
81
|
+
const body = await response.text();
|
|
82
|
+
let payload;
|
|
83
|
+
let parsed = false;
|
|
84
|
+
if (body !== "") {
|
|
85
|
+
try {
|
|
86
|
+
payload = JSON.parse(body);
|
|
87
|
+
parsed = true;
|
|
88
|
+
} catch {
|
|
89
|
+
if (response.ok) throw responseError("Upstash Redis \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (!response.ok) throw commandError(response.status, parsed ? payload : void 0, body);
|
|
93
|
+
return unwrap(payload);
|
|
94
|
+
}
|
|
95
|
+
function redisKey(value) {
|
|
96
|
+
const key = text(value);
|
|
97
|
+
if (key === void 0) throw new TBError("invalid_argument", "key \u4E0D\u80FD\u662F\u7A7A\u767D");
|
|
98
|
+
return key;
|
|
99
|
+
}
|
|
100
|
+
function stringOrNull(result, name) {
|
|
101
|
+
if (result === null || typeof result === "string") return result;
|
|
102
|
+
throw responseError(`Upstash Redis \u7684 ${name} \u8FD4\u56DE\u503C\u4E0D\u5408\u5951\u7EA6`);
|
|
103
|
+
}
|
|
104
|
+
function integer(result, name) {
|
|
105
|
+
if (typeof result !== "number" || !Number.isInteger(result)) {
|
|
106
|
+
throw responseError(`Upstash Redis \u7684 ${name} \u8FD4\u56DE\u503C\u4E0D\u5408\u5951\u7EA6`);
|
|
107
|
+
}
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
function flag(result, name) {
|
|
111
|
+
const value = integer(result, name);
|
|
112
|
+
if (value !== 0 && value !== 1) throw responseError(`Upstash Redis \u7684 ${name} \u8FD4\u56DE\u503C\u4E0D\u5408\u5951\u7EA6`);
|
|
113
|
+
return value === 1;
|
|
114
|
+
}
|
|
115
|
+
function scanPage(result) {
|
|
116
|
+
if (!Array.isArray(result) || result.length !== 2) {
|
|
117
|
+
throw responseError("Upstash Redis \u7684 SCAN \u8FD4\u56DE\u503C\u4E0D\u5408\u5951\u7EA6");
|
|
118
|
+
}
|
|
119
|
+
const [cursor, keys] = result;
|
|
120
|
+
if (typeof cursor !== "string" && typeof cursor !== "number" || !Array.isArray(keys)) {
|
|
121
|
+
throw responseError("Upstash Redis \u7684 SCAN \u8FD4\u56DE\u503C\u4E0D\u5408\u5951\u7EA6");
|
|
122
|
+
}
|
|
123
|
+
if (keys.some((key) => typeof key !== "string")) {
|
|
124
|
+
throw responseError("Upstash Redis \u7684 SCAN \u8FD4\u56DE\u4E86\u975E\u5B57\u7B26\u4E32\u952E");
|
|
125
|
+
}
|
|
126
|
+
return { nextCursor: String(cursor), keys };
|
|
127
|
+
}
|
|
128
|
+
async function get(input, ctx) {
|
|
129
|
+
const result = await command(ctx, ["GET", redisKey(input.key)]);
|
|
130
|
+
return { value: stringOrNull(result, "GET") };
|
|
131
|
+
}
|
|
132
|
+
async function set(input, ctx) {
|
|
133
|
+
const args = ["SET", redisKey(input.key), input.value];
|
|
134
|
+
if (input.expirationSeconds !== void 0) args.push("EX", input.expirationSeconds);
|
|
135
|
+
if (input.condition !== void 0) args.push(input.condition);
|
|
136
|
+
const result = await command(ctx, args);
|
|
137
|
+
if (result !== "OK" && result !== null) {
|
|
138
|
+
throw responseError("Upstash Redis \u7684 SET \u8FD4\u56DE\u503C\u4E0D\u5408\u5951\u7EA6");
|
|
139
|
+
}
|
|
140
|
+
return { stored: result === "OK" };
|
|
141
|
+
}
|
|
142
|
+
async function deleteKey(input, ctx) {
|
|
143
|
+
const result = await command(ctx, ["DEL", redisKey(input.key)]);
|
|
144
|
+
return { deleted: flag(result, "DEL") };
|
|
145
|
+
}
|
|
146
|
+
async function exists(input, ctx) {
|
|
147
|
+
const result = await command(ctx, ["EXISTS", redisKey(input.key)]);
|
|
148
|
+
return { exists: flag(result, "EXISTS") };
|
|
149
|
+
}
|
|
150
|
+
async function expire(input, ctx) {
|
|
151
|
+
const result = await command(ctx, ["EXPIRE", redisKey(input.key), input.expirationSeconds]);
|
|
152
|
+
return { updated: flag(result, "EXPIRE") };
|
|
153
|
+
}
|
|
154
|
+
async function ttl(input, ctx) {
|
|
155
|
+
const result = await command(ctx, ["TTL", redisKey(input.key)]);
|
|
156
|
+
return { ttlSeconds: integer(result, "TTL") };
|
|
157
|
+
}
|
|
158
|
+
async function scan(input, ctx) {
|
|
159
|
+
const args = ["SCAN", text(input.cursor) ?? "0"];
|
|
160
|
+
const match = text(input.match);
|
|
161
|
+
if (match !== void 0) args.push("MATCH", match);
|
|
162
|
+
if (input.count !== void 0) args.push("COUNT", input.count);
|
|
163
|
+
const page = scanPage(await command(ctx, args));
|
|
164
|
+
return { ...page, complete: page.nextCursor === "0" };
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// ../plugins/src/upstash_redis/schema.ts
|
|
168
|
+
var getInput = external_exports.strictObject({
|
|
169
|
+
key: external_exports.string().min(1).describe("The Redis key.")
|
|
170
|
+
}).describe("The Redis key to retrieve.");
|
|
171
|
+
var getOutput = external_exports.strictObject({
|
|
172
|
+
value: external_exports.string().describe("The stored string value, or null when the key does not exist. Upstash replaces bytes that are not valid UTF-8 with U+FFFD, so only text values round-trip exactly.").nullable()
|
|
173
|
+
}).describe("The value returned for the Redis key.");
|
|
174
|
+
var setInput = external_exports.strictObject({
|
|
175
|
+
key: external_exports.string().min(1).describe("The Redis key."),
|
|
176
|
+
value: external_exports.string().min(1).describe("The string value stored for the Redis key."),
|
|
177
|
+
expirationSeconds: external_exports.int().min(1).describe("Expiration time in seconds.").optional(),
|
|
178
|
+
condition: external_exports.enum(["NX", "XX"]).describe("Optional Redis write condition: NX stores only a new key; XX stores only an existing key.").optional()
|
|
179
|
+
}).describe("The Redis string value to store.");
|
|
180
|
+
var setOutput = external_exports.strictObject({
|
|
181
|
+
stored: external_exports.boolean().describe("Whether Redis stored the value. False means the requested condition was not met.")
|
|
182
|
+
}).describe("The result of the Redis SET command.");
|
|
183
|
+
var deleteInput = external_exports.strictObject({
|
|
184
|
+
key: external_exports.string().min(1).describe("The Redis key.")
|
|
185
|
+
}).describe("The Redis key to delete.");
|
|
186
|
+
var deleteOutput = external_exports.strictObject({
|
|
187
|
+
deleted: external_exports.boolean().describe("Whether Redis deleted an existing key.")
|
|
188
|
+
}).describe("The result of the Redis DEL command.");
|
|
189
|
+
var existsInput = external_exports.strictObject({
|
|
190
|
+
key: external_exports.string().min(1).describe("The Redis key.")
|
|
191
|
+
}).describe("The Redis key to check.");
|
|
192
|
+
var existsOutput = external_exports.strictObject({
|
|
193
|
+
exists: external_exports.boolean().describe("Whether the Redis key exists.")
|
|
194
|
+
}).describe("The result of the Redis EXISTS command.");
|
|
195
|
+
var expireInput = external_exports.strictObject({
|
|
196
|
+
key: external_exports.string().min(1).describe("The Redis key."),
|
|
197
|
+
expirationSeconds: external_exports.int().min(1).describe("Expiration time in seconds.")
|
|
198
|
+
}).describe("The Redis key and its new expiration time.");
|
|
199
|
+
var expireOutput = external_exports.strictObject({
|
|
200
|
+
updated: external_exports.boolean().describe("Whether Redis updated the expiration for an existing key.")
|
|
201
|
+
}).describe("The result of the Redis EXPIRE command.");
|
|
202
|
+
var ttlInput = external_exports.strictObject({
|
|
203
|
+
key: external_exports.string().min(1).describe("The Redis key.")
|
|
204
|
+
}).describe("The Redis key whose expiration to retrieve.");
|
|
205
|
+
var ttlOutput = external_exports.strictObject({
|
|
206
|
+
ttlSeconds: external_exports.int().describe("Remaining expiration in seconds. -2 means the key does not exist; -1 means the key has no expiration.")
|
|
207
|
+
}).describe("The result of the Redis TTL command.");
|
|
208
|
+
var scanInput = external_exports.strictObject({
|
|
209
|
+
cursor: external_exports.string().min(1).describe("The cursor returned by a previous scan. Omit it to start at cursor 0.").optional(),
|
|
210
|
+
match: external_exports.string().min(1).describe("Optional Redis glob pattern used to filter keys.").optional(),
|
|
211
|
+
count: external_exports.int().min(1).max(1e3).describe("Optional scan work hint from 1 to 1000.").optional()
|
|
212
|
+
}).describe("Cursor pagination and optional filters for Redis SCAN.");
|
|
213
|
+
var scanOutput = external_exports.strictObject({
|
|
214
|
+
nextCursor: external_exports.string().min(1).describe("Cursor to pass to the next scan request. A value of 0 means scanning is complete."),
|
|
215
|
+
keys: external_exports.array(external_exports.string().min(1)).describe("Keys returned in this scan page."),
|
|
216
|
+
complete: external_exports.boolean().describe("Whether this scan reached cursor 0.")
|
|
217
|
+
}).describe("One page returned by Redis SCAN.");
|
|
218
|
+
var upstashRedisActions = {
|
|
219
|
+
get: {
|
|
220
|
+
description: "Get the string value stored for one Redis key.",
|
|
221
|
+
effect: "write",
|
|
222
|
+
inputSchema: getInput,
|
|
223
|
+
outputSchema: external_exports.toJSONSchema(getOutput, { io: "output", unrepresentable: "any" })
|
|
224
|
+
},
|
|
225
|
+
set: {
|
|
226
|
+
description: "Store a string value for one Redis key, optionally with an expiration or conditional write.",
|
|
227
|
+
effect: "write",
|
|
228
|
+
inputSchema: setInput,
|
|
229
|
+
outputSchema: external_exports.toJSONSchema(setOutput, { io: "output", unrepresentable: "any" })
|
|
230
|
+
},
|
|
231
|
+
delete: {
|
|
232
|
+
description: "Delete one Redis key.",
|
|
233
|
+
effect: "write",
|
|
234
|
+
inputSchema: deleteInput,
|
|
235
|
+
outputSchema: external_exports.toJSONSchema(deleteOutput, { io: "output", unrepresentable: "any" })
|
|
236
|
+
},
|
|
237
|
+
exists: {
|
|
238
|
+
description: "Check whether one Redis key exists.",
|
|
239
|
+
effect: "write",
|
|
240
|
+
inputSchema: existsInput,
|
|
241
|
+
outputSchema: external_exports.toJSONSchema(existsOutput, { io: "output", unrepresentable: "any" })
|
|
242
|
+
},
|
|
243
|
+
expire: {
|
|
244
|
+
description: "Set or replace the expiration time for one Redis key.",
|
|
245
|
+
effect: "write",
|
|
246
|
+
inputSchema: expireInput,
|
|
247
|
+
outputSchema: external_exports.toJSONSchema(expireOutput, { io: "output", unrepresentable: "any" })
|
|
248
|
+
},
|
|
249
|
+
ttl: {
|
|
250
|
+
description: "Get the remaining expiration time for one Redis key.",
|
|
251
|
+
effect: "write",
|
|
252
|
+
inputSchema: ttlInput,
|
|
253
|
+
outputSchema: external_exports.toJSONSchema(ttlOutput, { io: "output", unrepresentable: "any" })
|
|
254
|
+
},
|
|
255
|
+
scan: {
|
|
256
|
+
description: "Scan one page of Redis keys without reading the full keyspace.",
|
|
257
|
+
effect: "write",
|
|
258
|
+
inputSchema: scanInput,
|
|
259
|
+
outputSchema: external_exports.toJSONSchema(scanOutput, { io: "output", unrepresentable: "any" })
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
// ../plugins/src/upstash_redis/index.ts
|
|
264
|
+
function createUpstashRedisPlugin() {
|
|
265
|
+
return createProviderPlugin({
|
|
266
|
+
description: "Upstash Redis",
|
|
267
|
+
credentialFields: [
|
|
268
|
+
{
|
|
269
|
+
key: "restUrl",
|
|
270
|
+
label: "REST URL",
|
|
271
|
+
required: true,
|
|
272
|
+
secret: false,
|
|
273
|
+
description: "Upstash \u63A7\u5236\u53F0\u91CC\u90A3\u4E2A\u6570\u636E\u5E93\u7684 HTTPS REST \u5730\u5740(https://<db>.upstash.io);\u53EA\u63A5\u53D7\u5B98\u65B9 upstash.io \u7AEF\u70B9"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
key: "restToken",
|
|
277
|
+
label: "REST Token",
|
|
278
|
+
required: true,
|
|
279
|
+
secret: true,
|
|
280
|
+
description: "\u4EE5 Bearer \u53D1\u9001\u7684 Upstash REST \u4EE4\u724C\u3002\u53EA\u8BFB\u4EE4\u724C\u80FD\u8DD1 get/exists/ttl,\u4F46 scan \u4E0E\u6240\u6709\u5199\u64CD\u4F5C\u8981\u6807\u51C6\u4EE4\u724C"
|
|
281
|
+
}
|
|
282
|
+
],
|
|
283
|
+
actions: upstashRedisActions,
|
|
284
|
+
handlers: {
|
|
285
|
+
get,
|
|
286
|
+
set,
|
|
287
|
+
delete: deleteKey,
|
|
288
|
+
exists,
|
|
289
|
+
expire,
|
|
290
|
+
ttl,
|
|
291
|
+
scan
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
var upstash_redis_default = createUpstashRedisPlugin();
|
|
296
|
+
export {
|
|
297
|
+
createUpstashRedisPlugin,
|
|
298
|
+
upstash_redis_default as default
|
|
299
|
+
};
|