@purpleschool/gptbot 0.5.39 → 0.5.41

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 (55) hide show
  1. package/api/controllers/http/index.ts +1 -0
  2. package/api/controllers/http/promocode.ts +8 -0
  3. package/api/controllers/http/referral.ts +1 -0
  4. package/api/routes.ts +12 -0
  5. package/build/api/controllers/http/index.js +1 -0
  6. package/build/api/controllers/http/promocode.js +10 -0
  7. package/build/api/controllers/http/referral.js +1 -0
  8. package/build/api/routes.js +9 -0
  9. package/build/commands/index.js +1 -0
  10. package/build/commands/product/buy-product.command.js +2 -0
  11. package/build/commands/promocode/create-promocode.command.js +16 -0
  12. package/build/commands/promocode/delete-promocode.command.js +16 -0
  13. package/build/commands/promocode/find-promocode.command.js +17 -0
  14. package/build/commands/promocode/index.js +21 -0
  15. package/build/commands/promocode/update-promocode.command.js +19 -0
  16. package/build/commands/promocode/validate-promocode.command.js +17 -0
  17. package/build/commands/referral/index.js +1 -0
  18. package/build/commands/referral/validate-referral.command.js +15 -0
  19. package/build/commands/subscription/buy-subscription.command.js +2 -0
  20. package/build/commands/subscription/upgrade-subscription.command.js +1 -0
  21. package/build/constants/errors/errors.js +40 -0
  22. package/build/constants/index.js +2 -0
  23. package/build/constants/promocode/enums/index.js +18 -0
  24. package/build/constants/promocode/enums/promocode-promotion.enum.js +7 -0
  25. package/build/constants/promocode/enums/promocode-status.enum.js +8 -0
  26. package/build/constants/promocode/index.js +17 -0
  27. package/build/constants/unregistered-user/enums/index.js +17 -0
  28. package/build/constants/unregistered-user/enums/unregistered-user-status.enum.js +9 -0
  29. package/build/constants/unregistered-user/index.js +17 -0
  30. package/build/models/index.js +1 -0
  31. package/build/models/promocode.schema.js +18 -0
  32. package/commands/index.ts +1 -0
  33. package/commands/product/buy-product.command.ts +2 -0
  34. package/commands/promocode/create-promocode.command.ts +18 -0
  35. package/commands/promocode/delete-promocode.command.ts +18 -0
  36. package/commands/promocode/find-promocode.command.ts +22 -0
  37. package/commands/promocode/index.ts +5 -0
  38. package/commands/promocode/update-promocode.command.ts +24 -0
  39. package/commands/promocode/validate-promocode.command.ts +19 -0
  40. package/commands/referral/index.ts +1 -0
  41. package/commands/referral/validate-referral.command.ts +17 -0
  42. package/commands/subscription/buy-subscription.command.ts +2 -0
  43. package/commands/subscription/upgrade-subscription.command.ts +1 -0
  44. package/constants/errors/errors.ts +40 -0
  45. package/constants/index.ts +2 -0
  46. package/constants/promocode/enums/index.ts +2 -0
  47. package/constants/promocode/enums/promocode-promotion.enum.ts +3 -0
  48. package/constants/promocode/enums/promocode-status.enum.ts +4 -0
  49. package/constants/promocode/index.ts +1 -0
  50. package/constants/unregistered-user/enums/index.ts +1 -0
  51. package/constants/unregistered-user/enums/unregistered-user-status.enum.ts +5 -0
  52. package/constants/unregistered-user/index.ts +1 -0
  53. package/models/index.ts +1 -0
  54. package/models/promocode.schema.ts +17 -0
  55. package/package.json +1 -1
@@ -24,3 +24,4 @@ export * from './unregistered-user';
24
24
  export * from './user-to-task-private';
25
25
  export * from './user-to-task-public';
26
26
  export * from './user';
