@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.
Files changed (115) hide show
  1. package/dist/{airtable-S3T4TAN7.js → airtable-NOSOMOVB.js} +106 -114
  2. package/dist/{alt_text_generator_ai-4DIRIDKL.js → alt_text_generator_ai-BHIJ4LW5.js} +25 -16
  3. package/dist/{amap-LGVGNPML.js → amap-QRLP4TWZ.js} +114 -123
  4. package/dist/{anthropic-27RFZO35.js → anthropic-IEOI36EV.js} +34 -56
  5. package/dist/{apify-6WLYAIAS.js → apify-3CCYTQVK.js} +31 -49
  6. package/dist/{brave_search-K2SVJ66F.js → brave_search-PZNYDQG7.js} +52 -77
  7. package/dist/chunk-JXHMDBAY.js +45 -0
  8. package/dist/chunk-LMLX3DJF.js +50 -0
  9. package/dist/{chunk-YB2FLNWI.js → chunk-RVWZN3CI.js} +2103 -1775
  10. package/dist/{chunk-BB6ZLMTU.js → chunk-TLNUIPFZ.js} +492 -300
  11. package/dist/chunk-U5UHT7CX.js +977 -0
  12. package/dist/chunk-U67V476Y.js +35 -0
  13. package/dist/chunk-WW2IMPQK.js +283 -0
  14. package/dist/{chunk-VK3V2WTY.js → chunk-YASUMV2K.js} +4 -6
  15. package/dist/{circleci-WV3ITU7Q.js → circleci-VSJ4O5FC.js} +36 -55
  16. package/dist/{clerk-NFQEFKS4.js → clerk-CC2JZBZI.js} +60 -80
  17. package/dist/{cloudflare_dns-2RK5ASBJ.js → cloudflare_dns-PJEBSEYQ.js} +90 -113
  18. package/dist/{cohere-5KEW7LWT.js → cohere-KBACYSPF.js} +33 -49
  19. package/dist/{confluence-SZE63S46.js → confluence-2PX3O7G5.js} +79 -115
  20. package/dist/{convertapi-QPG2JC5K.js → convertapi-BVOTD2PJ.js} +13 -16
  21. package/dist/{currencyapi-UO2APQRY.js → currencyapi-6ZQ2VNQ7.js} +30 -53
  22. package/dist/{deepseek-LJELIMM3.js → deepseek-MB3WVVTB.js} +30 -38
  23. package/dist/{docker_hub-2MFXSBOF.js → docker_hub-7CLQL2IJ.js} +141 -157
  24. package/dist/{dropbox-GQYNTTVA.js → dropbox-VFYDVUNK.js} +134 -141
  25. package/dist/{dub-KI2LHXST.js → dub-QN3EETJY.js} +61 -93
  26. package/dist/{e2b-WO6ISY3C.js → e2b-NKC3Y776.js} +39 -69
  27. package/dist/{exa-IZ7B3BPT.js → exa-KKZ6F25K.js} +49 -77
  28. package/dist/{fal_ai-LTMF36GJ.js → fal_ai-25LYJD2O.js} +37 -44
  29. package/dist/{feishu-WM7SLSFD.js → feishu-NRT55B3Q.js} +4 -6
  30. package/dist/{feishu_custom_bot-66W3MXH2.js → feishu_custom_bot-3W3XXUG4.js} +4 -5
  31. package/dist/{figma-2Z274VQZ.js → figma-4FLP35TC.js} +56 -81
  32. package/dist/{firehydrant-IFI4R65V.js → firehydrant-BLXPLZ3X.js} +40 -53
  33. package/dist/{fixer-BCCZEB3D.js → fixer-4OR62TGE.js} +31 -43
  34. package/dist/{fly-755FXYB5.js → fly-MYCKOZZK.js} +50 -66
  35. package/dist/{front-4FZKKXXK.js → front-3DFYVMF3.js} +43 -66
  36. package/dist/{geocodio-WYKDJ3DP.js → geocodio-CXMD6VKA.js} +37 -63
  37. package/dist/{ghost-5BNQTCOH.js → ghost-4UUE737W.js} +51 -57
  38. package/dist/{github-ULELF5VX.js → github-WFS2ON2N.js} +48 -41
  39. package/dist/{gmail-G34WT64J.js → gmail-KW7FXA7A.js} +26 -36
  40. package/dist/{googlecalendar-BQU255SC.js → googlecalendar-AMH5JQMC.js} +57 -78
  41. package/dist/{googledocs-HPCNQXYJ.js → googledocs-R5VA6CKD.js} +14 -22
  42. package/dist/{grafana-VOV24FIC.js → grafana-IT6DWIVB.js} +95 -122
  43. package/dist/{graphhopper-D5RXW6AP.js → graphhopper-TYFDJZWC.js} +32 -46
  44. package/dist/index.d.ts +57 -50
  45. package/dist/index.js +4 -3
  46. package/dist/{ip2proxy-DAYO7EKZ.js → ip2proxy-GJ4HXVXO.js} +35 -42
  47. package/dist/{ipgeolocation_io-XD4PSLII.js → ipgeolocation_io-OAGR6PRF.js} +40 -60
  48. package/dist/{ipqualityscore-K27QEAWK.js → ipqualityscore-BCKAMDGL.js} +30 -42
  49. package/dist/{jina_ai-E6UXFV2P.js → jina_ai-N3NXRVIZ.js} +32 -58
  50. package/dist/{jira-ZDSXGQ6W.js → jira-CHLBKWLO.js} +116 -126
  51. package/dist/{langsmith-TIFJRREW.js → langsmith-OIKOTPY3.js} +101 -121
  52. package/dist/{lemlist-DASEMJMA.js → lemlist-VAKYPKS3.js} +57 -68
  53. package/dist/{linear-KE6UP4SP.js → linear-Q6QTPJ5R.js} +109 -118
  54. package/dist/{logsnag-IMNDN4R5.js → logsnag-SQOQBTES.js} +31 -48
  55. package/dist/main.js +103 -102
  56. package/dist/{mattermost-HHHMUXQA.js → mattermost-G2KBEICM.js} +45 -62
  57. package/dist/{mem0-D2FGGOIY.js → mem0-D2FPLYDX.js} +72 -98
  58. package/dist/{memos-4OVIGFPH.js → memos-76PTWV5V.js} +68 -122
  59. package/dist/{metabase-33WCX5YD.js → metabase-TWSIDVBM.js} +47 -60
  60. package/dist/{mistral_ai-QIMZ2JYL.js → mistral_ai-TP7TQUEJ.js} +35 -40
  61. package/dist/{mother_duck-M6VWS2VH.js → mother_duck-UXY5THYU.js} +42 -62
  62. package/dist/{ngrok-Z2PKQBHH.js → ngrok-RZW2ISJK.js} +42 -58
  63. package/dist/{notes-SS4RPC4K.js → notes-B2I6FWK2.js} +3 -5
  64. package/dist/{notion-FJCNQ6I7.js → notion-QOKRUE6M.js} +83 -97
  65. package/dist/{open_exchange_rates-WU57WTT5.js → open_exchange_rates-ODLFWEJ7.js} +35 -39
  66. package/dist/{openai-JODZ4GKT.js → openai-ZPBPPPGT.js} +51 -55
  67. package/dist/{opengraph_io-SQRAUSV5.js → opengraph_io-EOI5UJKT.js} +61 -79
  68. package/dist/{openrouter-Q5XXEJZ7.js → openrouter-BUWLF3BG.js} +41 -55
  69. package/dist/{outline-RT2EHJ2X.js → outline-NXS3QRXO.js} +89 -104
  70. package/dist/{paddle-OF2V7GAC.js → paddle-T4MSKQ76.js} +34 -49
  71. package/dist/{perplexity-LNZEWLHG.js → perplexity-WW5N2LW7.js} +33 -50
  72. package/dist/{pinecone-JSJIXZYN.js → pinecone-RY5AZPQM.js} +65 -91
  73. package/dist/{pipedrive-D4CKVUXR.js → pipedrive-OHYQNZTU.js} +37 -59
  74. package/dist/{polar-M7ZYP6UR.js → polar-XZIAHXS5.js} +43 -53
  75. package/dist/{posthog-YV7CZOH4.js → posthog-DTPTWORY.js} +58 -77
  76. package/dist/{postmark-KYHLECRG.js → postmark-F4UCQKC3.js} +52 -71
  77. package/dist/{prerender-HCMHBKV2.js → prerender-P3Y2MLIC.js} +32 -50
  78. package/dist/{pubmed-WYVLCCN3.js → pubmed-RHU3GXFB.js} +28 -60
  79. package/dist/{railway-TWIRD5KR.js → railway-VB6SRLI6.js} +32 -39
  80. package/dist/{readwise-UZ467IQ7.js → readwise-DIMSKJZR.js} +62 -78
  81. package/dist/{render-MECUC5CC.js → render-XCCDCEEK.js} +48 -64
  82. package/dist/{replicate-A5MEK3SW.js → replicate-IUEOQ4JC.js} +41 -58
  83. package/dist/{resend-BC6EAWJQ.js → resend-N5MJZH5E.js} +27 -37
  84. package/dist/{rootly-ZM3QDUIS.js → rootly-25T4NBTU.js} +64 -76
  85. package/dist/{scrapfly-WAML42QJ.js → scrapfly-PK4XFXUA.js} +45 -51
  86. package/dist/{scrapingbee-DG7PET3V.js → scrapingbee-ITPBMWQU.js} +25 -33
  87. package/dist/{screenshot_fyi-HY6WTHIO.js → screenshot_fyi-5U6ZYPKR.js} +29 -47
  88. package/dist/{semantic_scholar-C5IZA7IP.js → semantic_scholar-BJGCI2MU.js} +37 -56
  89. package/dist/{sentry-OKBPSTDM.js → sentry-63IC263P.js} +66 -85
  90. package/dist/{shodan-PPC6DYU4.js → shodan-2WBIFHFN.js} +42 -53
  91. package/dist/{shopify-EWGUHBXO.js → shopify-XLLJRAGM.js} +32 -49
  92. package/dist/{stripe-6RPDPC5W.js → stripe-WLVCY3UN.js} +4 -5
  93. package/dist/{supabase-SK7DQ42N.js → supabase-BKNZ35ER.js} +69 -88
  94. package/dist/{tavily-YCG5VQMH.js → tavily-YFSDEUTL.js} +37 -62
  95. package/dist/{telegram-2OES5FYB.js → telegram-FC35W74G.js} +168 -177
  96. package/dist/{telnyx-POOSBBR4.js → telnyx-MI32XZUG.js} +30 -50
  97. package/dist/{todoist-M7YD6YSS.js → todoist-4ZFJKZC6.js} +77 -89
  98. package/dist/{trello-IS6V5W3E.js → trello-UOGFNMK4.js} +108 -122
  99. package/dist/{turso-RCFHUFVH.js → turso-YTSTW3ZS.js} +52 -64
  100. package/dist/{twilio-OS2RXFGO.js → twilio-XAJDFUQH.js} +48 -55
  101. package/dist/{umami-PQ2SJ2LN.js → umami-ZVIUBPAI.js} +49 -69
  102. package/dist/{unsplash-C6BPZO4E.js → unsplash-IU3PLDNS.js} +35 -52
  103. package/dist/{upstash_redis-WH6UER7H.js → upstash_redis-3EYJW7SY.js} +28 -40
  104. package/dist/{uptimerobot-M3YZGS6Z.js → uptimerobot-PJG2ASRU.js} +11 -12
  105. package/dist/{v2ex-R4JWTEHN.js → v2ex-KFQWWGFC.js} +36 -61
  106. package/dist/{vercel-FZVYUOQD.js → vercel-I2ZDOQRL.js} +124 -150
  107. package/dist/{webapi-VLM4IKVB.js → webapi-GW5QXWXE.js} +1 -1
  108. package/dist/{wolfram_alpha_api-2KOLO5DC.js → wolfram_alpha_api-BNXOJMB6.js} +26 -34
  109. package/dist/{wordpress-XRWGO6LG.js → wordpress-36D7BSMP.js} +87 -104
  110. package/dist/{workos-WR4NKOYL.js → workos-6X4JJRRC.js} +37 -56
  111. package/dist/{zhihu-BKZIB3WA.js → zhihu-CIXKCHIU.js} +35 -57
  112. package/package.json +5 -5
  113. package/dist/chunk-2O27H4Y2.js +0 -183
  114. package/dist/chunk-GKX72JMJ.js +0 -378
  115. package/dist/chunk-MLKGABMK.js +0 -9
