@purpleschool/gptbot 0.5.7 → 0.5.13
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.
- package/api/controllers/auth.ts +1 -0
- package/api/controllers/index.ts +1 -0
- package/api/controllers/payment.ts +5 -0
- package/api/controllers/subscription.ts +3 -0
- package/build/api/controllers/auth.js +1 -0
- package/build/api/controllers/index.js +1 -0
- package/build/api/controllers/payment.js +7 -0
- package/build/api/controllers/subscription.js +3 -0
- package/build/commands/auth/index.js +1 -1
- package/build/commands/auth/{reset-paasword.command.js → reset-password.command.js} +1 -5
- package/build/commands/auth/verify-email-retry.command.js +9 -0
- package/build/commands/auth/verify-email.command.js +1 -5
- package/build/commands/blog/delete-post.command.js +1 -3
- package/build/commands/category/delete-category.command.js +1 -3
- package/build/commands/chat/archive-all.command.js +1 -5
- package/build/commands/chat/delete-chat.command.js +1 -3
- package/build/commands/chat/delete-chat.command.v2.js +1 -3
- package/build/commands/index.js +1 -0
- package/build/commands/page/delete-page.command.js +1 -3
- package/build/commands/payment/get-payment-history.command.js +11 -0
- package/build/commands/payment/index.js +18 -0
- package/build/commands/product/delete-product.command.js +1 -3
- package/build/commands/subscription/cancel-subscription.command.js +1 -3
- package/build/commands/subscription/create-custom-subscription-plan.command.js +24 -0
- package/build/commands/subscription/find-subscription.command.js +1 -1
- package/build/commands/subscription/get-available-upgrades.command.js +13 -0
- package/build/commands/subscription/index.js +3 -0
- package/build/commands/subscription/recover-subscription.command.js +1 -3
- package/build/commands/subscription/upgrade-subscription.command.js +41 -0
- package/build/constants/email/subjects.js +10 -0
- package/build/constants/errors/errors.js +45 -0
- package/build/constants/order/enums/index.js +1 -0
- package/build/constants/order/enums/order-type.enum.js +8 -0
- package/build/constants/payment/enums/index.js +1 -0
- package/build/constants/payment/enums/payment-history-item-type.enum.js +8 -0
- package/build/constants/subscription/enums/index.js +4 -0
- package/build/constants/subscription/enums/subscription-action.enum.js +10 -0
- package/build/constants/subscription/enums/subscription-plan.enum.js +8 -0
- package/build/constants/subscription/enums/subscription-status.enum.js +1 -0
- package/build/constants/subscription/enums/subscription-type.enum.js +8 -0
- package/build/constants/subscription/enums/user-to-subscription-type.enum.js +8 -0
- package/build/helpers/index.js +17 -0
- package/build/helpers/subscription/calc-custom-subscription-price.helper.js +19 -0
- package/build/helpers/subscription/index.js +17 -0
- package/build/index.js +1 -0
- package/build/models/message.schema.js +1 -1
- package/build/models/payment-history-item.schema.js +14 -0
- package/build/models/subscription-upgrade-schema.js +8 -0
- package/build/models/subscription.schema.js +14 -2
- package/build/models/user-to-subscription.schema.js +1 -0
- package/commands/auth/index.ts +1 -1
- package/commands/auth/{reset-paasword.command.ts → reset-password.command.ts} +1 -5
- package/commands/auth/verify-email-retry.command.ts +10 -0
- package/commands/auth/verify-email.command.ts +1 -5
- package/commands/blog/delete-post.command.ts +1 -3
- package/commands/category/delete-category.command.ts +1 -3
- package/commands/chat/archive-all.command.ts +1 -6
- package/commands/chat/delete-chat.command.ts +1 -3
- package/commands/chat/delete-chat.command.v2.ts +1 -3
- package/commands/index.ts +1 -0
- package/commands/page/delete-page.command.ts +1 -3
- package/commands/payment/get-payment-history.command.ts +10 -0
- package/commands/payment/index.ts +2 -0
- package/commands/product/delete-product.command.ts +1 -3
- package/commands/subscription/cancel-subscription.command.ts +1 -3
- package/commands/subscription/create-custom-subscription-plan.command.ts +26 -0
- package/commands/subscription/find-subscription.command.ts +2 -2
- package/commands/subscription/get-available-upgrades.command.ts +15 -0
- package/commands/subscription/index.ts +3 -0
- package/commands/subscription/recover-subscription.command.ts +1 -3
- package/commands/subscription/upgrade-subscription.command.ts +46 -0
- package/constants/email/subjects.ts +7 -0
- package/constants/errors/errors.ts +45 -0
- package/constants/order/enums/index.ts +1 -0
- package/constants/order/enums/order-type.enum.ts +4 -0
- package/constants/payment/enums/index.ts +1 -0
- package/constants/payment/enums/payment-history-item-type.enum.ts +4 -0
- package/constants/subscription/enums/index.ts +4 -0
- package/constants/subscription/enums/subscription-action.enum.ts +6 -0
- package/constants/subscription/enums/subscription-plan.enum.ts +4 -0
- package/constants/subscription/enums/subscription-status.enum.ts +1 -0
- package/constants/subscription/enums/subscription-type.enum.ts +4 -0
- package/constants/subscription/enums/user-to-subscription-type.enum.ts +4 -0
- package/helpers/index.ts +1 -0
- package/helpers/subscription/calc-custom-subscription-price.helper.ts +19 -0
- package/helpers/subscription/index.ts +1 -0
- package/index.ts +1 -0
- package/models/message.schema.ts +1 -1
- package/models/payment-history-item.schema.ts +12 -0
- package/models/subscription-upgrade-schema.ts +9 -0
- package/models/subscription.schema.ts +21 -1
- package/models/user-to-subscription.schema.ts +1 -0
- package/package.json +1 -1
package/api/controllers/auth.ts
CHANGED
package/api/controllers/index.ts
CHANGED
|
@@ -14,7 +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("./reset-
|
|
17
|
+
__exportStar(require("./reset-password.command"), exports);
|
|
18
18
|
__exportStar(require("./restore-password.command"), exports);
|
|
19
19
|
__exportStar(require("./login.command"), exports);
|
|
20
20
|
__exportStar(require("./register-user.command"), exports);
|
|
@@ -9,9 +9,5 @@ var ResetPasswordCommand;
|
|
|
9
9
|
newPassword: zod_1.z.string(),
|
|
10
10
|
userId: zod_1.z.string().uuid(),
|
|
11
11
|
});
|
|
12
|
-
ResetPasswordCommand.ResponseSchema = zod_1.z.
|
|
13
|
-
data: zod_1.z.object({
|
|
14
|
-
isSuccess: zod_1.z.boolean(),
|
|
15
|
-
}),
|
|
16
|
-
});
|
|
12
|
+
ResetPasswordCommand.ResponseSchema = zod_1.z.void();
|
|
17
13
|
})(ResetPasswordCommand || (exports.ResetPasswordCommand = ResetPasswordCommand = {}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VerifyEmailRetryCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
var VerifyEmailRetryCommand;
|
|
6
|
+
(function (VerifyEmailRetryCommand) {
|
|
7
|
+
VerifyEmailRetryCommand.RequestSchema = zod_1.z.object({});
|
|
8
|
+
VerifyEmailRetryCommand.ResponseSchema = zod_1.z.void();
|
|
9
|
+
})(VerifyEmailRetryCommand || (exports.VerifyEmailRetryCommand = VerifyEmailRetryCommand = {}));
|
|
@@ -9,9 +9,5 @@ var VerifyEmailCommand;
|
|
|
9
9
|
verifyTokenHash: true,
|
|
10
10
|
email: true,
|
|
11
11
|
});
|
|
12
|
-
VerifyEmailCommand.ResponseSchema = zod_1.z.
|
|
13
|
-
data: zod_1.z.object({
|
|
14
|
-
isSuccess: zod_1.z.boolean(),
|
|
15
|
-
}),
|
|
16
|
-
});
|
|
12
|
+
VerifyEmailCommand.ResponseSchema = zod_1.z.void();
|
|
17
13
|
})(VerifyEmailCommand || (exports.VerifyEmailCommand = VerifyEmailCommand = {}));
|
|
@@ -8,7 +8,5 @@ var DeletePostCommand;
|
|
|
8
8
|
DeletePostCommand.RequestSchema = models_1.PostSchema.pick({
|
|
9
9
|
uuid: true,
|
|
10
10
|
});
|
|
11
|
-
DeletePostCommand.ResponseSchema = zod_1.z.
|
|
12
|
-
isDeleted: zod_1.z.boolean(),
|
|
13
|
-
});
|
|
11
|
+
DeletePostCommand.ResponseSchema = zod_1.z.void();
|
|
14
12
|
})(DeletePostCommand || (exports.DeletePostCommand = DeletePostCommand = {}));
|
|
@@ -8,7 +8,5 @@ var DeleteCategoryCommand;
|
|
|
8
8
|
DeleteCategoryCommand.RequestSchema = category_schema_1.CategorySchema.pick({
|
|
9
9
|
uuid: true,
|
|
10
10
|
});
|
|
11
|
-
DeleteCategoryCommand.ResponseSchema = zod_1.z.
|
|
12
|
-
isDeleted: zod_1.z.boolean(),
|
|
13
|
-
});
|
|
11
|
+
DeleteCategoryCommand.ResponseSchema = zod_1.z.void();
|
|
14
12
|
})(DeleteCategoryCommand || (exports.DeleteCategoryCommand = DeleteCategoryCommand = {}));
|
|
@@ -4,9 +4,5 @@ exports.ArchiveAllCommand = void 0;
|
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
var ArchiveAllCommand;
|
|
6
6
|
(function (ArchiveAllCommand) {
|
|
7
|
-
ArchiveAllCommand.ResponseSchema = zod_1.z.
|
|
8
|
-
data: zod_1.z.object({
|
|
9
|
-
isArchived: zod_1.z.boolean(),
|
|
10
|
-
}),
|
|
11
|
-
});
|
|
7
|
+
ArchiveAllCommand.ResponseSchema = zod_1.z.void();
|
|
12
8
|
})(ArchiveAllCommand || (exports.ArchiveAllCommand = ArchiveAllCommand = {}));
|
|
@@ -9,7 +9,5 @@ var DeleteChatCommand;
|
|
|
9
9
|
uuid: true,
|
|
10
10
|
categoryId: true,
|
|
11
11
|
});
|
|
12
|
-
DeleteChatCommand.ResponseSchema = zod_1.z.
|
|
13
|
-
isDeleted: zod_1.z.boolean(),
|
|
14
|
-
});
|
|
12
|
+
DeleteChatCommand.ResponseSchema = zod_1.z.void();
|
|
15
13
|
})(DeleteChatCommand || (exports.DeleteChatCommand = DeleteChatCommand = {}));
|
|
@@ -8,7 +8,5 @@ var DeleteChatV2Command;
|
|
|
8
8
|
DeleteChatV2Command.RequestSchema = models_1.ChatSchema.pick({
|
|
9
9
|
uuid: true,
|
|
10
10
|
});
|
|
11
|
-
DeleteChatV2Command.ResponseSchema = zod_1.z.
|
|
12
|
-
isDeleted: zod_1.z.boolean(),
|
|
13
|
-
});
|
|
11
|
+
DeleteChatV2Command.ResponseSchema = zod_1.z.void();
|
|
14
12
|
})(DeleteChatV2Command || (exports.DeleteChatV2Command = DeleteChatV2Command = {}));
|
package/build/commands/index.js
CHANGED
|
@@ -8,7 +8,5 @@ var DeletePageCommand;
|
|
|
8
8
|
DeletePageCommand.RequestSchema = models_1.PageSchema.pick({
|
|
9
9
|
uuid: true,
|
|
10
10
|
});
|
|
11
|
-
DeletePageCommand.ResponseSchema = zod_1.z.
|
|
12
|
-
isDeleted: zod_1.z.boolean(),
|
|
13
|
-
});
|
|
11
|
+
DeletePageCommand.ResponseSchema = zod_1.z.void();
|
|
14
12
|
})(DeletePageCommand || (exports.DeletePageCommand = DeletePageCommand = {}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetPaymentHistoryCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const payment_history_item_schema_1 = require("../../models/payment-history-item.schema");
|
|
6
|
+
var GetPaymentHistoryCommand;
|
|
7
|
+
(function (GetPaymentHistoryCommand) {
|
|
8
|
+
GetPaymentHistoryCommand.ResponseSchema = zod_1.z.object({
|
|
9
|
+
data: zod_1.z.array(payment_history_item_schema_1.PaymentHistoryItemSchema),
|
|
10
|
+
});
|
|
11
|
+
})(GetPaymentHistoryCommand || (exports.GetPaymentHistoryCommand = GetPaymentHistoryCommand = {}));
|
|
@@ -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("./get-payment-history.command"), exports);
|
|
18
|
+
__exportStar(require("./pay.command"), exports);
|
|
@@ -8,7 +8,5 @@ var DeleteProductCommand;
|
|
|
8
8
|
DeleteProductCommand.RequestSchema = models_1.ProductSchema.pick({
|
|
9
9
|
uuid: true,
|
|
10
10
|
});
|
|
11
|
-
DeleteProductCommand.ResponseSchema = zod_1.z.
|
|
12
|
-
isDeleted: zod_1.z.boolean(),
|
|
13
|
-
});
|
|
11
|
+
DeleteProductCommand.ResponseSchema = zod_1.z.void();
|
|
14
12
|
})(DeleteProductCommand || (exports.DeleteProductCommand = DeleteProductCommand = {}));
|
|
@@ -10,7 +10,5 @@ var CancelSubscriptionCommand;
|
|
|
10
10
|
CancelSubscriptionCommand.RequestSchema = zod_1.z.object({
|
|
11
11
|
text: zod_1.z.string(),
|
|
12
12
|
});
|
|
13
|
-
CancelSubscriptionCommand.ResponseSchema = zod_1.z.
|
|
14
|
-
isSuccess: zod_1.z.boolean(),
|
|
15
|
-
});
|
|
13
|
+
CancelSubscriptionCommand.ResponseSchema = zod_1.z.void();
|
|
16
14
|
})(CancelSubscriptionCommand || (exports.CancelSubscriptionCommand = CancelSubscriptionCommand = {}));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateCustomSubscriptionPlanCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const models_1 = require("../../models");
|
|
6
|
+
var CreateCustomSubscriptionPlanCommand;
|
|
7
|
+
(function (CreateCustomSubscriptionPlanCommand) {
|
|
8
|
+
CreateCustomSubscriptionPlanCommand.RequestSchema = zod_1.z.object({
|
|
9
|
+
tokens: zod_1.z
|
|
10
|
+
.number()
|
|
11
|
+
.refine((val) => val % 500 === 0, {
|
|
12
|
+
message: 'tokens must be a multiple of 500',
|
|
13
|
+
})
|
|
14
|
+
.refine((val) => val > 1000, {
|
|
15
|
+
message: 'tokens must be greater than 1000',
|
|
16
|
+
})
|
|
17
|
+
.refine((val) => val <= 10000, {
|
|
18
|
+
message: 'tokens must be equal or less than 10000',
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
CreateCustomSubscriptionPlanCommand.ResponseSchema = zod_1.z.object({
|
|
22
|
+
data: models_1.SubscriptionSchema,
|
|
23
|
+
});
|
|
24
|
+
})(CreateCustomSubscriptionPlanCommand || (exports.CreateCustomSubscriptionPlanCommand = CreateCustomSubscriptionPlanCommand = {}));
|
|
@@ -9,7 +9,7 @@ var FindSubscriptionCommand;
|
|
|
9
9
|
uuid: true,
|
|
10
10
|
});
|
|
11
11
|
FindSubscriptionCommand.ResponseSchema = zod_1.z.object({
|
|
12
|
-
data: zod_1.z.array(models_1.
|
|
12
|
+
data: zod_1.z.array(models_1.SubscriptionWithSubTypesSchema),
|
|
13
13
|
});
|
|
14
14
|
FindSubscriptionCommand.ResponseByUUIDSchema = zod_1.z.object({
|
|
15
15
|
data: models_1.SubscriptionSchema,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetAvailableUpgradesCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const models_1 = require("../../models");
|
|
6
|
+
const subscription_upgrade_schema_1 = require("../../models/subscription-upgrade-schema");
|
|
7
|
+
var GetAvailableUpgradesCommand;
|
|
8
|
+
(function (GetAvailableUpgradesCommand) {
|
|
9
|
+
GetAvailableUpgradesCommand.RequestSchema = models_1.SubscriptionSchema.pick({});
|
|
10
|
+
GetAvailableUpgradesCommand.ResponseSchema = zod_1.z.object({
|
|
11
|
+
data: zod_1.z.array(subscription_upgrade_schema_1.SubscriptionUpgradeSchema),
|
|
12
|
+
});
|
|
13
|
+
})(GetAvailableUpgradesCommand || (exports.GetAvailableUpgradesCommand = GetAvailableUpgradesCommand = {}));
|
|
@@ -20,3 +20,6 @@ __exportStar(require("./create-subscription.command"), exports);
|
|
|
20
20
|
__exportStar(require("./find-subscription.command"), exports);
|
|
21
21
|
__exportStar(require("./cancel-subscription.command"), exports);
|
|
22
22
|
__exportStar(require("./recover-subscription.command"), exports);
|
|
23
|
+
__exportStar(require("./get-available-upgrades.command"), exports);
|
|
24
|
+
__exportStar(require("./update-subscription.command"), exports);
|
|
25
|
+
__exportStar(require("./create-custom-subscription-plan.command"), exports);
|
|
@@ -7,7 +7,5 @@ var RecoverSubscriptionCommand;
|
|
|
7
7
|
RecoverSubscriptionCommand.RequestParamSchema = zod_1.z.object({
|
|
8
8
|
uuidSiteUserToSubscription: zod_1.z.string(),
|
|
9
9
|
});
|
|
10
|
-
RecoverSubscriptionCommand.ResponseSchema = zod_1.z.
|
|
11
|
-
isSuccess: zod_1.z.boolean(),
|
|
12
|
-
});
|
|
10
|
+
RecoverSubscriptionCommand.ResponseSchema = zod_1.z.void();
|
|
13
11
|
})(RecoverSubscriptionCommand || (exports.RecoverSubscriptionCommand = RecoverSubscriptionCommand = {}));
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UpgradeSubscriptionCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const models_1 = require("../../models");
|
|
6
|
+
var UpgradeSubscriptionCommand;
|
|
7
|
+
(function (UpgradeSubscriptionCommand) {
|
|
8
|
+
UpgradeSubscriptionCommand.RequestSchema = models_1.SubscriptionSchema.pick({
|
|
9
|
+
uuid: true,
|
|
10
|
+
});
|
|
11
|
+
const IReceiptOrderSchema = zod_1.z.object({
|
|
12
|
+
items: zod_1.z.array(zod_1.z.object({
|
|
13
|
+
label: zod_1.z.string(),
|
|
14
|
+
price: zod_1.z.number(),
|
|
15
|
+
quantity: zod_1.z.number(),
|
|
16
|
+
amount: zod_1.z.number(),
|
|
17
|
+
vat: zod_1.z.number(),
|
|
18
|
+
})),
|
|
19
|
+
email: zod_1.z.string(),
|
|
20
|
+
isBso: zod_1.z.boolean(),
|
|
21
|
+
amounts: zod_1.z.object({
|
|
22
|
+
electronic: zod_1.z.number(),
|
|
23
|
+
}),
|
|
24
|
+
});
|
|
25
|
+
UpgradeSubscriptionCommand.ResponseSchema = zod_1.z.object({
|
|
26
|
+
publicId: zod_1.z.string(),
|
|
27
|
+
amount: zod_1.z.number(),
|
|
28
|
+
currency: zod_1.z.string(),
|
|
29
|
+
accountId: zod_1.z.string(),
|
|
30
|
+
description: zod_1.z.string(),
|
|
31
|
+
invoiceId: zod_1.z.string(),
|
|
32
|
+
email: zod_1.z.string(),
|
|
33
|
+
skin: zod_1.z.string(),
|
|
34
|
+
autoClose: zod_1.z.number(),
|
|
35
|
+
data: zod_1.z.object({
|
|
36
|
+
CloudPayments: zod_1.z.object({
|
|
37
|
+
CustomerReceipt: IReceiptOrderSchema,
|
|
38
|
+
}),
|
|
39
|
+
}),
|
|
40
|
+
});
|
|
41
|
+
})(UpgradeSubscriptionCommand || (exports.UpgradeSubscriptionCommand = UpgradeSubscriptionCommand = {}));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EMAIL_SUBJECTS = void 0;
|
|
4
|
+
exports.EMAIL_SUBJECTS = {
|
|
5
|
+
WELCOME: 'Добро пожаловать на сервис ruGPT!',
|
|
6
|
+
EMAIL_VERIFICATION: 'Подтверждение почты',
|
|
7
|
+
SUBSCRIPTION_PURCHASE: 'Спасибо за покупку подписки',
|
|
8
|
+
SUBSCRIPTION_CANCEL: 'Нам жаль, что вы от нас уходите(',
|
|
9
|
+
PRODUCT_PURCHASE: 'Спасибо за покупку тарифа',
|
|
10
|
+
};
|
|
@@ -510,4 +510,49 @@ exports.ERRORS = {
|
|
|
510
510
|
message: 'Модель ИИ устарела',
|
|
511
511
|
httpCode: 400,
|
|
512
512
|
},
|
|
513
|
+
EMAIL_ALREADY_VERIFIED: {
|
|
514
|
+
code: 'A116',
|
|
515
|
+
message: 'Электронная почта уже подтверждена',
|
|
516
|
+
httpCode: 400,
|
|
517
|
+
},
|
|
518
|
+
GET_UNREGISTERED_SESSION_ERROR: {
|
|
519
|
+
code: 'A117',
|
|
520
|
+
message: 'Не удалось получить сессию с данным идентификатором',
|
|
521
|
+
httpCode: 500,
|
|
522
|
+
},
|
|
523
|
+
UNREGISTERED_USER_LIMIT_UPDATE_ERROR: {
|
|
524
|
+
code: 'A118',
|
|
525
|
+
message: 'Не удалось обновить баланс пользователя',
|
|
526
|
+
httpCode: 500,
|
|
527
|
+
},
|
|
528
|
+
PAYMENT_HISTORY_ERROR: {
|
|
529
|
+
code: 'A119',
|
|
530
|
+
message: 'Не удалось получить историю платежей',
|
|
531
|
+
httpCode: 500,
|
|
532
|
+
},
|
|
533
|
+
SUBSCRIPTION_GET_UPGRADES_ERROR: {
|
|
534
|
+
code: 'A120',
|
|
535
|
+
message: 'Не удалось получить информацию о возможных улучшениях для подписки',
|
|
536
|
+
httpCode: 500,
|
|
537
|
+
},
|
|
538
|
+
SUBSCRIPTION_UPGRADE_ERROR: {
|
|
539
|
+
code: 'A121',
|
|
540
|
+
message: 'Не удалось улучшить подписку',
|
|
541
|
+
httpCode: 500,
|
|
542
|
+
},
|
|
543
|
+
RECURRENT_UPDATE_ERROR: {
|
|
544
|
+
code: 'A122',
|
|
545
|
+
message: 'Не удалось изменить данные подписки',
|
|
546
|
+
httpCode: 500,
|
|
547
|
+
},
|
|
548
|
+
ALREADY_HAS_SUBSCRIPTION: {
|
|
549
|
+
code: 'A123',
|
|
550
|
+
message: 'На данной учетной записи уже есть подписка',
|
|
551
|
+
httpCode: 409,
|
|
552
|
+
},
|
|
553
|
+
SUBSCRIPTION_UPGRADE_INVALID: {
|
|
554
|
+
code: 'A124',
|
|
555
|
+
message: 'Невозможно улучшить подписку с данными параметрами',
|
|
556
|
+
httpCode: 400,
|
|
557
|
+
},
|
|
513
558
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ORDER_TYPE = void 0;
|
|
4
|
+
var ORDER_TYPE;
|
|
5
|
+
(function (ORDER_TYPE) {
|
|
6
|
+
ORDER_TYPE["purchase"] = "purchase";
|
|
7
|
+
ORDER_TYPE["upgrade"] = "upgrade";
|
|
8
|
+
})(ORDER_TYPE || (exports.ORDER_TYPE = ORDER_TYPE = {}));
|
|
@@ -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("./payment-status.enum"), exports);
|
|
18
|
+
__exportStar(require("./payment-history-item-type.enum"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PAYMENT_HISTORY_ITEM_TYPE = void 0;
|
|
4
|
+
var PAYMENT_HISTORY_ITEM_TYPE;
|
|
5
|
+
(function (PAYMENT_HISTORY_ITEM_TYPE) {
|
|
6
|
+
PAYMENT_HISTORY_ITEM_TYPE["SUBSCRIPTION"] = "subscription";
|
|
7
|
+
PAYMENT_HISTORY_ITEM_TYPE["PRODUCT"] = "product";
|
|
8
|
+
})(PAYMENT_HISTORY_ITEM_TYPE || (exports.PAYMENT_HISTORY_ITEM_TYPE = PAYMENT_HISTORY_ITEM_TYPE = {}));
|
|
@@ -15,3 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./subscription-status.enum"), exports);
|
|
18
|
+
__exportStar(require("./subscription-plan.enum"), exports);
|
|
19
|
+
__exportStar(require("./user-to-subscription-type.enum"), exports);
|
|
20
|
+
__exportStar(require("./subscription-type.enum"), exports);
|
|
21
|
+
__exportStar(require("./subscription-action.enum"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SUBSCRIPTION_ACTION = void 0;
|
|
4
|
+
var SUBSCRIPTION_ACTION;
|
|
5
|
+
(function (SUBSCRIPTION_ACTION) {
|
|
6
|
+
SUBSCRIPTION_ACTION["disabled"] = "disabled";
|
|
7
|
+
SUBSCRIPTION_ACTION["buy"] = "buy";
|
|
8
|
+
SUBSCRIPTION_ACTION["upgrade"] = "upgrade";
|
|
9
|
+
SUBSCRIPTION_ACTION["possible_upgrade"] = "possible_upgrade";
|
|
10
|
+
})(SUBSCRIPTION_ACTION || (exports.SUBSCRIPTION_ACTION = SUBSCRIPTION_ACTION = {}));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SUBSCRIPTION_PLAN = void 0;
|
|
4
|
+
var SUBSCRIPTION_PLAN;
|
|
5
|
+
(function (SUBSCRIPTION_PLAN) {
|
|
6
|
+
SUBSCRIPTION_PLAN["system"] = "system";
|
|
7
|
+
SUBSCRIPTION_PLAN["custom"] = "custom";
|
|
8
|
+
})(SUBSCRIPTION_PLAN || (exports.SUBSCRIPTION_PLAN = SUBSCRIPTION_PLAN = {}));
|
|
@@ -6,4 +6,5 @@ var SUBSCRIPTION_STATUS;
|
|
|
6
6
|
SUBSCRIPTION_STATUS["active"] = "active";
|
|
7
7
|
SUBSCRIPTION_STATUS["canceled"] = "canceled";
|
|
8
8
|
SUBSCRIPTION_STATUS["expired"] = "expired";
|
|
9
|
+
SUBSCRIPTION_STATUS["upgraded"] = "upgraded";
|
|
9
10
|
})(SUBSCRIPTION_STATUS || (exports.SUBSCRIPTION_STATUS = SUBSCRIPTION_STATUS = {}));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SUBSCRIPTION_TYPE = void 0;
|
|
4
|
+
var SUBSCRIPTION_TYPE;
|
|
5
|
+
(function (SUBSCRIPTION_TYPE) {
|
|
6
|
+
SUBSCRIPTION_TYPE["main"] = "main";
|
|
7
|
+
SUBSCRIPTION_TYPE["sub"] = "sub";
|
|
8
|
+
})(SUBSCRIPTION_TYPE || (exports.SUBSCRIPTION_TYPE = SUBSCRIPTION_TYPE = {}));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.USER_TO_SUBSCRIPTION_TYPE = void 0;
|
|
4
|
+
var USER_TO_SUBSCRIPTION_TYPE;
|
|
5
|
+
(function (USER_TO_SUBSCRIPTION_TYPE) {
|
|
6
|
+
USER_TO_SUBSCRIPTION_TYPE["paid"] = "paid";
|
|
7
|
+
USER_TO_SUBSCRIPTION_TYPE["interval"] = "interval";
|
|
8
|
+
})(USER_TO_SUBSCRIPTION_TYPE || (exports.USER_TO_SUBSCRIPTION_TYPE = USER_TO_SUBSCRIPTION_TYPE = {}));
|
|
@@ -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("./subscription"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calcCustomSubscriptionPrice = calcCustomSubscriptionPrice;
|
|
4
|
+
function calcCustomSubscriptionPrice(tokenCount, period) {
|
|
5
|
+
const MIN_TOKEN_COUNT = 1000;
|
|
6
|
+
const MAX_DISCOUNT = 0.85;
|
|
7
|
+
const DISCOUNT_PER_STEP = 0.005;
|
|
8
|
+
const STEP = 500;
|
|
9
|
+
const BASE_PRICE = 0.95;
|
|
10
|
+
if (tokenCount < 0) {
|
|
11
|
+
throw new Error('Token count must be a non-negative integer');
|
|
12
|
+
}
|
|
13
|
+
if (tokenCount < MIN_TOKEN_COUNT) {
|
|
14
|
+
throw new Error(`Token count must be at least ${MIN_TOKEN_COUNT}`);
|
|
15
|
+
}
|
|
16
|
+
const discount = Math.max(0, (tokenCount - MIN_TOKEN_COUNT) / STEP) * DISCOUNT_PER_STEP;
|
|
17
|
+
const priceMultiplier = Math.max(BASE_PRICE - discount, MAX_DISCOUNT);
|
|
18
|
+
return Math.round(tokenCount * priceMultiplier * period);
|
|
19
|
+
}
|
|
@@ -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("./calc-custom-subscription-price.helper"), exports);
|
package/build/index.js
CHANGED
|
@@ -5,7 +5,7 @@ const zod_1 = require("zod");
|
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
6
|
exports.MessageSchema = zod_1.z.object({
|
|
7
7
|
uuid: zod_1.z.string().uuid(),
|
|
8
|
-
text: zod_1.z.string(),
|
|
8
|
+
text: zod_1.z.string().max(10000),
|
|
9
9
|
chatId: zod_1.z.nullable(zod_1.z.string().uuid()),
|
|
10
10
|
role: zod_1.z.string(),
|
|
11
11
|
tokenUsage: zod_1.z.number(),
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PaymentHistoryItemSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
exports.PaymentHistoryItemSchema = zod_1.z.object({
|
|
7
|
+
uuid: zod_1.z.string().uuid(),
|
|
8
|
+
status: zod_1.z.nativeEnum(constants_1.PAYMENT_STATUS),
|
|
9
|
+
sum: zod_1.z.number(),
|
|
10
|
+
description: zod_1.z.string(),
|
|
11
|
+
type: zod_1.z.nativeEnum(constants_1.PAYMENT_HISTORY_ITEM_TYPE),
|
|
12
|
+
createdAt: zod_1.z.date(),
|
|
13
|
+
updatedAt: zod_1.z.date(),
|
|
14
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SubscriptionUpgradeSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const subscription_schema_1 = require("./subscription.schema");
|
|
6
|
+
exports.SubscriptionUpgradeSchema = zod_1.z.intersection(subscription_schema_1.SubscriptionSchema, zod_1.z.object({
|
|
7
|
+
upgradePrice: zod_1.z.number(),
|
|
8
|
+
}));
|
|
@@ -1,15 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SubscriptionSchema = void 0;
|
|
3
|
+
exports.SubscriptionWithSubTypesSchema = exports.SubscriptionWithActionSchema = exports.SubscriptionSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const product_schema_1 = require("./product.schema");
|
|
6
|
+
const constants_1 = require("../constants");
|
|
6
7
|
exports.SubscriptionSchema = zod_1.z.object({
|
|
7
8
|
uuid: zod_1.z.string().uuid(),
|
|
9
|
+
mainSubscriptionId: zod_1.z.nullable(zod_1.z.string().uuid()),
|
|
8
10
|
name: zod_1.z.string().min(3).max(16384),
|
|
9
11
|
requests: zod_1.z.number(),
|
|
10
12
|
price: zod_1.z.number(),
|
|
11
13
|
features: zod_1.z.array(product_schema_1.FeaturesSchema),
|
|
12
|
-
|
|
14
|
+
plan: zod_1.z.nativeEnum(constants_1.SUBSCRIPTION_PLAN),
|
|
15
|
+
type: zod_1.z.nativeEnum(constants_1.SUBSCRIPTION_TYPE),
|
|
16
|
+
discount: zod_1.z.number(),
|
|
17
|
+
period: zod_1.z.number(),
|
|
18
|
+
tokens: zod_1.z.number(),
|
|
13
19
|
createdAt: zod_1.z.date(),
|
|
14
20
|
updatedAt: zod_1.z.date(),
|
|
15
21
|
});
|
|
22
|
+
exports.SubscriptionWithActionSchema = zod_1.z.intersection(exports.SubscriptionSchema, zod_1.z.object({
|
|
23
|
+
action: zod_1.z.nativeEnum(constants_1.SUBSCRIPTION_ACTION),
|
|
24
|
+
}));
|
|
25
|
+
exports.SubscriptionWithSubTypesSchema = zod_1.z.intersection(exports.SubscriptionWithActionSchema, zod_1.z.object({
|
|
26
|
+
subTypes: zod_1.z.array(exports.SubscriptionWithActionSchema),
|
|
27
|
+
}));
|
|
@@ -11,6 +11,7 @@ exports.UserToSubscriptionSchema = zod_1.z.object({
|
|
|
11
11
|
tokenBalance: zod_1.z.number(),
|
|
12
12
|
status: zod_1.z.string(),
|
|
13
13
|
endDate: zod_1.z.date().nullable(),
|
|
14
|
+
intervalEndDate: zod_1.z.date().nullable(),
|
|
14
15
|
createdAt: zod_1.z.date(),
|
|
15
16
|
updatedAt: zod_1.z.date(),
|
|
16
17
|
});
|