@ezychat/web 0.1.79 → 0.1.80

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.
@@ -0,0 +1,76 @@
1
+ import { type ForwardMessageBody } from '@ezychat/shared';
2
+ /**
3
+ * Forward one message to 1–5 existing chats (docs/features/forward-message/design.md). The server
4
+ * checks every chat before anything is sent and answers the copies, one per chat.
5
+ */
6
+ export declare function useForwardMessage(): import("@tanstack/react-query").UseMutationResult<{
7
+ messages: {
8
+ id: string;
9
+ chatJid: string;
10
+ senderJid: string | null;
11
+ senderName: string | null;
12
+ fromMe: boolean;
13
+ sentByUserId: number | null;
14
+ type: "text" | "image" | "video" | "audio" | "document" | "sticker" | "system";
15
+ body: string | null;
16
+ mediaUrl: string | null;
17
+ mediaMime: string | null;
18
+ mediaName: string | null;
19
+ mediaStatus: "none" | "pending" | "failed" | "ok";
20
+ quotedId: string | null;
21
+ status: "pending" | "failed" | "sent" | "delivered" | "read";
22
+ error: string | null;
23
+ timestamp: number;
24
+ clientId: string | null;
25
+ reactions: {
26
+ emoji: string;
27
+ senderJid: string | null;
28
+ fromMe: boolean;
29
+ at: number;
30
+ sentByUserId: number | null;
31
+ senderName?: string | null | undefined;
32
+ }[];
33
+ voiceNote?: boolean | undefined;
34
+ template?: {
35
+ name: string;
36
+ language: string;
37
+ } | null | undefined;
38
+ viaAssistant?: boolean | undefined;
39
+ forwarded?: {
40
+ manyTimes: boolean;
41
+ } | null | undefined;
42
+ mediaSize?: number | null | undefined;
43
+ mediaWidth?: number | null | undefined;
44
+ mediaHeight?: number | null | undefined;
45
+ mediaThumbUrl?: string | null | undefined;
46
+ scheduledTask?: {
47
+ id: number;
48
+ name: string | null;
49
+ } | null | undefined;
50
+ transcript?: string | null | undefined;
51
+ transcriptLang?: string | null | undefined;
52
+ transcriptStatus?: "pending" | "failed" | "ok" | "skipped" | "too_long" | "unsupported" | null | undefined;
53
+ senderProfile?: {
54
+ chatJid: string;
55
+ name: string;
56
+ } | null | undefined;
57
+ safety?: {
58
+ itemId: number;
59
+ level: "none" | "warning" | "high";
60
+ rules: ("exeInZip" | "executable" | "doubleExtension" | "scamNumber" | "cantInspect" | "macroFile" | "unlockCodeInMessage" | "openOnComputer" | "lookalikeLink" | "financeUrgency" | "firstFile")[];
61
+ aiReason: string | null;
62
+ locked: boolean;
63
+ deletedBy: string | null;
64
+ status: "open" | "safe" | "reported" | "blocked" | "cleared";
65
+ } | null | undefined;
66
+ editedAt?: number | null | undefined;
67
+ editCount?: number | undefined;
68
+ deletedAt?: number | null | undefined;
69
+ deletedBy?: "phone" | "team" | "sender" | "group_admin" | null | undefined;
70
+ deletedByUserId?: number | null | undefined;
71
+ hidden?: boolean | undefined;
72
+ }[];
73
+ }, Error, {
74
+ id: string;
75
+ body: ForwardMessageBody;
76
+ }, unknown>;
@@ -29,6 +29,13 @@ export declare function useCreateInbox(): import("@tanstack/react-query").UseMut
29
29
  editMessage?: boolean | undefined;
30
30
  deleteForEveryone?: boolean | undefined;
31
31
  deleteForMe?: boolean | undefined;
32
+ mediaLimits?: {
33
+ video?: number | undefined;
34
+ image?: number | undefined;
35
+ audio?: number | undefined;
36
+ document?: number | undefined;
37
+ } | undefined;
38
+ forwardedMark?: boolean | undefined;
32
39
  };
33
40
  memberIds?: number[] | undefined;
