@purpleschool/gptbot 0.8.96 → 0.8.99

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 (81) hide show
  1. package/api/controllers/http/index.ts +1 -0
  2. package/api/controllers/http/interior-design.ts +14 -0
  3. package/api/controllers/http/payment.ts +1 -0
  4. package/api/controllers/http/product.ts +1 -0
  5. package/api/controllers/http/subscription.ts +1 -0
  6. package/api/routes.ts +37 -0
  7. package/build/api/controllers/http/index.js +1 -0
  8. package/build/api/controllers/http/interior-design.js +16 -0
  9. package/build/api/controllers/http/payment.js +1 -0
  10. package/build/api/controllers/http/product.js +1 -0
  11. package/build/api/controllers/http/subscription.js +1 -0
  12. package/build/api/routes.js +25 -0
  13. package/build/commands/payment/find-payments-by-criteria.command.js +53 -0
  14. package/build/commands/payment/index.js +1 -0
  15. package/build/commands/product/index.js +1 -0
  16. package/build/commands/product/refund-product.command.js +15 -0
  17. package/build/commands/subscription/index.js +1 -0
  18. package/build/commands/subscription/refund-subscription.command.js +15 -0
  19. package/build/commands/tools/index.js +1 -0
  20. package/build/commands/tools/interior-design/delete-all-interior-design-jobs.command.js +8 -0
  21. package/build/commands/tools/interior-design/delete-interior-design-job-by-uuid.command.js +11 -0
  22. package/build/commands/tools/interior-design/find-interior-design-job-by-uuid.command.js +14 -0
  23. package/build/commands/tools/interior-design/find-interior-design-jobs.command.js +18 -0
  24. package/build/commands/tools/interior-design/get-interior-design-tool-config.command.js +11 -0
  25. package/build/commands/tools/interior-design/index.js +25 -0
  26. package/build/commands/tools/interior-design/interior-design.command.js +20 -0
  27. package/build/commands/tools/interior-design/retry-interior-design-job.command.js +25 -0
  28. package/build/commands/tools/interior-design/set-reaction-to-interior-design-job.command.js +28 -0
  29. package/build/commands/tools/interior-design/update-interior-design-job-title.command.js +17 -0
  30. package/build/commands/user/get-user-payments.command.js +3 -1
  31. package/build/constants/errors/errors.js +4411 -2760
  32. package/build/constants/errors/index.js +1 -1
  33. package/build/constants/product/enums/product-status.enum.js +1 -0
  34. package/build/constants/subscription/enums/subscription-feature-type.enum.js +3 -0
  35. package/build/constants/subscription/enums/subscription-status.enum.js +1 -0
  36. package/build/constants/tool/enums/tool-type.enum.js +1 -0
  37. package/build/helpers/index.js +1 -0
  38. package/build/helpers/interior-design/calculate-interior-design-price.helper.js +13 -0
  39. package/build/helpers/interior-design/index.js +17 -0
  40. package/build/models/payment.schema.js +8 -3
  41. package/build/models/subscription-feature.schema.js +14 -1
  42. package/build/models/tools/index.js +1 -0
  43. package/build/models/tools/interior-design/index.js +19 -0
  44. package/build/models/tools/interior-design/interior-design-config.schema.js +23 -0
  45. package/build/models/tools/interior-design/interior-design-job.schema.js +27 -0
  46. package/build/models/tools/interior-design/interior-design-model.schema.js +33 -0
  47. package/commands/payment/find-payments-by-criteria.command.ts +63 -0
  48. package/commands/payment/index.ts +1 -0
  49. package/commands/product/index.ts +1 -0
  50. package/commands/product/refund-product.command.ts +17 -0
  51. package/commands/subscription/index.ts +1 -0
  52. package/commands/subscription/refund-subscription.command.ts +17 -0
  53. package/commands/tools/index.ts +1 -0
  54. package/commands/tools/interior-design/delete-all-interior-design-jobs.command.ts +6 -0
  55. package/commands/tools/interior-design/delete-interior-design-job-by-uuid.command.ts +11 -0
  56. package/commands/tools/interior-design/find-interior-design-job-by-uuid.command.ts +16 -0
  57. package/commands/tools/interior-design/find-interior-design-jobs.command.ts +18 -0
  58. package/commands/tools/interior-design/get-interior-design-tool-config.command.ts +10 -0
  59. package/commands/tools/interior-design/index.ts +9 -0
  60. package/commands/tools/interior-design/interior-design.command.ts +21 -0
  61. package/commands/tools/interior-design/retry-interior-design-job.command.ts +27 -0
  62. package/commands/tools/interior-design/set-reaction-to-interior-design-job.command.ts +33 -0
  63. package/commands/tools/interior-design/update-interior-design-job-title.command.ts +19 -0
  64. package/commands/user/get-user-payments.command.ts +4 -2
  65. package/constants/errors/errors.ts +4451 -2766
  66. package/constants/errors/index.ts +1 -1
  67. package/constants/product/enums/product-status.enum.ts +1 -0
  68. package/constants/subscription/enums/subscription-feature-type.enum.ts +3 -0
  69. package/constants/subscription/enums/subscription-status.enum.ts +1 -0
  70. package/constants/tool/enums/tool-type.enum.ts +1 -0
  71. package/helpers/index.ts +1 -0
  72. package/helpers/interior-design/calculate-interior-design-price.helper.ts +23 -0
  73. package/helpers/interior-design/index.ts +1 -0
  74. package/models/payment.schema.ts +7 -2
  75. package/models/subscription-feature.schema.ts +19 -0
  76. package/models/tools/index.ts +1 -0
  77. package/models/tools/interior-design/index.ts +3 -0
  78. package/models/tools/interior-design/interior-design-config.schema.ts +29 -0
  79. package/models/tools/interior-design/interior-design-job.schema.ts +32 -0
  80. package/models/tools/interior-design/interior-design-model.schema.ts +44 -0
  81. package/package.json +1 -1
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./errors"), exports);
18
17
  __exportStar(require("./verbose"), exports);
