@ai-grator/api 0.1.24 → 0.1.25

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 (120) hide show
  1. package/admin/endpoints/admin.ts +6 -0
  2. package/admin/endpoints/commands/index.ts +2 -0
  3. package/admin/endpoints/commands/mark-admin-support-chat-read.command.ts +25 -0
  4. package/admin/endpoints/commands/send-admin-support-reply.command.ts +38 -0
  5. package/admin/endpoints/queries/get-admin-support-chat-messages.query.ts +33 -0
  6. package/admin/endpoints/queries/get-admin-support-chats.query.ts +27 -0
  7. package/admin/endpoints/queries/index.ts +6 -4
  8. package/admin/models/admin-support-chat-list-item.schema.ts +13 -0
  9. package/admin/models/index.ts +1 -0
  10. package/build/admin/endpoints/admin.d.ts +4 -0
  11. package/build/admin/endpoints/admin.d.ts.map +1 -1
  12. package/build/admin/endpoints/admin.js +5 -0
  13. package/build/admin/endpoints/commands/index.d.ts +2 -0
  14. package/build/admin/endpoints/commands/index.d.ts.map +1 -1
  15. package/build/admin/endpoints/commands/index.js +2 -0
  16. package/build/admin/endpoints/commands/mark-admin-support-chat-read.command.d.ts +24 -0
  17. package/build/admin/endpoints/commands/mark-admin-support-chat-read.command.d.ts.map +1 -0
  18. package/build/admin/endpoints/commands/mark-admin-support-chat-read.command.js +25 -0
  19. package/build/admin/endpoints/commands/send-admin-support-reply.command.d.ts +79 -0
  20. package/build/admin/endpoints/commands/send-admin-support-reply.command.d.ts.map +1 -0
  21. package/build/admin/endpoints/commands/send-admin-support-reply.command.js +37 -0
  22. package/build/admin/endpoints/queries/get-admin-support-chat-messages.query.d.ts +86 -0
  23. package/build/admin/endpoints/queries/get-admin-support-chat-messages.query.d.ts.map +1 -0
  24. package/build/admin/endpoints/queries/get-admin-support-chat-messages.query.js +32 -0
  25. package/build/admin/endpoints/queries/get-admin-support-chats.query.d.ts +49 -0
  26. package/build/admin/endpoints/queries/get-admin-support-chats.query.d.ts.map +1 -0
  27. package/build/admin/endpoints/queries/get-admin-support-chats.query.js +27 -0
  28. package/build/admin/endpoints/queries/index.d.ts +6 -4
  29. package/build/admin/endpoints/queries/index.d.ts.map +1 -1
  30. package/build/admin/endpoints/queries/index.js +6 -4
  31. package/build/admin/models/admin-support-chat-list-item.schema.d.ts +12 -0
  32. package/build/admin/models/admin-support-chat-list-item.schema.d.ts.map +1 -0
  33. package/build/admin/models/admin-support-chat-list-item.schema.js +13 -0
  34. package/build/admin/models/index.d.ts +1 -0
  35. package/build/admin/models/index.d.ts.map +1 -1
  36. package/build/admin/models/index.js +1 -0
  37. package/build/chat/endpoints/commands/create-chat.command.d.ts +2 -0
  38. package/build/chat/endpoints/commands/create-chat.command.d.ts.map +1 -1
  39. package/build/chat/endpoints/commands/update-chat.command.d.ts +2 -0
  40. package/build/chat/endpoints/commands/update-chat.command.d.ts.map +1 -1
  41. package/build/chat/endpoints/queries/get-chat-by-uuid.query.d.ts +2 -0
  42. package/build/chat/endpoints/queries/get-chat-by-uuid.query.d.ts.map +1 -1
  43. package/build/chat/endpoints/queries/get-chats.query.d.ts +2 -0
  44. package/build/chat/endpoints/queries/get-chats.query.d.ts.map +1 -1
  45. package/build/chat/models/chat-response.schema.d.ts +1 -0
  46. package/build/chat/models/chat-response.schema.d.ts.map +1 -1
  47. package/build/chat/models/chat-response.schema.js +1 -0
  48. package/build/errors/errors.d.ts +22 -0
  49. package/build/errors/errors.d.ts.map +1 -1
  50. package/build/errors/errors.js +22 -0
  51. package/build/index.d.ts +1 -0
  52. package/build/index.d.ts.map +1 -1
  53. package/build/index.js +1 -0
  54. package/build/scripts/generate-openapi.js +64 -0
  55. package/build/support/endpoints/commands/index.d.ts +3 -0
  56. package/build/support/endpoints/commands/index.d.ts.map +1 -0
  57. package/build/support/endpoints/commands/index.js +18 -0
  58. package/build/support/endpoints/commands/mark-support-chat-read-by-user.command.d.ts +12 -0
  59. package/build/support/endpoints/commands/mark-support-chat-read-by-user.command.d.ts.map +1 -0
  60. package/build/support/endpoints/commands/mark-support-chat-read-by-user.command.js +15 -0
  61. package/build/support/endpoints/commands/send-support-message.command.d.ts +70 -0
  62. package/build/support/endpoints/commands/send-support-message.command.d.ts.map +1 -0
  63. package/build/support/endpoints/commands/send-support-message.command.js +30 -0
  64. package/build/support/endpoints/index.d.ts +4 -0
  65. package/build/support/endpoints/index.d.ts.map +1 -0
  66. package/build/support/endpoints/index.js +19 -0
  67. package/build/support/endpoints/queries/get-support-history.query.d.ts +77 -0
  68. package/build/support/endpoints/queries/get-support-history.query.d.ts.map +1 -0
  69. package/build/support/endpoints/queries/get-support-history.query.js +25 -0
  70. package/build/support/endpoints/queries/get-support-unread-count.query.d.ts +17 -0
  71. package/build/support/endpoints/queries/get-support-unread-count.query.d.ts.map +1 -0
  72. package/build/support/endpoints/queries/get-support-unread-count.query.js +18 -0
  73. package/build/support/endpoints/queries/index.d.ts +3 -0
  74. package/build/support/endpoints/queries/index.d.ts.map +1 -0
  75. package/build/support/endpoints/queries/index.js +18 -0
  76. package/build/support/endpoints/support.d.ts +8 -0
  77. package/build/support/endpoints/support.d.ts.map +1 -0
  78. package/build/support/endpoints/support.js +10 -0
  79. package/build/support/enums/index.d.ts +2 -0
  80. package/build/support/enums/index.d.ts.map +1 -0
  81. package/build/support/enums/index.js +17 -0
  82. package/build/support/enums/support-message-author-type.enum.d.ts +5 -0
  83. package/build/support/enums/support-message-author-type.enum.d.ts.map +1 -0
  84. package/build/support/enums/support-message-author-type.enum.js +8 -0
  85. package/build/support/index.d.ts +5 -0
  86. package/build/support/index.d.ts.map +1 -0
  87. package/build/support/index.js +20 -0
  88. package/build/support/models/index.d.ts +2 -0
  89. package/build/support/models/index.d.ts.map +1 -0
  90. package/build/support/models/index.js +17 -0
  91. package/build/support/models/support-message-response.schema.d.ts +28 -0
  92. package/build/support/models/support-message-response.schema.d.ts.map +1 -0
  93. package/build/support/models/support-message-response.schema.js +14 -0
  94. package/build/support/websocket/index.d.ts +2 -0
  95. package/build/support/websocket/index.d.ts.map +1 -0
  96. package/build/support/websocket/index.js +17 -0
  97. package/build/support/websocket/support-socket-events.d.ts +50 -0
  98. package/build/support/websocket/support-socket-events.d.ts.map +1 -0
  99. package/build/support/websocket/support-socket-events.js +27 -0
  100. package/build/tsconfig.tsbuildinfo +1 -1
  101. package/chat/models/chat-response.schema.ts +1 -0
  102. package/errors/errors.ts +22 -0
  103. package/index.ts +1 -0
  104. package/package.json +1 -1
  105. package/scripts/generate-openapi.ts +98 -0
  106. package/support/endpoints/commands/index.ts +2 -0
  107. package/support/endpoints/commands/mark-support-chat-read-by-user.command.ts +14 -0
  108. package/support/endpoints/commands/send-support-message.command.ts +30 -0
  109. package/support/endpoints/index.ts +3 -0
  110. package/support/endpoints/queries/get-support-history.query.ts +25 -0
  111. package/support/endpoints/queries/get-support-unread-count.query.ts +17 -0
  112. package/support/endpoints/queries/index.ts +2 -0
  113. package/support/endpoints/support.ts +8 -0
  114. package/support/enums/index.ts +1 -0
  115. package/support/enums/support-message-author-type.enum.ts +4 -0
  116. package/support/index.ts +4 -0
  117. package/support/models/index.ts +1 -0
  118. package/support/models/support-message-response.schema.ts +14 -0
  119. package/support/websocket/index.ts +1 -0
  120. package/support/websocket/support-socket-events.ts +35 -0