34
41
  }, Error, {
@@ -65,6 +72,13 @@ export declare function useUpdateInbox(): import("@tanstack/react-query").UseMut
65
72
  editMessage?: boolean | undefined;
66
73
  deleteForEveryone?: boolean | undefined;
67
74
  deleteForMe?: boolean | undefined;
75
+ mediaLimits?: {
76
+ video?: number | undefined;
77
+ image?: number | undefined;
78
+ audio?: number | undefined;
79
+ document?: number | undefined;
80
+ } | undefined;
81
+ forwardedMark?: boolean | undefined;
68
82
  };
69
83
  memberIds?: number[] | undefined;
70
84
  }, Error, {
@@ -46,6 +46,13 @@ export declare function useEditMessage(): import("@tanstack/react-query").UseMut
46
46
  language: string;
47
47
  } | null | undefined;
48
48
  viaAssistant?: boolean | undefined;
49
+ forwarded?: {
50
+ manyTimes: boolean;
51
+ } | null | undefined;
52
+ mediaSize?: number | null | undefined;
53
+ mediaWidth?: number | null | undefined;
54
+ mediaHeight?: number | null | undefined;
55
+ mediaThumbUrl?: string | null | undefined;
49
56
  scheduledTask?: {
50
57
  id: number;
51
58
  name: string | null;
@@ -108,6 +115,13 @@ export declare function useDeleteMessage(): import("@tanstack/react-query").UseM
108
115
  language: string;
109
116
  } | null | undefined;
110
117
  viaAssistant?: boolean | undefined;
