@purpleschool/multisite 0.0.27 → 0.0.29

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 (222) hide show
  1. package/build/api/controller/http/ai-proxy.d.ts +3 -3
  2. package/build/api/controller/http/ai-proxy.d.ts.map +1 -1
  3. package/build/api/controller/http/auth.d.ts +12 -12
  4. package/build/api/controller/http/auth.d.ts.map +1 -1
  5. package/build/api/controller/http/cloud-payments.d.ts +2 -2
  6. package/build/api/controller/http/cloud-payments.d.ts.map +1 -1
  7. package/build/api/controller/http/file.d.ts +5 -5
  8. package/build/api/controller/http/file.d.ts.map +1 -1
  9. package/build/api/controller/http/health.d.ts +1 -1
  10. package/build/api/controller/http/health.d.ts.map +1 -1
  11. package/build/api/controller/http/image-editor.d.ts +6 -6
  12. package/build/api/controller/http/image-editor.d.ts.map +1 -1
  13. package/build/api/controller/http/image-generation.d.ts +6 -6
  14. package/build/api/controller/http/image-generation.d.ts.map +1 -1
  15. package/build/api/controller/http/marketplace-card.d.ts +7 -7
  16. package/build/api/controller/http/marketplace-card.d.ts.map +1 -1
  17. package/build/api/controller/http/page-question.d.ts +3 -3
  18. package/build/api/controller/http/page-question.d.ts.map +1 -1
  19. package/build/api/controller/http/page.d.ts +4 -4
  20. package/build/api/controller/http/page.d.ts.map +1 -1
  21. package/build/api/controller/http/payment.d.ts +3 -3
  22. package/build/api/controller/http/payment.d.ts.map +1 -1
  23. package/build/api/controller/http/product.d.ts +6 -6
  24. package/build/api/controller/http/product.d.ts.map +1 -1
  25. package/build/api/controller/http/sitemap.d.ts +2 -2
  26. package/build/api/controller/http/sitemap.d.ts.map +1 -1
  27. package/build/api/controller/http/stt.d.ts +6 -6
  28. package/build/api/controller/http/stt.d.ts.map +1 -1
  29. package/build/api/controller/http/subscription.d.ts +7 -7
  30. package/build/api/controller/http/subscription.d.ts.map +1 -1
  31. package/build/api/controller/http/transaction.d.ts +2 -2
  32. package/build/api/controller/http/transaction.d.ts.map +1 -1
  33. package/build/api/controller/http/tts.d.ts +6 -6
  34. package/build/api/controller/http/tts.d.ts.map +1 -1
  35. package/build/api/controller/http/unregistered-user.d.ts +2 -2
  36. package/build/api/controller/http/unregistered-user.d.ts.map +1 -1
  37. package/build/api/controller/http/user-to-product.d.ts +1 -1
  38. package/build/api/controller/http/user-to-product.d.ts.map +1 -1
  39. package/build/api/controller/http/user-to-subscription.d.ts +1 -1
  40. package/build/api/controller/http/user-to-subscription.d.ts.map +1 -1
  41. package/build/api/controller/http/user.d.ts +5 -5
  42. package/build/api/controller/http/user.d.ts.map +1 -1
  43. package/build/api/routes.d.ts +1 -1
  44. package/build/api/routes.d.ts.map +1 -1
  45. package/build/commands/auth/register.command.d.ts +1 -1
  46. package/build/commands/auth/reset-password.command.d.ts +2 -2
  47. package/build/commands/auth/verify-email.command.d.ts +2 -2
  48. package/build/commands/auth/vk-login.command.d.ts +2 -2
  49. package/build/commands/auth/yandex-login.command.d.ts +2 -2
  50. package/build/commands/file/upload-file.command.d.ts +8 -8
  51. package/build/commands/image-editor/execute-image-editor.command.d.ts +100 -88
  52. package/build/commands/image-editor/execute-image-editor.command.d.ts.map +1 -1
  53. package/build/commands/image-editor/proxy-image-editor-callback.command.d.ts +2 -2
  54. package/build/commands/image-editor/proxy-image-editor-callback.command.js +1 -1
  55. package/build/commands/image-editor/retry-image-editor-job.command.d.ts +101 -89
  56. package/build/commands/image-editor/retry-image-editor-job.command.d.ts.map +1 -1
  57. package/build/commands/image-editor/set-reaction-to-image-editor-job.command.d.ts +85 -78
  58. package/build/commands/image-editor/set-reaction-to-image-editor-job.command.d.ts.map +1 -1
  59. package/build/commands/image-editor/update-image-editor-job-title.command.d.ts +85 -78
  60. package/build/commands/image-editor/update-image-editor-job-title.command.d.ts.map +1 -1
  61. package/build/commands/image-generation/execute-image-generation.command.d.ts +71 -71
  62. package/build/commands/image-generation/proxy-image-generation-callback.command.d.ts +4 -4
  63. package/build/commands/image-generation/retry-image-generation-job.command.d.ts +72 -72
  64. package/build/commands/image-generation/set-reaction-to-image-generation-job.command.d.ts +65 -65
  65. package/build/commands/image-generation/update-image-generation-job-title.command.d.ts +65 -65
  66. package/build/commands/marketplace-card/execute-marketplace-card.command.d.ts +20 -20
  67. package/build/commands/marketplace-card/retry-marketplace-card-job.command.d.ts +16 -16
  68. package/build/commands/marketplace-card/set-reaction-to-marketplace-card-job.command.d.ts +16 -16
  69. package/build/commands/marketplace-card/update-marketplace-card-job-title.command.d.ts +16 -16
  70. package/build/commands/page/create-page-question.command.d.ts +9 -9
  71. package/build/commands/page/create-page.command.d.ts +15 -15
  72. package/build/commands/page/find-page-by-alias.command.d.ts +72 -72
  73. package/build/commands/page/find-page-by-criteria.command.d.ts +28 -28
  74. package/build/commands/page/find-page.command.d.ts +48 -48
  75. package/build/commands/page/update-page-question.command.d.ts +9 -9
  76. package/build/commands/page/update-page.command.d.ts +15 -15
  77. package/build/commands/payment/cloud-payments.command.d.ts +18 -18
  78. package/build/commands/product/buy-product.command.d.ts +80 -80
  79. package/build/commands/product/fast-buy-product.command.d.ts +81 -81
  80. package/build/commands/product/update-product.command.d.ts +6 -6
  81. package/build/commands/stt/execute-stt.command.d.ts +81 -81
  82. package/build/commands/stt/retry-stt-job.command.d.ts +79 -79
  83. package/build/commands/stt/set-reaction-to-stt-job.command.d.ts +79 -79
  84. package/build/commands/stt/update-stt-job-title.command.d.ts +79 -79
  85. package/build/commands/subscription/buy-subscription.command.d.ts +80 -80
  86. package/build/commands/subscription/fast-buy-subscription.command.d.ts +81 -81
  87. package/build/commands/subscription/update-subscription.command.d.ts +24 -24
  88. package/build/commands/transaction/write-off.command.d.ts +5 -5
  89. package/build/commands/tts/execute-tts.command.d.ts +99 -99
  90. package/build/commands/tts/retry-tts-job.command.d.ts +92 -92
  91. package/build/commands/tts/set-reaction-to-tts-job.command.d.ts +92 -92
  92. package/build/commands/tts/update-tts-job-title.command.d.ts +92 -92
  93. package/build/commands/unregistered-user/upsert-unregistered-user.command.d.ts +4 -4
  94. package/build/commands/user-to-product/get-user-to-product-by-uuid.command.d.ts +4 -4
  95. package/build/commands/user-to-product/update-user-to-product.command.d.ts +7 -7
  96. package/build/commands/user-to-subscription/get-user-to-subscription-by-uuid.command.d.ts +28 -28
  97. package/build/commands/user-to-subscription/update-user-to-subscription.command.d.ts +36 -36
  98. package/build/constants/email/email-endpoint.d.ts +1 -1
  99. package/build/constants/email/email-endpoint.d.ts.map +1 -1
  100. package/build/constants/email/email-endpoint.js +1 -1
  101. package/build/constants/email/subjects.d.ts +10 -10
  102. package/build/constants/email/subjects.d.ts.map +1 -1
  103. package/build/constants/errors/errors.d.ts +338 -328
  104. package/build/constants/errors/errors.d.ts.map +1 -1
  105. package/build/constants/errors/errors.js +10 -0
  106. package/build/constants/image-editor/enums/image-editing-strategy.enum.d.ts +2 -1
  107. package/build/constants/image-editor/enums/image-editing-strategy.enum.d.ts.map +1 -1
  108. package/build/constants/image-editor/enums/image-editing-strategy.enum.js +1 -0
  109. package/build/constants/subscription/free-subscription-id.constant.d.ts +1 -1
  110. package/build/helpers/image-generation/calculate-image-generation-price.helper.d.ts +4 -2
  111. package/build/helpers/image-generation/calculate-image-generation-price.helper.d.ts.map +1 -1
  112. package/build/helpers/index.d.ts +1 -0
  113. package/build/helpers/index.d.ts.map +1 -1
  114. package/build/helpers/index.js +1 -0
  115. package/build/helpers/openai-image-2/calculate-openai-image-2-price.helper.d.ts +20 -0
  116. package/build/helpers/openai-image-2/calculate-openai-image-2-price.helper.d.ts.map +1 -0
  117. package/build/helpers/openai-image-2/calculate-openai-image-2-price.helper.js +125 -0
  118. package/build/helpers/openai-image-2/index.d.ts +2 -0
  119. package/build/helpers/openai-image-2/index.d.ts.map +1 -0
  120. package/build/helpers/openai-image-2/index.js +17 -0
  121. package/build/models/cloud-payments-widget-data.schema.d.ts +58 -58
  122. package/build/models/cloud-payments-widget.schema.d.ts +62 -62
  123. package/build/models/common/attached-file.schema.d.ts +4 -4
  124. package/build/models/common/receipt.schema.d.ts +8 -8
  125. package/build/models/file.schema.d.ts +4 -4
  126. package/build/models/image-editor/image-editor-config.schema.d.ts +153 -128
  127. package/build/models/image-editor/image-editor-config.schema.d.ts.map +1 -1
  128. package/build/models/image-editor/image-editor-job-params.schema.d.ts +13 -10
  129. package/build/models/image-editor/image-editor-job-params.schema.d.ts.map +1 -1
  130. package/build/models/image-editor/image-editor-job-params.schema.js +1 -0
  131. package/build/models/image-editor/image-editor-job-request-params.schema.d.ts +7 -4
  132. package/build/models/image-editor/image-editor-job-request-params.schema.d.ts.map +1 -1
  133. package/build/models/image-editor/image-editor-job-request-params.schema.js +2 -1
  134. package/build/models/image-editor/image-editor-job.schema.d.ts +49 -44
  135. package/build/models/image-editor/image-editor-job.schema.d.ts.map +1 -1
  136. package/build/models/image-editor/image-editor-model-params.schema.d.ts +18 -5
  137. package/build/models/image-editor/image-editor-model-params.schema.d.ts.map +1 -1
  138. package/build/models/image-editor/image-editor-model-params.schema.js +5 -0
  139. package/build/models/image-editor/image-editor-model.schema.d.ts +63 -44
  140. package/build/models/image-editor/image-editor-model.schema.d.ts.map +1 -1
  141. package/build/models/image-editor/image-editor-pricing-rule.schema.d.ts +2 -2
  142. package/build/models/image-editor/image-editor-prompt-group.schema.d.ts +26 -26
  143. package/build/models/image-editor/image-editor-system-prompt.schema.d.ts +12 -12
  144. package/build/models/image-generation/image-generation-config.schema.d.ts +122 -122
  145. package/build/models/image-generation/image-generation-job-attempt.schema.d.ts +2 -2
  146. package/build/models/image-generation/image-generation-job-params.schema.d.ts +9 -9
  147. package/build/models/image-generation/image-generation-job-request-params.schema.d.ts +1 -1
  148. package/build/models/image-generation/image-generation-job.schema.d.ts +38 -38
  149. package/build/models/image-generation/image-generation-model-params.schema.d.ts +4 -4
  150. package/build/models/image-generation/image-generation-model.schema.d.ts +42 -42
  151. package/build/models/image-generation/image-generation-preset.schema.d.ts +2 -2
  152. package/build/models/image-generation/image-generation-pricing-rule.schema.d.ts +4 -4
  153. package/build/models/image-generation/image-generation-vendor.schema.d.ts +80 -80
  154. package/build/models/marketplace-card/marketplace-card-config.schema.d.ts +18 -18
  155. package/build/models/marketplace-card/marketplace-card-job-request-params.schema.d.ts +4 -4
  156. package/build/models/marketplace-card/marketplace-card-job.schema.d.ts +8 -8
  157. package/build/models/marketplace-card/marketplace-card-model.schema.d.ts +4 -4
  158. package/build/models/marketplace-card/marketplace-card-style-preset.schema.d.ts +2 -2
  159. package/build/models/page-question.schema.d.ts +4 -4
  160. package/build/models/page.schema.d.ts +20 -20
  161. package/build/models/product.schema.d.ts +2 -2
  162. package/build/models/stt/stt-config.schema.d.ts +28 -28
  163. package/build/models/stt/stt-job-attempt.schema.d.ts +4 -4
  164. package/build/models/stt/stt-job.schema.d.ts +42 -42
  165. package/build/models/stt/stt-model.schema.d.ts +14 -14
  166. package/build/models/stt/stt-response.schema.d.ts +1 -1
  167. package/build/models/subscription.schema.d.ts +8 -8
  168. package/build/models/tools/vendor.schema.d.ts +2 -2
  169. package/build/models/tts/tts-config.schema.d.ts +184 -184
  170. package/build/models/tts/tts-job-attempt.schema.d.ts +4 -4
  171. package/build/models/tts/tts-job-params.schema.d.ts +2 -2
  172. package/build/models/tts/tts-job.schema.d.ts +50 -50
  173. package/build/models/tts/tts-model.schema.d.ts +196 -196
  174. package/build/models/unlocked-by-subscription.schema.d.ts.map +1 -1
  175. package/build/models/user-to-product.schema.d.ts +2 -2
  176. package/build/models/user-to-subscription.schema.d.ts +14 -14
  177. package/build/models/user.schema.d.ts +4 -4
  178. package/build/queries/file/find-files.command.d.ts +8 -8
  179. package/build/queries/file/get-file.command.d.ts +8 -8
  180. package/build/queries/image-editor/find-image-editor-jobs.command.d.ts +86 -79
  181. package/build/queries/image-editor/find-image-editor-jobs.command.d.ts.map +1 -1
  182. package/build/queries/image-editor/get-image-editor-config.command.d.ts +217 -186
  183. package/build/queries/image-editor/get-image-editor-config.command.d.ts.map +1 -1
  184. package/build/queries/image-editor/get-image-editor-job.command.d.ts +85 -78
  185. package/build/queries/image-editor/get-image-editor-job.command.d.ts.map +1 -1
  186. package/build/queries/image-generation/find-image-generation-jobs.command.d.ts +66 -66
  187. package/build/queries/image-generation/get-image-generation-config.command.d.ts +162 -162
  188. package/build/queries/image-generation/get-image-generation-job.command.d.ts +65 -65
  189. package/build/queries/marketplace-card/find-marketplace-card-jobs.command.d.ts +17 -17
  190. package/build/queries/marketplace-card/get-marketplace-card-config.command.d.ts +30 -30
  191. package/build/queries/marketplace-card/get-marketplace-card-job.command.d.ts +16 -16
  192. package/build/queries/page/find-all-page-questions.query.d.ts +8 -8
  193. package/build/queries/page/find-page-question-by-uuid.query.d.ts +8 -8
  194. package/build/queries/page/find-page-questions-by-page-id.query.d.ts +8 -8
  195. package/build/queries/payment/get-payment-history.command.d.ts +12 -12
  196. package/build/queries/product/find-products.command.d.ts +4 -4
  197. package/build/queries/stt/find-stt-jobs.command.d.ts +79 -79
  198. package/build/queries/stt/get-stt-config.command.d.ts +42 -42
  199. package/build/queries/stt/get-stt-job.command.d.ts +79 -79
  200. package/build/queries/subscription/find-subscriptions.command.d.ts +16 -16
  201. package/build/queries/subscription/get-subscriptions-summary.command.d.ts +51 -51
  202. package/build/queries/tts/find-tts-jobs.command.d.ts +94 -94
  203. package/build/queries/tts/get-tts-config.command.d.ts +242 -242
  204. package/build/queries/tts/get-tts-job.command.d.ts +92 -92
  205. package/build/queries/user/find-users.command.d.ts +16 -16
  206. package/build/queries/user/get-all-users.command.d.ts +8 -8
  207. package/build/queries/user/get-my-products.command.d.ts +10 -10
  208. package/build/queries/user/get-my-subscriptions.command.d.ts +36 -36
  209. package/build/queries/user/get-user-payments.command.d.ts +42 -42
  210. package/build/queries/user/get-user.command.d.ts +8 -8
  211. package/commands/image-editor/proxy-image-editor-callback.command.ts +1 -1
  212. package/constants/email/email-endpoint.ts +1 -1
  213. package/constants/errors/errors.ts +10 -0
  214. package/constants/image-editor/enums/image-editing-strategy.enum.ts +1 -0
  215. package/helpers/image-generation/calculate-image-generation-price.helper.ts +4 -2
  216. package/helpers/index.ts +1 -0
  217. package/helpers/openai-image-2/calculate-openai-image-2-price.helper.ts +160 -0
  218. package/helpers/openai-image-2/index.ts +1 -0
  219. package/models/image-editor/image-editor-job-params.schema.ts +1 -0
  220. package/models/image-editor/image-editor-job-request-params.schema.ts +2 -1
  221. package/models/image-editor/image-editor-model-params.schema.ts +5 -0
  222. package/package.json +1 -1
