@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,24 +1,26 @@
1
+ import {
2
+ createProviderHttpClient
3
+ } from "./chunk-WW2IMPQK.js";
4
+ import {
5
+ asJsonObject,
6
+ compactDefined
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-YASUMV2K.js";
13
+ import "./chunk-U5UHT7CX.js";
10
14
  import {
11
15
  TBError,
12
16
  external_exports
13
- } from "./chunk-YB2FLNWI.js";
14
- import "./chunk-MLKGABMK.js";
17
+ } from "./chunk-RVWZN3CI.js";
18
+ import "./chunk-U67V476Y.js";
15
19
 
16
20
  // ../plugins/src/sentry/api.ts
17
21
  var SERVICE = "sentry";
18
22
  var API_BASE = "https://sentry.io/api/0/";
19
- function record(value) {
20
- return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
21
- }
23
+ var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
22
24
  function str(value) {
23
25
  return typeof value === "string" ? value : void 0;
24
26
  }
@@ -52,11 +54,8 @@ function nullableStrArray(value) {
52
54
  function arrayValue(value) {
53
55
  return Array.isArray(value) ? value : [];
54
56
  }
55
- function compact(value) {
56
- return Object.fromEntries(Object.entries(value).filter(([, child]) => child !== void 0));
57
- }
58
57
  function expectRecord(value, label) {
59
- const body = record(value);
58
+ const body = asJsonObject(value);
60
59
  if (body === void 0) throw new TBError("unavailable", `Sentry ${label} \u54CD\u5E94\u5F62\u72B6\u4E0D\u7B26`, { retryable: true });
61
60
  return body;
62
61
  }
@@ -73,52 +72,34 @@ function joinClauses(...clauses) {
73
72
  const kept = clauses.filter((clause) => nonEmpty(clause));
74
73
  return kept.length > 0 ? kept.join(" ") : void 0;
75
74
  }
76
- function buildUrl(path, query) {
77
- const url = new URL(path, API_BASE);
78
- for (const [key, value] of Object.entries(query ?? {})) {
79
- if (value === void 0) continue;
80
- if (Array.isArray(value)) {
81
- for (const item of value) url.searchParams.append(key, String(item));
82
- continue;
83
- }
84
- url.searchParams.set(key, String(value));
85
- }
86
- return url.toString();
87
- }
88
75
  function errorMessage(payload, status) {
89
- const body = record(payload);
90
- const nested = str(record(body?.detail)?.message);
76
+ const body = asJsonObject(payload);
77
+ const nested = str(asJsonObject(body?.detail)?.message);
91
78
  return pickStr(body?.error_description, body?.detail, body?.error, body?.message) ?? (nonEmpty(nested) ? nested : void 0) ?? `Sentry \u8FD4\u56DE HTTP ${status}`;
92
79
  }
93
- async function readJson(response) {
94
- if (!(response.headers.get("content-type") ?? "").includes("application/json")) return null;
95
- try {
96
- return await response.json();
97
- } catch {
98
- return null;
99
- }
100
- }
101
80
  async function request(ctx, path, options = {}) {
102
81
  const token = requireApiKey(ctx, SERVICE);
103
- const headers = {
104
- accept: "application/json",
105
- authorization: `Bearer ${token}`
106
- };
107
- if (options.body !== void 0) headers["content-type"] = "application/json";
108
- let response;
109
- try {
110
- response = await guardedFetch(buildUrl(path, options.query), {
111
- method: options.method ?? "GET",
112
- headers,
113
- ...options.body === void 0 ? {} : { body: JSON.stringify(options.body) }
114
- });
115
- } catch (error) {
116
- if (error instanceof TBError) throw error;
117
- throw upstreamError(502, `Sentry \u8BF7\u6C42\u5931\u8D25:${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`);
118
- }
119
- const payload = await readJson(response);
120
- if (!response.ok) throw upstreamError(response.status, errorMessage(payload, response.status));
121
- return { payload, headers: response.headers };
82
+ const result = await http.request({
83
+ // path 不带前导斜杠 —— 见文件头注释,否则 /api/0 前缀会被整段吃掉。
84
+ path,
85
+ method: options.method ?? "GET",
86
+ // 多值过滤器(environment / project / field …)展开成重复的同名参数。
87
+ query: Object.entries(options.query ?? {}),
88
+ headers: { accept: "application/json", authorization: `Bearer ${token}` },
89
+ ...options.body === void 0 ? {} : { json: options.body },
90
+ invalidJson: "text",
91
+ responseType: "auto",
92
+ mapError: ({ bodyKind, data, headers, status }) => {
93
+ const payload2 = headers.get("content-type")?.includes("application/json") === true && bodyKind === "json" ? data : null;
94
+ return upstreamError(status, errorMessage(payload2, status));
95
+ },
96
+ mapTransportError: ({ message }) => upstreamError(
97
+ 502,
98
+ `Sentry \u8BF7\u6C42\u5931\u8D25:${message ?? "\u672A\u77E5\u9519\u8BEF"}`
99
+ )
100
+ });
101
+ const payload = result.headers.get("content-type")?.includes("application/json") === true && result.bodyKind === "json" ? result.data : null;
102
+ return { payload, headers: result.headers };
122
103
  }
123
104
  function splitLinkHeader(value) {
124
105
  const entries = [];
@@ -172,12 +153,12 @@ function cursors(headers) {
172
153
  return result;
173
154
  }
174
155
  function normalizeSetupDialog(value) {
175
- const body = record(value);
156
+ const body = asJsonObject(value);
176
157
  if (body === void 0) return null;
177
158
  return { url: nullableStr(body.url), width: nullableInt(body.width), height: nullableInt(body.height) };
178
159
  }
179
160
  function normalizeProviderMetadata(value) {
180
- const body = record(value);
161
+ const body = asJsonObject(value);
181
162
  if (body === void 0) return null;
182
163
  return {
183
164
  noun: nullableStr(body.noun),
@@ -186,7 +167,7 @@ function normalizeProviderMetadata(value) {
186
167
  // Sentry 同一字段在不同端点上 camelCase 与 snake_case 混用,两种都收。
187
168
  issueUrl: nullableStr(body.issueUrl ?? body.issue_url),
188
169
  sourceUrl: nullableStr(body.sourceUrl ?? body.source_url),
189
- aspects: record(body.aspects) ?? null,
170
+ aspects: asJsonObject(body.aspects) ?? null,
190
171
  features: arrayValue(body.features)
191
172
  };
192
173
  }
@@ -199,7 +180,7 @@ function normalizeIntegrationProvider(value) {
199
180
  canAdd: bool(body.canAdd),
200
181
  canDisable: bool(body.canDisable),
201
182
  features: strArray(body.features),
202
- aspects: record(body.aspects) ?? {},
183
+ aspects: asJsonObject(body.aspects) ?? {},
203
184
  metadata: normalizeProviderMetadata(body.metadata),
204
185
  setupDialog: normalizeSetupDialog(body.setupDialog)
205
186
  };
@@ -216,7 +197,7 @@ function normalizeOrganizationIntegration(value) {
216
197
  status: nullableStr(body.status),
217
198
  provider: normalizeIntegrationProvider(body.provider),
218
199
  configOrganization: arrayValue(body.configOrganization),
219
- configData: record(body.configData ?? body.config_data) ?? {},
200
+ configData: asJsonObject(body.configData ?? body.config_data) ?? {},
220
201
  externalId: nullableStr(body.externalId),
221
202
  organizationId: nullableInt(body.organizationId),
222
203
  organizationIntegrationStatus: nullableStr(body.organizationIntegrationStatus),
@@ -224,14 +205,14 @@ function normalizeOrganizationIntegration(value) {
224
205
  };
225
206
  }
226
207
  function normalizeSentryAppOwner(value) {
227
- const body = record(value);
208
+ const body = asJsonObject(value);
228
209
  if (body === void 0) return null;
229
210
  return { id: nullableInt(body.id), slug: nullableStr(body.slug) };
230
211
  }
231
212
  function normalizeSentryAppAvatars(value) {
232
213
  if (!Array.isArray(value)) return [];
233
214
  return value.flatMap((item) => {
234
- const body = record(item);
215
+ const body = asJsonObject(item);
235
216
  if (body === void 0) return [];
236
217
  return [{
237
218
  avatarType: str(body.avatarType) ?? "",
@@ -271,7 +252,7 @@ function normalizeSentryApp(value) {
271
252
  };
272
253
  }
273
254
  function normalizeTeam(value) {
274
- const body = record(value);
255
+ const body = asJsonObject(value);
275
256
  if (body === void 0) return null;
276
257
  return { id: nullableStr(body.id), slug: nullableStr(body.slug), name: nullableStr(body.name) };
277
258
  }
@@ -301,7 +282,7 @@ function normalizeProject(value) {
301
282
  };
302
283
  }
303
284
  function normalizeProjectSummary(value) {
304
- const body = record(value);
285
+ const body = asJsonObject(value);
305
286
  if (body === void 0) return null;
306
287
  return {
307
288
  id: str(body.id) ?? "",
@@ -311,7 +292,7 @@ function normalizeProjectSummary(value) {
311
292
  };
312
293
  }
313
294
  function normalizeIssueActor(value) {
314
- const body = record(value);
295
+ const body = asJsonObject(value);
315
296
  if (body === void 0) return null;
316
297
  return {
317
298
  id: nullableStr(body.id),
@@ -322,7 +303,7 @@ function normalizeIssueActor(value) {
322
303
  };
323
304
  }
324
305
  function normalizeIssueStatusDetails(value) {
325
- const body = record(value);
306
+ const body = asJsonObject(value);
326
307
  if (body === void 0) return null;
327
308
  const inNextRelease = body.inNextRelease ?? body.in_next_release;
328
309
  return {
@@ -334,7 +315,7 @@ function normalizeIssueStatusDetails(value) {
334
315
  function normalizeIssueTags(value) {
335
316
  if (!Array.isArray(value)) return [];
336
317
  return value.flatMap((item) => {
337
- const body = record(item);
318
+ const body = asJsonObject(item);
338
319
  if (body === void 0 || !nonEmpty(body.key)) return [];
339
320
  return [{ key: body.key, name: nullableStr(body.name), value: nullableStr(body.value) }];
340
321
  });
@@ -368,7 +349,7 @@ function normalizeIssue(value) {
368
349
  };
369
350
  }
370
351
  function normalizeEventUser(value) {
371
- const body = record(value);
352
+ const body = asJsonObject(value);
372
353
  if (body === void 0) return null;
373
354
  return {
374
355
  id: nullableStr(body.id),
@@ -381,7 +362,7 @@ function normalizeEventUser(value) {
381
362
  function normalizeEventTags(value) {
382
363
  if (!Array.isArray(value)) return [];
383
364
  return value.flatMap((item) => {
384
- const body = record(item);
365
+ const body = asJsonObject(item);
385
366
  if (body === void 0 || !nonEmpty(body.key) || !nonEmpty(body.value)) return [];
386
367
  return [{ key: body.key, value: body.value }];
387
368
  });
@@ -404,7 +385,7 @@ function normalizeIssueEvent(value) {
404
385
  function normalizeReleaseProjects(value) {
405
386
  if (!Array.isArray(value)) return [];
406
387
  return value.flatMap((item) => {
407
- const body = record(item);
388
+ const body = asJsonObject(item);
408
389
  if (body === void 0) return [];
409
390
  return [{ id: nullableInt(body.id), slug: nullableStr(body.slug), name: nullableStr(body.name) }];
410
391
  });
@@ -430,13 +411,13 @@ function normalizeRelease(value) {
430
411
  function normalizeHealthGroups(value) {
431
412
  if (!Array.isArray(value)) return [];
432
413
  return value.flatMap((item) => {
433
- const body = record(item);
414
+ const body = asJsonObject(item);
434
415
  if (body === void 0) return [];
435
- return [{ by: record(body.by) ?? {}, totals: record(body.totals) ?? {}, series: record(body.series) ?? null }];
416
+ return [{ by: asJsonObject(body.by) ?? {}, totals: asJsonObject(body.totals) ?? {}, series: asJsonObject(body.series) ?? null }];
436
417
  });
437
418
  }
438
419
  function normalizeReplayUser(value) {
439
- const body = record(value);
420
+ const body = asJsonObject(value);
440
421
  if (body === void 0) return null;
441
422
  return {
442
423
  id: nullableStr(body.id),
@@ -446,7 +427,7 @@ function normalizeReplayUser(value) {
446
427
  };
447
428
  }
448
429
  function normalizeNamedValue(value) {
449
- const body = record(value);
430
+ const body = asJsonObject(value);
450
431
  if (body === void 0) return null;
451
432
  return { name: nullableStr(body.name), version: nullableStr(body.version) };
452
433
  }
@@ -454,7 +435,7 @@ function normalizeReplayReleases(value) {
454
435
  if (!Array.isArray(value)) return [];
455
436
  return value.flatMap((item) => {
456
437
  if (typeof item === "string") return [item];
457
- const version = str(record(item)?.version);
438
+ const version = str(asJsonObject(item)?.version);
458
439
  return version === void 0 ? [] : [version];
459
440
  });
460
441
  }
@@ -481,12 +462,12 @@ function normalizeReplay(value) {
481
462
  }
482
463
  function normalizeCreatedBy(value) {
483
464
  if (typeof value === "string") return value;
484
- const body = record(value);
465
+ const body = asJsonObject(value);
485
466
  if (body === void 0) return null;
486
467
  return nullableStr(body.id ?? body.email ?? body.username);
487
468
  }
488
469
  function normalizeAlertTrigger(value) {
489
- const body = record(value);
470
+ const body = asJsonObject(value);
490
471
  if (body === void 0) return null;
491
472
  return {
492
473
  id: nullableStr(body.id),
@@ -499,7 +480,7 @@ function normalizeAlertTrigger(value) {
499
480
  function normalizeAlertActionFilters(value) {
500
481
  if (!Array.isArray(value)) return [];
501
482
  return value.flatMap((item) => {
502
- const body = record(item);
483
+ const body = asJsonObject(item);
503
484
  if (body === void 0) return [];
504
485
  return [{
505
486
  id: nullableStr(body.id),
@@ -523,21 +504,21 @@ function normalizeAlert(value) {
523
504
  environment: nullableStr(body.environment),
524
505
  lastTriggered: nullableStr(body.lastTriggered),
525
506
  detectorIds: strArray(body.detectorIds),
526
- config: record(body.config) ?? {},
507
+ config: asJsonObject(body.config) ?? {},
527
508
  triggers: normalizeAlertTrigger(body.triggers),
528
509
  actionFilters: normalizeAlertActionFilters(body.actionFilters)
529
510
  };
530
511
  }
531
512
  function unwrapWorkflowList(payload) {
532
513
  if (Array.isArray(payload)) return payload;
533
- const body = record(payload);
514
+ const body = asJsonObject(payload);
534
515
  if (body === void 0 || !Array.isArray(body.data)) {
535
516
  throw new TBError("unavailable", "Sentry alerts \u54CD\u5E94\u5F62\u72B6\u4E0D\u7B26", { retryable: true });
536
517
  }
537
518
  return body.data;
538
519
  }
539
520
  function unwrapWorkflowItem(payload) {
540
- const body = record(payload);
521
+ const body = asJsonObject(payload);
541
522
  return body !== void 0 && "data" in body ? body.data : payload;
542
523
  }
543
524
  function seg(value) {
@@ -545,7 +526,7 @@ function seg(value) {
545
526
  }
546
527
  async function listOrganizationIntegrations(input, ctx) {
547
528
  const { payload } = await request(ctx, `organizations/${seg(input.organizationIdOrSlug)}/integrations/`, {
548
- query: compact({
529
+ query: compactDefined({
549
530
  providerKey: input.providerKey,
550
531
  includeConfig: input.includeConfig,
551
532
  features: input.features
@@ -641,10 +622,10 @@ async function listIssueEvents(input, ctx) {
641
622
  return { events: expectArray(payload, "issue events").map(normalizeIssueEvent) };
642
623
  }
643
624
  async function updateIssue(input, ctx) {
644
- const details = input.statusDetails === void 0 ? void 0 : compact({ ...input.statusDetails });
625
+ const details = input.statusDetails === void 0 ? void 0 : compactDefined({ ...input.statusDetails });
645
626
  const { payload } = await request(ctx, `organizations/${seg(input.organizationIdOrSlug)}/issues/${seg(input.issueId)}/`, {
646
627
  method: "PUT",
647
- body: compact({
628
+ body: compactDefined({
648
629
  status: input.status,
649
630
  hasSeen: input.hasSeen,
650
631
  isPublic: input.isPublic,
@@ -666,7 +647,7 @@ async function listOrganizationReleases(input, ctx) {
666
647
  async function getOrganizationRelease(input, ctx) {
667
648
  const path = `organizations/${seg(input.organizationIdOrSlug)}/releases/${seg(input.version)}/`;
668
649
  const { payload } = await request(ctx, path, {
669
- query: compact({
650
+ query: compactDefined({
670
651
  sort: input.sort,
671
652
  query: input.query,
672
653
  health: input.health,
@@ -1,25 +1,28 @@
1
+ import {
2
+ createProviderHttpClient
3
+ } from "./chunk-WW2IMPQK.js";
4
+ import {
5
+ asJsonObject,
6
+ booleanValue,
7
+ compactDefined
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/shodan/api.ts
17
22
  var SERVICE = "shodan";
18
23
  var API_BASE = "https://api.shodan.io";
19
24
  var API_INFO_PATH = "/api-info";
20
- function record(value) {
21
- return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
22
- }
25
+ var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
23
26
  function invalidResponse(field) {
24
27
  return upstreamError(502, `Shodan ${field} response is invalid`);
25
28
  }
@@ -34,11 +37,8 @@ function requiredCount(value, field) {
34
37
  function optionalCount(value, field) {
35
38
  return value === void 0 ? void 0 : requiredCount(value, field);
36
39
  }
37
- function optionalFlag(value) {
38
- return typeof value === "boolean" ? value : void 0;
39
- }
40
40
  function objectArray(value, field) {
41
- if (!Array.isArray(value) || value.some((item) => record(item) === void 0)) throw invalidResponse(field);
41
+ if (!Array.isArray(value) || value.some((item) => asJsonObject(item) === void 0)) throw invalidResponse(field);
42
42
  return value;
43
43
  }
44
44
  function textArray(value, field) {
@@ -48,12 +48,9 @@ function textArray(value, field) {
48
48
  }
49
49
  return value.map((item) => item.trim());
50
50
  }
51
- function compact(input) {
52
- return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0));
53
- }
54
51
  function errorMessage(payload, status) {
55
52
  if (typeof payload === "string" && payload.trim() !== "") return payload.trim();
56
- const body = record(payload);
53
+ const body = asJsonObject(payload);
57
54
  for (const key of ["error", "message"]) {
58
55
  const value = body?.[key];
59
56
  if (typeof value === "string" && value.trim() !== "") return value.trim();
@@ -61,31 +58,23 @@ function errorMessage(payload, status) {
61
58
  return `Shodan request failed with ${status || 500}`;
62
59
  }
63
60
  async function request(ctx, path, query = {}) {
64
- const url = new URL(path, API_BASE);
65
- for (const [key, value] of Object.entries(query)) {
66
- if (value !== void 0) url.searchParams.set(key, String(value));
67
- }
68
- url.searchParams.set("key", requireApiKey(ctx, SERVICE));
69
- let response;
70
- let raw;
71
- try {
72
- response = await guardedFetch(url.toString(), { method: "GET", headers: { accept: "application/json" } });
73
- raw = await response.text();
74
- } catch (error) {
75
- const message = error instanceof Error ? `Shodan request failed: ${error.message}` : "Shodan request failed";
76
- throw upstreamError(502, message);
77
- }
78
- let payload = null;
79
- if (raw !== "") {
80
- try {
81
- payload = JSON.parse(raw);
82
- } catch {
83
- if (response.ok) throw upstreamError(502, "Shodan returned invalid JSON");
84
- payload = raw;
85
- }
86
- }
87
- if (!response.ok) throw upstreamError(response.status, errorMessage(payload, response.status));
88
- const body = record(payload);
61
+ const requestQuery = [
62
+ ...Object.entries(query),
63
+ ["key", requireApiKey(ctx, SERVICE)]
64
+ ];
65
+ const response = await http.request({
66
+ path,
67
+ query: requestQuery,
68
+ headers: { accept: "application/json" },
69
+ invalidJson: "text",
70
+ mapError: ({ data, status }) => upstreamError(status, errorMessage(data, status)),
71
+ mapTransportError: ({ message }) => upstreamError(
72
+ 502,
73
+ message === void 0 ? "Shodan request failed" : `Shodan request failed: ${message}`
74
+ )
75
+ });
76
+ if (response.bodyKind === "invalid-json") throw upstreamError(502, "Shodan returned invalid JSON");
77
+ const body = asJsonObject(response.bodyKind === "empty" ? null : response.data);
89
78
  if (body === void 0) throw upstreamError(502, "Shodan returned an invalid JSON response");
90
79
  return body;
91
80
  }
@@ -102,16 +91,16 @@ function joinCommaList(values, field) {
102
91
  }
103
92
  async function getApiInfo(_input, ctx) {
104
93
  const payload = await request(ctx, API_INFO_PATH);
105
- return compact({
94
+ return compactDefined({
106
95
  plan: requiredText(payload.plan, "plan"),
107
- https: optionalFlag(payload.https),
96
+ https: booleanValue(payload.https),
108
97
  monitored_ips: requiredCount(payload.monitored_ips, "monitored_ips"),
109
98
  query_credits: requiredCount(payload.query_credits, "query_credits"),
110
99
  scan_credits: requiredCount(payload.scan_credits, "scan_credits"),
111
- telnet: optionalFlag(payload.telnet),
112
- unlocked: optionalFlag(payload.unlocked),
100
+ telnet: booleanValue(payload.telnet),
101
+ unlocked: booleanValue(payload.unlocked),
113
102
  unlocked_left: optionalCount(payload.unlocked_left, "unlocked_left"),
114
- usage_limits: record(payload.usage_limits)
103
+ usage_limits: asJsonObject(payload.usage_limits)
115
104
  });
116
105
  }
117
106
  async function searchHosts(input, ctx) {
@@ -121,17 +110,17 @@ async function searchHosts(input, ctx) {
121
110
  page: input.page,
122
111
  minify: input.minify
123
112
  });
124
- return compact({
113
+ return compactDefined({
125
114
  matches: objectArray(payload.matches, "matches"),
126
115
  total: requiredCount(payload.total, "total"),
127
- facets: record(payload.facets)
116
+ facets: asJsonObject(payload.facets)
128
117
  });
129
118
  }
130
119
  async function countSearchResults(input, ctx) {
131
120
  const payload = await request(ctx, "/shodan/host/count", { query: input.query, facets: input.facets });
132
- return compact({
121
+ return compactDefined({
133
122
  total: requiredCount(payload.total, "total"),
134
- facets: record(payload.facets)
123
+ facets: asJsonObject(payload.facets)
135
124
  });
136
125
  }
137
126
  async function getHost(input, ctx) {
@@ -148,7 +137,7 @@ async function getDomainInfo(input, ctx) {
148
137
  tags: textArray(payload.tags, "tags"),
149
138
  data: payload.data === void 0 ? [] : objectArray(payload.data, "data"),
150
139
  subdomains: textArray(payload.subdomains, "subdomains"),
151
- more: optionalFlag(payload.more) ?? false
140
+ more: booleanValue(payload.more) ?? false
152
141
  };
153
142
  }
154
143
  async function resolveHostnames(input, ctx) {
@@ -1,32 +1,29 @@
1
+ import {
2
+ createProviderHttpClient
3
+ } from "./chunk-WW2IMPQK.js";
4
+ import {
5
+ asJsonObject,
6
+ trimmedText
7
+ } from "./chunk-JXHMDBAY.js";
1
8
  import {
2
9
  createProviderPlugin,
3
10
  requireCredential,
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-YASUMV2K.js";
13
+ import "./chunk-U5UHT7CX.js";
10
14
  import {
11
15
  TBError,
12
16
  external_exports
13
- } from "./chunk-YB2FLNWI.js";
14
- import "./chunk-MLKGABMK.js";
17
+ } from "./chunk-RVWZN3CI.js";
18
+ import "./chunk-U67V476Y.js";
15
19
 
16
20
  // ../plugins/src/shopify/api.ts
17
21
  var SERVICE = "shopify";
18
22
  var REST_API_VERSION = "2026-04";
19
23
  var MYSHOPIFY_SUFFIX = ".myshopify.com";
20
- function text(value) {
21
- if (typeof value !== "string") return void 0;
22
- const trimmed = value.trim();
23
- return trimmed === "" ? void 0 : trimmed;
24
- }
25
- function record(value) {
26
- return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
27
- }
24
+ var http = createProviderHttpClient({ service: SERVICE });
28
25
  function requireRecord(value, label) {
29
- const result = record(value);
26
+ const result = asJsonObject(value);
30
27
  if (result === void 0) throw new TBError("unavailable", `Shopify \u54CD\u5E94\u7F3A\u5C11 ${label}`, { retryable: true });
31
28
  return result;
32
29
  }
@@ -75,17 +72,17 @@ function shopHost(ctx) {
75
72
  return normalized;
76
73
  }
77
74
  function errorDetail(payload) {
78
- if (typeof payload === "string") return text(payload);
79
- const body = record(payload);
75
+ if (typeof payload === "string") return trimmedText(payload);
76
+ const body = asJsonObject(payload);
80
77
  if (body === void 0) return void 0;
81
78
  const errors = body.errors;
82
79
  if (typeof errors === "string") return errors;
83
80
  if (Array.isArray(errors)) return errors.map((item) => String(item)).join("; ");
84
- const errorRecord = record(errors);
81
+ const errorRecord = asJsonObject(errors);
85
82
  if (errorRecord !== void 0) {
86
83
  return Object.entries(errorRecord).map(([key, value]) => `${key}: ${Array.isArray(value) ? value.join(", ") : String(value)}`).join("; ");
87
84
  }
88
- return text(body.error) ?? text(body.message);
85
+ return trimmedText(body.error) ?? trimmedText(body.message);
89
86
  }
90
87
  function pageInfoForRel(linkHeader, rel) {
91
88
  if (linkHeader === null || linkHeader === "") return null;
@@ -106,42 +103,28 @@ function pageInfoForRel(linkHeader, rel) {
106
103
  return null;
107
104
  }
108
105
  async function request(ctx, path, query) {
109
- const url = new URL(
110
- path.startsWith("/") ? path.slice(1) : path,
111
- `https://${shopHost(ctx)}/admin/api/${REST_API_VERSION}/`
112
- );
113
- for (const [key, value] of Object.entries(query ?? {})) url.searchParams.set(key, value);
114
- const response = await guardedFetch(url.toString(), {
115
- method: "GET",
106
+ const result = await http.request({
107
+ baseUrl: `https://${shopHost(ctx)}/admin/api/${REST_API_VERSION}/`,
108
+ path,
109
+ query: Object.entries(query ?? {}),
116
110
  headers: {
117
111
  "accept": "application/json",
118
112
  "x-shopify-access-token": requireCredential(ctx, SERVICE, "apiKey")
113
+ },
114
+ invalidJsonMessage: "Shopify REST \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
115
+ mapError: ({ data, status }) => {
116
+ const detail = errorDetail(data);
117
+ return upstreamError(
118
+ status,
119
+ detail === void 0 ? `Shopify REST \u8FD4\u56DE HTTP ${status}` : `Shopify REST \u8FD4\u56DE HTTP ${status}: ${detail}`
120
+ );
119
121
  }
120
122
  });
121
- const body = await response.text();
122
- let payload = null;
123
- if (body.trim() !== "") {
124
- try {
125
- payload = JSON.parse(body);
126
- } catch {
127
- if (response.ok) {
128
- throw new TBError("unavailable", "Shopify REST \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94", { retryable: true });
129
- }
130
- payload = body;
131
- }
132
- }
133
- if (!response.ok) {
134
- const detail = errorDetail(payload);
135
- throw upstreamError(
136
- response.status,
137
- detail === void 0 ? `Shopify REST \u8FD4\u56DE HTTP ${response.status}` : `Shopify REST \u8FD4\u56DE HTTP ${response.status}: ${detail}`
138
- );
139
- }
140
123
  return {
141
- payload,
124
+ payload: result.data === void 0 ? null : result.data,
142
125
  pagination: {
143
- nextPageInfo: pageInfoForRel(response.headers.get("link"), "next"),
144
- previousPageInfo: pageInfoForRel(response.headers.get("link"), "previous")
126
+ nextPageInfo: pageInfoForRel(result.headers.get("link"), "next"),
127
+ previousPageInfo: pageInfoForRel(result.headers.get("link"), "previous")
145
128
  }
146
129
  };
147
130
  }
@@ -2,16 +2,15 @@ import {
2
2
  createProviderPlugin,
3
3
  requireApiKey,
4
4
  upstreamError
5
- } from "./chunk-VK3V2WTY.js";
5
+ } from "./chunk-YASUMV2K.js";
6
6
  import {
7
7
  guardedFetch
8
- } from "./chunk-2O27H4Y2.js";
9
- import "./chunk-GKX72JMJ.js";
8
+ } from "./chunk-U5UHT7CX.js";
10
9
  import {
11
10
  TBError,
12
11
  external_exports
13
- } from "./chunk-YB2FLNWI.js";
14
- import "./chunk-MLKGABMK.js";
12
+ } from "./chunk-RVWZN3CI.js";
13
+ import "./chunk-U67V476Y.js";
15
14
 
16
15
  // ../plugins/src/stripe/api.ts
17
16
  var SERVICE = "stripe";