@zerodot/telegram 1.1.1 → 1.2.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.
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @zerodot/telegram
2
2
 
3
+ <img src="https://raw.githubusercontent.com/zerodot-io/nodes/main/packages/telegram/telegram.svg" alt="Telegram logo" width="48" height="48">
4
+
3
5
  Send messages and files with a Telegram bot, and start a workflow when the bot gets a message or other update. Use it to build chat bots and notifications.
4
6
 
5
7
  ## Install
package/dist/index.cjs CHANGED
@@ -185,6 +185,16 @@ const additionalFields = zod.z.object({
185
185
  mimeType: zod.z.string()
186
186
  }).partial().catchall(zod.z.unknown());
187
187
  const forOperations = (...operations) => ({ showWhen: { operation: operations } });
188
+ /** The field is necessary at run time when it shows. */
189
+ const requiredFor = (...operations) => ({
190
+ ...forOperations(...operations),
191
+ requiredWhenShown: true
192
+ });
193
+ /** An edit of an inline message uses `inlineMessageId`, not a chat and a message. */
194
+ const NOT_FOR_INLINE = { hideWhen: {
195
+ operation: ["editMessageText"],
196
+ messageType: ["inlineMessage"]
197
+ } };
188
198
  const SEND_FILE = [
189
199
  "sendPhoto",
190
200
  "sendVideo",
@@ -276,7 +286,6 @@ const telegramConfig = zod.z.object({
276
286
  }
277
287
  }),
