@ai-grator/api 0.1.24 → 0.1.27

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 (160) 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 +29 -0
  49. package/build/errors/errors.d.ts.map +1 -1
  50. package/build/errors/errors.js +29 -0
  51. package/build/index.d.ts +2 -0
  52. package/build/index.d.ts.map +1 -1
  53. package/build/index.js +2 -0
  54. package/build/model-catalog/endpoints/index.d.ts +3 -0
  55. package/build/model-catalog/endpoints/index.d.ts.map +1 -0
  56. package/build/model-catalog/endpoints/index.js +18 -0
  57. package/build/model-catalog/endpoints/model-catalog.d.ts +5 -0
  58. package/build/model-catalog/endpoints/model-catalog.d.ts.map +1 -0
  59. package/build/model-catalog/endpoints/model-catalog.js +7 -0
  60. package/build/model-catalog/endpoints/queries/get-model-catalog.query.d.ts +39 -0
  61. package/build/model-catalog/endpoints/queries/get-model-catalog.query.d.ts.map +1 -0
  62. package/build/model-catalog/endpoints/queries/get-model-catalog.query.js +19 -0
  63. package/build/model-catalog/endpoints/queries/index.d.ts +2 -0
  64. package/build/model-catalog/endpoints/queries/index.d.ts.map +1 -0
  65. package/build/model-catalog/endpoints/queries/index.js +17 -0
  66. package/build/model-catalog/enums/index.d.ts +3 -0
  67. package/build/model-catalog/enums/index.d.ts.map +1 -0
  68. package/build/model-catalog/enums/index.js +18 -0
  69. package/build/model-catalog/enums/model-category.enum.d.ts +7 -0
  70. package/build/model-catalog/enums/model-category.enum.d.ts.map +1 -0
  71. package/build/model-catalog/enums/model-category.enum.js +10 -0
  72. package/build/model-catalog/enums/price-unit.enum.d.ts +5 -0
  73. package/build/model-catalog/enums/price-unit.enum.d.ts.map +1 -0
  74. package/build/model-catalog/enums/price-unit.enum.js +8 -0
  75. package/build/model-catalog/index.d.ts +4 -0
  76. package/build/model-catalog/index.d.ts.map +1 -0
  77. package/build/model-catalog/index.js +19 -0
  78. package/build/model-catalog/models/index.d.ts +2 -0
  79. package/build/model-catalog/models/index.d.ts.map +1 -0
  80. package/build/model-catalog/models/index.js +17 -0
  81. package/build/model-catalog/models/model-catalog-item-response.schema.d.ts +16 -0
  82. package/build/model-catalog/models/model-catalog-item-response.schema.d.ts.map +1 -0
  83. package/build/model-catalog/models/model-catalog-item-response.schema.js +15 -0
  84. package/build/scripts/generate-openapi.js +97 -0
  85. package/build/support/endpoints/commands/index.d.ts +3 -0
  86. package/build/support/endpoints/commands/index.d.ts.map +1 -0
  87. package/build/support/endpoints/commands/index.js +18 -0
  88. package/build/support/endpoints/commands/mark-support-chat-read-by-user.command.d.ts +12 -0
  89. package/build/support/endpoints/commands/mark-support-chat-read-by-user.command.d.ts.map +1 -0
  90. package/build/support/endpoints/commands/mark-support-chat-read-by-user.command.js +15 -0
  91. package/build/support/endpoints/commands/send-support-message.command.d.ts +70 -0
  92. package/build/support/endpoints/commands/send-support-message.command.d.ts.map +1 -0
  93. package/build/support/endpoints/commands/send-support-message.command.js +30 -0
  94. package/build/support/endpoints/index.d.ts +4 -0
  95. package/build/support/endpoints/index.d.ts.map +1 -0
  96. package/build/support/endpoints/index.js +19 -0
  97. package/build/support/endpoints/queries/get-support-history.query.d.ts +77 -0
  98. package/build/support/endpoints/queries/get-support-history.query.d.ts.map +1 -0
  99. package/build/support/endpoints/queries/get-support-history.query.js +25 -0
  100. package/build/support/endpoints/queries/get-support-unread-count.query.d.ts +17 -0
  101. package/build/support/endpoints/queries/get-support-unread-count.query.d.ts.map +1 -0
  102. package/build/support/endpoints/queries/get-support-unread-count.query.js +18 -0
  103. package/build/support/endpoints/queries/index.d.ts +3 -0
  104. package/build/support/endpoints/queries/index.d.ts.map +1 -0
  105. package/build/support/endpoints/queries/index.js +18 -0
  106. package/build/support/endpoints/support.d.ts +8 -0
  107. package/build/support/endpoints/support.d.ts.map +1 -0
  108. package/build/support/endpoints/support.js +10 -0
  109. package/build/support/enums/index.d.ts +2 -0
  110. package/build/support/enums/index.d.ts.map +1 -0
  111. package/build/support/enums/index.js +17 -0
  112. package/build/support/enums/support-message-author-type.enum.d.ts +5 -0
  113. package/build/support/enums/support-message-author-type.enum.d.ts.map +1 -0
  114. package/build/support/enums/support-message-author-type.enum.js +8 -0
  115. package/build/support/index.d.ts +5 -0
  116. package/build/support/index.d.ts.map +1 -0
  117. package/build/support/index.js +20 -0
  118. package/build/support/models/index.d.ts +2 -0
  119. package/build/support/models/index.d.ts.map +1 -0
  120. package/build/support/models/index.js +17 -0
  121. package/build/support/models/support-message-response.schema.d.ts +28 -0
  122. package/build/support/models/support-message-response.schema.d.ts.map +1 -0
  123. package/build/support/models/support-message-response.schema.js +14 -0
  124. package/build/support/websocket/index.d.ts +2 -0
  125. package/build/support/websocket/index.d.ts.map +1 -0
  126. package/build/support/websocket/index.js +17 -0
  127. package/build/support/websocket/support-socket-events.d.ts +50 -0
  128. package/build/support/websocket/support-socket-events.d.ts.map +1 -0
  129. package/build/support/websocket/support-socket-events.js +27 -0
  130. package/build/tsconfig.tsbuildinfo +1 -1
  131. package/chat/models/chat-response.schema.ts +1 -0
  132. package/errors/errors.ts +29 -0
  133. package/index.ts +2 -0
  134. package/model-catalog/endpoints/index.ts +2 -0
  135. package/model-catalog/endpoints/model-catalog.ts +5 -0
  136. package/model-catalog/endpoints/queries/get-model-catalog.query.ts +18 -0
  137. package/model-catalog/endpoints/queries/index.ts +1 -0
  138. package/model-catalog/enums/index.ts +2 -0
  139. package/model-catalog/enums/model-category.enum.ts +6 -0
  140. package/model-catalog/enums/price-unit.enum.ts +4 -0
  141. package/model-catalog/index.ts +3 -0
  142. package/model-catalog/models/index.ts +1 -0
  143. package/model-catalog/models/model-catalog-item-response.schema.ts +15 -0
  144. package/package.json +1 -1
  145. package/scripts/generate-openapi.ts +136 -0
  146. package/support/endpoints/commands/index.ts +2 -0
  147. package/support/endpoints/commands/mark-support-chat-read-by-user.command.ts +14 -0
  148. package/support/endpoints/commands/send-support-message.command.ts +30 -0
  149. package/support/endpoints/index.ts +3 -0
  150. package/support/endpoints/queries/get-support-history.query.ts +25 -0
  151. package/support/endpoints/queries/get-support-unread-count.query.ts +17 -0
  152. package/support/endpoints/queries/index.ts +2 -0
  153. package/support/endpoints/support.ts +8 -0
  154. package/support/enums/index.ts +1 -0
  155. package/support/enums/support-message-author-type.enum.ts +4 -0
  156. package/support/index.ts +4 -0
  157. package/support/models/index.ts +1 -0
  158. package/support/models/support-message-response.schema.ts +14 -0
  159. package/support/websocket/index.ts +1 -0
  160. 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,33 @@ 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