@@ -18,34 +18,34 @@ export declare namespace GetUserPaymentsCommand {
18
18
  updatedAt: z.ZodUnion<[z.ZodDate, z.ZodString]>;
19
19
  }, "strip", z.ZodTypeAny, {
20
20
  uuid: string;
21
- description: string;
22
- userId: string;
23
- productId: string | null;
24
- updatedAt: string | Date;
25
- subscriptionId: string | null;
26
- currency: string;
27
- sum: number;
28
21
  orderType: ORDER_TYPE;
29
22
  orderStatus: ORDER_STATUS;
23
+ description: string;
24
+ productId: string | null;
30
25
  productName: string | null;
26
+ subscriptionId: string | null;
31
27
  subscriptionName: string | null;
32
28
  paymentStatus: PAYMENT_STATUS;
29
+ userId: string;
33
30
  userEmail: string;
31
+ sum: number;
32
+ currency: string;
33
+ updatedAt: string | Date;
34
34
  }, {
35
35
  uuid: string;
36
- description: string;
37
- userId: string;
38
- productId: string | null;
39
- updatedAt: string | Date;
40
- subscriptionId: string | null;
41
- currency: string;
42
- sum: number;
43
36
  orderType: ORDER_TYPE;
44
37
  orderStatus: ORDER_STATUS;
38
+ description: string;
39
+ productId: string | null;
45
40
  productName: string | null;
41
+ subscriptionId: string | null;
46
42
  subscriptionName: string | null;
47
43
  paymentStatus: PAYMENT_STATUS;
44
+ userId: string;
48
45
  userEmail: string;
46
+ sum: number;
47
+ currency: string;
48
+ updatedAt: string | Date;
49
49
  }>;
