@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,39 @@
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";
15
+ } from "./chunk-B4P6YZFS.js";
6
16
  import {
7
- assertPublicHttpUrl,
8
- guardedFetch
9
- } from "./chunk-2O27H4Y2.js";
10
- import "./chunk-GKX72JMJ.js";
17
+ assertPublicHttpUrl
18
+ } from "./chunk-SWBNHIO4.js";
11
19
  import {
12
20
  TBError,
13
21
  external_exports
14
- } from "./chunk-YB2FLNWI.js";
15
- import "./chunk-MLKGABMK.js";
22
+ } from "./chunk-OKRZPQ3R.js";
23
+ import "./chunk-U67V476Y.js";
16
24
 
17
25
  // ../plugins/src/telegram/api.ts
18
26
  var SERVICE = "telegram";
19
27
  var API_BASE = "https://api.telegram.org";
20
28
  var REQUEST_TIMEOUT_MS = 3e4;
21
- function text(value) {
22
- if (typeof value !== "string") return void 0;
23
- const trimmed = value.trim();
24
- return trimmed === "" ? void 0 : trimmed;
25
- }
26
- function num(value) {
27
- return typeof value === "number" && Number.isFinite(value) ? value : void 0;
28
- }
29
- function bool(value) {
30
- return typeof value === "boolean" ? value : void 0;
31
- }
32
- function record(value) {
33
- return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
34
- }
29
+ var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
35
30
  function asRecord(value) {
36
- const result = record(value);
31
+ const result = asJsonObject(value);
37
32
  if (result === void 0) {
38
33
  throw new TBError("unavailable", "Telegram \u8FD4\u56DE\u4E86\u975E\u9884\u671F\u7684\u5BF9\u8C61\u8D1F\u8F7D", { retryable: true });
39
34
  }
40
35
  return result;
41
36
  }