+ },
826
+ MODEL_CATALOG: {
827
+ FIND_ERROR: {
828
+ httpCode: 500,
829
+ code: 'MODEL_CATALOG.FIND_ERROR',
830
+ message: 'Не удалось получить каталог моделей',
831
+ },
832
+ },
804
833
  } as const;
package/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './_common';
2
2
  export * from './ai-model';
3
3
  export * from './generation-model';
4
+ export * from './model-catalog';
4
5
  export * from './generation-job';
5
6
  export * from './article';
6
7
  export * from './auth';
@@ -16,3 +17,4 @@ export * from './admin';
16
17
  export * from './file';
17
18
  export * from './generation-job-chat';
18
19
  export * from './marketplace-card';
20
+ export * from './support';
@@ -0,0 +1,2 @@
1
+ export * from './model-catalog';
2
+ export * from './queries';
@@ -0,0 +1,5 @@
1
+ export const MODEL_CATALOG_CONTROLLER = 'models' as const;
2
+
3
+ export const MODEL_CATALOG_ROUTES = {
4
+ GET_ALL: '',
5
+ } as const;
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ import { defineContract, HTTP_METHODS, HttpErrorResponseSchema } from '../../../_common';
3
+ import { ModelCatalogItemResponseSchema } from '../../models';
4
+ import { MODEL_CATALOG_ROUTES } from '../model-catalog';
5
+
6
+ export const GetModelCatalogQueryResponse = z.object({
7
+ models: z.array(ModelCatalogItemResponseSchema),
8
+ });
9
+
10
+ export const GetModelCatalogQuery = defineContract({
11
+ method: HTTP_METHODS.GET,
12
+ path: MODEL_CATALOG_ROUTES.GET_ALL,
13
+ summary: 'Get public model catalog',
14
+ responses: {
15
+ 200: GetModelCatalogQueryResponse,
16
+ 500: HttpErrorResponseSchema,
17
+ },
18
+ });
@@ -0,0 +1 @@
1
+ export * from './get-model-catalog.query';
@@ -0,0 +1,2 @@
1
+ export * from './model-category.enum';
2
+ export * from './price-unit.enum';
@@ -0,0 +1,6 @@
1
+ export enum MODEL_CATEGORY {
2
+ TEXT = 'text',
3
+ IMAGE = 'image',
4
+ VIDEO = 'video',
5
+ MUSIC = 'music',
6
+ }
@@ -0,0 +1,4 @@
1
+ export enum PRICE_UNIT {
2
+ PER_MILLION_TOKENS = 'per_million_tokens',
3
+ PER_GENERATION = 'per_generation',
4
+ }
@@ -0,0 +1,3 @@
1
+ export * from './enums';
2
+ export * from './models';
3
+ export * from './endpoints';
@@ -0,0 +1 @@
1
+ export * from './model-catalog-item-response.schema';
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod';
2
+ import { IconSchema } from '../../_common';
3
+ import { MODEL_CATEGORY, PRICE_UNIT } from '../enums';
4
+
5
+ export const ModelCatalogItemResponseSchema = z.object({
6
+ uuid: z.uuid(),
7
+ name: z.string(),
8
+ description: z.string().nullable(),
9
+ category: z.enum(MODEL_CATEGORY),
10
+ icons: IconSchema,
11
+ priceFrom: z.number().nonnegative(),
12
+ priceUnit: z.enum(PRICE_UNIT),
13
+ });
14
+
15
+ export type ModelCatalogItemResponseSchemaType = z.infer<typeof ModelCatalogItemResponseSchema>;
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.27",
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,
@@ -180,6 +221,11 @@ import {
180
221
  GetAiModelByUuidQueryResponse,
181
222
  } from '../ai-model/endpoints/queries/get-ai-model-by-uuid.query';
