@nomalism-com/types 0.45.12 → 0.45.14

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.
@@ -1,22 +1,29 @@
1
1
  import type { IChatBalloon } from '../../stock/chat/interfaces';
2
2
  import type { IPublicDocument, IPublicFindBySubscriberId, ITags } from '../../ui/portal/interface';
3
3
  export declare const Route = "ws";
4
- export type ChatSocketEvent = {
4
+ interface IEvent {
5
+ type: string;
6
+ }
7
+ interface IChatTranslationUpdated extends IEvent {
5
8
  type: 'chat.translation.updated';
6
9
  chat_id: string;
7
10
  translation: string;
8
11
  target_language_id: string;
9
- } | {
12
+ }
13
+ interface IChatMessageCreated extends IEvent {
10
14
  type: 'chat.message.created';
11
15
  balloon: IChatBalloon;
12
- } | {
16
+ }
17
+ interface IChatMessageUpdated extends IEvent {
13
18
  type: 'chat.message.updated';
14
19
  chat_id: string;
15
20
  patch: Partial<NonNullable<IChatBalloon['chat']>>;
16
- } | {
21
+ }
22
+ interface IChatMessageDeleted extends IEvent {
17
23
  type: 'chat.message.deleted';
18
24
  chat_id: string;
19
- } | {
25
+ }
26
+ export type ChatSocketEvent = IChatTranslationUpdated | IChatMessageCreated | IChatMessageUpdated | IChatMessageDeleted | {
20
27
  type: 'chat.file.deleted';
21
28
  file_id: string;
22
29
  } | {
@@ -40,17 +47,18 @@ export type ChatSocketEvent = {
40
47
  } | {
41
48
  type: 'pong';
42
49
  };
43
- export interface ChatSocketOptions {
50
+ export interface SocketOptions<T extends IEvent> {
44
51
  token: string;
45
- onEvent: (evt: ChatSocketEvent) => void;
52
+ onEvent: (evt: T) => void;
46
53
  onOpen?: () => void;
47
54
  onReconnect?: () => void;
48
55
  onClose?: () => void;
49
56
  onAuthUnverified?: () => void;
50
57
  }
51
- export interface ChatSocketHandle {
58
+ export interface SocketHandle {
52
59
  close: () => void;
53
60
  }
54
- export interface IClient {
55
- openChatSocket(data: ChatSocketOptions): ChatSocketHandle;
61
+ export interface IClient<T extends IEvent> {
62
+ openSocket(data: SocketOptions<T>): SocketHandle;
56
63
  }
64
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nomalism-com/types",
3
3
  "description": "A nomalism package with all necessary types and validations for developing APIs",
4
- "version": "0.45.12",
4
+ "version": "0.45.14",
5
5
  "author": "Nomalism <it.nomalism@gmail.com> (https://nomalism.com/)",
6
6
  "license": "UNLICENSED",
7
7
  "type": "module",