18
+ __exportStar(require("./errors"), exports);
@@ -7,4 +7,5 @@ var PRODUCT_STATUS;
7
7
  PRODUCT_STATUS["canceled"] = "canceled";
8
8
  PRODUCT_STATUS["depleted"] = "depleted";
9
9
  PRODUCT_STATUS["expired"] = "expired";
10
+ PRODUCT_STATUS["refunded"] = "refunded";
10
11
  })(PRODUCT_STATUS || (exports.PRODUCT_STATUS = PRODUCT_STATUS = {}));
@@ -26,6 +26,8 @@ var SUBSCRIPTION_FEATURE_TYPE;
26
26
  SUBSCRIPTION_FEATURE_TYPE["WRITER_MODEL_ACCESS"] = "writer_model_access";
27
27
  SUBSCRIPTION_FEATURE_TYPE["IMAGE_EDITOR_QUOTA"] = "image_editor_quota";
28
28
  SUBSCRIPTION_FEATURE_TYPE["IMAGE_EDITOR_MODEL_ACCESS"] = "image_editor_model_access";
29
+ SUBSCRIPTION_FEATURE_TYPE["INTERIOR_DESIGN_QUOTA"] = "interior_design_quota";
30
+ SUBSCRIPTION_FEATURE_TYPE["INTERIOR_DESIGN_MODEL_ACCESS"] = "interior_design_model_access";
29
31
  })(SUBSCRIPTION_FEATURE_TYPE || (exports.SUBSCRIPTION_FEATURE_TYPE = SUBSCRIPTION_FEATURE_TYPE = {}));
30
32
  var SUBSCRIPTION_FEATURE_KIND;
31
33
  (function (SUBSCRIPTION_FEATURE_KIND) {
@@ -41,4 +43,5 @@ var SUBSCRIPTION_FEATURE_KIND;
41
43
  SUBSCRIPTION_FEATURE_KIND["MUSIC"] = "music";
42
44
  SUBSCRIPTION_FEATURE_KIND["WRITER"] = "writer";
43
45
  SUBSCRIPTION_FEATURE_KIND["IMAGE_EDITOR"] = "image_editor";
46
+ SUBSCRIPTION_FEATURE_KIND["INTERIOR_DESIGN"] = "interior_design";
44
47
  })(SUBSCRIPTION_FEATURE_KIND || (exports.SUBSCRIPTION_FEATURE_KIND = SUBSCRIPTION_FEATURE_KIND = {}));
