@purpleschool/gptbot 0.5.46 → 0.5.48

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 (33) hide show
  1. package/api/controllers/http/ai-model.ts +1 -0
  2. package/api/controllers/http/subscription.ts +1 -0
  3. package/api/routes.ts +5 -0
  4. package/build/api/controllers/http/ai-model.js +1 -0
  5. package/build/api/controllers/http/subscription.js +1 -0
  6. package/build/api/routes.js +3 -0
  7. package/build/commands/ai-model/find-ai-models-available-to-user.comand.js +12 -0
  8. package/build/commands/ai-model/index.js +1 -0
  9. package/build/commands/subscription/get-free-subscription.command.js +11 -0
  10. package/build/commands/subscription/index.js +1 -0
  11. package/build/constants/errors/errors.js +27 -2
  12. package/build/constants/subscription/enums/index.js +1 -0
  13. package/build/constants/subscription/enums/subscription-feature-type.enum.js +10 -0
  14. package/build/constants/subscription/free-subscription.constant.js +21 -0
  15. package/build/models/ai-model.schema.js +2 -0
  16. package/build/models/index.js +1 -0
  17. package/build/models/product.schema.js +5 -1
  18. package/build/models/subscription-feature.schema.js +35 -0
  19. package/build/models/subscription.schema.js +12 -5
  20. package/commands/ai-model/find-ai-models-available-to-user.comand.ts +12 -0
  21. package/commands/ai-model/index.ts +1 -0
  22. package/commands/subscription/get-free-subscription.command.ts +10 -0
  23. package/commands/subscription/index.ts +1 -0
  24. package/constants/errors/errors.ts +28 -2
  25. package/constants/subscription/enums/index.ts +1 -0
  26. package/constants/subscription/enums/subscription-feature-type.enum.ts +6 -0
  27. package/constants/subscription/free-subscription.constant.ts +19 -0
  28. package/models/ai-model.schema.ts +2 -0
  29. package/models/index.ts +1 -0
  30. package/models/product.schema.ts +5 -1
  31. package/models/subscription-feature.schema.ts +39 -0
  32. package/models/subscription.schema.ts +12 -4
  33. package/package.json +1 -1
@@ -5,4 +5,5 @@ export const AI_MODEL_ROUTES = {
5
5
  FIND_BY_UUID: 'by/uuid',
6
6
  GET_ALL: 'all',
7
7
  GET_FORMATTED: 'formatted',
8
+ AVAILABLE: 'available',
8
9
  } as const;
@@ -13,4 +13,5 @@ export const SUBSCRIPTION_ROUTES = {
13
13
  GET_AVAILABLE_UPGRADES: 'available-upgrades',
14
14
  UPGRADE: 'upgrade',
15
15
  CREATE_CUSTOM: 'custom',
16
+ FREE: 'free',
16
17
  } as const;
package/api/routes.ts CHANGED
@@ -121,6 +121,11 @@ export const REST_API = {
121
121
  PATCH: (uuid: string) => `${ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${uuid}`,
122
122
  DELETE: (uuid: string) => `${ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${uuid}`,
123
123
  CREATE: `${ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}`,
124
+ UPGRADE: (uuid: string) =>
125
+ `${ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${uuid}/${CONTROLLERS.SUBSCRIPTION_ROUTES.UPGRADE}`,
126
+ GET_AVAILABLE_UPGRADES: (uuid: string) =>
127
+ `${ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${uuid}/${CONTROLLERS.SUBSCRIPTION_ROUTES.GET_AVAILABLE_UPGRADES}`,
128
+ CREATE_CUSTOM: `${ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.CREATE_CUSTOM}`,
124
129
  },
125
130
  FILES: {
126
131
  UPLOAD_FILE: `${ROOT}/${CONTROLLERS.FILE_CONTROLLER}/${CONTROLLERS.FILE_ROUTES.UPLOAD_FILE}`,
@@ -7,4 +7,5 @@ exports.AI_MODEL_ROUTES = {
7
7
  FIND_BY_UUID: 'by/uuid',
8
8
  GET_ALL: 'all',
9
9
  GET_FORMATTED: 'formatted',
10
+ AVAILABLE: 'available',
10
11
  };
@@ -14,4 +14,5 @@ exports.SUBSCRIPTION_ROUTES = {
14
14
  GET_AVAILABLE_UPGRADES: 'available-upgrades',
15
15
  UPGRADE: 'upgrade',
16
16
  CREATE_CUSTOM: 'custom',
17
+ FREE: 'free',
17
18
  };
@@ -136,6 +136,9 @@ exports.REST_API = {
136
136
  PATCH: (uuid) => `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${uuid}`,
137
137
  DELETE: (uuid) => `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${uuid}`,
138
138
  CREATE: `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}`,
139
+ UPGRADE: (uuid) => `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${uuid}/${CONTROLLERS.SUBSCRIPTION_ROUTES.UPGRADE}`,
140
+ GET_AVAILABLE_UPGRADES: (uuid) => `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${uuid}/${CONTROLLERS.SUBSCRIPTION_ROUTES.GET_AVAILABLE_UPGRADES}`,
141
+ CREATE_CUSTOM: `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.CREATE_CUSTOM}`,
139
142
  },
140
143
  FILES: {
141
144
  UPLOAD_FILE: `${exports.ROOT}/${CONTROLLERS.FILE_CONTROLLER}/${CONTROLLERS.FILE_ROUTES.UPLOAD_FILE}`,
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FindAiModelsAvailableToUserCommand = void 0;
4
+ const models_1 = require("../../models");
5
+ const zod_1 = require("zod");
6
+ var FindAiModelsAvailableToUserCommand;
7
+ (function (FindAiModelsAvailableToUserCommand) {
8
+ FindAiModelsAvailableToUserCommand.RequestSchema = zod_1.z.void();
9
+ FindAiModelsAvailableToUserCommand.ResponseSchema = zod_1.z.object({
10
+ data: zod_1.z.array(models_1.AiModelSchema),
11
+ });
12
+ })(FindAiModelsAvailableToUserCommand || (exports.FindAiModelsAvailableToUserCommand = FindAiModelsAvailableToUserCommand = {}));
@@ -17,5 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./create-ai-model.command"), exports);
18
18
  __exportStar(require("./delete-ai-model.command"), exports);
19
19
  __exportStar(require("./find-ai-model.command"), exports);
20
+ __exportStar(require("./find-ai-models-available-to-user.comand"), exports);
20
21
  __exportStar(require("./find-formatted-ai-model.command"), exports);
21
22
  __exportStar(require("./update-ai-model.command"), exports);
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetFreeSubscriptionCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
6
+ var GetFreeSubscriptionCommand;
7
+ (function (GetFreeSubscriptionCommand) {
8
+ GetFreeSubscriptionCommand.ResponseSchema = zod_1.z.object({
9
+ data: models_1.SubscriptionSchema,
10
+ });
11
+ })(GetFreeSubscriptionCommand || (exports.GetFreeSubscriptionCommand = GetFreeSubscriptionCommand = {}));
@@ -21,6 +21,7 @@ __exportStar(require("./create-subscription.command"), exports);
21
21
  __exportStar(require("./delete-subscription.command"), exports);
22
22
  __exportStar(require("./find-subscription.command"), exports);
23
23
  __exportStar(require("./get-available-upgrades.command"), exports);
24
+ __exportStar(require("./get-free-subscription.command"), exports);
24
25
  __exportStar(require("./recover-subscription.command"), exports);
25
26
  __exportStar(require("./update-subscription.command"), exports);
26
27
  __exportStar(require("./upgrade-subscription.command"), exports);
@@ -870,9 +870,9 @@ exports.ERRORS = {
870
870
  message: 'Превышено максимальное количество прикрепленных файлов',
871
871
  httpCode: 400,
872
872
  },
873
- CHAT_NO_ACCESS_TO_PREMIUM_MODELS: {
873
+ AI_MODEL_USER_HAS_NO_ACCESS: {
874
874
  code: 'A199',
875
- message: 'У пользователя нет доступа к премиум моделям',
875
+ message: 'У пользователя нет доступа к данной ИИ модели',
876
876
  httpCode: 400,
877
877
  },
878
878
  CHAT_TRANSFER_ERROR: {
@@ -935,4 +935,29 @@ exports.ERRORS = {
935
935
  message: 'Ссылка для авторизации через телеграм уже была использована',
936
936
  httpCode: 400,
937
937
  },
938
+ AI_MODEL_MAX_INPUT_LENGTH_EXCEEDED: {
939
+ code: 'A213',
940
+ message: 'Превышено максимальное количество символов в запросе',
941
+ httpCode: 400,
942
+ },
943
+ AI_MODEL_MAX_INPUT_TOKENS_EXCEEDED: {
944
+ code: 'A214',
945
+ message: 'Превышено максимальное количество токенов в запросе',
946
+ httpCode: 400,
947
+ },
948
+ AI_MODEL_FAILED_TO_CHECK_ACCESS: {
949
+ code: 'A215',
950
+ message: 'Не удалось проверить наличие доступа к ИИ модели',
951
+ httpCode: 500,
952
+ },
953
+ AI_MODEL_FAILED_TO_FIND_AVAILABLE_MODELS: {
954
+ code: 'A216',
955
+ message: 'Произошла ошибка при поиске доступных ИИ моделей',
956
+ httpCode: 500,
957
+ },
958
+ CHAT_INPUT_LIMITS_CHECK_ERROR: {
959
+ code: 'A217',
960
+ message: 'Произошла ошибка при проверке ограничений на длину запроса для чата',
961
+ httpCode: 500,
962
+ },
938
963
  };
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./subscription-action.enum"), exports);
18
+ __exportStar(require("./subscription-feature-type.enum"), exports);
18
19
  __exportStar(require("./subscription-plan.enum"), exports);
19
20
  __exportStar(require("./subscription-status.enum"), exports);
20
21
  __exportStar(require("./subscription-type.enum"), exports);
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SUBSCRIPTION_FEATURE_TYPE = void 0;
4
+ var SUBSCRIPTION_FEATURE_TYPE;
5
+ (function (SUBSCRIPTION_FEATURE_TYPE) {
6
+ SUBSCRIPTION_FEATURE_TYPE["REQUESTS_QUOTA"] = "requests_quota";
7
+ SUBSCRIPTION_FEATURE_TYPE["AI_MODEL_ACCESS"] = "ai_model_access";
8
+ SUBSCRIPTION_FEATURE_TYPE["MAX_INPUT_LENGTH"] = "max_input_length";
9
+ SUBSCRIPTION_FEATURE_TYPE["INFO"] = "info";
10
+ })(SUBSCRIPTION_FEATURE_TYPE || (exports.SUBSCRIPTION_FEATURE_TYPE = SUBSCRIPTION_FEATURE_TYPE = {}));
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FREE_SUBSCRIPTION_DATA = void 0;
4
+ const enums_1 = require("./enums");
5
+ exports.FREE_SUBSCRIPTION_DATA = {
6
+ uuid: '00000000-0000-0000-0000-000000000000',
7
+ mainSubscriptionId: null,
8
+ name: 'Бесплатный',
9
+ requests: 0,
10
+ price: 0,
11
+ tokens: 0,
12
+ type: enums_1.SUBSCRIPTION_TYPE.main,
13
+ discount: 0,
14
+ maxDiscountPercent: 0,
15
+ period: 0,
16
+ plan: enums_1.SUBSCRIPTION_PLAN.system,
17
+ icon: 'https://rugpt.hb.bizmrg.com/images/images/ac095d48-a66b-4862-82c7-eb120b5bd467.svg',
18
+ interval: '',
19
+ createdAt: new Date(),
20
+ updatedAt: new Date(),
21
+ };
@@ -16,6 +16,8 @@ exports.AiModelSchema = zod_1.z.object({
16
16
  status: zod_1.z.nativeEnum(constants_1.AI_MODEL_STATUS),
17
17
  contentType: zod_1.z.enum(Object.values(constants_1.AI_MODEL_CONTENT_TYPE)),
18
18
  features: zod_1.z.array(zod_1.z.nativeEnum(constants_1.AI_MODEL_FEATURE)),
19
+ maxInputLength: zod_1.z.number(),
20
+ maxInputTokens: zod_1.z.number(),
19
21
  createdAt: zod_1.z.date(),
20
22
  updatedAt: zod_1.z.date(),
21
23
  });
@@ -35,6 +35,7 @@ __exportStar(require("./product.schema"), exports);
35
35
  __exportStar(require("./question.schema"), exports);
36
36
  __exportStar(require("./referral-bonus.schema"), exports);
37
37
  __exportStar(require("./section.schema"), exports);
38
+ __exportStar(require("./subscription-feature.schema"), exports);
38
39
  __exportStar(require("./subscription-upgrade-schema"), exports);
39
40
  __exportStar(require("./subscription.schema"), exports);
40
41
  __exportStar(require("./telegram-user-data.schema"), exports);
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ProductSchema = exports.FeaturesSchema = void 0;
4
4
  const zod_1 = require("zod");
5
+ const subscription_feature_schema_1 = require("./subscription-feature.schema");
5
6
  exports.FeaturesSchema = zod_1.z.object({
6
7
  icon: zod_1.z.string(),
7
8
  title: zod_1.z.string(),
@@ -11,7 +12,10 @@ exports.ProductSchema = zod_1.z.object({
11
12
  name: zod_1.z.string().min(3).max(16384),
12
13
  requests: zod_1.z.number(),
13
14
  price: zod_1.z.number(),
14
- features: zod_1.z.array(exports.FeaturesSchema),
15
+ icon: zod_1.z.string(),
16
+ features: zod_1.z.array(subscription_feature_schema_1.SubscriptionFeatureSchema),
17
+ maxInputLength: zod_1.z.number(),
18
+ maxInputTokens: zod_1.z.number(),
15
19
  createdAt: zod_1.z.date(),
16
20
  updatedAt: zod_1.z.date(),
17
21
  });
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SubscriptionFeatureSchema = exports.MaxInputLengthFeatureSchema = exports.RequestsQuotaFeatureSchema = exports.AiModelAccessFeatureSchema = exports.SubscriptionFeatureBaseSchema = void 0;
4
+ const constants_1 = require("../constants");
5
+ const zod_1 = require("zod");
6
+ exports.SubscriptionFeatureBaseSchema = zod_1.z.object({
7
+ title: zod_1.z.string(),
8
+ icon: zod_1.z.string(),
9
+ type: zod_1.z.nativeEnum(constants_1.SUBSCRIPTION_FEATURE_TYPE),
10
+ });
11
+ exports.AiModelAccessFeatureSchema = exports.SubscriptionFeatureBaseSchema.extend({
12
+ type: zod_1.z.literal(constants_1.SUBSCRIPTION_FEATURE_TYPE.AI_MODEL_ACCESS),
13
+ value: zod_1.z.object({
14
+ isAvailable: zod_1.z.boolean(),
15
+ order: zod_1.z.number(),
16
+ contentType: zod_1.z.nativeEnum(constants_1.AI_MODEL_CONTENT_TYPE),
17
+ }),
18
+ });
19
+ exports.RequestsQuotaFeatureSchema = exports.SubscriptionFeatureBaseSchema.extend({
20
+ type: zod_1.z.literal(constants_1.SUBSCRIPTION_FEATURE_TYPE.REQUESTS_QUOTA),
21
+ value: zod_1.z.object({
22
+ tokens: zod_1.z.number(),
23
+ }),
24
+ });
25
+ exports.MaxInputLengthFeatureSchema = exports.SubscriptionFeatureBaseSchema.extend({
26
+ type: zod_1.z.literal(constants_1.SUBSCRIPTION_FEATURE_TYPE.MAX_INPUT_LENGTH),
27
+ value: zod_1.z.object({
28
+ maxInputLength: zod_1.z.number(),
29
+ }),
30
+ });
31
+ exports.SubscriptionFeatureSchema = zod_1.z.union([
32
+ exports.AiModelAccessFeatureSchema,
33
+ exports.RequestsQuotaFeatureSchema,
34
+ exports.MaxInputLengthFeatureSchema,
35
+ ]);
@@ -1,27 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SubscriptionWithSubTypesSchema = exports.SubscriptionWithActionSchema = exports.SubscriptionSchema = void 0;
3
+ exports.SubscriptionWithFeaturesSchema = exports.SubscriptionWithSubTypesSchema = exports.SubscriptionWithActionSchema = exports.SubscriptionSchema = void 0;
4
4
  const zod_1 = require("zod");
5
- const product_schema_1 = require("./product.schema");
6
5
  const constants_1 = require("../constants");
6
+ const subscription_feature_schema_1 = require("./subscription-feature.schema");
7
7
  exports.SubscriptionSchema = zod_1.z.object({
8
8
  uuid: zod_1.z.string().uuid(),
9
9
  mainSubscriptionId: zod_1.z.nullable(zod_1.z.string().uuid()),
10
10
  name: zod_1.z.string().min(3).max(16384),
11
11
  requests: zod_1.z.number(),
12
12
  price: zod_1.z.number(),
13
- features: zod_1.z.array(product_schema_1.FeaturesSchema),
14
13
  plan: zod_1.z.nativeEnum(constants_1.SUBSCRIPTION_PLAN),
15
14
  type: zod_1.z.nativeEnum(constants_1.SUBSCRIPTION_TYPE),
16
15
  discount: zod_1.z.number(),
17
16
  period: zod_1.z.number(),
18
17
  tokens: zod_1.z.number(),
18
+ icon: zod_1.z.string(),
19
+ action: zod_1.z.nativeEnum(constants_1.SUBSCRIPTION_ACTION).optional().nullable(),
20
+ features: zod_1.z.array(subscription_feature_schema_1.SubscriptionFeatureSchema),
21
+ maxInputLength: zod_1.z.number(),
22
+ maxInputTokens: zod_1.z.number(),
19
23
  createdAt: zod_1.z.date(),
20
24
  updatedAt: zod_1.z.date(),
21
25
  });
22
26
  exports.SubscriptionWithActionSchema = zod_1.z.intersection(exports.SubscriptionSchema, zod_1.z.object({
23
27
  action: zod_1.z.nativeEnum(constants_1.SUBSCRIPTION_ACTION),
24
28
  }));
25
- exports.SubscriptionWithSubTypesSchema = zod_1.z.intersection(exports.SubscriptionWithActionSchema, zod_1.z.object({
26
- subTypes: zod_1.z.array(exports.SubscriptionWithActionSchema),
29
+ exports.SubscriptionWithSubTypesSchema = zod_1.z.intersection(exports.SubscriptionSchema, zod_1.z.object({
30
+ subTypes: zod_1.z.array(exports.SubscriptionSchema),
27
31
  }));
32
+ exports.SubscriptionWithFeaturesSchema = exports.SubscriptionSchema.extend({
33
+ features: zod_1.z.array(subscription_feature_schema_1.SubscriptionFeatureSchema),
34
+ });
@@ -0,0 +1,12 @@
1
+ import { AiModelSchema } from '../../models';
2
+ import { z } from 'zod';
3
+
4
+ export namespace FindAiModelsAvailableToUserCommand {
5
+ export const RequestSchema = z.void();
6
+ export type Request = z.infer<typeof RequestSchema>;
7
+
8
+ export const ResponseSchema = z.object({
9
+ data: z.array(AiModelSchema),
10
+ });
11
+ export type Response = z.infer<typeof ResponseSchema>;
12
+ }
@@ -1,5 +1,6 @@
1
1
  export * from './create-ai-model.command';
2
2
  export * from './delete-ai-model.command';
3
3
  export * from './find-ai-model.command';
4
+ export * from './find-ai-models-available-to-user.comand';
4
5
  export * from './find-formatted-ai-model.command';
5
6
  export * from './update-ai-model.command';
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+ import { SubscriptionSchema } from '../../models';
3
+
4
+ export namespace GetFreeSubscriptionCommand {
5
+ export const ResponseSchema = z.object({
6
+ data: SubscriptionSchema,
7
+ });
8
+
9
+ export type Response = z.infer<typeof ResponseSchema>;
10
+ }
@@ -5,6 +5,7 @@ export * from './create-subscription.command';
5
5
  export * from './delete-subscription.command';
6
6
  export * from './find-subscription.command';
7
7
  export * from './get-available-upgrades.command';
8
+ export * from './get-free-subscription.command';
8
9
  export * from './recover-subscription.command';
9
10
  export * from './update-subscription.command';
10
11
  export * from './upgrade-subscription.command';
@@ -872,11 +872,12 @@ export const ERRORS = {
872
872
  message: 'Превышено максимальное количество прикрепленных файлов',
873
873
  httpCode: 400,
874
874
  },
875
- CHAT_NO_ACCESS_TO_PREMIUM_MODELS: {
875
+ AI_MODEL_USER_HAS_NO_ACCESS: {
876
876
  code: 'A199',
877
- message: 'У пользователя нет доступа к премиум моделям',
877
+ message: 'У пользователя нет доступа к данной ИИ модели',
878
878
  httpCode: 400,
879
879
  },
880
+
880
881
  CHAT_TRANSFER_ERROR: {
881
882
  code: 'A200',
882
883
  message: 'Произошла ошибка при переносе чата',
@@ -937,4 +938,29 @@ export const ERRORS = {
937
938
  message: 'Ссылка для авторизации через телеграм уже была использована',
938
939
  httpCode: 400,
939
940
  },
941
+ AI_MODEL_MAX_INPUT_LENGTH_EXCEEDED: {
942
+ code: 'A213',
943
+ message: 'Превышено максимальное количество символов в запросе',
944
+ httpCode: 400,
945
+ },
946
+ AI_MODEL_MAX_INPUT_TOKENS_EXCEEDED: {
947
+ code: 'A214',
948
+ message: 'Превышено максимальное количество токенов в запросе',
949
+ httpCode: 400,
950
+ },
951
+ AI_MODEL_FAILED_TO_CHECK_ACCESS: {
952
+ code: 'A215',
953
+ message: 'Не удалось проверить наличие доступа к ИИ модели',
954
+ httpCode: 500,
955
+ },
956
+ AI_MODEL_FAILED_TO_FIND_AVAILABLE_MODELS: {
957
+ code: 'A216',
958
+ message: 'Произошла ошибка при поиске доступных ИИ моделей',
959
+ httpCode: 500,
960
+ },
961
+ CHAT_INPUT_LIMITS_CHECK_ERROR: {
962
+ code: 'A217',
963
+ message: 'Произошла ошибка при проверке ограничений на длину запроса для чата',
964
+ httpCode: 500,
965
+ },
940
966
  };
@@ -1,4 +1,5 @@
1
1
  export * from './subscription-action.enum';
2
+ export * from './subscription-feature-type.enum';
2
3
  export * from './subscription-plan.enum';
3
4
  export * from './subscription-status.enum';
4
5
  export * from './subscription-type.enum';
@@ -0,0 +1,6 @@
1
+ export enum SUBSCRIPTION_FEATURE_TYPE {
2
+ REQUESTS_QUOTA = 'requests_quota',
3
+ AI_MODEL_ACCESS = 'ai_model_access',
4
+ MAX_INPUT_LENGTH = 'max_input_length',
5
+ INFO = 'info',
6
+ }
@@ -0,0 +1,19 @@
1
+ import { SUBSCRIPTION_PLAN, SUBSCRIPTION_TYPE } from './enums';
2
+
3
+ export const FREE_SUBSCRIPTION_DATA = {
4
+ uuid: '00000000-0000-0000-0000-000000000000',
5
+ mainSubscriptionId: null,
6
+ name: 'Бесплатный',
7
+ requests: 0,
8
+ price: 0,
9
+ tokens: 0,
10
+ type: SUBSCRIPTION_TYPE.main,
11
+ discount: 0,
12
+ maxDiscountPercent: 0,
13
+ period: 0,
14
+ plan: SUBSCRIPTION_PLAN.system,
15
+ icon: 'https://rugpt.hb.bizmrg.com/images/images/ac095d48-a66b-4862-82c7-eb120b5bd467.svg',
16
+ interval: '',
17
+ createdAt: new Date(),
18
+ updatedAt: new Date(),
19
+ };
@@ -19,6 +19,8 @@ export const AiModelSchema = z.object({
19
19
  status: z.nativeEnum(AI_MODEL_STATUS),
20
20
  contentType: z.enum(Object.values(AI_MODEL_CONTENT_TYPE) as [TAIModelContentTypeEnum]),
21
21
  features: z.array(z.nativeEnum(AI_MODEL_FEATURE)),
22
+ maxInputLength: z.number(),
23
+ maxInputTokens: z.number(),
22
24
  createdAt: z.date(),
23
25
  updatedAt: z.date(),
24
26
  });
package/models/index.ts CHANGED
@@ -19,6 +19,7 @@ export * from './product.schema';
19
19
  export * from './question.schema';
20
20
  export * from './referral-bonus.schema';
21
21
  export * from './section.schema';
22
+ export * from './subscription-feature.schema';
22
23
  export * from './subscription-upgrade-schema';
23
24
  export * from './subscription.schema';
24
25
  export * from './telegram-user-data.schema';
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { SubscriptionFeatureSchema } from './subscription-feature.schema';
2
3
 
3
4
  export const FeaturesSchema = z.object({
4
5
  icon: z.string(),
@@ -10,7 +11,10 @@ export const ProductSchema = z.object({
10
11
  name: z.string().min(3).max(16384),
11
12
  requests: z.number(),
12
13
  price: z.number(),
13
- features: z.array(FeaturesSchema),
14
+ icon: z.string(),
15
+ features: z.array(SubscriptionFeatureSchema),
16
+ maxInputLength: z.number(),
17
+ maxInputTokens: z.number(),
14
18
  createdAt: z.date(),
15
19
  updatedAt: z.date(),
16
20
  });
@@ -0,0 +1,39 @@
1
+ import { AI_MODEL_CONTENT_TYPE, SUBSCRIPTION_FEATURE_TYPE } from '../constants';
2
+ import { z } from 'zod';
3
+
4
+ export const SubscriptionFeatureBaseSchema = z.object({
5
+ title: z.string(),
6
+ icon: z.string(),
7
+ type: z.nativeEnum(SUBSCRIPTION_FEATURE_TYPE),
8
+ });
9
+
10
+ export const AiModelAccessFeatureSchema = SubscriptionFeatureBaseSchema.extend({
11
+ type: z.literal(SUBSCRIPTION_FEATURE_TYPE.AI_MODEL_ACCESS),
12
+ value: z.object({
13
+ isAvailable: z.boolean(),
14
+ order: z.number(),
15
+ contentType: z.nativeEnum(AI_MODEL_CONTENT_TYPE),
16
+ }),
17
+ });
18
+
19
+ export const RequestsQuotaFeatureSchema = SubscriptionFeatureBaseSchema.extend({
20
+ type: z.literal(SUBSCRIPTION_FEATURE_TYPE.REQUESTS_QUOTA),
21
+ value: z.object({
22
+ tokens: z.number(),
23
+ }),
24
+ });
25
+
26
+ export const MaxInputLengthFeatureSchema = SubscriptionFeatureBaseSchema.extend({
27
+ type: z.literal(SUBSCRIPTION_FEATURE_TYPE.MAX_INPUT_LENGTH),
28
+ value: z.object({
29
+ maxInputLength: z.number(),
30
+ }),
31
+ });
32
+
33
+ export const SubscriptionFeatureSchema = z.union([
34
+ AiModelAccessFeatureSchema,
35
+ RequestsQuotaFeatureSchema,
36
+ MaxInputLengthFeatureSchema,
37
+ ]);
38
+
39
+ export type SubscriptionFeature = z.infer<typeof SubscriptionFeatureSchema>;
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { FeaturesSchema } from './product.schema';
3
2
  import { SUBSCRIPTION_ACTION, SUBSCRIPTION_PLAN, SUBSCRIPTION_TYPE } from '../constants';
3
+ import { SubscriptionFeatureSchema } from './subscription-feature.schema';
4
4
 
5
5
  export const SubscriptionSchema = z.object({
6
6
  uuid: z.string().uuid(),
@@ -8,12 +8,16 @@ export const SubscriptionSchema = z.object({
8
8
  name: z.string().min(3).max(16384),
9
9
  requests: z.number(),
10
10
  price: z.number(),
11
- features: z.array(FeaturesSchema),
12
11
  plan: z.nativeEnum(SUBSCRIPTION_PLAN),
13
12
  type: z.nativeEnum(SUBSCRIPTION_TYPE),
14
13
  discount: z.number(),
15
14
  period: z.number(),
16
15
  tokens: z.number(),
16
+ icon: z.string(),
17
+ action: z.nativeEnum(SUBSCRIPTION_ACTION).optional().nullable(),
18
+ features: z.array(SubscriptionFeatureSchema),
19
+ maxInputLength: z.number(),
20
+ maxInputTokens: z.number(),
17
21
  createdAt: z.date(),
18
22
  updatedAt: z.date(),
19
23
  });
@@ -26,8 +30,12 @@ export const SubscriptionWithActionSchema = z.intersection(
26
30
  );
27
31
 
28
32
  export const SubscriptionWithSubTypesSchema = z.intersection(
29
- SubscriptionWithActionSchema,
33
+ SubscriptionSchema,
30
34
  z.object({
31
- subTypes: z.array(SubscriptionWithActionSchema),
35
+ subTypes: z.array(SubscriptionSchema),
32
36
  }),
33
37
  );
38
+
39
+ export const SubscriptionWithFeaturesSchema = SubscriptionSchema.extend({
40
+ features: z.array(SubscriptionFeatureSchema),
41
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.5.46",
3
+ "version": "0.5.48",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",