@ai-grator/api 0.3.77 → 0.3.79

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 (286) 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/probe-admin-trend-reference-video.command.ts +1 -0
  8. package/admin/endpoints/commands/reorder-admin-preset-categories.command.ts +33 -0
  9. package/admin/endpoints/commands/reorder-admin-presets.command.ts +33 -0
  10. package/admin/endpoints/commands/update-admin-preset-category.command.ts +36 -0
  11. package/admin/endpoints/commands/update-admin-preset-status.command.ts +37 -0
  12. package/admin/endpoints/commands/update-admin-preset.command.ts +36 -0
  13. package/admin/endpoints/queries/get-admin-preset-categories.query.ts +22 -0
  14. package/admin/endpoints/queries/get-admin-preset.query.ts +29 -0
  15. package/admin/endpoints/queries/get-admin-presets.query.ts +37 -0
  16. package/admin/endpoints/queries/index.ts +3 -0
  17. package/admin/models/admin-preset-category-response.schema.ts +14 -0
  18. package/admin/models/admin-preset-response.schema.ts +67 -0
  19. package/admin/models/index.ts +2 -0
  20. package/build/admin/endpoints/admin.d.ts +12 -0
  21. package/build/admin/endpoints/admin.d.ts.map +1 -1
  22. package/build/admin/endpoints/admin.js +14 -0
  23. package/build/admin/endpoints/commands/create-admin-preset-category.command.d.ts +51 -0
  24. package/build/admin/endpoints/commands/create-admin-preset-category.command.d.ts.map +1 -0
  25. package/build/admin/endpoints/commands/create-admin-preset-category.command.js +25 -0
  26. package/build/admin/endpoints/commands/create-admin-preset.command.d.ts +490 -0
  27. package/build/admin/endpoints/commands/create-admin-preset.command.d.ts.map +1 -0
  28. package/build/admin/endpoints/commands/create-admin-preset.command.js +26 -0
  29. package/build/admin/endpoints/commands/delete-admin-preset-category.command.d.ts +27 -0
  30. package/build/admin/endpoints/commands/delete-admin-preset-category.command.d.ts.map +1 -0
  31. package/build/admin/endpoints/commands/delete-admin-preset-category.command.js +26 -0
  32. package/build/admin/endpoints/commands/delete-admin-preset.command.d.ts +26 -0
  33. package/build/admin/endpoints/commands/delete-admin-preset.command.d.ts.map +1 -0
  34. package/build/admin/endpoints/commands/delete-admin-preset.command.js +25 -0
  35. package/build/admin/endpoints/commands/index.d.ts +9 -0
  36. package/build/admin/endpoints/commands/index.d.ts.map +1 -1
  37. package/build/admin/endpoints/commands/index.js +9 -0
  38. package/build/admin/endpoints/commands/probe-admin-trend-reference-video.command.d.ts +2 -0
  39. package/build/admin/endpoints/commands/probe-admin-trend-reference-video.command.d.ts.map +1 -1
  40. package/build/admin/endpoints/commands/probe-admin-trend-reference-video.command.js +1 -0
  41. package/build/admin/endpoints/commands/reorder-admin-preset-categories.command.d.ts +26 -0
  42. package/build/admin/endpoints/commands/reorder-admin-preset-categories.command.d.ts.map +1 -0
  43. package/build/admin/endpoints/commands/reorder-admin-preset-categories.command.js +28 -0
  44. package/build/admin/endpoints/commands/reorder-admin-presets.command.d.ts +29 -0
  45. package/build/admin/endpoints/commands/reorder-admin-presets.command.d.ts.map +1 -0
  46. package/build/admin/endpoints/commands/reorder-admin-presets.command.js +30 -0
  47. package/build/admin/endpoints/commands/update-admin-preset-category.command.d.ts +59 -0
  48. package/build/admin/endpoints/commands/update-admin-preset-category.command.d.ts.map +1 -0
  49. package/build/admin/endpoints/commands/update-admin-preset-category.command.js +31 -0
  50. package/build/admin/endpoints/commands/update-admin-preset-status.command.d.ts +312 -0
  51. package/build/admin/endpoints/commands/update-admin-preset-status.command.d.ts.map +1 -0
  52. package/build/admin/endpoints/commands/update-admin-preset-status.command.js +32 -0
  53. package/build/admin/endpoints/commands/update-admin-preset.command.d.ts +497 -0
  54. package/build/admin/endpoints/commands/update-admin-preset.command.d.ts.map +1 -0
  55. package/build/admin/endpoints/commands/update-admin-preset.command.js +31 -0
  56. package/build/admin/endpoints/queries/get-admin-preset-categories.query.d.ts +38 -0
  57. package/build/admin/endpoints/queries/get-admin-preset-categories.query.d.ts.map +1 -0
  58. package/build/admin/endpoints/queries/get-admin-preset-categories.query.js +21 -0
  59. package/build/admin/endpoints/queries/get-admin-preset.query.d.ts +304 -0
  60. package/build/admin/endpoints/queries/get-admin-preset.query.d.ts.map +1 -0
  61. package/build/admin/endpoints/queries/get-admin-preset.query.js +26 -0
  62. package/build/admin/endpoints/queries/get-admin-presets.query.d.ts +141 -0
  63. package/build/admin/endpoints/queries/get-admin-presets.query.d.ts.map +1 -0
  64. package/build/admin/endpoints/queries/get-admin-presets.query.js +34 -0
  65. package/build/admin/endpoints/queries/index.d.ts +3 -0
  66. package/build/admin/endpoints/queries/index.d.ts.map +1 -1
  67. package/build/admin/endpoints/queries/index.js +3 -0
  68. package/build/admin/models/admin-preset-category-response.schema.d.ts +13 -0
  69. package/build/admin/models/admin-preset-category-response.schema.d.ts.map +1 -0
  70. package/build/admin/models/admin-preset-category-response.schema.js +14 -0
  71. package/build/admin/models/admin-preset-response.schema.d.ts +205 -0
  72. package/build/admin/models/admin-preset-response.schema.d.ts.map +1 -0
  73. package/build/admin/models/admin-preset-response.schema.js +52 -0
  74. package/build/admin/models/index.d.ts +2 -0
  75. package/build/admin/models/index.d.ts.map +1 -1
  76. package/build/admin/models/index.js +2 -0
  77. package/build/chat/endpoints/commands/create-chat.command.d.ts +8 -0
  78. package/build/chat/endpoints/commands/create-chat.command.d.ts.map +1 -1
  79. package/build/chat/endpoints/commands/update-chat.command.d.ts +8 -0
  80. package/build/chat/endpoints/commands/update-chat.command.d.ts.map +1 -1
  81. package/build/chat/endpoints/queries/get-chat-by-uuid.query.d.ts +8 -0
  82. package/build/chat/endpoints/queries/get-chat-by-uuid.query.d.ts.map +1 -1
  83. package/build/chat/endpoints/queries/get-chats.query.d.ts +10 -0
  84. package/build/chat/endpoints/queries/get-chats.query.d.ts.map +1 -1
  85. package/build/chat/endpoints/queries/get-chats.query.js +4 -1
  86. package/build/chat/models/chat-response.schema.d.ts +4 -0
  87. package/build/chat/models/chat-response.schema.d.ts.map +1 -1
  88. package/build/chat/models/chat-response.schema.js +2 -0
  89. package/build/errors/errors.d.ts +207 -0
  90. package/build/errors/errors.d.ts.map +1 -1
  91. package/build/errors/errors.js +207 -0
  92. package/build/generation-job/endpoints/commands/create-generation-job.command.d.ts +8 -0
  93. package/build/generation-job/endpoints/commands/create-generation-job.command.d.ts.map +1 -1
  94. package/build/generation-job/endpoints/commands/update-generation-job.command.d.ts +8 -0
  95. package/build/generation-job/endpoints/commands/update-generation-job.command.d.ts.map +1 -1
  96. package/build/generation-job/endpoints/queries/get-generation-job-by-uuid.query.d.ts +8 -0
  97. package/build/generation-job/endpoints/queries/get-generation-job-by-uuid.query.d.ts.map +1 -1
  98. package/build/generation-job/endpoints/queries/get-generation-job-history.query.d.ts +14 -0
  99. package/build/generation-job/endpoints/queries/get-generation-job-history.query.d.ts.map +1 -1
  100. package/build/generation-job/endpoints/queries/get-generation-job-history.query.js +2 -0
  101. package/build/generation-job/endpoints/queries/get-generation-jobs.query.d.ts +10 -0
  102. package/build/generation-job/endpoints/queries/get-generation-jobs.query.d.ts.map +1 -1
  103. package/build/generation-job/endpoints/queries/get-generation-jobs.query.js +2 -0
  104. package/build/generation-job/models/generation-job-response.schema.d.ts +4 -0
  105. package/build/generation-job/models/generation-job-response.schema.d.ts.map +1 -1
  106. package/build/generation-job/models/generation-job-response.schema.js +2 -0
  107. package/build/generation-job/models/index.d.ts +1 -0
  108. package/build/generation-job/models/index.d.ts.map +1 -1
  109. package/build/generation-job/models/index.js +1 -0
  110. package/build/generation-job/models/seedance-2_5-params.schema.d.ts +50 -0
  111. package/build/generation-job/models/seedance-2_5-params.schema.d.ts.map +1 -0
  112. package/build/generation-job/models/seedance-2_5-params.schema.js +30 -0
  113. package/build/generation-job-chat/endpoints/commands/create-generation-job-chat.command.d.ts +8 -0
  114. package/build/generation-job-chat/endpoints/commands/create-generation-job-chat.command.d.ts.map +1 -1
  115. package/build/generation-job-chat/endpoints/commands/update-generation-job-chat.command.d.ts +8 -0
  116. package/build/generation-job-chat/endpoints/commands/update-generation-job-chat.command.d.ts.map +1 -1
  117. package/build/generation-job-chat/endpoints/queries/get-generation-job-chat-by-uuid.query.d.ts +8 -0
  118. package/build/generation-job-chat/endpoints/queries/get-generation-job-chat-by-uuid.query.d.ts.map +1 -1
  119. package/build/generation-job-chat/endpoints/queries/get-generation-job-chats.query.d.ts +10 -0
  120. package/build/generation-job-chat/endpoints/queries/get-generation-job-chats.query.d.ts.map +1 -1
  121. package/build/generation-job-chat/endpoints/queries/get-generation-job-chats.query.js +2 -0
  122. package/build/generation-job-chat/models/generation-job-chat-response.schema.d.ts +4 -0
  123. package/build/generation-job-chat/models/generation-job-chat-response.schema.d.ts.map +1 -1
  124. package/build/generation-job-chat/models/generation-job-chat-response.schema.js +2 -0
  125. package/build/index.d.ts +1 -0
  126. package/build/index.d.ts.map +1 -1
  127. package/build/index.js +1 -0
  128. package/build/preset/endpoints/commands/add-preset-favorite.command.d.ts +25 -0
  129. package/build/preset/endpoints/commands/add-preset-favorite.command.d.ts.map +1 -0
  130. package/build/preset/endpoints/commands/add-preset-favorite.command.js +22 -0
  131. package/build/preset/endpoints/commands/index.d.ts +5 -0
  132. package/build/preset/endpoints/commands/index.d.ts.map +1 -0
  133. package/build/preset/endpoints/commands/index.js +20 -0
  134. package/build/preset/endpoints/commands/prepare-preset.command.d.ts +198 -0
  135. package/build/preset/endpoints/commands/prepare-preset.command.d.ts.map +1 -0
  136. package/build/preset/endpoints/commands/prepare-preset.command.js +41 -0
  137. package/build/preset/endpoints/commands/remove-preset-favorite.command.d.ts +25 -0
  138. package/build/preset/endpoints/commands/remove-preset-favorite.command.d.ts.map +1 -0
  139. package/build/preset/endpoints/commands/remove-preset-favorite.command.js +22 -0
  140. package/build/preset/endpoints/commands/run-preset.command.d.ts +387 -0
  141. package/build/preset/endpoints/commands/run-preset.command.d.ts.map +1 -0
  142. package/build/preset/endpoints/commands/run-preset.command.js +55 -0
  143. package/build/preset/endpoints/index.d.ts +4 -0
  144. package/build/preset/endpoints/index.d.ts.map +1 -0
  145. package/build/preset/endpoints/index.js +19 -0
  146. package/build/preset/endpoints/preset.d.ts +16 -0
  147. package/build/preset/endpoints/preset.d.ts.map +1 -0
  148. package/build/preset/endpoints/preset.js +18 -0
  149. package/build/preset/endpoints/queries/get-preset-price.query.d.ts +62 -0
  150. package/build/preset/endpoints/queries/get-preset-price.query.d.ts.map +1 -0
  151. package/build/preset/endpoints/queries/get-preset-price.query.js +30 -0
  152. package/build/preset/endpoints/queries/get-preset-results.query.d.ts +74 -0
  153. package/build/preset/endpoints/queries/get-preset-results.query.d.ts.map +1 -0
  154. package/build/preset/endpoints/queries/get-preset-results.query.js +32 -0
  155. package/build/preset/endpoints/queries/get-public-preset-by-slug.query.d.ts +334 -0
  156. package/build/preset/endpoints/queries/get-public-preset-by-slug.query.d.ts.map +1 -0
  157. package/build/preset/endpoints/queries/get-public-preset-by-slug.query.js +25 -0
  158. package/build/preset/endpoints/queries/index.d.ts +6 -0
  159. package/build/preset/endpoints/queries/index.d.ts.map +1 -0
  160. package/build/preset/endpoints/queries/index.js +21 -0
  161. package/build/preset/endpoints/queries/list-public-preset-categories.query.d.ts +28 -0
  162. package/build/preset/endpoints/queries/list-public-preset-categories.query.d.ts.map +1 -0
  163. package/build/preset/endpoints/queries/list-public-preset-categories.query.js +19 -0
  164. package/build/preset/endpoints/queries/list-public-presets.query.d.ts +122 -0
  165. package/build/preset/endpoints/queries/list-public-presets.query.d.ts.map +1 -0
  166. package/build/preset/endpoints/queries/list-public-presets.query.js +32 -0
  167. package/build/preset/enums/index.d.ts +10 -0
  168. package/build/preset/enums/index.d.ts.map +1 -0
  169. package/build/preset/enums/index.js +25 -0
  170. package/build/preset/enums/preset-card-media-type.enum.d.ts +6 -0
  171. package/build/preset/enums/preset-card-media-type.enum.d.ts.map +1 -0
  172. package/build/preset/enums/preset-card-media-type.enum.js +9 -0
  173. package/build/preset/enums/preset-example-type.enum.d.ts +5 -0
  174. package/build/preset/enums/preset-example-type.enum.d.ts.map +1 -0
  175. package/build/preset/enums/preset-example-type.enum.js +8 -0
  176. package/build/preset/enums/preset-field-type.enum.d.ts +6 -0
  177. package/build/preset/enums/preset-field-type.enum.d.ts.map +1 -0
  178. package/build/preset/enums/preset-field-type.enum.js +9 -0
  179. package/build/preset/enums/preset-filter.enum.d.ts +6 -0
  180. package/build/preset/enums/preset-filter.enum.d.ts.map +1 -0
  181. package/build/preset/enums/preset-filter.enum.js +9 -0
  182. package/build/preset/enums/preset-limits.d.ts +30 -0
  183. package/build/preset/enums/preset-limits.d.ts.map +1 -0
  184. package/build/preset/enums/preset-limits.js +32 -0
  185. package/build/preset/enums/preset-result-type.enum.d.ts +5 -0
  186. package/build/preset/enums/preset-result-type.enum.d.ts.map +1 -0
  187. package/build/preset/enums/preset-result-type.enum.js +8 -0
  188. package/build/preset/enums/preset-select-display.enum.d.ts +7 -0
  189. package/build/preset/enums/preset-select-display.enum.d.ts.map +1 -0
  190. package/build/preset/enums/preset-select-display.enum.js +10 -0
  191. package/build/preset/enums/preset-status.enum.d.ts +5 -0
  192. package/build/preset/enums/preset-status.enum.d.ts.map +1 -0
  193. package/build/preset/enums/preset-status.enum.js +8 -0
  194. package/build/preset/enums/preset-tool.enum.d.ts +6 -0
  195. package/build/preset/enums/preset-tool.enum.d.ts.map +1 -0
  196. package/build/preset/enums/preset-tool.enum.js +9 -0
  197. package/build/preset/helpers/index.d.ts +3 -0
  198. package/build/preset/helpers/index.d.ts.map +1 -0
  199. package/build/preset/helpers/index.js +18 -0
  200. package/build/preset/helpers/preset-prompt-placeholder.helper.d.ts +4 -0
  201. package/build/preset/helpers/preset-prompt-placeholder.helper.d.ts.map +1 -0
  202. package/build/preset/helpers/preset-prompt-placeholder.helper.js +12 -0
  203. package/build/preset/helpers/preset-tag.helper.d.ts +3 -0
  204. package/build/preset/helpers/preset-tag.helper.d.ts.map +1 -0
  205. package/build/preset/helpers/preset-tag.helper.js +9 -0
  206. package/build/preset/index.d.ts +5 -0
  207. package/build/preset/index.d.ts.map +1 -0
  208. package/build/preset/index.js +20 -0
  209. package/build/preset/models/index.d.ts +9 -0
  210. package/build/preset/models/index.d.ts.map +1 -0
  211. package/build/preset/models/index.js +24 -0
  212. package/build/preset/models/preset-common.schema.d.ts +23 -0
  213. package/build/preset/models/preset-common.schema.d.ts.map +1 -0
  214. package/build/preset/models/preset-common.schema.js +26 -0
  215. package/build/preset/models/preset-field-value.schema.d.ts +51 -0
  216. package/build/preset/models/preset-field-value.schema.d.ts.map +1 -0
  217. package/build/preset/models/preset-field-value.schema.js +44 -0
  218. package/build/preset/models/preset-field.schema.d.ts +310 -0
  219. package/build/preset/models/preset-field.schema.d.ts.map +1 -0
  220. package/build/preset/models/preset-field.schema.js +186 -0
  221. package/build/preset/models/preset-input.schema.d.ts +106 -0
  222. package/build/preset/models/preset-input.schema.d.ts.map +1 -0
  223. package/build/preset/models/preset-input.schema.js +97 -0
  224. package/build/preset/models/preset-media.schema.d.ts +81 -0
  225. package/build/preset/models/preset-media.schema.d.ts.map +1 -0
  226. package/build/preset/models/preset-media.schema.js +75 -0
  227. package/build/preset/models/preset-result.schema.d.ts +23 -0
  228. package/build/preset/models/preset-result.schema.d.ts.map +1 -0
  229. package/build/preset/models/preset-result.schema.js +21 -0
  230. package/build/preset/models/preset-tag.schema.d.ts +10 -0
  231. package/build/preset/models/preset-tag.schema.d.ts.map +1 -0
  232. package/build/preset/models/preset-tag.schema.js +11 -0
  233. package/build/preset/models/public-preset.schema.d.ts +322 -0
  234. package/build/preset/models/public-preset.schema.d.ts.map +1 -0
  235. package/build/preset/models/public-preset.schema.js +50 -0
  236. package/build/trend/endpoints/commands/generate-trend.command.d.ts +8 -0
  237. package/build/trend/endpoints/commands/generate-trend.command.d.ts.map +1 -1
  238. package/build/tsconfig.tsbuildinfo +1 -1
  239. package/chat/endpoints/queries/get-chats.query.ts +4 -1
  240. package/chat/models/chat-response.schema.ts +2 -0
  241. package/errors/errors.ts +207 -0
  242. package/generation-job/endpoints/queries/get-generation-job-history.query.ts +2 -0
  243. package/generation-job/endpoints/queries/get-generation-jobs.query.ts +2 -0
  244. package/generation-job/models/generation-job-response.schema.ts +2 -0
  245. package/generation-job/models/index.ts +1 -0
  246. package/generation-job/models/seedance-2_5-params.schema.ts +32 -0
  247. package/generation-job-chat/endpoints/queries/get-generation-job-chats.query.ts +2 -0
  248. package/generation-job-chat/models/generation-job-chat-response.schema.ts +2 -0
  249. package/index.ts +1 -0
  250. package/package.json +1 -1
  251. package/preset/endpoints/commands/add-preset-favorite.command.ts +26 -0
  252. package/preset/endpoints/commands/index.ts +4 -0
  253. package/preset/endpoints/commands/prepare-preset.command.ts +47 -0
  254. package/preset/endpoints/commands/remove-preset-favorite.command.ts +26 -0
  255. package/preset/endpoints/commands/run-preset.command.ts +65 -0
  256. package/preset/endpoints/index.ts +3 -0
  257. package/preset/endpoints/preset.ts +18 -0
  258. package/preset/endpoints/queries/get-preset-price.query.ts +35 -0
  259. package/preset/endpoints/queries/get-preset-results.query.ts +37 -0
  260. package/preset/endpoints/queries/get-public-preset-by-slug.query.ts +30 -0
  261. package/preset/endpoints/queries/index.ts +5 -0
  262. package/preset/endpoints/queries/list-public-preset-categories.query.ts +20 -0
  263. package/preset/endpoints/queries/list-public-presets.query.ts +35 -0
  264. package/preset/enums/index.ts +9 -0
  265. package/preset/enums/preset-card-media-type.enum.ts +5 -0
  266. package/preset/enums/preset-example-type.enum.ts +4 -0
  267. package/preset/enums/preset-field-type.enum.ts +5 -0
  268. package/preset/enums/preset-filter.enum.ts +5 -0
  269. package/preset/enums/preset-limits.ts +33 -0
  270. package/preset/enums/preset-result-type.enum.ts +4 -0
  271. package/preset/enums/preset-select-display.enum.ts +6 -0
  272. package/preset/enums/preset-status.enum.ts +4 -0
  273. package/preset/enums/preset-tool.enum.ts +5 -0
  274. package/preset/helpers/index.ts +2 -0
  275. package/preset/helpers/preset-prompt-placeholder.helper.ts +9 -0
  276. package/preset/helpers/preset-tag.helper.ts +9 -0
  277. package/preset/index.ts +4 -0
  278. package/preset/models/index.ts +8 -0
  279. package/preset/models/preset-common.schema.ts +45 -0
  280. package/preset/models/preset-field-value.schema.ts +51 -0
  281. package/preset/models/preset-field.schema.ts +251 -0
  282. package/preset/models/preset-input.schema.ts +129 -0
  283. package/preset/models/preset-media.schema.ts +94 -0
  284. package/preset/models/preset-result.schema.ts +21 -0
  285. package/preset/models/preset-tag.schema.ts +13 -0
  286. package/preset/models/public-preset.schema.ts +68 -0