@@ -14,4 +14,5 @@ var SUBSCRIPTION_STATUS;
14
14
  SUBSCRIPTION_STATUS["awaiting_downgrade"] = "awaiting_downgrade";
15
15
  SUBSCRIPTION_STATUS["downgrade_canceled"] = "downgrade_canceled";
16
16
  SUBSCRIPTION_STATUS["deleted"] = "deleted";
17
+ SUBSCRIPTION_STATUS["refunded"] = "refunded";
17
18
  })(SUBSCRIPTION_STATUS || (exports.SUBSCRIPTION_STATUS = SUBSCRIPTION_STATUS = {}));
@@ -9,4 +9,5 @@ var TOOL_TYPE;
9
9
  TOOL_TYPE["IMAGE_GENERATION"] = "image_generation";
10
10
  TOOL_TYPE["IMAGE_EDITOR"] = "image_editor";
11
11
  TOOL_TYPE["MUSIC"] = "music";
12
+ TOOL_TYPE["INTERIOR_DESIGN"] = "interior_design";
12
13
  })(TOOL_TYPE || (exports.TOOL_TYPE = TOOL_TYPE = {}));
@@ -25,3 +25,4 @@ __exportStar(require("./writer"), exports);
25
25
  __exportStar(require("./image-editor"), exports);
26
26
  __exportStar(require("./image-generation"), exports);
27
27
  __exportStar(require("./music"), exports);