@@ -19,6 +19,7 @@ export const ChatResponseSchema = z.object({
19
19
  lastModel: ChatLastModelSchema.nullable(),
20
20
  createdAt: z.iso.datetime(),
21
21
  updatedAt: z.iso.datetime(),
22
+ lastMessageAt: z.iso.datetime(),
22
23
  });
23
24
 
24
25
  export type ChatResponseSchemaType = z.infer<typeof ChatResponseSchema>;
package/errors/errors.ts CHANGED
@@ -801,4 +801,26 @@ export const ERRORS = {
801
801
  message: 'Запрос провайдера генерации не удался',
802
802
  },
803
803
  },
804
+ SUPPORT: {
805
+ CHAT_NOT_FOUND: {
806
+ httpCode: 404,
807
+ code: 'SUPPORT.CHAT_NOT_FOUND',
808
+ message: 'Чат поддержки не найден',
809
+ },
810
+ SEND_MESSAGE_ERROR: {
811
+ httpCode: 500,
812
+ code: 'SUPPORT.SEND_MESSAGE_ERROR',
813
+ message: 'Не удалось отправить сообщение в поддержку',
814
+ },
815
+ FIND_ERROR: {
816
+ httpCode: 500,
817
+ code: 'SUPPORT.FIND_ERROR',
818
+ message: 'Не удалось получить историю переписки с поддержкой',
819
+ },
820
+ MARK_READ_ERROR: {
821
+ httpCode: 500,
822
+ code: 'SUPPORT.MARK_READ_ERROR',
823
+ message: 'Не удалось отметить сообщения поддержки как прочитанные',
824
+ },
825
+ },
804
826
  } as const;