278
288
  chatId: id.optional().meta({
279
- ...forOperations("sendMessage", "editMessageText", "deleteMessage", "pinChatMessage", "unpinChatMessage", ...SEND_FILE, "sendLocation", "sendMediaGroup", "sendChatAction", "sendAndWait", "get", "administrators", "member", "leave", "setTitle", "setDescription"),
280
289
  showWhen: {
281
290
  resource: ["message", "chat"],
282
291
  operation: [
@@ -298,9 +307,14 @@ const telegramConfig = zod.z.object({
298
307
  "setDescription"
299
308
  ]
300
309
  },
310
+ ...NOT_FOR_INLINE,
311
+ requiredWhenShown: true,
301
312
  description: "Unique identifier of the target chat, or @channelusername"
302
313
  }),
303
- messageId: id.optional().meta(forOperations("editMessageText", "deleteMessage", "pinChatMessage", "unpinChatMessage")),
314
+ messageId: id.optional().meta({
315
+ ...requiredFor("editMessageText", "deleteMessage", "pinChatMessage", "unpinChatMessage"),
316
+ ...NOT_FOR_INLINE
317
+ }),
304
318
  messageType: zod.z.enum(["message", "inlineMessage"]).optional().meta({
305
319
  ...forOperations("editMessageText"),
306
320
  labels: {
@@ -312,19 +326,28 @@ const telegramConfig = zod.z.object({
312
326
  inlineMessage: "A message that was sent through inline mode"
313
327
  }
314
328
  }),
315
- inlineMessageId: zod.z.string().optional().meta(forOperations("editMessageText")),
316
- userId: id.optional().meta(forOperations("member")),
317
- title: zod.z.string().optional().meta(forOperations("setTitle")),
318
- description: zod.z.string().optional().meta(forOperations("setDescription")),
319
- queryId: zod.z.string().optional().meta(forOperations("answerQuery", "answerInlineQuery")),
329
+ inlineMessageId: zod.z.string().optional().meta({
330
+ showWhen: {
331
+ operation: ["editMessageText"],
332
+ messageType: ["inlineMessage"]
333
+ },
334
+ requiredWhenShown: true
335
+ }),
336
+ userId: id.optional().meta(requiredFor("member")),
337
+ title: zod.z.string().optional().meta(requiredFor("setTitle")),
338
+ description: zod.z.string().optional().meta(requiredFor("setDescription")),
339
+ queryId: zod.z.string().optional().meta(requiredFor("answerQuery", "answerInlineQuery")),
320
340
  results: zod.z.string().optional().meta({
321
- ...forOperations("answerInlineQuery"),
341
+ ...requiredFor("answerInlineQuery"),
322
342
  description: "A JSON array of results for the inline query"
323
343
  }),
324
- fileId: zod.z.string().optional().meta({ showWhen: {
325
- resource: ["file"],
326
- operation: ["get"]
327
- } }),
344
+ fileId: zod.z.string().optional().meta({
345
+ showWhen: {
346
+ resource: ["file"],
347
+ operation: ["get"]
348
+ },
349
+ requiredWhenShown: true
350
+ }),
328
351
  download: zod.z.boolean().default(false).meta({
329
352
  showWhen: {
330
353
  resource: ["file"],
@@ -341,7 +364,7 @@ const telegramConfig = zod.z.object({
341
364
  description: "The property of `binary` in the input that holds the file"
342
365
  }),
343
366
  message: zod.z.string().optional().meta({
344
- ...forOperations("sendAndWait"),
367
+ ...requiredFor("sendAndWait"),
345
368
  description: "The message to send, with the buttons"
346
369
  }),
347
370
  responseType: zod.z.enum([
@@ -391,15 +414,16 @@ const telegramConfig = zod.z.object({
391
414
  description: "limitWaitTimeHours: how long to wait for an answer. Default 168 (7 days)."
392
415
  }),
393
416
  text: zod.z.string().optional().meta({
394
- ...forOperations("sendMessage", "editMessageText"),
417
+ ...requiredFor("sendMessage", "editMessageText"),
395
418
  ui: "textarea"
396
419
  }),
397
420
  file: zod.z.string().optional().meta({
398
- ...forOperations(...SEND_FILE),
421
+ ...requiredFor(...SEND_FILE),
422
+ hideWhen: { binaryData: [true] },
399
423
  description: "A public URL, or the file_id of a file that Telegram has"
400
424
  }),
401
425
  action: zod.z.enum(CHAT_ACTIONS).optional().meta({
402
- ...forOperations("sendChatAction"),
426
+ ...requiredFor("sendChatAction"),
403
427
  labels: {
404
428
  typing: "Typing a Message",
405
429
  find_location: "Selecting a Location",
@@ -425,9 +449,9 @@ const telegramConfig = zod.z.object({
425
449
  upload_video_note: "Show that the bot sends a round video"
426
450
  }
427
451
  }),
428
- latitude: zod.z.number().optional().meta(forOperations("sendLocation")),
429
- longitude: zod.z.number().optional().meta(forOperations("sendLocation")),
430
- media: zod.z.object({ media: zod.z.array(mediaItem) }).optional().meta(forOperations("sendMediaGroup")),
452
+ latitude: zod.z.number().optional().meta(requiredFor("sendLocation")),
453
+ longitude: zod.z.number().optional().meta(requiredFor("sendLocation")),
454
+ media: zod.z.object({ media: zod.z.array(mediaItem) }).optional().meta(requiredFor("sendMediaGroup")),
431
455
  replyMarkup: zod.z.enum([
432
456
  "none",
433
457
  "inlineKeyboard",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerodot/telegram",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "Send messages and files with a Telegram bot, and start a workflow when the bot gets a message or other update. Use it to build chat bots and notifications.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
@@ -9,7 +9,8 @@
9
9
  "directory": "packages/telegram"
10
10
  },
11
11
  "keywords": [
12
- "zerodot-node-package"
12
+ "zerodot-node-package",
13
+ "communication"
13
14
  ],
14
15
  "type": "module",
15
16
  "main": "./dist/index.cjs",
@@ -23,7 +24,10 @@
23
24
  "zerodot": {
24
25
  "sdk": "^1.2",
25
26
  "label": "Telegram",
26
- "summary": "Send messages and react to bot updates"
27
+ "summary": "Send messages and react to bot updates",
28
+ "categories": [
29
+ "communication"
30
+ ]
27
31
  },
28
32
  "publishConfig": {
29
33
  "access": "public"