@purpleschool/gptbot 0.5.31 → 0.5.33

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 (50) hide show
  1. package/api/controllers/http/account-merge.ts +5 -0
  2. package/api/controllers/http/index.ts +1 -0
  3. package/api/controllers/http/user-to-task-private.ts +1 -0
  4. package/api/controllers/index.ts +0 -1
  5. package/build/api/controllers/http/account-merge.js +7 -0
  6. package/build/api/controllers/http/index.js +1 -0
  7. package/build/api/controllers/http/user-to-task-private.js +1 -0
  8. package/build/api/controllers/index.js +0 -1
  9. package/build/{api/controllers/amqp → commands/account-merge}/index.js +1 -2
  10. package/build/commands/account-merge/merge-account.command.js +16 -0
  11. package/build/commands/index.js +1 -0
  12. package/build/commands/payment/index.js +2 -1
  13. package/build/commands/payment/receipt.command.js +67 -0
  14. package/build/commands/telegram-profile/index.js +0 -3
  15. package/build/commands/user-to-task/check-task-completion.command.js +14 -0
  16. package/build/commands/user-to-task/index.js +1 -0
  17. package/build/constants/errors/errors.js +45 -0
  18. package/build/constants/roles/role.js +1 -0
  19. package/build/constants/user/enums/index.js +1 -0
  20. package/build/constants/user/enums/singup-method.enum.js +8 -0
  21. package/build/constants/user/enums/user-status.js +1 -0
  22. package/build/models/cloud-payments-receipt.schema.js +118 -0
  23. package/build/models/index.js +1 -0
  24. package/commands/account-merge/index.ts +1 -0
  25. package/commands/account-merge/merge-account.command.ts +18 -0
  26. package/commands/index.ts +1 -0
  27. package/commands/payment/index.ts +2 -1
  28. package/commands/payment/receipt.command.ts +68 -0
  29. package/commands/telegram-profile/index.ts +0 -3
  30. package/commands/user-to-task/check-task-completion.command.ts +14 -0
  31. package/commands/user-to-task/index.ts +1 -0
  32. package/constants/errors/errors.ts +47 -0
  33. package/constants/roles/role.ts +1 -0
  34. package/constants/user/enums/index.ts +1 -0
  35. package/constants/user/enums/singup-method.enum.ts +4 -0
  36. package/constants/user/enums/user-status.ts +1 -0
  37. package/models/cloud-payments-receipt.schema.ts +119 -0
  38. package/models/index.ts +1 -0
  39. package/package.json +1 -1
  40. package/api/controllers/amqp/index.ts +0 -2
  41. package/api/controllers/amqp/telegram-connect.ts +0 -3
  42. package/api/controllers/amqp/telegram-profile.ts +0 -4
  43. package/build/api/controllers/amqp/telegram-connect.js +0 -6
  44. package/build/api/controllers/amqp/telegram-profile.js +0 -7
  45. package/build/commands/telegram-profile/check-my-telegram-profile-connected.command.js +0 -12
  46. package/build/commands/telegram-profile/connect-telegram-profile-with-verification-code.command.js +0 -15
  47. package/build/commands/telegram-profile/create-new-user-from-telegram-bot.command.js +0 -12
  48. package/commands/telegram-profile/check-my-telegram-profile-connected.command.ts +0 -11
  49. package/commands/telegram-profile/connect-telegram-profile-with-verification-code.command.ts +0 -16
  50. package/commands/telegram-profile/create-new-user-from-telegram-bot.command.ts +0 -13
@@ -0,0 +1,5 @@
1
+ export const ACCOUNT_MERGE_CONTROLLER = 'account-merge' as const;
2
+
3
+ export const ACCOUNT_MERGE_ROUTES = {
4
+ MERGE: '',
5
+ } as const;
@@ -1,3 +1,4 @@
1
+ export * from './account-merge';
1
2
  export * from './ai-model';
2
3
  export * from './auth';
3
4
  export * from './blog';
@@ -4,4 +4,5 @@ export const USER_TO_TASK_PRIVATE_ROUTES = {
4
4
  MY: 'my',
5
5
  START: (uuid: string) => `${uuid}/start`,
6
6
  REWARDS: 'rewards',
7
+ CHECK: (uuid: string) => `${uuid}/check`,
7
8
  } as const;
@@ -1,2 +1 @@
1
- export * from './amqp';
2
1
  export * from './http';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ACCOUNT_MERGE_ROUTES = exports.ACCOUNT_MERGE_CONTROLLER = void 0;
4
+ exports.ACCOUNT_MERGE_CONTROLLER = 'account-merge';
5
+ exports.ACCOUNT_MERGE_ROUTES = {
6
+ MERGE: '',
7
+ };
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./account-merge"), exports);
17
18
  __exportStar(require("./ai-model"), exports);
18
19
  __exportStar(require("./auth"), exports);
19
20
  __exportStar(require("./blog"), exports);
@@ -6,4 +6,5 @@ exports.USER_TO_TASK_PRIVATE_ROUTES = {
6
6
  MY: 'my',
7
7
  START: (uuid) => `${uuid}/start`,
8
8
  REWARDS: 'rewards',
9
+ CHECK: (uuid) => `${uuid}/check`,
9
10
  };
@@ -14,5 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./amqp"), exports);
18
17
  __exportStar(require("./http"), exports);
@@ -14,5 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./telegram-connect"), exports);
18
- __exportStar(require("./telegram-profile"), exports);
17
+ __exportStar(require("./merge-account.command"), exports);
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MergeAccountCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ var MergeAccountCommand;
6
+ (function (MergeAccountCommand) {
7
+ MergeAccountCommand.RequestSchema = zod_1.z.object({
8
+ email: zod_1.z.string().email(),
9
+ password: zod_1.z.string(),
10
+ });
11
+ MergeAccountCommand.ResponseSchema = zod_1.z.object({
12
+ data: zod_1.z.object({
13
+ accessToken: zod_1.z.string(),
14
+ }),
15
+ });
16
+ })(MergeAccountCommand || (exports.MergeAccountCommand = MergeAccountCommand = {}));
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./account-merge"), exports);
17
18
  __exportStar(require("./ai-model"), exports);
18
19
  __exportStar(require("./auth"), exports);
19
20
  __exportStar(require("./blog"), exports);
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./check.command"), exports);
17
18
  __exportStar(require("./get-payment-history.command"), exports);
18
19
  __exportStar(require("./pay.command"), exports);
19
- __exportStar(require("./check.command"), exports);
20
+ __exportStar(require("./receipt.command"), exports);
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReceiptCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
6
+ var ReceiptCommand;
7
+ (function (ReceiptCommand) {
8
+ ReceiptCommand.RequestSchema = zod_1.z
9
+ .object({
10
+ Id: zod_1.z.string(),
11
+ DocumentNumber: zod_1.z.string(),
12
+ SessionNumber: zod_1.z.string(),
13
+ Number: zod_1.z.string(),
14
+ FiscalSign: zod_1.z.string(),
15
+ DeviceNumber: zod_1.z.string(),
16
+ RegNumber: zod_1.z.string(),
17
+ FiscalNumber: zod_1.z.string(),
18
+ Inn: zod_1.z.string(),
19
+ Type: zod_1.z.string(),
20
+ Ofd: zod_1.z.string(),
21
+ Url: zod_1.z.string(),
22
+ QrCodeUrl: zod_1.z.string(),
23
+ TransactionId: zod_1.z.string(),
24
+ Amount: zod_1.z.string().transform((amount) => parseInt(amount, 10)),
25
+ DateTime: zod_1.z.string(),
26
+ InvoiceId: zod_1.z.string().optional(),
27
+ SubscriptionId: zod_1.z.string().optional(),
28
+ AccountId: zod_1.z.string(),
29
+ Receipt: zod_1.z
30
+ .string()
31
+ .transform((str, ctx) => {
32
+ try {
33
+ return JSON.parse(str);
34
+ }
35
+ catch (e) {
36
+ ctx.addIssue({ code: 'custom', message: 'Invalid JSON' });
37
+ return zod_1.z.NEVER;
38
+ }
39
+ })
40
+ .pipe(models_1.CloudPaymentsReceiptSchema),
41
+ })
42
+ .transform((data) => ({
43
+ id: data.Id,
44
+ docmentNumber: data.DocumentNumber,
45
+ sessionNumber: data.SessionNumber,
46
+ number: data.Number,
47
+ fiscalSign: data.FiscalSign,
48
+ deviceNumber: data.DeviceNumber,
49
+ regNumber: data.RegNumber,
50
+ fiscalNumber: data.FiscalNumber,
51
+ inn: data.Inn,
52
+ type: data.Type,
53
+ ofd: data.Ofd,
54
+ url: data.Url,
55
+ qrCodeUrl: data.QrCodeUrl,
56
+ transactionId: data.TransactionId,
57
+ amount: data.Amount,
58
+ dateTime: data.DateTime,
59
+ invoiceId: data.InvoiceId,
60
+ subscriptionId: data.SubscriptionId,
61
+ accountId: data.AccountId,
62
+ receipt: data.Receipt,
63
+ }));
64
+ ReceiptCommand.ResponseSchema = zod_1.z.object({
65
+ code: zod_1.z.number(),
66
+ });
67
+ })(ReceiptCommand || (exports.ReceiptCommand = ReceiptCommand = {}));
@@ -15,8 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./auth-with-telegram-web-app.command"), exports);
18
- __exportStar(require("./check-my-telegram-profile-connected.command"), exports);
19
18
  __exportStar(require("./check-telegram-profile-exists.command"), exports);
20
- __exportStar(require("./connect-telegram-profile-with-verification-code.command"), exports);
21
19
  __exportStar(require("./create-telegram-profile-connection-link.command"), exports);
22
- __exportStar(require("./create-new-user-from-telegram-bot.command"), exports);
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CheckTaskCompletionCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
6
+ var CheckTaskCompletionCommand;
7
+ (function (CheckTaskCompletionCommand) {
8
+ CheckTaskCompletionCommand.RequestParamsSchema = models_1.UserTaskSchema.pick({
9
+ taskId: true,
10
+ });
11
+ CheckTaskCompletionCommand.ResponseSchema = zod_1.z.object({
12
+ data: models_1.UserTaskSchema,
13
+ });
14
+ })(CheckTaskCompletionCommand || (exports.CheckTaskCompletionCommand = CheckTaskCompletionCommand = {}));
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./check-task-completion.command"), exports);
17
18
  __exportStar(require("./claim-task-reward.command"), exports);
18
19
  __exportStar(require("./get-my-tasks.command"), exports);
19
20
  __exportStar(require("./start-task.command"), exports);
@@ -795,4 +795,49 @@ exports.ERRORS = {
795
795
  message: 'Произошла ошибка при обновлении Telegram профиля',
796
796
  httpCode: 500,
797
797
  },
798
+ TASK_NOT_READY_FOR_CHECK: {
799
+ code: 'A184',
800
+ message: 'Задание не готово к проверке',
801
+ httpCode: 400,
802
+ },
803
+ TASK_CHECK_ERROR: {
804
+ code: 'A185',
805
+ message: 'Произошла ошибка при проверке задания',
806
+ httpCode: 500,
807
+ },
808
+ TASK_TELEGRAM_CHANNEL_NOT_SUBSCRIBED: {
809
+ code: 'A186',
810
+ message: 'Пользователь не подписан на канал',
811
+ httpCode: 400,
812
+ },
813
+ ACCOUNT_MERGE_ERROR: {
814
+ code: 'A187',
815
+ message: 'Произошла ошибка при объединении учетных записей',
816
+ httpCode: 500,
817
+ },
818
+ ACCOUNT_MERGE_SOURCE_ACCOUNT_HAS_PURCHASES: {
819
+ code: 'A188',
820
+ message: 'Объединение невозможно: на исходной учетной записи есть покупки.',
821
+ httpCode: 400,
822
+ },
823
+ ACCOUNT_MERGE_SOURCE_ACCOUNT_INVALID_SIGNUP_METHOD: {
824
+ code: 'A189',
825
+ message: 'Объединение невозможно: исходная учетная запись не была зарегистрирована через Telegram.',
826
+ httpCode: 400,
827
+ },
828
+ ACCOUNT_MERGE_TARGET_ACCOUNT_INVALID_SIGNUP_METHOD: {
829
+ code: 'A190',
830
+ message: 'Объединение возможно только с учетной записью, зарегистрированной через веб-сайт',
831
+ httpCode: 400,
832
+ },
833
+ ACCOUNT_MERGE_TARGET_ACCOUNT_HAS_TELEGRAM_PROFILE_LINKED: {
834
+ code: 'A191',
835
+ message: 'Невозможно объединить учетные записи: к выбранной учетной записи уже привязан Telegram профиль',
836
+ httpCode: 400,
837
+ },
838
+ TELEGRAM_SEND_RECEIPT_ERROR: {
839
+ code: 'A192',
840
+ message: 'Произошла ошибка при отправке чека в Telegram',
841
+ httpCode: 500,
842
+ },
798
843
  };
@@ -4,4 +4,5 @@ exports.ROLE = void 0;
4
4
  exports.ROLE = {
5
5
  USER: 'user',
6
6
  ADMIN: 'admin',
7
+ DEACTIVATED: 'deactivated',
7
8
  };
@@ -14,4 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./singup-method.enum"), exports);
17
18
  __exportStar(require("./user-status"), exports);
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SIGNUP_METHOD = void 0;
4
+ var SIGNUP_METHOD;
5
+ (function (SIGNUP_METHOD) {
6
+ SIGNUP_METHOD["WEBSITE"] = "website";
7
+ SIGNUP_METHOD["TELEGRAM"] = "telegram";
8
+ })(SIGNUP_METHOD || (exports.SIGNUP_METHOD = SIGNUP_METHOD = {}));
@@ -6,4 +6,5 @@ var USER_STATUS;
6
6
  USER_STATUS["ACTIVE"] = "active";
7
7
  USER_STATUS["INACTIVE"] = "inactive";
8
8
  USER_STATUS["TG_AUTO_REGISTERED"] = "tg_auto_registered";
9
+ USER_STATUS["MERGED"] = "merged";
9
10
  })(USER_STATUS || (exports.USER_STATUS = USER_STATUS = {}));
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CloudPaymentsReceiptSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const ItemSchema = zod_1.z.object({
6
+ Label: zod_1.z.string(),
7
+ Price: zod_1.z.number(),
8
+ Quantity: zod_1.z.number(),
9
+ Amount: zod_1.z.number(),
10
+ Department: zod_1.z.nullable(zod_1.z.unknown()),
11
+ Vat: zod_1.z.number(),
12
+ EAN13: zod_1.z.nullable(zod_1.z.string()),
13
+ AgentSign: zod_1.z.nullable(zod_1.z.unknown()),
14
+ Method: zod_1.z.number(),
15
+ Object: zod_1.z.number(),
16
+ MeasurementUnit: zod_1.z.nullable(zod_1.z.string()),
17
+ UnitCode: zod_1.z.nullable(zod_1.z.string()),
18
+ Code: zod_1.z.nullable(zod_1.z.string()),
19
+ CalcVat: zod_1.z.number(),
20
+ VatDescription: zod_1.z.string(),
21
+ MethodName: zod_1.z.nullable(zod_1.z.string()),
22
+ ObjectName: zod_1.z.nullable(zod_1.z.string()),
23
+ AgentDescription: zod_1.z.string(),
24
+ AgentData: zod_1.z.nullable(zod_1.z.unknown()),
25
+ PurveyorData: zod_1.z.nullable(zod_1.z.unknown()),
26
+ Excise: zod_1.z.nullable(zod_1.z.unknown()),
27
+ CountryOriginCode: zod_1.z.nullable(zod_1.z.string()),
28
+ CustomsDeclarationNumber: zod_1.z.nullable(zod_1.z.string()),
29
+ ProductCodeData: zod_1.z.nullable(zod_1.z.unknown()),
30
+ AdditionalPositionInfo: zod_1.z.nullable(zod_1.z.string()),
31
+ SaleObjectData: zod_1.z.nullable(zod_1.z.unknown()),
32
+ PriceChangeDescription: zod_1.z.nullable(zod_1.z.string()),
33
+ IndustryRequisiteCollection: zod_1.z.array(zod_1.z.unknown()),
34
+ MarkPartQuantity: zod_1.z.nullable(zod_1.z.unknown()),
35
+ ExpectedMarkItemStatus: zod_1.z.nullable(zod_1.z.unknown()),
36
+ MarkCheckFlags: zod_1.z.nullable(zod_1.z.unknown()),
37
+ RawMarkCode: zod_1.z.nullable(zod_1.z.string()),
38
+ GroupSeparator: zod_1.z.nullable(zod_1.z.string()),
39
+ MarkResultSign: zod_1.z.nullable(zod_1.z.unknown()),
40
+ Spic: zod_1.z.nullable(zod_1.z.string()),
41
+ PackageCode: zod_1.z.nullable(zod_1.z.string()),
42
+ Barcode: zod_1.z.nullable(zod_1.z.string()),
43
+ Discount: zod_1.z.nullable(zod_1.z.number()),
44
+ OtherDiscount: zod_1.z.nullable(zod_1.z.number()),
45
+ MarkCodes: zod_1.z.array(zod_1.z.unknown()),
46
+ });
47
+ const AmountsSchema = zod_1.z.object({
48
+ Electronic: zod_1.z.number(),
49
+ Cash: zod_1.z.number(),
50
+ AdvancePayment: zod_1.z.number(),
51
+ Credit: zod_1.z.number(),
52
+ Provision: zod_1.z.number(),
53
+ });
54
+ const VatTotalSchema = zod_1.z.object({
55
+ Vat: zod_1.z.number(),
56
+ Label: zod_1.z.string(),
57
+ Amount: zod_1.z.number(),
58
+ });
59
+ exports.CloudPaymentsReceiptSchema = zod_1.z.object({
60
+ TinyUrl: zod_1.z.string(),
61
+ Email: zod_1.z.string().email(),
62
+ Phone: zod_1.z.nullable(zod_1.z.string()),
63
+ CalculationPlace: zod_1.z.string().url(),
64
+ SettlePlace: zod_1.z.string(),
65
+ Items: zod_1.z.array(ItemSchema),
66
+ TaxationSystem: zod_1.z.number(),
67
+ Amounts: AmountsSchema,
68
+ IsBso: zod_1.z.boolean(),
69
+ Currency: zod_1.z.number(),
70
+ CustomerInfo: zod_1.z.nullable(zod_1.z.unknown()),
71
+ CustomerInn: zod_1.z.nullable(zod_1.z.string()),
72
+ CustomerBirthday: zod_1.z.nullable(zod_1.z.string()),
73
+ CustomerStateCode: zod_1.z.nullable(zod_1.z.string()),
74
+ CustomerDocType: zod_1.z.nullable(zod_1.z.string()),
75
+ CustomerDoc: zod_1.z.nullable(zod_1.z.string()),
76
+ CustomerPlace: zod_1.z.nullable(zod_1.z.string()),
77
+ HasServices: zod_1.z.boolean(),
78
+ AgentSign: zod_1.z.nullable(zod_1.z.unknown()),
79
+ EncryptedData: zod_1.z.nullable(zod_1.z.unknown()),
80
+ Signature: zod_1.z.nullable(zod_1.z.string()),
81
+ HasAgentData: zod_1.z.boolean(),
82
+ CashierName: zod_1.z.nullable(zod_1.z.string()),
83
+ CashierInn: zod_1.z.nullable(zod_1.z.string()),
84
+ PurveyorData: zod_1.z.nullable(zod_1.z.unknown()),
85
+ AgentData: zod_1.z.nullable(zod_1.z.unknown()),
86
+ DocumentNumber: zod_1.z.string(),
87
+ SessionNumber: zod_1.z.string(),
88
+ SessionCheckNumber: zod_1.z.string(),
89
+ FiscalSign: zod_1.z.string(),
90
+ FiscalDate: zod_1.z.string().datetime(),
91
+ DeviceNumber: zod_1.z.string(),
92
+ RegNumber: zod_1.z.string(),
93
+ FiscalNumber: zod_1.z.string(),
94
+ Ofd: zod_1.z.number(),
95
+ Url: zod_1.z.string(),
96
+ TestMode: zod_1.z.boolean(),
97
+ ClientAdress: zod_1.z.string().email(),
98
+ FfdVersion: zod_1.z.number(),
99
+ KkmModelName: zod_1.z.string(),
100
+ IsSmsDisabled: zod_1.z.boolean(),
101
+ ReceiptQrCodeUrl: zod_1.z.string(),
102
+ ReceiptOfdUrl: zod_1.z.string(),
103
+ ReceiptLocalUrl: zod_1.z.string(),
104
+ OfdName: zod_1.z.string(),
105
+ OfdUrl: zod_1.z.string(),
106
+ OfdInn: zod_1.z.string(),
107
+ VatTotals: zod_1.z.array(VatTotalSchema),
108
+ TaxationSystemDescription: zod_1.z.string(),
109
+ AdditionalReceiptInfos: zod_1.z.array(zod_1.z.unknown()),
110
+ UserRequisiteData: zod_1.z.nullable(zod_1.z.unknown()),
111
+ AdditionalReceiptRequisite: zod_1.z.nullable(zod_1.z.unknown()),
112
+ IndustryRequisiteCollection: zod_1.z.array(zod_1.z.unknown()),
113
+ OperationReceiptRequisite: zod_1.z.nullable(zod_1.z.unknown()),
114
+ TinyUrlRefundTarget: zod_1.z.nullable(zod_1.z.string()),
115
+ Location: zod_1.z.nullable(zod_1.z.unknown()),
116
+ TaxiData: zod_1.z.nullable(zod_1.z.unknown()),
117
+ OtherContactData: zod_1.z.nullable(zod_1.z.unknown()),
118
+ });
@@ -18,6 +18,7 @@ __exportStar(require("./ai-model-formatted.schema"), exports);
18
18
  __exportStar(require("./ai-model.schema"), exports);
19
19
  __exportStar(require("./category.schema"), exports);
20
20
  __exportStar(require("./chat.schema"), exports);
21
+ __exportStar(require("./cloud-payments-receipt.schema"), exports);
21
22
  __exportStar(require("./course-author.schema"), exports);
22
23
  __exportStar(require("./course.schema"), exports);
23
24
  __exportStar(require("./feedback.schema"), exports);
@@ -0,0 +1 @@
1
+ export * from './merge-account.command';
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+
3
+ export namespace MergeAccountCommand {
4
+ export const RequestSchema = z.object({
5
+ email: z.string().email(),
6
+ password: z.string(),
7
+ });
8
+
9
+ export type Request = z.infer<typeof RequestSchema>;
10
+
11
+ export const ResponseSchema = z.object({
12
+ data: z.object({
13
+ accessToken: z.string(),
14
+ }),
15
+ });
16
+
17
+ export type Response = z.infer<typeof ResponseSchema>;
18
+ }
package/commands/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './account-merge';
1
2
  export * from './ai-model';
2
3
  export * from './auth';
3
4
  export * from './blog';
@@ -1,3 +1,4 @@
1
+ export * from './check.command';
1
2
  export * from './get-payment-history.command';
2
3
  export * from './pay.command';
3
- export * from './check.command';
4
+ export * from './receipt.command';
@@ -0,0 +1,68 @@
1
+ import { z } from 'zod';
2
+ import { CloudPaymentsReceiptSchema } from '../../models';
3
+
4
+ export namespace ReceiptCommand {
5
+ export const RequestSchema = z
6
+ .object({
7
+ Id: z.string(),
8
+ DocumentNumber: z.string(),
9
+ SessionNumber: z.string(),
10
+ Number: z.string(),
11
+ FiscalSign: z.string(),
12
+ DeviceNumber: z.string(),
13
+ RegNumber: z.string(),
14
+ FiscalNumber: z.string(),
15
+ Inn: z.string(),
16
+ Type: z.string(),
17
+ Ofd: z.string(),
18
+ Url: z.string(),
19
+ QrCodeUrl: z.string(),
20
+ TransactionId: z.string(),
21
+ Amount: z.string().transform((amount) => parseInt(amount, 10)),
22
+ DateTime: z.string(),
23
+ InvoiceId: z.string().optional(),
24
+ SubscriptionId: z.string().optional(),
25
+ AccountId: z.string(),
26
+ Receipt: z
27
+ .string()
28
+ .transform((str, ctx) => {
29
+ try {
30
+ return JSON.parse(str);
31
+ } catch (e) {
32
+ ctx.addIssue({ code: 'custom', message: 'Invalid JSON' });
33
+ return z.NEVER;
34
+ }
35
+ })
36
+ .pipe(CloudPaymentsReceiptSchema),
37
+ })
38
+ .transform((data) => ({
39
+ id: data.Id,
40
+ docmentNumber: data.DocumentNumber,
41
+ sessionNumber: data.SessionNumber,
42
+ number: data.Number,
43
+ fiscalSign: data.FiscalSign,
44
+ deviceNumber: data.DeviceNumber,
45
+ regNumber: data.RegNumber,
46
+ fiscalNumber: data.FiscalNumber,
47
+ inn: data.Inn,
48
+ type: data.Type,
49
+ ofd: data.Ofd,
50
+ url: data.Url,
51
+ qrCodeUrl: data.QrCodeUrl,
52
+ transactionId: data.TransactionId,
53
+ amount: data.Amount,
54
+ dateTime: data.DateTime,
55
+ invoiceId: data.InvoiceId,
56
+ subscriptionId: data.SubscriptionId,
57
+ accountId: data.AccountId,
58
+ receipt: data.Receipt,
59
+ }));
60
+
61
+ export type Request = z.infer<typeof RequestSchema>;
62
+
63
+ export const ResponseSchema = z.object({
64
+ code: z.number(),
65
+ });
66
+
67
+ export type Response = z.infer<typeof ResponseSchema>;
68
+ }
@@ -1,6 +1,3 @@
1
1
  export * from './auth-with-telegram-web-app.command';
2
- export * from './check-my-telegram-profile-connected.command';
3
2
  export * from './check-telegram-profile-exists.command';
4
- export * from './connect-telegram-profile-with-verification-code.command';
5
3
  export * from './create-telegram-profile-connection-link.command';
6
- export * from './create-new-user-from-telegram-bot.command';
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ import { UserTaskSchema } from '../../models';
3
+
4
+ export namespace CheckTaskCompletionCommand {
5
+ export const RequestParamsSchema = UserTaskSchema.pick({
6
+ taskId: true,
7
+ });
8
+ export type RequestParams = z.infer<typeof RequestParamsSchema>;
9
+
10
+ export const ResponseSchema = z.object({
11
+ data: UserTaskSchema,
12
+ });
13
+ export type Response = z.infer<typeof ResponseSchema>;
14
+ }
@@ -1,3 +1,4 @@
1
+ export * from './check-task-completion.command';
1
2
  export * from './claim-task-reward.command';
2
3
  export * from './get-my-tasks.command';
3
4
  export * from './start-task.command';
@@ -795,4 +795,51 @@ export const ERRORS = {
795
795
  message: 'Произошла ошибка при обновлении Telegram профиля',
796
796
  httpCode: 500,
797
797
  },
798
+ TASK_NOT_READY_FOR_CHECK: {
799
+ code: 'A184',
800
+ message: 'Задание не готово к проверке',
801
+ httpCode: 400,
802
+ },
803
+ TASK_CHECK_ERROR: {
804
+ code: 'A185',
805
+ message: 'Произошла ошибка при проверке задания',
806
+ httpCode: 500,
807
+ },
808
+ TASK_TELEGRAM_CHANNEL_NOT_SUBSCRIBED: {
809
+ code: 'A186',
810
+ message: 'Пользователь не подписан на канал',
811
+ httpCode: 400,
812
+ },
813
+ ACCOUNT_MERGE_ERROR: {
814
+ code: 'A187',
815
+ message: 'Произошла ошибка при объединении учетных записей',
816
+ httpCode: 500,
817
+ },
818
+ ACCOUNT_MERGE_SOURCE_ACCOUNT_HAS_PURCHASES: {
819
+ code: 'A188',
820
+ message: 'Объединение невозможно: на исходной учетной записи есть покупки.',
821
+ httpCode: 400,
822
+ },
823
+ ACCOUNT_MERGE_SOURCE_ACCOUNT_INVALID_SIGNUP_METHOD: {
824
+ code: 'A189',
825
+ message:
826
+ 'Объединение невозможно: исходная учетная запись не была зарегистрирована через Telegram.',
827
+ httpCode: 400,
828
+ },
829
+ ACCOUNT_MERGE_TARGET_ACCOUNT_INVALID_SIGNUP_METHOD: {
830
+ code: 'A190',
831
+ message: 'Объединение возможно только с учетной записью, зарегистрированной через веб-сайт',
832
+ httpCode: 400,
833
+ },
834
+ ACCOUNT_MERGE_TARGET_ACCOUNT_HAS_TELEGRAM_PROFILE_LINKED: {
835
+ code: 'A191',
836
+ message:
837
+ 'Невозможно объединить учетные записи: к выбранной учетной записи уже привязан Telegram профиль',
838
+ httpCode: 400,
839
+ },
840
+ TELEGRAM_SEND_RECEIPT_ERROR: {
841
+ code: 'A192',
842
+ message: 'Произошла ошибка при отправке чека в Telegram',
843
+ httpCode: 500,
844
+ },
798
845
  };
@@ -1,6 +1,7 @@
1
1
  export const ROLE = {
2
2
  USER: 'user',
3
3
  ADMIN: 'admin',
4
+ DEACTIVATED: 'deactivated',
4
5
  } as const;
5
6
 
6
7
  export type TRole = typeof ROLE;
@@ -1 +1,2 @@
1
+ export * from './singup-method.enum';
1
2
  export * from './user-status';
@@ -0,0 +1,4 @@
1
+ export enum SIGNUP_METHOD {
2
+ WEBSITE = 'website',
3
+ TELEGRAM = 'telegram',
4
+ }
@@ -2,4 +2,5 @@ export enum USER_STATUS {
2
2
  ACTIVE = 'active',
3
3
  INACTIVE = 'inactive',
4
4
  TG_AUTO_REGISTERED = 'tg_auto_registered',
5
+ MERGED = 'merged',
5
6
  }
@@ -0,0 +1,119 @@
1
+ import { z } from 'zod';
2
+
3
+ const ItemSchema = z.object({
4
+ Label: z.string(),
5
+ Price: z.number(),
6
+ Quantity: z.number(),
7
+ Amount: z.number(),
8
+ Department: z.nullable(z.unknown()),
9
+ Vat: z.number(),
10
+ EAN13: z.nullable(z.string()),
11
+ AgentSign: z.nullable(z.unknown()),
12
+ Method: z.number(),
13
+ Object: z.number(),
14
+ MeasurementUnit: z.nullable(z.string()),
15
+ UnitCode: z.nullable(z.string()),
16
+ Code: z.nullable(z.string()),
17
+ CalcVat: z.number(),
18
+ VatDescription: z.string(),
19
+ MethodName: z.nullable(z.string()),
20
+ ObjectName: z.nullable(z.string()),
21
+ AgentDescription: z.string(),
22
+ AgentData: z.nullable(z.unknown()),
23
+ PurveyorData: z.nullable(z.unknown()),
24
+ Excise: z.nullable(z.unknown()),
25
+ CountryOriginCode: z.nullable(z.string()),
26
+ CustomsDeclarationNumber: z.nullable(z.string()),
27
+ ProductCodeData: z.nullable(z.unknown()),
28
+ AdditionalPositionInfo: z.nullable(z.string()),
29
+ SaleObjectData: z.nullable(z.unknown()),
30
+ PriceChangeDescription: z.nullable(z.string()),
31
+ IndustryRequisiteCollection: z.array(z.unknown()),
32
+ MarkPartQuantity: z.nullable(z.unknown()),
33
+ ExpectedMarkItemStatus: z.nullable(z.unknown()),
34
+ MarkCheckFlags: z.nullable(z.unknown()),
35
+ RawMarkCode: z.nullable(z.string()),
36
+ GroupSeparator: z.nullable(z.string()),
37
+ MarkResultSign: z.nullable(z.unknown()),
38
+ Spic: z.nullable(z.string()),
39
+ PackageCode: z.nullable(z.string()),
40
+ Barcode: z.nullable(z.string()),
41
+ Discount: z.nullable(z.number()),
42
+ OtherDiscount: z.nullable(z.number()),
43
+ MarkCodes: z.array(z.unknown()),
44
+ });
45
+
46
+ const AmountsSchema = z.object({
47
+ Electronic: z.number(),
48
+ Cash: z.number(),
49
+ AdvancePayment: z.number(),
50
+ Credit: z.number(),
51
+ Provision: z.number(),
52
+ });
53
+
54
+ const VatTotalSchema = z.object({
55
+ Vat: z.number(),
56
+ Label: z.string(),
57
+ Amount: z.number(),
58
+ });
59
+
60
+ export const CloudPaymentsReceiptSchema = z.object({
61
+ TinyUrl: z.string(),
62
+ Email: z.string().email(),
63
+ Phone: z.nullable(z.string()),
64
+ CalculationPlace: z.string().url(),
65
+ SettlePlace: z.string(),
66
+ Items: z.array(ItemSchema),
67
+ TaxationSystem: z.number(),
68
+ Amounts: AmountsSchema,
69
+ IsBso: z.boolean(),
70
+ Currency: z.number(),
71
+ CustomerInfo: z.nullable(z.unknown()),
72
+ CustomerInn: z.nullable(z.string()),
73
+ CustomerBirthday: z.nullable(z.string()),
74
+ CustomerStateCode: z.nullable(z.string()),
75
+ CustomerDocType: z.nullable(z.string()),
76
+ CustomerDoc: z.nullable(z.string()),
77
+ CustomerPlace: z.nullable(z.string()),
78
+ HasServices: z.boolean(),
79
+ AgentSign: z.nullable(z.unknown()),
80
+ EncryptedData: z.nullable(z.unknown()),
81
+ Signature: z.nullable(z.string()),
82
+ HasAgentData: z.boolean(),
83
+ CashierName: z.nullable(z.string()),
84
+ CashierInn: z.nullable(z.string()),
85
+ PurveyorData: z.nullable(z.unknown()),
86
+ AgentData: z.nullable(z.unknown()),
87
+ DocumentNumber: z.string(),
88
+ SessionNumber: z.string(),
89
+ SessionCheckNumber: z.string(),
90
+ FiscalSign: z.string(),
91
+ FiscalDate: z.string().datetime(),
92
+ DeviceNumber: z.string(),
93
+ RegNumber: z.string(),
94
+ FiscalNumber: z.string(),
95
+ Ofd: z.number(),
96
+ Url: z.string(),
97
+ TestMode: z.boolean(),
98
+ ClientAdress: z.string().email(),
99
+ FfdVersion: z.number(),
100
+ KkmModelName: z.string(),
101
+ IsSmsDisabled: z.boolean(),
102
+ ReceiptQrCodeUrl: z.string(),
103
+ ReceiptOfdUrl: z.string(),
104
+ ReceiptLocalUrl: z.string(),
105
+ OfdName: z.string(),
106
+ OfdUrl: z.string(),
107
+ OfdInn: z.string(),
108
+ VatTotals: z.array(VatTotalSchema),
109
+ TaxationSystemDescription: z.string(),
110
+ AdditionalReceiptInfos: z.array(z.unknown()),
111
+ UserRequisiteData: z.nullable(z.unknown()),
112
+ AdditionalReceiptRequisite: z.nullable(z.unknown()),
113
+ IndustryRequisiteCollection: z.array(z.unknown()),
114
+ OperationReceiptRequisite: z.nullable(z.unknown()),
115
+ TinyUrlRefundTarget: z.nullable(z.string()),
116
+ Location: z.nullable(z.unknown()),
117
+ TaxiData: z.nullable(z.unknown()),
118
+ OtherContactData: z.nullable(z.unknown()),
119
+ });
package/models/index.ts CHANGED
@@ -2,6 +2,7 @@ export * from './ai-model-formatted.schema';
2
2
  export * from './ai-model.schema';
3
3
  export * from './category.schema';
4
4
  export * from './chat.schema';
5
+ export * from './cloud-payments-receipt.schema';
5
6
  export * from './course-author.schema';
6
7
  export * from './course.schema';
7
8
  export * from './feedback.schema';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.5.31",
3
+ "version": "0.5.33",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,2 +0,0 @@
1
- export * from './telegram-connect';
2
- export * from './telegram-profile';
@@ -1,3 +0,0 @@
1
- export const TELEGRAM_CONNECT_AMQP_ROUTES = {
2
- CONNECT_WITH_CODE: 'tg.connect.connect-with-code.rpc',
3
- };
@@ -1,4 +0,0 @@
1
- export const TELEGRAM_PROFILE_AMQP_ROUTES = {
2
- CREATE_NEW_USER_FROM_BOT: 'tg.profile.create-new-user-from-bot',
3
- CHECK_PROFILE_EXISTS: 'tg.profile.check-exists.rpc',
4
- };
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TELEGRAM_CONNECT_AMQP_ROUTES = void 0;
4
- exports.TELEGRAM_CONNECT_AMQP_ROUTES = {
5
- CONNECT_WITH_CODE: 'tg.connect.connect-with-code.rpc',
6
- };
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TELEGRAM_PROFILE_AMQP_ROUTES = void 0;
4
- exports.TELEGRAM_PROFILE_AMQP_ROUTES = {
5
- CREATE_NEW_USER_FROM_BOT: 'tg.profile.create-new-user-from-bot',
6
- CHECK_PROFILE_EXISTS: 'tg.profile.check-exists.rpc',
7
- };
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CheckMyTelegramProfileConnectedCommand = void 0;
4
- const zod_1 = require("zod");
5
- var CheckMyTelegramProfileConnectedCommand;
6
- (function (CheckMyTelegramProfileConnectedCommand) {
7
- CheckMyTelegramProfileConnectedCommand.ResponseSchema = zod_1.z.object({
8
- data: zod_1.z.object({
9
- connected: zod_1.z.boolean(),
10
- }),
11
- });
12
- })(CheckMyTelegramProfileConnectedCommand || (exports.CheckMyTelegramProfileConnectedCommand = CheckMyTelegramProfileConnectedCommand = {}));
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConnectTelegramProfileWithVerificationCodeCommand = void 0;
4
- const zod_1 = require("zod");
5
- const models_1 = require("../../models");
6
- var ConnectTelegramProfileWithVerificationCodeCommand;
7
- (function (ConnectTelegramProfileWithVerificationCodeCommand) {
8
- ConnectTelegramProfileWithVerificationCodeCommand.RequestSchema = models_1.TelegramUserDataSchema.extend({
9
- code: zod_1.z.string(),
10
- });
11
- ConnectTelegramProfileWithVerificationCodeCommand.ResponseSchema = zod_1.z.object({
12
- isSuccess: zod_1.z.boolean(),
13
- message: zod_1.z.string().optional(),
14
- });
15
- })(ConnectTelegramProfileWithVerificationCodeCommand || (exports.ConnectTelegramProfileWithVerificationCodeCommand = ConnectTelegramProfileWithVerificationCodeCommand = {}));
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CreateNewUserFromTelegramBotCommand = void 0;
4
- const zod_1 = require("zod");
5
- const models_1 = require("../../models");
6
- var CreateNewUserFromTelegramBotCommand;
7
- (function (CreateNewUserFromTelegramBotCommand) {
8
- CreateNewUserFromTelegramBotCommand.RequestSchema = models_1.TelegramUserDataSchema.extend({
9
- partnerId: zod_1.z.string().uuid().optional(),
10
- });
11
- CreateNewUserFromTelegramBotCommand.ResponseSchema = zod_1.z.void();
12
- })(CreateNewUserFromTelegramBotCommand || (exports.CreateNewUserFromTelegramBotCommand = CreateNewUserFromTelegramBotCommand = {}));
@@ -1,11 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- export namespace CheckMyTelegramProfileConnectedCommand {
4
- export const ResponseSchema = z.object({
5
- data: z.object({
6
- connected: z.boolean(),
7
- }),
8
- });
9
-
10
- export type Response = z.infer<typeof ResponseSchema>;
11
- }
@@ -1,16 +0,0 @@
1
- import { z } from 'zod';
2
- import { TelegramUserDataSchema } from '../../models';
3
-
4
- export namespace ConnectTelegramProfileWithVerificationCodeCommand {
5
- export const RequestSchema = TelegramUserDataSchema.extend({
6
- code: z.string(),
7
- });
8
-
9
- export type Request = z.infer<typeof RequestSchema>;
10
-
11
- export const ResponseSchema = z.object({
12
- isSuccess: z.boolean(),
13
- message: z.string().optional(),
14
- });
15
- export type Response = z.infer<typeof ResponseSchema>;
16
- }
@@ -1,13 +0,0 @@
1
- import { z } from 'zod';
2
- import { TelegramUserDataSchema } from '../../models';
3
-
4
- export namespace CreateNewUserFromTelegramBotCommand {
5
- export const RequestSchema = TelegramUserDataSchema.extend({
6
- partnerId: z.string().uuid().optional(),
7
- });
8
-
9
- export type Request = z.infer<typeof RequestSchema>;
10
-
11
- export const ResponseSchema = z.void();
12
- export type Response = z.infer<typeof ResponseSchema>;
13
- }