27
+ export * from './promocode';
@@ -0,0 +1,8 @@
1
+ export const PROMOCODE_PRIVATE_CONTROLLER = 'private/promocode' as const;
2
+ export const PROMOCODE_PUBLIC_CONTROLLER = 'public/promocode' as const;
3
+
4
+ export const PROMOCODE_ROUTES = {
5
+ FIND_ALL: 'all',
6
+ VALIDATE: 'validate',
7
+ FIND_BY_UUID: 'by/uuid',
8
+ } as const;
@@ -2,4 +2,5 @@ export const REFERRAL_CONTROLLER = 'referral' as const;
2
2
 
3
3
  export const REFERRAL_ROUTES = {
4
4
  GET_MY_BONUSES: 'bonuses/my',
5
+ VALIDATE: 'validate/users',
5
6
  } as const;
package/api/routes.ts CHANGED
@@ -136,4 +136,16 @@ export const REST_API = {
136
136
  GET: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${CONTROLLERS.BLOG_ROUTES.FIND}`,
137
137
  GET_ALL: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${CONTROLLERS.BLOG_ROUTES.FIND_ALL}`,
138
138
  },
139
+ PROMOCODE: {
140
+ CREATE: `${ROOT}/${CONTROLLERS.PROMOCODE_PRIVATE_CONTROLLER}`,
141
+ PATCH: (uuid: string) => `${ROOT}/${CONTROLLERS.PROMOCODE_PRIVATE_CONTROLLER}/${uuid}`,
142
+ DELETE: (uuid: string) => `${ROOT}/${CONTROLLERS.PROMOCODE_PRIVATE_CONTROLLER}/${uuid}`,
143
+ GET_BY_UUID: (uuid: string) =>
144
+ `${ROOT}/${CONTROLLERS.PROMOCODE_PRIVATE_CONTROLLER}/${CONTROLLERS.PROMOCODE_ROUTES.FIND_BY_UUID}/${uuid}`,
145
+ GET_ALL: `${ROOT}/${CONTROLLERS.PROMOCODE_PRIVATE_CONTROLLER}/${CONTROLLERS.PROMOCODE_ROUTES.FIND_ALL}`,
146
+ VALIDATE_PRIVATE: (code: string) =>
147
+ `${ROOT}/${CONTROLLERS.PROMOCODE_PRIVATE_CONTROLLER}/${CONTROLLERS.PROMOCODE_ROUTES.VALIDATE}/${code}`,
148
+ VALIDATE_PUBLIC: (code: string) =>
149
+ `${ROOT}/${CONTROLLERS.PROMOCODE_PUBLIC_CONTROLLER}/${CONTROLLERS.PROMOCODE_ROUTES.VALIDATE}/${code}`,
150
+ },
139
151
  } as const;
@@ -40,3 +40,4 @@ __exportStar(require("./unregistered-user"), exports);
40
40
  __exportStar(require("./user-to-task-private"), exports);
41
41
  __exportStar(require("./user-to-task-public"), exports);
42
42
  __exportStar(require("./user"), exports);
43
+ __exportStar(require("./promocode"), exports);
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PROMOCODE_ROUTES = exports.PROMOCODE_PUBLIC_CONTROLLER = exports.PROMOCODE_PRIVATE_CONTROLLER = void 0;
4
+ exports.PROMOCODE_PRIVATE_CONTROLLER = 'private/promocode';
5
+ exports.PROMOCODE_PUBLIC_CONTROLLER = 'public/promocode';
6
+ exports.PROMOCODE_ROUTES = {
7
+ FIND_ALL: 'all',
8
+ VALIDATE: 'validate',
9
+ FIND_BY_UUID: 'by/uuid',
10
+ };
@@ -4,4 +4,5 @@ exports.REFERRAL_ROUTES = exports.REFERRAL_CONTROLLER = void 0;
4
4
  exports.REFERRAL_CONTROLLER = 'referral';
5
5
  exports.REFERRAL_ROUTES = {
6
6
  GET_MY_BONUSES: 'bonuses/my',
7
+ VALIDATE: 'validate/users',
7
8
  };