42
- function compact(value) {
43
- return Object.fromEntries(Object.entries(value).filter(([, child]) => child !== void 0));
44
- }
45
37
  function assertBotToken(botToken) {
46
38
  if (botToken.length === 0 || /[/?#\s]/u.test(botToken)) {
47
39
  throw new TBError("invalid_argument", "telegram bot token is malformed");
@@ -51,46 +43,45 @@ function methodUrl(botToken, method) {
51
43
  assertBotToken(botToken);
52
44
  return `${API_BASE}/bot${botToken}/${method}`;
53
45
  }
54
- async function readEnvelope(response) {
46
+ function readEnvelope(response) {
55
47
  if ((response.headers.get("content-type") ?? "").includes("application/json")) {
56
- return await response.json().then((value) => record(value) ?? {}).catch(() => ({}));
48
+ return response.bodyKind === "json" ? asJsonObject(response.data) ?? {} : {};
57
49
  }
58
- const body = await response.text().catch(() => "");
50
+ const body = typeof response.data === "string" ? response.data : "";
59
51
  return {
60
52
  ok: false,
61
53
  description: body === "" ? `telegram request failed with ${response.status}` : body,
62
54
  error_code: response.status
63
55
  };
64
56
  }
65
- function telegramError(response, payload, method) {
66
- const code = num(payload.error_code) ?? (response.ok ? void 0 : response.status);
57
+ function telegramError(statusCode, responseOk, payload, method) {
58
+ const code = finiteNumber(payload.error_code) ?? (responseOk ? void 0 : statusCode);
67
59
  const status = code ?? 502;
68
- const description = text(payload.description) ?? `telegram ${method} request failed with ${status}`;
60
+ const description = trimmedText(payload.description) ?? `telegram ${method} request failed with ${status}`;
69
61
  if (status === 429) {
70
- const retryAfter = num(record(payload.parameters)?.retry_after);
62
+ const retryAfter = finiteNumber(asJsonObject(payload.parameters)?.retry_after);
71
63
  return upstreamError(429, retryAfter === void 0 ? description : `${description} Retry after ${retryAfter} seconds.`);
72
64
  }
73
65
  return upstreamError(status, description);
74
66
  }
75
67
  async function request(ctx, method, body) {
76
- const url = methodUrl(requireApiKey(ctx, SERVICE), method);
77
- const timeoutSignal = AbortSignal.timeout(REQUEST_TIMEOUT_MS);
78
- let response;
79
- try {
80
- response = await guardedFetch(url, {
81
- method: body === void 0 ? "GET" : "POST",
82
- ...body === void 0 ? {} : { headers: { "content-type": "application/json" }, body: JSON.stringify(body) },
83
- signal: timeoutSignal
84
- });
85
- } catch (error) {
86
- if (error instanceof TBError) throw error;
87
- if (timeoutSignal.aborted) {
88
- throw upstreamError(504, `telegram ${method} \u8BF7\u6C42\u8D85\u65F6(${REQUEST_TIMEOUT_MS / 1e3} \u79D2)`);
89
- }
90
- throw upstreamError(502, `telegram ${method} \u8BF7\u6C42\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`);
91
- }
92
- const payload = await readEnvelope(response);
93
- if (!response.ok || payload.ok !== true) throw telegramError(response, payload, method);
68
+ const botToken = requireApiKey(ctx, SERVICE);
69
+ const result = await http.request({
70
+ path: methodUrl(botToken, method),
71
+ method: body === void 0 ? "GET" : "POST",
72
+ ...body === void 0 ? {} : { json: body },
73
+ responseType: "auto",
74
+ invalidJson: "text",
75
+ timeoutMs: REQUEST_TIMEOUT_MS,
76
+ sensitiveValues: [botToken],
77
+ mapError: (context) => {
78
+ const payload2 = readEnvelope(context);
79
+ return telegramError(context.status, false, payload2, method);
80
+ },
81
+ mapTransportError: ({ kind, message }) => kind === "timeout" ? upstreamError(504, `telegram ${method} \u8BF7\u6C42\u8D85\u65F6(${REQUEST_TIMEOUT_MS / 1e3} \u79D2)`) : upstreamError(502, `telegram ${method} \u8BF7\u6C42\u5931\u8D25: ${message ?? "\u672A\u77E5\u9519\u8BEF"}`)
82
+ });
83
+ const payload = readEnvelope(result);
84
+ if (payload.ok !== true) throw telegramError(result.status, true, payload, method);
94
85
  if (payload.result === void 0) {
95
86
  throw new TBError("unavailable", `telegram ${method} response did not include result`, { retryable: true });
96
87
  }
@@ -108,19 +99,19 @@ function jsonLike(value) {
108
99
  } catch {
109
100
  throw new TBError("invalid_argument", "invalid JSON string input");
110
101
  }
111
- const result = record(parsed);
102
+ const result = asJsonObject(parsed);
112
103
  if (result === void 0) throw new TBError("invalid_argument", "JSON string input must decode to an object");
113
104
  return result;
114
105
  }
115
- return record(value);
106
+ return asJsonObject(value);
116
107
  }
117
108
  function publicUrl(value) {
118
- const candidate = text(value);
109
+ const candidate = trimmedText(value);
119
110
  if (candidate === void 0) return void 0;
120
111
  return assertPublicHttpUrl(candidate).toString();
121
112
  }
122
113
  function urlOrFileId(value) {
123
- const candidate = text(value);
114
+ const candidate = trimmedText(value);
124
115
  if (candidate === void 0 || !/^https?:\/\//iu.test(candidate)) return value;
125
116
  return publicUrl(candidate);
126
117
  }
@@ -129,24 +120,24 @@ function normalizeUser(value) {
129
120
  id: Number(value.id),
130
121
  isBot: Boolean(value.is_bot),
131
122
  firstName: String(value.first_name ?? ""),
132
- username: text(value.username),
133
- languageCode: text(value.language_code),
134
- canJoinGroups: bool(value.can_join_groups),
135
- canReadAllGroupMessages: bool(value.can_read_all_group_messages),
136
- supportsInlineQueries: bool(value.supports_inline_queries),
137
- canConnectToBusiness: bool(value.can_connect_to_business),
138
- hasMainWebApp: bool(value.has_main_web_app)
123
+ username: trimmedText(value.username),
124
+ languageCode: trimmedText(value.language_code),
125
+ canJoinGroups: booleanValue(value.can_join_groups),
126
+ canReadAllGroupMessages: booleanValue(value.can_read_all_group_messages),
127
+ supportsInlineQueries: booleanValue(value.supports_inline_queries),
128
+ canConnectToBusiness: booleanValue(value.can_connect_to_business),
129
+ hasMainWebApp: booleanValue(value.has_main_web_app)
139
130
  };
140
131
  }
141
132
  function normalizeChat(value) {
142
133
  return {
143
134
  id: Number(value.id),
144
135
  type: String(value.type ?? ""),
145
- title: text(value.title),
146
- username: text(value.username),
147
- firstName: text(value.first_name),
148
- lastName: text(value.last_name),
149
- isForum: bool(value.is_forum)
136
+ title: trimmedText(value.title),
137
+ username: trimmedText(value.username),
138
+ firstName: trimmedText(value.first_name),
139
+ lastName: trimmedText(value.last_name),
140
+ isForum: booleanValue(value.is_forum)
150
141
  };
151
142
  }
152
143
  function normalizePhotoSize(value) {
@@ -155,16 +146,16 @@ function normalizePhotoSize(value) {
155
146
  fileUniqueId: String(value.file_unique_id ?? ""),
156
147
  width: Number(value.width),
157
148
  height: Number(value.height),
158
- fileSize: num(value.file_size)
149
+ fileSize: finiteNumber(value.file_size)
159
150
  };
160
151
  }
161
152
  function normalizeDocument(value) {
162
153
  return {
163
154
  fileId: String(value.file_id ?? ""),
164
155
  fileUniqueId: String(value.file_unique_id ?? ""),
165
- fileName: text(value.file_name),
166
- mimeType: text(value.mime_type),
167
- fileSize: num(value.file_size)
156
+ fileName: trimmedText(value.file_name),
157
+ mimeType: trimmedText(value.mime_type),
158
+ fileSize: finiteNumber(value.file_size)
168
159
  };
169
160
  }
170
161
  function normalizeVideoQuality(value) {
@@ -174,7 +165,7 @@ function normalizeVideoQuality(value) {
174
165
  width: Number(value.width),
175
166
  height: Number(value.height),
176
167
  codec: String(value.codec ?? ""),
177
- fileSize: num(value.file_size)
168
+ fileSize: finiteNumber(value.file_size)
178
169
  };
179
170
  }
180
171
  function normalizeVideo(value) {
@@ -186,11 +177,11 @@ function normalizeVideo(value) {
186
177
  duration: Number(value.duration),
187
178
  thumbnail: value.thumbnail ? normalizePhotoSize(asRecord(value.thumbnail)) : void 0,
188
179
  cover: Array.isArray(value.cover) ? value.cover.map((item) => normalizePhotoSize(asRecord(item))) : void 0,
189
- startTimestamp: num(value.start_timestamp),
180
+ startTimestamp: finiteNumber(value.start_timestamp),
190
181
  qualities: Array.isArray(value.qualities) ? value.qualities.map((item) => normalizeVideoQuality(asRecord(item))) : void 0,
191
- fileName: text(value.file_name),
192
- mimeType: text(value.mime_type),
193
- fileSize: num(value.file_size)
182
+ fileName: trimmedText(value.file_name),
183
+ mimeType: trimmedText(value.mime_type),
184
+ fileSize: finiteNumber(value.file_size)
194
185
  };
195
186
  }
196
187
  function normalizeAudio(value) {
@@ -198,11 +189,11 @@ function normalizeAudio(value) {
198
189
  fileId: String(value.file_id ?? ""),
199
190
  fileUniqueId: String(value.file_unique_id ?? ""),
200
191
  duration: Number(value.duration),
201
- performer: text(value.performer),
202
- title: text(value.title),
203
- fileName: text(value.file_name),
204
- mimeType: text(value.mime_type),
205
- fileSize: num(value.file_size),
192
+ performer: trimmedText(value.performer),
193
+ title: trimmedText(value.title),
194
+ fileName: trimmedText(value.file_name),
195
+ mimeType: trimmedText(value.mime_type),
196
+ fileSize: finiteNumber(value.file_size),
206
197
  thumbnail: value.thumbnail ? normalizePhotoSize(asRecord(value.thumbnail)) : void 0
207
198
  };
208
199
  }
@@ -211,8 +202,8 @@ function normalizeVoice(value) {
211
202
  fileId: String(value.file_id ?? ""),
212
203
  fileUniqueId: String(value.file_unique_id ?? ""),
213
204
  duration: Number(value.duration),
214
- mimeType: text(value.mime_type),
215
- fileSize: num(value.file_size)
205
+ mimeType: trimmedText(value.mime_type),
206
+ fileSize: finiteNumber(value.file_size)
216
207
  };
217
208
  }
218
209
  function normalizeAnimation(value) {
@@ -223,28 +214,28 @@ function normalizeAnimation(value) {
223
214
  height: Number(value.height),
224
215
  duration: Number(value.duration),
225
216
  thumbnail: value.thumbnail ? normalizePhotoSize(asRecord(value.thumbnail)) : void 0,
226
- fileName: text(value.file_name),
227
- mimeType: text(value.mime_type),
228
- fileSize: num(value.file_size)
217
+ fileName: trimmedText(value.file_name),
218
+ mimeType: trimmedText(value.mime_type),
219
+ fileSize: finiteNumber(value.file_size)
229
220
  };
230
221
  }
231
222
  function normalizeContact(value) {
232
223
  return {
233
224
  phoneNumber: String(value.phone_number ?? ""),
234
225
  firstName: String(value.first_name ?? ""),
235
- lastName: text(value.last_name),
236
- userId: num(value.user_id),
237
- vcard: text(value.vcard)
226
+ lastName: trimmedText(value.last_name),
227
+ userId: finiteNumber(value.user_id),
228
+ vcard: trimmedText(value.vcard)
238
229
  };
239
230
  }
240
231
  function normalizeLocation(value) {
241
232
  return {
242
233
  latitude: Number(value.latitude),
243
234
  longitude: Number(value.longitude),
244
- horizontalAccuracy: num(value.horizontal_accuracy),
245
- livePeriod: num(value.live_period),
246
- heading: num(value.heading),
247
- proximityAlertRadius: num(value.proximity_alert_radius)
235
+ horizontalAccuracy: finiteNumber(value.horizontal_accuracy),
236
+ livePeriod: finiteNumber(value.live_period),
237
+ heading: finiteNumber(value.heading),
238
+ proximityAlertRadius: finiteNumber(value.proximity_alert_radius)
248
239
  };
249
240
  }
250
241
  function normalizeVenue(value) {
@@ -252,10 +243,10 @@ function normalizeVenue(value) {
252
243
  location: normalizeLocation(asRecord(value.location)),
253
244
  title: String(value.title ?? ""),
254
245
  address: String(value.address ?? ""),
255
- foursquareId: text(value.foursquare_id),
256
- foursquareType: text(value.foursquare_type),
257
- googlePlaceId: text(value.google_place_id),
258
- googlePlaceType: text(value.google_place_type)
246
+ foursquareId: trimmedText(value.foursquare_id),
247
+ foursquareType: trimmedText(value.foursquare_type),
248
+ googlePlaceId: trimmedText(value.google_place_id),
249
+ googlePlaceType: trimmedText(value.google_place_type)
259
250
  };
260
251
  }
261
252
  function normalizeDice(value) {
@@ -277,10 +268,10 @@ function normalizePoll(value) {
277
268
  isAnonymous: Boolean(value.is_anonymous),
278
269
  type: value.type === "quiz" ? "quiz" : "regular",
279
270
  allowsMultipleAnswers: Boolean(value.allows_multiple_answers),
280
- closeDate: num(value.close_date),
281
- openPeriod: num(value.open_period),
282
- explanation: text(value.explanation),
283
- correctOptionId: num(value.correct_option_id)
271
+ closeDate: finiteNumber(value.close_date),
272
+ openPeriod: finiteNumber(value.open_period),
273
+ explanation: trimmedText(value.explanation),
274
+ correctOptionId: finiteNumber(value.correct_option_id)
284
275
  };
285
276
  }
286
277
  function normalizeMessage(value) {
@@ -290,22 +281,22 @@ function normalizeMessage(value) {
290
281
  chat: normalizeChat(asRecord(value.chat)),
291
282
  from: value.from ? normalizeUser(asRecord(value.from)) : void 0,
292
283
  senderChat: value.sender_chat ? normalizeChat(asRecord(value.sender_chat)) : void 0,
293
- text: text(value.text),
294
- caption: text(value.caption),
284
+ text: trimmedText(value.text),
285
+ caption: trimmedText(value.caption),
295
286
  photo: Array.isArray(value.photo) ? value.photo.map((item) => normalizePhotoSize(asRecord(item))) : void 0,
296
287
  document: value.document ? normalizeDocument(asRecord(value.document)) : void 0,
297
288
  location: value.location ? normalizeLocation(asRecord(value.location)) : void 0,
298
289
  poll: value.poll ? normalizePoll(asRecord(value.poll)) : void 0,
299
290
  entities: Array.isArray(value.entities) ? value.entities.map((item) => asRecord(item)) : void 0,
300
291
  captionEntities: Array.isArray(value.caption_entities) ? value.caption_entities.map((item) => asRecord(item)) : void 0,
301
- forwardDate: num(value.forward_date),
292
+ forwardDate: finiteNumber(value.forward_date),
302
293
  forwardFrom: value.forward_from ? normalizeUser(asRecord(value.forward_from)) : void 0,
303
294
  forwardFromChat: value.forward_from_chat ? normalizeChat(asRecord(value.forward_from_chat)) : void 0,
304
- forwardFromMessageId: num(value.forward_from_message_id),
305
- forwardSignature: text(value.forward_signature),
306
- forwardSenderName: text(value.forward_sender_name),
295
+ forwardFromMessageId: finiteNumber(value.forward_from_message_id),
296
+ forwardSignature: trimmedText(value.forward_signature),
297
+ forwardSenderName: trimmedText(value.forward_sender_name),
307
298
  linkPreviewOptions: value.link_preview_options ? asRecord(value.link_preview_options) : void 0,
308
- businessConnectionId: text(value.business_connection_id),
299
+ businessConnectionId: trimmedText(value.business_connection_id),
309
300
  video: value.video ? normalizeVideo(asRecord(value.video)) : void 0,
310
301
  audio: value.audio ? normalizeAudio(asRecord(value.audio)) : void 0,
311
302
  voice: value.voice ? normalizeVoice(asRecord(value.voice)) : void 0,
@@ -317,20 +308,20 @@ function normalizeMessage(value) {
317
308
  }
318
309
  function normalizeBusinessBotRights(value) {
319
310
  return {
320
- canReply: bool(value.can_reply),
321
- canReadMessages: bool(value.can_read_messages),
322
- canDeleteSentMessages: bool(value.can_delete_sent_messages),
323
- canDeleteAllMessages: bool(value.can_delete_all_messages),
324
- canEditName: bool(value.can_edit_name),
325
- canEditBio: bool(value.can_edit_bio),
326
- canEditProfilePhoto: bool(value.can_edit_profile_photo),
327
- canEditUsername: bool(value.can_edit_username),
328
- canChangeGiftSettings: bool(value.can_change_gift_settings),
329
- canViewGiftsAndStars: bool(value.can_view_gifts_and_stars),
330
- canConvertGiftsToStars: bool(value.can_convert_gifts_to_stars),
331
- canTransferAndUpgradeGifts: bool(value.can_transfer_and_upgrade_gifts),
332
- canTransferStars: bool(value.can_transfer_stars),
333
- canManageStories: bool(value.can_manage_stories)
311
+ canReply: booleanValue(value.can_reply),
312
+ canReadMessages: booleanValue(value.can_read_messages),
313
+ canDeleteSentMessages: booleanValue(value.can_delete_sent_messages),
314
+ canDeleteAllMessages: booleanValue(value.can_delete_all_messages),
315
+ canEditName: booleanValue(value.can_edit_name),
316
+ canEditBio: booleanValue(value.can_edit_bio),
317
+ canEditProfilePhoto: booleanValue(value.can_edit_profile_photo),
318
+ canEditUsername: booleanValue(value.can_edit_username),
319
+ canChangeGiftSettings: booleanValue(value.can_change_gift_settings),
320
+ canViewGiftsAndStars: booleanValue(value.can_view_gifts_and_stars),
321
+ canConvertGiftsToStars: booleanValue(value.can_convert_gifts_to_stars),
322
+ canTransferAndUpgradeGifts: booleanValue(value.can_transfer_and_upgrade_gifts),
323
+ canTransferStars: booleanValue(value.can_transfer_stars),
324
+ canManageStories: booleanValue(value.can_manage_stories)
334
325
  };
335
326
  }
336
327
  function normalizeBusinessConnection(value) {
@@ -369,11 +360,11 @@ function normalizeWebhookInfo(value) {
369
360
  url: String(value.url ?? ""),
370
361
  hasCustomCertificate: Boolean(value.has_custom_certificate),
371
362
  pendingUpdateCount: Number(value.pending_update_count ?? 0),
372
- ipAddress: text(value.ip_address),
373
- lastErrorDate: num(value.last_error_date),
374
- lastErrorMessage: text(value.last_error_message),
375
- lastSynchronizationErrorDate: num(value.last_synchronization_error_date),
376
- maxConnections: num(value.max_connections),
363
+ ipAddress: trimmedText(value.ip_address),
364
+ lastErrorDate: finiteNumber(value.last_error_date),
365
+ lastErrorMessage: trimmedText(value.last_error_message),
366
+ lastSynchronizationErrorDate: finiteNumber(value.last_synchronization_error_date),
367
+ maxConnections: finiteNumber(value.max_connections),
377
368
  allowedUpdates: Array.isArray(value.allowed_updates) ? value.allowed_updates.map((item) => String(item)) : void 0
378
369
  };
379
370
  }
@@ -381,26 +372,26 @@ function normalizeChatMember(value) {
381
372
  return {
382
373
  status: String(value.status ?? ""),
383
374
  user: normalizeUser(asRecord(value.user)),
384
- customTitle: text(value.custom_title),
385
- isAnonymous: bool(value.is_anonymous),
386
- untilDate: num(value.until_date),
387
- canBeEdited: bool(value.can_be_edited),
388
- canChangeInfo: bool(value.can_change_info),
389
- canManageChat: bool(value.can_manage_chat),
390
- canInviteUsers: bool(value.can_invite_users),
391
- canPinMessages: bool(value.can_pin_messages),
392
- canEditMessages: bool(value.can_edit_messages),
393
- canPostMessages: bool(value.can_post_messages),
394
- canDeleteMessages: bool(value.can_delete_messages),
395
- canPromoteMembers: bool(value.can_promote_members),
396
- canRestrictMembers: bool(value.can_restrict_members),
397
- canManageVideoChats: bool(value.can_manage_video_chats),
398
- canManageTopics: bool(value.can_manage_topics)
375
+ customTitle: trimmedText(value.custom_title),
376
+ isAnonymous: booleanValue(value.is_anonymous),
377
+ untilDate: finiteNumber(value.until_date),
378
+ canBeEdited: booleanValue(value.can_be_edited),
379
+ canChangeInfo: booleanValue(value.can_change_info),
380
+ canManageChat: booleanValue(value.can_manage_chat),
381
+ canInviteUsers: booleanValue(value.can_invite_users),
382
+ canPinMessages: booleanValue(value.can_pin_messages),
383
+ canEditMessages: booleanValue(value.can_edit_messages),
384
+ canPostMessages: booleanValue(value.can_post_messages),
385
+ canDeleteMessages: booleanValue(value.can_delete_messages),
386
+ canPromoteMembers: booleanValue(value.can_promote_members),
387
+ canRestrictMembers: booleanValue(value.can_restrict_members),
388
+ canManageVideoChats: booleanValue(value.can_manage_video_chats),
389
+ canManageTopics: booleanValue(value.can_manage_topics)
399
390
  };
400
391
  }
401
392
  function normalizeChatPermissions(value) {
402
393
  const permissions = asRecord(value);
403
- return compact({
394
+ return compactDefined({
404
395
  can_send_messages: permissions.canSendMessages,
405
396
  can_send_audios: permissions.canSendAudios,
406
397
  can_send_documents: permissions.canSendDocuments,
@@ -424,12 +415,12 @@ function normalizeChatInviteLink(value) {
424
415
  createsJoinRequest: Boolean(value.creates_join_request),
425
416
  isPrimary: Boolean(value.is_primary),
426
417
  isRevoked: Boolean(value.is_revoked),
427
- name: text(value.name),
428
- expireDate: num(value.expire_date),
429
- memberLimit: num(value.member_limit),
430
- pendingJoinRequestCount: num(value.pending_join_request_count),
431
- subscriptionPeriod: num(value.subscription_period),
432
- subscriptionPrice: num(value.subscription_price)
418
+ name: trimmedText(value.name),
419
+ expireDate: finiteNumber(value.expire_date),
420
+ memberLimit: finiteNumber(value.member_limit),
421
+ pendingJoinRequestCount: finiteNumber(value.pending_join_request_count),
422
+ subscriptionPeriod: finiteNumber(value.subscription_period),
423
+ subscriptionPrice: finiteNumber(value.subscription_price)
433
424
  };
434
425
  }
435
426
  function assertIncreasingMessageIds(value) {
@@ -459,7 +450,7 @@ function asArray(value) {
459
450
  return value;
460
451
  }
461
452
  async function getUpdates(input, ctx) {
462
- const result = await request(ctx, "getUpdates", compact({
453
+ const result = await request(ctx, "getUpdates", compactDefined({
463
454
  offset: input.offset,
464
455
  limit: input.limit,
465
456
  timeout: input.timeout,
@@ -468,7 +459,7 @@ async function getUpdates(input, ctx) {
468
459
  return { updates: asArray(result).map((update) => normalizeUpdate(asRecord(update))) };
469
460
  }
470
461
  async function sendMessage(input, ctx) {
471
- const result = await request(ctx, "sendMessage", compact({
462
+ const result = await request(ctx, "sendMessage", compactDefined({
472
463
  business_connection_id: input.businessConnectionId,
473
464
  chat_id: input.chatId,
474
465
  text: input.text,
@@ -484,7 +475,7 @@ async function sendMessage(input, ctx) {
484
475
  return normalizeMessage(asRecord(result));
485
476
  }
486
477
  async function copyMessage(input, ctx) {
487
- const result = asRecord(await request(ctx, "copyMessage", compact({
478
+ const result = asRecord(await request(ctx, "copyMessage", compactDefined({
488
479
  chat_id: input.chatId,
489
480
  from_chat_id: input.fromChatId,
490
481
  message_id: input.messageId,
@@ -499,7 +490,7 @@ async function copyMessage(input, ctx) {
499
490
  }
500
491
  async function transferMessages(ctx, method, input) {
501
492
  assertIncreasingMessageIds(input.messageIds);
502
- const result = await request(ctx, method, compact({
493
+ const result = await request(ctx, method, compactDefined({
503
494
  chat_id: input.chatId,
504
495
  from_chat_id: input.fromChatId,
505
496
  message_ids: input.messageIds,
@@ -523,7 +514,7 @@ function deleteMessages(input, ctx) {
523
514
  });
524
515
  }
525
516
  function setMessageReaction(input, ctx) {
526
- return booleanAction(ctx, "setMessageReaction", compact({
517
+ return booleanAction(ctx, "setMessageReaction", compactDefined({
527
518
  chat_id: input.chatId,
528
519
  message_id: input.messageId,
529
520
  reaction: input.reaction,
@@ -531,7 +522,7 @@ function setMessageReaction(input, ctx) {
531
522
  }));
532
523
  }
533
524
  function sendChatAction(input, ctx) {
534
- return booleanAction(ctx, "sendChatAction", compact({
525
+ return booleanAction(ctx, "sendChatAction", compactDefined({
535
526
  business_connection_id: input.businessConnectionId,
536
527
  chat_id: input.chatId,
537
528
  message_thread_id: input.messageThreadId,
@@ -540,7 +531,7 @@ function sendChatAction(input, ctx) {
540
531
  }
541
532
  async function sendMedia(ctx, method, field, input) {
542
533
  const source = input;
543
- const result = await request(ctx, method, compact({
534
+ const result = await request(ctx, method, compactDefined({
544
535
  business_connection_id: input.businessConnectionId,
545
536
  chat_id: input.chatId,
546
537
  message_thread_id: input.messageThreadId,
@@ -575,7 +566,7 @@ function sendAnimation(input, ctx) {
575
566
  return sendMedia(ctx, "sendAnimation", "animation", input);
576
567
  }
577
568
  async function sendMediaGroup(input, ctx) {
578
- const result = await request(ctx, "sendMediaGroup", compact({
569
+ const result = await request(ctx, "sendMediaGroup", compactDefined({
579
570
  business_connection_id: input.businessConnectionId,
580
571
  chat_id: input.chatId,
581
572
  message_thread_id: input.messageThreadId,
@@ -586,7 +577,7 @@ async function sendMediaGroup(input, ctx) {
586
577
  return { messages: asArray(result).map((message) => normalizeMessage(asRecord(message))) };
587
578
  }
588
579
  async function sendStructuredMessage(ctx, method, fields, input) {
589
- const result = await request(ctx, method, compact({
580
+ const result = await request(ctx, method, compactDefined({
590
581
  business_connection_id: input.businessConnectionId,
591
582
  chat_id: input.chatId,
592
583
  message_thread_id: input.messageThreadId,
@@ -640,7 +631,7 @@ function deleteBusinessMessages(input, ctx) {
640
631
  }
641
632
  async function editMessageText(input, ctx) {
642
633
  assertEditMessageTarget(input);
643
- const result = await request(ctx, "editMessageText", compact({
634
+ const result = await request(ctx, "editMessageText", compactDefined({
644
635
  chat_id: input.chatId,
645
636
  message_id: input.messageId,
646
637
  inline_message_id: input.inlineMessageId,
@@ -649,12 +640,12 @@ async function editMessageText(input, ctx) {
649
640
  link_preview_options: input.disableWebPagePreview === true ? { is_disabled: true } : void 0
650
641
  }));
651
642
  if (result === true) {
652
- return { edited: true, message: null, inlineMessageId: text(input.inlineMessageId) ?? null };
643
+ return { edited: true, message: null, inlineMessageId: trimmedText(input.inlineMessageId) ?? null };
653
644
  }
654
645
  return { edited: true, message: normalizeMessage(asRecord(result)), inlineMessageId: null };
655
646
  }
656
647
  async function sendPhoto(input, ctx) {
657
- const result = await request(ctx, "sendPhoto", compact({
648
+ const result = await request(ctx, "sendPhoto", compactDefined({
658
649
  chat_id: input.chatId,
659
650
  photo: urlOrFileId(input.photo),
660
651
  caption: input.caption,
@@ -667,7 +658,7 @@ async function sendPhoto(input, ctx) {
667
658
  return normalizeMessage(asRecord(result));
668
659
  }
669
660
  async function sendDocument(input, ctx) {
670
- const result = await request(ctx, "sendDocument", compact({
661
+ const result = await request(ctx, "sendDocument", compactDefined({
671
662
  chat_id: input.chatId,
672
663
  document: urlOrFileId(input.document),
673
664
  caption: input.caption,
@@ -687,7 +678,7 @@ async function sendPoll(input, ctx) {
687
678
  if (input.type === "quiz" && input.correctOptionId == null) {
688
679
  throw new TBError("invalid_argument", "send_poll quiz polls require correctOptionId");
689
680
  }
690
- const result = await request(ctx, "sendPoll", compact({
681
+ const result = await request(ctx, "sendPoll", compactDefined({
691
682
  chat_id: input.chatId,
692
683
  question: input.question,
693
684
  options: input.options,
@@ -719,14 +710,14 @@ async function getChatAdministrators(input, ctx) {
719
710
  }
720
711
  async function getChatMembersCount(input, ctx) {
721
712
  const result = await request(ctx, "getChatMemberCount", { chat_id: input.chatId });
722
- const count = num(result);
713
+ const count = finiteNumber(result);
723
714
  if (count === void 0) {
724
715
  throw new TBError("unavailable", "Telegram \u7684\u6210\u5458\u6570\u4E0D\u662F\u4E00\u4E2A\u6570\u5B57", { retryable: true });
725
716
  }
726
717
  return { memberCount: count };
727
718
  }
728
719
  function banChatMember(input, ctx) {
729
- return booleanAction(ctx, "banChatMember", compact({
720
+ return booleanAction(ctx, "banChatMember", compactDefined({
730
721
  chat_id: input.chatId,
731
722
  user_id: input.userId,
732
723
  until_date: input.untilDate,
@@ -734,14 +725,14 @@ function banChatMember(input, ctx) {
734
725
  }));
735
726
  }
736
727
  function unbanChatMember(input, ctx) {
737
- return booleanAction(ctx, "unbanChatMember", compact({
728
+ return booleanAction(ctx, "unbanChatMember", compactDefined({
738
729
  chat_id: input.chatId,
739
730
  user_id: input.userId,
740
731
  only_if_banned: input.onlyIfBanned
741
732
  }));
742
733
  }
743
734
  function restrictChatMember(input, ctx) {
744
- return booleanAction(ctx, "restrictChatMember", compact({
735
+ return booleanAction(ctx, "restrictChatMember", compactDefined({
745
736
  chat_id: input.chatId,
746
737
  user_id: input.userId,
747
738
  permissions: normalizeChatPermissions(input.permissions),
@@ -750,7 +741,7 @@ function restrictChatMember(input, ctx) {
750
741
  }));
751
742
  }
752
743
  function promoteChatMember(input, ctx) {
753
- return booleanAction(ctx, "promoteChatMember", compact({
744
+ return booleanAction(ctx, "promoteChatMember", compactDefined({
754
745
  chat_id: input.chatId,
755
746
  user_id: input.userId,
756
747
  is_anonymous: input.isAnonymous,
@@ -773,14 +764,14 @@ function promoteChatMember(input, ctx) {
773
764
  }));
774
765
  }
775
766
  function setChatPermissions(input, ctx) {
776
- return booleanAction(ctx, "setChatPermissions", compact({
767
+ return booleanAction(ctx, "setChatPermissions", compactDefined({
777
768
  chat_id: input.chatId,
778
769
  permissions: normalizeChatPermissions(input.permissions),
779
770
  use_independent_chat_permissions: input.useIndependentChatPermissions
780
771
  }));
781
772
  }
782
773
  function pinChatMessage(input, ctx) {
783
- return booleanAction(ctx, "pinChatMessage", compact({
774
+ return booleanAction(ctx, "pinChatMessage", compactDefined({
784
775
  business_connection_id: input.businessConnectionId,
785
776
  chat_id: input.chatId,
786
777
  message_id: input.messageId,
@@ -788,7 +779,7 @@ function pinChatMessage(input, ctx) {
788
779
  }));
789
780
  }
790
781
  function unpinChatMessage(input, ctx) {
791
- return booleanAction(ctx, "unpinChatMessage", compact({
782
+ return booleanAction(ctx, "unpinChatMessage", compactDefined({
792
783
  business_connection_id: input.businessConnectionId,
793
784
  chat_id: input.chatId,
794
785
  message_id: input.messageId
@@ -807,7 +798,7 @@ function deleteMessage(input, ctx) {
807
798
  return booleanAction(ctx, "deleteMessage", { chat_id: input.chatId, message_id: input.messageId });
808
799
  }
809
800
  async function forwardMessage(input, ctx) {
810
- const result = await request(ctx, "forwardMessage", compact({
801
+ const result = await request(ctx, "forwardMessage", compactDefined({
811
802
  chat_id: input.chatId,
812
803
  from_chat_id: input.fromChatId,
813
804
  message_id: input.messageId,
@@ -816,7 +807,7 @@ async function forwardMessage(input, ctx) {
816
807
  return normalizeMessage(asRecord(result));
817
808
  }
818
809
  async function sendLocation(input, ctx) {
819
- const result = await request(ctx, "sendLocation", compact({
810
+ const result = await request(ctx, "sendLocation", compactDefined({
820
811
  chat_id: input.chatId,
821
812
  latitude: input.latitude,
822
813
  longitude: input.longitude,
@@ -842,7 +833,7 @@ async function mutateChatInviteLink(ctx, method, input) {
842
833
  if (source.memberLimit != null && source.createsJoinRequest === true) {
843
834
  throw new TBError("invalid_argument", "memberLimit cannot be combined with createsJoinRequest");
844
835
  }
845
- const result = await request(ctx, method, compact({
836
+ const result = await request(ctx, method, compactDefined({
846
837
  chat_id: input.chatId,
847
838
  invite_link: source.inviteLink,
848
839
  name: source.name,
@@ -862,7 +853,7 @@ function revokeChatInviteLink(input, ctx) {
862
853
  return mutateChatInviteLink(ctx, "revokeChatInviteLink", input);
863
854
  }
864
855
  function answerCallbackQuery(input, ctx) {
865
- return booleanAction(ctx, "answerCallbackQuery", compact({
856
+ return booleanAction(ctx, "answerCallbackQuery", compactDefined({
866
857
  callback_query_id: input.callbackQueryId,
867
858
  text: input.text,
868
859
  show_alert: input.showAlert,
@@ -871,14 +862,14 @@ function answerCallbackQuery(input, ctx) {
871
862
  }));
872
863
  }
873
864
  function setMyCommands(input, ctx) {
874
- return booleanAction(ctx, "setMyCommands", compact({
865
+ return booleanAction(ctx, "setMyCommands", compactDefined({
875
866
  commands: input.commands,
876
867
  scope: jsonLike(input.scope),
877
868
  language_code: input.languageCode
878
869
  }));
879
870
  }
880
871
  function setWebhook(input, ctx) {
881
- return booleanAction(ctx, "setWebhook", compact({
872
+ return booleanAction(ctx, "setWebhook", compactDefined({
882
873
  // Telegram 会主动回访这个地址,故它同样要过出站可达性判定(填内网地址等于让上游探我们的内网)。
883
874
  url: publicUrl(input.url),
884
875
  secret_token: input.secretToken,
@@ -888,7 +879,7 @@ function setWebhook(input, ctx) {
888
879
  }));
889
880
  }
890
881
  function deleteWebhook(input, ctx) {
891
- return booleanAction(ctx, "deleteWebhook", compact({ drop_pending_updates: input.dropPendingUpdates }));
882
+ return booleanAction(ctx, "deleteWebhook", compactDefined({ drop_pending_updates: input.dropPendingUpdates }));
892
883
  }
893
884
 
894
885
  // ../plugins/src/telegram/schema.ts