@nomalism-com/types 0.45.13 → 0.45.15

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,46 +1,60 @@
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
+ export interface IEvent {
5
+ type: string;
6
+ }
7
+ export 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
+ export interface IChatMessageCreated extends IEvent {
10
14
  type: 'chat.message.created';
11
15
  balloon: IChatBalloon;
12
- } | {
16
+ }
17
+ export 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
+ export interface IChatMessageDeleted extends IEvent {
17
23
  type: 'chat.message.deleted';
18
24
  chat_id: string;
19
- } | {
25
+ }
26
+ export interface IChatFileDeleted extends IEvent {
20
27
  type: 'chat.file.deleted';
21
28
  file_id: string;
22
- } | {
29
+ }
30
+ export interface IChatReadStateUpdated extends IEvent {
23
31
  type: 'chat.read_state.updated';
24
32
  chat_document_header_id: string;
25
33
  client_read: boolean;
26
34
  chat_id?: string;
27
35
  file_id?: string;
28
- } | {
36
+ }
37
+ export interface IChatTagsUpdated extends IEvent {
29
38
  type: 'chat.tags.updated';
30
39
  chat_document_header_id: string;
31
40
  tags: ITags[];
32
- } | {
41
+ }
42
+ export interface IPersonaUpdated extends IEvent {
33
43
  type: 'persona.updated';
34
44
  persona: NonNullable<IPublicFindBySubscriberId['persona']>;
35
- } | {
45
+ }
46
+ export interface IDocumentUpdated extends IEvent {
36
47
  type: 'document.updated';
37
48
  document: IPublicDocument;
38
- } | {
49
+ }
50
+ export interface IPing extends IEvent {
39
51
  type: 'ping';
40
- } | {
52
+ }
53
+ export interface IPong extends IEvent {
41
54
  type: 'pong';
42
- };
43
- export interface SocketOptions<T> {
55
+ }
56
+ export type ChatSocketEvent = IChatTranslationUpdated | IChatMessageCreated | IChatMessageUpdated | IChatMessageDeleted | IChatFileDeleted | IChatReadStateUpdated | IChatTagsUpdated | IPersonaUpdated | IDocumentUpdated | IPing | IPong;
57
+ export interface SocketOptions<T extends IEvent> {
44
58
  token: string;
45
59
  onEvent: (evt: T) => void;
46
60
  onOpen?: () => void;
@@ -51,6 +65,6 @@ export interface SocketOptions<T> {
51
65
  export interface SocketHandle {
52
66
  close: () => void;
53
67
  }
54
- export interface IClient<T> {
68
+ export interface IClient<T extends IEvent> {
55
69
  openSocket(data: SocketOptions<T>): SocketHandle;
56
70
  }
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.13",
4
+ "version": "0.45.15",
5
5
  "author": "Nomalism <it.nomalism@gmail.com> (https://nomalism.com/)",
6
6
  "license": "UNLICENSED",
7
7
  "type": "module",