182
223
  import { GetAllAiModelsQuery, GetAllAiModelsQueryResponse } from '../ai-model/endpoints/queries/get-ai-models.query';
224
+ import { MODEL_CATALOG_CONTROLLER } from '../model-catalog/endpoints/model-catalog';
225
+ import {
226
+ GetModelCatalogQuery,
227
+ GetModelCatalogQueryResponse,
228
+ } from '../model-catalog/endpoints/queries/get-model-catalog.query';
183
229
  import { GENERATION_MODEL_CONTROLLER } from '../generation-model/endpoints/generation-model';
184
230
  import {
185
231
  GetGenerationModelsQuery,
@@ -405,6 +451,7 @@ async function main() {
405
451
  registerSchema('AiModelsGetAllResponse', GetAllAiModelsQueryResponse);
406
452
  registerSchema('AiModelsGetByUuidParams', GetAiModelByUuidQueryParams);
407
453
  registerSchema('AiModelsGetByUuidResponse', GetAiModelByUuidQueryResponse);
454
+ registerSchema('ModelCatalogGetAllResponse', GetModelCatalogQueryResponse);
408
455
  registerSchema('GenerationModelGetAllResponse', GetGenerationModelsQueryResponse);
409
456
  registerSchema('GenerationModelGetByTypeParams', GetGenerationModelsByTypeQueryParams);
410
457
  registerSchema('GenerationModelGetByTypeResponse', GetGenerationModelsByTypeQueryResponse);
@@ -469,6 +516,22 @@ async function main() {
469
516
  registerSchema('AdminGetStatsQuery', GetAdminStatsQueryQuery);
470
517
  registerSchema('AdminGetStatsResponse', GetAdminStatsQueryResponse);
471
518
  registerSchema('AdminGetKieBalanceResponse', GetAdminKieBalanceQueryResponse);
519
+ registerSchema('AdminGetSupportChatsQuery', GetAdminSupportChatsQueryQuery);
520
+ registerSchema('AdminGetSupportChatsResponse', GetAdminSupportChatsQueryResponse);
521
+ registerSchema('AdminGetSupportChatMessagesParams', GetAdminSupportChatMessagesQueryParams);
522
+ registerSchema('AdminGetSupportChatMessagesQuery', GetAdminSupportChatMessagesQueryQuery);
523
+ registerSchema('AdminGetSupportChatMessagesResponse', GetAdminSupportChatMessagesQueryResponse);
524
+ registerSchema('AdminSendSupportReplyParams', SendAdminSupportReplyCommandParams);
525
+ registerSchema('AdminSendSupportReplyRequest', SendAdminSupportReplyCommandBody);
526
+ registerSchema('AdminSendSupportReplyResponse', SendAdminSupportReplyCommandResponse);
527
+ registerSchema('AdminMarkSupportChatReadParams', MarkAdminSupportChatReadCommandParams);
528
+ registerSchema('AdminMarkSupportChatReadResponse', MarkAdminSupportChatReadCommandResponse);
529
+ registerSchema('SupportSendMessageRequest', SendSupportMessageCommandBody);
530
+ registerSchema('SupportSendMessageResponse', SendSupportMessageCommandResponse);
531
+ registerSchema('SupportGetHistoryQuery', GetSupportHistoryQueryQuery);
532
+ registerSchema('SupportGetHistoryResponse', GetSupportHistoryQueryResponse);
533
+ registerSchema('SupportGetUnreadCountResponse', GetSupportUnreadCountQueryResponse);
534
+ registerSchema('SupportMarkReadResponse', MarkSupportChatReadByUserCommandResponse);
472
535
  registerSchema('MarketplaceCardCreateRequest', CreateMarketplaceCardCommandBody);
473
536
  registerSchema('MarketplaceCardCreateResponse', CreateMarketplaceCardCommandResponse);
474
537
  registerSchema('MarketplaceCardGetByUuidParams', GetMarketplaceCardQueryParams);
@@ -507,6 +570,12 @@ async function main() {
507
570
  DeleteMessageCommand,
508
571
  ];
509
572
  const fileContracts: HttpContract[] = [UploadFileCommand];
573
+ const supportContracts: HttpContract[] = [
574
+ SendSupportMessageCommand,
575
+ GetSupportHistoryQuery,
576
+ GetSupportUnreadCountQuery,
577
+ MarkSupportChatReadByUserCommand,
578
+ ];
510
579
  const walletContracts: HttpContract[] = [GetWalletBalanceQuery, GetWalletTransactionsQuery];
511
580
  const paymentContracts: HttpContract[] = [CreatePaymentCommand];
512
581
  const marketplaceCardContracts: HttpContract[] = [
@@ -518,6 +587,7 @@ async function main() {
518
587
  DeleteMarketplaceCardCommand,
519
588
  ];
520
589
  const aiModelContracts: HttpContract[] = [GetAllAiModelsQuery, GetAiModelByUuidQuery];
590
+ const modelCatalogContracts: HttpContract[] = [GetModelCatalogQuery];
521
591
  const generationModelContracts: HttpContract[] = [
522
592
  GetGenerationModelsQuery,
523
593
  GetGenerationModelsByTypeQuery,
@@ -556,6 +626,10 @@ async function main() {
556
626
  GetAdminUserTransactionsQuery,
557
627
  GetAdminStatsQuery,
558
628
  GetAdminKieBalanceQuery,
629
+ GetAdminSupportChatsQuery,
630
+ GetAdminSupportChatMessagesQuery,
631
+ SendAdminSupportReplyCommand,
632
+ MarkAdminSupportChatReadCommand,
559
633
  ];
560
634
 
561
635
  for (const contract of authContracts) {
@@ -685,6 +759,37 @@ async function main() {
685
759
  });
686
760
  }
687
761
 
762
+ for (const contract of supportContracts) {
763
+ const method = contract.method.toLowerCase();
764
+ if (!supportedHttpMethods.has(method)) {
765
+ throw new Error(`Unsupported HTTP method: ${contract.method}`);
766
+ }
767
+
768
+ registry.registerPath({
769
+ method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
770
+ path: toOpenApiPath(SUPPORT_CONTROLLER, contract.path),
771
+ summary: contract.summary,
772
+ tags: ['Support'],
773
+ request: {
774
+ ...(contract.request?.body
775
+ ? {
776
+ body: {
777
+ required: true,
778
+ content: {
779
+ 'application/json': {
780
+ schema: resolveSchema(contract.request.body),
781
+ },
782
+ },
783
+ },
784
+ }
785
+ : {}),
786
+ ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
787
+ ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
788
+ },
789
+ responses: buildResponses(contract.responses, resolveSchema),
790
+ });
791
+ }
792
+
688
793
  for (const contract of walletContracts) {
689
794
  const method = contract.method.toLowerCase();
690
795
  if (!supportedHttpMethods.has(method)) {
@@ -778,6 +883,37 @@ async function main() {
778
883
  });
779
884
  }
780
885
 
886
+ for (const contract of modelCatalogContracts) {
887
+ const method = contract.method.toLowerCase();
888
+ if (!supportedHttpMethods.has(method)) {
889
+ throw new Error(`Unsupported HTTP method: ${contract.method}`);
890
+ }
891
+
892
+ registry.registerPath({
893
+ method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
894
+ path: toOpenApiPath(MODEL_CATALOG_CONTROLLER, contract.path),
895
+ summary: contract.summary,
896
+ tags: ['Model Catalog'],
897
+ request: {
898
+ ...(contract.request?.body
899
+ ? {
900
+ body: {
901
+ required: true,
902
+ content: {
903
+ 'application/json': {
904
+ schema: resolveSchema(contract.request.body),
905
+ },
906
+ },
907
+ },
908
+ }
909
+ : {}),
910
+ ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
911
+ ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
912
+ },
913
+ responses: buildResponses(contract.responses, resolveSchema),
914
+ });
915
+ }
916
+
781
917
  for (const contract of generationModelContracts) {
782
918
  const method = contract.method.toLowerCase();
783
919
  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>;