50
50
  const ResponseSchema: z.ZodObject<{
51
51
  data: z.ZodArray<z.ZodObject<{
@@ -65,68 +65,68 @@ export declare namespace GetUserPaymentsCommand {
65
65
  updatedAt: z.ZodUnion<[z.ZodDate, z.ZodString]>;
66
66
  }, "strip", z.ZodTypeAny, {
67
67
  uuid: string;
68
- description: string;
69
- userId: string;
70
- productId: string | null;
71
- updatedAt: string | Date;
72
- subscriptionId: string | null;
73
- currency: string;
74
- sum: number;
75
68
  orderType: ORDER_TYPE;
76
69
  orderStatus: ORDER_STATUS;
70
+ description: string;
71
+ productId: string | null;
77
72
  productName: string | null;
73
+ subscriptionId: string | null;
78
74
  subscriptionName: string | null;
79
75
  paymentStatus: PAYMENT_STATUS;
76
+ userId: string;
80
77
  userEmail: string;
78
+ sum: number;
79
+ currency: string;
80
+ updatedAt: string | Date;
81
81
  }, {
82
82
  uuid: string;
83
- description: string;
84
- userId: string;
85
- productId: string | null;
86
- updatedAt: string | Date;
87
- subscriptionId: string | null;
88
- currency: string;
89
- sum: number;
90
83
  orderType: ORDER_TYPE;
91
84
  orderStatus: ORDER_STATUS;
85
+ description: string;
86
+ productId: string | null;
92
87
  productName: string | null;
88
+ subscriptionId: string | null;
93
89
  subscriptionName: string | null;
94
90
  paymentStatus: PAYMENT_STATUS;
91
+ userId: string;
95
92
  userEmail: string;
93
+ sum: number;
94
+ currency: string;
95
+ updatedAt: string | Date;
96
96
  }>, "many">;
97
97
  }, "strip", z.ZodTypeAny, {
98
98
  data: {
99
99
  uuid: string;
100
- description: string;
101
- userId: string;
102
- productId: string | null;
103
- updatedAt: string | Date;
104
- subscriptionId: string | null;
105
- currency: string;
106
- sum: number;
107
100
  orderType: ORDER_TYPE;
108
101
  orderStatus: ORDER_STATUS;
102
+ description: string;
103
+ productId: string | null;
109
104
  productName: string | null;
105
+ subscriptionId: string | null;
110
106
  subscriptionName: string | null;
111
107
  paymentStatus: PAYMENT_STATUS;
108
+ userId: string;
112
109
  userEmail: string;
110
+ sum: number;
111
+ currency: string;
112
+ updatedAt: string | Date;
113
113
  }[];
114
114
  }, {
115
115
  data: {
116
116
  uuid: string;
117
- description: string;
118
- userId: string;
119
- productId: string | null;
120
- updatedAt: string | Date;
121
- subscriptionId: string | null;
122
- currency: string;
123
- sum: number;
124
117
  orderType: ORDER_TYPE;
125
118
  orderStatus: ORDER_STATUS;
119
+ description: string;
120
+ productId: string | null;
126
121
  productName: string | null;
122
+ subscriptionId: string | null;
127
123
  subscriptionName: string | null;
128
124
  paymentStatus: PAYMENT_STATUS;
125
+ userId: string;
129
126
  userEmail: string;
127
+ sum: number;
128
+ currency: string;
129
+ updatedAt: string | Date;
130
130
  }[];
131
131
  }>;
132
132
  type Response = z.infer<typeof ResponseSchema>;
@@ -10,36 +10,36 @@ export declare namespace GetUserCommand {
10
10
  siteId: z.ZodString;
11
11
  tokenBonusBalance: z.ZodNumber;
12
12
  }, "strip", z.ZodTypeAny, {
13
- email: string;
14
13
  uuid: string;
15
- siteId: string;
14
+ email: string;
16
15
  role: USER_ROLE;
17
16
  status: USER_STATUS;
17
+ siteId: string;
18
18
  tokenBonusBalance: number;
19
19
  }, {
20
- email: string;
21
20
  uuid: string;
22
- siteId: string;
21
+ email: string;
23
22
  role: USER_ROLE;
24
23
  status: USER_STATUS;
24
+ siteId: string;
25
25
  tokenBonusBalance: number;
26
26
  }>;
27
27
  }, "strip", z.ZodTypeAny, {
28
28
  data: {
29
- email: string;
30
29
  uuid: string;
31
- siteId: string;
30
+ email: string;
32
31
  role: USER_ROLE;
33
32
  status: USER_STATUS;
33
+ siteId: string;
34
34
  tokenBonusBalance: number;
35
35
  };
36
36
  }, {
37
37
  data: {
38
- email: string;
39
38
  uuid: string;
40
- siteId: string;
39
+ email: string;
41
40
  role: USER_ROLE;
42
41
  status: USER_STATUS;
42
+ siteId: string;
43
43
  tokenBonusBalance: number;
44
44
  };
45
45
  }>;