118
+ forwarded?: {
119
+ manyTimes: boolean;
120
+ } | null | undefined;
121
+ mediaSize?: number | null | undefined;
122
+ mediaWidth?: number | null | undefined;
123
+ mediaHeight?: number | null | undefined;
124
+ mediaThumbUrl?: string | null | undefined;
111
125
  scheduledTask?: {
112
126
  id: number;
113
127
  name: string | null;
@@ -289,6 +289,13 @@ export declare function useMessages(jid: string | null | undefined): import("@ta
289
289
  language: string;
290
290
  } | null | undefined;
291
291
  viaAssistant?: boolean | undefined;
292
+ forwarded?: {
293
+ manyTimes: boolean;
294
+ } | null | undefined;
295
+ mediaSize?: number | null | undefined;
296
+ mediaWidth?: number | null | undefined;
297
+ mediaHeight?: number | null | undefined;
298
+ mediaThumbUrl?: string | null | undefined;
292
299
  scheduledTask?: {
293
300
  id: number;
294
301
  name: string | null;
@@ -365,6 +372,13 @@ export declare function useSendText(jid: string): import("@tanstack/react-query"
365
372
  language: string;
366
373
  } | null | undefined;
367
374
  viaAssistant?: boolean | undefined;
375
+ forwarded?: {
376
+ manyTimes: boolean;
377
+ } | null | undefined;
378
+ mediaSize?: number | null | undefined;
379
+ mediaWidth?: number | null | undefined;
380
+ mediaHeight?: number | null | undefined;
381
+ mediaThumbUrl?: string | null | undefined;
368
382
  scheduledTask?: {
369
383
  id: number;
370
384
  name: string | null;
@@ -402,6 +416,8 @@ export interface SendMediaInput {
402
416
  quotedId?: string;
403
417
  /** A recorded Ogg/Opus voice note: sent as a WhatsApp voice note, never with a caption. */
404
418
  voiceNote?: boolean;
419
+ /** A video above the number's video limit goes as a file (a document, full quality). */
420
+ asFile?: boolean;
405
421
  }
406
422
  export declare function useSendMedia(jid: string): import("@tanstack/react-query").UseMutationResult<{
407
423
  id: string;
@@ -435,6 +451,13 @@ export declare function useSendMedia(jid: string): import("@tanstack/react-query
435
451
  language: string;
436
452
  } | null | undefined;
437
453
  viaAssistant?: boolean | undefined;
454
+ forwarded?: {
455
+ manyTimes: boolean;
456
+ } | null | undefined;
457
+ mediaSize?: number | null | undefined;
458
+ mediaWidth?: number | null | undefined;
459
+ mediaHeight?: number | null | undefined;
460
+ mediaThumbUrl?: string | null | undefined;
438
461
  scheduledTask?: {
439
462
  id: number;
440
463
  name: string | null;
@@ -494,6 +517,13 @@ export declare function useRetryMessage(): import("@tanstack/react-query").UseMu
494
517
  language: string;
495
518
  } | null | undefined;
496
519
  viaAssistant?: boolean | undefined;
520
+ forwarded?: {
521
+ manyTimes: boolean;
522
+ } | null | undefined;
523
+ mediaSize?: number | null | undefined;
524
+ mediaWidth?: number | null | undefined;
525
+ mediaHeight?: number | null | undefined;
526
+ mediaThumbUrl?: string | null | undefined;
497
527
  scheduledTask?: {
498
528
  id: number;
499
529
  name: string | null;
@@ -840,6 +870,13 @@ export declare function useInboxes(opts?: {
840
870
  editMessage?: boolean | undefined;
841
871
  deleteForEveryone?: boolean | undefined;
842
872
  deleteForMe?: boolean | undefined;
873
+ mediaLimits?: {
874
+ video?: number | undefined;
875
+ image?: number | undefined;
876
+ audio?: number | undefined;
877
+ document?: number | undefined;
878
+ } | undefined;
879
+ forwardedMark?: boolean | undefined;
843
880
  };
844
881
  memberIds?: number[] | undefined;
845
882
  }[];
@@ -60,6 +60,13 @@ export declare function useSendTemplate(jid: string): import("@tanstack/react-qu
60
60
  language: string;
61
61
  } | null | undefined;
62
62
  viaAssistant?: boolean | undefined;
63
+ forwarded?: {
64
+ manyTimes: boolean;
65
+ } | null | undefined;
66
+ mediaSize?: number | null | undefined;
67
+ mediaWidth?: number | null | undefined;
68
+ mediaHeight?: number | null | undefined;
69
+ mediaThumbUrl?: string | null | undefined;
63
70
  scheduledTask?: {
64
71
  id: number;
65
72
  name: string | null;
@@ -797,6 +797,7 @@ export declare const enResources: {
797
797
  unavailable: string;
798
798
  unavailableHint: string;
799
799
  };
800
+ sentAsFile: string;
800
801
  };
801
802
  quickReplies: {
802
803
  title: string;
@@ -1017,6 +1018,11 @@ export declare const enResources: {
1017
1018
  };
1018
1019
  scheduled: string;
1019
1020
  scheduledNamed: string;
1021
+ uploadErrors: {
1022
+ too_large: string;
1023
+ too_large_as_video: string;
1024
+ too_large_for_whatsapp: string;
1025
+ };
1020
1026
  };
1021
1027
  media: {
1022
1028
  types: {
@@ -1727,6 +1733,95 @@ export declare const enResources: {
1727
1733
  };
1728
1734
  usageNoLimit: string;
1729
1735
  };
1736
+ forward: {
1737
+ action: string;
1738
+ lockedReason: string;
1739
+ forwarded: string;
1740
+ forwardedMany: string;
1741
+ title: string;
1742
+ description: string;
1743
+ manyTimesNote: string;
1744
+ count: string;
1745
+ full: string;
1746
+ remove: string;
1747
+ search: string;
1748
+ listLabel: string;
1749
+ loading: string;
1750
+ emptyTitle: string;
1751
+ emptyQuery: string;
1752
+ emptyNone: string;
1753
+ windowClosedRow: string;
1754
+ otherInbox: string;
1755
+ cancel: string;
1756
+ send: string;
1757
+ sendCount_one: string;
1758
+ sendCount_other: string;
1759
+ sending: string;
1760
+ sentOne: string;
1761
+ sentMany_one: string;
1762
+ sentMany_other: string;
1763
+ openChat: string;
1764
+ problems: {
1765
+ wa_disconnected: {
1766
+ title: string;
1767
+ body: string;
1768
+ };
1769
+ window_closed: {
1770
+ title: string;
1771
+ body: string;
1772
+ };
1773
+ safety_locked: {
1774
+ title: string;
1775
+ body: string;
1776
+ };
1777
+ rate_limited: {
1778
+ title: string;
1779
+ body: string;
1780
+ };
1781
+ media_unavailable: {
1782
+ title: string;
1783
+ body: string;
1784
+ };
1785
+ message_deleted: {
1786
+ title: string;
1787
+ body: string;
1788
+ };
1789
+ other: {
1790
+ title: string;
1791
+ body: string;
1792
+ };
1793
+ too_large_as_video: {
1794
+ title: string;
1795
+ body: string;
1796
+ };
1797
+ too_large_for_whatsapp: {
1798
+ title: string;
1799
+ body: string;
1800
+ };
1801
+ message_not_sent: {
1802
+ title: string;
1803
+ body: string;
1804
+ };
1805
+ inbox_removed: {
1806
+ title: string;
1807
+ body: string;
1808
+ };
1809
+ forward_many_times: {
1810
+ title: string;
1811
+ body: string;
1812
+ };
1813
+ };
1814
+ largeNote: string;
1815
+ sendAs: string;
1816
+ asVideo: string;
1817
+ asFile: string;
1818
+ sendAsHint: string;
1819
+ videoTooBig: string;
1820
+ tooBigRow: string;
1821
+ sendingLarge: string;
1822
+ thisNumber: string;
1823
+ loadFailed: string;
1824
+ };
1730
1825
  };
1731
1826
  admin: {
1732
1827
  title: string;
@@ -1,5 +1,6 @@
1
1
  import type React from 'react';
2
2
  import { type GroupMember, type QuickReply, type ReplyPhraseListItem, type FixEnglishStatus } from '@ezychat/shared';
3
+ import { type MediaLimits } from '../lib/file-transfer';
3
4
  /** Lets the conversation hand files dropped anywhere on it to the composer. */
4
5
  export interface ComposerHandle {
5
6
  addFiles(files: readonly File[]): void;
@@ -65,6 +66,8 @@ export interface ComposerProps {
65
66
  error: boolean;
66
67
  onOpen(): void;
67
68
  } | null;
69
+ /** What this chat's WhatsApp number takes per kind of file (bytes); absent = the upload limit. */
70
+ mediaLimits?: MediaLimits | null;
68
71
  /**
69
72
  * Fix English (docs/features/grammar-fix/design.md): spelling and grammar marks in this chat
70
73
  * (any chat type; null or a status with both checks off = nothing shown).
@@ -79,4 +82,4 @@ export interface ComposerProps {
79
82
  onAddWord(word: string): Promise<unknown>;
80
83
  } | null;
81
84
  }
82
- export declare function Composer({ quickReplies, onSend, onAttach, onVoiceNote, onTyping, confirmSend, disabled, placeholder, replyTo, onCancelReply, aiSuggest, askEzy, fixEnglish, mentions, ref, }: ComposerProps): React.JSX.Element;
85
+ export declare function Composer({ quickReplies, onSend, onAttach, onVoiceNote, onTyping, confirmSend, disabled, placeholder, replyTo, onCancelReply, aiSuggest, askEzy, fixEnglish, mentions, mediaLimits, ref, }: ComposerProps): React.JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { type Message } from '@ezychat/shared';
2
+ /** Server refusals shown as a banner. */
3
+ export type ForwardProblem = 'wa_disconnected' | 'window_closed' | 'safety_locked' | 'rate_limited' | 'media_unavailable' | 'message_deleted' | 'message_not_sent' | 'inbox_removed' | 'forward_many_times' | 'too_large_as_video' | 'too_large_for_whatsapp' | 'other';
4
+ /** The banner for a refused forward: the server's code, or `other`. */
5
+ export declare function forwardProblemOf(err: unknown): ForwardProblem;
6
+ export declare function ForwardDialog({ message, sourceInboxId, onClose, }: Readonly<{
7
+ message: Message;
8
+ /** The inbox of the chat the message is in (for the "own number" note). */
9
+ sourceInboxId: number;
10
+ onClose(): void;
11
+ }>): import("react").JSX.Element;
@@ -1,4 +1,5 @@
1
1
  import type React from 'react';
2
+ import { type CSSProperties } from 'react';
2
3
  import type { Message } from '@ezychat/shared';
3
4
  export interface MediaViewProps {
4
5
  message: Message;
@@ -7,5 +8,7 @@ export interface MediaViewProps {
7
8
  }
8
9
  /** The file name a media file gets when dragged or saved out of the app. */
9
10
  export declare function mediaFileName(m: Pick<Message, 'id' | 'type' | 'mediaName' | 'mediaMime'>): string;
11
+ /** The space an image takes in the chat, so nothing moves when its file arrives; undefined when its size is not known. */
12
+ export declare function imageBox(width: number | null | undefined, height: number | null | undefined): CSSProperties | undefined;
10
13
  /** Renders the media part of a message (image, sticker, video, audio, document). */
11
14
  export declare function MediaView({ message: m, onLoad }: MediaViewProps): React.JSX.Element;
@@ -4,13 +4,18 @@ import type { Directory } from './useDirectory';
4
4
  /**
5
5
  * The ⋮ button next to a message (hover or focus on desktop, like Reply; touch screens reach the
6
6
  * same actions from the press-and-hold bar). Shown only when the user may do something with the
7
- * message; Edit stays visible, disabled, once its 15 minutes are over.
7
+ * message: Forward first (every message that can be forwarded), then Edit and Delete. Edit stays
8
+ * visible, disabled, once its 15 minutes are over; Forward stays visible, disabled, for a file
9
+ * WhatsApp Safety locked.
8
10
  */
9
- export declare function MessageMoreMenu({ rights, disabledReason, onEdit, onDelete, }: {
11
+ export declare function MessageMoreMenu({ rights, disabledReason, onEdit, onDelete, onForward, forwardLocked, }: {
10
12
  rights: MessageRights;
11
13
  disabledReason: string | null;
12
14
  onEdit(): void;
13
15
  onDelete(): void;
16
+ /** Set when the message can be forwarded. */
17
+ onForward?(): void;
18
+ forwardLocked?: boolean;
14
19
  }): import("react").JSX.Element | null;
15
20
  /** Edit a sent text or caption. WhatsApp shows the customer "Edited". */
16
21
  export declare function EditMessageDialog({ message, onClose, }: {
@@ -40,3 +40,7 @@ export declare function StatusTicks({ status }: {
40
40
  status: Message['status'];
41
41
  }): React.JSX.Element;
42
42
  export declare function MessageBubble({ message: m, showSender, outboundLabel, quoted, onRetry, retrying, onMediaLoad, directory, onReply, onReact, reactDisabledReason, contactName, changes, onOpenQuote, highlighted, }: MessageBubbleProps): React.JSX.Element;
43
+ /** From this size a file shows that it is still uploading, and Forward warns before sending it. */
44
+ export declare const LARGE_FILE_BYTES: number;
45
+ /** Why a message was not sent, in plain words. */
46
+ export declare function failedReason(error: string | null, t: TFunction<['inbox', 'common']>): string;
@@ -17,6 +17,8 @@ export interface ReactionPickerProps {
17
17
  disabledReason: string | null;
18
18
  /** Touch screens open the bar by press-and-hold, so it offers Reply as well. */
19
19
  onReply?(): void;
20
+ /** …and Forward, for a message that can be forwarded now. */
21
+ onForward?(): void;
20
22
  /** …and Copy text, for a message with text. */
21
23
  onCopy?(): void;
22
24
  /** …and Edit / Delete, when the signed-in user may change the message now. */
@@ -28,4 +30,4 @@ export interface ReactionPickerProps {
28
30
  * reaction per number, so the whole team shares the linked number's reaction: a new emoji replaces
29
31
  * it, the same emoji again removes it.
30
32
  */
31
- export declare function ReactionPicker({ out, current, currentBy, open, onOpenChange, onReact, disabledReason, onReply, onCopy, onEdit, onDelete, }: ReactionPickerProps): import("react").JSX.Element;
33
+ export declare function ReactionPicker({ out, current, currentBy, open, onOpenChange, onReact, disabledReason, onReply, onForward, onCopy, onEdit, onDelete, }: ReactionPickerProps): import("react").JSX.Element;
@@ -26,6 +26,16 @@ export declare function messageRights(m: Message, user: {
26
26
  } | null, caps: Pick<InboxCapabilities, 'editMessage' | 'deleteForEveryone' | 'deleteForMe'>, now: number): MessageRights;
27
27
  /** Anything to offer in the message's menu. */
28
28
  export declare function hasActions(r: MessageRights): boolean;
29
+ /**
30
+ * A message that may be forwarded (the server's rule): one WhatsApp has (not `local-`, not pending
31
+ * or failed), not a system line, not deleted for everyone or hidden for the team.
32
+ */
33
+ export declare function forwardable(m: Message): boolean;
34
+ /**
35
+ * Forward stays in the menu but disabled for a file WhatsApp Safety rated High (locked, released or
36
+ * deleted), admins too: the server refuses it the same way (409 `safety_locked`).
37
+ */
38
+ export declare function forwardLocked(m: Message): boolean;
29
39
  /** Handlers and rights the conversation gives each bubble. */
30
40
  export interface MessageChangeProps {
31
41
  rightsOf(m: Message): MessageRights;
@@ -33,6 +43,8 @@ export interface MessageChangeProps {
33
43
  disabledReason: string | null;
34
44
  onEdit(m: Message): void;
35
45
  onDelete(m: Message): void;
46
+ /** Forward a copy to other chats (⋮ menu first item; under Reply in the press-and-hold bar). */
47
+ onForward?(m: Message): void;
36
48
  /** Admins may read the original of a deleted message. */
37
49
  isAdmin: boolean;
38
50
  }
@@ -10,9 +10,21 @@ export declare function filesFromTransfer(dt: Pick<DataTransfer, 'files'> | null
10
10
  export type RejectedFile = {
11
11
  file: File;
12
12
  reason: 'too_large' | 'empty' | 'too_many';
13
+ /** The limit a `too_large` file went over, in bytes. */
14
+ limit?: number;
13
15
  };
16
+ /** What a chat's WhatsApp number takes, per kind of file (`InboxCapabilities.mediaLimits`). */
17
+ export type MediaLimits = Partial<Record<'video' | 'image' | 'audio' | 'document', number>>;
18
+ /**
19
+ * The largest file of this type the chat's number takes: the app's upload limit, lowered by the
20
+ * number's own limit for images, audio and documents. A video is checked against the document
21
+ * limit only: above the video limit the server answers `too_large_as_video` (it may go as a file).
22
+ */
23
+ export declare function uploadLimitFor(mime: string, limits?: MediaLimits | null): number;
24
+ /** A video above the number's video limit (it can still go as a file, up to the document limit). */
25
+ export declare function videoNeedsFile(file: File, limits?: MediaLimits | null): boolean;
14
26
  /** Splits files into the ones that can be sent and the ones refused before any upload. */
15
- export declare function checkAttachments(files: readonly File[], alreadyQueued: number): {
27
+ export declare function checkAttachments(files: readonly File[], alreadyQueued: number, limits?: MediaLimits | null): {
16
28
  accepted: File[];
17
29
  rejected: RejectedFile[];
18
30
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ezychat/web",
3
- "version": "0.1.79",
3
+ "version": "0.1.80",
4
4
  "type": "module",
5
5
  "description": "EzyChat core: the team inbox web app (React) as a library, with createInboxApp and its extension API.",
6
6
  "license": "MIT",
@@ -40,7 +40,7 @@
40
40
  "build:lib": "node ../../scripts/build-web-lib.mjs"
41
41
  },
42
42
  "dependencies": {
43
- "@ezychat/shared": "0.1.79",
43
+ "@ezychat/shared": "0.1.80",
44
44
  "@fontsource-variable/inter": "^5.3.0",
45
45
  "@tanstack/react-query": "^5.105.0",
46
46
  "@types/react": "^19.3.0",