28
+ __exportStar(require("./interior-design"), exports);
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateInteriorDesignPrice = calculateInteriorDesignPrice;
4
+ function calculateInteriorDesignPrice({ basePrice, userHasActiveSubscriptionOrProduct, rules, }) {
5
+ let price = basePrice;
6
+ for (const rule of rules !== null && rules !== void 0 ? rules : []) {
7
+ const condition = rule.condition;
8
+ if (condition.withoutSub && userHasActiveSubscriptionOrProduct === false) {
9
+ price += rule.value;
10
+ }
11
+ }
12
+ return price;
13
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./calculate-interior-design-price.helper"), exports);
@@ -1,16 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PaymentWithDescriptionSchema = exports.PaymentSchema = void 0;
3
+ exports.PaymentWithUserDataSchema = exports.PaymentSchema = void 0;
4
4
  const zod_1 = require("zod");
5
+ const constants_1 = require("../constants");
5
6
  exports.PaymentSchema = zod_1.z.object({
6
7
  uuid: zod_1.z.string().uuid(),
7
- link: zod_1.z.nullable(zod_1.z.string()),
8
8
  status: zod_1.z.string(),
9
9
  sum: zod_1.z.number(),
10
10
  orderId: zod_1.z.string().uuid(),
11
11
  createdAt: zod_1.z.date(),
12
12
  updatedAt: zod_1.z.date(),
13
13
  });
14
- exports.PaymentWithDescriptionSchema = exports.PaymentSchema.extend({
14
+ exports.PaymentWithUserDataSchema = exports.PaymentSchema.extend({
15
15
  description: zod_1.z.string(),
16
+ userId: zod_1.z.string().uuid(),
17
+ email: zod_1.z.string().email(),
18
+ singupMethod: zod_1.z.nativeEnum(constants_1.SIGNUP_METHOD),
19
+ vkId: zod_1.z.string().nullable(),
20
+ yandexId: zod_1.z.string().nullable(),
16
21
  });
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SubscriptionFeatureSchema = exports.ImageEditorModelAccessFeatureSchema = exports.ImageEditorQuotaFeatureSchema = exports.WriterModelAccessFeatureSchema = exports.WriterQuotaFeatureSchema = exports.MusicModelAccessFeatureSchema = exports.MusicQuotaFeatureSchema = exports.PresentationQuotaFeatureSchema = exports.VideoModelAccessFeatureSchema = exports.VideoQuotaFeatureSchema = exports.STTQuotaFeatureSchema = exports.STTModelAccessFeatureSchema = exports.TTSQuotaFeatureSchema = exports.ImageGenerationQuotaFeatureSchema = exports.TtsModelAccessFeatureSchema = exports.AdvancedToolsAccessFeatureSchema = exports.WebSearchFeatureSchema = exports.ExtendedContextFeatureSchema = exports.MaxInputLengthFeatureSchema = exports.RequestsQuotaFeatureSchema = exports.AiModelAccessFeatureSchema = exports.CarryoverBalanceFeatureSchema = exports.TokensFeatureSchema = exports.SubscriptionFeatureBaseSchema = void 0;
3
+ exports.SubscriptionFeatureSchema = exports.InteriorDesignModelAccessFeatureSchema = exports.InteriorDesignQuotaFeatureSchema = exports.ImageEditorModelAccessFeatureSchema = exports.ImageEditorQuotaFeatureSchema = exports.WriterModelAccessFeatureSchema = exports.WriterQuotaFeatureSchema = exports.MusicModelAccessFeatureSchema = exports.MusicQuotaFeatureSchema = exports.PresentationQuotaFeatureSchema = exports.VideoModelAccessFeatureSchema = exports.VideoQuotaFeatureSchema = exports.STTQuotaFeatureSchema = exports.STTModelAccessFeatureSchema = exports.TTSQuotaFeatureSchema = exports.ImageGenerationQuotaFeatureSchema = exports.TtsModelAccessFeatureSchema = exports.AdvancedToolsAccessFeatureSchema = exports.WebSearchFeatureSchema = exports.ExtendedContextFeatureSchema = exports.MaxInputLengthFeatureSchema = exports.RequestsQuotaFeatureSchema = exports.AiModelAccessFeatureSchema = exports.CarryoverBalanceFeatureSchema = exports.TokensFeatureSchema = exports.SubscriptionFeatureBaseSchema = void 0;
4
4
  const constants_1 = require("../constants");
5
5
  const zod_1 = require("zod");
6
6
  exports.SubscriptionFeatureBaseSchema = zod_1.z.object({
@@ -143,6 +143,17 @@ exports.ImageEditorModelAccessFeatureSchema = exports.SubscriptionFeatureBaseSch
143
143
  isAvailable: zod_1.z.boolean(),
144
144
  modelId: zod_1.z.string(),
145
145
  });
146
+ exports.InteriorDesignQuotaFeatureSchema = exports.SubscriptionFeatureBaseSchema.extend({
147
+ kind: zod_1.z.literal(constants_1.SUBSCRIPTION_FEATURE_KIND.INTERIOR_DESIGN),
148
+ type: zod_1.z.literal(constants_1.SUBSCRIPTION_FEATURE_TYPE.INTERIOR_DESIGN_QUOTA),
149
+ value: zod_1.z.number(),
150
+ });
151
+ exports.InteriorDesignModelAccessFeatureSchema = exports.SubscriptionFeatureBaseSchema.extend({
152
+ kind: zod_1.z.literal(constants_1.SUBSCRIPTION_FEATURE_KIND.INTERIOR_DESIGN),
153
+ type: zod_1.z.literal(constants_1.SUBSCRIPTION_FEATURE_TYPE.INTERIOR_DESIGN_MODEL_ACCESS),
154
+ isAvailable: zod_1.z.boolean(),
155
+ modelId: zod_1.z.string(),
156
+ });
146
157
  exports.SubscriptionFeatureSchema = zod_1.z.union([
147
158
  exports.AiModelAccessFeatureSchema,
148
159
  exports.RequestsQuotaFeatureSchema,
@@ -166,4 +177,6 @@ exports.SubscriptionFeatureSchema = zod_1.z.union([
166
177
  exports.WriterModelAccessFeatureSchema,
167
178
  exports.ImageEditorQuotaFeatureSchema,
168
179
  exports.ImageEditorModelAccessFeatureSchema,
180
+ exports.InteriorDesignQuotaFeatureSchema,
181
+ exports.InteriorDesignModelAccessFeatureSchema,
169
182
  ]);
@@ -26,3 +26,4 @@ __exportStar(require("./image-editor"), exports);
26
26
  __exportStar(require("./video-editor"), exports);
27
27
  __exportStar(require("./music"), exports);
28
28
  __exportStar(require("./image-generation"), exports);
29
+ __exportStar(require("./interior-design"), exports);
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./interior-design-config.schema"), exports);
18
+ __exportStar(require("./interior-design-job.schema"), exports);
19
+ __exportStar(require("./interior-design-model.schema"), exports);
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InteriorDesignConfigSchema = exports.InteriorDesignRoomTypesSchema = exports.InteriorDesignStylesSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const interior_design_model_schema_1 = require("./interior-design-model.schema");
6
+ exports.InteriorDesignStylesSchema = zod_1.z.object({
7
+ uuid: zod_1.z.string(),
8
+ title: zod_1.z.string(),
9
+ prompt: zod_1.z.string(),
10
+ sample: zod_1.z.string(),
11
+ order: zod_1.z.number(),
12
+ });
13
+ exports.InteriorDesignRoomTypesSchema = zod_1.z.object({
14
+ uuid: zod_1.z.string(),
15
+ title: zod_1.z.string(),
16
+ prompt: zod_1.z.string(),
17
+ order: zod_1.z.number(),
18
+ });
19
+ exports.InteriorDesignConfigSchema = zod_1.z.object({
20
+ models: zod_1.z.array(interior_design_model_schema_1.InteriorDesignModelSchema),
21
+ styles: zod_1.z.array(exports.InteriorDesignStylesSchema),
22
+ roomTypes: zod_1.z.array(exports.InteriorDesignRoomTypesSchema),
23
+ });
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InteriorDesignJobSchema = exports.InteriorDesignJobParamsSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const constants_1 = require("../../../constants");
6
+ const tool_job_schema_1 = require("../../tool-job.schema");
7
+ const file_schema_1 = require("../../file.schema");
8
+ const common_1 = require("../common");
9
+ exports.InteriorDesignJobParamsSchema = zod_1.z.object({
10
+ attachedFiles: zod_1.z.array(common_1.AttachedToolFileSchema),
11
+ styleId: zod_1.z.string().optional(),
12
+ roomTypeId: zod_1.z.string().optional(),
13
+ });
14
+ exports.InteriorDesignJobSchema = tool_job_schema_1.ToolJobSchema.extend({
15
+ title: zod_1.z.string(),
16
+ prompt: zod_1.z.string(),
17
+ reaction: zod_1.z.nativeEnum(constants_1.USER_REACTION).nullable(),
18
+ imageUrls: zod_1.z.string().array(),
19
+ images: zod_1.z
20
+ .array(file_schema_1.FileSchema.pick({
21
+ uuid: true,
22
+ url: true,
23
+ }))
24
+ .nullable(),
25
+ params: exports.InteriorDesignJobParamsSchema,
26
+ modelId: zod_1.z.string(),
27
+ });
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InteriorDesignModelSchema = exports.InteriorDesignModelPricingRulesSchema = exports.InteriorDesignModelPricingRuleConditionSchema = exports.InteriorDesignModelParamsSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const icon_variants_schema_1 = require("../../icon-variants.schema");
6
+ const unlocked_by_subscription_schema_1 = require("../../unlocked-by-subscription.schema");
7
+ exports.InteriorDesignModelParamsSchema = zod_1.z.object({
8
+ imageAttachment: zod_1.z.object({
9
+ supported: zod_1.z.boolean(),
10
+ maxImages: zod_1.z.number(),
11
+ acceptedTypes: zod_1.z.array(zod_1.z.string()),
12
+ }),
13
+ });
14
+ exports.InteriorDesignModelPricingRuleConditionSchema = zod_1.z.object({
15
+ withoutSub: zod_1.z.boolean().optional(),
16
+ });
17
+ exports.InteriorDesignModelPricingRulesSchema = zod_1.z.array(zod_1.z.object({
18
+ condition: exports.InteriorDesignModelPricingRuleConditionSchema,
19
+ value: zod_1.z.number(),
20
+ }));
21
+ exports.InteriorDesignModelSchema = zod_1.z.object({
22
+ uuid: zod_1.z.string(),
23
+ title: zod_1.z.string(),
24
+ description: zod_1.z.string(),
25
+ price: zod_1.z.number(),
26
+ order: zod_1.z.number(),
27
+ icons: icon_variants_schema_1.IconVariantsSchema,
28
+ maxPromptLength: zod_1.z.number(),
29
+ params: exports.InteriorDesignModelParamsSchema,
30
+ pricingRules: exports.InteriorDesignModelPricingRulesSchema,
31
+ unlockedBy: unlocked_by_subscription_schema_1.UnlockedBySchema.nullable(),
32
+ canUse: zod_1.z.boolean(),
33
+ });
@@ -0,0 +1,63 @@
1
+ import { z } from 'zod';
2
+ import { DateFilter, NumberFilter, PaymentWithUserDataSchema } from '../../models';
3
+ import { PAYMENT_SORT_BY, PAYMENT_STATUS, SIGNUP_METHOD, SORT_ORDER } from '../../constants';
4
+
5
+ export namespace FindPaymentsByCriteriaCommand {
6
+ export const RequestSchema = z.preprocess(
7
+ (input) => {
8
+ if (input && typeof input === 'object' && !Array.isArray(input)) {
9
+ const obj = { ...input } as Record<string, any>;
10
+ const onlyNormalize = ['createdAt', 'sum'];
11
+
12
+ const relevantBracketed = Object.keys(obj).some((key) => {
13
+ const match = key.match(/^(\w+)\[(\w+)\]$/);
14
+ return match && onlyNormalize.includes(match[1]);
15
+ });
16
+
17
+ if (!relevantBracketed) {
18
+ return obj;
19
+ }
20
+
21
+ const result = { ...obj };
22
+ for (const key of Object.keys(obj)) {
23
+ const match = key.match(/^(\w+)\[(\w+)\]$/);
24
+ if (match && onlyNormalize.includes(match[1])) {
25
+ const [, outer, inner] = match;
26
+ result[outer] = result[outer] || {};
27
+ result[outer][inner] = obj[key];
28
+ delete result[key];
29
+ }
30
+ }
31
+ return result;
32
+ }
33
+ return input;
34
+ },
35
+ z.object({
36
+ status: z.nativeEnum(PAYMENT_STATUS).optional(),
37
+ orderId: z.string().optional(),
38
+ sum: NumberFilter.optional(),
39
+ userEmail: z.string().optional(),
40
+ createdAt: DateFilter.optional(),
41
+ userId: z.string().optional(),
42
+ signupMethod: z.nativeEnum(SIGNUP_METHOD).optional(),
43
+ vkId: z.string().optional(),
44
+ yandexId: z.string().optional(),
45
+
46
+ sortBy: z.nativeEnum(PAYMENT_SORT_BY).optional(),
47
+ sortOrder: z.nativeEnum(SORT_ORDER).default(SORT_ORDER.DESC).optional(),
48
+
49
+ limit: z.coerce.number().min(1),
50
+ offset: z.coerce.number().min(0).default(0),
51
+ }),
52
+ );
53
+
54
+ export type Request = z.infer<typeof RequestSchema>;
55
+
56
+ export const ResponseSchema = z.object({
57
+ data: z.array(PaymentWithUserDataSchema),
58
+ page: z.number(),
59
+ totalPages: z.number(),
60
+ });
61
+
62
+ export type Response = z.infer<typeof ResponseSchema>;
63
+ }
@@ -4,3 +4,4 @@ export * from './pay.command';
4
4
  export * from './receipt.command';
5
5
  export * from './recurrent.command';
6
6
  export * from './refund-payment.command';
7
+ export * from './find-payments-by-criteria.command';
@@ -4,3 +4,4 @@ export * from './delete-product.command';
4
4
  export * from './find-product.command';
5
5
  export * from './get-my-products.command';
6
6
  export * from './update-product.command';
7
+ export * from './refund-product.command';
@@ -0,0 +1,17 @@
1
+ import { z } from 'zod';
2
+
3
+ export namespace RefundProductCommand {
4
+ export const RequestSchema = z.object({
5
+ uuid: z.string().uuid(),
6
+ });
7
+
8
+ export type Request = z.infer<typeof RequestSchema>;
9
+
10
+ export const ResponseSchema = z.object({
11
+ data: z.object({
12
+ isSuccess: z.boolean(),
13
+ }),
14
+ });
15
+
16
+ export type Response = z.infer<typeof ResponseSchema>;
17
+ }
@@ -12,3 +12,4 @@ export * from './recover-subscription.command';
12
12
  export * from './update-subscription.command';
13
13
  export * from './upgrade-subscription.command';
14
14
  export * from './downgrade-subscription.command';
15
+ export * from './refund-subscription.command';
@@ -0,0 +1,17 @@
1
+ import { z } from 'zod';
2
+
3
+ export namespace RefundSubscriptionCommand {
4
+ export const RequestSchema = z.object({
5
+ uuid: z.string().uuid(),
6
+ });
7
+
8
+ export type Request = z.infer<typeof RequestSchema>;
9
+
10
+ export const ResponseSchema = z.object({
11
+ data: z.object({
12
+ isSuccess: z.boolean(),
13
+ }),
14
+ });
15
+
16
+ export type Response = z.infer<typeof ResponseSchema>;
17
+ }
@@ -9,3 +9,4 @@ export * from './image-editor';
9
9
  export * from './video-editor';
10
10
  export * from './music';
11
11
  export * from './image-generation';
12
+ export * from './interior-design';
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod';
2
+
3
+ export namespace DeleteAllInteriorDesignJobsCommand {
4
+ export const ResponseSchema = z.void();
5
+ export type Response = z.infer<typeof ResponseSchema>;
6
+ }
@@ -0,0 +1,11 @@
1
+ import { z } from 'zod';
2
+
3
+ export namespace DeleteInteriorDesignJobByUuidCommand {
4
+ export const RequestParamsSchema = z.object({
5
+ uuid: z.string().uuid(),
6
+ });
7
+ export type RequestParams = z.infer<typeof RequestParamsSchema>;
8
+
9
+ export const ResponseSchema = z.void();
10
+ export type Response = z.infer<typeof ResponseSchema>;
11
+ }
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ import { InteriorDesignJobSchema, ToolJobSchema } from '../../../models';
3
+
4
+ export namespace FindInteriorDesignJobByUUIDCommand {
5
+ export const RequestParamsSchema = ToolJobSchema.pick({
6
+ uuid: true,
7
+ });
8
+
9
+ export type Request = z.infer<typeof RequestParamsSchema>;
10
+
11
+ export const ResponseSchema = z.object({
12
+ data: InteriorDesignJobSchema,
13
+ });
14
+
15
+ export type Response = z.infer<typeof ResponseSchema>;
16
+ }
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ import { InteriorDesignJobSchema } from '../../../models';
3
+
4
+ export namespace FindInteriorDesignJobsCommand {
5
+ export const RequestQuerySchema = z.object({
6
+ limit: z.coerce.number().min(1).optional(),
7
+ offset: z.coerce.number().min(0).default(0).optional(),
8
+ title: z.string().optional(),
9
+ });
10
+ export type RequestQuery = z.infer<typeof RequestQuerySchema>;
11
+
12
+ export const ResponseSchema = z.object({
13
+ data: z.array(InteriorDesignJobSchema),
14
+ totalPages: z.number(),
15
+ page: z.number(),
16
+ });
17
+ export type Response = z.infer<typeof ResponseSchema>;
18
+ }
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+ import { InteriorDesignConfigSchema } from '../../../models';
3
+
4
+ export namespace GetInteriorDesignToolConfigCommand {
5
+ export const ResponseSchema = z.object({
6
+ data: InteriorDesignConfigSchema,
7
+ });
8
+
9
+ export type Response = z.infer<typeof ResponseSchema>;
10
+ }
@@ -0,0 +1,9 @@
1
+ export * from './delete-interior-design-job-by-uuid.command';
2
+ export * from './delete-all-interior-design-jobs.command';
3
+ export * from './retry-interior-design-job.command';
4
+ export * from './set-reaction-to-interior-design-job.command';
5
+ export * from './interior-design.command';
6
+ export * from './update-interior-design-job-title.command';
7
+ export * from './find-interior-design-job-by-uuid.command';
8
+ export * from './find-interior-design-jobs.command';
9
+ export * from './get-interior-design-tool-config.command';
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+ import { ToolJobSchema } from '../../../models';
3
+
4
+ export namespace InteriorDesignCommand {
5
+ export const RequestSchema = z.object({
6
+ modelId: z.string().uuid(),
7
+ prompt: z.string(),
8
+ params: z.object({
9
+ imageUrls: z.array(z.string()),
10
+ styleId: z.string().optional(),
11
+ roomTypeId: z.string().optional(),
12
+ }),
13
+ });
14
+ export type Request = z.infer<typeof RequestSchema>;
15
+
16
+ export const ResponseSchema = z.object({
17
+ data: ToolJobSchema,
18
+ });
19
+
20
+ export type Response = z.infer<typeof ResponseSchema>;
21
+ }
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+ import { InteriorDesignJobSchema } from '../../../models';
3
+
4
+ export namespace RetryInteriorDesignJobCommand {
5
+ export const RequestParamsSchema = z.object({
6
+ uuid: z.string().uuid(),
7
+ });
8
+ export type RequestParams = z.infer<typeof RequestParamsSchema>;
9
+
10
+ export const RequestBodySchema = z.object({
11
+ modelId: z.string().uuid().optional(),
12
+ prompt: z.string().optional(),
13
+ params: z
14
+ .object({
15
+ attachedFiles: z.string().array(),
16
+ styleId: z.string().optional(),
17
+ roomTypeId: z.string().optional(),
18
+ })
19
+ .optional(),
20
+ });
21
+ export type RequestBody = z.infer<typeof RequestBodySchema>;
22
+
23
+ export const ResponseSchema = z.object({
24
+ data: InteriorDesignJobSchema,
25
+ });
26
+ export type Response = z.infer<typeof ResponseSchema>;
27
+ }
@@ -0,0 +1,33 @@
1
+ import { z } from 'zod';
2
+ import { InteriorDesignJobSchema } from '../../../models';
3
+ import { USER_REACTION } from '../../../constants';
4
+
5
+ export namespace SetReactionToInteriorDesignJobCommand {
6
+ export const RequestSchema = z
7
+ .object({
8
+ reaction: z.nativeEnum(USER_REACTION).nullable(),
9
+ dislikeReason: z.string().nullable().default(null),
10
+ })
11
+ .refine(
12
+ (data) => {
13
+ if (data.reaction !== USER_REACTION.DISLIKED && data.dislikeReason) {
14
+ return false;
15
+ }
16
+ return true;
17
+ },
18
+ {
19
+ message: 'Dislike reason is not allowed when reaction is not DISLIKED',
20
+ },
21
+ );
22
+ export type Request = z.infer<typeof RequestSchema>;
23
+
24
+ export const RequestParamsSchema = z.object({
25
+ uuid: z.string().uuid(),
26
+ });
27
+ export type RequestParams = z.infer<typeof RequestParamsSchema>;
28
+
29
+ export const ResponseSchema = z.object({
30
+ data: InteriorDesignJobSchema,
31
+ });
32
+ export type Response = z.infer<typeof ResponseSchema>;
33
+ }
@@ -0,0 +1,19 @@
1
+ import { z } from 'zod';
2
+ import { InteriorDesignJobSchema } from '../../../models';
3
+
4
+ export namespace UpdateInteriorDesignJobTitleCommand {
5
+ export const RequestSchema = z.object({
6
+ title: z.string().min(1).max(40).trim(),
7
+ });
8
+ export type Request = z.infer<typeof RequestSchema>;
9
+
10
+ export const RequestParamsSchema = z.object({
11
+ uuid: z.string().uuid(),
12
+ });
13
+ export type RequestParams = z.infer<typeof RequestParamsSchema>;
14
+
15
+ export const ResponseSchema = z.object({
16
+ data: InteriorDesignJobSchema,
17
+ });
18
+ export type Response = z.infer<typeof ResponseSchema>;
19
+ }
@@ -1,6 +1,6 @@
1
1
  import z from 'zod';
2
2
  import { PAYMENT_SORT_BY, PAYMENT_STATUS, SORT_ORDER } from '../../constants';
3
- import { PaymentWithDescriptionSchema } from '../../models';
3
+ import { PaymentWithUserDataSchema } from '../../models';
4
4
 
5
5
  export namespace GetUserPaymentsCommand {
6
6
  export const RequestParamSchema = z.object({
@@ -20,7 +20,9 @@ export namespace GetUserPaymentsCommand {
20
20
  .partial();
21
21
 
22
22
  export const ResponseSchema = z.object({
23
- data: z.array(PaymentWithDescriptionSchema),
23
+ data: z.array(PaymentWithUserDataSchema),
24
+ page: z.number(),
25
+ totalPages: z.number(),
24
26
  });
25
27
 
26
28
  export type Response = z.infer<typeof ResponseSchema>;