@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,47 +1,38 @@
1
+ import {
2
+ createProviderHttpClient
3
+ } from "./chunk-VLOIDU5U.js";
4
+ import {
5
+ asJsonObject,
6
+ booleanValue,
7
+ compactDefined,
8
+ integerValue,
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/airtable/api.ts
17
24
  var SERVICE = "airtable";
18
25
  var API_BASE = "https://api.airtable.com";
19
26
  var BASES_PATH = "/v0/meta/bases";
27
+ var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
20
28
  var GET_URL_LENGTH_SOFT_LIMIT = 15e3;
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
- }
29
- function boolean(value) {
30
- return typeof value === "boolean" ? value : void 0;
31
- }
32
- function integer(value) {
33
- return typeof value === "number" && Number.isInteger(value) ? value : void 0;
34
- }
35
29
  function requireText(value, field) {
36
- const result = text(value);
30
+ const result = trimmedText(value);
37
31
  if (result === void 0) throw new TBError("invalid_argument", `${field} is required`);
38
32
  return result;
39
33
  }
40
- function compact(input) {
41
- return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0));
42
- }
43
34
  function requireObject(value, label) {
44
- const fields = record(value);
35
+ const fields = asJsonObject(value);
45
36
  if (fields === void 0) throw upstreamError(502, `${label} must be a plain object`);
46
37
  return fields;
47
38
  }
@@ -50,7 +41,7 @@ function objectArray(value, label) {
50
41
  return value.map((item, index) => requireObject(item, `${label}[${index}]`));
51
42
  }
52
43
  function inputObject(value, label) {
53
- const fields = record(value);
44
+ const fields = asJsonObject(value);
54
45
  if (fields === void 0) throw new TBError("invalid_argument", `${label} must be an object`);
55
46
  return fields;
56
47
  }
@@ -59,54 +50,55 @@ function buildUrl(path, query) {
59
50
  for (const [key, value] of query ?? []) url.searchParams.append(key, value);
60
51
  return url.toString();
61
52
  }
62
- function headers(apiKey, hasBody) {
63
- return {
64
- accept: "application/json",
65
- authorization: `Bearer ${apiKey}`,
66
- ...hasBody ? { "content-type": "application/json" } : {}
67
- };
68
- }
69
53
  function errorMessage(payload, status) {
70
54
  if (typeof payload === "string" && payload !== "") return payload;
71
- const error = record(record(payload)?.error);
72
- const message = text(error?.message);
73
- const type = text(error?.type);
55
+ const error = asJsonObject(asJsonObject(payload)?.error);
56
+ const message = trimmedText(error?.message);
57
+ const type = trimmedText(error?.type);
74
58
  if (message !== void 0 && type !== void 0) return `${message} (${type})`;
75
59
  return message ?? type ?? `airtable request failed with ${status}`;
76
60
  }