@@ -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>;
@@ -0,0 +1,35 @@
1
+ import { z } from 'zod';
2
+ import { defineContract, defineOffsetPaginationQuery, HTTP_METHODS, HttpErrorResponseSchema } from '../../../_common';
3
+ import { PRESET_SEARCH_MAX_LENGTH } from '../../enums';
4
+ import { PresetSlugSchema, PublicPresetCardSchema } from '../../models';
5
+ import { PRESET_ROUTES } from '../preset';
6
+
7
+ export const ListPublicPresetsQueryQuery = defineOffsetPaginationQuery().extend({
8
+ categorySlug: PresetSlugSchema.optional(),
9
+ q: z.string().trim().min(1).max(PRESET_SEARCH_MAX_LENGTH).optional(),
10
+ favorites: z.stringbool().optional(),
11
+ });
12
+
13
+ export const ListPublicPresetsQueryResponse = z.object({
14
+ presets: z.array(PublicPresetCardSchema),
15
+ total: z.number().int().nonnegative(),
16
+ page: z.number().int().positive(),
17
+ limit: z.number().int().positive(),
18
+ });
19
+
20
+ export const ListPublicPresetsQuery = defineContract({
21
+ method: HTTP_METHODS.GET,
22
+ path: PRESET_ROUTES.LIST,
23
+ summary: 'List published presets with active model, ordered by admin order; supports search and favorites',
24
+ request: {
25
+ query: ListPublicPresetsQueryQuery,
26
+ },
27
+ responses: {
28
+ 200: ListPublicPresetsQueryResponse,
29
+ 400: HttpErrorResponseSchema,
30
+ 500: HttpErrorResponseSchema,
31
+ },
32
+ });
33
+
34
+ export type ListPublicPresetsQueryQueryType = z.infer<typeof ListPublicPresetsQueryQuery>;
35
+ export type ListPublicPresetsQueryResponseType = z.infer<typeof ListPublicPresetsQueryResponse>;
@@ -0,0 +1,9 @@
1
+ export * from './preset-status.enum';
2
+ export * from './preset-tool.enum';
3
+ export * from './preset-field-type.enum';
4
+ export * from './preset-select-display.enum';
5
+ export * from './preset-card-media-type.enum';
6
+ export * from './preset-example-type.enum';
7
+ export * from './preset-filter.enum';
8
+ export * from './preset-result-type.enum';
9
+ export * from './preset-limits';
@@ -0,0 +1,5 @@
1
+ export enum PRESET_CARD_MEDIA_TYPE {
2
+ IMAGE = 'image',
3
+ COMPARE = 'compare',
4
+ VIDEO = 'video',
5
+ }
@@ -0,0 +1,4 @@
1
+ export enum PRESET_EXAMPLE_TYPE {
2
+ MEDIA = 'media',
3
+ TEXT = 'text',
4
+ }
@@ -0,0 +1,5 @@
1
+ export enum PRESET_FIELD_TYPE {
2
+ FILE = 'file',
3
+ SELECT = 'select',
4
+ TEXT = 'text',
5
+ }
@@ -0,0 +1,5 @@
1
+ export enum PRESET_FILTER {
2
+ ALL = 'all',
3
+ ONLY = 'only',
4
+ EXCLUDE = 'exclude',
5
+ }
@@ -0,0 +1,33 @@
1
+ export const PRESET_SLUG_MAX_LENGTH = 255;
2
+ export const PRESET_SLUG_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
3
+ export const PRESET_TITLE_MAX_LENGTH = 40;
4
+ export const PRESET_SHORT_DESCRIPTION_MAX_LENGTH = 90;
5
+ export const PRESET_DESCRIPTION_MAX_LENGTH = 300;
6
+ export const PRESET_BADGE_MAX_LENGTH = 50;
7
+ export const PRESET_PROMPT_TEMPLATE_MAX_LENGTH = 10000;
8
+ export const PRESET_MAX_FIELDS = 5;
9
+ export const PRESET_MAX_REQUIRED_FIELDS = 3;
10
+
11
+ export const PRESET_FIELD_KEY_MAX_LENGTH = 50;
12
+ export const PRESET_FIELD_KEY_PATTERN = /^[a-z][a-z0-9_]*$/;
13
+ export const PRESET_FIELD_LABEL_MAX_LENGTH = 100;
14
+ export const PRESET_FIELD_HINT_MAX_LENGTH = 200;
15
+ export const PRESET_FIELD_PROMPT_VALUE_MAX_LENGTH = 1000;
16
+ export const PRESET_SELECT_MAX_OPTIONS = 20;
17
+ export const PRESET_SELECT_OPTION_VALUE_MAX_LENGTH = 50;
18
+ export const PRESET_TEXT_FIELD_MAX_LENGTH = 50000;
19
+ export const PRESET_TEXT_FIELD_DEFAULT_MAX_LENGTH = 500;
20
+ export const PRESET_SELECT_CUSTOM_VALUE_MAX_LENGTH = 300;
21
+ export const PRESET_SELECT_CUSTOM_VALUE_DEFAULT_MAX_LENGTH = 150;
22
+
23
+ export const PRESET_EXAMPLE_MAX_MEDIA_ITEMS = 6;
24
+ export const PRESET_EXAMPLE_CAPTION_MAX_LENGTH = 100;
25
+ export const PRESET_EXAMPLE_TEXT_MAX_LENGTH = 5000;
26
+ export const PRESET_EXAMPLE_SOURCE_MAX_LENGTH = 2000;
27
+
28
+ export const PRESET_CATEGORY_NAME_MAX_LENGTH = 100;
29
+ export const PRESET_CATEGORY_ICON_MAX_LENGTH = 100;
30
+
31
+ export const PRESET_SEARCH_MAX_LENGTH = 255;
32
+ export const PRESET_RESULTS_DEFAULT_LIMIT = 4;
33
+ export const PRESET_RESULTS_MAX_LIMIT = 20;
@@ -0,0 +1,4 @@
1
+ export enum PRESET_RESULT_TYPE {
2
+ GENERATION = 'generation',
3
+ CHAT = 'chat',
4
+ }
@@ -0,0 +1,6 @@
1
+ export enum PRESET_SELECT_DISPLAY {
2
+ CHIPS = 'chips',
3
+ DROPDOWN = 'dropdown',
4
+ SWITCH = 'switch',
5
+ TILES = 'tiles',
6
+ }
@@ -0,0 +1,4 @@
1
+ export enum PRESET_STATUS {
2
+ DRAFT = 'draft',
3
+ PUBLISHED = 'published',
4
+ }
@@ -0,0 +1,5 @@
1
+ export enum PRESET_TOOL {
2
+ IMAGE = 'image',
3
+ VIDEO = 'video',
4
+ TEXT = 'text',
5
+ }
@@ -0,0 +1,2 @@
1
+ export * from './preset-prompt-placeholder.helper';
2
+ export * from './preset-tag.helper';
@@ -0,0 +1,9 @@
1
+ export const PRESET_PROMPT_PLACEHOLDER_PATTERN = /\{([a-z][a-z0-9_]*)\}/g;
2
+
3
+ export function toPresetPromptPlaceholder(fieldKey: string): string {
4
+ return `{${fieldKey}}`;
5
+ }
6
+
7
+ export function extractPresetPromptPlaceholders(promptTemplate: string): string[] {
8
+ return [...new Set(Array.from(promptTemplate.matchAll(PRESET_PROMPT_PLACEHOLDER_PATTERN), (match) => match[1]))];
9
+ }
@@ -0,0 +1,9 @@
1
+ import { PresetTagSchemaType } from '../models/preset-tag.schema';
2
+
3
+ export function toPresetTag(presetId: string | null, presetTitle: string | null): PresetTagSchemaType | null {
4
+ if (!presetTitle) {
5
+ return null;
6
+ }
7
+
8
+ return { uuid: presetId ?? null, title: presetTitle };
9
+ }
@@ -0,0 +1,4 @@
1
+ export * from './enums';
2
+ export * from './helpers';
3
+ export * from './models';
4
+ export * from './endpoints';
@@ -0,0 +1,8 @@
1
+ export * from './preset-tag.schema';
2
+ export * from './preset-common.schema';
3
+ export * from './preset-field.schema';
4
+ export * from './preset-media.schema';
5
+ export * from './preset-input.schema';
6
+ export * from './preset-field-value.schema';
7
+ export * from './public-preset.schema';
8
+ export * from './preset-result.schema';
@@ -0,0 +1,45 @@
1
+ import { z } from 'zod';
2
+ import {
3
+ PRESET_CATEGORY_ICON_MAX_LENGTH,
4
+ PRESET_CATEGORY_NAME_MAX_LENGTH,
5
+ PRESET_FIELD_KEY_MAX_LENGTH,
6
+ PRESET_FIELD_KEY_PATTERN,
7
+ PRESET_FIELD_TYPE,
8
+ PRESET_SLUG_MAX_LENGTH,
9
+ PRESET_SLUG_PATTERN,
10
+ PRESET_STATUS,
11
+ PRESET_TOOL,
12
+ } from '../enums';
13
+
14
+ export const PresetStatusSchema = z.enum(PRESET_STATUS);
15
+ export const PresetToolSchema = z.enum(PRESET_TOOL);
16
+ export const PresetFieldTypeSchema = z.enum(PRESET_FIELD_TYPE);
17
+
18
+ export const PresetSlugSchema = z.string().min(1).max(PRESET_SLUG_MAX_LENGTH).regex(PRESET_SLUG_PATTERN);
19
+
20
+ export const PresetFieldKeySchema = z
21
+ .string()
22
+ .min(1)
23
+ .max(PRESET_FIELD_KEY_MAX_LENGTH)
24
+ .regex(PRESET_FIELD_KEY_PATTERN, 'Field key must start with a-z and contain only a-z, 0-9 and _');
25
+
26
+ export const PresetCategoryNameSchema = z.string().trim().min(1).max(PRESET_CATEGORY_NAME_MAX_LENGTH);
27
+
28
+ export const PresetCategoryIconSchema = z.string().trim().min(1).max(PRESET_CATEGORY_ICON_MAX_LENGTH);
29
+
30
+ export const PresetModelParamsSchema = z.record(z.string(), z.unknown());
31
+
32
+ export const PresetChatOptionsSchema = z.object({
33
+ reasoning: z.boolean().default(false),
34
+ webSearch: z.boolean().default(false),
35
+ });
36
+
37
+ export const PresetFileSchema = z.object({
38
+ uuid: z.uuid(),
39
+ url: z.url(),
40
+ thumbnailUrl: z.url().nullable(),
41
+ });
42
+
43
+ export type PresetModelParamsSchemaType = z.infer<typeof PresetModelParamsSchema>;
44
+ export type PresetChatOptionsSchemaType = z.infer<typeof PresetChatOptionsSchema>;
45
+ export type PresetFileSchemaType = z.infer<typeof PresetFileSchema>;
@@ -0,0 +1,51 @@
1
+ import { z } from 'zod';
2
+ import { PRESET_FIELD_TYPE, PRESET_MAX_FIELDS, PRESET_SELECT_CUSTOM_VALUE_MAX_LENGTH } from '../enums';
3
+ import { PresetFieldKeySchema } from './preset-common.schema';
4
+
5
+ export const PresetFileFieldValueSchema = z.object({
6
+ type: z.literal(PRESET_FIELD_TYPE.FILE),
7
+ key: PresetFieldKeySchema,
8
+ fileIds: z
9
+ .array(z.uuid())
10
+ .min(1)
11
+ .refine((fileIds) => new Set(fileIds).size === fileIds.length, { message: 'File ids must be unique' }),
12
+ });
13
+
14
+ export const PresetSelectFieldValueSchema = z
15
+ .object({
16
+ type: z.literal(PRESET_FIELD_TYPE.SELECT),
17
+ key: PresetFieldKeySchema,
18
+ values: z.array(z.string().min(1)).default([]),
19
+ customValue: z.string().trim().min(1).max(PRESET_SELECT_CUSTOM_VALUE_MAX_LENGTH).nullable().default(null),
20
+ })
21
+ .refine((value) => new Set(value.values).size === value.values.length, {
22
+ path: ['values'],
23
+ message: 'Selected values must be unique',
24
+ })
25
+ .refine((value) => value.values.length > 0 || value.customValue !== null, {
26
+ message: 'Select value must contain selected options or custom value',
27
+ });
28
+
29
+ export const PresetTextFieldValueSchema = z.object({
30
+ type: z.literal(PRESET_FIELD_TYPE.TEXT),
31
+ key: PresetFieldKeySchema,
32
+ text: z.string().trim().min(1),
33
+ });
34
+
35
+ export const PresetFieldValueSchema = z.discriminatedUnion('type', [
36
+ PresetFileFieldValueSchema,
37
+ PresetSelectFieldValueSchema,
38
+ PresetTextFieldValueSchema,
39
+ ]);
40
+
41
+ export const PresetFieldValuesSchema = z
42
+ .array(PresetFieldValueSchema)
43
+ .max(PRESET_MAX_FIELDS)
44
+ .refine((values) => new Set(values.map((value) => value.key)).size === values.length, {
45
+ message: 'Each field can have only one value',
46
+ });
47
+
48
+ export type PresetFileFieldValueSchemaType = z.infer<typeof PresetFileFieldValueSchema>;
49
+ export type PresetSelectFieldValueSchemaType = z.infer<typeof PresetSelectFieldValueSchema>;
50
+ export type PresetTextFieldValueSchemaType = z.infer<typeof PresetTextFieldValueSchema>;
51
+ export type PresetFieldValueSchemaType = z.infer<typeof PresetFieldValueSchema>;
@@ -0,0 +1,251 @@
1
+ import { z } from 'zod';
2
+ import {
3
+ PRESET_FIELD_HINT_MAX_LENGTH,
4
+ PRESET_FIELD_LABEL_MAX_LENGTH,
5
+ PRESET_FIELD_PROMPT_VALUE_MAX_LENGTH,
6
+ PRESET_FIELD_TYPE,
7
+ PRESET_MAX_FIELDS,
8
+ PRESET_MAX_REQUIRED_FIELDS,
9
+ PRESET_SELECT_CUSTOM_VALUE_DEFAULT_MAX_LENGTH,
10
+ PRESET_SELECT_CUSTOM_VALUE_MAX_LENGTH,
11
+ PRESET_SELECT_DISPLAY,
12
+ PRESET_SELECT_MAX_OPTIONS,
13
+ PRESET_SELECT_OPTION_VALUE_MAX_LENGTH,
14
+ PRESET_TEXT_FIELD_DEFAULT_MAX_LENGTH,
15
+ PRESET_TEXT_FIELD_MAX_LENGTH,
16
+ } from '../enums';
17
+ import { PresetFieldKeySchema, PresetFileSchema, PresetModelParamsSchema } from './preset-common.schema';
18
+
19
+ function hasUniqueItems(items: string[]): boolean {
20
+ return new Set(items).size === items.length;
21
+ }
22
+
23
+ export const PresetSelectDisplaySchema = z.enum(PRESET_SELECT_DISPLAY);
24
+
25
+ export const PresetFieldShowIfSchema = z.object({
26
+ key: PresetFieldKeySchema,
27
+ values: z.array(z.string().min(1)).min(1).refine(hasUniqueItems, { message: 'showIf values must be unique' }),
28
+ });
29
+
30
+ const PresetFieldBaseSchema = z.object({
31
+ key: PresetFieldKeySchema,
32
+ label: z.string().trim().min(1).max(PRESET_FIELD_LABEL_MAX_LENGTH),
33
+ required: z.boolean(),
34
+ showIf: PresetFieldShowIfSchema.nullable().default(null),
35
+ });
36
+
37
+ const PresetPromptValueSchema = z.string().trim().min(1).max(PRESET_FIELD_PROMPT_VALUE_MAX_LENGTH);
38
+
39
+ export const PresetFileFieldObjectSchema = PresetFieldBaseSchema.extend({
40
+ type: z.literal(PRESET_FIELD_TYPE.FILE),
41
+ slot: z.string().trim().min(1).nullable().default(null),
42
+ minCount: z.int().min(1).default(1),
43
+ maxCount: z.int().min(1),
44
+ hint: z.string().trim().min(1).max(PRESET_FIELD_HINT_MAX_LENGTH).nullable().default(null),
45
+ promptValue: PresetPromptValueSchema,
46
+ promptFallback: PresetPromptValueSchema.nullable().default(null),
47
+ });
48
+
49
+ export const PresetFileFieldSchema = PresetFileFieldObjectSchema.superRefine((field, ctx) => {
50
+ if (field.minCount > field.maxCount) {
51
+ ctx.addIssue({ code: 'custom', path: ['minCount'], message: 'minCount must not exceed maxCount' });
52
+ }
53
+
54
+ if (field.required && field.promptFallback !== null) {
55
+ ctx.addIssue({
56
+ code: 'custom',
57
+ path: ['promptFallback'],
58
+ message: 'promptFallback is allowed only for optional fields',
59
+ });
60
+ }
61
+ });
62
+
63
+ const PresetSelectOptionObjectSchema = z.object({
64
+ value: z.string().trim().min(1).max(PRESET_SELECT_OPTION_VALUE_MAX_LENGTH),
65
+ label: z.string().trim().min(1).max(PRESET_FIELD_LABEL_MAX_LENGTH),
66
+ promptValue: PresetPromptValueSchema.nullable().default(null),
67
+ params: PresetModelParamsSchema.nullable().default(null),
68
+ });
69
+
70
+ export const PresetSelectOptionSchema = PresetSelectOptionObjectSchema.extend({
71
+ previewFileId: z.uuid().nullable().default(null),
72
+ }).refine((option) => option.promptValue !== null || option.params !== null, {
73
+ message: 'Option must have promptValue or params',
74
+ });
75
+
76
+ export const PresetSelectOptionResponseSchema = PresetSelectOptionObjectSchema.extend({
77
+ previewFile: PresetFileSchema.nullable(),
78
+ });
79
+
80
+ function hasModelParams(option: PresetSelectOptionSchemaType): boolean {
81
+ return option.params !== null;
82
+ }
83
+
84
+ function hasPreview(option: PresetSelectOptionSchemaType): boolean {
85
+ return option.previewFileId !== null;
86
+ }
87
+
88
+ const PresetSelectFieldObjectSchema = PresetFieldBaseSchema.extend({
89
+ type: z.literal(PRESET_FIELD_TYPE.SELECT),
90
+ display: PresetSelectDisplaySchema.default(PRESET_SELECT_DISPLAY.CHIPS),
91
+ multiple: z.boolean().default(false),
92
+ defaultValues: z.array(z.string()).default([]),
93
+ allowCustom: z.boolean().default(false),
94
+ customMaxLength: z
95
+ .int()
96
+ .min(1)
97
+ .max(PRESET_SELECT_CUSTOM_VALUE_MAX_LENGTH)
98
+ .default(PRESET_SELECT_CUSTOM_VALUE_DEFAULT_MAX_LENGTH),
99
+ customPlaceholder: z.string().trim().min(1).max(PRESET_FIELD_HINT_MAX_LENGTH).nullable().default(null),
100
+ });
101
+
102
+ export const PresetSelectFieldSchema = PresetSelectFieldObjectSchema.extend({
103
+ options: z.array(PresetSelectOptionSchema).min(1).max(PRESET_SELECT_MAX_OPTIONS),
104
+ }).superRefine((field, ctx) => {
105
+ const optionValues = field.options.map((option) => option.value);
106
+
107
+ if (!hasUniqueItems(optionValues)) {
108
+ ctx.addIssue({ code: 'custom', path: ['options'], message: 'Option values must be unique' });
109
+ }
110
+
111
+ if (field.defaultValues.some((value) => !optionValues.includes(value))) {
112
+ ctx.addIssue({ code: 'custom', path: ['defaultValues'], message: 'Default values must be among options' });
113
+ }
114
+
115
+ if (!hasUniqueItems(field.defaultValues)) {
116
+ ctx.addIssue({ code: 'custom', path: ['defaultValues'], message: 'Default values must be unique' });
117
+ }
118
+
119
+ if (!field.multiple && field.defaultValues.length > 1) {
120
+ ctx.addIssue({
121
+ code: 'custom',
122
+ path: ['defaultValues'],
123
+ message: 'Single select can have at most one default value',
124
+ });
125
+ }
126
+
127
+ if (field.multiple && field.options.some(hasModelParams)) {
128
+ ctx.addIssue({
129
+ code: 'custom',
130
+ path: ['options'],
131
+ message: 'Options with model params are allowed only in single select',
132
+ });
133
+ }
134
+
135
+ if (field.allowCustom && field.options.some(hasModelParams)) {
136
+ ctx.addIssue({
137
+ code: 'custom',
138
+ path: ['allowCustom'],
139
+ message: 'Custom value is not allowed when options carry model params',
140
+ });
141
+ }
142
+
143
+ if (
144
+ field.display === PRESET_SELECT_DISPLAY.SWITCH &&
145
+ (field.options.length !== 2 || field.multiple || field.allowCustom)
146
+ ) {
147
+ ctx.addIssue({
148
+ code: 'custom',
149
+ path: ['display'],
150
+ message: 'Switch requires exactly two options, single select and no custom value',
151
+ });
152
+ }
153
+
154
+ if (field.display === PRESET_SELECT_DISPLAY.TILES && !field.options.every(hasPreview)) {
155
+ ctx.addIssue({ code: 'custom', path: ['options'], message: 'Tiles require previewFileId on every option' });
156
+ }
157
+ });
158
+
159
+ export const PresetSelectFieldResponseSchema = PresetSelectFieldObjectSchema.extend({
160
+ options: z.array(PresetSelectOptionResponseSchema),
161
+ });
162
+
163
+ export const PresetTextFieldObjectSchema = PresetFieldBaseSchema.extend({
164
+ type: z.literal(PRESET_FIELD_TYPE.TEXT),
165
+ placeholder: z.string().trim().min(1).max(PRESET_FIELD_HINT_MAX_LENGTH).nullable().default(null),
166
+ multiline: z.boolean().default(false),
167
+ maxLength: z.int().min(1).max(PRESET_TEXT_FIELD_MAX_LENGTH).default(PRESET_TEXT_FIELD_DEFAULT_MAX_LENGTH),
168
+ defaultValue: z.string().trim().min(1).nullable().default(null),
169
+ promptFallback: PresetPromptValueSchema.nullable().default(null),
170
+ });
171
+
172
+ export const PresetTextFieldSchema = PresetTextFieldObjectSchema.refine(
173
+ (field) => field.defaultValue === null || field.defaultValue.length <= field.maxLength,
174
+ { path: ['defaultValue'], message: 'Default value must not exceed maxLength' },
175
+ );
176
+
177
+ export const PresetFieldSchema = z.discriminatedUnion('type', [
178
+ PresetFileFieldSchema,
179
+ PresetSelectFieldSchema,
180
+ PresetTextFieldSchema,
181
+ ]);
182
+
183
+ export const PresetFieldResponseSchema = z.discriminatedUnion('type', [
184
+ PresetFileFieldObjectSchema,
185
+ PresetSelectFieldResponseSchema,
186
+ PresetTextFieldObjectSchema,
187
+ ]);
188
+
189
+ function isRequired(field: PresetFieldSchemaType): boolean {
190
+ return field.required;
191
+ }
192
+
193
+ function findShowIfIssue(field: PresetFieldSchemaType, fieldsAbove: PresetFieldSchemaType[]): string | null {
194
+ const showIf = field.showIf;
195
+ if (showIf === null) {
196
+ return null;
197
+ }
198
+
199
+ const target = fieldsAbove.find((fieldAbove) => fieldAbove.key === showIf.key);
200
+ if (target === undefined || target.type !== PRESET_FIELD_TYPE.SELECT) {
201
+ return `showIf must reference a select field placed above: ${showIf.key}`;
202
+ }
203
+
204
+ const optionValues = target.options.map((option) => option.value);
205
+ const unknownValues = showIf.values.filter((value) => !optionValues.includes(value));
206
+ if (unknownValues.length > 0) {
207
+ return `showIf values are not options of ${showIf.key}: ${unknownValues.join(', ')}`;
208
+ }
209
+
210
+ return null;
211
+ }
212
+
213
+ export const PresetFieldsSchema = z
214
+ .array(PresetFieldSchema)
215
+ .max(PRESET_MAX_FIELDS)
216
+ .superRefine((fields, ctx) => {
217
+ if (!hasUniqueItems(fields.map((field) => field.key))) {
218
+ ctx.addIssue({ code: 'custom', message: 'Field keys must be unique' });
219
+ }
220
+
221
+ if (fields.filter(isRequired).length > PRESET_MAX_REQUIRED_FIELDS) {
222
+ ctx.addIssue({
223
+ code: 'custom',
224
+ message: `Preset can have at most ${PRESET_MAX_REQUIRED_FIELDS} required fields`,
225
+ });
226
+ }
227
+
228
+ fields.forEach((field, index) => {
229
+ const issue = findShowIfIssue(field, fields.slice(0, index));
230
+ if (issue !== null) {
231
+ ctx.addIssue({ code: 'custom', path: [index, 'showIf'], message: issue });
232
+ }
233
+ });
234
+ });
235
+
236
+ export const PresetRequireOneOfSchema = z
237
+ .array(z.array(PresetFieldKeySchema).min(2).refine(hasUniqueItems, { message: 'Keys in a group must be unique' }))
238
+ .max(PRESET_MAX_FIELDS)
239
+ .default([]);
240
+
241
+ export type PresetFieldShowIfSchemaType = z.infer<typeof PresetFieldShowIfSchema>;
242
+ export type PresetFileFieldSchemaType = z.infer<typeof PresetFileFieldSchema>;
243
+ export type PresetSelectOptionSchemaType = z.infer<typeof PresetSelectOptionSchema>;
244
+ export type PresetSelectOptionResponseSchemaType = z.infer<typeof PresetSelectOptionResponseSchema>;
245
+ export type PresetSelectFieldSchemaType = z.infer<typeof PresetSelectFieldSchema>;
246
+ export type PresetSelectFieldResponseSchemaType = z.infer<typeof PresetSelectFieldResponseSchema>;
247
+ export type PresetTextFieldSchemaType = z.infer<typeof PresetTextFieldSchema>;
248
+ export type PresetFieldSchemaType = z.infer<typeof PresetFieldSchema>;
249
+ export type PresetFieldResponseSchemaType = z.infer<typeof PresetFieldResponseSchema>;
250
+ export type PresetFieldsSchemaType = z.infer<typeof PresetFieldsSchema>;
251
+ export type PresetRequireOneOfSchemaType = z.infer<typeof PresetRequireOneOfSchema>;