@purpleschool/gptbot 0.7.72 → 0.7.74

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 (37) hide show
  1. package/api/controllers/http/promocode.ts +0 -1
  2. package/api/controllers/http/webmaster.ts +1 -1
  3. package/build/api/controllers/http/promocode.js +0 -1
  4. package/build/api/controllers/http/webmaster.js +1 -1
  5. package/build/commands/auth/register-user.command.js +2 -4
  6. package/build/commands/auth/vk-login.command.js +5 -2
  7. package/build/commands/auth/yandex-login.command.js +5 -2
  8. package/build/commands/product/buy-product.command.js +4 -0
  9. package/build/commands/promocode/index.js +0 -1
  10. package/build/commands/subscription/buy-subscription.command.js +4 -0
  11. package/build/commands/telegram-auth/create-telegram-auth-link.command.js +2 -0
  12. package/build/commands/telegram-profile/auth-with-telegram-web-app.command.js +4 -0
  13. package/build/commands/user/get-me.command.js +1 -0
  14. package/build/constants/errors/errors.js +5 -0
  15. package/build/constants/promocode/enums/promocode-promotion.enum.js +0 -1
  16. package/build/models/index.js +1 -0
  17. package/build/models/promocode.schema.js +0 -1
  18. package/build/models/user-referrals.schema.js +15 -0
  19. package/build/models/webmaster-balance.schema.js +0 -1
  20. package/commands/auth/register-user.command.ts +3 -5
  21. package/commands/auth/vk-login.command.ts +9 -6
  22. package/commands/auth/yandex-login.command.ts +7 -4
  23. package/commands/product/buy-product.command.ts +4 -0
  24. package/commands/promocode/index.ts +0 -1
  25. package/commands/subscription/buy-subscription.command.ts +4 -0
  26. package/commands/telegram-auth/create-telegram-auth-link.command.ts +5 -0
  27. package/commands/telegram-profile/auth-with-telegram-web-app.command.ts +4 -0
  28. package/commands/user/get-me.command.ts +1 -0
  29. package/constants/errors/errors.ts +5 -0
  30. package/constants/promocode/enums/promocode-promotion.enum.ts +0 -1
  31. package/models/index.ts +1 -0
  32. package/models/promocode.schema.ts +0 -1
  33. package/models/user-referrals.schema.ts +10 -0
  34. package/models/webmaster-balance.schema.ts +0 -1
  35. package/package.json +1 -1
  36. package/build/commands/promocode/get-webmaster-promocode.command.js +0 -17
  37. package/commands/promocode/get-webmaster-promocode.command.ts +0 -19
@@ -6,5 +6,4 @@ export const PROMOCODE_ROUTES = {
6
6
  VALIDATE: 'validate',
7
7
  FIND_BY_UUID: 'by/uuid',
8
8
  UPSELL: 'upsell',
9
- WEBMASTER: 'referral',
10
9
  } as const;
@@ -1,4 +1,4 @@
1
- export const WEBMASTER_CONTROLLER_PRIVATE = 'private/referral' as const;
1
+ export const WEBMASTER_CONTROLLER_PRIVATE = 'private/webmaster' as const;
2
2
 