77
- async function request(ctx, input) {
78
- const apiKey = requireApiKey(ctx, SERVICE);
79
- let response;
80
- try {
81
- response = await guardedFetch(buildUrl(input.path, input.query), {
82
- method: input.method ?? "GET",
83
- headers: headers(apiKey, input.body !== void 0),
84
- body: input.body === void 0 ? void 0 : JSON.stringify(input.body)
85
- });
86
- } catch (error) {
87
- if (error instanceof TBError) throw error;
88
- const detail = error instanceof Error && error.message !== "" ? error.message : "unknown request error";
89
- throw upstreamError(502, `airtable request failed: ${detail}`);
90
- }
91
- const contentType = response.headers.get("content-type") ?? "";
92
- const raw = await response.text().catch(() => "");
93
- let payload = null;
61
+ function responsePayload(result) {
62
+ const contentType = result.headers.get("content-type") ?? "";
94
63
  if (contentType.includes("application/json")) {
64
+ if (result.bodyKind === "json") return result.data;
65
+ if (result.bodyKind === "empty" && (result.status === 204 || result.status === 205)) return null;
66
+ throw upstreamError(502, "airtable response parsing failed: invalid JSON");
67
+ }
68
+ if (result.bodyKind === "empty") return null;
69
+ if (result.bodyKind === "text") {
95
70
  try {
96
- payload = JSON.parse(raw);
97
- } catch (error) {
98
- const detail = error instanceof Error && error.message !== "" ? error.message : "unknown parsing error";
99
- throw upstreamError(502, `airtable response parsing failed: ${detail}`);
100
- }
101
- } else if (raw !== "") {
102
- try {
103
- payload = JSON.parse(raw);
71
+ return JSON.parse(String(result.data));
104
72
  } catch {
105
- payload = raw;
73
+ return result.data;
106
74
  }
107
75
  }
108
- if (!response.ok) throw upstreamError(response.status, errorMessage(payload, response.status));
109
- return payload;
76
+ return result.data;
77
+ }
78
+ function mapAirtableError(context) {
79
+ try {
80
+ return upstreamError(context.status, errorMessage(responsePayload(context), context.status));
81
+ } catch {
82
+ return upstreamError(502, "airtable response parsing failed: invalid JSON");
83
+ }
84
+ }
85
+ async function request(ctx, input) {
86
+ const apiKey = requireApiKey(ctx, SERVICE);
87
+ const result = await http.request({
88
+ path: input.path,
89
+ method: input.method ?? "GET",
90
+ query: input.query,
91
+ headers: { accept: "application/json", authorization: `Bearer ${apiKey}` },
92
+ ...input.body === void 0 ? {} : { json: input.body },
93
+ invalidJson: "text",
94
+ responseType: "auto",
95
+ mapError: mapAirtableError,
96
+ mapTransportError: ({ message }) => upstreamError(
97
+ 502,
98
+ `airtable request failed: ${message ?? "unknown request error"}`
99
+ )
100
+ });
101
+ return responsePayload(result);
110
102
  }
111
103
  function recordCollectionPath(input) {
112
104
  const baseId = encodeURIComponent(requireText(input.baseId, "baseId"));
@@ -119,11 +111,11 @@ function includeQuery(include) {
119
111
  function commonReadQuery(input) {
120
112
  const query = [];
121
113
  for (const field of input.fields ?? []) query.push(["fields[]", requireText(field, "fields item")]);
122
- const cellFormat = text(input.cellFormat);
123
- const timeZone = text(input.timeZone);
124
- const userLocale = text(input.userLocale);
125
- const returnFieldsByFieldId = boolean(input.returnFieldsByFieldId);
126
- const includeDateDependencyMetadata = boolean(input.includeDateDependencyMetadata);
114
+ const cellFormat = trimmedText(input.cellFormat);
115
+ const timeZone = trimmedText(input.timeZone);
116
+ const userLocale = trimmedText(input.userLocale);
117
+ const returnFieldsByFieldId = booleanValue(input.returnFieldsByFieldId);
118
+ const includeDateDependencyMetadata = booleanValue(input.includeDateDependencyMetadata);
127
119
  if (cellFormat !== void 0) query.push(["cellFormat", cellFormat]);
128
120
  if (timeZone !== void 0) query.push(["timeZone", timeZone]);
129
121
  if (userLocale !== void 0) query.push(["userLocale", userLocale]);
@@ -135,11 +127,11 @@ function commonReadQuery(input) {
135
127
  }
136
128
  function listRecordsQuery(input) {
137
129
  const query = commonReadQuery(input);
138
- const offset = text(input.offset);
139
- const pageSize = integer(input.pageSize);
140
- const maxRecords = integer(input.maxRecords);
141
- const view = text(input.view);
142
- const filterByFormula = text(input.filterByFormula);
130
+ const offset = trimmedText(input.offset);
131
+ const pageSize = integerValue(input.pageSize);
132
+ const maxRecords = integerValue(input.maxRecords);
133
+ const view = trimmedText(input.view);
134
+ const filterByFormula = trimmedText(input.filterByFormula);
143
135
  if (offset !== void 0) query.push(["offset", offset]);
144
136
  if (pageSize !== void 0) query.push(["pageSize", String(pageSize)]);
145
137
  if (maxRecords !== void 0) query.push(["maxRecords", String(maxRecords)]);
@@ -148,7 +140,7 @@ function listRecordsQuery(input) {
148
140
  for (const [index, item] of (input.sort ?? []).entries()) {
149
141
  const rule = inputObject(item, `sort[${index}]`);
150
142
  query.push([`sort[${index}][field]`, requireText(rule.field, `sort[${index}].field`)]);
151
- const direction = text(rule.direction);
143
+ const direction = trimmedText(rule.direction);
152
144
  if (direction !== void 0) query.push([`sort[${index}][direction]`, direction]);
153
145
  }
154
146
  for (const item of input.recordMetadata ?? []) {
@@ -157,25 +149,25 @@ function listRecordsQuery(input) {
157
149
  return query;
158
150
  }
159
151
  function listRecordsPostBody(input) {
160
- return compact({
161
- view: text(input.view),
152
+ return compactDefined({
153
+ view: trimmedText(input.view),
162
154
  fields: input.fields === void 0 ? void 0 : input.fields.map((field) => requireText(field, "fields item")),
163
155
  sort: input.sort === void 0 ? void 0 : input.sort.map((item, index) => {
164
156
  const rule = inputObject(item, `sort[${index}]`);
165
- return compact({
157
+ return compactDefined({
166
158
  field: requireText(rule.field, `sort[${index}].field`),
167
- direction: text(rule.direction)
159
+ direction: trimmedText(rule.direction)
168
160
  });
169
161
  }),
170
- filterByFormula: text(input.filterByFormula),
171
- maxRecords: integer(input.maxRecords),
172
- pageSize: integer(input.pageSize),
173
- offset: text(input.offset),
174
- cellFormat: text(input.cellFormat),
175
- timeZone: text(input.timeZone),
176
- userLocale: text(input.userLocale),
177
- returnFieldsByFieldId: boolean(input.returnFieldsByFieldId),
178
- includeDateDependencyMetadata: boolean(input.includeDateDependencyMetadata),
162
+ filterByFormula: trimmedText(input.filterByFormula),
163
+ maxRecords: integerValue(input.maxRecords),
164
+ pageSize: integerValue(input.pageSize),
165
+ offset: trimmedText(input.offset),
166
+ cellFormat: trimmedText(input.cellFormat),
167
+ timeZone: trimmedText(input.timeZone),
168
+ userLocale: trimmedText(input.userLocale),
169
+ returnFieldsByFieldId: booleanValue(input.returnFieldsByFieldId),
170
+ includeDateDependencyMetadata: booleanValue(input.includeDateDependencyMetadata),
179
171
  recordMetadata: input.recordMetadata === void 0 ? void 0 : input.recordMetadata.map((item) => requireText(item, "recordMetadata item"))
180
172
  });
181
173
  }
@@ -184,12 +176,12 @@ function fieldConfig(value, label) {
184
176
  delete field.baseId;
185
177
  delete field.tableId;
186
178
  delete field.columnId;
187
- return compact({
179
+ return compactDefined({
188
180
  ...field,
189
181
  name: requireText(field.name, `${label}.name`),
190
182
  type: requireText(field.type, `${label}.type`),
191
- description: text(field.description),
192
- options: record(field.options)
183
+ description: trimmedText(field.description),
184
+ options: asJsonObject(field.options)
193
185
  });
194
186
  }
195
187
  function fieldConfigs(value, label) {
@@ -202,21 +194,21 @@ function tableConfigs(value) {
202
194
  if (tables.length === 0) throw new TBError("invalid_argument", "tables is required");
203
195
  return tables.map((table, index) => {
204
196
  const config = inputObject(table, `tables[${index}]`);
205
- return compact({
197
+ return compactDefined({
206
198
  ...config,
207
199
  name: requireText(config.name, `tables[${index}].name`),
208
- description: text(config.description),
200
+ description: trimmedText(config.description),
209
201
  fields: fieldConfigs(config.fields, `tables[${index}].fields`)
210
202
  });
211
203
  });
212
204
  }
213
205
  function recordFields(value, label) {
214
- const fields = record(value);
206
+ const fields = asJsonObject(value);
215
207
  if (fields === void 0) throw new TBError("invalid_argument", `${label} must be an object`);
216
208
  return fields;
217
209
  }
218
210
  async function listBases(input, ctx) {
219
- const offset = text(input.offset);
211
+ const offset = trimmedText(input.offset);
220
212
  const payload = requireObject(
221
213
  await request(ctx, { path: BASES_PATH, query: offset === void 0 ? [] : [["offset", offset]] }),
222
214
  "airtable list bases response"
@@ -224,7 +216,7 @@ async function listBases(input, ctx) {
224
216
  return {
225
217
  bases: objectArray(payload.bases, "bases"),
226
218
  // 翻页靠它:没有下一页时给 null,压成 undefined 会让调用方分不清"到底了"。
227
- offset: text(payload.offset) ?? null
219
+ offset: trimmedText(payload.offset) ?? null
228
220
  };
229
221
  }
230
222
  async function getBaseCollaborators(input, ctx) {
@@ -267,9 +259,9 @@ async function createTable(input, ctx) {
267
259
  const payload = await request(ctx, {
268
260
  method: "POST",
269
261
  path: `${BASES_PATH}/${encodeURIComponent(requireText(input.baseId, "baseId"))}/tables`,
270
- body: compact({
262
+ body: compactDefined({
271
263
  name: requireText(input.name, "name"),
272
- description: text(input.description),
264
+ description: trimmedText(input.description),
273
265
  fields: fieldConfigs(input.fields, "fields")
274
266
  })
275
267
  });
@@ -281,10 +273,10 @@ async function updateTable(input, ctx) {
281
273
  const payload = await request(ctx, {
282
274
  method: "PATCH",
283
275
  path: `${BASES_PATH}/${baseId}/tables/${table}`,
284
- body: compact({
285
- name: text(input.name),
286
- description: text(input.description),
287
- dateDependencySettings: record(input.dateDependencySettings)
276
+ body: compactDefined({
277
+ name: trimmedText(input.name),
278
+ description: trimmedText(input.description),
279
+ dateDependencySettings: asJsonObject(input.dateDependencySettings)
288
280
  })
289
281
  });
290
282
  return requireObject(payload, "airtable update table response");
@@ -306,10 +298,10 @@ async function updateField(input, ctx) {
306
298
  const payload = await request(ctx, {
307
299
  method: "PATCH",
308
300
  path: `${BASES_PATH}/${baseId}/tables/${tableId}/fields/${columnId}`,
309
- body: compact({
310
- name: text(input.name),
311
- description: text(input.description),
312
- options: record(input.options)
301
+ body: compactDefined({
302
+ name: trimmedText(input.name),
303
+ description: trimmedText(input.description),
304
+ options: asJsonObject(input.options)
313
305
  })
314
306
  });
315
307
  return requireObject(payload, "airtable update field response");
@@ -324,7 +316,7 @@ async function listRecords(input, ctx) {
324
316
  );
325
317
  return {
326
318
  records: objectArray(payload.records, "records"),
327
- offset: text(payload.offset) ?? null
319
+ offset: trimmedText(payload.offset) ?? null
328
320
  };
329
321
  }
330
322
  async function getRecord(input, ctx) {
@@ -341,13 +333,13 @@ async function createRecords(input, ctx) {
341
333
  await request(ctx, {
342
334
  method: "POST",
343
335
  path: recordCollectionPath(input),
344
- body: compact({
336
+ body: compactDefined({
345
337
  // 创建时只发 fields:带上 id 会被 Airtable 当成非法字段。
346
338
  records: records.map((item, index) => ({
347
339
  fields: recordFields(inputObject(item, `records[${index}]`).fields, `records[${index}].fields`)
348
340
  })),
349
- typecast: boolean(input.typecast),
350
- returnFieldsByFieldId: boolean(input.returnFieldsByFieldId)
341
+ typecast: booleanValue(input.typecast),
342
+ returnFieldsByFieldId: booleanValue(input.returnFieldsByFieldId)
351
343
  })
352
344
  }),
353
345
  "airtable create records response"
@@ -361,7 +353,7 @@ async function updateRecords(input, ctx) {
361
353
  await request(ctx, {
362
354
  method: "PATCH",
363
355
  path: recordCollectionPath(input),
364
- body: compact({
356
+ body: compactDefined({
365
357
  records: records.map((item, index) => {
366
358
  const entry = inputObject(item, `records[${index}]`);
367
359
  return {
@@ -369,8 +361,8 @@ async function updateRecords(input, ctx) {
369
361
  fields: recordFields(entry.fields, `records[${index}].fields`)
370
362
  };
371
363
  }),
372
- typecast: boolean(input.typecast),
373
- returnFieldsByFieldId: boolean(input.returnFieldsByFieldId)
364
+ typecast: booleanValue(input.typecast),
365
+ returnFieldsByFieldId: booleanValue(input.returnFieldsByFieldId)
374
366
  })
375
367
  }),
376
368
  "airtable update records response"
@@ -1,17 +1,18 @@
1
+ import {
2
+ createProviderHttpClient
3
+ } from "./chunk-VLOIDU5U.js";
4
+ import "./chunk-JXHMDBAY.js";
1
5
  import {
2
6
  createProviderPlugin,
3
7
  requireApiKey,
4
8
  upstreamError
5
- } from "./chunk-VK3V2WTY.js";
6
- import {
7
- guardedFetch
8
- } from "./chunk-2O27H4Y2.js";
9
- import "./chunk-GKX72JMJ.js";
9
+ } from "./chunk-B4P6YZFS.js";
10
+ import "./chunk-SWBNHIO4.js";
10
11
  import {
11
12
  TBError,
12
13
  external_exports
13
- } from "./chunk-YB2FLNWI.js";
14
- import "./chunk-MLKGABMK.js";
14
+ } from "./chunk-OKRZPQ3R.js";
15
+ import "./chunk-U67V476Y.js";
15
16
 
16
17
  // ../plugins/src/alt_text_generator_ai/schema.ts
17
18
  var generateAltTextInput = external_exports.strictObject({
@@ -31,7 +32,11 @@ var altTextGeneratorAiActions = {
31
32
 
32
33
  // ../plugins/src/alt_text_generator_ai/api.ts
33
34
  var SERVICE = "alt_text_generator_ai";
34
- var BASE_URL = "https://alttextgeneratorai.com";
35
+ var http = createProviderHttpClient({
36
+ baseUrl: "https://alttextgeneratorai.com/",
37
+ crossOriginRedirect: "error",
38
+ service: SERVICE
39
+ });
35
40
  function unwrapText(body) {
36
41
  const trimmed = body.trim();
37
42
  if (trimmed === "") return void 0;
@@ -43,16 +48,20 @@ function unwrapText(body) {
43
48
  return trimmed;
44
49
  }
45
50
  async function generateAltText(input, ctx) {
46
- const response = await guardedFetch(`${BASE_URL}/api/wp`, {
51
+ const apiKey = requireApiKey(ctx, SERVICE);
52
+ const { data } = await http.request({
53
+ path: "api/wp",
47
54
  method: "POST",
48
- headers: { "accept": "text/plain", "content-type": "application/json" },
49
- body: JSON.stringify({ image: input.imageUrl ?? "", wpkey: requireApiKey(ctx, SERVICE) })
55
+ headers: { accept: "text/plain" },
56
+ json: { image: input.imageUrl ?? "", wpkey: apiKey },
57
+ responseType: "text",
58
+ sensitiveValues: [apiKey],
59
+ mapError: ({ data: body, status }) => upstreamError(
60
+ status,
61
+ typeof body === "string" && body.trim() !== "" ? body.trim() : `Alt Text Generator AI \u8FD4\u56DE HTTP ${status}`
62
+ )
50
63
  });
51
- const body = await response.text();
52
- if (!response.ok) {
53
- throw upstreamError(response.status, body.trim() || `Alt Text Generator AI \u8FD4\u56DE HTTP ${response.status}`);
54
- }
55
- const altText = unwrapText(body);
64
+ const altText = unwrapText(data ?? "");
56
65
  if (altText === void 0) {
57
66
  throw new TBError("unavailable", "Alt Text Generator AI \u8FD4\u56DE\u4E86\u7A7A\u7ED3\u679C", { retryable: true });
58
67
  }