@tool-bridge/server 0.16.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/{airtable-S3T4TAN7.js → airtable-23JBIM6X.js} +106 -114
  2. package/dist/{alt_text_generator_ai-4DIRIDKL.js → alt_text_generator_ai-ADWBTCIH.js} +25 -16
  3. package/dist/{amap-LGVGNPML.js → amap-CYQCYW2Z.js} +114 -123
  4. package/dist/{anthropic-27RFZO35.js → anthropic-5P62HDNR.js} +34 -56
  5. package/dist/{apify-6WLYAIAS.js → apify-54RZUAGW.js} +31 -49
  6. package/dist/{brave_search-K2SVJ66F.js → brave_search-AHJ6FTD5.js} +52 -77
  7. package/dist/{chunk-VK3V2WTY.js → chunk-B4P6YZFS.js} +4 -6
  8. package/dist/{chunk-BB6ZLMTU.js → chunk-CLEZ6YQ6.js} +2600 -481
  9. package/dist/chunk-JXHMDBAY.js +45 -0
  10. package/dist/chunk-LMLX3DJF.js +50 -0
  11. package/dist/{chunk-YB2FLNWI.js → chunk-OKRZPQ3R.js} +2558 -1926
  12. package/dist/chunk-SWBNHIO4.js +977 -0
  13. package/dist/chunk-U67V476Y.js +35 -0
  14. package/dist/chunk-VLOIDU5U.js +283 -0
  15. package/dist/{circleci-WV3ITU7Q.js → circleci-UM3NSQJ3.js} +36 -55
  16. package/dist/{clerk-NFQEFKS4.js → clerk-FE5LQ2CZ.js} +60 -80
  17. package/dist/{cloudflare_dns-2RK5ASBJ.js → cloudflare_dns-KEZABKUT.js} +90 -113
  18. package/dist/{cohere-5KEW7LWT.js → cohere-4IPJADXP.js} +33 -49
  19. package/dist/{confluence-SZE63S46.js → confluence-56QEKNQI.js} +79 -115
  20. package/dist/{convertapi-QPG2JC5K.js → convertapi-3QRM5K5T.js} +13 -16
  21. package/dist/{currencyapi-UO2APQRY.js → currencyapi-L6G4OND5.js} +30 -53
  22. package/dist/{deepseek-LJELIMM3.js → deepseek-LGC6HBFG.js} +30 -38
  23. package/dist/{docker_hub-2MFXSBOF.js → docker_hub-XDMK3BIU.js} +141 -157
  24. package/dist/{dropbox-GQYNTTVA.js → dropbox-4QARMFZU.js} +134 -141
  25. package/dist/{dub-KI2LHXST.js → dub-C6JSJKOT.js} +61 -93
  26. package/dist/{e2b-WO6ISY3C.js → e2b-6A6TVACJ.js} +39 -69
  27. package/dist/{exa-IZ7B3BPT.js → exa-SIWWW6AA.js} +49 -77
  28. package/dist/{fal_ai-LTMF36GJ.js → fal_ai-3IJXOKSP.js} +37 -44
  29. package/dist/{feishu-WM7SLSFD.js → feishu-L4KDA4DC.js} +4 -6
  30. package/dist/{feishu_custom_bot-66W3MXH2.js → feishu_custom_bot-SDM75H4P.js} +4 -5
  31. package/dist/{figma-2Z274VQZ.js → figma-6DD436DN.js} +56 -81
  32. package/dist/{firehydrant-IFI4R65V.js → firehydrant-SYSGYB3R.js} +40 -53
  33. package/dist/{fixer-BCCZEB3D.js → fixer-FZG7ASTF.js} +31 -43
  34. package/dist/{fly-755FXYB5.js → fly-HMRCZBUC.js} +50 -66
  35. package/dist/{front-4FZKKXXK.js → front-FAFSD7I3.js} +43 -66
  36. package/dist/{geocodio-WYKDJ3DP.js → geocodio-4D3TWENM.js} +37 -63
  37. package/dist/{ghost-5BNQTCOH.js → ghost-OSO2FOZS.js} +51 -57
  38. package/dist/{github-ULELF5VX.js → github-OR4I4RHE.js} +48 -41
  39. package/dist/{gmail-G34WT64J.js → gmail-5AOPJ63E.js} +26 -36
  40. package/dist/{googlecalendar-BQU255SC.js → googlecalendar-SOJIJUWH.js} +57 -78
  41. package/dist/{googledocs-HPCNQXYJ.js → googledocs-QSKN5TLN.js} +14 -22
  42. package/dist/{grafana-VOV24FIC.js → grafana-R3AIZM7M.js} +95 -122
  43. package/dist/{graphhopper-D5RXW6AP.js → graphhopper-4CR3QOAX.js} +32 -46
  44. package/dist/index.d.ts +108 -56
  45. package/dist/index.js +4 -3
  46. package/dist/{ip2proxy-DAYO7EKZ.js → ip2proxy-OBCG6X6J.js} +35 -42
  47. package/dist/{ipgeolocation_io-XD4PSLII.js → ipgeolocation_io-NHH3DTQW.js} +40 -60
  48. package/dist/{ipqualityscore-K27QEAWK.js → ipqualityscore-7POMCBEC.js} +30 -42
  49. package/dist/{jina_ai-E6UXFV2P.js → jina_ai-YXVKROV4.js} +32 -58
  50. package/dist/{jira-ZDSXGQ6W.js → jira-LADO3VJU.js} +116 -126
  51. package/dist/{langsmith-TIFJRREW.js → langsmith-XZ6UAQFU.js} +101 -121
  52. package/dist/{lemlist-DASEMJMA.js → lemlist-P74GLNE7.js} +57 -68
  53. package/dist/{linear-KE6UP4SP.js → linear-CXJ7D37A.js} +109 -118
  54. package/dist/{logsnag-IMNDN4R5.js → logsnag-EVVHWFLK.js} +31 -48
  55. package/dist/main.js +103 -102
  56. package/dist/{mattermost-HHHMUXQA.js → mattermost-WG2MRGBD.js} +45 -62
  57. package/dist/{mem0-D2FGGOIY.js → mem0-HQWUKG6U.js} +72 -98
  58. package/dist/{memos-4OVIGFPH.js → memos-SQMJIFOE.js} +68 -122
  59. package/dist/{metabase-33WCX5YD.js → metabase-E27G2DZI.js} +47 -60
  60. package/dist/{mistral_ai-QIMZ2JYL.js → mistral_ai-MIL63NIT.js} +35 -40
  61. package/dist/{mother_duck-M6VWS2VH.js → mother_duck-AIZVCBNR.js} +42 -62
  62. package/dist/{ngrok-Z2PKQBHH.js → ngrok-XS4DVIQS.js} +42 -58
  63. package/dist/{notes-SS4RPC4K.js → notes-JEOUSL2Y.js} +3 -5
  64. package/dist/{notion-FJCNQ6I7.js → notion-U4EZVDW2.js} +83 -97
  65. package/dist/{open_exchange_rates-WU57WTT5.js → open_exchange_rates-AZSQEYEJ.js} +35 -39
  66. package/dist/{openai-JODZ4GKT.js → openai-HW3SYMTQ.js} +51 -55
  67. package/dist/{opengraph_io-SQRAUSV5.js → opengraph_io-QX74MAEL.js} +61 -79
  68. package/dist/{openrouter-Q5XXEJZ7.js → openrouter-OXSKYL6N.js} +41 -55
  69. package/dist/{outline-RT2EHJ2X.js → outline-CCQAPDSW.js} +89 -104
  70. package/dist/{paddle-OF2V7GAC.js → paddle-6KQPSSCK.js} +34 -49
  71. package/dist/{perplexity-LNZEWLHG.js → perplexity-2TXO7IQE.js} +33 -50
  72. package/dist/{pinecone-JSJIXZYN.js → pinecone-YOO7NULI.js} +65 -91
  73. package/dist/{pipedrive-D4CKVUXR.js → pipedrive-Q6RIFIFP.js} +37 -59
  74. package/dist/{polar-M7ZYP6UR.js → polar-KUMGCES3.js} +43 -53
  75. package/dist/{posthog-YV7CZOH4.js → posthog-VXQHBSMB.js} +58 -77
  76. package/dist/{postmark-KYHLECRG.js → postmark-YLIPF52S.js} +52 -71
  77. package/dist/{prerender-HCMHBKV2.js → prerender-CRY7UJN5.js} +32 -50
  78. package/dist/{pubmed-WYVLCCN3.js → pubmed-3Z4T5AM7.js} +28 -60
  79. package/dist/{railway-TWIRD5KR.js → railway-BP37IGFL.js} +32 -39
  80. package/dist/{readwise-UZ467IQ7.js → readwise-HTKICF4K.js} +62 -78
  81. package/dist/{render-MECUC5CC.js → render-WIVTUXJH.js} +48 -64
  82. package/dist/{replicate-A5MEK3SW.js → replicate-JJYPA43D.js} +41 -58
  83. package/dist/{resend-BC6EAWJQ.js → resend-TKHZVG7A.js} +27 -37
  84. package/dist/{rootly-ZM3QDUIS.js → rootly-FRSZLG5U.js} +64 -76
  85. package/dist/{scrapfly-WAML42QJ.js → scrapfly-M5WXGQWE.js} +45 -51
  86. package/dist/{scrapingbee-DG7PET3V.js → scrapingbee-PMXNLLBK.js} +25 -33
  87. package/dist/{screenshot_fyi-HY6WTHIO.js → screenshot_fyi-HFW4TAOH.js} +29 -47
  88. package/dist/{semantic_scholar-C5IZA7IP.js → semantic_scholar-KXVH2VZQ.js} +37 -56
  89. package/dist/{sentry-OKBPSTDM.js → sentry-WWOT2LRX.js} +66 -85
  90. package/dist/{shodan-PPC6DYU4.js → shodan-FY635H35.js} +42 -53
  91. package/dist/{shopify-EWGUHBXO.js → shopify-HQLBVSA5.js} +32 -49
  92. package/dist/{stripe-6RPDPC5W.js → stripe-GJN2GOHB.js} +4 -5
  93. package/dist/{supabase-SK7DQ42N.js → supabase-BBNZGQU6.js} +69 -88
  94. package/dist/{tavily-YCG5VQMH.js → tavily-DPENIBOG.js} +37 -62
  95. package/dist/{telegram-2OES5FYB.js → telegram-L4NONG6H.js} +168 -177
  96. package/dist/{telnyx-POOSBBR4.js → telnyx-H67MAEZS.js} +30 -50
  97. package/dist/{todoist-M7YD6YSS.js → todoist-G2BSP4DX.js} +77 -89
  98. package/dist/{trello-IS6V5W3E.js → trello-7WMVFDG2.js} +108 -122
  99. package/dist/{turso-RCFHUFVH.js → turso-ZUAESFC2.js} +52 -64
  100. package/dist/{twilio-OS2RXFGO.js → twilio-EYFYIX3B.js} +48 -55
  101. package/dist/{umami-PQ2SJ2LN.js → umami-AXAUDUVF.js} +49 -69
  102. package/dist/{unsplash-C6BPZO4E.js → unsplash-UCQAWPLR.js} +35 -52
  103. package/dist/{upstash_redis-WH6UER7H.js → upstash_redis-ZPZ4ASU6.js} +28 -40
  104. package/dist/{uptimerobot-M3YZGS6Z.js → uptimerobot-4QVKKUD5.js} +11 -12
  105. package/dist/{v2ex-R4JWTEHN.js → v2ex-VGEFJTYC.js} +36 -61
  106. package/dist/{vercel-FZVYUOQD.js → vercel-JME4TSCN.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-TRGU2MDG.js} +26 -34
  109. package/dist/{wordpress-XRWGO6LG.js → wordpress-WRUKLCZR.js} +87 -104
  110. package/dist/{workos-WR4NKOYL.js → workos-ZDW4EHS4.js} +37 -56
  111. package/dist/{zhihu-BKZIB3WA.js → zhihu-4VI67CWU.js} +35 -57
  112. package/package.json +3 -3
  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,48 +1,46 @@
