@purpleschool/gptbot 0.5.53 → 0.5.55

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 (41) hide show
  1. package/api/controllers/http/product.ts +1 -0
  2. package/api/controllers/http/subscription.ts +1 -0
  3. package/api/routes.ts +2 -0
  4. package/build/api/controllers/http/product.js +1 -0
  5. package/build/api/controllers/http/subscription.js +1 -0
  6. package/build/api/routes.js +2 -0
  7. package/build/commands/ai-model/find-ai-model.command.js +1 -1
  8. package/build/commands/auth/register-user.command.js +7 -3
  9. package/build/commands/product/get-my-products.command.js +11 -0
  10. package/build/commands/product/index.js +1 -0
  11. package/build/commands/subscription/get-subscriptions-summary.command.js +13 -0
  12. package/build/commands/subscription/index.js +1 -0
  13. package/build/commands/telegram-profile/auth-with-telegram-web-app.command.js +2 -0
  14. package/build/constants/errors/errors.js +5 -0
  15. package/build/constants/product/enums/product-status.enum.js +1 -0
  16. package/build/constants/subscription/enums/subscription-plan.enum.js +1 -0
  17. package/build/constants/subscription/enums/user-to-subscription-marks.enum.js +1 -0
  18. package/build/constants/subscription/free-subscription.constant.js +16 -2
  19. package/build/models/ai-model-formatted.schema.js +1 -1
  20. package/build/models/ai-model.schema.js +9 -1
  21. package/build/models/index.js +3 -1
  22. package/build/models/user-to-product.schema.js +19 -0
  23. package/build/models/utm.schema.js +15 -0
  24. package/commands/ai-model/find-ai-model.command.ts +2 -2
  25. package/commands/auth/register-user.command.ts +8 -7
  26. package/commands/product/get-my-products.command.ts +10 -0
  27. package/commands/product/index.ts +1 -0
  28. package/commands/subscription/get-subscriptions-summary.command.ts +16 -0
  29. package/commands/subscription/index.ts +1 -0
  30. package/commands/telegram-profile/auth-with-telegram-web-app.command.ts +2 -0
  31. package/constants/errors/errors.ts +5 -0
  32. package/constants/product/enums/product-status.enum.ts +1 -0
  33. package/constants/subscription/enums/subscription-plan.enum.ts +1 -0
  34. package/constants/subscription/enums/user-to-subscription-marks.enum.ts +1 -0
  35. package/constants/subscription/free-subscription.constant.ts +22 -2
  36. package/models/ai-model-formatted.schema.ts +1 -1
  37. package/models/ai-model.schema.ts +9 -0
  38. package/models/index.ts +3 -1
  39. package/models/user-to-product.schema.ts +18 -0
  40. package/models/utm.schema.ts +15 -0
  41. package/package.json +1 -1
@@ -7,4 +7,5 @@ export const PRODUCT_ROUTES = {
7
7
  GET_ALL: 'all',
8
8
  BUY: `buy`,
9
9
  FAST_BUY: `fast/buy`,
10
+ MY: 'my',
10
11
  } as const;
@@ -14,4 +14,5 @@ export const SUBSCRIPTION_ROUTES = {
14
14
  UPGRADE: 'upgrade',
15
15
  CREATE_CUSTOM: 'custom',
16
16
  FREE: 'free',
17
+ SUMMARY: 'summary',
17
18
  } as const;
package/api/routes.ts CHANGED
@@ -103,6 +103,7 @@ export const REST_API = {
103
103
  CREATE: `${ROOT}/${CONTROLLERS.PRODUCT_PRIVATE_CONTROLLER}`,
104
104
  BUY: (uuid: string) =>
105
105
  `${ROOT}/${CONTROLLERS.PRODUCT_PRIVATE_CONTROLLER}/${CONTROLLERS.PRODUCT_ROUTES.BUY}/${uuid}`,
106
+ MY: `${ROOT}/${CONTROLLERS.PRODUCT_PRIVATE_CONTROLLER}/${CONTROLLERS.PRODUCT_ROUTES.MY}`,
106
107
  },