@@ -1,55 +1,49 @@
1
+ import {
2
+ createProviderHttpClient
3
+ } from "./chunk-WW2IMPQK.js";
4
+ import {
5
+ asJsonObject,
6
+ booleanValue,
7
+ compactDefined,
8
+ trimmedText
9
+ } from "./chunk-JXHMDBAY.js";
1
10
  import {
2
11
  createProviderPlugin,
3
12
  requireCredential,
4
13
  upstreamError
5
- } from "./chunk-VK3V2WTY.js";
6
- import {
7
- guardedFetch
8
- } from "./chunk-2O27H4Y2.js";
9
- import "./chunk-GKX72JMJ.js";
14
+ } from "./chunk-YASUMV2K.js";
15
+ import "./chunk-U5UHT7CX.js";
10
16
  import {
11
17
  TBError,
12
18
  external_exports
13
- } from "./chunk-YB2FLNWI.js";
14
- import "./chunk-MLKGABMK.js";
19
+ } from "./chunk-RVWZN3CI.js";
20
+ import "./chunk-U67V476Y.js";
15
21
 
16
22
  // ../plugins/src/trello/api.ts
17
23
  var SERVICE = "trello";
18
24
  var API_BASE = "https://api.trello.com/1";
25
+ var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
19
26
  var DEFAULT_MEMBER_FIELDS = ["id", "username", "fullName"];