package/index.ts CHANGED
@@ -16,3 +16,4 @@ export * from './admin';
16
16
  export * from './file';
17
17
  export * from './generation-job-chat';
18
18
  export * from './marketplace-card';
19
+ export * from './support';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-grator/api",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
4
4
  "main": "build/index.js",
5
5
  "types": "build/index.d.ts",
6
6
  "scripts": {
@@ -157,6 +157,47 @@ import {
157
157
  UploadFileCommandBody,
158
158
  UploadFileCommandResponse,
159
159
  } from '../file/endpoints/commands/upload-file.command';
160
+ import { SUPPORT_CONTROLLER } from '../support/endpoints/support';
161
+ import {
162
+ SendSupportMessageCommand,
163
+ SendSupportMessageCommandBody,
164
+ SendSupportMessageCommandResponse,
165
+ } from '../support/endpoints/commands/send-support-message.command';
166
+ import {
167
+ MarkSupportChatReadByUserCommand,
168
+ MarkSupportChatReadByUserCommandResponse,
169
+ } from '../support/endpoints/commands/mark-support-chat-read-by-user.command';
170
+ import {
171
+ GetSupportHistoryQuery,
172
+ GetSupportHistoryQueryQuery,
173
+ GetSupportHistoryQueryResponse,
174
+ } from '../support/endpoints/queries/get-support-history.query';
175
+ import {
176
+ GetSupportUnreadCountQuery,
177
+ GetSupportUnreadCountQueryResponse,
178
+ } from '../support/endpoints/queries/get-support-unread-count.query';
179
+ import {
180
+ SendAdminSupportReplyCommand,
181
+ SendAdminSupportReplyCommandBody,
182
+ SendAdminSupportReplyCommandParams,
183
+ SendAdminSupportReplyCommandResponse,
184
+ } from '../admin/endpoints/commands/send-admin-support-reply.command';
185
+ import {
186
+ MarkAdminSupportChatReadCommand,
187
+ MarkAdminSupportChatReadCommandParams,
188
+ MarkAdminSupportChatReadCommandResponse,
189
+ } from '../admin/endpoints/commands/mark-admin-support-chat-read.command';
190
+ import {
191
+ GetAdminSupportChatsQuery,
192
+ GetAdminSupportChatsQueryQuery,
193
+ GetAdminSupportChatsQueryResponse,
194
+ } from '../admin/endpoints/queries/get-admin-support-chats.query';
195
+ import {
196
+ GetAdminSupportChatMessagesQuery,
197
+ GetAdminSupportChatMessagesQueryParams,
198
+ GetAdminSupportChatMessagesQueryQuery,
199
+ GetAdminSupportChatMessagesQueryResponse,
200
+ } from '../admin/endpoints/queries/get-admin-support-chat-messages.query';
160
201
  import { WALLET_CONTROLLER } from '../wallet/endpoints/wallet';
161
202
  import {
162
203
  GetWalletBalanceQuery,
@@ -469,6 +510,22 @@ async function main() {
469
510
  registerSchema('AdminGetStatsQuery', GetAdminStatsQueryQuery);
470
511
  registerSchema('AdminGetStatsResponse', GetAdminStatsQueryResponse);
471
512
  registerSchema('AdminGetKieBalanceResponse', GetAdminKieBalanceQueryResponse);
513
+ registerSchema('AdminGetSupportChatsQuery', GetAdminSupportChatsQueryQuery);
514
+ registerSchema('AdminGetSupportChatsResponse', GetAdminSupportChatsQueryResponse);
515
+ registerSchema('AdminGetSupportChatMessagesParams', GetAdminSupportChatMessagesQueryParams);
516
+ registerSchema('AdminGetSupportChatMessagesQuery', GetAdminSupportChatMessagesQueryQuery);
517
+ registerSchema('AdminGetSupportChatMessagesResponse', GetAdminSupportChatMessagesQueryResponse);
518
+ registerSchema('AdminSendSupportReplyParams', SendAdminSupportReplyCommandParams);
519
+ registerSchema('AdminSendSupportReplyRequest', SendAdminSupportReplyCommandBody);
520
+ registerSchema('AdminSendSupportReplyResponse', SendAdminSupportReplyCommandResponse);
521
+ registerSchema('AdminMarkSupportChatReadParams', MarkAdminSupportChatReadCommandParams);
522
+ registerSchema('AdminMarkSupportChatReadResponse', MarkAdminSupportChatReadCommandResponse);
523
+ registerSchema('SupportSendMessageRequest', SendSupportMessageCommandBody);
524
+ registerSchema('SupportSendMessageResponse', SendSupportMessageCommandResponse);
525
+ registerSchema('SupportGetHistoryQuery', GetSupportHistoryQueryQuery);
526
+ registerSchema('SupportGetHistoryResponse', GetSupportHistoryQueryResponse);
527
+ registerSchema('SupportGetUnreadCountResponse', GetSupportUnreadCountQueryResponse);
528
+ registerSchema('SupportMarkReadResponse', MarkSupportChatReadByUserCommandResponse);
472
529
  registerSchema('MarketplaceCardCreateRequest', CreateMarketplaceCardCommandBody);
473
530
  registerSchema('MarketplaceCardCreateResponse', CreateMarketplaceCardCommandResponse);
474
531
  registerSchema('MarketplaceCardGetByUuidParams', GetMarketplaceCardQueryParams);
@@ -507,6 +564,12 @@ async function main() {
507
564
  DeleteMessageCommand,
508
565
  ];
509
566
  const fileContracts: HttpContract[] = [UploadFileCommand];
567
+ const supportContracts: HttpContract[] = [
568
+ SendSupportMessageCommand,
569
+ GetSupportHistoryQuery,
570
+ GetSupportUnreadCountQuery,
571
+ MarkSupportChatReadByUserCommand,
572
+ ];
510
573
  const walletContracts: HttpContract[] = [GetWalletBalanceQuery, GetWalletTransactionsQuery];
511
574
  const paymentContracts: HttpContract[] = [CreatePaymentCommand];
512
575
  const marketplaceCardContracts: HttpContract[] = [
@@ -556,6 +619,10 @@ async function main() {
556
619
  GetAdminUserTransactionsQuery,
557
620
  GetAdminStatsQuery,
558
621
  GetAdminKieBalanceQuery,
622
+ GetAdminSupportChatsQuery,
623
+ GetAdminSupportChatMessagesQuery,
624
+ SendAdminSupportReplyCommand,
625
+ MarkAdminSupportChatReadCommand,
559
626
  ];
560
627
 
561
628
  for (const contract of authContracts) {
@@ -685,6 +752,37 @@ async function main() {
685
752
  });
686
753
  }
687
754
 
755
+ for (const contract of supportContracts) {
756
+ const method = contract.method.toLowerCase();
757
+ if (!supportedHttpMethods.has(method)) {
758
+ throw new Error(`Unsupported HTTP method: ${contract.method}`);
759
+ }
760
+
761
+ registry.registerPath({
762
+ method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
763
+ path: toOpenApiPath(SUPPORT_CONTROLLER, contract.path),
764
+ summary: contract.summary,
765
+ tags: ['Support'],
766
+ request: {
767
+ ...(contract.request?.body
768
+ ? {
769
+ body: {
770
+ required: true,
771
+ content: {
772
+ 'application/json': {
773
+ schema: resolveSchema(contract.request.body),
774
+ },
775
+ },
776
+ },
777
+ }
778
+ : {}),
779
+ ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
780
+ ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
781
+ },
782
+ responses: buildResponses(contract.responses, resolveSchema),
783
+ });
784
+ }
785
+
688
786
  for (const contract of walletContracts) {
689
787
  const method = contract.method.toLowerCase();
690
788
  if (!supportedHttpMethods.has(method)) {
@@ -0,0 +1,2 @@
1
+ export * from './send-support-message.command';
2
+ export * from './mark-support-chat-read-by-user.command';
@@ -0,0 +1,14 @@
1
+ import { defineContract, HTTP_METHODS, HttpErrorResponseSchema, HttpSuccessResponseSchema } from '../../../_common';
2
+ import { SUPPORT_ROUTES } from '../support';
3
+
4
+ export const MarkSupportChatReadByUserCommandResponse = HttpSuccessResponseSchema;
5
+
6
+ export const MarkSupportChatReadByUserCommand = defineContract({
7
+ method: HTTP_METHODS.POST,
8
+ path: SUPPORT_ROUTES.MARK_READ,
9
+ summary: 'Mark support chat as read by the current user',
10
+ responses: {
11
+ 200: MarkSupportChatReadByUserCommandResponse,
12
+ 500: HttpErrorResponseSchema,
13
+ },
14
+ });
@@ -0,0 +1,30 @@
1
+ import { z } from 'zod';
2
+ import { defineContract, HTTP_METHODS, HttpErrorResponseSchema } from '../../../_common';
3
+ import { SUPPORT_ROUTES } from '../support';
4
+ import { SupportMessageResponseSchema } from '../../models';
5
+
6
+ export const SendSupportMessageCommandBody = z
7
+ .object({
8
+ text: z.string().trim().min(1).optional(),
9
+ fileIds: z.array(z.uuid()).optional(),
10
+ })
11
+ .refine(({ text, fileIds }) => Boolean(text) || Boolean(fileIds?.length), {
12
+ message: 'text or fileIds is required',
13
+ path: ['text'],
14
+ });
15
+
16
+ export const SendSupportMessageCommandResponse = SupportMessageResponseSchema;
17
+
18
+ export const SendSupportMessageCommand = defineContract({
19
+ method: HTTP_METHODS.POST,
20
+ path: SUPPORT_ROUTES.SEND_MESSAGE,
21
+ summary: 'Send a message to support (creates the chat on the first message)',
22
+ request: {
23
+ body: SendSupportMessageCommandBody,
24
+ },
25
+ responses: {
26
+ 201: SendSupportMessageCommandResponse,
27
+ 400: HttpErrorResponseSchema,
28
+ 500: HttpErrorResponseSchema,
29
+ },
30
+ });
@@ -0,0 +1,3 @@
1
+ export * from './support';
2
+ export * from './commands';
3
+ export * from './queries';
@@ -0,0 +1,25 @@
1
+ import { z } from 'zod';
2
+ import { defineContract, defineCursorPaginationQuery, HTTP_METHODS, HttpErrorResponseSchema } from '../../../_common';
3
+ import { SUPPORT_ROUTES } from '../support';
4
+ import { SupportMessageResponseSchema } from '../../models';
5
+
6
+ export const GetSupportHistoryQueryQuery = defineCursorPaginationQuery(z.uuid());
7
+
8
+ export const GetSupportHistoryQueryResponse = z.object({
9
+ messages: z.array(SupportMessageResponseSchema),
10
+ nextCursor: z.uuid().nullable(),
11
+ hasMore: z.boolean(),
12
+ });
13
+
14
+ export const GetSupportHistoryQuery = defineContract({
15
+ method: HTTP_METHODS.GET,
16
+ path: SUPPORT_ROUTES.GET_HISTORY,
17
+ summary: 'Get support chat history for the current user',
18
+ request: {
19
+ query: GetSupportHistoryQueryQuery,
20
+ },
21
+ responses: {
22
+ 200: GetSupportHistoryQueryResponse,
23
+ 500: HttpErrorResponseSchema,
24
+ },
25
+ });
@@ -0,0 +1,17 @@
1
+ import { z } from 'zod';
2
+ import { defineContract, HTTP_METHODS, HttpErrorResponseSchema } from '../../../_common';
3
+ import { SUPPORT_ROUTES } from '../support';
4
+
5
+ export const GetSupportUnreadCountQueryResponse = z.object({
6
+ unreadCount: z.number().int().nonnegative(),
7
+ });
8
+
9
+ export const GetSupportUnreadCountQuery = defineContract({
10
+ method: HTTP_METHODS.GET,
11
+ path: SUPPORT_ROUTES.GET_UNREAD_COUNT,
12
+ summary: 'Get the count of unread support replies for the current user',
13
+ responses: {
14
+ 200: GetSupportUnreadCountQueryResponse,
15
+ 500: HttpErrorResponseSchema,
16
+ },
17
+ });
@@ -0,0 +1,2 @@
1
+ export * from './get-support-history.query';
2
+ export * from './get-support-unread-count.query';
@@ -0,0 +1,8 @@
1
+ export const SUPPORT_CONTROLLER = 'support' as const;
2
+
3
+ export const SUPPORT_ROUTES = {
4
+ SEND_MESSAGE: '',
5
+ GET_HISTORY: '',
6
+ GET_UNREAD_COUNT: 'unread-count',
7
+ MARK_READ: 'read',
8
+ } as const;
@@ -0,0 +1 @@
1
+ export * from './support-message-author-type.enum';
@@ -0,0 +1,4 @@
1
+ export enum SUPPORT_MESSAGE_AUTHOR_TYPE {
2
+ USER = 'user',
3
+ ADMIN = 'admin',
4
+ }
@@ -0,0 +1,4 @@
1
+ export * from './enums';
2
+ export * from './models';
3
+ export * from './endpoints';
4
+ export * from './websocket';
@@ -0,0 +1 @@
1
+ export * from './support-message-response.schema';
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ import { SUPPORT_MESSAGE_AUTHOR_TYPE } from '../enums';
3
+ import { FileResponseSchema } from '../../file';
4
+
5
+ export const SupportMessageResponseSchema = z.object({
6
+ uuid: z.uuid(),
7
+ chatId: z.uuid(),
8
+ authorType: z.enum(SUPPORT_MESSAGE_AUTHOR_TYPE),
9
+ text: z.string().nullable(),
10
+ files: z.array(FileResponseSchema),
11
+ createdAt: z.iso.datetime(),
12
+ });
13
+
14
+ export type SupportMessageResponseSchemaType = z.infer<typeof SupportMessageResponseSchema>;
@@ -0,0 +1 @@
1
+ export * from './support-socket-events';
@@ -0,0 +1,35 @@
1
+ import { z } from 'zod';
2
+ import { SupportMessageResponseSchema } from '../models';
3
+
4
+ export const SUPPORT_SOCKET_NAMESPACE = '/support' as const;
5
+
6
+ export const SUPPORT_SOCKET_EVENTS = {
7
+ MESSAGE: 'support:message',
8
+ UNREAD_COUNT: 'support:unread-count',
9
+ CHAT_UPDATED: 'support:chat-updated',
10
+ } as const;
11
+
12
+ export const SupportSocketMessagePayloadSchema = z.object({
13
+ userId: z.uuid(),
14
+ message: SupportMessageResponseSchema,
15
+ });
16
+
17
+ export type SupportSocketMessagePayloadSchemaType = z.infer<typeof SupportSocketMessagePayloadSchema>;
18
+
19
+ export const SupportSocketUnreadCountPayloadSchema = z.object({
20
+ unreadCount: z.number().int().nonnegative(),
21
+ });
22
+
23
+ export type SupportSocketUnreadCountPayloadSchemaType = z.infer<typeof SupportSocketUnreadCountPayloadSchema>;
24
+
25
+ export const SupportSocketChatUpdatedPayloadSchema = z.object({
26
+ userId: z.uuid(),
27
+ userEmail: z.email(),
28
+ userName: z.string().nullable(),
29
+ lastMessage: z.string().nullable(),
30
+ lastMessageHasAttachment: z.boolean(),
31
+ lastMessageAt: z.iso.datetime(),
32
+ unreadCount: z.number().int().nonnegative(),
33
+ });
34
+
35
+ export type SupportSocketChatUpdatedPayloadSchemaType = z.infer<typeof SupportSocketChatUpdatedPayloadSchema>;