1
+ import {
2
+ createProviderHttpClient
3
+ } from "./chunk-VLOIDU5U.js";
4
+ import {
5
+ asJsonObject,
6
+ trimmedText
7
+ } from "./chunk-JXHMDBAY.js";
1
8
  import {
2
9
  createProviderPlugin,
3
10
  requireApiKey,
4
11
  upstreamError
5
- } from "./chunk-VK3V2WTY.js";
6
- import {
7
- guardedFetch
8
- } from "./chunk-2O27H4Y2.js";
9
- import "./chunk-GKX72JMJ.js";
12
+ } from "./chunk-B4P6YZFS.js";
13
+ import "./chunk-SWBNHIO4.js";
10
14
  import {
11
15
  TBError,
12
16
  external_exports
13
- } from "./chunk-YB2FLNWI.js";
14
- import "./chunk-MLKGABMK.js";
17
+ } from "./chunk-OKRZPQ3R.js";
18
+ import "./chunk-U67V476Y.js";
15
19
 
16
20
  // ../plugins/src/v2ex/api.ts
17
21
  var SERVICE = "v2ex";
18
22
  var API_BASE = "https://www.v2ex.com/api/v2";
19
23
  var LEGACY_API_BASE = "https://www.v2ex.com/api";
20
24
  var REQUEST_TIMEOUT_MS = 3e4;