107
108
  SUBSCRIPTION_PUBLIC: {
108
109
  GET: `${ROOT}/${CONTROLLERS.SUBSCRIPTION_PUBLIC_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.GET_ALL}`,
@@ -128,6 +129,7 @@ export const REST_API = {
128
129
  GET_AVAILABLE_UPGRADES: (uuid: string) =>
129
130
  `${ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${uuid}/${CONTROLLERS.SUBSCRIPTION_ROUTES.GET_AVAILABLE_UPGRADES}`,
130
131
  CREATE_CUSTOM: `${ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.CREATE_CUSTOM}`,
132
+ SUMMARY: `${ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.SUMMARY}`,
131
133
  },
132
134
  FILES: {
133
135
  UPLOAD_FILE: `${ROOT}/${CONTROLLERS.FILE_CONTROLLER}/${CONTROLLERS.FILE_ROUTES.UPLOAD_FILE}`,
@@ -8,4 +8,5 @@ exports.PRODUCT_ROUTES = {
8
8
  GET_ALL: 'all',
9
9
  BUY: `buy`,
10
10
  FAST_BUY: `fast/buy`,
11
+ MY: 'my',
11
12
  };
@@ -15,4 +15,5 @@ exports.SUBSCRIPTION_ROUTES = {
15
15
  UPGRADE: 'upgrade',
16
16
  CREATE_CUSTOM: 'custom',
17
17
  FREE: 'free',
18
+ SUMMARY: 'summary',
18
19
  };
@@ -123,6 +123,7 @@ exports.REST_API = {
123
123
  DELETE: (uuid) => `${exports.ROOT}/${CONTROLLERS.PRODUCT_PRIVATE_CONTROLLER}/${uuid}`,
124
124
  CREATE: `${exports.ROOT}/${CONTROLLERS.PRODUCT_PRIVATE_CONTROLLER}`,
125
125
  BUY: (uuid) => `${exports.ROOT}/${CONTROLLERS.PRODUCT_PRIVATE_CONTROLLER}/${CONTROLLERS.PRODUCT_ROUTES.BUY}/${uuid}`,
126
+ MY: `${exports.ROOT}/${CONTROLLERS.PRODUCT_PRIVATE_CONTROLLER}/${CONTROLLERS.PRODUCT_ROUTES.MY}`,
126
127
  },
127
128
  SUBSCRIPTION_PUBLIC: {
128
129
  GET: `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_PUBLIC_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.GET_ALL}`,
@@ -141,6 +142,7 @@ exports.REST_API = {
141
142
  UPGRADE: (uuid) => `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${uuid}/${CONTROLLERS.SUBSCRIPTION_ROUTES.UPGRADE}`,
142
143
  GET_AVAILABLE_UPGRADES: (uuid) => `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${uuid}/${CONTROLLERS.SUBSCRIPTION_ROUTES.GET_AVAILABLE_UPGRADES}`,
143
144
  CREATE_CUSTOM: `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.CREATE_CUSTOM}`,
145
+ SUMMARY: `${exports.ROOT}/${CONTROLLERS.SUBSCRIPTION_PRIVATE_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_ROUTES.SUMMARY}`,
144
146
  },
145
147
  FILES: {
146
148
  UPLOAD_FILE: `${exports.ROOT}/${CONTROLLERS.FILE_CONTROLLER}/${CONTROLLERS.FILE_ROUTES.UPLOAD_FILE}`,
@@ -9,7 +9,7 @@ var FindAIModelCommand;
9
9
  uuid: true,
10
10
  });
11
11
  FindAIModelCommand.ResponseSchema = zod_1.z.object({
12
- data: zod_1.z.array(models_1.AiModelSchema),
12
+ data: zod_1.z.array(models_1.AiModelWithUnlockedBySchema),
13
13
  });
14
14
  FindAIModelCommand.ResponseByUUIDSchema = zod_1.z.object({
15
15
  data: models_1.AiModelSchema,
@@ -5,9 +5,13 @@ const models_1 = require("../../models");
5
5
  const zod_1 = require("zod");
6
6
  var RegisterUserCommand;
7
7
  (function (RegisterUserCommand) {
8
- RegisterUserCommand.RequestSchema = zod_1.z.intersection(models_1.UserSchema.pick({ email: true, password: true }), zod_1.z.object({
9
- partnerId: zod_1.z.string().uuid().optional(),
10
- }));
8
+ RegisterUserCommand.RequestSchema = models_1.UserSchema.pick({ email: true, password: true })
9
+ .extend({
10
+ partnerId: zod_1.z.string().optional(),
11
+ })
12
+ .extend({
13
+ utm: models_1.UtmSchema.optional(),
14
+ });
11
15
  RegisterUserCommand.ResponseSchema = zod_1.z.object({
12
16
  data: zod_1.z.object({
13
17
  accessToken: zod_1.z.string(),
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetMyProductsCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
6
+ var GetMyProductsCommand;
7
+ (function (GetMyProductsCommand) {
8
+ GetMyProductsCommand.ResponseSchema = zod_1.z.object({
9
+ data: zod_1.z.array(models_1.UserToProductWithProductSchema),
10
+ });
11
+ })(GetMyProductsCommand || (exports.GetMyProductsCommand = GetMyProductsCommand = {}));
@@ -18,4 +18,5 @@ __exportStar(require("./buy-product.command"), exports);
18
18
  __exportStar(require("./create-product.command"), exports);
19
19
  __exportStar(require("./delete-product.command"), exports);
20
20
  __exportStar(require("./find-product.command"), exports);
21
+ __exportStar(require("./get-my-products.command"), exports);
21
22
  __exportStar(require("./update-product.command"), exports);
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetSubscriptionsSummaryCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
6
+ var GetSubscriptionsSummaryCommand;
7
+ (function (GetSubscriptionsSummaryCommand) {
8
+ GetSubscriptionsSummaryCommand.ResponseSchema = zod_1.z.object({
9
+ features: zod_1.z.array(models_1.SubscriptionFeatureSchema),
10
+ subscriptions: zod_1.z.array(models_1.UserToSubscriptionWithSubscriptionSchema),
11
+ products: zod_1.z.array(models_1.UserToProductWithProductSchema),
12
+ });
13
+ })(GetSubscriptionsSummaryCommand || (exports.GetSubscriptionsSummaryCommand = GetSubscriptionsSummaryCommand = {}));
@@ -22,6 +22,7 @@ __exportStar(require("./delete-subscription.command"), exports);
22
22
  __exportStar(require("./find-subscription.command"), exports);
23
23
  __exportStar(require("./get-available-upgrades.command"), exports);
24
24
  __exportStar(require("./get-free-subscription.command"), exports);
25
+ __exportStar(require("./get-subscriptions-summary.command"), exports);
25
26
  __exportStar(require("./recover-subscription.command"), exports);
26
27
  __exportStar(require("./update-subscription.command"), exports);
27
28
  __exportStar(require("./upgrade-subscription.command"), exports);
@@ -2,12 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AuthWithTelegramWebAppCommand = void 0;
4
4
  const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
5
6
  var AuthWithTelegramWebAppCommand;
6
7
  (function (AuthWithTelegramWebAppCommand) {
7
8
  AuthWithTelegramWebAppCommand.RequestBodySchema = zod_1.z.object({
8
9
  initData: zod_1.z.string(),
9
10
  platform: zod_1.z.string().nullable(),
10
11
  partnerId: zod_1.z.string().optional(),
12
+ utm: models_1.UtmSchema.optional(),
11
13
  });
12
14
  AuthWithTelegramWebAppCommand.ResponseSchema = zod_1.z.object({
13
15
  data: zod_1.z.object({
@@ -960,4 +960,9 @@ exports.ERRORS = {
960
960
  message: 'Произошла ошибка при проверке ограничений на длину запроса для чата',
961
961
  httpCode: 500,
962
962
  },
963
+ UTM_SAVE_ERROR: {
964
+ code: 'A218',
965
+ message: 'Произошла ошибка при сохранении UTM',
966
+ httpCode: 500,
967
+ },
963
968
  };
@@ -5,4 +5,5 @@ var PRODUCT_STATUS;
5
5
  (function (PRODUCT_STATUS) {
6
6
  PRODUCT_STATUS["active"] = "active";
7
7
  PRODUCT_STATUS["canceled"] = "canceled";
8
+ PRODUCT_STATUS["depleted"] = "depleted";
8
9
  })(PRODUCT_STATUS || (exports.PRODUCT_STATUS = PRODUCT_STATUS = {}));
@@ -5,4 +5,5 @@ var SUBSCRIPTION_PLAN;
5
5
  (function (SUBSCRIPTION_PLAN) {
6
6
  SUBSCRIPTION_PLAN["system"] = "system";
7
7
  SUBSCRIPTION_PLAN["custom"] = "custom";
8
+ SUBSCRIPTION_PLAN["mock"] = "mock";
8
9
  })(SUBSCRIPTION_PLAN || (exports.SUBSCRIPTION_PLAN = SUBSCRIPTION_PLAN = {}));
@@ -4,4 +4,5 @@ exports.USER_TO_SUBSCRIPTION_MARKS = void 0;
4
4
  var USER_TO_SUBSCRIPTION_MARKS;
5
5
  (function (USER_TO_SUBSCRIPTION_MARKS) {
6
6
  USER_TO_SUBSCRIPTION_MARKS["WITHOUT_AUTO_RENEWAL"] = "WITHOUT_AUTO_RENEWAL";
7
+ USER_TO_SUBSCRIPTION_MARKS["MOCK"] = "MOCK";
7
8
  })(USER_TO_SUBSCRIPTION_MARKS || (exports.USER_TO_SUBSCRIPTION_MARKS = USER_TO_SUBSCRIPTION_MARKS = {}));
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FREE_SUBSCRIPTION_DATA = void 0;
3
+ exports.FREE_USER_TO_SUBSCRIPTION_DATA = exports.FREE_SUBSCRIPTION_DATA = void 0;
4
4
  const enums_1 = require("./enums");
5
5
  exports.FREE_SUBSCRIPTION_DATA = {
6
6
  uuid: '00000000-0000-0000-0000-000000000000',
@@ -13,9 +13,23 @@ exports.FREE_SUBSCRIPTION_DATA = {
13
13
  discount: 0,
14
14
  maxDiscountPercent: 0,
15
15
  period: 1,
16
- plan: enums_1.SUBSCRIPTION_PLAN.system,
16
+ plan: enums_1.SUBSCRIPTION_PLAN.mock,
17
17
  icon: 'https://rugpt.hb.bizmrg.com/images/images/ac095d48-a66b-4862-82c7-eb120b5bd467.svg',
18
18
  interval: '',
19
19
  createdAt: new Date(),
20
20
  updatedAt: new Date(),
21
21
  };
22
+ exports.FREE_USER_TO_SUBSCRIPTION_DATA = {
23
+ uuid: '00000000-0000-0000-0000-000000000000',
24
+ userId: '00000000-0000-0000-0000-000000000000',
25
+ subscriptionId: '00000000-0000-0000-0000-000000000000',
26
+ initTokenBalance: 0,
27
+ active: true,
28
+ tokenBalance: 0,
29
+ status: enums_1.SUBSCRIPTION_STATUS.active,
30
+ endDate: null,
31
+ marks: [enums_1.USER_TO_SUBSCRIPTION_MARKS.MOCK],
32
+ intervalEndDate: null,
33
+ createdAt: new Date(),
34
+ updatedAt: new Date(),
35
+ };
@@ -4,4 +4,4 @@ exports.AiModelFormmattedSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const ai_model_schema_1 = require("./ai-model.schema");
6
6
  const page_schema_1 = require("./page.schema");
7
- exports.AiModelFormmattedSchema = zod_1.z.intersection(ai_model_schema_1.AiModelSchema, zod_1.z.object({ page: page_schema_1.PageSchema.pick({ alias: true }).optional() }));
7
+ exports.AiModelFormmattedSchema = zod_1.z.intersection(ai_model_schema_1.AiModelSchema, zod_1.z.object({ page: page_schema_1.PageSchema.pick({ alias: true }).optional().nullable() }));
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AiModelSchema = void 0;
3
+ exports.AiModelWithUnlockedBySchema = exports.AiModelSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const constants_1 = require("../constants");
6
6
  exports.AiModelSchema = zod_1.z.object({
@@ -21,3 +21,11 @@ exports.AiModelSchema = zod_1.z.object({
21
21
  createdAt: zod_1.z.date(),
22
22
  updatedAt: zod_1.z.date(),
23
23
  });
24
+ exports.AiModelWithUnlockedBySchema = exports.AiModelSchema.extend({
25
+ unlockedBy: zod_1.z
26
+ .object({
27
+ uuid: zod_1.z.string().uuid(),
28
+ name: zod_1.z.string(),
29
+ })
30
+ .nullable(),
31
+ });
@@ -33,6 +33,7 @@ __exportStar(require("./payment-history-item.schema"), exports);
33
33
  __exportStar(require("./payment.schema"), exports);
34
34
  __exportStar(require("./post.schema"), exports);
35
35
  __exportStar(require("./product.schema"), exports);
36
+ __exportStar(require("./promocode.schema"), exports);
36
37
  __exportStar(require("./question.schema"), exports);
37
38
  __exportStar(require("./referral-bonus.schema"), exports);
38
39
  __exportStar(require("./section.schema"), exports);
@@ -42,6 +43,7 @@ __exportStar(require("./subscription.schema"), exports);
42
43
  __exportStar(require("./telegram-user-data.schema"), exports);
43
44
  __exportStar(require("./unregistered-user.schema"), exports);
44
45
  __exportStar(require("./user-task.schema"), exports);
46
+ __exportStar(require("./user-to-product.schema"), exports);
45
47
  __exportStar(require("./user-to-subscription.schema"), exports);
46
48
  __exportStar(require("./user.schema"), exports);
47
- __exportStar(require("./promocode.schema"), exports);
49
+ __exportStar(require("./utm.schema"), exports);
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserToProductWithProductSchema = exports.UserToProductSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const product_schema_1 = require("./product.schema");
6
+ const constants_1 = require("../constants");
7
+ exports.UserToProductSchema = zod_1.z.object({
8
+ uuid: zod_1.z.string().uuid(),
9
+ userId: zod_1.z.string().uuid(),
10
+ productId: zod_1.z.string().uuid(),
11
+ initTokenBalance: zod_1.z.number(),
12
+ tokenBalance: zod_1.z.number(),
13
+ status: zod_1.z.nativeEnum(constants_1.PRODUCT_STATUS),
14
+ createdAt: zod_1.z.date(),
15
+ updatedAt: zod_1.z.date(),
16
+ });
17
+ exports.UserToProductWithProductSchema = exports.UserToProductSchema.extend({
18
+ product: product_schema_1.ProductSchema,
19
+ });
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UtmSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.UtmSchema = zod_1.z
6
+ .object({
7
+ utmSource: zod_1.z.string().optional().nullable(),
8
+ utmMedium: zod_1.z.string().optional().nullable(),
9
+ utmCampaign: zod_1.z.string().optional().nullable(),
10
+ utmContent: zod_1.z.string().optional().nullable(),
11
+ utmTerm: zod_1.z.string().optional().nullable(),
12
+ })
13
+ .refine((data) => Object.values(data).some((value) => value != null && value !== ''), {
14
+ message: 'At least one UTM parameter must be provided',
15
+ });
@@ -1,4 +1,4 @@
1
- import { AiModelSchema } from '../../models';
1
+ import { AiModelSchema, AiModelWithUnlockedBySchema } from '../../models';
2
2
  import { z } from 'zod';
3
3
 
4
4
  export namespace FindAIModelCommand {
@@ -9,7 +9,7 @@ export namespace FindAIModelCommand {
9
9
  export type Request = z.infer<typeof RequestSchema>;
10
10
 
11
11
  export const ResponseSchema = z.object({
12
- data: z.array(AiModelSchema),
12
+ data: z.array(AiModelWithUnlockedBySchema),
13
13
  });
14
14
 
15
15
  export type Response = z.infer<typeof ResponseSchema>;
@@ -1,13 +1,14 @@
1
- import { UserSchema } from '../../models';
1
+ import { UserSchema, UtmSchema } from '../../models';
2
2
  import { z } from 'zod';
3
3
 
4
4
  export namespace RegisterUserCommand {
5
- export const RequestSchema = z.intersection(
6
- UserSchema.pick({ email: true, password: true }),
7
- z.object({
8
- partnerId: z.string().uuid().optional(),
9
- }),
10
- );
5
+ export const RequestSchema = UserSchema.pick({ email: true, password: true })
6
+ .extend({
7
+ partnerId: z.string().optional(),
8
+ })
9
+ .extend({
10
+ utm: UtmSchema.optional(),
11
+ });
11
12
 
12
13
  export type Request = z.infer<typeof RequestSchema>;
13
14
 
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+ import { UserToProductWithProductSchema } from '../../models';
3
+
4
+ export namespace GetMyProductsCommand {
5
+ export const ResponseSchema = z.object({
6
+ data: z.array(UserToProductWithProductSchema),
7
+ });
8
+
9
+ export type Response = z.infer<typeof ResponseSchema>;
10
+ }
@@ -2,4 +2,5 @@ export * from './buy-product.command';
2
2
  export * from './create-product.command';
3
3
  export * from './delete-product.command';
4
4
  export * from './find-product.command';
5
+ export * from './get-my-products.command';
5
6
  export * from './update-product.command';
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ import {
3
+ SubscriptionFeatureSchema,
4
+ UserToProductWithProductSchema,
5
+ UserToSubscriptionWithSubscriptionSchema,
6
+ } from '../../models';
7
+
8
+ export namespace GetSubscriptionsSummaryCommand {
9
+ export const ResponseSchema = z.object({
10
+ features: z.array(SubscriptionFeatureSchema),
11
+ subscriptions: z.array(UserToSubscriptionWithSubscriptionSchema),
12
+ products: z.array(UserToProductWithProductSchema),
13
+ });
14
+
15
+ export type Response = z.infer<typeof ResponseSchema>;
16
+ }
@@ -6,6 +6,7 @@ export * from './delete-subscription.command';
6
6
  export * from './find-subscription.command';
7
7
  export * from './get-available-upgrades.command';
8
8
  export * from './get-free-subscription.command';
9
+ export * from './get-subscriptions-summary.command';
9
10
  export * from './recover-subscription.command';
10
11
  export * from './update-subscription.command';
11
12
  export * from './upgrade-subscription.command';
@@ -1,10 +1,12 @@
1
1
  import { z } from 'zod';
2
+ import { UtmSchema } from '../../models';
2
3
 
3
4
  export namespace AuthWithTelegramWebAppCommand {
4
5
  export const RequestBodySchema = z.object({
5
6
  initData: z.string(),
6
7
  platform: z.string().nullable(),
7
8
  partnerId: z.string().optional(),
9
+ utm: UtmSchema.optional(),
8
10
  });
9
11
 
10
12
  export type Request = z.infer<typeof RequestBodySchema>;
@@ -963,4 +963,9 @@ export const ERRORS = {
963
963
  message: 'Произошла ошибка при проверке ограничений на длину запроса для чата',
964
964
  httpCode: 500,
965
965
  },
966
+ UTM_SAVE_ERROR: {
967
+ code: 'A218',
968
+ message: 'Произошла ошибка при сохранении UTM',
969
+ httpCode: 500,
970
+ },
966
971
  };
@@ -1,4 +1,5 @@
1
1
  export enum PRODUCT_STATUS {
2
2
  active = 'active',
3
3
  canceled = 'canceled',
4
+ depleted = 'depleted',
4
5
  }
@@ -1,4 +1,5 @@
1
1
  export enum SUBSCRIPTION_PLAN {
2
2
  system = 'system',
3
3
  custom = 'custom',
4
+ mock = 'mock', // Does not exist in DB
4
5
  }
@@ -1,3 +1,4 @@
1
1
  export enum USER_TO_SUBSCRIPTION_MARKS {
2
2
  WITHOUT_AUTO_RENEWAL = 'WITHOUT_AUTO_RENEWAL',
3
+ MOCK = 'MOCK',
3
4
  }
@@ -1,4 +1,9 @@
1
- import { SUBSCRIPTION_PLAN, SUBSCRIPTION_TYPE } from './enums';
1
+ import {
2
+ SUBSCRIPTION_PLAN,
3
+ SUBSCRIPTION_STATUS,
4
+ SUBSCRIPTION_TYPE,
5
+ USER_TO_SUBSCRIPTION_MARKS,
6
+ } from './enums';
2
7
 
3
8
  export const FREE_SUBSCRIPTION_DATA = {
4
9
  uuid: '00000000-0000-0000-0000-000000000000',
@@ -11,9 +16,24 @@ export const FREE_SUBSCRIPTION_DATA = {
11
16
  discount: 0,
12
17
  maxDiscountPercent: 0,
13
18
  period: 1,
14
- plan: SUBSCRIPTION_PLAN.system,
19
+ plan: SUBSCRIPTION_PLAN.mock,
15
20
  icon: 'https://rugpt.hb.bizmrg.com/images/images/ac095d48-a66b-4862-82c7-eb120b5bd467.svg',
16
21
  interval: '',
17
22
  createdAt: new Date(),
18
23
  updatedAt: new Date(),
19
24
  };
25
+
26
+ export const FREE_USER_TO_SUBSCRIPTION_DATA = {
27
+ uuid: '00000000-0000-0000-0000-000000000000',
28
+ userId: '00000000-0000-0000-0000-000000000000',
29
+ subscriptionId: '00000000-0000-0000-0000-000000000000',
30
+ initTokenBalance: 0,
31
+ active: true,
32
+ tokenBalance: 0,
33
+ status: SUBSCRIPTION_STATUS.active,
34
+ endDate: null,
35
+ marks: [USER_TO_SUBSCRIPTION_MARKS.MOCK],
36
+ intervalEndDate: null,
37
+ createdAt: new Date(),
38
+ updatedAt: new Date(),
39
+ };
@@ -4,5 +4,5 @@ import { PageSchema } from './page.schema';
4
4
 
5
5
  export const AiModelFormmattedSchema = z.intersection(
6
6
  AiModelSchema,
7
- z.object({ page: PageSchema.pick({ alias: true }).optional() }),
7
+ z.object({ page: PageSchema.pick({ alias: true }).optional().nullable() }),
8
8
  );
@@ -24,3 +24,12 @@ export const AiModelSchema = z.object({
24
24
  createdAt: z.date(),
25
25
  updatedAt: z.date(),
26
26
  });
27
+
28
+ export const AiModelWithUnlockedBySchema = AiModelSchema.extend({
29
+ unlockedBy: z
30
+ .object({
31
+ uuid: z.string().uuid(),
32
+ name: z.string(),
33
+ })
34
+ .nullable(),
35
+ });
package/models/index.ts CHANGED
@@ -17,6 +17,7 @@ export * from './payment-history-item.schema';
17
17
  export * from './payment.schema';
18
18
  export * from './post.schema';
19
19
  export * from './product.schema';
20
+ export * from './promocode.schema';
20
21
  export * from './question.schema';
21
22
  export * from './referral-bonus.schema';
22
23
  export * from './section.schema';
@@ -26,6 +27,7 @@ export * from './subscription.schema';
26
27
  export * from './telegram-user-data.schema';
27
28
  export * from './unregistered-user.schema';
28
29
  export * from './user-task.schema';
30
+ export * from './user-to-product.schema';
29
31
  export * from './user-to-subscription.schema';
30
32
  export * from './user.schema';
31
- export * from './promocode.schema';
33
+ export * from './utm.schema';
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ import { ProductSchema } from './product.schema';
3
+ import { PRODUCT_STATUS } from '../constants';
4
+
5
+ export const UserToProductSchema = z.object({
6
+ uuid: z.string().uuid(),
7
+ userId: z.string().uuid(),
8
+ productId: z.string().uuid(),
9
+ initTokenBalance: z.number(),
10
+ tokenBalance: z.number(),
11
+ status: z.nativeEnum(PRODUCT_STATUS),
12
+ createdAt: z.date(),
13
+ updatedAt: z.date(),
14
+ });
15
+
16
+ export const UserToProductWithProductSchema = UserToProductSchema.extend({
17
+ product: ProductSchema,
18
+ });
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod';
2
+
3
+ export const UtmSchema = z
4
+ .object({
5
+ utmSource: z.string().optional().nullable(),
6
+ utmMedium: z.string().optional().nullable(),
7
+ utmCampaign: z.string().optional().nullable(),
8
+ utmContent: z.string().optional().nullable(),
9
+ utmTerm: z.string().optional().nullable(),
10
+ })
11
+ .refine((data) => Object.values(data).some((value) => value != null && value !== ''), {
12
+ message: 'At least one UTM parameter must be provided',
13
+ });
14
+
15
+ export type Utm = z.infer<typeof UtmSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.5.53",
3
+ "version": "0.5.55",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",