20
27
  var DEFAULT_BOARD_FIELDS = ["name", "desc", "url", "shortUrl", "closed"];
21
28
  var DEFAULT_CARD_FIELDS = ["name", "desc", "url", "shortUrl", "closed", "due", "dueComplete", "idBoard", "idList"];
22
29
  var AUTH_HINTS = {
23
- "invalid key": "Trello API key \u65E0\u6548:\u7528 https://trello.com/power-ups/admin \u4E0A Key \u4E00\u680F\u7684\u503C,\u4E0D\u662F API Secret,\u4E5F\u4E0D\u662F Atlassian API token",
24
- "invalid token": "Trello API token \u65E0\u6548:\u5728 https://trello.com/power-ups/admin \u4E0A API Key \u65C1\u8FB9\u7684 Token \u94FE\u63A5\u91CC\u751F\u6210"
30
+ // 不带 scheme:provider HTTP 边界会统一抹掉错误里的完整 URL,避免上游响应携密 URL 泄漏。
31
+ "invalid key": "Trello API key \u65E0\u6548:\u7528 trello.com/power-ups/admin \u4E0A Key \u4E00\u680F\u7684\u503C,\u4E0D\u662F API Secret,\u4E5F\u4E0D\u662F Atlassian API token",
32
+ "invalid token": "Trello API token \u65E0\u6548:\u5728 trello.com/power-ups/admin \u4E0A API Key \u65C1\u8FB9\u7684 Token \u94FE\u63A5\u91CC\u751F\u6210"
25
33
  };
26
- function text(value) {
27
- if (typeof value !== "string") return void 0;
28
- const trimmed = value.trim();
29
- return trimmed === "" ? void 0 : trimmed;
30
- }
31
- function record(value) {
32
- return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
33
- }
34
34
  function number(value) {
35
35
  return typeof value === "number" ? value : void 0;
36
36
  }
37
- function boolean(value) {
38
- return typeof value === "boolean" ? value : void 0;
39
- }
40
37
  function nullableText(value) {
41
- return value === null ? null : text(value);
42
- }
43
- function compact(input) {
44
- return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0));
38
+ return value === null ? null : trimmedText(value);
45
39
  }
46
40
  function requireInput(value, field) {
47
- const result = text(value);
41
+ const result = trimmedText(value);
48
42
  if (result === void 0) throw new TBError("invalid_argument", `${field} \u662F\u5FC5\u586B\u7684`);
49
43
  return result;
50
44
  }
51
45
  function requireRecord(value, label) {
52
- const result = record(value);
46
+ const result = asJsonObject(value);
53
47
  if (result === void 0) throw new TBError("unavailable", `${label}\u4E0D\u662F\u5BF9\u8C61`, { retryable: true });
54
48
  return result;
55
49
  }
@@ -68,140 +62,132 @@ function idList(value, field) {
68
62
  if (value === void 0) return void 0;
69
63
  return value.map((item) => requireInput(item, field)).join(",");
70
64
  }