@@ -149,4 +149,13 @@ exports.REST_API = {
149
149
  GET: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${CONTROLLERS.BLOG_ROUTES.FIND}`,
150
150
  GET_ALL: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${CONTROLLERS.BLOG_ROUTES.FIND_ALL}`,
151
151
  },
152
+ PROMOCODE: {
153
+ CREATE: `${exports.ROOT}/${CONTROLLERS.PROMOCODE_PRIVATE_CONTROLLER}`,
154
+ PATCH: (uuid) => `${exports.ROOT}/${CONTROLLERS.PROMOCODE_PRIVATE_CONTROLLER}/${uuid}`,
155
+ DELETE: (uuid) => `${exports.ROOT}/${CONTROLLERS.PROMOCODE_PRIVATE_CONTROLLER}/${uuid}`,
156
+ GET_BY_UUID: (uuid) => `${exports.ROOT}/${CONTROLLERS.PROMOCODE_PRIVATE_CONTROLLER}/${CONTROLLERS.PROMOCODE_ROUTES.FIND_BY_UUID}/${uuid}`,
157
+ GET_ALL: `${exports.ROOT}/${CONTROLLERS.PROMOCODE_PRIVATE_CONTROLLER}/${CONTROLLERS.PROMOCODE_ROUTES.FIND_ALL}`,
158
+ VALIDATE_PRIVATE: (code) => `${exports.ROOT}/${CONTROLLERS.PROMOCODE_PRIVATE_CONTROLLER}/${CONTROLLERS.PROMOCODE_ROUTES.VALIDATE}/${code}`,
159
+ VALIDATE_PUBLIC: (code) => `${exports.ROOT}/${CONTROLLERS.PROMOCODE_PUBLIC_CONTROLLER}/${CONTROLLERS.PROMOCODE_ROUTES.VALIDATE}/${code}`,
160
+ },
152
161
  };
@@ -38,3 +38,4 @@ __exportStar(require("./unregistered-user"), exports);
38
38
  __exportStar(require("./user"), exports);
39
39
  __exportStar(require("./user-to-subscription"), exports);
40
40
  __exportStar(require("./user-to-task"), exports);
41
+ __exportStar(require("./promocode"), exports);
@@ -10,6 +10,7 @@ var BuyProductCommand;
10
10
  });
11
11
  BuyProductCommand.RequestSchema = zod_1.z.object({
12
12
  useDiscount: zod_1.z.boolean(),
13
+ promocode: zod_1.z.string().optional(),
13
14
  });