@@ -3,7 +3,7 @@ import { z } from 'zod';
3
3
  export namespace ProxyImageEditorCallbackCommand {
4
4
  export const RequestSchema = z.object({
5
5
  jobId: z.string().min(1),
6
- imageUrl: z.string().url().optional(),
6
+ imageUrl: z.string().min(1).optional(),
7
7
  error: z.string().optional(),
8
8
  });
9
9
  export type Request = z.infer<typeof RequestSchema>;
@@ -1 +1 @@
1
- export const EmailEndpoint = 'https://api.rusender.ru/v1/email/send';
1
+ export const EmailEndpoint = 'https://api.rusender.ru/api/v1/external-mails/send';
@@ -21,6 +21,11 @@ export const ERRORS = {
21
21
  code: 'TENANT_003',
22
22
  httpCode: 500,
23
23
  },
24
+ TOOL_NOT_AVAILABLE_FOR_SITE: {
25
+ message: 'Инструмент недоступен для сайта',
26
+ code: 'TOOL_001',
27
+ httpCode: 403,
28
+ },
24
29
 
25
30
  // AUTH
26
31
  AUTH_REGISTER_CONFLICT: {
@@ -536,6 +541,11 @@ export const ERRORS = {
536
541
  code: 'IMAGE_EDITOR_009',
537
542
  httpCode: 403,
538
543
  },
544
+ IMAGE_EDITOR_IMAGE_REQUIRED: {
545
+ message: 'Для редактирования изображения необходимо прикрепить хотя бы одно изображение',
546
+ code: 'IMAGE_EDITOR_015',
547
+ httpCode: 400,
548
+ },
539
549
  IMAGE_EDITOR_NOT_ENOUGH_TOKENS: {
540
550
  message: 'Недостаточно токенов',
541
551
  code: 'IMAGE_EDITOR_003',
@@ -6,4 +6,5 @@ export enum IMAGE_EDITING_STRATEGY {
6
6
  NANO_BANANA_PRO_CALLBACK = 'NANO_BANANA_PRO_CALLBACK',
7
7
  NANO_BANANA_PRO_POLLING = 'NANO_BANANA_PRO_POLLING',
8
8
  SEEDREAM_EDITING_CALLBACK = 'SEEDREAM_EDITING_CALLBACK',
9
+ OPENAI_IMAGE_2_CALLBACK = 'OPENAI_IMAGE_2_CALLBACK',
9
10
  }
@@ -1,4 +1,4 @@
1
- import { ImageGenerationJobParams, ImageGenerationPricingRules } from '../../models';
1
+ import { ImageGenerationPricingRules } from '../../models';
2
2
 
3
3
  export function calculateImageGenerationPrice({
4
4
  basePrice,
@@ -7,7 +7,9 @@ export function calculateImageGenerationPrice({
7
7
  rules,
8
8
  }: {
9
9
  basePrice: number;
10
- params: Pick<ImageGenerationJobParams, 'resolution'>;
10
+ params: {
11
+ resolution?: string;
12
+ };
11
13
  userHasActiveSubscriptionOrProduct: boolean;
12
14
  rules: ImageGenerationPricingRules;
13
15
  }): number {
package/helpers/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './image-generation';
2
2
  export * from './image-editor';
3
+ export * from './openai-image-2';
@@ -0,0 +1,160 @@
1
+ type Image2Quality = 'low' | 'medium' | 'high';
2
+ type Image2Resolution = '1K' | '2K' | '4K';
3
+ type Image2Size = { width: number; height: number };
4
+
5
+ export type OpenAIImage2PricedModel = {
6
+ aiModel: string;
7
+ params?: {
8
+ quality?: unknown;
9
+ aspectRatio?: Partial<Record<string, Image2Size | 'auto'>>;
10
+ };
11
+ };
12
+
13
+ const LOW_QUALITY_SURCHARGE_STARS = 2;
14
+ const OPENAI_OUTPUT_PRICE_PER_1M_USD = 30;
15
+ const STAR_PRICE_USD = 0.018;
16
+ const TARGET_MARGIN = 0.6;
17
+ const IMAGE_2_INPUT_IMAGE_SURCHARGE_STARS = 2;
18
+
19
+ const IMAGE_2_QUALITY_BASE_TOKENS: Record<Image2Quality, number> = {
20
+ low: 16,
21
+ medium: 48,
22
+ high: 96,
23
+ };
24
+
25
+ const IMAGE_2_RESOLUTION_MULTIPLIER: Record<Image2Resolution, number> = {
26
+ '1K': 1,
27
+ '2K': 2,
28
+ '4K': 4,
29
+ };
30
+
31
+ const IMAGE_2_MAX_EDGE = 3840;
32
+ const IMAGE_2_MAX_PIXEL_BUDGET = 8_294_400;
33
+ const IMAGE_2_SIZE_STEP = 16;
34
+
35
+ export function isOpenAIImage2Model(model: Pick<OpenAIImage2PricedModel, 'aiModel'>): boolean {
36
+ return model.aiModel.toLowerCase().startsWith('gpt-image-2');
37
+ }
38
+
39
+ export function calculateOpenAIImage2InternalPrice(params: {
40
+ model: OpenAIImage2PricedModel;
41
+ aspectRatio: string;
42
+ resolution?: string;
43
+ hasAttachedImage?: boolean;
44
+ }): number | null {
45
+ const { model, aspectRatio, resolution, hasAttachedImage = false } = params;
46
+
47
+ const quality = resolveQuality(model.aiModel, model.params?.quality);
48
+ const normalizedResolution = normalizeResolution(resolution);
49
+ const baseSize = model.params?.aspectRatio?.[aspectRatio];
50
+ if (!quality || !isImage2Size(baseSize) || !normalizedResolution) {
51
+ return null;
52
+ }
53
+
54
+ const multiplier = IMAGE_2_RESOLUTION_MULTIPLIER[normalizedResolution];
55
+ const normalizedSize = normalizeImage2SizeToOpenAILimits({
56
+ width: Math.round(baseSize.width * multiplier),
57
+ height: Math.round(baseSize.height * multiplier),
58
+ });
59
+ const outputTokens = calculateImage2OutputTokens({
60
+ quality,
61
+ ...normalizedSize,
62
+ });
63
+
64
+ const costUsd = (outputTokens / 1_000_000) * OPENAI_OUTPUT_PRICE_PER_1M_USD;
65
+ const sellUsd = costUsd / (1 - TARGET_MARGIN);
66
+
67
+ let finalStars = Math.max(1, Math.ceil(sellUsd / STAR_PRICE_USD));
68
+ if (hasAttachedImage) {
69
+ finalStars += IMAGE_2_INPUT_IMAGE_SURCHARGE_STARS;
70
+ }
71
+
72
+ if (quality === 'low') {
73
+ finalStars += LOW_QUALITY_SURCHARGE_STARS;
74
+ }
75
+
76
+ return finalStars;
77
+ }
78
+
79
+ function isImage2Size(value: unknown): value is Image2Size {
80
+ if (!value || typeof value !== 'object') return false;
81
+ const candidate = value as Partial<Image2Size>;
82
+ return typeof candidate.width === 'number' && typeof candidate.height === 'number';
83
+ }
84
+
85
+ function resolveQuality(aiModel: string, rawQuality: unknown): Image2Quality | null {
86
+ const normalizedModel = aiModel.toLowerCase();
87
+ if (normalizedModel.endsWith('-low')) return 'low';
88
+ if (normalizedModel.endsWith('-medium')) return 'medium';
89
+ if (normalizedModel.endsWith('-high')) return 'high';
90
+
91
+ if (typeof rawQuality === 'string') {
92
+ return normalizeQuality(rawQuality);
93
+ }
94
+
95
+ if (rawQuality && typeof rawQuality === 'object') {
96
+ const values = Object.values(rawQuality as Record<string, unknown>);
97
+ for (const value of values) {
98
+ if (typeof value !== 'string') continue;
99
+ const normalized = normalizeQuality(value);
100
+ if (normalized) return normalized;
101
+ }
102
+ }
103
+
104
+ return null;
105
+ }
106
+
107
+ function normalizeQuality(value: string): Image2Quality | null {
108
+ const normalized = value.trim().toLowerCase();
109
+ if (normalized === 'low') return 'low';
110
+ if (normalized === 'medium') return 'medium';
111
+ if (normalized === 'high') return 'high';
112
+ return null;
113
+ }
114
+
115
+ function normalizeResolution(value?: string): Image2Resolution | null {
116
+ if (!value) return '1K';
117
+ if (value === '1K' || value === '2K' || value === '4K') {
118
+ return value;
119
+ }
120
+ return null;
121
+ }
122
+
123
+ function normalizeImage2SizeToOpenAILimits(size: Image2Size): Image2Size {
124
+ let scale = 1;
125
+ const longestEdge = Math.max(size.width, size.height);
126
+ if (longestEdge > IMAGE_2_MAX_EDGE) {
127
+ scale = Math.min(scale, IMAGE_2_MAX_EDGE / longestEdge);
128
+ }
129
+
130
+ const pixelCount = size.width * size.height;
131
+ if (pixelCount > IMAGE_2_MAX_PIXEL_BUDGET) {
132
+ scale = Math.min(scale, Math.sqrt(IMAGE_2_MAX_PIXEL_BUDGET / pixelCount));
133
+ }
134
+
135
+ const normalizedWidth =
136
+ Math.floor((size.width * scale) / IMAGE_2_SIZE_STEP) * IMAGE_2_SIZE_STEP;
137
+ const normalizedHeight =
138
+ Math.floor((size.height * scale) / IMAGE_2_SIZE_STEP) * IMAGE_2_SIZE_STEP;
139
+
140
+ return {
141
+ width: Math.max(IMAGE_2_SIZE_STEP, normalizedWidth),
142
+ height: Math.max(IMAGE_2_SIZE_STEP, normalizedHeight),
143
+ };
144
+ }
145
+
146
+ function calculateImage2OutputTokens(params: {
147
+ quality: Image2Quality;
148
+ width: number;
149
+ height: number;
150
+ }): number {
151
+ const { quality, width, height } = params;
152
+ const longestEdge = Math.max(width, height);
153
+ const shortestEdge = Math.min(width, height);
154
+ const qualityBaseTokens = IMAGE_2_QUALITY_BASE_TOKENS[quality];
155
+ const scaledShortEdgeTokens = Math.round((qualityBaseTokens * shortestEdge) / longestEdge);
156
+ const widthTokens = width >= height ? qualityBaseTokens : scaledShortEdgeTokens;
157
+ const heightTokens = width >= height ? scaledShortEdgeTokens : qualityBaseTokens;
158
+
159
+ return Math.ceil((widthTokens * heightTokens * (2_000_000 + width * height)) / 4_000_000);
160
+ }
@@ -0,0 +1 @@
1
+ export * from './calculate-openai-image-2-price.helper';
@@ -6,6 +6,7 @@ export const ImageEditorJobParamsSchema = z.object({
6
6
  imageUrls: z.array(z.string()).optional(),
7
7
  systemPromptId: z.string().uuid().optional(),
8
8
  aspectRatio: z.string().optional(),
9
+ resolution: z.string().optional(),
9
10
  userHasActiveSubscriptionOrProduct: z.boolean().optional(),
10
11
  });
11
12
 
@@ -1,9 +1,10 @@
1
1
  import { z } from 'zod';
2
2
 
3
3
  export const ImageEditorJobRequestParamsSchema = z.object({
4
- imageUrls: z.array(z.string().uuid()).optional().default([]),
4
+ imageUrls: z.array(z.string().uuid()).min(1),
5
5
  systemPromptId: z.string().uuid().optional(),
6
6
  aspectRatio: z.string().optional(),
7
+ resolution: z.string().optional(),
7
8
  });
8
9
 
9
10
  export type ImageEditorJobRequestParams = z.infer<typeof ImageEditorJobRequestParamsSchema>;
@@ -13,6 +13,11 @@ export const ImageEditorModelParamsSchema = z.object({
13
13
  height: z.number().int().positive(),
14
14
  }),
15
15
  ),
16
+ resolution: z
17
+ .object({
18
+ options: z.array(z.string()),
19
+ })
20
+ .optional(),
16
21
  });
17
22
 
18
23
  export type ImageEditorModelParams = z.infer<typeof ImageEditorModelParamsSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/multisite",
3
- "version": "0.0.27",
3
+ "version": "0.0.29",
4
4
  "description": "Multisite API contracts (DTO schemas, routes, constants)",
5
5
  "type": "commonjs",
6
6
  "main": "build/index.js",