3
3
  export const WEBMASTER_ROUTES = {
4
4
  GET_MY: 'my',
@@ -8,5 +8,4 @@ exports.PROMOCODE_ROUTES = {
8
8
  VALIDATE: 'validate',
9
9
  FIND_BY_UUID: 'by/uuid',
10
10
  UPSELL: 'upsell',
11
- WEBMASTER: 'referral',
12
11
  };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WEBMASTER_ROUTES = exports.WEBMASTER_CONTROLLER_PRIVATE = void 0;
4
- exports.WEBMASTER_CONTROLLER_PRIVATE = 'private/referral';
4
+ exports.WEBMASTER_CONTROLLER_PRIVATE = 'private/webmaster';
5
5
  exports.WEBMASTER_ROUTES = {
6
6
  GET_MY: 'my',
7
7
  GET_BALANCE_OVERVIEW: 'overview',
@@ -6,12 +6,10 @@ const zod_1 = require("zod");
6
6
  var RegisterUserCommand;
7
7
  (function (RegisterUserCommand) {
8
8
  RegisterUserCommand.RequestSchema = models_1.UserSchema.pick({ email: true, password: true })
9
- .extend({
10
- partnerId: zod_1.z.string().optional(),
11
- })
12
9
  .extend({
13
10
  utm: models_1.UtmSchema.optional(),
14
- });
11
+ })
12
+ .merge(models_1.UserReferralsSchema);
15
13
  RegisterUserCommand.ResponseSchema = zod_1.z.object({
16
14
  data: zod_1.z.object({
17
15
  accessToken: zod_1.z.string(),
@@ -2,14 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VKLoginCommand = void 0;
4
4
  const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
5
6
  var VKLoginCommand;
6
7
  (function (VKLoginCommand) {
7
- VKLoginCommand.RequestSchema = zod_1.z.object({
8
+ VKLoginCommand.RequestSchema = zod_1.z
9
+ .object({
8
10
  code: zod_1.z.string(),
9
11
  code_verifier: zod_1.z.string(),
10
12
  device_id: zod_1.z.string(),
11
13
  state: zod_1.z.string(),
12
- });
14
+ })
15
+ .merge(models_1.UserReferralsSchema);
13
16
  VKLoginCommand.ResponseSchema = zod_1.z.object({
14
17
  data: zod_1.z.object({
15
18
  accessToken: zod_1.z.string(),
@@ -2,12 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.YandexLoginCommand = void 0;
4
4
  const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
5
6
  var YandexLoginCommand;
6
7
  (function (YandexLoginCommand) {
7
- YandexLoginCommand.RequestSchema = zod_1.z.object({
8
+ YandexLoginCommand.RequestSchema = zod_1.z
9
+ .object({
8
10
  code: zod_1.z.string(),
9
11
  code_verifier: zod_1.z.string(),
10
- });
12
+ })
13
+ .merge(models_1.UserReferralsSchema);
11
14
  YandexLoginCommand.ResponseSchema = zod_1.z.object({
12
15
  data: zod_1.z.object({
13
16
  accessToken: zod_1.z.string(),
@@ -30,6 +30,10 @@ var BuyProductCommand;
30
30
  email: zod_1.z.string().email(),
31
31
  partnerId: zod_1.z.string().uuid().optional(),
32
32
  promocode: zod_1.z.string().optional(),
33
+ webmasterAlias: zod_1.z.string().optional(),
34
+ webmasterReferralProvidedAt: zod_1.z
35
+ .preprocess((val) => (typeof val === 'string' ? new Date(val) : val), zod_1.z.date())
36
+ .optional(),
33
37
  });
34
38
  BuyProductCommand.ResponseSchema = zod_1.z.object({
35
39
  publicId: zod_1.z.string(),
@@ -20,4 +20,3 @@ __exportStar(require("./find-promocode.command"), exports);
20
20
  __exportStar(require("./get-upsell-offer.command"), exports);
21
21
  __exportStar(require("./update-promocode.command"), exports);
22
22
  __exportStar(require("./validate-promocode.command"), exports);
23
- __exportStar(require("./get-webmaster-promocode.command"), exports);
@@ -16,6 +16,10 @@ var BuySubscriptionCommand;
16
16
  email: zod_1.z.string().email(),
17
17
  partnerId: zod_1.z.string().uuid().optional(),
18
18
  promocode: zod_1.z.string().optional(),
19
+ webmasterAlias: zod_1.z.string().optional(),
20
+ webmasterReferralProvidedAt: zod_1.z
21
+ .preprocess((val) => (typeof val === 'string' ? new Date(val) : val), zod_1.z.date())
22
+ .optional(),
19
23
  });
20
24
  const IReceiptOrderSchema = zod_1.z.object({
21
25
  items: zod_1.z.array(zod_1.z.object({
@@ -2,8 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CreateTelegramAuthLinkCommand = void 0;
4
4
  const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
5
6
  var CreateTelegramAuthLinkCommand;
6
7
  (function (CreateTelegramAuthLinkCommand) {
8
+ CreateTelegramAuthLinkCommand.RequestSchema = models_1.UserReferralsSchema;
7
9
  CreateTelegramAuthLinkCommand.ResponseSchema = zod_1.z.object({
8
10
  data: zod_1.z.object({
9
11
  uuid: zod_1.z.string().uuid(),
@@ -9,6 +9,10 @@ var AuthWithTelegramWebAppCommand;
9
9
  initData: zod_1.z.string(),
10
10
  platform: zod_1.z.string().nullable(),
11
11
  partnerId: zod_1.z.string().optional(),
12
+ webmasterAlias: zod_1.z.string().optional(),
13
+ webmasterReferralProvidedAt: zod_1.z
14
+ .preprocess((val) => (typeof val === 'string' ? new Date(val) : val), zod_1.z.date())
15
+ .optional(),
12
16
  utm: models_1.UtmSchema.optional(),
13
17
  });
14
18
  AuthWithTelegramWebAppCommand.ResponseSchema = zod_1.z.object({
@@ -14,6 +14,7 @@ var GetMeCommand;
14
14
  role: zod_1.z.nativeEnum(constants_1.ROLE),
15
15
  signupMethod: zod_1.z.nativeEnum(constants_1.SIGNUP_METHOD),
16
16
  telegramId: zod_1.z.number().nullable(),
17
+ webmasterId: zod_1.z.string().uuid().nullable(),
17
18
  }),
18
19
  });
19
20
  })(GetMeCommand || (exports.GetMeCommand = GetMeCommand = {}));
@@ -2279,4 +2279,9 @@ exports.ERRORS = {
2279
2279
  message: 'У вас нет доступа к этой модели Writer',
2280
2280
  httpCode: 403,
2281
2281
  },
2282
+ WEBMASTER_BONUS_APPLY_ERROR: {
2283
+ code: 'A449',
2284
+ message: 'Не удалось применить бонусы вебмастеру',
2285
+ httpCode: 500,
2286
+ },
2282
2287
  };
@@ -6,5 +6,4 @@ var PROMOCODE_PROMOTION;
6
6
  PROMOCODE_PROMOTION["BONUS"] = "bonus";
7
7
  PROMOCODE_PROMOTION["CHAT_UPSELL"] = "chat_upsell";
8
8
  PROMOCODE_PROMOTION["DAILY_STREAK"] = "daily_streak";
9
- PROMOCODE_PROMOTION["WEBMASTER"] = "webmaster";
10
9
  })(PROMOCODE_PROMOTION || (exports.PROMOCODE_PROMOTION = PROMOCODE_PROMOTION = {}));
@@ -68,3 +68,4 @@ __exportStar(require("./users-filter-notification.schema"), exports);
68
68
  __exportStar(require("./daily-streak"), exports);
69
69
  __exportStar(require("./webmaster.schema"), exports);
70
70
  __exportStar(require("./webmaster-balance.schema"), exports);
71
+ __exportStar(require("./user-referrals.schema"), exports);
@@ -15,7 +15,6 @@ exports.PromocodeSchema = zod_1.z.object({
15
15
  endDate: zod_1.z.date().nullable(),
16
16
  userId: zod_1.z.string().uuid().nullable(),
17
17
  unregisteredUserId: zod_1.z.string().uuid().nullable(),
18
- webmasterId: zod_1.z.string().uuid().nullable(),
19
18
  createdAt: zod_1.z.date(),
20
19
  updatedAt: zod_1.z.date(),
21
20
  });
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.UserReferralsSchema = void 0;
7
+ const zod_1 = __importDefault(require("zod"));
8
+ exports.UserReferralsSchema = zod_1.default.object({
9
+ partnerId: zod_1.default.string().uuid().optional(),
10
+ webmasterAlias: zod_1.default.string().optional(),
11
+ webmasterReferralProvidedAt: zod_1.default
12
+ .string()
13
+ .transform((date) => new Date(date))
14
+ .optional(),
15
+ });
@@ -10,7 +10,6 @@ exports.WebmasterBalanceSchema = zod_1.default.object({
10
10
  uuid: zod_1.default.string().uuid(),
11
11
  webmasterId: zod_1.default.string().uuid(),
12
12
  orderId: zod_1.default.string().uuid().nullable(),
13
- promocodeId: zod_1.default.string().uuid().nullable(),
14
13
  sourceUserId: zod_1.default.string().uuid().nullable(),
15
14
  amount: zod_1.default.number(),
16
15
  type: zod_1.default.nativeEnum(constants_1.WEBMASTER_BALANCE_TYPE),
@@ -1,14 +1,12 @@
1
- import { UserSchema, UtmSchema } from '../../models';
1
+ import { UserReferralsSchema, UserSchema, UtmSchema } from '../../models';
2
2
  import { z } from 'zod';
3
3
 
4
4
  export namespace RegisterUserCommand {
5
5
  export const RequestSchema = UserSchema.pick({ email: true, password: true })
6
- .extend({
7
- partnerId: z.string().optional(),
8
- })
9
6
  .extend({
10
7
  utm: UtmSchema.optional(),
11
- });
8
+ })
9
+ .merge(UserReferralsSchema);
12
10
 
13
11
  export type Request = z.infer<typeof RequestSchema>;
14
12
 
@@ -1,12 +1,15 @@
1
1
  import { z } from 'zod';
2
+ import { UserReferralsSchema } from '../../models';
2
3
 
3
4
  export namespace VKLoginCommand {
4
- export const RequestSchema = z.object({
5
- code: z.string(),
6
- code_verifier: z.string(),
7
- device_id: z.string(),
8
- state: z.string(),
9
- });
5
+ export const RequestSchema = z
6
+ .object({
7
+ code: z.string(),
8
+ code_verifier: z.string(),
9
+ device_id: z.string(),
10
+ state: z.string(),
11
+ })
12
+ .merge(UserReferralsSchema);
10
13
 
11
14
  export type Request = z.infer<typeof RequestSchema>;
12
15
 
@@ -1,10 +1,13 @@
1
1
  import { z } from 'zod';
2
+ import { UserReferralsSchema } from '../../models';
2
3
 
3
4
  export namespace YandexLoginCommand {
4
- export const RequestSchema = z.object({
5
- code: z.string(),
6
- code_verifier: z.string(),
7
- });
5
+ export const RequestSchema = z
6
+ .object({
7
+ code: z.string(),
8
+ code_verifier: z.string(),
9
+ })
10
+ .merge(UserReferralsSchema);
8
11
 
9
12
  export type Request = z.infer<typeof RequestSchema>;
10
13
 
@@ -36,6 +36,10 @@ export namespace BuyProductCommand {
36
36
  email: z.string().email(),
37
37
  partnerId: z.string().uuid().optional(),
38
38
  promocode: z.string().optional(),
39
+ webmasterAlias: z.string().optional(),
40
+ webmasterReferralProvidedAt: z
41
+ .preprocess((val) => (typeof val === 'string' ? new Date(val) : val), z.date())
42
+ .optional(),
39
43
  });
40
44
 
41
45
  export type RequestFast = z.infer<typeof RequestFastSchema>;
@@ -4,4 +4,3 @@ export * from './find-promocode.command';
4
4
  export * from './get-upsell-offer.command';
5
5
  export * from './update-promocode.command';
6
6
  export * from './validate-promocode.command';
7
- export * from './get-webmaster-promocode.command';
@@ -16,6 +16,10 @@ export namespace BuySubscriptionCommand {
16
16
  email: z.string().email(),
17
17
  partnerId: z.string().uuid().optional(),
18
18
  promocode: z.string().optional(),
19
+ webmasterAlias: z.string().optional(),
20
+ webmasterReferralProvidedAt: z
21
+ .preprocess((val) => (typeof val === 'string' ? new Date(val) : val), z.date())
22
+ .optional(),
19
23
  });
20
24
 
21
25
  export type RequestFast = z.infer<typeof RequestFastSchema>;
@@ -1,6 +1,11 @@
1
1
  import { z } from 'zod';
2
+ import { UserReferralsSchema } from '../../models';
2
3
 
3
4
  export namespace CreateTelegramAuthLinkCommand {
5
+ export const RequestSchema = UserReferralsSchema;
6
+
7
+ export type Request = z.infer<typeof RequestSchema>;
8
+
4
9
  export const ResponseSchema = z.object({
5
10
  data: z.object({
6
11
  uuid: z.string().uuid(),
@@ -6,6 +6,10 @@ export namespace AuthWithTelegramWebAppCommand {
6
6
  initData: z.string(),
7
7
  platform: z.string().nullable(),
8
8
  partnerId: z.string().optional(),
9
+ webmasterAlias: z.string().optional(),
10
+ webmasterReferralProvidedAt: z
11
+ .preprocess((val) => (typeof val === 'string' ? new Date(val) : val), z.date())
12
+ .optional(),
9
13
  utm: UtmSchema.optional(),
10
14
  });
11
15
 
@@ -14,6 +14,7 @@ export namespace GetMeCommand {
14
14
  role: z.nativeEnum(ROLE),
15
15
  signupMethod: z.nativeEnum(SIGNUP_METHOD),
16
16
  telegramId: z.number().nullable(),
17
+ webmasterId: z.string().uuid().nullable(),
17
18
  }),
18
19
  });
19
20
 
@@ -2287,4 +2287,9 @@ export const ERRORS = {
2287
2287
  message: 'У вас нет доступа к этой модели Writer',
2288
2288
  httpCode: 403,
2289
2289
  },
2290
+ WEBMASTER_BONUS_APPLY_ERROR: {
2291
+ code: 'A449',
2292
+ message: 'Не удалось применить бонусы вебмастеру',
2293
+ httpCode: 500,
2294
+ },
2290
2295
  };
@@ -2,5 +2,4 @@ export enum PROMOCODE_PROMOTION {
2
2
  BONUS = 'bonus',
3
3
  CHAT_UPSELL = 'chat_upsell',
4
4
  DAILY_STREAK = 'daily_streak',
5
- WEBMASTER = 'webmaster',
6
5
  }
package/models/index.ts CHANGED
@@ -52,3 +52,4 @@ export * from './users-filter-notification.schema';
52
52
  export * from './daily-streak';
53
53
  export * from './webmaster.schema';
54
54
  export * from './webmaster-balance.schema';
55
+ export * from './user-referrals.schema';
@@ -13,7 +13,6 @@ export const PromocodeSchema = z.object({
13
13
  endDate: z.date().nullable(),
14
14
  userId: z.string().uuid().nullable(),
15
15
  unregisteredUserId: z.string().uuid().nullable(),
16
- webmasterId: z.string().uuid().nullable(),
17
16
 
18
17
  createdAt: z.date(),
19
18
  updatedAt: z.date(),
@@ -0,0 +1,10 @@
1
+ import z from 'zod';
2
+
3
+ export const UserReferralsSchema = z.object({
4
+ partnerId: z.string().uuid().optional(),
5
+ webmasterAlias: z.string().optional(),
6
+ webmasterReferralProvidedAt: z
7
+ .string()
8
+ .transform((date) => new Date(date))
9
+ .optional(),
10
+ });
@@ -5,7 +5,6 @@ export const WebmasterBalanceSchema = z.object({
5
5
  uuid: z.string().uuid(),
6
6
  webmasterId: z.string().uuid(),
7
7
  orderId: z.string().uuid().nullable(),
8
- promocodeId: z.string().uuid().nullable(),
9
8
  sourceUserId: z.string().uuid().nullable(),
10
9
  amount: z.number(),
11
10
  type: z.nativeEnum(WEBMASTER_BALANCE_TYPE),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.7.72",
3
+ "version": "0.7.74",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetWebmasterPromocodeCommand = void 0;
4
- const zod_1 = require("zod");
5
- const models_1 = require("../../models");
6
- var GetWebmasterPromocodeCommand;
7
- (function (GetWebmasterPromocodeCommand) {
8
- GetWebmasterPromocodeCommand.RequestSchema = models_1.WebmasterSchema.pick({ alias: true });
9
- GetWebmasterPromocodeCommand.ResponseSchema = zod_1.z.object({
10
- data: zod_1.z.object({
11
- isEligible: zod_1.z.boolean(),
12
- promocode: zod_1.z.string().nullable(),
13
- amount: zod_1.z.number().nullable(),
14
- endDate: zod_1.z.date().nullable(),
15
- }),
16
- });
17
- })(GetWebmasterPromocodeCommand || (exports.GetWebmasterPromocodeCommand = GetWebmasterPromocodeCommand = {}));
@@ -1,19 +0,0 @@
1
- import { z } from 'zod';
2
- import { WebmasterSchema } from '../../models';
3
-
4
- export namespace GetWebmasterPromocodeCommand {
5
- export const RequestSchema = WebmasterSchema.pick({ alias: true });
6
-
7
- export type Request = z.infer<typeof RequestSchema>;
8
-
9
- export const ResponseSchema = z.object({
10
- data: z.object({
11
- isEligible: z.boolean(),
12
- promocode: z.string().nullable(),
13
- amount: z.number().nullable(),
14
- endDate: z.date().nullable(),
15
- }),
16
- });
17
-
18
- export type Response = z.infer<typeof ResponseSchema>;
19
- }