14
15
  const IReceiptOrderSchema = zod_1.z.object({
15
16
  items: zod_1.z.array(zod_1.z.object({
@@ -28,6 +29,7 @@ var BuyProductCommand;
28
29
  BuyProductCommand.RequestFastSchema = zod_1.z.object({
29
30
  email: zod_1.z.string().email(),
30
31
  partnerId: zod_1.z.string().uuid().optional(),
32
+ promocode: zod_1.z.string().optional(),
31
33
  });
32
34
  BuyProductCommand.ResponseSchema = zod_1.z.object({
33
35
  publicId: zod_1.z.string(),
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreatePromocodeCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
6
+ var CreatePromocodeCommand;
7
+ (function (CreatePromocodeCommand) {
8
+ CreatePromocodeCommand.RequestSchema = models_1.PromocodeSchema.omit({
9
+ uuid: true,
10
+ createdAt: true,
11
+ updatedAt: true,
12
+ });
13
+ CreatePromocodeCommand.ResponseSchema = zod_1.z.object({
14
+ data: models_1.PromocodeSchema,
15
+ });
16
+ })(CreatePromocodeCommand || (exports.CreatePromocodeCommand = CreatePromocodeCommand = {}));
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeletePromocodeCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
6
+ var DeletePromocodeCommand;
7
+ (function (DeletePromocodeCommand) {
8
+ DeletePromocodeCommand.RequestSchema = models_1.PromocodeSchema.pick({
9
+ uuid: true,
10
+ });
11
+ DeletePromocodeCommand.ResponseSchema = zod_1.z.object({
12
+ data: zod_1.z.object({
13
+ isDeleted: zod_1.z.boolean(),
14
+ }),
15
+ });
16
+ })(DeletePromocodeCommand || (exports.DeletePromocodeCommand = DeletePromocodeCommand = {}));
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FindPromocodeCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
6
+ var FindPromocodeCommand;
7
+ (function (FindPromocodeCommand) {
8
+ FindPromocodeCommand.RequestSchema = models_1.PromocodeSchema.pick({
9
+ uuid: true,
10
+ });
11
+ FindPromocodeCommand.ResponseSchema = zod_1.z.object({
12
+ data: zod_1.z.array(models_1.PromocodeSchema),
13
+ });
14
+ FindPromocodeCommand.ResponseByUUIDSchema = zod_1.z.object({
15
+ data: models_1.PromocodeSchema,
16
+ });
17
+ })(FindPromocodeCommand || (exports.FindPromocodeCommand = FindPromocodeCommand = {}));
@@ -0,0 +1,21 @@
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("./create-promocode.command"), exports);
18
+ __exportStar(require("./delete-promocode.command"), exports);
19
+ __exportStar(require("./find-promocode.command"), exports);
20
+ __exportStar(require("./update-promocode.command"), exports);
21
+ __exportStar(require("./validate-promocode.command"), exports);
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UpdatePromocodeCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
6
+ var UpdatePromocodeCommand;
7
+ (function (UpdatePromocodeCommand) {
8
+ UpdatePromocodeCommand.RequestSchema = models_1.PromocodeSchema.omit({
9
+ createdAt: true,
10
+ updatedAt: true,
11
+ uuid: true,
12
+ }).partial();
13
+ UpdatePromocodeCommand.RequestParamSchema = zod_1.z.object({
14
+ uuid: zod_1.z.string().uuid(),
15
+ });
16
+ UpdatePromocodeCommand.ResponseSchema = zod_1.z.object({
17
+ data: models_1.PromocodeSchema,
18
+ });
19
+ })(UpdatePromocodeCommand || (exports.UpdatePromocodeCommand = UpdatePromocodeCommand = {}));
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidatePromocodeCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
6
+ var ValidatePromocodeCommand;
7
+ (function (ValidatePromocodeCommand) {
8
+ ValidatePromocodeCommand.RequestSchema = models_1.PromocodeSchema.pick({
9
+ code: true,
10
+ });
11
+ ValidatePromocodeCommand.ResponseSchema = zod_1.z.object({
12
+ data: zod_1.z.object({
13
+ amount: zod_1.z.number(),
14
+ promotion: zod_1.z.string().nullable(),
15
+ }),
16
+ });
17
+ })(ValidatePromocodeCommand || (exports.ValidatePromocodeCommand = ValidatePromocodeCommand = {}));
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./get-by-bonuses.command"), exports);
18
+ __exportStar(require("./validate-referral.command"), exports);
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidateReferralCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ var ValidateReferralCommand;
6
+ (function (ValidateReferralCommand) {
7
+ ValidateReferralCommand.RequestParamsSchema = zod_1.z.object({
8
+ partnerId: zod_1.z.string().uuid(),
9
+ });
10
+ ValidateReferralCommand.ResponseSchema = zod_1.z.object({
11
+ data: zod_1.z.object({
12
+ amount: zod_1.z.number(),
13
+ }),
14
+ });
15
+ })(ValidateReferralCommand || (exports.ValidateReferralCommand = ValidateReferralCommand = {}));
@@ -10,10 +10,12 @@ var BuySubscriptionCommand;
10
10
  });
11
11
  BuySubscriptionCommand.RequestSchema = zod_1.z.object({
12
12
  useDiscount: zod_1.z.boolean(),
13
+ promocode: zod_1.z.string().optional(),
13
14
  });
14
15
  BuySubscriptionCommand.RequestFastSchema = zod_1.z.object({
15
16
  email: zod_1.z.string().email(),
16
17
  partnerId: zod_1.z.string().uuid().optional(),
18
+ promocode: zod_1.z.string().optional(),
17
19
  });
18
20
  const IReceiptOrderSchema = zod_1.z.object({
19
21
  items: zod_1.z.array(zod_1.z.object({
@@ -7,6 +7,7 @@ var UpgradeSubscriptionCommand;
7
7
  (function (UpgradeSubscriptionCommand) {
8
8
  UpgradeSubscriptionCommand.RequestSchema = zod_1.z.object({
9
9
  upgradeSubscriptionId: zod_1.z.string().uuid(),
10
+ promocode: zod_1.z.string().optional(),
10
11
  });
11
12
  UpgradeSubscriptionCommand.RequestParamSchema = models_1.UserToSubscriptionSchema.pick({
12
13
  uuid: true,
@@ -875,4 +875,44 @@ exports.ERRORS = {
875
875
  message: 'У пользователя нет доступа к премиум моделям',
876
876
  httpCode: 400,
877
877
  },
878
+ CHAT_TRANSFER_ERROR: {
879
+ code: 'A200',
880
+ message: 'Произошла ошибка при переносе чата',
881
+ httpCode: 500,
882
+ },
883
+ PROMOCODE_CONFLICT_ERROR: {
884
+ code: 'A201',
885
+ message: 'Промокод уже существует',
886
+ httpCode: 409,
887
+ },
888
+ PROMOCODE_FIND_ERROR: {
889
+ code: 'A202',
890
+ message: 'Промокод не найден',
891
+ httpCode: 404,
892
+ },
893
+ PROMOCODE_CREATE_ERROR: {
894
+ code: 'A203',
895
+ message: 'Промокод не создан',
896
+ httpCode: 500,
897
+ },
898
+ PROMOCODE_UPDATE_ERROR: {
899
+ code: 'A205',
900
+ message: 'Промокод не обновлен',
901
+ httpCode: 500,
902
+ },
903
+ PROMOCODE_DELETE_ERROR: {
904
+ code: 'A206',
905
+ message: 'Промокод не удален',
906
+ httpCode: 500,
907
+ },
908
+ PROMOCODES_FIND_ERROR: {
909
+ code: 'A207',
910
+ message: 'Промокоды не найдены',
911
+ httpCode: 500,
912
+ },
913
+ PROMOCODE_VALIDATE_ERROR: {
914
+ code: 'A208',
915
+ message: 'Промокод не провалидирован',
916
+ httpCode: 500,
917
+ },
878
918
  };
@@ -35,4 +35,6 @@ __exportStar(require("./subscription"), exports);
35
35
  __exportStar(require("./task"), exports);
36
36
  __exportStar(require("./telegram"), exports);
37
37
  __exportStar(require("./transaction"), exports);
38
+ __exportStar(require("./unregistered-user"), exports);
38
39
  __exportStar(require("./user"), exports);
40
+ __exportStar(require("./promocode"), exports);
@@ -0,0 +1,18 @@
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("./promocode-promotion.enum"), exports);
18
+ __exportStar(require("./promocode-status.enum"), exports);
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PROMOCODE_PROMOTION = void 0;
4
+ var PROMOCODE_PROMOTION;
5
+ (function (PROMOCODE_PROMOTION) {
6
+ PROMOCODE_PROMOTION["bonus"] = "bonus";
7
+ })(PROMOCODE_PROMOTION || (exports.PROMOCODE_PROMOTION = PROMOCODE_PROMOTION = {}));
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PROMOCODE_STATUS = void 0;
4
+ var PROMOCODE_STATUS;
5
+ (function (PROMOCODE_STATUS) {
6
+ PROMOCODE_STATUS["active"] = "active";
7
+ PROMOCODE_STATUS["inactive"] = "inactive";
8
+ })(PROMOCODE_STATUS || (exports.PROMOCODE_STATUS = PROMOCODE_STATUS = {}));
@@ -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("./enums"), exports);
@@ -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("./unregistered-user-status.enum"), exports);
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UNREGISTERED_USER_STATUS = void 0;
4
+ var UNREGISTERED_USER_STATUS;
5
+ (function (UNREGISTERED_USER_STATUS) {
6
+ UNREGISTERED_USER_STATUS["ACTIVE"] = "active";
7
+ UNREGISTERED_USER_STATUS["FRAUD"] = "fraud";
8
+ UNREGISTERED_USER_STATUS["TRANSFERRED"] = "transferred";
9
+ })(UNREGISTERED_USER_STATUS || (exports.UNREGISTERED_USER_STATUS = UNREGISTERED_USER_STATUS = {}));
@@ -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("./enums"), exports);
@@ -42,3 +42,4 @@ __exportStar(require("./unregistered-user.schema"), exports);
42
42
  __exportStar(require("./user-task.schema"), exports);
43
43
  __exportStar(require("./user-to-subscription.schema"), exports);
44
44
  __exportStar(require("./user.schema"), exports);
45
+ __exportStar(require("./promocode.schema"), exports);
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PromocodeSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const constants_1 = require("../constants");
6
+ exports.PromocodeSchema = zod_1.z.object({
7
+ uuid: zod_1.z.string().uuid(),
8
+ code: zod_1.z.string(),
9
+ amount: zod_1.z.number(),
10
+ promotion: zod_1.z.nativeEnum(constants_1.PROMOCODE_PROMOTION),
11
+ limit: zod_1.z.number(),
12
+ used: zod_1.z.number().default(0),
13
+ status: zod_1.z.nativeEnum(constants_1.PROMOCODE_STATUS),
14
+ forFirstPurchase: zod_1.z.boolean().optional(),
15
+ endDate: zod_1.z.date().nullable(),
16
+ createdAt: zod_1.z.date(),
17
+ updatedAt: zod_1.z.date(),
18
+ });
package/commands/index.ts CHANGED
@@ -22,3 +22,4 @@ export * from './unregistered-user';
22
22
  export * from './user';
23
23
  export * from './user-to-subscription';
24
24
  export * from './user-to-task';
25
+ export * from './promocode';
@@ -8,6 +8,7 @@ export namespace BuyProductCommand {
8
8
 
9
9
  export const RequestSchema = z.object({
10
10
  useDiscount: z.boolean(),
11
+ promocode: z.string().optional(),
11
12
  });
12
13
 
13
14
  export type RequestParam = z.infer<typeof RequestParamSchema>;
@@ -34,6 +35,7 @@ export namespace BuyProductCommand {
34
35
  export const RequestFastSchema = z.object({
35
36
  email: z.string().email(),
36
37
  partnerId: z.string().uuid().optional(),
38
+ promocode: z.string().optional(),
37
39
  });
38
40
 
39
41
  export type RequestFast = z.infer<typeof RequestFastSchema>;
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ import { PromocodeSchema } from '../../models';
3
+
4
+ export namespace CreatePromocodeCommand {
5
+ export const RequestSchema = PromocodeSchema.omit({
6
+ uuid: true,
7
+ createdAt: true,
8
+ updatedAt: true,
9
+ });
10
+
11
+ export type Request = z.infer<typeof RequestSchema>;
12
+
13
+ export const ResponseSchema = z.object({
14
+ data: PromocodeSchema,
15
+ });
16
+
17
+ export type Response = z.infer<typeof ResponseSchema>;
18
+ }
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ import { PromocodeSchema } from '../../models';
3
+
4
+ export namespace DeletePromocodeCommand {
5
+ export const RequestSchema = PromocodeSchema.pick({
6
+ uuid: true,
7
+ });
8
+
9
+ export type Request = z.infer<typeof RequestSchema>;
10
+
11
+ export const ResponseSchema = z.object({
12
+ data: z.object({
13
+ isDeleted: z.boolean(),
14
+ }),
15
+ });
16
+
17
+ export type Response = z.infer<typeof ResponseSchema>;
18
+ }
@@ -0,0 +1,22 @@
1
+ import { z } from 'zod';
2
+ import { PromocodeSchema } from '../../models';
3
+
4
+ export namespace FindPromocodeCommand {
5
+ export const RequestSchema = PromocodeSchema.pick({
6
+ uuid: true,
7
+ });
8
+
9
+ export type Request = z.infer<typeof RequestSchema>;
10
+
11
+ export const ResponseSchema = z.object({
12
+ data: z.array(PromocodeSchema),
13
+ });
14
+
15
+ export type Response = z.infer<typeof ResponseSchema>;
16
+
17
+ export const ResponseByUUIDSchema = z.object({
18
+ data: PromocodeSchema,
19
+ });
20
+
21
+ export type ResponseByUUID = z.infer<typeof ResponseByUUIDSchema>;
22
+ }
@@ -0,0 +1,5 @@
1
+ export * from './create-promocode.command';
2
+ export * from './delete-promocode.command';
3
+ export * from './find-promocode.command';
4
+ export * from './update-promocode.command';
5
+ export * from './validate-promocode.command';
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ import { PromocodeSchema } from '../../models';
3
+
4
+ export namespace UpdatePromocodeCommand {
5
+ export const RequestSchema = PromocodeSchema.omit({
6
+ createdAt: true,
7
+ updatedAt: true,
8
+ uuid: true,
9
+ }).partial();
10
+
11
+ export type Request = z.infer<typeof RequestSchema>;
12
+
13
+ export const RequestParamSchema = z.object({
14
+ uuid: z.string().uuid(),
15
+ });
16
+
17
+ export type RequestParam = z.infer<typeof RequestParamSchema>;
18
+
19
+ export const ResponseSchema = z.object({
20
+ data: PromocodeSchema,
21
+ });
22
+
23
+ export type Response = z.infer<typeof ResponseSchema>;
24
+ }
@@ -0,0 +1,19 @@
1
+ import { z } from 'zod';
2
+ import { PromocodeSchema } from '../../models';
3
+
4
+ export namespace ValidatePromocodeCommand {
5
+ export const RequestSchema = PromocodeSchema.pick({
6
+ code: true,
7
+ });
8
+
9
+ export type Request = z.infer<typeof RequestSchema>;
10
+
11
+ export const ResponseSchema = z.object({
12
+ data: z.object({
13
+ amount: z.number(),
14
+ promotion: z.string().nullable(),
15
+ }),
16
+ });
17
+
18
+ export type Response = z.infer<typeof ResponseSchema>;
19
+ }
@@ -1 +1,2 @@
1
1
  export * from './get-by-bonuses.command';
2
+ export * from './validate-referral.command';
@@ -0,0 +1,17 @@
1
+ import { z } from 'zod';
2
+
3
+ export namespace ValidateReferralCommand {
4
+ export const RequestParamsSchema = z.object({
5
+ partnerId: z.string().uuid(),
6
+ });
7
+
8
+ export type RequestParams = z.infer<typeof RequestParamsSchema>;
9
+
10
+ export const ResponseSchema = z.object({
11
+ data: z.object({
12
+ amount: z.number(),
13
+ }),
14
+ });
15
+
16
+ export type Response = z.infer<typeof ResponseSchema>;
17
+ }
@@ -8,12 +8,14 @@ export namespace BuySubscriptionCommand {
8
8
 
9
9
  export const RequestSchema = z.object({
10
10
  useDiscount: z.boolean(),
11
+ promocode: z.string().optional(),
11
12
  });
12
13
 
13
14
  export type Request = z.infer<typeof RequestSchema>;
14
15
  export const RequestFastSchema = z.object({
15
16
  email: z.string().email(),
16
17
  partnerId: z.string().uuid().optional(),
18
+ promocode: z.string().optional(),
17
19
  });
18
20
 
19
21
  export type RequestFast = z.infer<typeof RequestFastSchema>;
@@ -4,6 +4,7 @@ import { UserToSubscriptionSchema } from '../../models';
4
4
  export namespace UpgradeSubscriptionCommand {
5
5
  export const RequestSchema = z.object({
6
6
  upgradeSubscriptionId: z.string().uuid(),
7
+ promocode: z.string().optional(),
7
8
  });
8
9
 
9
10
  export const RequestParamSchema = UserToSubscriptionSchema.pick({
@@ -877,4 +877,44 @@ export const ERRORS = {
877
877
  message: 'У пользователя нет доступа к премиум моделям',
878
878
  httpCode: 400,
879
879
  },
880
+ CHAT_TRANSFER_ERROR: {
881
+ code: 'A200',
882
+ message: 'Произошла ошибка при переносе чата',
883
+ httpCode: 500,
884
+ },
885
+ PROMOCODE_CONFLICT_ERROR: {
886
+ code: 'A201',
887
+ message: 'Промокод уже существует',
888
+ httpCode: 409,
889
+ },
890
+ PROMOCODE_FIND_ERROR: {
891
+ code: 'A202',
892
+ message: 'Промокод не найден',
893
+ httpCode: 404,
894
+ },
895
+ PROMOCODE_CREATE_ERROR: {
896
+ code: 'A203',
897
+ message: 'Промокод не создан',
898
+ httpCode: 500,
899
+ },
900
+ PROMOCODE_UPDATE_ERROR: {
901
+ code: 'A205',
902
+ message: 'Промокод не обновлен',
903
+ httpCode: 500,
904
+ },
905
+ PROMOCODE_DELETE_ERROR: {
906
+ code: 'A206',
907
+ message: 'Промокод не удален',
908
+ httpCode: 500,
909
+ },
910
+ PROMOCODES_FIND_ERROR: {
911
+ code: 'A207',
912
+ message: 'Промокоды не найдены',
913
+ httpCode: 500,
914
+ },
915
+ PROMOCODE_VALIDATE_ERROR: {
916
+ code: 'A208',
917
+ message: 'Промокод не провалидирован',
918
+ httpCode: 500,
919
+ },
880
920
  };
@@ -19,4 +19,6 @@ export * from './subscription';
19
19
  export * from './task';
20
20
  export * from './telegram';
21
21
  export * from './transaction';
22
+ export * from './unregistered-user';
22
23
  export * from './user';
24
+ export * from './promocode';
@@ -0,0 +1,2 @@
1
+ export * from './promocode-promotion.enum';
2
+ export * from './promocode-status.enum';
@@ -0,0 +1,3 @@
1
+ export enum PROMOCODE_PROMOTION {
2
+ bonus = 'bonus',
3
+ }
@@ -0,0 +1,4 @@
1
+ export enum PROMOCODE_STATUS {
2
+ active = 'active',
3
+ inactive = 'inactive',
4
+ }
@@ -0,0 +1 @@
1
+ export * from './enums';
@@ -0,0 +1 @@
1
+ export * from './unregistered-user-status.enum';
@@ -0,0 +1,5 @@
1
+ export enum UNREGISTERED_USER_STATUS {
2
+ ACTIVE = 'active',
3
+ FRAUD = 'fraud',
4
+ TRANSFERRED = 'transferred',
5
+ }
@@ -0,0 +1 @@
1
+ export * from './enums';
package/models/index.ts CHANGED
@@ -26,3 +26,4 @@ export * from './unregistered-user.schema';
26
26
  export * from './user-task.schema';
27
27
  export * from './user-to-subscription.schema';
28
28
  export * from './user.schema';
29
+ export * from './promocode.schema';
@@ -0,0 +1,17 @@
1
+ import { z } from 'zod';
2
+ import { PROMOCODE_PROMOTION, PROMOCODE_STATUS } from '../constants';
3
+
4
+ export const PromocodeSchema = z.object({
5
+ uuid: z.string().uuid(),
6
+ code: z.string(),
7
+ amount: z.number(),
8
+ promotion: z.nativeEnum(PROMOCODE_PROMOTION),
9
+ limit: z.number(),
10
+ used: z.number().default(0),
11
+ status: z.nativeEnum(PROMOCODE_STATUS),
12
+ forFirstPurchase: z.boolean().optional(),
13
+ endDate: z.date().nullable(),
14
+
15
+ createdAt: z.date(),
16
+ updatedAt: z.date(),
17
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.5.39",
3
+ "version": "0.5.41",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {