@ai-grator/api 0.3.77 → 0.3.78

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 (274) hide show
  1. package/admin/endpoints/admin.ts +16 -0
  2. package/admin/endpoints/commands/create-admin-preset-category.command.ts +29 -0
  3. package/admin/endpoints/commands/create-admin-preset.command.ts +30 -0
  4. package/admin/endpoints/commands/delete-admin-preset-category.command.ts +29 -0
  5. package/admin/endpoints/commands/delete-admin-preset.command.ts +28 -0
  6. package/admin/endpoints/commands/index.ts +9 -0
  7. package/admin/endpoints/commands/reorder-admin-preset-categories.command.ts +33 -0
  8. package/admin/endpoints/commands/reorder-admin-presets.command.ts +33 -0
  9. package/admin/endpoints/commands/update-admin-preset-category.command.ts +36 -0
  10. package/admin/endpoints/commands/update-admin-preset-status.command.ts +37 -0
  11. package/admin/endpoints/commands/update-admin-preset.command.ts +36 -0
  12. package/admin/endpoints/queries/get-admin-preset-categories.query.ts +22 -0
  13. package/admin/endpoints/queries/get-admin-preset.query.ts +29 -0
  14. package/admin/endpoints/queries/get-admin-presets.query.ts +37 -0
  15. package/admin/endpoints/queries/index.ts +3 -0
  16. package/admin/models/admin-preset-category-response.schema.ts +14 -0
  17. package/admin/models/admin-preset-response.schema.ts +67 -0
  18. package/admin/models/index.ts +2 -0
  19. package/build/admin/endpoints/admin.d.ts +12 -0
  20. package/build/admin/endpoints/admin.d.ts.map +1 -1
  21. package/build/admin/endpoints/admin.js +14 -0
  22. package/build/admin/endpoints/commands/create-admin-preset-category.command.d.ts +51 -0
  23. package/build/admin/endpoints/commands/create-admin-preset-category.command.d.ts.map +1 -0
  24. package/build/admin/endpoints/commands/create-admin-preset-category.command.js +25 -0
  25. package/build/admin/endpoints/commands/create-admin-preset.command.d.ts +490 -0
  26. package/build/admin/endpoints/commands/create-admin-preset.command.d.ts.map +1 -0
  27. package/build/admin/endpoints/commands/create-admin-preset.command.js +26 -0
  28. package/build/admin/endpoints/commands/delete-admin-preset-category.command.d.ts +27 -0
  29. package/build/admin/endpoints/commands/delete-admin-preset-category.command.d.ts.map +1 -0
  30. package/build/admin/endpoints/commands/delete-admin-preset-category.command.js +26 -0
  31. package/build/admin/endpoints/commands/delete-admin-preset.command.d.ts +26 -0
  32. package/build/admin/endpoints/commands/delete-admin-preset.command.d.ts.map +1 -0
  33. package/build/admin/endpoints/commands/delete-admin-preset.command.js +25 -0
  34. package/build/admin/endpoints/commands/index.d.ts +9 -0
  35. package/build/admin/endpoints/commands/index.d.ts.map +1 -1
  36. package/build/admin/endpoints/commands/index.js +9 -0
  37. package/build/admin/endpoints/commands/reorder-admin-preset-categories.command.d.ts +26 -0
  38. package/build/admin/endpoints/commands/reorder-admin-preset-categories.command.d.ts.map +1 -0
  39. package/build/admin/endpoints/commands/reorder-admin-preset-categories.command.js +28 -0
  40. package/build/admin/endpoints/commands/reorder-admin-presets.command.d.ts +29 -0
  41. package/build/admin/endpoints/commands/reorder-admin-presets.command.d.ts.map +1 -0
  42. package/build/admin/endpoints/commands/reorder-admin-presets.command.js +30 -0
  43. package/build/admin/endpoints/commands/update-admin-preset-category.command.d.ts +59 -0
  44. package/build/admin/endpoints/commands/update-admin-preset-category.command.d.ts.map +1 -0
  45. package/build/admin/endpoints/commands/update-admin-preset-category.command.js +31 -0
  46. package/build/admin/endpoints/commands/update-admin-preset-status.command.d.ts +312 -0
  47. package/build/admin/endpoints/commands/update-admin-preset-status.command.d.ts.map +1 -0
  48. package/build/admin/endpoints/commands/update-admin-preset-status.command.js +32 -0
  49. package/build/admin/endpoints/commands/update-admin-preset.command.d.ts +497 -0
  50. package/build/admin/endpoints/commands/update-admin-preset.command.d.ts.map +1 -0
  51. package/build/admin/endpoints/commands/update-admin-preset.command.js +31 -0
  52. package/build/admin/endpoints/queries/get-admin-preset-categories.query.d.ts +38 -0
  53. package/build/admin/endpoints/queries/get-admin-preset-categories.query.d.ts.map +1 -0
  54. package/build/admin/endpoints/queries/get-admin-preset-categories.query.js +21 -0
  55. package/build/admin/endpoints/queries/get-admin-preset.query.d.ts +304 -0
  56. package/build/admin/endpoints/queries/get-admin-preset.query.d.ts.map +1 -0
  57. package/build/admin/endpoints/queries/get-admin-preset.query.js +26 -0
  58. package/build/admin/endpoints/queries/get-admin-presets.query.d.ts +141 -0
  59. package/build/admin/endpoints/queries/get-admin-presets.query.d.ts.map +1 -0
  60. package/build/admin/endpoints/queries/get-admin-presets.query.js +34 -0
  61. package/build/admin/endpoints/queries/index.d.ts +3 -0
  62. package/build/admin/endpoints/queries/index.d.ts.map +1 -1
  63. package/build/admin/endpoints/queries/index.js +3 -0
  64. package/build/admin/models/admin-preset-category-response.schema.d.ts +13 -0
  65. package/build/admin/models/admin-preset-category-response.schema.d.ts.map +1 -0
  66. package/build/admin/models/admin-preset-category-response.schema.js +14 -0
  67. package/build/admin/models/admin-preset-response.schema.d.ts +205 -0
  68. package/build/admin/models/admin-preset-response.schema.d.ts.map +1 -0
  69. package/build/admin/models/admin-preset-response.schema.js +52 -0
  70. package/build/admin/models/index.d.ts +2 -0
  71. package/build/admin/models/index.d.ts.map +1 -1
  72. package/build/admin/models/index.js +2 -0
  73. package/build/chat/endpoints/commands/create-chat.command.d.ts +8 -0
  74. package/build/chat/endpoints/commands/create-chat.command.d.ts.map +1 -1
  75. package/build/chat/endpoints/commands/update-chat.command.d.ts +8 -0
  76. package/build/chat/endpoints/commands/update-chat.command.d.ts.map +1 -1
  77. package/build/chat/endpoints/queries/get-chat-by-uuid.query.d.ts +8 -0
  78. package/build/chat/endpoints/queries/get-chat-by-uuid.query.d.ts.map +1 -1
  79. package/build/chat/endpoints/queries/get-chats.query.d.ts +10 -0
  80. package/build/chat/endpoints/queries/get-chats.query.d.ts.map +1 -1
  81. package/build/chat/endpoints/queries/get-chats.query.js +4 -1
  82. package/build/chat/models/chat-response.schema.d.ts +4 -0
  83. package/build/chat/models/chat-response.schema.d.ts.map +1 -1
  84. package/build/chat/models/chat-response.schema.js +2 -0
  85. package/build/errors/errors.d.ts +202 -0
  86. package/build/errors/errors.d.ts.map +1 -1
  87. package/build/errors/errors.js +202 -0
  88. package/build/generation-job/endpoints/commands/create-generation-job.command.d.ts +8 -0
  89. package/build/generation-job/endpoints/commands/create-generation-job.command.d.ts.map +1 -1
  90. package/build/generation-job/endpoints/commands/update-generation-job.command.d.ts +8 -0
  91. package/build/generation-job/endpoints/commands/update-generation-job.command.d.ts.map +1 -1
  92. package/build/generation-job/endpoints/queries/get-generation-job-by-uuid.query.d.ts +8 -0
  93. package/build/generation-job/endpoints/queries/get-generation-job-by-uuid.query.d.ts.map +1 -1
  94. package/build/generation-job/endpoints/queries/get-generation-job-history.query.d.ts +14 -0
  95. package/build/generation-job/endpoints/queries/get-generation-job-history.query.d.ts.map +1 -1
  96. package/build/generation-job/endpoints/queries/get-generation-job-history.query.js +2 -0
  97. package/build/generation-job/endpoints/queries/get-generation-jobs.query.d.ts +10 -0
  98. package/build/generation-job/endpoints/queries/get-generation-jobs.query.d.ts.map +1 -1
  99. package/build/generation-job/endpoints/queries/get-generation-jobs.query.js +2 -0
  100. package/build/generation-job/models/generation-job-response.schema.d.ts +4 -0
  101. package/build/generation-job/models/generation-job-response.schema.d.ts.map +1 -1
  102. package/build/generation-job/models/generation-job-response.schema.js +2 -0
  103. package/build/generation-job-chat/endpoints/commands/create-generation-job-chat.command.d.ts +8 -0
  104. package/build/generation-job-chat/endpoints/commands/create-generation-job-chat.command.d.ts.map +1 -1
  105. package/build/generation-job-chat/endpoints/commands/update-generation-job-chat.command.d.ts +8 -0
  106. package/build/generation-job-chat/endpoints/commands/update-generation-job-chat.command.d.ts.map +1 -1
  107. package/build/generation-job-chat/endpoints/queries/get-generation-job-chat-by-uuid.query.d.ts +8 -0
  108. package/build/generation-job-chat/endpoints/queries/get-generation-job-chat-by-uuid.query.d.ts.map +1 -1
  109. package/build/generation-job-chat/endpoints/queries/get-generation-job-chats.query.d.ts +10 -0
  110. package/build/generation-job-chat/endpoints/queries/get-generation-job-chats.query.d.ts.map +1 -1
  111. package/build/generation-job-chat/endpoints/queries/get-generation-job-chats.query.js +2 -0
  112. package/build/generation-job-chat/models/generation-job-chat-response.schema.d.ts +4 -0
  113. package/build/generation-job-chat/models/generation-job-chat-response.schema.d.ts.map +1 -1
  114. package/build/generation-job-chat/models/generation-job-chat-response.schema.js +2 -0
  115. package/build/index.d.ts +1 -0
  116. package/build/index.d.ts.map +1 -1
  117. package/build/index.js +1 -0
  118. package/build/preset/endpoints/commands/add-preset-favorite.command.d.ts +25 -0
  119. package/build/preset/endpoints/commands/add-preset-favorite.command.d.ts.map +1 -0
  120. package/build/preset/endpoints/commands/add-preset-favorite.command.js +22 -0
  121. package/build/preset/endpoints/commands/index.d.ts +5 -0
  122. package/build/preset/endpoints/commands/index.d.ts.map +1 -0
  123. package/build/preset/endpoints/commands/index.js +20 -0
  124. package/build/preset/endpoints/commands/prepare-preset.command.d.ts +198 -0
  125. package/build/preset/endpoints/commands/prepare-preset.command.d.ts.map +1 -0
  126. package/build/preset/endpoints/commands/prepare-preset.command.js +41 -0
  127. package/build/preset/endpoints/commands/remove-preset-favorite.command.d.ts +25 -0
  128. package/build/preset/endpoints/commands/remove-preset-favorite.command.d.ts.map +1 -0
  129. package/build/preset/endpoints/commands/remove-preset-favorite.command.js +22 -0
  130. package/build/preset/endpoints/commands/run-preset.command.d.ts +387 -0
  131. package/build/preset/endpoints/commands/run-preset.command.d.ts.map +1 -0
  132. package/build/preset/endpoints/commands/run-preset.command.js +55 -0
  133. package/build/preset/endpoints/index.d.ts +4 -0
  134. package/build/preset/endpoints/index.d.ts.map +1 -0
  135. package/build/preset/endpoints/index.js +19 -0
  136. package/build/preset/endpoints/preset.d.ts +16 -0
  137. package/build/preset/endpoints/preset.d.ts.map +1 -0
  138. package/build/preset/endpoints/preset.js +18 -0
  139. package/build/preset/endpoints/queries/get-preset-price.query.d.ts +62 -0
  140. package/build/preset/endpoints/queries/get-preset-price.query.d.ts.map +1 -0
  141. package/build/preset/endpoints/queries/get-preset-price.query.js +30 -0
  142. package/build/preset/endpoints/queries/get-preset-results.query.d.ts +74 -0
  143. package/build/preset/endpoints/queries/get-preset-results.query.d.ts.map +1 -0
  144. package/build/preset/endpoints/queries/get-preset-results.query.js +32 -0
  145. package/build/preset/endpoints/queries/get-public-preset-by-slug.query.d.ts +334 -0
  146. package/build/preset/endpoints/queries/get-public-preset-by-slug.query.d.ts.map +1 -0
  147. package/build/preset/endpoints/queries/get-public-preset-by-slug.query.js +25 -0
  148. package/build/preset/endpoints/queries/index.d.ts +6 -0
  149. package/build/preset/endpoints/queries/index.d.ts.map +1 -0
  150. package/build/preset/endpoints/queries/index.js +21 -0
  151. package/build/preset/endpoints/queries/list-public-preset-categories.query.d.ts +28 -0
  152. package/build/preset/endpoints/queries/list-public-preset-categories.query.d.ts.map +1 -0
  153. package/build/preset/endpoints/queries/list-public-preset-categories.query.js +19 -0
  154. package/build/preset/endpoints/queries/list-public-presets.query.d.ts +122 -0
  155. package/build/preset/endpoints/queries/list-public-presets.query.d.ts.map +1 -0
  156. package/build/preset/endpoints/queries/list-public-presets.query.js +32 -0
  157. package/build/preset/enums/index.d.ts +10 -0
  158. package/build/preset/enums/index.d.ts.map +1 -0
  159. package/build/preset/enums/index.js +25 -0
  160. package/build/preset/enums/preset-card-media-type.enum.d.ts +6 -0
  161. package/build/preset/enums/preset-card-media-type.enum.d.ts.map +1 -0
  162. package/build/preset/enums/preset-card-media-type.enum.js +9 -0
  163. package/build/preset/enums/preset-example-type.enum.d.ts +5 -0
  164. package/build/preset/enums/preset-example-type.enum.d.ts.map +1 -0
  165. package/build/preset/enums/preset-example-type.enum.js +8 -0
  166. package/build/preset/enums/preset-field-type.enum.d.ts +6 -0
  167. package/build/preset/enums/preset-field-type.enum.d.ts.map +1 -0
  168. package/build/preset/enums/preset-field-type.enum.js +9 -0
  169. package/build/preset/enums/preset-filter.enum.d.ts +6 -0
  170. package/build/preset/enums/preset-filter.enum.d.ts.map +1 -0
  171. package/build/preset/enums/preset-filter.enum.js +9 -0
  172. package/build/preset/enums/preset-limits.d.ts +30 -0
  173. package/build/preset/enums/preset-limits.d.ts.map +1 -0
  174. package/build/preset/enums/preset-limits.js +32 -0
  175. package/build/preset/enums/preset-result-type.enum.d.ts +5 -0
  176. package/build/preset/enums/preset-result-type.enum.d.ts.map +1 -0
  177. package/build/preset/enums/preset-result-type.enum.js +8 -0
  178. package/build/preset/enums/preset-select-display.enum.d.ts +7 -0
  179. package/build/preset/enums/preset-select-display.enum.d.ts.map +1 -0
  180. package/build/preset/enums/preset-select-display.enum.js +10 -0
  181. package/build/preset/enums/preset-status.enum.d.ts +5 -0
  182. package/build/preset/enums/preset-status.enum.d.ts.map +1 -0
  183. package/build/preset/enums/preset-status.enum.js +8 -0
  184. package/build/preset/enums/preset-tool.enum.d.ts +6 -0
  185. package/build/preset/enums/preset-tool.enum.d.ts.map +1 -0
  186. package/build/preset/enums/preset-tool.enum.js +9 -0
  187. package/build/preset/helpers/index.d.ts +3 -0
  188. package/build/preset/helpers/index.d.ts.map +1 -0
  189. package/build/preset/helpers/index.js +18 -0
  190. package/build/preset/helpers/preset-prompt-placeholder.helper.d.ts +4 -0
  191. package/build/preset/helpers/preset-prompt-placeholder.helper.d.ts.map +1 -0
  192. package/build/preset/helpers/preset-prompt-placeholder.helper.js +12 -0
  193. package/build/preset/helpers/preset-tag.helper.d.ts +3 -0
  194. package/build/preset/helpers/preset-tag.helper.d.ts.map +1 -0
  195. package/build/preset/helpers/preset-tag.helper.js +9 -0
  196. package/build/preset/index.d.ts +5 -0
  197. package/build/preset/index.d.ts.map +1 -0
  198. package/build/preset/index.js +20 -0
  199. package/build/preset/models/index.d.ts +9 -0
  200. package/build/preset/models/index.d.ts.map +1 -0
  201. package/build/preset/models/index.js +24 -0
  202. package/build/preset/models/preset-common.schema.d.ts +23 -0
  203. package/build/preset/models/preset-common.schema.d.ts.map +1 -0
  204. package/build/preset/models/preset-common.schema.js +26 -0
  205. package/build/preset/models/preset-field-value.schema.d.ts +51 -0
  206. package/build/preset/models/preset-field-value.schema.d.ts.map +1 -0
  207. package/build/preset/models/preset-field-value.schema.js +44 -0
  208. package/build/preset/models/preset-field.schema.d.ts +310 -0
  209. package/build/preset/models/preset-field.schema.d.ts.map +1 -0
  210. package/build/preset/models/preset-field.schema.js +186 -0
  211. package/build/preset/models/preset-input.schema.d.ts +106 -0
  212. package/build/preset/models/preset-input.schema.d.ts.map +1 -0
  213. package/build/preset/models/preset-input.schema.js +97 -0
  214. package/build/preset/models/preset-media.schema.d.ts +81 -0
  215. package/build/preset/models/preset-media.schema.d.ts.map +1 -0
  216. package/build/preset/models/preset-media.schema.js +75 -0
  217. package/build/preset/models/preset-result.schema.d.ts +23 -0
  218. package/build/preset/models/preset-result.schema.d.ts.map +1 -0
  219. package/build/preset/models/preset-result.schema.js +21 -0
  220. package/build/preset/models/preset-tag.schema.d.ts +10 -0
  221. package/build/preset/models/preset-tag.schema.d.ts.map +1 -0
  222. package/build/preset/models/preset-tag.schema.js +11 -0
  223. package/build/preset/models/public-preset.schema.d.ts +322 -0
  224. package/build/preset/models/public-preset.schema.d.ts.map +1 -0
  225. package/build/preset/models/public-preset.schema.js +50 -0
  226. package/build/trend/endpoints/commands/generate-trend.command.d.ts +8 -0
  227. package/build/trend/endpoints/commands/generate-trend.command.d.ts.map +1 -1
  228. package/build/tsconfig.tsbuildinfo +1 -1
  229. package/chat/endpoints/queries/get-chats.query.ts +4 -1
  230. package/chat/models/chat-response.schema.ts +2 -0
  231. package/errors/errors.ts +202 -0
  232. package/generation-job/endpoints/queries/get-generation-job-history.query.ts +2 -0
  233. package/generation-job/endpoints/queries/get-generation-jobs.query.ts +2 -0
  234. package/generation-job/models/generation-job-response.schema.ts +2 -0
  235. package/generation-job-chat/endpoints/queries/get-generation-job-chats.query.ts +2 -0
  236. package/generation-job-chat/models/generation-job-chat-response.schema.ts +2 -0
  237. package/index.ts +1 -0
  238. package/package.json +1 -1
  239. package/preset/endpoints/commands/add-preset-favorite.command.ts +26 -0
  240. package/preset/endpoints/commands/index.ts +4 -0
  241. package/preset/endpoints/commands/prepare-preset.command.ts +47 -0
  242. package/preset/endpoints/commands/remove-preset-favorite.command.ts +26 -0
  243. package/preset/endpoints/commands/run-preset.command.ts +65 -0
  244. package/preset/endpoints/index.ts +3 -0
  245. package/preset/endpoints/preset.ts +18 -0
  246. package/preset/endpoints/queries/get-preset-price.query.ts +35 -0
  247. package/preset/endpoints/queries/get-preset-results.query.ts +37 -0
  248. package/preset/endpoints/queries/get-public-preset-by-slug.query.ts +30 -0
  249. package/preset/endpoints/queries/index.ts +5 -0
  250. package/preset/endpoints/queries/list-public-preset-categories.query.ts +20 -0
  251. package/preset/endpoints/queries/list-public-presets.query.ts +35 -0
  252. package/preset/enums/index.ts +9 -0
  253. package/preset/enums/preset-card-media-type.enum.ts +5 -0
  254. package/preset/enums/preset-example-type.enum.ts +4 -0
  255. package/preset/enums/preset-field-type.enum.ts +5 -0
  256. package/preset/enums/preset-filter.enum.ts +5 -0
  257. package/preset/enums/preset-limits.ts +33 -0
  258. package/preset/enums/preset-result-type.enum.ts +4 -0
  259. package/preset/enums/preset-select-display.enum.ts +6 -0
  260. package/preset/enums/preset-status.enum.ts +4 -0
  261. package/preset/enums/preset-tool.enum.ts +5 -0
  262. package/preset/helpers/index.ts +2 -0
  263. package/preset/helpers/preset-prompt-placeholder.helper.ts +9 -0
  264. package/preset/helpers/preset-tag.helper.ts +9 -0
  265. package/preset/index.ts +4 -0
  266. package/preset/models/index.ts +8 -0
  267. package/preset/models/preset-common.schema.ts +45 -0
  268. package/preset/models/preset-field-value.schema.ts +51 -0
  269. package/preset/models/preset-field.schema.ts +251 -0
  270. package/preset/models/preset-input.schema.ts +129 -0
  271. package/preset/models/preset-media.schema.ts +94 -0
  272. package/preset/models/preset-result.schema.ts +21 -0
  273. package/preset/models/preset-tag.schema.ts +13 -0
  274. package/preset/models/public-preset.schema.ts +68 -0
@@ -2,8 +2,11 @@ import { z } from 'zod';
2
2
  import { defineContract, defineCursorPaginationQuery, HTTP_METHODS, HttpErrorResponseSchema } from '../../../_common';
3
3
  import { ChatResponseSchema } from '../../models';
4
4
  import { CHAT_ROUTES } from '../chat';
5
+ import { PresetFilterQuerySchema } from '../../../preset/models/preset-tag.schema';
5
6
 
6
- export const GetChatsQueryQuery = defineCursorPaginationQuery(z.uuid());
7
+ export const GetChatsQueryQuery = defineCursorPaginationQuery(z.uuid()).extend({
8
+ presetFilter: PresetFilterQuerySchema,
9
+ });
7
10
 
8
11
  export const GetChatsQueryResponse = z.object({
9
12
  chats: z.array(ChatResponseSchema),
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { PresetTagSchema } from '../../preset/models/preset-tag.schema';
2
3
  import { CHAT_STATUS } from '../enums';
3
4
 
4
5
  export const ChatLastModelSchema = z.object({
@@ -17,6 +18,7 @@ export const ChatResponseSchema = z.object({
17
18
  title: z.string().min(1),
18
19
  chatStatus: z.enum(CHAT_STATUS),
19
20
  lastModel: ChatLastModelSchema.nullable(),
21
+ preset: PresetTagSchema.nullable(),
20
22
  createdAt: z.iso.datetime(),
21
23
  updatedAt: z.iso.datetime(),
22
24
  lastMessageAt: z.iso.datetime(),
package/errors/errors.ts CHANGED
@@ -1416,6 +1416,208 @@ export const ERRORS = {
1416
1416
  message: 'Не удалось запустить генерацию по тренду',
1417
1417
  },
1418
1418
  },
1419
+ PRESET: {
1420
+ NOT_FOUND: {
1421
+ httpCode: 404,
1422
+ code: 'PRESET.NOT_FOUND',
1423
+ message: 'Пресет не найден',
1424
+ },
1425
+ SLUG_CONFLICT: {
1426
+ httpCode: 409,
1427
+ code: 'PRESET.SLUG_CONFLICT',
1428
+ message: 'Пресет с таким slug уже существует',
1429
+ },
1430
+ CATEGORY_NOT_FOUND: {
1431
+ httpCode: 404,
1432
+ code: 'PRESET.CATEGORY_NOT_FOUND',
1433
+ message: 'Категория пресетов не найдена',
1434
+ },
1435
+ CATEGORY_SLUG_CONFLICT: {
1436
+ httpCode: 409,
1437
+ code: 'PRESET.CATEGORY_SLUG_CONFLICT',
1438
+ message: 'Категория пресетов с таким slug уже существует',
1439
+ },
1440
+ CATEGORY_NOT_EMPTY: {
1441
+ httpCode: 409,
1442
+ code: 'PRESET.CATEGORY_NOT_EMPTY',
1443
+ message: 'В категории есть пресеты, удалите или перенесите их',
1444
+ },
1445
+ CATEGORY_REORDER_INVALID: {
1446
+ httpCode: 400,
1447
+ code: 'PRESET.CATEGORY_REORDER_INVALID',
1448
+ message: 'Список для сортировки должен содержать все категории ровно один раз',
1449
+ },
1450
+ REORDER_INVALID: {
1451
+ httpCode: 400,
1452
+ code: 'PRESET.REORDER_INVALID',
1453
+ message: 'Список для сортировки должен содержать все пресеты категории ровно один раз',
1454
+ },
1455
+ MODEL_NOT_FOUND: {
1456
+ httpCode: 404,
1457
+ code: 'PRESET.MODEL_NOT_FOUND',
1458
+ message: 'Модель для пресета не найдена',
1459
+ },
1460
+ MODEL_TOOL_MISMATCH: {
1461
+ httpCode: 400,
1462
+ code: 'PRESET.MODEL_TOOL_MISMATCH',
1463
+ message: 'Модель не соответствует инструменту пресета',
1464
+ },
1465
+ MODEL_UNAVAILABLE: {
1466
+ httpCode: 400,
1467
+ code: 'PRESET.MODEL_UNAVAILABLE',
1468
+ message: 'Модель пресета сейчас недоступна',
1469
+ },
1470
+ PARAMS_INVALID: {
1471
+ httpCode: 400,
1472
+ code: 'PRESET.PARAMS_INVALID',
1473
+ message: 'Параметры пресета не подходят модели',
1474
+ },
1475
+ MEDIA_FILE_NOT_FOUND: {
1476
+ httpCode: 404,
1477
+ code: 'PRESET.MEDIA_FILE_NOT_FOUND',
1478
+ message: 'Файл медиа пресета не найден',
1479
+ },
1480
+ MEDIA_FILE_TYPE_INVALID: {
1481
+ httpCode: 400,
1482
+ code: 'PRESET.MEDIA_FILE_TYPE_INVALID',
1483
+ message: 'Файл медиа пресета имеет неверный тип',
1484
+ },
1485
+ ATTACHMENT_SLOT_NOT_FOUND: {
1486
+ httpCode: 400,
1487
+ code: 'PRESET.ATTACHMENT_SLOT_NOT_FOUND',
1488
+ message: 'Модель не поддерживает указанный слот вложений',
1489
+ },
1490
+ ATTACHMENT_SLOT_LIMIT_EXCEEDED: {
1491
+ httpCode: 400,
1492
+ code: 'PRESET.ATTACHMENT_SLOT_LIMIT_EXCEEDED',
1493
+ message: 'Количество файлов в полях превышает лимит модели',
1494
+ },
1495
+ PROMPT_UNKNOWN_FIELD: {
1496
+ httpCode: 400,
1497
+ code: 'PRESET.PROMPT_UNKNOWN_FIELD',
1498
+ message: 'Промпт ссылается на несуществующее поле',
1499
+ },
1500
+ FIELD_NOT_FOUND: {
1501
+ httpCode: 400,
1502
+ code: 'PRESET.FIELD_NOT_FOUND',
1503
+ message: 'Поле не принадлежит пресету',
1504
+ },
1505
+ FIELD_VALUE_MISSING: {
1506
+ httpCode: 400,
1507
+ code: 'PRESET.FIELD_VALUE_MISSING',
1508
+ message: 'Заполните обязательные поля пресета',
1509
+ },
1510
+ FIELD_VALUE_TYPE_MISMATCH: {
1511
+ httpCode: 400,
1512
+ code: 'PRESET.FIELD_VALUE_TYPE_MISMATCH',
1513
+ message: 'Тип значения не совпадает с типом поля',
1514
+ },
1515
+ FIELD_OPTION_NOT_FOUND: {
1516
+ httpCode: 400,
1517
+ code: 'PRESET.FIELD_OPTION_NOT_FOUND',
1518
+ message: 'Выбранный вариант не существует',
1519
+ },
1520
+ FIELD_MULTIPLE_NOT_ALLOWED: {
1521
+ httpCode: 400,
1522
+ code: 'PRESET.FIELD_MULTIPLE_NOT_ALLOWED',
1523
+ message: 'В поле можно выбрать только один вариант',
1524
+ },
1525
+ FIELD_CUSTOM_NOT_ALLOWED: {
1526
+ httpCode: 400,
1527
+ code: 'PRESET.FIELD_CUSTOM_NOT_ALLOWED',
1528
+ message: 'В поле нельзя указать свой вариант',
1529
+ },
1530
+ FIELD_TEXT_TOO_LONG: {
1531
+ httpCode: 400,
1532
+ code: 'PRESET.FIELD_TEXT_TOO_LONG',
1533
+ message: 'Текст превышает допустимую длину поля',
1534
+ },
1535
+ FIELD_FILE_COUNT_INVALID: {
1536
+ httpCode: 400,
1537
+ code: 'PRESET.FIELD_FILE_COUNT_INVALID',
1538
+ message: 'Количество файлов не соответствует полю',
1539
+ },
1540
+ FIELD_FILE_TYPE_INVALID: {
1541
+ httpCode: 400,
1542
+ code: 'PRESET.FIELD_FILE_TYPE_INVALID',
1543
+ message: 'Тип файла не подходит для поля',
1544
+ },
1545
+ FIELD_REQUIRE_ONE_OF_MISSING: {
1546
+ httpCode: 400,
1547
+ code: 'PRESET.FIELD_REQUIRE_ONE_OF_MISSING',
1548
+ message: 'Заполните хотя бы одно поле из группы',
1549
+ },
1550
+ FIELD_HIDDEN_VALUE: {
1551
+ httpCode: 400,
1552
+ code: 'PRESET.FIELD_HIDDEN_VALUE',
1553
+ message: 'Передано значение скрытого поля',
1554
+ },
1555
+ MODEL_FEATURE_UNSUPPORTED: {
1556
+ httpCode: 400,
1557
+ code: 'PRESET.MODEL_FEATURE_UNSUPPORTED',
1558
+ message: 'Модель не поддерживает выбранные опции чата',
1559
+ },
1560
+ PROMPT_TOO_LONG: {
1561
+ httpCode: 400,
1562
+ code: 'PRESET.PROMPT_TOO_LONG',
1563
+ message: 'Промпт с подставленными значениями превышает лимит модели',
1564
+ },
1565
+ FIND_ERROR: {
1566
+ httpCode: 500,
1567
+ code: 'PRESET.FIND_ERROR',
1568
+ message: 'Не удалось получить пресеты',
1569
+ },
1570
+ CREATE_ERROR: {
1571
+ httpCode: 500,
1572
+ code: 'PRESET.CREATE_ERROR',
1573
+ message: 'Не удалось создать пресет',
1574
+ },
1575
+ UPDATE_ERROR: {
1576
+ httpCode: 500,
1577
+ code: 'PRESET.UPDATE_ERROR',
1578
+ message: 'Не удалось обновить пресет',
1579
+ },
1580
+ DELETE_ERROR: {
1581
+ httpCode: 500,
1582
+ code: 'PRESET.DELETE_ERROR',
1583
+ message: 'Не удалось удалить пресет',
1584
+ },
1585
+ CATEGORY_SAVE_ERROR: {
1586
+ httpCode: 500,
1587
+ code: 'PRESET.CATEGORY_SAVE_ERROR',
1588
+ message: 'Не удалось сохранить категорию пресетов',
1589
+ },
1590
+ CATEGORY_DELETE_ERROR: {
1591
+ httpCode: 500,
1592
+ code: 'PRESET.CATEGORY_DELETE_ERROR',
1593
+ message: 'Не удалось удалить категорию пресетов',
1594
+ },
1595
+ FAVORITE_ERROR: {
1596
+ httpCode: 500,
1597
+ code: 'PRESET.FAVORITE_ERROR',
1598
+ message: 'Не удалось обновить избранное',
1599
+ },
1600
+ PRICE_ERROR: {
1601
+ httpCode: 500,
1602
+ code: 'PRESET.PRICE_ERROR',
1603
+ message: 'Не удалось рассчитать стоимость пресета',
1604
+ },
1605
+ RUN_ERROR: {
1606
+ httpCode: 500,
1607
+ code: 'PRESET.RUN_ERROR',
1608
+ message: 'Не удалось запустить пресет',
1609
+ },
1610
+ PREPARE_ERROR: {
1611
+ httpCode: 500,
1612
+ code: 'PRESET.PREPARE_ERROR',
1613
+ message: 'Не удалось подготовить чат по пресету',
1614
+ },
1615
+ RESULTS_ERROR: {
1616
+ httpCode: 500,
1617
+ code: 'PRESET.RESULTS_ERROR',
1618
+ message: 'Не удалось получить результаты по пресету',
1619
+ },
1620
+ },
1419
1621
  ANTIFRAUD: {
1420
1622
  CHECK_NOT_FOUND: {
1421
1623
  httpCode: 404,
@@ -3,6 +3,7 @@ import { defineContract, defineCursorPaginationQuery, HTTP_METHODS, HttpErrorRes
3
3
  import { GenerationTypeSchema } from '../../../generation-model';
4
4
  import { GenerationJobResponseSchema } from '../../models';
5
5
  import { GENERATION_JOB_ROUTES } from '../generation-job';
6
+ import { PresetFilterQuerySchema } from '../../../preset/models/preset-tag.schema';
6
7
 
7
8
  export const GetGenerationJobHistoryQueryQuery = defineCursorPaginationQuery(z.uuid()).extend({
8
9
  generationType: GenerationTypeSchema.optional(),
@@ -10,6 +11,7 @@ export const GetGenerationJobHistoryQueryQuery = defineCursorPaginationQuery(z.u
10
11
  prompt: z.string().min(1).optional(),
11
12
  dateFrom: z.coerce.date().optional(),
12
13
  dateTo: z.coerce.date().optional(),
14
+ presetFilter: PresetFilterQuerySchema,
13
15
  });
14
16
 
15
17
  export const GenerationJobHistoryItemSchema = GenerationJobResponseSchema.extend({
@@ -3,9 +3,11 @@ import { defineContract, HTTP_METHODS, HttpErrorResponseSchema } from '../../../
3
3
  import { GenerationTypeSchema } from '../../../generation-model';
4
4
  import { GenerationJobResponseSchema } from '../../models';
5
5
  import { GENERATION_JOB_ROUTES } from '../generation-job';
6
+ import { PresetFilterQuerySchema } from '../../../preset/models/preset-tag.schema';
6
7
 
7
8
  export const GetGenerationJobsQueryQuery = z.object({
8
9
  generationType: GenerationTypeSchema.optional(),
10
+ presetFilter: PresetFilterQuerySchema,
9
11
  });
10
12
 
11
13
  export const GetGenerationJobsQueryResponse = z.object({
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { GenerationTypeSchema } from '../../generation-model';
3
+ import { PresetTagSchema } from '../../preset/models/preset-tag.schema';
3
4
  import { GENERATION_JOB_STATUS } from '../enums';
4
5
  import { GenerationJobAttachmentFileSchema } from './generation-job-attachment-file.schema';
5
6
 
@@ -19,6 +20,7 @@ export const GenerationJobOutputSchema = z.object({
19
20
  export const GenerationJobResponseSchema = z.object({
20
21
  uuid: z.uuid(),
21
22
  jobChatId: z.uuid().nullable(),
23
+ preset: PresetTagSchema.nullable(),
22
24
  modelId: z.uuid(),
23
25
  generationType: GenerationTypeSchema,
24
26
  status: GenerationJobStatusSchema,
@@ -3,9 +3,11 @@ import { defineContract, defineCursorPaginationQuery, HTTP_METHODS, HttpErrorRes
3
3
  import { GenerationTypeSchema } from '../../../generation-model';
4
4
  import { GenerationJobChatResponseSchema } from '../../models';
5
5
  import { GENERATION_JOB_CHAT_ROUTES } from '../generation-job-chat';
6
+ import { PresetFilterQuerySchema } from '../../../preset/models/preset-tag.schema';
6
7
 
7
8
  export const GetGenerationJobChatsQueryQuery = defineCursorPaginationQuery(z.uuid()).extend({
8
9
  type: GenerationTypeSchema.optional(),
10
+ presetFilter: PresetFilterQuerySchema,
9
11
  });
10
12
 
11
13
  export const GetGenerationJobChatsQueryResponse = z.object({
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { GenerationTypeSchema } from '../../generation-model';
3
+ import { PresetTagSchema } from '../../preset/models/preset-tag.schema';
3
4
 
4
5
  export const GenerationJobChatResponseSchema = z.object({
5
6
  uuid: z.uuid(),
@@ -7,6 +8,7 @@ export const GenerationJobChatResponseSchema = z.object({
7
8
  type: GenerationTypeSchema,
8
9
  modelId: z.uuid().nullable(),
9
10
  trendId: z.uuid().nullable(),
11
+ preset: PresetTagSchema.nullable(),
10
12
  icon: z.url().nullable(),
11
13
  createdAt: z.iso.datetime(),
12
14
  updatedAt: z.iso.datetime(),
package/index.ts CHANGED
@@ -25,3 +25,4 @@ export * from './trend';
25
25
  export * from './support';
26
26
  export * from './user-context';
27
27
  export * from './organization';
28
+ export * from './preset';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-grator/api",
3
- "version": "0.3.77",
3
+ "version": "0.3.78",
4
4
  "main": "build/index.js",
5
5
  "types": "build/index.d.ts",
6
6
  "scripts": {
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ import { defineContract, HTTP_METHODS, HttpErrorResponseSchema, HttpSuccessResponseSchema } from '../../../_common';
3
+ import { PRESET_ROUTES } from '../preset';
4
+ import { PresetSlugParams } from '../queries/get-public-preset-by-slug.query';
5
+
6
+ export const AddPresetFavoriteCommandParams = PresetSlugParams;
7
+
8
+ export const AddPresetFavoriteCommandResponse = HttpSuccessResponseSchema;
9
+
10
+ export const AddPresetFavoriteCommand = defineContract({
11
+ method: HTTP_METHODS.PUT,
12
+ path: PRESET_ROUTES.ADD_FAVORITE(':slug'),
13
+ summary: 'Add preset to favorites of the current user; idempotent',
14
+ request: {
15
+ params: AddPresetFavoriteCommandParams,
16
+ },
17
+ responses: {
18
+ 200: AddPresetFavoriteCommandResponse,
19
+ 401: HttpErrorResponseSchema,
20
+ 404: HttpErrorResponseSchema,
21
+ 500: HttpErrorResponseSchema,
22
+ },
23
+ });
24
+
25
+ export type AddPresetFavoriteCommandParamsType = z.infer<typeof AddPresetFavoriteCommandParams>;
26
+ export type AddPresetFavoriteCommandResponseType = z.infer<typeof AddPresetFavoriteCommandResponse>;
@@ -0,0 +1,4 @@
1
+ export * from './run-preset.command';
2
+ export * from './prepare-preset.command';
3
+ export * from './add-preset-favorite.command';
4
+ export * from './remove-preset-favorite.command';
@@ -0,0 +1,47 @@
1
+ import { z } from 'zod';
2
+ import { defineContract, HTTP_METHODS, HttpErrorResponseSchema } from '../../../_common';
3
+ import { GenerationJobChatResponseSchema } from '../../../generation-job-chat/models/generation-job-chat-response.schema';
4
+ import { PRESET_TOOL } from '../../enums';
5
+ import { PresetModelParamsSchema } from '../../models';
6
+ import { PRESET_ROUTES } from '../preset';
7
+ import { PresetSlugParams } from '../queries/get-public-preset-by-slug.query';
8
+ import { PresetFieldValuesBody, PresetTextChatLaunchSchema } from './run-preset.command';
9
+
10
+ const PresetGenerationDraftSchema = z.object({
11
+ chat: GenerationJobChatResponseSchema,
12
+ modelId: z.uuid(),
13
+ prompt: z.string().min(1),
14
+ params: PresetModelParamsSchema,
15
+ attachments: z.record(z.string(), z.array(z.uuid())),
16
+ });
17
+
18
+ export const PreparePresetCommandParams = PresetSlugParams;
19
+
20
+ export const PreparePresetCommandBody = PresetFieldValuesBody;
21
+
22
+ export const PreparePresetCommandResponse = z.discriminatedUnion('tool', [
23
+ PresetGenerationDraftSchema.extend({ tool: z.literal(PRESET_TOOL.IMAGE) }),
24
+ PresetGenerationDraftSchema.extend({ tool: z.literal(PRESET_TOOL.VIDEO) }),
25
+ PresetTextChatLaunchSchema,
26
+ ]);
27
+
28
+ export const PreparePresetCommand = defineContract({
29
+ method: HTTP_METHODS.POST,
30
+ path: PRESET_ROUTES.PREPARE(':slug'),
31
+ summary: 'Create a tagged chat of the preset tool and return assembled prompt, model and params without running',
32
+ request: {
33
+ params: PreparePresetCommandParams,
34
+ body: PreparePresetCommandBody,
35
+ },
36
+ responses: {
37
+ 201: PreparePresetCommandResponse,
38
+ 400: HttpErrorResponseSchema,
39
+ 401: HttpErrorResponseSchema,
40
+ 404: HttpErrorResponseSchema,
41
+ 500: HttpErrorResponseSchema,
42
+ },
43
+ });
44
+
45
+ export type PreparePresetCommandParamsType = z.infer<typeof PreparePresetCommandParams>;
46
+ export type PreparePresetCommandBodyType = z.infer<typeof PreparePresetCommandBody>;
47
+ export type PreparePresetCommandResponseType = z.infer<typeof PreparePresetCommandResponse>;
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ import { defineContract, HTTP_METHODS, HttpErrorResponseSchema, HttpSuccessResponseSchema } from '../../../_common';
3
+ import { PRESET_ROUTES } from '../preset';
4
+ import { PresetSlugParams } from '../queries/get-public-preset-by-slug.query';
5
+
6
+ export const RemovePresetFavoriteCommandParams = PresetSlugParams;
7
+
8
+ export const RemovePresetFavoriteCommandResponse = HttpSuccessResponseSchema;
9
+
10
+ export const RemovePresetFavoriteCommand = defineContract({
11
+ method: HTTP_METHODS.DELETE,
12
+ path: PRESET_ROUTES.REMOVE_FAVORITE(':slug'),
13
+ summary: 'Remove preset from favorites of the current user; idempotent',
14
+ request: {
15
+ params: RemovePresetFavoriteCommandParams,
16
+ },
17
+ responses: {
18
+ 200: RemovePresetFavoriteCommandResponse,
19
+ 401: HttpErrorResponseSchema,
20
+ 404: HttpErrorResponseSchema,
21
+ 500: HttpErrorResponseSchema,
22
+ },
23
+ });
24
+
25
+ export type RemovePresetFavoriteCommandParamsType = z.infer<typeof RemovePresetFavoriteCommandParams>;
26
+ export type RemovePresetFavoriteCommandResponseType = z.infer<typeof RemovePresetFavoriteCommandResponse>;
@@ -0,0 +1,65 @@
1
+ import { z } from 'zod';
2
+ import { defineContract, HTTP_METHODS, HttpErrorResponseSchema } from '../../../_common';
3
+ import { ChatResponseSchema } from '../../../chat/models/chat-response.schema';
4
+ import { GenerationJobResponseSchema } from '../../../generation-job/models/generation-job-response.schema';
5
+ import { GenerationJobChatResponseSchema } from '../../../generation-job-chat/models/generation-job-chat-response.schema';
6
+ import { PRESET_TOOL } from '../../enums';
7
+ import { PresetChatOptionsSchema, PresetFieldValuesSchema } from '../../models';
8
+ import { PRESET_ROUTES } from '../preset';
9
+ import { PresetSlugParams } from '../queries/get-public-preset-by-slug.query';
10
+
11
+ export const PresetFieldValuesBody = z.object({
12
+ values: PresetFieldValuesSchema,
13
+ });
14
+
15
+ export const PresetTextChatLaunchSchema = z.object({
16
+ tool: z.literal(PRESET_TOOL.TEXT),
17
+ chat: ChatResponseSchema,
18
+ aiModelId: z.uuid(),
19
+ prompt: z.string().min(1),
20
+ fileIds: z.array(z.uuid()),
21
+ options: PresetChatOptionsSchema,
22
+ });
23
+
24
+ export const RunPresetCommandParams = PresetSlugParams;
25
+
26
+ export const RunPresetCommandBody = PresetFieldValuesBody;
27
+
28
+ export const RunPresetCommandResponse = z.discriminatedUnion('tool', [
29
+ z.object({
30
+ tool: z.literal(PRESET_TOOL.IMAGE),
31
+ chat: GenerationJobChatResponseSchema,
32
+ job: GenerationJobResponseSchema,
33
+ }),
34
+ z.object({
35
+ tool: z.literal(PRESET_TOOL.VIDEO),
36
+ chat: GenerationJobChatResponseSchema,
37
+ job: GenerationJobResponseSchema,
38
+ }),
39
+ PresetTextChatLaunchSchema,
40
+ ]);
41
+
42
+ export const RunPresetCommand = defineContract({
43
+ method: HTTP_METHODS.POST,
44
+ path: PRESET_ROUTES.RUN(':slug'),
45
+ summary:
46
+ 'Run preset: image/video creates a tagged generation chat and starts generation; text creates a tagged LLM chat and returns the prompt to send',
47
+ request: {
48
+ params: RunPresetCommandParams,
49
+ body: RunPresetCommandBody,
50
+ },
51
+ responses: {
52
+ 201: RunPresetCommandResponse,
53
+ 400: HttpErrorResponseSchema,
54
+ 401: HttpErrorResponseSchema,
55
+ 402: HttpErrorResponseSchema,
56
+ 404: HttpErrorResponseSchema,
57
+ 500: HttpErrorResponseSchema,
58
+ },
59
+ });
60
+
61
+ export type PresetFieldValuesBodyType = z.infer<typeof PresetFieldValuesBody>;
62
+ export type PresetTextChatLaunchSchemaType = z.infer<typeof PresetTextChatLaunchSchema>;
63
+ export type RunPresetCommandParamsType = z.infer<typeof RunPresetCommandParams>;
64
+ export type RunPresetCommandBodyType = z.infer<typeof RunPresetCommandBody>;
65
+ export type RunPresetCommandResponseType = z.infer<typeof RunPresetCommandResponse>;
@@ -0,0 +1,3 @@
1
+ export * from './preset';
2
+ export * from './commands';
3
+ export * from './queries';
@@ -0,0 +1,18 @@
1
+ export const PRESET_CONTROLLER = 'presets' as const;
2
+
3
+ export const PRESET_ROUTES = {
4
+ LIST: '',
5
+ GET_BY_SLUG: (slug: string) => `${slug}`,
6
+ GET_PRICE: (slug: string) => `${slug}/price`,
7
+ RUN: (slug: string) => `${slug}/run`,
8
+ PREPARE: (slug: string) => `${slug}/prepare`,
9
+ GET_RESULTS: (slug: string) => `${slug}/results`,
10
+ ADD_FAVORITE: (slug: string) => `${slug}/favorite`,
11
+ REMOVE_FAVORITE: (slug: string) => `${slug}/favorite`,
12
+ } as const;
13
+
14
+ export const PRESET_CATEGORY_CONTROLLER = 'preset-categories' as const;
15
+
16
+ export const PRESET_CATEGORY_ROUTES = {
17
+ LIST: '',
18
+ } as const;
@@ -0,0 +1,35 @@
1
+ import { z } from 'zod';
2
+ import { defineContract, HTTP_METHODS, HttpErrorResponseSchema } from '../../../_common';
3
+ import { PresetFieldValuesSchema } from '../../models';
4
+ import { PRESET_ROUTES } from '../preset';
5
+ import { PresetSlugParams } from './get-public-preset-by-slug.query';
6
+
7
+ export const GetPresetPriceQueryParams = PresetSlugParams;
8
+
9
+ export const GetPresetPriceQueryBody = z.object({
10
+ values: PresetFieldValuesSchema.default([]),
11
+ });
12
+
13
+ export const GetPresetPriceQueryResponse = z.object({
14
+ totalCost: z.number().nonnegative(),
15
+ });
16
+
17
+ export const GetPresetPriceQuery = defineContract({
18
+ method: HTTP_METHODS.POST,
19
+ path: PRESET_ROUTES.GET_PRICE(':slug'),
20
+ summary: 'Calculate preset price by model price with fixed params and params of selected options',
21
+ request: {
22
+ params: GetPresetPriceQueryParams,
23
+ body: GetPresetPriceQueryBody,
24
+ },
25
+ responses: {
26
+ 200: GetPresetPriceQueryResponse,
27
+ 400: HttpErrorResponseSchema,
28
+ 404: HttpErrorResponseSchema,
29
+ 500: HttpErrorResponseSchema,
30
+ },
31
+ });
32
+
33
+ export type GetPresetPriceQueryParamsType = z.infer<typeof GetPresetPriceQueryParams>;
34
+ export type GetPresetPriceQueryBodyType = z.infer<typeof GetPresetPriceQueryBody>;
35
+ export type GetPresetPriceQueryResponseType = z.infer<typeof GetPresetPriceQueryResponse>;
@@ -0,0 +1,37 @@
1
+ import { z } from 'zod';
2
+ import { defineContract, HTTP_METHODS, HttpErrorResponseSchema } from '../../../_common';
3
+ import { PRESET_RESULTS_DEFAULT_LIMIT, PRESET_RESULTS_MAX_LIMIT } from '../../enums';
4
+ import { PresetResultItemSchema } from '../../models';
5
+ import { PRESET_ROUTES } from '../preset';
6
+ import { PresetSlugParams } from './get-public-preset-by-slug.query';
7
+
8
+ export const GetPresetResultsQueryParams = PresetSlugParams;
9
+
10
+ export const GetPresetResultsQueryQuery = z.object({
11
+ limit: z.coerce.number().int().min(1).max(PRESET_RESULTS_MAX_LIMIT).default(PRESET_RESULTS_DEFAULT_LIMIT),
12
+ });
13
+
14
+ export const GetPresetResultsQueryResponse = z.object({
15
+ total: z.number().int().nonnegative(),
16
+ items: z.array(PresetResultItemSchema),
17
+ });
18
+
19
+ export const GetPresetResultsQuery = defineContract({
20
+ method: HTTP_METHODS.GET,
21
+ path: PRESET_ROUTES.GET_RESULTS(':slug'),
22
+ summary: 'Count and latest results of the current user made through the preset',
23
+ request: {
24
+ params: GetPresetResultsQueryParams,
25
+ query: GetPresetResultsQueryQuery,
26
+ },
27
+ responses: {
28
+ 200: GetPresetResultsQueryResponse,
29
+ 401: HttpErrorResponseSchema,
30
+ 404: HttpErrorResponseSchema,
31
+ 500: HttpErrorResponseSchema,
32
+ },
33
+ });
34
+
35
+ export type GetPresetResultsQueryParamsType = z.infer<typeof GetPresetResultsQueryParams>;
36
+ export type GetPresetResultsQueryQueryType = z.infer<typeof GetPresetResultsQueryQuery>;
37
+ export type GetPresetResultsQueryResponseType = z.infer<typeof GetPresetResultsQueryResponse>;
@@ -0,0 +1,30 @@
1
+ import { z } from 'zod';
2
+ import { defineContract, HTTP_METHODS, HttpErrorResponseSchema } from '../../../_common';
3
+ import { PresetSlugSchema, PublicPresetSchema } from '../../models';
4
+ import { PRESET_ROUTES } from '../preset';
5
+
6
+ export const PresetSlugParams = z.object({
7
+ slug: PresetSlugSchema,
8
+ });
9
+
10
+ export const GetPublicPresetBySlugQueryParams = PresetSlugParams;
11
+
12
+ export const GetPublicPresetBySlugQueryResponse = PublicPresetSchema;
13
+
14
+ export const GetPublicPresetBySlugQuery = defineContract({
15
+ method: HTTP_METHODS.GET,
16
+ path: PRESET_ROUTES.GET_BY_SLUG(':slug'),
17
+ summary: 'Get published preset with fields, model attachment limits, example and start price',
18
+ request: {
19
+ params: GetPublicPresetBySlugQueryParams,
20
+ },
21
+ responses: {
22
+ 200: GetPublicPresetBySlugQueryResponse,
23
+ 404: HttpErrorResponseSchema,
24
+ 500: HttpErrorResponseSchema,
25
+ },
26
+ });
27
+
28
+ export type PresetSlugParamsType = z.infer<typeof PresetSlugParams>;
29
+ export type GetPublicPresetBySlugQueryParamsType = z.infer<typeof GetPublicPresetBySlugQueryParams>;
30
+ export type GetPublicPresetBySlugQueryResponseType = z.infer<typeof GetPublicPresetBySlugQueryResponse>;
@@ -0,0 +1,5 @@
1
+ export * from './list-public-preset-categories.query';
2
+ export * from './list-public-presets.query';
3
+ export * from './get-public-preset-by-slug.query';
4
+ export * from './get-preset-price.query';
5
+ export * from './get-preset-results.query';
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ import { defineContract, HTTP_METHODS, HttpErrorResponseSchema } from '../../../_common';
3
+ import { PublicPresetCategorySchema } from '../../models';
4
+ import { PRESET_CATEGORY_ROUTES } from '../preset';
5
+
6
+ export const ListPublicPresetCategoriesQueryResponse = z.object({
7
+ categories: z.array(PublicPresetCategorySchema),
8
+ });
9
+
10
+ export const ListPublicPresetCategoriesQuery = defineContract({
11
+ method: HTTP_METHODS.GET,
12
+ path: PRESET_CATEGORY_ROUTES.LIST,
13
+ summary: 'List active preset categories ordered by admin order',
14
+ responses: {
15
+ 200: ListPublicPresetCategoriesQueryResponse,
16
+ 500: HttpErrorResponseSchema,
17
+ },
18
+ });
19
+
20
+ export type ListPublicPresetCategoriesQueryResponseType = z.infer<typeof ListPublicPresetCategoriesQueryResponse>;