21
- function record(value) {
22
- return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
23
- }
24
- function text(value) {
25
- if (typeof value !== "string") return void 0;
26
- const trimmed = value.trim();
27
- return trimmed === "" ? void 0 : trimmed;
28
- }
25
+ var v2Http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
26
+ var legacyHttp = createProviderHttpClient({ baseUrl: `${LEGACY_API_BASE}/`, service: SERVICE });
29
27
  function invalidResponse(message) {
30
28
  return new TBError("unavailable", message, { retryable: true });
31
29
  }
32
30
  function requireRecord(value, label) {
33
- const result = record(value);
31
+ const result = asJsonObject(value);
34
32
  if (result === void 0) throw invalidResponse(`${label} must be an object`);
35
33
  return result;
36
34
  }
37
35
  function errorMessage(payload) {
38
- if (typeof payload === "string") return text(payload);
39
- const body = record(payload);
36
+ if (typeof payload === "string") return trimmedText(payload);
37
+ const body = asJsonObject(payload);
40
38
  if (body === void 0) return void 0;
41
- const direct = text(body.message) ?? text(body.error);
39
+ const direct = trimmedText(body.message) ?? trimmedText(body.error);
42
40
  if (direct !== void 0) return direct;
43
41
  if (Array.isArray(body.errors)) {
44
42
  for (const item of body.errors) {
45
- const detail = text(record(item)?.detail) ?? text(record(item)?.message);
43
+ const detail = trimmedText(asJsonObject(item)?.detail) ?? trimmedText(asJsonObject(item)?.message);
46
44
  if (detail !== void 0) return detail;
47
45
  }
48
46
  }
@@ -51,58 +49,35 @@ function errorMessage(payload) {
51
49
  function envelopeError(payload) {
52
50
  return new TBError("invalid_argument", errorMessage(payload) ?? "V2EX request failed");
53
51
  }
54
- async function readPayload(response) {
55
- const raw = await response.text().catch(() => "");
56
- if (raw.trim() === "") return null;
57
- try {
58
- return JSON.parse(raw);
59
- } catch {
60
- return raw;
61
- }
62
- }
63
- async function send(url, init, label) {
64
- let response;
65
- try {
66
- response = await guardedFetch(url.toString(), {
67
- ...init,
68
- // 不设超时会让一个挂死的端点拖住整个调用;上游同样给了 30s 的独立预算。
69
- signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
70
- });
71
- } catch (error) {
72
- if (error instanceof TBError) throw error;
73
- if (error instanceof Error && error.name === "TimeoutError") {
74
- throw upstreamError(504, `${label} request timed out after ${REQUEST_TIMEOUT_MS / 1e3} seconds`);
75
- }
76
- throw upstreamError(
77
- 502,
78
- error instanceof Error ? `${label} request failed: ${error.message}` : `${label} request failed`
79
- );
80
- }
81
- const payload = await readPayload(response);
82
- if (!response.ok) throw upstreamError(response.status, errorMessage(payload) ?? "V2EX request failed");
83
- return payload;
52
+ async function send(client, request2, label) {
53
+ const response = await client.request({
54
+ ...request2,
55
+ timeoutMs: REQUEST_TIMEOUT_MS,
56
+ invalidJson: "text",
57
+ mapError: ({ data, status }) => upstreamError(status, errorMessage(data) ?? "V2EX request failed"),
58
+ mapTransportError: ({ kind, message }) => kind === "timeout" ? upstreamError(504, `${label} request timed out after ${REQUEST_TIMEOUT_MS / 1e3} seconds`) : upstreamError(502, message === void 0 ? `${label} request failed` : `${label} request failed: ${message}`)
59
+ });
60
+ return response.bodyKind === "empty" ? null : response.data;
84
61
  }
85
62
  async function request(ctx, options) {
86
- const url = new URL(`${API_BASE}${options.path}`);
87
- for (const [key, value] of Object.entries(options.query ?? {})) {
88
- if (value !== void 0 && value !== "") url.searchParams.set(key, String(value));
89
- }
90
63
  const headers = {
91
64
  accept: "application/json",
92
65
  authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
93
66
  };
94
- if (options.body !== void 0) headers["content-type"] = "application/json";
95
- return send(url, {
67
+ return send(v2Http, {
96
68
  method: options.method,
69
+ path: options.path,
70
+ // 上游连**空串**也当作"没给",不只是 undefined/null。
71
+ query: Object.entries(options.query ?? {}).filter(([, value]) => value !== void 0 && value !== ""),
97
72
  headers,
98
- ...options.body === void 0 ? {} : { body: JSON.stringify(options.body) }
73
+ ...options.body === void 0 ? {} : { json: options.body }
99
74
  }, `V2EX ${options.path}`);
100
75
  }
101
76
  async function legacyRequest(ctx, path) {
102
77
  requireApiKey(ctx, SERVICE);
103
78
  const payload = await send(
104
- new URL(`${LEGACY_API_BASE}${path}`),
105
- { method: "GET", headers: { accept: "application/json" } },
79
+ legacyHttp,
80
+ { method: "GET", path, headers: { accept: "application/json" } },
106
81
  `V2EX legacy ${path}`
107
82
  );
108
83
  if (!Array.isArray(payload)) {
@@ -116,7 +91,7 @@ function unwrapEnvelope(payload, label) {
116
91
  if (!("result" in envelope)) {
117
92
  throw invalidResponse(`V2EX ${label} response missing result`);
118
93
  }
119
- return { message: text(envelope.message), result: envelope.result };
94
+ return { message: trimmedText(envelope.message), result: envelope.result };
120
95
  }
121
96
  function ensureAccepted(payload, label) {
122
97
  if (payload === null) return;
@@ -185,7 +160,7 @@ async function createToken(input, ctx) {
185
160
  }),
186
161
  "token creation"
187
162
  );
188
- const token = text(objectResult(envelope, "token creation").token);
163
+ const token = trimmedText(objectResult(envelope, "token creation").token);
189
164
  if (token === void 0) {
190
165
  throw invalidResponse("V2EX token creation response missing token");
191
166
  }
@@ -1,40 +1,29 @@
1
+ import {
2
+ createProviderHttpClient
3
+ } from "./chunk-VLOIDU5U.js";
4
+ import {
5
+ asJsonObject,
6
+ booleanValue,
7
+ compactDefined,
8
+ finiteNumber,
9
+ trimmedText
10
+ } from "./chunk-JXHMDBAY.js";
1
11
  import {
2
12
  createProviderPlugin,
3
13
  requireApiKey,
4
14
  upstreamError
5
- } from "./chunk-VK3V2WTY.js";
6
- import {
7
- guardedFetch
8
- } from "./chunk-2O27H4Y2.js";
9
- import "./chunk-GKX72JMJ.js";
15
+ } from "./chunk-B4P6YZFS.js";
16
+ import "./chunk-SWBNHIO4.js";
10
17
  import {
11
18
  TBError,
12
19
  external_exports
13
- } from "./chunk-YB2FLNWI.js";
14
- import "./chunk-MLKGABMK.js";
20
+ } from "./chunk-OKRZPQ3R.js";
21
+ import "./chunk-U67V476Y.js";
15
22
 
16
23
  // ../plugins/src/vercel/api.ts
17
24
  var SERVICE = "vercel";
18
25
  var API_BASE = "https://api.vercel.com";
19
- function text(value) {
20
- if (typeof value !== "string") return void 0;
21
- const trimmed = value.trim();
22
- return trimmed === "" ? void 0 : trimmed;
23
- }
24
- function num(value) {
25
- return typeof value === "number" && Number.isFinite(value) ? value : void 0;
26
- }
27
- function bool(value) {
28
- return typeof value === "boolean" ? value : void 0;
29
- }
30
- function record(value) {
31
- return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
32
- }
33
- function compact(input) {
34
- return Object.fromEntries(
35
- Object.entries(input).filter(([, value]) => value !== void 0)
36
- );
37
- }
26
+ var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
38
27
  function stringArray(value) {
39
28
  return Array.isArray(value) ? value.filter((item) => typeof item === "string") : void 0;
40
29
  }
@@ -45,111 +34,96 @@ function contractError(label) {
45
34
  return new TBError("unavailable", `Vercel \u54CD\u5E94\u7F3A\u5C11\u6216\u7C7B\u578B\u4E0D\u7B26:${label}`, { retryable: true });
46
35
  }
47
36
  function requiredText(value, label) {
48
- const result = text(value);
37
+ const result = trimmedText(value);
49
38
  if (result === void 0) throw contractError(label);
50
39
  return result;
51
40
  }
52
41
  function requiredNumber(value, label) {
53
- const result = num(value);
42
+ const result = finiteNumber(value);
54
43
  if (result === void 0) throw contractError(label);
55
44
  return result;
56
45
  }
57
46
  function requiredRecord(value, label) {
58
- const result = record(value);
47
+ const result = asJsonObject(value);
59
48
  if (result === void 0) throw contractError(label);
60
49
  return result;
61
50
  }
62
51
  function arrayPayload(payload, key) {
63
52
  if (Array.isArray(payload)) return payload;
64
- const value = record(payload)?.[key];
53
+ const value = asJsonObject(payload)?.[key];
65
54
  return Array.isArray(value) ? value : [];
66
55
  }
67
56
  async function request(ctx, input) {
68
- const url = new URL(`${API_BASE}${input.path}`);
69
- for (const [key, value] of Object.entries(input.query ?? {})) {
70
- if (value === void 0 || value === "") continue;
71
- url.searchParams.set(key, String(value));
72
- }
73
- const headers = {
74
- authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
75
- };
76
- if (input.body !== void 0) headers["content-type"] = "application/json";
77
- const response = await guardedFetch(url.toString(), {
57
+ const hasBody = input.body !== void 0;
58
+ const { data } = await http.request({
59
+ path: input.path,
78
60
  method: input.method ?? "GET",
79
- headers,
80
- body: input.body === void 0 ? void 0 : JSON.stringify(input.body)
81
- });
82
- const raw = await response.text();
83
- let payload = {};
84
- let isJson = true;
85
- if (raw !== "") {
86
- try {
87
- payload = JSON.parse(raw);
88
- } catch {
89
- isJson = false;
61
+ // 上游 `queryParams` 连空串一起跳过。
62
+ query: Object.entries(input.query ?? {}).filter(([, value]) => value !== void 0 && value !== ""),
63
+ headers: { authorization: `Bearer ${requireApiKey(ctx, SERVICE)}` },
64
+ ...hasBody ? { json: input.body } : {},
65
+ invalidJsonMessage: "Vercel \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
66
+ mapError: ({ bodyKind, data: payload, status }) => {
67
+ const body = asJsonObject(payload) ?? {};
68
+ const error = asJsonObject(body.error) ?? {};
69
+ const message = trimmedText(error.message) ?? trimmedText(body.message) ?? (bodyKind === "invalid-json" || bodyKind === "text" ? trimmedText(payload) : void 0) ?? `Vercel \u8FD4\u56DE HTTP ${status}`;
70
+ return upstreamError(status, message);
90
71
  }
91
- }
92
- if (!response.ok) {
93
- const body = record(payload) ?? {};
94
- const error = record(body.error) ?? {};
95
- const message = text(error.message) ?? text(body.message) ?? (isJson ? void 0 : text(raw)) ?? `Vercel \u8FD4\u56DE HTTP ${response.status}`;
96
- throw upstreamError(response.status, message);
97
- }
98
- if (!isJson) throw new TBError("unavailable", "Vercel \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94", { retryable: true });
99
- return payload;
72
+ });
73
+ return data ?? {};
100
74
  }
101
75
  function unwrap(payload, key) {
102
76
  const body = requiredRecord(payload, key);
103
- return record(body[key]) ?? body;
77
+ return asJsonObject(body[key]) ?? body;
104
78
  }
105
79
  function mapUser(payload) {
106
80
  const user = unwrap(payload, "user");
107
- return compact({
81
+ return compactDefined({
108
82
  // 上游在 id 缺失时报 502:没有 id 的 user 响应不能算成功。
109
83
  id: requiredText(user.id, "user.id"),
110
- username: text(user.username),
111
- email: text(user.email),
112
- name: text(user.name)
84
+ username: trimmedText(user.username),
85
+ email: trimmedText(user.email),
86
+ name: trimmedText(user.name)
113
87
  });
114
88
  }
115
89
  function mapTeam(payload) {
116
90
  const team = unwrap(payload, "team");
117
- return compact({
91
+ return compactDefined({
118
92
  id: requiredText(team.id, "team.id"),
119
- slug: text(team.slug),
120
- name: text(team.name),
121
- createdAt: num(team.createdAt),
122
- updatedAt: num(team.updatedAt)
93
+ slug: trimmedText(team.slug),
94
+ name: trimmedText(team.name),
95
+ createdAt: finiteNumber(team.createdAt),
96
+ updatedAt: finiteNumber(team.updatedAt)
123
97
  });
124
98
  }
125
99
  function mapDeployment(value) {
126
100
  const deployment = requiredRecord(value, "deployment");
127
- return compact({
101
+ return compactDefined({
128
102
  id: requiredText(deployment.id, "deployment.id"),
129
- name: text(deployment.name),
130
- url: text(deployment.url),
131
- state: text(deployment.state),
132
- readyState: text(deployment.readyState),
133
- target: text(deployment.target),
134
- createdAt: num(deployment.createdAt),
135
- ready: num(deployment.ready),
136
- projectId: text(deployment.projectId),
137
- creator: record(deployment.creator),
138
- meta: record(deployment.meta),
103
+ name: trimmedText(deployment.name),
104
+ url: trimmedText(deployment.url),
105
+ state: trimmedText(deployment.state),
106
+ readyState: trimmedText(deployment.readyState),
107
+ target: trimmedText(deployment.target),
108
+ createdAt: finiteNumber(deployment.createdAt),
109
+ ready: finiteNumber(deployment.ready),
110
+ projectId: trimmedText(deployment.projectId),
111
+ creator: asJsonObject(deployment.creator),
112
+ meta: asJsonObject(deployment.meta),
139
113
  alias: stringArray(deployment.alias)
140
114
  });
141
115
  }
142
116
  function mapProject(value) {
143
117
  const project = requiredRecord(value, "project");
144
- return compact({
118
+ return compactDefined({
145
119
  id: requiredText(project.id, "project.id"),
146
120
  name: requiredText(project.name, "project.name"),
147
- accountId: text(project.accountId),
148
- framework: text(project.framework),
149
- nodeVersion: text(project.nodeVersion),
150
- createdAt: num(project.createdAt),
151
- updatedAt: num(project.updatedAt),
152
- link: record(project.link),
121
+ accountId: trimmedText(project.accountId),
122
+ framework: trimmedText(project.framework),
123
+ nodeVersion: trimmedText(project.nodeVersion),
124
+ createdAt: finiteNumber(project.createdAt),
125
+ updatedAt: finiteNumber(project.updatedAt),
126
+ link: asJsonObject(project.link),
153
127
  latestDeployments: Array.isArray(project.latestDeployments) ? project.latestDeployments.map((deployment) => mapDeployment(deployment)) : void 0
154
128
  });
155
129
  }
@@ -163,80 +137,80 @@ function mapDeploymentEvent(value) {
163
137
  }
164
138
  function mapRuntimeLog(value) {
165
139
  const log = requiredRecord(value, "runtime log");
166
- return compact({
140
+ return compactDefined({
167
141
  timestampInMs: requiredNumber(log.timestampInMs, "log.timestampInMs"),
168
142
  level: requiredText(log.level, "log.level"),
169
143
  message: requiredText(log.message, "log.message"),
170
144
  source: requiredText(log.source, "log.source"),
171
- requestMethod: text(log.requestMethod),
172
- requestPath: text(log.requestPath),
173
- responseStatusCode: num(log.responseStatusCode)
145
+ requestMethod: trimmedText(log.requestMethod),
146
+ requestPath: trimmedText(log.requestPath),
147
+ responseStatusCode: finiteNumber(log.responseStatusCode)
174
148
  });
175
149
  }
176
150
  function mapEnv(value) {
177
151
  const env = requiredRecord(value, "env");
178
- return compact({
152
+ return compactDefined({
179
153
  id: requiredText(env.id, "env.id"),
180
154
  key: requiredText(env.key, "env.key"),
181
155
  type: requiredText(env.type, "env.type"),
182
156
  target: stringArray(env.target),
183
- gitBranch: text(env.gitBranch),
184
- createdAt: num(env.createdAt),
185
- updatedAt: num(env.updatedAt),
186
- comment: text(env.comment)
157
+ gitBranch: trimmedText(env.gitBranch),
158
+ createdAt: finiteNumber(env.createdAt),
159
+ updatedAt: finiteNumber(env.updatedAt),
160
+ comment: trimmedText(env.comment)
187
161
  });
188
162
  }
189
163
  function mapDomain(value) {
190
164
  const domain = requiredRecord(value, "domain");
191
- return compact({
165
+ return compactDefined({
192
166
  name: requiredText(domain.name, "domain.name"),
193
- apexName: text(domain.apexName),
194
- verified: bool(domain.verified),
195
- verification: Array.isArray(domain.verification) ? domain.verification.map((item) => record(item)).filter((item) => item !== void 0) : void 0,
167
+ apexName: trimmedText(domain.apexName),
168
+ verified: booleanValue(domain.verified),
169
+ verification: Array.isArray(domain.verification) ? domain.verification.map((item) => asJsonObject(item)).filter((item) => item !== void 0) : void 0,
196
170
  // null 是"明确没有重定向",与"字段缺席"不是一回事。
197
- redirect: domain.redirect === null ? null : text(domain.redirect),
198
- gitBranch: text(domain.gitBranch),
199
- customEnvironmentId: text(domain.customEnvironmentId)
171
+ redirect: domain.redirect === null ? null : trimmedText(domain.redirect),
172
+ gitBranch: trimmedText(domain.gitBranch),
173
+ customEnvironmentId: trimmedText(domain.customEnvironmentId)
200
174
  });
201
175
  }
202
176
  function mapWebhook(value) {
203
177
  const webhook = requiredRecord(value, "webhook");
204
- return compact({
178
+ return compactDefined({
205
179
  id: requiredText(webhook.id, "webhook.id"),
206
180
  url: requiredText(webhook.url, "webhook.url"),
207
181
  events: stringArray(webhook.events),
208
182
  projectIds: stringArray(webhook.projectIds),
209
- teamId: text(webhook.teamId),
210
- createdAt: num(webhook.createdAt),
211
- updatedAt: num(webhook.updatedAt)
183
+ teamId: trimmedText(webhook.teamId),
184
+ createdAt: finiteNumber(webhook.createdAt),
185
+ updatedAt: finiteNumber(webhook.updatedAt)
212
186
  });
213
187
  }
214
188
  function pagination(payload) {
215
- return record(record(payload)?.pagination);
189
+ return asJsonObject(asJsonObject(payload)?.pagination);
216
190
  }
217
191
  function projectBody(input) {
218
- return compact({
219
- name: text(input.name),
220
- framework: text(input.framework),
221
- rootDirectory: text(input.rootDirectory),
222
- nodeVersion: text(input.nodeVersion),
223
- buildCommand: text(input.buildCommand),
224
- devCommand: text(input.devCommand),
225
- installCommand: text(input.installCommand),
226
- outputDirectory: text(input.outputDirectory),
227
- directoryListing: bool(input.directoryListing),
228
- publicSource: bool(input.publicSource),
229
- gitForkProtection: bool(input.gitForkProtection)
192
+ return compactDefined({
193
+ name: trimmedText(input.name),
194
+ framework: trimmedText(input.framework),
195
+ rootDirectory: trimmedText(input.rootDirectory),
196
+ nodeVersion: trimmedText(input.nodeVersion),
197
+ buildCommand: trimmedText(input.buildCommand),
198
+ devCommand: trimmedText(input.devCommand),
199
+ installCommand: trimmedText(input.installCommand),
200
+ outputDirectory: trimmedText(input.outputDirectory),
201
+ directoryListing: booleanValue(input.directoryListing),
202
+ publicSource: booleanValue(input.publicSource),
203
+ gitForkProtection: booleanValue(input.gitForkProtection)
230
204
  });
231
205
  }
232
206
  function envBody(input) {
233
- return compact({
234
- key: text(input.key),
235
- value: text(input.value),
236
- type: text(input.type),
207
+ return compactDefined({
208
+ key: trimmedText(input.key),
209
+ value: trimmedText(input.value),
210
+ type: trimmedText(input.type),
237
211
  target: stringArray(input.target),
238
- gitBranch: text(input.gitBranch),
239
- comment: text(input.comment),
212
+ gitBranch: trimmedText(input.gitBranch),
213
+ comment: trimmedText(input.comment),
240
214
  customEnvironmentIds: stringArray(input.customEnvironmentIds)
241
215
  });
242
216
  }
@@ -256,7 +230,7 @@ async function listTeams(input, ctx) {
256
230
  path: "/v2/teams",
257
231
  query: { limit: input.limit, since: input.since }
258
232
  });
259
- return compact({
233
+ return compactDefined({
260
234
  teams: arrayPayload(payload, "teams").map((team) => mapTeam(team)),
261
235
  pagination: pagination(payload)
262
236
  });
@@ -271,10 +245,10 @@ async function listProjects(input, ctx) {
271
245
  limit: input.limit,
272
246
  since: input.since,
273
247
  until: input.until,
274
- repoUrl: text(input.repoUrl)
248
+ repoUrl: trimmedText(input.repoUrl)
275
249
  }
276
250
  });
277
- return compact({
251
+ return compactDefined({
278
252
  projects: arrayPayload(payload, "projects").map((project) => mapProject(project)),
279
253
  pagination: pagination(payload)
280
254
  });
@@ -303,14 +277,14 @@ async function listDeployments(input, ctx) {
303
277
  path: "/v6/deployments",
304
278
  query: {
305
279
  limit: input.limit,
306
- projectId: text(input.projectId),
280
+ projectId: trimmedText(input.projectId),
307
281
  since: input.since,
308
282
  until: input.until,
309
- target: text(input.target),
310
- state: text(input.state)
283
+ target: trimmedText(input.target),
284
+ state: trimmedText(input.state)
311
285
  }
312
286
  });
313
- return compact({
287
+ return compactDefined({
314
288
  deployments: arrayPayload(payload, "deployments").map((deployment) => mapDeployment(deployment)),
315
289
  pagination: pagination(payload)
316
290
  });
@@ -329,7 +303,7 @@ async function getDeploymentEvents(input, ctx) {
329
303
  query: {
330
304
  // 这个端点的布尔用 1/0 编码,与 get_deployment 不同。
331
305
  builds: flag(input.builds),
332
- direction: text(input.direction),
306
+ direction: trimmedText(input.direction),
333
307
  limit: input.limit,
334
308
  since: input.since,
335
309
  until: input.until
@@ -347,8 +321,8 @@ async function listProjectEnvs(input, ctx) {
347
321
  const payload = await request(ctx, {
348
322
  path: `/v10/projects/${seg(input.idOrName)}/env`,
349
323
  query: {
350
- customEnvironmentId: text(input.customEnvironmentId),
351
- gitBranch: text(input.gitBranch)
324
+ customEnvironmentId: trimmedText(input.customEnvironmentId),
325
+ gitBranch: trimmedText(input.gitBranch)
352
326
  }
353
327
  });
354
328
  return { envs: arrayPayload(payload, "envs").map((env) => mapEnv(env)) };
@@ -385,11 +359,11 @@ async function listProjectDomains(input, ctx) {
385
359
  limit: input.limit,
386
360
  since: input.since,
387
361
  until: input.until,
388
- gitBranch: text(input.gitBranch),
389
- customEnvironmentId: text(input.customEnvironmentId)
362
+ gitBranch: trimmedText(input.gitBranch),
363
+ customEnvironmentId: trimmedText(input.customEnvironmentId)
390
364
  }
391
365
  });
392
- return compact({
366
+ return compactDefined({
393
367
  domains: arrayPayload(payload, "domains").map((domain) => mapDomain(domain)),
394
368
  pagination: pagination(payload)
395
369
  });
@@ -404,11 +378,11 @@ async function addProjectDomain(input, ctx) {
404
378
  const payload = await request(ctx, {
405
379
  method: "POST",
406
380
  path: `/v10/projects/${seg(input.idOrName)}/domains`,
407
- body: compact({
408
- name: text(input.name),
409
- redirect: text(input.redirect),
410
- gitBranch: text(input.gitBranch),
411
- customEnvironmentId: text(input.customEnvironmentId)
381
+ body: compactDefined({
382
+ name: trimmedText(input.name),
383
+ redirect: trimmedText(input.redirect),
384
+ gitBranch: trimmedText(input.gitBranch),
385
+ customEnvironmentId: trimmedText(input.customEnvironmentId)
412
386
  })
413
387
  });
414
388
  return { domain: mapDomain(payload) };
@@ -425,10 +399,10 @@ async function getDomainConfig(input, ctx) {
425
399
  await request(ctx, { path: `/v6/domains/${seg(input.domain)}/config` }),
426
400
  "domain config"
427
401
  );
428
- return compact({
429
- configuredBy: text(payload.configuredBy),
402
+ return compactDefined({
403
+ configuredBy: trimmedText(payload.configuredBy),
430
404
  acceptedChallenges: stringArray(payload.acceptedChallenges),
431
- misconfigured: bool(payload.misconfigured),
405
+ misconfigured: booleanValue(payload.misconfigured),
432
406
  recommendedNameServers: stringArray(payload.recommendedNameServers)
433
407
  });
434
408
  }
@@ -443,8 +417,8 @@ async function createWebhook(input, ctx) {
443
417
  const payload = await request(ctx, {
444
418
  method: "POST",
445
419
  path: "/v1/webhooks",
446
- body: compact({
447
- url: text(input.url),
420
+ body: compactDefined({
421
+ url: trimmedText(input.url),
448
422
  events: stringArray(input.events),
449
423
  projectIds: stringArray(input.projectIds)
450
424
  })
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __export
3
- } from "./chunk-MLKGABMK.js";
3
+ } from "./chunk-U67V476Y.js";
4
4
 
5
5
  // ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/util/base64url.js
6
6
  var base64url_exports = {};