@tool-bridge/server 0.21.1 → 0.23.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/admin.js +170 -0
- package/dist/airtable-VMQVXLHK.js +790 -0
- package/dist/{alt_text_generator_ai-W7O34SNG.js → alt_text_generator_ai-FTWY4RU4.js} +12 -11
- package/dist/{amap-VOX4T2AW.js → amap-OK5VBHYC.js} +221 -220
- package/dist/anthropic-S67AZFZ3.js +203 -0
- package/dist/apify-ZE6MYQI3.js +248 -0
- package/dist/brave_search-TG2M2KOD.js +302 -0
- package/dist/chunk-2JNAI4OC.js +161 -0
- package/dist/{chunk-KMTT3I6D.js → chunk-4XJPN3DY.js} +19392 -26136
- package/dist/chunk-5ICRY3VU.js +8432 -0
- package/dist/chunk-7CTWGTDU.js +302 -0
- package/dist/chunk-BADVCN6K.js +378 -0
- package/dist/{chunk-XYBU3WZH.js → chunk-TDAWLMDE.js} +3 -3
- package/dist/chunk-U7PTOA3U.js +7320 -0
- package/dist/{chunk-E6JCVKW6.js → chunk-VWRUGUSU.js} +3 -3
- package/dist/{chunk-ATK45BXV.js → chunk-WJHG6OK7.js} +4 -2
- package/dist/circleci-3L3WJVSK.js +389 -0
- package/dist/clerk-EZPF2V7T.js +1019 -0
- package/dist/cohere-U27DPO64.js +185 -0
- package/dist/{confluence-B3EWPZVE.js → confluence-G2KL6ERH.js} +105 -104
- package/dist/{convertapi-EUWSQYPF.js → convertapi-L4CLJ2M3.js} +32 -31
- package/dist/{currencyapi-KVTIK3GL.js → currencyapi-YPYXG7YY.js} +71 -71
- package/dist/deepseek-6HT6WF3M.js +210 -0
- package/dist/docker_hub-LPE3PCVB.js +933 -0
- package/dist/dropbox-V56ABHTA.js +1305 -0
- package/dist/dub-6OKQ7MHT.js +680 -0
- package/dist/e2b-JS2U2QFU.js +278 -0
- package/dist/exa-DPWVYXSP.js +332 -0
- package/dist/{fal_ai-23E7JPNT.js → fal_ai-DK6Y27ZF.js} +81 -80
- package/dist/{feishu-7QRIDUV6.js → feishu-K7EGSRF3.js} +528 -572
- package/dist/{feishu_custom_bot-TJ4K7QNJ.js → feishu_custom_bot-2JUGFYNG.js} +57 -53
- package/dist/figma-FT5I7ITD.js +777 -0
- package/dist/firehydrant-EIKLKHX2.js +563 -0
- package/dist/{fixer-BWON27UO.js → fixer-U5QXIAKD.js} +34 -33
- package/dist/fly-T3JYFZ2M.js +469 -0
- package/dist/{front-QCGXYEDJ.js → front-D72MGVOR.js} +104 -104
- package/dist/geocodio-BOTD5TI5.js +213 -0
- package/dist/ghost-KYP7SZGB.js +338 -0
- package/dist/github-AGMZT3VY.js +5421 -0
- package/dist/gmail-BLJNJOBG.js +1887 -0
- package/dist/googlecalendar-GTHWNCF6.js +2524 -0
- package/dist/{googledocs-BUHL4J2H.js → googledocs-6EEDMEBQ.js} +341 -340
- package/dist/{grafana-GLU2DWF2.js → grafana-GMW6EKSQ.js} +221 -220
- package/dist/graphhopper-6OLGBDGB.js +325 -0
- package/dist/index.d.ts +1132 -332
- package/dist/index.js +31 -14
- package/dist/{ip2proxy-EZ64Y4ZH.js → ip2proxy-4QN42E6T.js} +28 -27
- package/dist/ipgeolocation_io-SK4XKDA2.js +315 -0
- package/dist/ipqualityscore-6ANBPXKT.js +279 -0
- package/dist/{jina_ai-EFBHTBXL.js → jina_ai-IHPSVRM5.js} +23 -23
- package/dist/{jira-HQSHAA5K.js → jira-46KKM4LC.js} +118 -117
- package/dist/langsmith-JZA345I5.js +593 -0
- package/dist/lemlist-43IV7DK6.js +289 -0
- package/dist/{linear-K7RYFYAD.js → linear-5LFH7XNL.js} +327 -326
- package/dist/logsnag-5RMYAHIL.js +150 -0
- package/dist/main.js +57 -280
- package/dist/{mattermost-S2BRCWLQ.js → mattermost-XFL6SHGG.js} +59 -58
- package/dist/mem0-NYO4DTP6.js +544 -0
- package/dist/memos-37MPQOLV.js +744 -0
- package/dist/{metabase-MMSEPCOF.js → metabase-KYBKZFMG.js} +90 -89
- package/dist/mistral_ai-6PL3K4PM.js +1196 -0
- package/dist/{mother_duck-H7PCQNZ2.js → mother_duck-2NH7W5M5.js} +94 -93
- package/dist/ngrok-UO6CDYCA.js +356 -0
- package/dist/{notes-PFMKRO33.js → notes-I3P32WP4.js} +11 -9
- package/dist/notion-BEAJFUOE.js +940 -0
- package/dist/open_exchange_rates-CMF62JB4.js +215 -0
- package/dist/openai-IHOMKVND.js +800 -0
- package/dist/opengraph_io-ZQ2FGLHX.js +362 -0
- package/dist/openrouter-HXLW3NR5.js +441 -0
- package/dist/outline-ELCP4NEU.js +599 -0
- package/dist/paddle-O77LALVN.js +454 -0
- package/dist/perplexity-JCU654QV.js +220 -0
- package/dist/pinecone-W5W4LRKL.js +571 -0
- package/dist/{pipedrive-Y2O7QGFF.js → pipedrive-ITMJLLPZ.js} +99 -98
- package/dist/polar-R33XU4L3.js +395 -0
- package/dist/posthog-JVNTOLTV.js +3464 -0
- package/dist/postmark-6SBG7HWV.js +427 -0
- package/dist/{prerender-MENYM2TY.js → prerender-GPNKTNFC.js} +31 -30
- package/dist/{pubmed-GOXUVVH5.js → pubmed-UP6ZEEIH.js} +239 -238
- package/dist/{railway-V2SID4WV.js → railway-KWEWXHTY.js} +118 -117
- package/dist/readwise-BLATSMC3.js +470 -0
- package/dist/render-QYRVIXII.js +461 -0
- package/dist/{replicate-756MXPYX.js → replicate-JYTWH4NF.js} +81 -80
- package/dist/{resend-ZKH3BTBI.js → resend-L5N75SZM.js} +20 -16
- package/dist/rootly-MHCPEQ26.js +336 -0
- package/dist/{scrapfly-NSRHFDIQ.js → scrapfly-PTPGYSJM.js} +62 -61
- package/dist/{scrapingbee-OQHLAVEY.js → scrapingbee-JN6UH5PY.js} +56 -56
- package/dist/{screenshot_fyi-DVWG3AXC.js → screenshot_fyi-4QRVSV55.js} +16 -16
- package/dist/semantic_scholar-LRSWA2GE.js +611 -0
- package/dist/{sentry-546MNDJG.js → sentry-2G6PF5W6.js} +208 -207
- package/dist/{shodan-C3OON3Z3.js → shodan-WKKPP5C6.js} +62 -61
- package/dist/shopify-64YDK5T2.js +610 -0
- package/dist/stripe-QAIGGOTF.js +585 -0
- package/dist/{supabase-U2SL4D63.js → supabase-WHTGR6ND.js} +245 -244
- package/dist/tavily-QIXCDDWO.js +326 -0
- package/dist/telegram-E6G7CWI6.js +1767 -0
- package/dist/{telnyx-CXQ4EZUX.js → telnyx-ZDVVS7PK.js} +57 -56
- package/dist/todoist-DMYF3G7J.js +664 -0
- package/dist/trello-HY2RYIRP.js +1080 -0
- package/dist/turso-HAQWMGRP.js +416 -0
- package/dist/{twilio-4PDBJKWX.js → twilio-MLXYPHJE.js} +70 -69
- package/dist/umami-DZHBLPVG.js +389 -0
- package/dist/unsplash-GS2OPXKE.js +351 -0
- package/dist/{upstash_redis-G4LQBYHA.js → upstash_redis-XMXWTNAJ.js} +51 -50
- package/dist/uptimerobot-TF5WRZ4G.js +483 -0
- package/dist/v2ex-2BVXAPDF.js +667 -0
- package/dist/vercel-YMJGQYJE.js +1076 -0
- package/dist/{wolfram_alpha_api-3G4PUJWB.js → wolfram_alpha_api-I56SXWFZ.js} +36 -35
- package/dist/wordpress-R7TDFZ2P.js +812 -0
- package/dist/workos-HDNHWVMS.js +664 -0
- package/dist/zhihu-LX6AGGDS.js +254 -0
- package/package.json +18 -9
- package/dist/airtable-LLZDFN7M.js +0 -789
- package/dist/anthropic-G23NN3X5.js +0 -202
- package/dist/apify-Y3SS734K.js +0 -247
- package/dist/brave_search-ZC7OAPSZ.js +0 -301
- package/dist/chunk-R6P4XAE5.js +0 -248
- package/dist/chunk-U7B6DS2O.js +0 -977
- package/dist/chunk-UZM2RXZH.js +0 -23436
- package/dist/circleci-3BAX5FCG.js +0 -388
- package/dist/clerk-6LEM6TNU.js +0 -1019
- package/dist/cloudflare_dns-KINYTJUD.js +0 -588
- package/dist/cohere-XCJ5AJ6B.js +0 -185
- package/dist/deepseek-PC5YGNC5.js +0 -209
- package/dist/docker_hub-C3MA5FU6.js +0 -932
- package/dist/dropbox-XBV7Z2IR.js +0 -1304
- package/dist/dub-LDOFG3HC.js +0 -679
- package/dist/e2b-JMCPSVBW.js +0 -277
- package/dist/exa-RAK7O7RD.js +0 -331
- package/dist/figma-E6IX5DTH.js +0 -773
- package/dist/firehydrant-ZBLPQREE.js +0 -562
- package/dist/fly-ZH3HFCZJ.js +0 -468
- package/dist/geocodio-YGNI7DA4.js +0 -212
- package/dist/ghost-EVSGKH2Q.js +0 -337
- package/dist/github-MA2BGRCJ.js +0 -5420
- package/dist/gmail-E5E6AADE.js +0 -1886
- package/dist/googlecalendar-BTLFPXTD.js +0 -2523
- package/dist/graphhopper-WSMB3TCD.js +0 -324
- package/dist/ipgeolocation_io-AA7HAS22.js +0 -315
- package/dist/ipqualityscore-BHJXVTJT.js +0 -277
- package/dist/langsmith-5W6SCT6F.js +0 -592
- package/dist/lemlist-HJWH6UMK.js +0 -288
- package/dist/logsnag-4KFOHL37.js +0 -150
- package/dist/mem0-CAW43CIC.js +0 -543
- package/dist/memos-TWEGPKFM.js +0 -740
- package/dist/mistral_ai-64BGZQHP.js +0 -1195
- package/dist/ngrok-GQCUGZKJ.js +0 -356
- package/dist/notion-DQWZWP4N.js +0 -936
- package/dist/open_exchange_rates-QMMD735E.js +0 -214
- package/dist/openai-W6PX32NZ.js +0 -799
- package/dist/opengraph_io-HNDBXYNW.js +0 -361
- package/dist/openrouter-JJYMEAUL.js +0 -437
- package/dist/outline-MCBNQZYY.js +0 -595
- package/dist/paddle-D2SKLUDN.js +0 -453
- package/dist/perplexity-XIFMKUAE.js +0 -219
- package/dist/pinecone-HUFTALV2.js +0 -570
- package/dist/polar-TYTOMOSR.js +0 -394
- package/dist/posthog-43JAR3VW.js +0 -3463
- package/dist/postmark-KL2QJYSG.js +0 -426
- package/dist/readwise-CI4GIMMJ.js +0 -469
- package/dist/render-SUBJ6YRZ.js +0 -460
- package/dist/rootly-CD2LJHPI.js +0 -336
- package/dist/semantic_scholar-T4A252KW.js +0 -610
- package/dist/shopify-Y2HN2MCQ.js +0 -609
- package/dist/stripe-VE3CD3AY.js +0 -584
- package/dist/tavily-KCZHK6HE.js +0 -326
- package/dist/telegram-3URFBCMY.js +0 -1766
- package/dist/todoist-HNPWNYTD.js +0 -663
- package/dist/trello-3W2MIXRP.js +0 -1079
- package/dist/turso-2EQF7C2Z.js +0 -415
- package/dist/umami-5REN7TGP.js +0 -388
- package/dist/unsplash-EIXL424F.js +0 -350
- package/dist/uptimerobot-KNJ3EYLY.js +0 -482
- package/dist/v2ex-RHJ234PZ.js +0 -666
- package/dist/vercel-AS6NCIC7.js +0 -1075
- package/dist/wordpress-KNDAAUV7.js +0 -811
- package/dist/workos-R6UITSJ7.js +0 -663
- package/dist/zhihu-AGK4HILK.js +0 -253
|
@@ -1,469 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createAuthedClient
|
|
3
|
-
} from "./chunk-XYBU3WZH.js";
|
|
4
|
-
import "./chunk-E6JCVKW6.js";
|
|
5
|
-
import {
|
|
6
|
-
asJsonObject,
|
|
7
|
-
compactDefined,
|
|
8
|
-
integerValue,
|
|
9
|
-
trimmedText
|
|
10
|
-
} from "./chunk-JXHMDBAY.js";
|
|
11
|
-
import {
|
|
12
|
-
createProviderPlugin,
|
|
13
|
-
upstreamError
|
|
14
|
-
} from "./chunk-ATK45BXV.js";
|
|
15
|
-
import "./chunk-U7B6DS2O.js";
|
|
16
|
-
import {
|
|
17
|
-
TBError,
|
|
18
|
-
external_exports
|
|
19
|
-
} from "./chunk-UZM2RXZH.js";
|
|
20
|
-
import "./chunk-U67V476Y.js";
|
|
21
|
-
|
|
22
|
-
// ../plugins/src/readwise/api.ts
|
|
23
|
-
var SERVICE = "readwise";
|
|
24
|
-
var API_BASE = "https://readwise.io/api";
|
|
25
|
-
function readArray(value) {
|
|
26
|
-
return Array.isArray(value) ? value : [];
|
|
27
|
-
}
|
|
28
|
-
function errorMessage(payload, status) {
|
|
29
|
-
const object = asJsonObject(payload);
|
|
30
|
-
if (object !== void 0) {
|
|
31
|
-
const direct = trimmedText(object.detail) ?? trimmedText(object.message) ?? trimmedText(object.error);
|
|
32
|
-
if (direct !== void 0) return direct;
|
|
33
|
-
for (const value of Object.values(object)) {
|
|
34
|
-
if (Array.isArray(value)) {
|
|
35
|
-
const first = value.find((item) => typeof item === "string" && item.trim() !== "");
|
|
36
|
-
if (typeof first === "string") return first.trim();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return `Readwise request failed with status ${status}`;
|
|
41
|
-
}
|
|
42
|
-
var http = createAuthedClient({
|
|
43
|
-
baseUrl: `${API_BASE}/`,
|
|
44
|
-
service: SERVICE,
|
|
45
|
-
// Readwise 用的是 `Token <key>`,不是 Bearer —— 写成 Bearer 会一直 401。
|
|
46
|
-
auth: { kind: "token" },
|
|
47
|
-
headers: { accept: "application/json" },
|
|
48
|
-
mapError: ({ bodyKind, data, status }) => bodyKind === "invalid-json" ? new TBError("unavailable", "Readwise \u8FD4\u56DE\u4E86\u975E\u6CD5 JSON", { retryable: true }) : upstreamError(status, errorMessage(data, status))
|
|
49
|
-
});
|
|
50
|
-
async function request(ctx, input) {
|
|
51
|
-
const response = await http.request(ctx, {
|
|
52
|
-
method: input.method ?? "GET",
|
|
53
|
-
path: input.path,
|
|
54
|
-
query: Object.entries(input.query ?? {}),
|
|
55
|
-
...input.body === void 0 ? {} : { json: input.body },
|
|
56
|
-
invalidJsonMessage: "Readwise \u8FD4\u56DE\u4E86\u975E\u6CD5 JSON"
|
|
57
|
-
});
|
|
58
|
-
return response.bodyKind === "empty" ? {} : response.data;
|
|
59
|
-
}
|
|
60
|
-
function requireRecord(value, message) {
|
|
61
|
-
const object = asJsonObject(value);
|
|
62
|
-
if (object === void 0) throw new TBError("unavailable", message, { retryable: true });
|
|
63
|
-
return object;
|
|
64
|
-
}
|
|
65
|
-
function query(input) {
|
|
66
|
-
const output = {};
|
|
67
|
-
for (const [key, value] of Object.entries(input)) {
|
|
68
|
-
if (value === void 0 || value === "") continue;
|
|
69
|
-
output[key] = String(value);
|
|
70
|
-
}
|
|
71
|
-
return output;
|
|
72
|
-
}
|
|
73
|
-
function normalizeHighlight(value) {
|
|
74
|
-
const item = asJsonObject(value) ?? {};
|
|
75
|
-
return {
|
|
76
|
-
id: integerValue(item.id) ?? null,
|
|
77
|
-
text: trimmedText(item.text) ?? "",
|
|
78
|
-
title: trimmedText(item.title) ?? null,
|
|
79
|
-
author: trimmedText(item.author) ?? null,
|
|
80
|
-
// note 保留空串:上游用 typeof 判断而非 optionalString,清空备注要能表达出来。
|
|
81
|
-
note: typeof item.note === "string" ? item.note : null,
|
|
82
|
-
url: trimmedText(item.url) ?? null,
|
|
83
|
-
highlightedAt: trimmedText(item.highlighted_at) ?? trimmedText(item.highlightedAt) ?? null,
|
|
84
|
-
updatedAt: trimmedText(item.updated_at) ?? trimmedText(item.updatedAt) ?? null,
|
|
85
|
-
raw: item
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
function normalizeBook(value) {
|
|
89
|
-
const item = asJsonObject(value) ?? {};
|
|
90
|
-
return {
|
|
91
|
-
// export 接口回的是 user_book_id,books 接口回的是 id。
|
|
92
|
-
id: integerValue(item.user_book_id) ?? integerValue(item.id) ?? null,
|
|
93
|
-
title: trimmedText(item.title) ?? null,
|
|
94
|
-
author: trimmedText(item.author) ?? null,
|
|
95
|
-
category: trimmedText(item.category) ?? null,
|
|
96
|
-
source: trimmedText(item.source) ?? null,
|
|
97
|
-
numHighlights: integerValue(item.num_highlights) ?? integerValue(item.numHighlights) ?? null,
|
|
98
|
-
updatedAt: trimmedText(item.updated) ?? trimmedText(item.updated_at) ?? null,
|
|
99
|
-
highlights: readArray(item.highlights).map(normalizeHighlight),
|
|
100
|
-
raw: item
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
function readTags(value) {
|
|
104
|
-
if (Array.isArray(value)) return value.filter((item) => typeof item === "string");
|
|
105
|
-
const object = asJsonObject(value);
|
|
106
|
-
return object === void 0 ? [] : Object.keys(object);
|
|
107
|
-
}
|
|
108
|
-
function normalizeDocument(value) {
|
|
109
|
-
const item = asJsonObject(value) ?? {};
|
|
110
|
-
return {
|
|
111
|
-
id: trimmedText(item.id) ?? trimmedText(item.document_id) ?? null,
|
|
112
|
-
url: trimmedText(item.url) ?? null,
|
|
113
|
-
sourceUrl: trimmedText(item.source_url) ?? trimmedText(item.sourceUrl) ?? null,
|
|
114
|
-
title: trimmedText(item.title) ?? null,
|
|
115
|
-
author: trimmedText(item.author) ?? null,
|
|
116
|
-
category: trimmedText(item.category) ?? null,
|
|
117
|
-
location: trimmedText(item.location) ?? null,
|
|
118
|
-
tags: readTags(item.tags),
|
|
119
|
-
createdAt: trimmedText(item.created_at) ?? trimmedText(item.createdAt) ?? null,
|
|
120
|
-
updatedAt: trimmedText(item.updated_at) ?? trimmedText(item.updatedAt) ?? null,
|
|
121
|
-
raw: item
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
function readDocumentRecord(payload) {
|
|
125
|
-
return asJsonObject(payload.document) ?? asJsonObject(payload.result) ?? asJsonObject(payload.saved_document) ?? payload;
|
|
126
|
-
}
|
|
127
|
-
async function createHighlights(input, ctx) {
|
|
128
|
-
const payload = await request(ctx, {
|
|
129
|
-
path: "/v2/highlights/",
|
|
130
|
-
method: "POST",
|
|
131
|
-
body: { highlights: input.highlights }
|
|
132
|
-
});
|
|
133
|
-
const books = readArray(payload);
|
|
134
|
-
return { books: books.map(normalizeBook), raw: books };
|
|
135
|
-
}
|
|
136
|
-
async function exportHighlights(input, ctx) {
|
|
137
|
-
const payload = requireRecord(
|
|
138
|
-
await request(ctx, {
|
|
139
|
-
path: "/v2/export/",
|
|
140
|
-
query: query({ updatedAfter: input.updatedAfter, pageCursor: input.pageCursor })
|
|
141
|
-
}),
|
|
142
|
-
"Readwise \u8FD4\u56DE\u4E86\u975E\u6CD5\u7684 export \u54CD\u5E94"
|
|
143
|
-
);
|
|
144
|
-
return {
|
|
145
|
-
count: integerValue(payload.count) ?? null,
|
|
146
|
-
nextPageCursor: trimmedText(payload.nextPageCursor) ?? null,
|
|
147
|
-
books: readArray(payload.results).map(normalizeBook),
|
|
148
|
-
raw: payload
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
async function listBooks(input, ctx) {
|
|
152
|
-
const payload = requireRecord(
|
|
153
|
-
await request(ctx, {
|
|
154
|
-
path: "/v2/books/",
|
|
155
|
-
query: query({
|
|
156
|
-
page: input.page,
|
|
157
|
-
page_size: input.pageSize,
|
|
158
|
-
category: input.category,
|
|
159
|
-
updated__gt: input.updatedAfter,
|
|
160
|
-
updated__lt: input.updatedBefore
|
|
161
|
-
})
|
|
162
|
-
}),
|
|
163
|
-
"Readwise \u8FD4\u56DE\u4E86\u975E\u6CD5\u7684 books \u54CD\u5E94"
|
|
164
|
-
);
|
|
165
|
-
return {
|
|
166
|
-
count: integerValue(payload.count) ?? null,
|
|
167
|
-
next: trimmedText(payload.next) ?? null,
|
|
168
|
-
previous: trimmedText(payload.previous) ?? null,
|
|
169
|
-
books: readArray(payload.results).map(normalizeBook),
|
|
170
|
-
raw: payload
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
async function listDocuments(input, ctx) {
|
|
174
|
-
const payload = requireRecord(
|
|
175
|
-
await request(ctx, {
|
|
176
|
-
path: "/v3/list/",
|
|
177
|
-
query: query({
|
|
178
|
-
pageCursor: input.pageCursor,
|
|
179
|
-
updatedAfter: input.updatedAfter,
|
|
180
|
-
location: input.location,
|
|
181
|
-
category: input.category,
|
|
182
|
-
tag: input.tag
|
|
183
|
-
})
|
|
184
|
-
}),
|
|
185
|
-
"Readwise \u8FD4\u56DE\u4E86\u975E\u6CD5\u7684\u6587\u6863\u5217\u8868"
|
|
186
|
-
);
|
|
187
|
-
return {
|
|
188
|
-
count: integerValue(payload.count) ?? null,
|
|
189
|
-
nextPageCursor: trimmedText(payload.nextPageCursor) ?? null,
|
|
190
|
-
documents: readArray(payload.results).map(normalizeDocument),
|
|
191
|
-
raw: payload
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
async function saveDocument(input, ctx) {
|
|
195
|
-
const payload = requireRecord(
|
|
196
|
-
await request(ctx, {
|
|
197
|
-
path: "/v3/save/",
|
|
198
|
-
method: "POST",
|
|
199
|
-
body: compactDefined({
|
|
200
|
-
url: input.url,
|
|
201
|
-
title: input.title,
|
|
202
|
-
author: input.author,
|
|
203
|
-
summary: input.summary,
|
|
204
|
-
should_clean_html: input.shouldCleanHtml,
|
|
205
|
-
saved_using: input.savedUsing,
|
|
206
|
-
tags: input.tags
|
|
207
|
-
})
|
|
208
|
-
}),
|
|
209
|
-
"Readwise \u8FD4\u56DE\u4E86\u975E\u6CD5\u7684 save \u54CD\u5E94"
|
|
210
|
-
);
|
|
211
|
-
return { document: normalizeDocument(readDocumentRecord(payload)), raw: payload };
|
|
212
|
-
}
|
|
213
|
-
async function updateDocument(input, ctx) {
|
|
214
|
-
const payload = requireRecord(
|
|
215
|
-
await request(ctx, {
|
|
216
|
-
path: `/v3/update/${encodeURIComponent(input.documentId)}/`,
|
|
217
|
-
method: "PATCH",
|
|
218
|
-
body: compactDefined({
|
|
219
|
-
location: input.location,
|
|
220
|
-
title: input.title,
|
|
221
|
-
author: input.author,
|
|
222
|
-
summary: input.summary,
|
|
223
|
-
tags: input.tags
|
|
224
|
-
})
|
|
225
|
-
}),
|
|
226
|
-
"Readwise \u8FD4\u56DE\u4E86\u975E\u6CD5\u7684 update \u54CD\u5E94"
|
|
227
|
-
);
|
|
228
|
-
return { document: normalizeDocument(readDocumentRecord(payload)), raw: payload };
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// ../plugins/src/readwise/schema.ts
|
|
232
|
-
var createHighlightsInput = external_exports.strictObject({
|
|
233
|
-
highlights: external_exports.array(external_exports.strictObject({
|
|
234
|
-
text: external_exports.string().min(1).describe("The highlighted text to save in Readwise."),
|
|
235
|
-
title: external_exports.string().min(1).describe("The title of the source document or book."),
|
|
236
|
-
author: external_exports.string().min(1).describe("The author of the source document or book.").optional(),
|
|
237
|
-
category: external_exports.enum(["books", "articles", "tweets", "podcasts", "supplemental"]).describe("The Readwise highlight category such as books, articles, tweets, podcasts, or supplemental.").optional(),
|
|
238
|
-
source_type: external_exports.string().min(1).describe("The source type associated with the highlight, such as kindle, pocket, instapaper, or api.").optional(),
|
|
239
|
-
note: external_exports.string().describe("An optional note attached to the highlight.").optional(),
|
|
240
|
-
location: external_exports.int().min(1).describe("The highlight location in the source when available.").optional(),
|
|
241
|
-
location_type: external_exports.string().min(1).describe("The Readwise location type, such as page or order.").optional(),
|
|
242
|
-
highlighted_at: external_exports.string().min(1).describe("An ISO 8601 datetime string accepted by Readwise.").optional(),
|
|
243
|
-
url: external_exports.url().describe("The URL of the highlighted source when available.").optional()
|
|
244
|
-
}).describe("A highlight object accepted by the Readwise create highlights API.")).min(1).describe("The highlights to create.").optional()
|
|
245
|
-
}).describe("The input payload for creating Readwise highlights.");
|
|
246
|
-
var createHighlightsOutput = external_exports.strictObject({
|
|
247
|
-
books: external_exports.array(external_exports.strictObject({
|
|
248
|
-
id: external_exports.int().describe("The Readwise book identifier.").nullable().optional(),
|
|
249
|
-
title: external_exports.string().describe("The source title.").nullable().optional(),
|
|
250
|
-
author: external_exports.string().describe("The source author.").nullable().optional(),
|
|
251
|
-
category: external_exports.string().describe("The Readwise source category.").nullable().optional(),
|
|
252
|
-
source: external_exports.string().describe("The source integration or origin returned by Readwise.").nullable().optional(),
|
|
253
|
-
numHighlights: external_exports.int().describe("The number of highlights in the source.").nullable().optional(),
|
|
254
|
-
updatedAt: external_exports.string().describe("The datetime when the source was last updated.").nullable().optional(),
|
|
255
|
-
highlights: external_exports.array(external_exports.strictObject({
|
|
256
|
-
id: external_exports.int().describe("The Readwise highlight identifier.").nullable().optional(),
|
|
257
|
-
text: external_exports.string().describe("The highlighted text.").optional(),
|
|
258
|
-
title: external_exports.string().describe("The source title when Readwise returns it.").nullable().optional(),
|
|
259
|
-
author: external_exports.string().describe("The source author when Readwise returns it.").nullable().optional(),
|
|
260
|
-
note: external_exports.string().describe("The note attached to the highlight when present.").nullable().optional(),
|
|
261
|
-
url: external_exports.string().describe("The source URL when present.").nullable().optional(),
|
|
262
|
-
highlightedAt: external_exports.string().describe("The datetime when the text was highlighted.").nullable().optional(),
|
|
263
|
-
updatedAt: external_exports.string().describe("The datetime when the highlight was last updated.").nullable().optional(),
|
|
264
|
-
raw: external_exports.looseObject({}).describe("The raw highlight object returned by Readwise.").optional()
|
|
265
|
-
}).describe("A normalized Readwise highlight.")).describe("Highlights included with this source.").optional(),
|
|
266
|
-
raw: external_exports.looseObject({}).describe("The raw source object returned by Readwise.").optional()
|
|
267
|
-
}).describe("A normalized Readwise book or source.")).describe("The books, articles, or podcasts created or updated by Readwise.").optional(),
|
|
268
|
-
raw: external_exports.array(external_exports.looseObject({}).describe("One raw source object returned by Readwise.")).describe("The raw list of books, articles, or podcasts returned by Readwise.").optional()
|
|
269
|
-
}).describe("The response returned after creating Readwise highlights.");
|
|
270
|
-
var exportHighlightsInput = external_exports.strictObject({
|
|
271
|
-
updatedAfter: external_exports.string().min(1).describe("An ISO 8601 datetime string accepted by Readwise.").optional(),
|
|
272
|
-
pageCursor: external_exports.string().min(1).describe("The pagination cursor returned by a previous export response.").optional()
|
|
273
|
-
}).describe("The input payload for exporting Readwise highlights.");
|
|
274
|
-
var exportHighlightsOutput = external_exports.strictObject({
|
|
275
|
-
count: external_exports.int().describe("The total number of matching source records when provided.").nullable().optional(),
|
|
276
|
-
nextPageCursor: external_exports.string().describe("The cursor to pass as pageCursor on the next request, or null when there are no more pages.").nullable().optional(),
|
|
277
|
-
books: external_exports.array(external_exports.strictObject({
|
|
278
|
-
id: external_exports.int().describe("The Readwise book identifier.").nullable().optional(),
|
|
279
|
-
title: external_exports.string().describe("The source title.").nullable().optional(),
|
|
280
|
-
author: external_exports.string().describe("The source author.").nullable().optional(),
|
|
281
|
-
category: external_exports.string().describe("The Readwise source category.").nullable().optional(),
|
|
282
|
-
source: external_exports.string().describe("The source integration or origin returned by Readwise.").nullable().optional(),
|
|
283
|
-
numHighlights: external_exports.int().describe("The number of highlights in the source.").nullable().optional(),
|
|
284
|
-
updatedAt: external_exports.string().describe("The datetime when the source was last updated.").nullable().optional(),
|
|
285
|
-
highlights: external_exports.array(external_exports.strictObject({
|
|
286
|
-
id: external_exports.int().describe("The Readwise highlight identifier.").nullable().optional(),
|
|
287
|
-
text: external_exports.string().describe("The highlighted text.").optional(),
|
|
288
|
-
title: external_exports.string().describe("The source title when Readwise returns it.").nullable().optional(),
|
|
289
|
-
author: external_exports.string().describe("The source author when Readwise returns it.").nullable().optional(),
|
|
290
|
-
note: external_exports.string().describe("The note attached to the highlight when present.").nullable().optional(),
|
|
291
|
-
url: external_exports.string().describe("The source URL when present.").nullable().optional(),
|
|
292
|
-
highlightedAt: external_exports.string().describe("The datetime when the text was highlighted.").nullable().optional(),
|
|
293
|
-
updatedAt: external_exports.string().describe("The datetime when the highlight was last updated.").nullable().optional(),
|
|
294
|
-
raw: external_exports.looseObject({}).describe("The raw highlight object returned by Readwise.").optional()
|
|
295
|
-
}).describe("A normalized Readwise highlight.")).describe("Highlights included with this source.").optional(),
|
|
296
|
-
raw: external_exports.looseObject({}).describe("The raw source object returned by Readwise.").optional()
|
|
297
|
-
}).describe("A normalized Readwise book or source.")).describe("The exported books or sources.").optional(),
|
|
298
|
-
raw: external_exports.looseObject({}).describe("The raw export response returned by Readwise.").optional()
|
|
299
|
-
}).describe("The response returned when exporting Readwise highlights.");
|
|
300
|
-
var listBooksInput = external_exports.strictObject({
|
|
301
|
-
page: external_exports.int().min(1).describe("The page number to return.").optional(),
|
|
302
|
-
pageSize: external_exports.int().min(1).describe("The number of books to return per page.").optional(),
|
|
303
|
-
category: external_exports.enum(["books", "articles", "tweets", "podcasts", "supplemental"]).describe("The Readwise highlight category such as books, articles, tweets, podcasts, or supplemental.").optional(),
|
|
304
|
-
updatedAfter: external_exports.string().min(1).describe("An ISO 8601 datetime string accepted by Readwise.").optional(),
|
|
305
|
-
updatedBefore: external_exports.string().min(1).describe("An ISO 8601 datetime string accepted by Readwise.").optional()
|
|
306
|
-
}).describe("The input payload for listing Readwise books.");
|
|
307
|
-
var listBooksOutput = external_exports.strictObject({
|
|
308
|
-
count: external_exports.int().describe("The total number of matching books when provided.").nullable().optional(),
|
|
309
|
-
next: external_exports.string().describe("The URL for the next page, or null when there is no next page.").nullable().optional(),
|
|
310
|
-
previous: external_exports.string().describe("The URL for the previous page, or null when there is no previous page.").nullable().optional(),
|
|
311
|
-
books: external_exports.array(external_exports.strictObject({
|
|
312
|
-
id: external_exports.int().describe("The Readwise book identifier.").nullable().optional(),
|
|
313
|
-
title: external_exports.string().describe("The source title.").nullable().optional(),
|
|
314
|
-
author: external_exports.string().describe("The source author.").nullable().optional(),
|
|
315
|
-
category: external_exports.string().describe("The Readwise source category.").nullable().optional(),
|
|
316
|
-
source: external_exports.string().describe("The source integration or origin returned by Readwise.").nullable().optional(),
|
|
317
|
-
numHighlights: external_exports.int().describe("The number of highlights in the source.").nullable().optional(),
|
|
318
|
-
updatedAt: external_exports.string().describe("The datetime when the source was last updated.").nullable().optional(),
|
|
319
|
-
highlights: external_exports.array(external_exports.strictObject({
|
|
320
|
-
id: external_exports.int().describe("The Readwise highlight identifier.").nullable().optional(),
|
|
321
|
-
text: external_exports.string().describe("The highlighted text.").optional(),
|
|
322
|
-
title: external_exports.string().describe("The source title when Readwise returns it.").nullable().optional(),
|
|
323
|
-
author: external_exports.string().describe("The source author when Readwise returns it.").nullable().optional(),
|
|
324
|
-
note: external_exports.string().describe("The note attached to the highlight when present.").nullable().optional(),
|
|
325
|
-
url: external_exports.string().describe("The source URL when present.").nullable().optional(),
|
|
326
|
-
highlightedAt: external_exports.string().describe("The datetime when the text was highlighted.").nullable().optional(),
|
|
327
|
-
updatedAt: external_exports.string().describe("The datetime when the highlight was last updated.").nullable().optional(),
|
|
328
|
-
raw: external_exports.looseObject({}).describe("The raw highlight object returned by Readwise.").optional()
|
|
329
|
-
}).describe("A normalized Readwise highlight.")).describe("Highlights included with this source.").optional(),
|
|
330
|
-
raw: external_exports.looseObject({}).describe("The raw source object returned by Readwise.").optional()
|
|
331
|
-
}).describe("A normalized Readwise book or source.")).describe("The books returned by Readwise.").optional(),
|
|
332
|
-
raw: external_exports.looseObject({}).describe("The raw books response returned by Readwise.").optional()
|
|
333
|
-
}).describe("The response returned when listing Readwise books.");
|
|
334
|
-
var listDocumentsInput = external_exports.strictObject({
|
|
335
|
-
pageCursor: external_exports.string().min(1).describe("The pagination cursor returned by a previous list response.").optional(),
|
|
336
|
-
updatedAfter: external_exports.string().min(1).describe("An ISO 8601 datetime string accepted by Readwise.").optional(),
|
|
337
|
-
location: external_exports.enum(["new", "later", "shortlist", "archive", "feed"]).describe("The Reader location filter such as new, later, shortlist, archive, or feed.").optional(),
|
|
338
|
-
category: external_exports.string().min(1).describe("The Reader category filter such as article, email, rss, or pdf.").optional(),
|
|
339
|
-
tag: external_exports.string().min(1).describe("Only return documents with this tag.").optional()
|
|
340
|
-
}).describe("The input payload for listing Readwise Reader documents.");
|
|
341
|
-
var listDocumentsOutput = external_exports.strictObject({
|
|
342
|
-
count: external_exports.int().describe("The total number of matching documents when provided.").nullable().optional(),
|
|
343
|
-
nextPageCursor: external_exports.string().describe("The cursor to pass as pageCursor on the next request, or null when there are no more pages.").nullable().optional(),
|
|
344
|
-
documents: external_exports.array(external_exports.strictObject({
|
|
345
|
-
id: external_exports.string().describe("The Readwise Reader document identifier.").nullable().optional(),
|
|
346
|
-
url: external_exports.string().describe("The document URL.").nullable().optional(),
|
|
347
|
-
sourceUrl: external_exports.string().describe("The original source URL when Readwise returns it.").nullable().optional(),
|
|
348
|
-
title: external_exports.string().describe("The document title.").nullable().optional(),
|
|
349
|
-
author: external_exports.string().describe("The document author.").nullable().optional(),
|
|
350
|
-
category: external_exports.string().describe("The Reader category.").nullable().optional(),
|
|
351
|
-
location: external_exports.string().describe("The Reader location such as new, later, shortlist, archive, or feed.").nullable().optional(),
|
|
352
|
-
tags: external_exports.array(external_exports.string().describe("A Reader tag.")).describe("The document tags returned by Readwise.").optional(),
|
|
353
|
-
createdAt: external_exports.string().describe("The datetime when the document was created.").nullable().optional(),
|
|
354
|
-
updatedAt: external_exports.string().describe("The datetime when the document was last updated.").nullable().optional(),
|
|
355
|
-
raw: external_exports.looseObject({}).describe("The raw document object returned by Readwise.").optional()
|
|
356
|
-
}).describe("A normalized Readwise Reader document.")).describe("The Reader documents returned by Readwise.").optional(),
|
|
357
|
-
raw: external_exports.looseObject({}).describe("The raw list response returned by Readwise.").optional()
|
|
358
|
-
}).describe("The response returned when listing Readwise Reader documents.");
|
|
359
|
-
var saveDocumentInput = external_exports.strictObject({
|
|
360
|
-
url: external_exports.url().describe("The URL to save into Readwise Reader."),
|
|
361
|
-
title: external_exports.string().min(1).describe("An optional document title.").optional(),
|
|
362
|
-
author: external_exports.string().min(1).describe("An optional document author.").optional(),
|
|
363
|
-
summary: external_exports.string().min(1).describe("An optional document summary.").optional(),
|
|
364
|
-
shouldCleanHtml: external_exports.boolean().describe("Whether Readwise should clean the saved document HTML.").optional(),
|
|
365
|
-
savedUsing: external_exports.string().min(1).describe("A label describing the app or workflow that saved the document.").optional(),
|
|
366
|
-
tags: external_exports.array(external_exports.string().min(1).describe("A document tag.")).min(1).describe("Tags to attach to the saved document.").optional()
|
|
367
|
-
}).describe("The input payload for saving a Readwise Reader document.");
|
|
368
|
-
var saveDocumentOutput = external_exports.strictObject({
|
|
369
|
-
document: external_exports.strictObject({
|
|
370
|
-
id: external_exports.string().describe("The Readwise Reader document identifier.").nullable().optional(),
|
|
371
|
-
url: external_exports.string().describe("The document URL.").nullable().optional(),
|
|
372
|
-
sourceUrl: external_exports.string().describe("The original source URL when Readwise returns it.").nullable().optional(),
|
|
373
|
-
title: external_exports.string().describe("The document title.").nullable().optional(),
|
|
374
|
-
author: external_exports.string().describe("The document author.").nullable().optional(),
|
|
375
|
-
category: external_exports.string().describe("The Reader category.").nullable().optional(),
|
|
376
|
-
location: external_exports.string().describe("The Reader location such as new, later, shortlist, archive, or feed.").nullable().optional(),
|
|
377
|
-
tags: external_exports.array(external_exports.string().describe("A Reader tag.")).describe("The document tags returned by Readwise.").optional(),
|
|
378
|
-
createdAt: external_exports.string().describe("The datetime when the document was created.").nullable().optional(),
|
|
379
|
-
updatedAt: external_exports.string().describe("The datetime when the document was last updated.").nullable().optional(),
|
|
380
|
-
raw: external_exports.looseObject({}).describe("The raw document object returned by Readwise.").optional()
|
|
381
|
-
}).describe("A normalized Readwise Reader document.").optional(),
|
|
382
|
-
raw: external_exports.looseObject({}).describe("The raw save response returned by Readwise.").optional()
|
|
383
|
-
}).describe("The response returned after saving a Readwise Reader document.");
|
|
384
|
-
var updateDocumentInput = external_exports.strictObject({
|
|
385
|
-
documentId: external_exports.string().min(1).describe("The Readwise Reader document identifier."),
|
|
386
|
-
location: external_exports.enum(["new", "later", "shortlist", "archive", "feed"]).describe("The Reader location to apply to the document.").optional(),
|
|
387
|
-
title: external_exports.string().min(1).describe("The updated document title.").optional(),
|
|
388
|
-
author: external_exports.string().min(1).describe("The updated document author.").optional(),
|
|
389
|
-
summary: external_exports.string().min(1).describe("The updated document summary.").optional(),
|
|
390
|
-
tags: external_exports.array(external_exports.string().min(1).describe("A document tag.")).min(1).describe("The complete tag list to set on the document.").optional()
|
|
391
|
-
}).describe("The input payload for updating a Readwise Reader document.");
|
|
392
|
-
var updateDocumentOutput = external_exports.strictObject({
|
|
393
|
-
document: external_exports.strictObject({
|
|
394
|
-
id: external_exports.string().describe("The Readwise Reader document identifier.").nullable().optional(),
|
|
395
|
-
url: external_exports.string().describe("The document URL.").nullable().optional(),
|
|
396
|
-
sourceUrl: external_exports.string().describe("The original source URL when Readwise returns it.").nullable().optional(),
|
|
397
|
-
title: external_exports.string().describe("The document title.").nullable().optional(),
|
|
398
|
-
author: external_exports.string().describe("The document author.").nullable().optional(),
|
|
399
|
-
category: external_exports.string().describe("The Reader category.").nullable().optional(),
|
|
400
|
-
location: external_exports.string().describe("The Reader location such as new, later, shortlist, archive, or feed.").nullable().optional(),
|
|
401
|
-
tags: external_exports.array(external_exports.string().describe("A Reader tag.")).describe("The document tags returned by Readwise.").optional(),
|
|
402
|
-
createdAt: external_exports.string().describe("The datetime when the document was created.").nullable().optional(),
|
|
403
|
-
updatedAt: external_exports.string().describe("The datetime when the document was last updated.").nullable().optional(),
|
|
404
|
-
raw: external_exports.looseObject({}).describe("The raw document object returned by Readwise.").optional()
|
|
405
|
-
}).describe("A normalized Readwise Reader document.").optional(),
|
|
406
|
-
raw: external_exports.looseObject({}).describe("The raw update response returned by Readwise.").optional()
|
|
407
|
-
}).describe("The response returned after updating a Readwise Reader document.");
|
|
408
|
-
var readwiseActions = {
|
|
409
|
-
create_highlights: {
|
|
410
|
-
description: "Create one or more highlights in Readwise.",
|
|
411
|
-
effect: "write",
|
|
412
|
-
inputSchema: createHighlightsInput,
|
|
413
|
-
outputSchema: external_exports.toJSONSchema(createHighlightsOutput, { io: "output", unrepresentable: "any" })
|
|
414
|
-
},
|
|
415
|
-
export_highlights: {
|
|
416
|
-
description: "Export Readwise books and highlights updated after an optional date cursor.",
|
|
417
|
-
effect: "read",
|
|
418
|
-
inputSchema: exportHighlightsInput,
|
|
419
|
-
outputSchema: external_exports.toJSONSchema(exportHighlightsOutput, { io: "output", unrepresentable: "any" })
|
|
420
|
-
},
|
|
421
|
-
list_books: {
|
|
422
|
-
description: "List Readwise books or sources with optional category and update filters.",
|
|
423
|
-
effect: "read",
|
|
424
|
-
inputSchema: listBooksInput,
|
|
425
|
-
outputSchema: external_exports.toJSONSchema(listBooksOutput, { io: "output", unrepresentable: "any" })
|
|
426
|
-
},
|
|
427
|
-
list_documents: {
|
|
428
|
-
description: "List Readwise Reader documents with optional filters and pagination.",
|
|
429
|
-
effect: "read",
|
|
430
|
-
inputSchema: listDocumentsInput,
|
|
431
|
-
outputSchema: external_exports.toJSONSchema(listDocumentsOutput, { io: "output", unrepresentable: "any" })
|
|
432
|
-
},
|
|
433
|
-
save_document: {
|
|
434
|
-
description: "Save a URL into Readwise Reader with optional metadata.",
|
|
435
|
-
effect: "write",
|
|
436
|
-
inputSchema: saveDocumentInput,
|
|
437
|
-
outputSchema: external_exports.toJSONSchema(saveDocumentOutput, { io: "output", unrepresentable: "any" })
|
|
438
|
-
},
|
|
439
|
-
update_document: {
|
|
440
|
-
description: "Update the location, tags, or metadata for a Readwise Reader document.",
|
|
441
|
-
effect: "write",
|
|
442
|
-
inputSchema: updateDocumentInput,
|
|
443
|
-
outputSchema: external_exports.toJSONSchema(updateDocumentOutput, { io: "output", unrepresentable: "any" })
|
|
444
|
-
}
|
|
445
|
-
};
|
|
446
|
-
|
|
447
|
-
// ../plugins/src/readwise/index.ts
|
|
448
|
-
function createReadwisePlugin() {
|
|
449
|
-
return createProviderPlugin({
|
|
450
|
-
description: "Readwise",
|
|
451
|
-
actions: readwiseActions,
|
|
452
|
-
// 上游用 /v2/auth/ 验凭证,但那个端点没有对应的 action;list_books 是最接近的
|
|
453
|
-
// 只读、无必填入参的调用(export 会拉全量 highlight,更贵)。
|
|
454
|
-
credentialProbe: "list_books",
|
|
455
|
-
handlers: {
|
|
456
|
-
create_highlights: createHighlights,
|
|
457
|
-
export_highlights: exportHighlights,
|
|
458
|
-
list_books: listBooks,
|
|
459
|
-
list_documents: listDocuments,
|
|
460
|
-
save_document: saveDocument,
|
|
461
|
-
update_document: updateDocument
|
|
462
|
-
}
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
var readwise_default = createReadwisePlugin();
|
|
466
|
-
export {
|
|
467
|
-
createReadwisePlugin,
|
|
468
|
-
readwise_default as default
|
|
469
|
-
};
|