71
- function errorMessage(response, body) {
72
- const fallback = response.statusText !== "" ? response.statusText : `HTTP ${response.status}`;
73
- if (!(response.headers.get("content-type") ?? "").includes("application/json")) {
74
- return body === "" ? fallback : body;
75
- }
76
- let payload;
77
- try {
78
- payload = JSON.parse(body);
79
- } catch {
80
- return fallback;
65
+ function errorMessage(context) {
66
+ const fallback = context.statusText !== "" ? context.statusText : `HTTP ${context.status}`;
67
+ if (!(context.headers.get("content-type") ?? "").includes("application/json")) {
68
+ if (context.bodyKind === "empty") return fallback;
69
+ if (context.bodyKind === "invalid-json" || context.bodyKind === "text") {
70
+ return trimmedText(context.data) ?? fallback;
71
+ }
72
+ return JSON.stringify(context.data) ?? fallback;
81
73
  }
82
- if (typeof payload === "string") return text(payload) ?? fallback;
83
- const error = record(payload);
84
- return text(error?.message) ?? text(error?.error) ?? text(error?.detail) ?? fallback;
74
+ if (context.bodyKind !== "json") return fallback;
75
+ if (typeof context.data === "string") return trimmedText(context.data) ?? fallback;
76
+ const error = asJsonObject(context.data);
77
+ return trimmedText(error?.message) ?? trimmedText(error?.error) ?? trimmedText(error?.detail) ?? fallback;
85
78
  }
86
79
  async function request(ctx, input) {
87
- const url = new URL(`${API_BASE}${input.path}`);
88
- url.searchParams.set("key", requireCredential(ctx, SERVICE, "apiKey"));
89
- url.searchParams.set("token", requireCredential(ctx, SERVICE, "apiToken"));
90
- for (const [key, value] of input.query ?? []) {
91
- if (value === void 0 || value === null) continue;
92
- url.searchParams.set(key, String(value));
93
- }
80
+ const query = [
81
+ ["key", requireCredential(ctx, SERVICE, "apiKey")],
82
+ ["token", requireCredential(ctx, SERVICE, "apiToken")],
83
+ ...input.query ?? []
84
+ ];
94
85
  const hasBody = input.body !== void 0;
95
- const headers = { accept: "application/json" };
96
- if (hasBody) headers["content-type"] = "application/json";
97
- const response = await guardedFetch(url.toString(), {
86
+ const { data } = await http.request({
87
+ path: input.path,
98
88
  method: input.method ?? "GET",
99
- headers,
100
- body: hasBody ? JSON.stringify(input.body) : void 0
89
+ query,
90
+ headers: { accept: "application/json" },
91
+ ...hasBody ? { json: input.body } : {},
92
+ invalidJsonMessage: "Trello \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
93
+ mapError: (context) => {
94
+ const message = errorMessage(context);
95
+ return upstreamError(context.status, AUTH_HINTS[message] ?? message);
96
+ }
101
97
  });
102
- const body = await response.text().catch(() => "");
103
- if (!response.ok) {
104
- const message = errorMessage(response, body);
105
- throw upstreamError(response.status, AUTH_HINTS[message] ?? message);
106
- }
107
- if (response.status === 204 || body === "") return void 0;
108
- try {
109
- return JSON.parse(body);
110
- } catch {
111
- throw new TBError("unavailable", "Trello \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94", { retryable: true });
112
- }
98
+ return data;
113
99
  }
114
100
  function normalizeMember(payload) {
115
101
  const member = requireRecord(payload, "Trello \u6210\u5458");
116
- return compact({
117
- id: text(member.id),
118
- username: text(member.username),
119
- fullName: text(member.fullName)
102
+ return compactDefined({
103
+ id: trimmedText(member.id),
104
+ username: trimmedText(member.username),
105
+ fullName: trimmedText(member.fullName)
120
106
  });
121
107
  }
122
108
  function normalizeBoard(payload) {
123
109
  const board = requireRecord(payload, "Trello \u770B\u677F");
124
- return compact({
125
- id: text(board.id),
126
- name: text(board.name),
127
- description: text(board.desc),
128
- url: text(board.url),
129
- shortUrl: text(board.shortUrl),
130
- closed: boolean(board.closed)
110
+ return compactDefined({
111
+ id: trimmedText(board.id),
112
+ name: trimmedText(board.name),
113
+ description: trimmedText(board.desc),
114
+ url: trimmedText(board.url),
115
+ shortUrl: trimmedText(board.shortUrl),
116
+ closed: booleanValue(board.closed)
131
117
  });
132
118
  }
133
119
  function normalizeList(payload) {
134
120
  const list = requireRecord(payload, "Trello \u5217\u8868");
135
- return compact({
136
- id: text(list.id),
137
- boardId: text(list.idBoard),
138
- name: text(list.name),
139
- closed: boolean(list.closed),
121
+ return compactDefined({
122
+ id: trimmedText(list.id),
123
+ boardId: trimmedText(list.idBoard),
124
+ name: trimmedText(list.name),
125
+ closed: booleanValue(list.closed),
140
126
  position: number(list.pos)
141
127
  });
142
128
  }
143
129
  function normalizeCard(payload) {
144
130
  const card = requireRecord(payload, "Trello \u5361\u7247");
145
- return compact({
146
- id: text(card.id),
147
- boardId: text(card.idBoard),
148
- listId: text(card.idList),
149
- name: text(card.name),
150
- description: text(card.desc),
151
- url: text(card.url),
152
- shortUrl: text(card.shortUrl),
153
- closed: boolean(card.closed),
131
+ return compactDefined({
132
+ id: trimmedText(card.id),
133
+ boardId: trimmedText(card.idBoard),
134
+ listId: trimmedText(card.idList),
135
+ name: trimmedText(card.name),
136
+ description: trimmedText(card.desc),
137
+ url: trimmedText(card.url),
138
+ shortUrl: trimmedText(card.shortUrl),
139
+ closed: booleanValue(card.closed),
154
140
  due: nullableText(card.due),
155
- dueComplete: boolean(card.dueComplete)
141
+ dueComplete: booleanValue(card.dueComplete)
156
142
  });
157
143
  }
158
144
  function normalizeAction(payload) {
159
145
  const action = requireRecord(payload, "Trello \u52A8\u4F5C");
160
- return compact({
161
- id: text(action.id),
162
- type: text(action.type),
163
- data: record(action.data),
164
- date: text(action.date)
146
+ return compactDefined({
147
+ id: trimmedText(action.id),
148
+ type: trimmedText(action.type),
149
+ data: asJsonObject(action.data),
150
+ date: trimmedText(action.date)
165
151
  });
166
152
  }
167
153
  function normalizeCheckItem(payload) {
168
154
  const item = requireRecord(payload, "Trello \u68C0\u67E5\u9879");
169
- return compact({
170
- id: text(item.id),
171
- name: text(item.name),
172
- state: text(item.state),
155
+ return compactDefined({
156
+ id: trimmedText(item.id),
157
+ name: trimmedText(item.name),
158
+ state: trimmedText(item.state),
173
159
  position: number(item.pos)
174
160
  });
175
161
  }
176
162
  function normalizeChecklist(payload) {
177
163
  const checklist = requireRecord(payload, "Trello \u6E05\u5355");
178
164
  const items = checklist.checkItems;
179
- return compact({
180
- id: text(checklist.id),
181
- cardId: text(checklist.idCard),
182
- name: text(checklist.name),
165
+ return compactDefined({
166
+ id: trimmedText(checklist.id),
167
+ cardId: trimmedText(checklist.idCard),
168
+ name: trimmedText(checklist.name),
183
169
  checkItems: Array.isArray(items) ? items.map((item) => normalizeCheckItem(item)) : void 0
184
170
  });
185
171
  }
186
172
  function normalizeAttachment(payload) {
187
173
  const attachment = requireRecord(payload, "Trello \u9644\u4EF6");
188
- return compact({
189
- id: text(attachment.id),
190
- name: text(attachment.name),
191
- url: text(attachment.url),
174
+ return compactDefined({
175
+ id: trimmedText(attachment.id),
176
+ name: trimmedText(attachment.name),
177
+ url: trimmedText(attachment.url),
192
178
  // bytes 的 null 是"未知大小",与字段缺席不同。
193
179
  bytes: attachment.bytes === null ? null : number(attachment.bytes),
194
- date: text(attachment.date)
180
+ date: trimmedText(attachment.date)
195
181
  });
196
182
  }
197
183
  function cardBody(input, mode) {
198
184
  const updates = input;
199
- const body = compact({
200
- idList: mode === "create" ? requireInput(input.listId, "listId") : text(input.listId),
201
- name: text(input.name),
202
- desc: text(input.description),
185
+ const body = compactDefined({
186
+ idList: mode === "create" ? requireInput(input.listId, "listId") : trimmedText(input.listId),
187
+ name: trimmedText(input.name),
188
+ desc: trimmedText(input.description),
203
189
  // due 的 null 要原样发下去:那是"清掉截止日期"的表达。
204
- due: input.due === null ? null : text(input.due),
190
+ due: input.due === null ? null : trimmedText(input.due),
205
191
  pos: position(input.position),
206
192
  idMembers: idList(input.memberIds, "memberIds"),
207
193
  idLabels: idList(input.labelIds, "labelIds"),
@@ -214,7 +200,7 @@ function cardBody(input, mode) {
214
200
  return body;
215
201
  }
216
202
  async function getMember(input, ctx) {
217
- const memberId = text(input.memberId) ?? "me";
203
+ const memberId = trimmedText(input.memberId) ?? "me";
218
204
  const payload = await request(ctx, {
219
205
  path: `/members/${encodeURIComponent(memberId)}`,
220
206
  query: [["fields", fields(input.fields, DEFAULT_MEMBER_FIELDS)]]
@@ -222,7 +208,7 @@ async function getMember(input, ctx) {
222
208
  return { member: normalizeMember(payload) };
223
209
  }
224
210
  async function listMemberBoards(input, ctx) {
225
- const memberId = text(input.memberId) ?? "me";
211
+ const memberId = trimmedText(input.memberId) ?? "me";
226
212
  const payload = await request(ctx, {
227
213
  path: `/members/${encodeURIComponent(memberId)}/boards`,
228
214
  query: [
@@ -243,9 +229,9 @@ async function createBoard(input, ctx) {
243
229
  const payload = await request(ctx, {
244
230
  method: "POST",
245
231
  path: "/boards",
246
- body: compact({
232
+ body: compactDefined({
247
233
  name: requireInput(input.name, "name"),
248
- desc: text(input.description),
234
+ desc: trimmedText(input.description),
249
235
  defaultLists: input.defaultLists,
250
236
  // 可见性在 Trello 的建板接口里叫 prefs_permissionLevel,不是 permissionLevel。
251
237
  prefs_permissionLevel: input.permissionLevel
@@ -264,7 +250,7 @@ async function createList(input, ctx) {
264
250
  const payload = await request(ctx, {
265
251
  method: "POST",
266
252
  path: "/lists",
267
- body: compact({
253
+ body: compactDefined({
268
254
  idBoard: requireInput(input.boardId, "boardId"),
269
255
  name: requireInput(input.name, "name"),
270
256
  pos: position(input.position)
@@ -273,8 +259,8 @@ async function createList(input, ctx) {
273
259
  return { list: normalizeList(payload) };
274
260
  }
275
261
  async function updateList(input, ctx) {
276
- const body = compact({
277
- name: text(input.name),
262
+ const body = compactDefined({
263
+ name: trimmedText(input.name),
278
264
  pos: position(input.position)
279
265
  });
280
266
  if (Object.keys(body).length === 0) {
@@ -332,7 +318,7 @@ async function moveCard(input, ctx) {
332
318
  const payload = await request(ctx, {
333
319
  method: "PUT",
334
320
  path: `/cards/${encodeURIComponent(requireInput(input.cardId, "cardId"))}`,
335
- body: compact({
321
+ body: compactDefined({
336
322
  idList: requireInput(input.listId, "listId"),
337
323
  pos: position(input.position)
338
324
  })
@@ -426,7 +412,7 @@ async function addCheckitem(input, ctx) {
426
412
  const payload = await request(ctx, {
427
413
  method: "POST",
428
414
  path: `/checklists/${encodeURIComponent(requireInput(input.checklistId, "checklistId"))}/checkItems`,
429
- body: compact({
415
+ body: compactDefined({
430
416
  name: requireInput(input.name, "name"),
431
417
  pos: position(input.position),
432
418
  checked: input.checked
@@ -449,9 +435,9 @@ async function addCardAttachmentUrl(input, ctx) {
449
435
  const payload = await request(ctx, {
450
436
  method: "POST",
451
437
  path: `/cards/${encodeURIComponent(requireInput(input.cardId, "cardId"))}/attachments`,
452
- body: compact({
438
+ body: compactDefined({
453
439
  url: requireInput(input.url, "url"),
454
- name: text(input.name)
440
+ name: trimmedText(input.name)
455
441
  })
456
442
  });
457
443
  return { attachment: normalizeAttachment(payload) };
@@ -1,62 +1,57 @@
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-VK3V2WTY.js";
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-YB2FLNWI.js";
14
- import "./chunk-MLKGABMK.js";
18
+ } from "./chunk-RVWZN3CI.js";
19
+ import "./chunk-U67V476Y.js";
15
20
 
16
21
  // ../plugins/src/turso/api.ts
17
22
  var SERVICE = "turso";
18
23
  var API_BASE = "https://api.turso.tech";
19
- function record(value) {
20
- return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
21
- }
22
- function text(value) {
23
- if (typeof value !== "string") return void 0;
24
- const trimmed = value.trim();
25
- return trimmed === "" ? void 0 : trimmed;
26
- }
24
+ var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
27
25
  function requireText(value, field) {
28
- const result = text(value);
26
+ const result = trimmedText(value);
29
27
  if (result === void 0) throw new TBError("invalid_argument", `${field} is required.`);
30
28
  return result;
31
29
  }
32
- function compact(input) {
33
- return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0));
34
- }
35
30
  function responseError(message) {
36
31
  return new TBError("unavailable", message, { retryable: true });
37
32
  }
38
33
  function normalizeResource(raw) {
39
- return compact({
40
- slug: text(raw.slug),
41
- name: text(raw.name),
42
- type: text(raw.type),
43
- location: text(raw.location),
44
- uuid: text(raw.uuid),
45
- group: text(raw.group),
46
- hostname: text(raw.hostname),
47
- code: text(raw.code),
34
+ return compactDefined({
35
+ slug: trimmedText(raw.slug),
36
+ name: trimmedText(raw.name),
37
+ type: trimmedText(raw.type),
38
+ location: trimmedText(raw.location),
39
+ uuid: trimmedText(raw.uuid),
40
+ group: trimmedText(raw.group),
41
+ hostname: trimmedText(raw.hostname),
42
+ code: trimmedText(raw.code),
48
43
  raw
49
44
  });
50
45
  }
51
46
  function normalizeItems(items) {
52
47
  return items.flatMap((item) => {
53
- const fields = record(item);
48
+ const fields = asJsonObject(item);
54
49
  return fields === void 0 ? [] : [normalizeResource(fields)];
55
50
  });
56
51
  }
57
52
  function resourceList(payload, keys) {
58
53
  if (Array.isArray(payload)) return normalizeItems(payload);
59
- const fields = record(payload);
54
+ const fields = asJsonObject(payload);
60
55
  if (fields === void 0) throw responseError("Turso returned an invalid list response");
61
56
  for (const key of [...keys, "data"]) {
62
57
  const value = fields[key];
@@ -65,51 +60,44 @@ function resourceList(payload, keys) {
65
60
  throw responseError("Turso list response is missing items");
66
61
  }
67
62
  function singleResource(payload, keys) {
68
- const fields = record(payload);
63
+ const fields = asJsonObject(payload);
69
64
  if (fields === void 0) throw responseError("Turso returned an invalid resource response");
70
65
  for (const key of [...keys, "data"]) {
71
- const value = record(fields[key]);
66
+ const value = asJsonObject(fields[key]);
72
67
  if (value !== void 0) return normalizeResource(value);
73
68
  }
74
69
  return normalizeResource(fields);
75
70
  }
76
- function readPayload(body) {
77
- if (body.trim() === "") return {};
78
- try {
79
- return JSON.parse(body);
80
- } catch {
81
- return { message: body };
82
- }
83
- }
84
71
  function errorMessage(payload, status) {
85
- const direct = text(payload);
72
+ const direct = trimmedText(payload);
86
73
  if (direct !== void 0) return direct;
87
- const fields = record(payload);
88
- const nested = record(fields?.error);
89
- const message = text(fields?.message) ?? text(fields?.error) ?? text(fields?.detail) ?? text(fields?.title) ?? text(nested?.message) ?? text(nested?.detail);
74
+ const fields = asJsonObject(payload);
75
+ const nested = asJsonObject(fields?.error);
76
+ const message = trimmedText(fields?.message) ?? trimmedText(fields?.error) ?? trimmedText(fields?.detail) ?? trimmedText(fields?.title) ?? trimmedText(nested?.message) ?? trimmedText(nested?.detail);
90
77
  return message ?? `Turso request failed with ${status}`;
91
78
  }
92
79
  async function request(ctx, input) {
93
80
  const apiKey = requireApiKey(ctx, SERVICE);
94
- let response;
95
- let payload;
96
- try {
97
- response = await guardedFetch(`${API_BASE}${input.path}`, {
98
- method: input.method,
99
- headers: {
100
- accept: "application/json",
101
- authorization: `Bearer ${apiKey}`,
102
- ...input.body === void 0 ? {} : { "content-type": "application/json" }
103
- },
104
- body: input.body === void 0 ? void 0 : JSON.stringify(input.body)
105
- });
106
- payload = readPayload(await response.text());
107
- } catch (error) {
108
- if (error instanceof TBError) throw error;
109
- throw upstreamError(502, error instanceof Error ? `Turso request failed: ${error.message}` : "Turso request failed");
110
- }
111
- if (!response.ok) throw upstreamError(response.status, errorMessage(payload, response.status));
112
- return payload;
81
+ const response = await http.request({
82
+ method: input.method,
83
+ path: input.path,
84
+ headers: {
85
+ accept: "application/json",
86
+ authorization: `Bearer ${apiKey}`
87
+ },
88
+ ...input.body === void 0 ? {} : { json: input.body },
89
+ invalidJson: "text",
90
+ mapError: ({ bodyKind, data, status }) => upstreamError(
91
+ status,
92
+ errorMessage(bodyKind === "empty" ? {} : bodyKind === "json" ? data : { message: data }, status)
93
+ ),
94
+ mapTransportError: ({ message }) => upstreamError(
95
+ 502,
96
+ message === void 0 ? "Turso request failed" : `Turso request failed: ${message}`
97
+ )
98
+ });
99
+ if (response.bodyKind === "empty") return {};
100
+ return response.bodyKind === "json" ? response.data : { message: response.data };
113
101
  }
114
102
  function organizationPath(organizationSlug) {
115
103
  return `/v1/organizations/${encodeURIComponent(requireText(organizationSlug, "organizationSlug"))}`;
@@ -146,7 +134,7 @@ async function createGroup(input, ctx) {
146
134
  const payload = await request(ctx, {
147
135
  method: "POST",
148
136
  path: `${organizationPath(input.organizationSlug)}/groups`,
149
- body: compact({
137
+ body: compactDefined({
150
138
  name: requireText(input.name, "name"),
151
139
  location: requireText(input.location, "location"),
152
140
  extensions: extensions(input.extensions)