@purpleschool/gptbot 0.6.3 → 0.6.10
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/http/folder.ts +10 -0
- package/api/controllers/http/index.ts +1 -0
- package/api/controllers/http/user.ts +6 -0
- package/api/routes.ts +23 -0
- package/build/api/controllers/http/folder.js +12 -0
- package/build/api/controllers/http/index.js +1 -0
- package/build/api/controllers/http/user.js +6 -0
- package/build/api/routes.js +14 -0
- package/build/commands/chat/update-chat.command.js +5 -2
- package/build/commands/folder/create-folder.command.js +15 -0
- package/build/commands/folder/delete-folder.command.js +19 -0
- package/build/commands/folder/find-folder-by-uuid-with-chats.command.js +27 -0
- package/build/commands/folder/find-folder-by-uuid.command.js +17 -0
- package/build/commands/folder/find-folders-by-user.command.js +20 -0
- package/build/commands/folder/index.js +22 -0
- package/build/commands/folder/update-folder.command.js +18 -0
- package/build/commands/index.js +1 -0
- package/build/commands/payment/index.js +1 -0
- package/build/commands/payment/recurrent.command.js +47 -0
- package/build/commands/subscription/dismiss-subscription-renewal.command.js +12 -0
- package/build/commands/subscription/get-subscriptions-summary.command.js +1 -0
- package/build/commands/user/find-user-by-uuid.command.js +21 -0
- package/build/commands/user/find-users-by-criteria.command.js +32 -0
- package/build/commands/user/get-user-balance.command.js +15 -0
- package/build/commands/user/get-user-orders.command.js +27 -0
- package/build/commands/user/get-user-products.command.js +25 -0
- package/build/commands/user/get-user-subscriptions.command.js +25 -0
- package/build/commands/user/index.js +6 -1
- package/build/constants/errors/errors.js +43 -3
- package/build/constants/order/enums/order-sort-by.enum.js +11 -0
- package/build/constants/product/enums/index.js +1 -0
- package/build/constants/product/enums/product-sort-by.enum.js +9 -0
- package/build/constants/subscription/enums/index.js +1 -0
- package/build/constants/subscription/enums/subscription-sort-by.enum.js +9 -0
- package/build/constants/subscription/enums/subscription-status.enum.js +2 -0
- package/build/constants/ui-notification/enums/ui-notification-type.enum.js +1 -0
- package/build/constants/user/enums/index.js +2 -0
- package/build/constants/user/enums/sort-order.enum.js +8 -0
- package/build/constants/user/enums/user-sort-by.enum.js +9 -0
- package/build/models/folder.schema.js +12 -0
- package/build/models/index.js +1 -0
- package/build/models/order.schema.js +3 -1
- package/commands/chat/update-chat.command.ts +7 -3
- package/commands/folder/create-folder.command.ts +17 -0
- package/commands/folder/delete-folder.command.ts +18 -0
- package/commands/folder/find-folder-by-uuid-with-chats.command.ts +31 -0
- package/commands/folder/find-folder-by-uuid.command.ts +16 -0
- package/commands/folder/find-folders-by-user.command.ts +19 -0
- package/commands/folder/index.ts +6 -0
- package/commands/folder/update-folder.command.ts +23 -0
- package/commands/index.ts +1 -0
- package/commands/payment/index.ts +1 -0
- package/commands/payment/recurrent.command.ts +48 -0
- package/commands/subscription/dismiss-subscription-renewal.command.ts +13 -0
- package/commands/subscription/get-subscriptions-summary.command.ts +1 -0
- package/commands/user/find-user-by-uuid.command.ts +23 -0
- package/commands/user/find-users-by-criteria.command.ts +34 -0
- package/commands/user/{find-user.command.ts → get-user-balance.command.ts} +4 -3
- package/commands/user/get-user-orders.command.ts +28 -0
- package/commands/user/get-user-products.command.ts +26 -0
- package/commands/user/get-user-subscriptions.command.ts +26 -0
- package/commands/user/index.ts +6 -1
- package/constants/errors/errors.ts +43 -3
- package/constants/order/enums/order-sort-by.enum.ts +7 -0
- package/constants/product/enums/index.ts +1 -0
- package/constants/product/enums/product-sort-by.enum.ts +5 -0
- package/constants/subscription/enums/index.ts +1 -0
- package/constants/subscription/enums/subscription-sort-by.enum.ts +5 -0
- package/constants/subscription/enums/subscription-status.enum.ts +2 -0
- package/constants/ui-notification/enums/ui-notification-type.enum.ts +1 -0
- package/constants/user/enums/index.ts +2 -0
- package/constants/user/enums/sort-order.enum.ts +4 -0
- package/constants/user/enums/user-sort-by.enum.ts +5 -0
- package/models/folder.schema.ts +10 -0
- package/models/index.ts +1 -0
- package/models/order.schema.ts +3 -1
- package/package.json +1 -1
- package/build/commands/user/find-user.command.js +0 -14
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SUBSCRIPTION_SORT_BY = void 0;
|
|
4
|
+
var SUBSCRIPTION_SORT_BY;
|
|
5
|
+
(function (SUBSCRIPTION_SORT_BY) {
|
|
6
|
+
SUBSCRIPTION_SORT_BY["STATUS"] = "status";
|
|
7
|
+
SUBSCRIPTION_SORT_BY["CREATED_AT"] = "createdAt";
|
|
8
|
+
SUBSCRIPTION_SORT_BY["UPDATED_AT"] = "updatedAt";
|
|
9
|
+
})(SUBSCRIPTION_SORT_BY || (exports.SUBSCRIPTION_SORT_BY = SUBSCRIPTION_SORT_BY = {}));
|
|
@@ -7,4 +7,6 @@ var SUBSCRIPTION_STATUS;
|
|
|
7
7
|
SUBSCRIPTION_STATUS["canceled"] = "canceled";
|
|
8
8
|
SUBSCRIPTION_STATUS["expired"] = "expired";
|
|
9
9
|
SUBSCRIPTION_STATUS["upgraded"] = "upgraded";
|
|
10
|
+
SUBSCRIPTION_STATUS["rejected"] = "rejected";
|
|
11
|
+
SUBSCRIPTION_STATUS["past_due"] = "past_due";
|
|
10
12
|
})(SUBSCRIPTION_STATUS || (exports.SUBSCRIPTION_STATUS = SUBSCRIPTION_STATUS = {}));
|
|
@@ -4,4 +4,5 @@ exports.UI_NOTIFICATION_TYPE = void 0;
|
|
|
4
4
|
var UI_NOTIFICATION_TYPE;
|
|
5
5
|
(function (UI_NOTIFICATION_TYPE) {
|
|
6
6
|
UI_NOTIFICATION_TYPE["CONNECT_TELEGRAM_BONUS"] = "CONNECT_TELEGRAM_BONUS";
|
|
7
|
+
UI_NOTIFICATION_TYPE["SUBSCRIPTION_PAST_DUE"] = "SUBSCRIPTION_PAST_DUE";
|
|
7
8
|
})(UI_NOTIFICATION_TYPE || (exports.UI_NOTIFICATION_TYPE = UI_NOTIFICATION_TYPE = {}));
|
|
@@ -16,3 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./singup-method.enum"), exports);
|
|
18
18
|
__exportStar(require("./user-status"), exports);
|
|
19
|
+
__exportStar(require("./user-sort-by.enum"), exports);
|
|
20
|
+
__exportStar(require("./sort-order.enum"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SORT_ORDER = void 0;
|
|
4
|
+
var SORT_ORDER;
|
|
5
|
+
(function (SORT_ORDER) {
|
|
6
|
+
SORT_ORDER["ASC"] = "asc";
|
|
7
|
+
SORT_ORDER["DESC"] = "desc";
|
|
8
|
+
})(SORT_ORDER || (exports.SORT_ORDER = SORT_ORDER = {}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.USER_SORT_BY = void 0;
|
|
4
|
+
var USER_SORT_BY;
|
|
5
|
+
(function (USER_SORT_BY) {
|
|
6
|
+
USER_SORT_BY["EMAIL"] = "email";
|
|
7
|
+
USER_SORT_BY["CREATED_AT"] = "createdAt";
|
|
8
|
+
USER_SORT_BY["UPDATED_AT"] = "updatedAt";
|
|
9
|
+
})(USER_SORT_BY || (exports.USER_SORT_BY = USER_SORT_BY = {}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FolderSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.FolderSchema = zod_1.z.object({
|
|
6
|
+
uuid: zod_1.z.string().uuid(),
|
|
7
|
+
title: zod_1.z.string(),
|
|
8
|
+
prompt: zod_1.z.string(),
|
|
9
|
+
userId: zod_1.z.string().uuid(),
|
|
10
|
+
createdAt: zod_1.z.date(),
|
|
11
|
+
updatedAt: zod_1.z.date(),
|
|
12
|
+
});
|
package/build/models/index.js
CHANGED
|
@@ -61,3 +61,4 @@ __exportStar(require("./review.schema"), exports);
|
|
|
61
61
|
__exportStar(require("./prompt-category.schema"), exports);
|
|
62
62
|
__exportStar(require("./prompt-topic.schema"), exports);
|
|
63
63
|
__exportStar(require("./prompt.schema"), exports);
|
|
64
|
+
__exportStar(require("./folder.schema"), exports);
|
|
@@ -5,9 +5,11 @@ const zod_1 = require("zod");
|
|
|
5
5
|
exports.OrderSchema = zod_1.z.object({
|
|
6
6
|
uuid: zod_1.z.string().uuid(),
|
|
7
7
|
userId: zod_1.z.string().uuid(),
|
|
8
|
-
status: zod_1.z.
|
|
8
|
+
status: zod_1.z.string(),
|
|
9
|
+
type: zod_1.z.string(),
|
|
9
10
|
productId: zod_1.z.nullable(zod_1.z.string().uuid()),
|
|
10
11
|
subscriptionId: zod_1.z.nullable(zod_1.z.string().uuid()),
|
|
12
|
+
sum: zod_1.z.number(),
|
|
11
13
|
createdAt: zod_1.z.date(),
|
|
12
14
|
updatedAt: zod_1.z.date(),
|
|
13
15
|
});
|
|
@@ -7,9 +7,13 @@ export namespace UpdateChatCommand {
|
|
|
7
7
|
});
|
|
8
8
|
export type RequestParams = z.infer<typeof RequestParamsSchema>;
|
|
9
9
|
|
|
10
|
-
export const RequestSchema = z
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
export const RequestSchema = z
|
|
11
|
+
.object({
|
|
12
|
+
title: z.string().max(65),
|
|
13
|
+
folderId: z.string().uuid(),
|
|
14
|
+
})
|
|
15
|
+
.partial();
|
|
16
|
+
|
|
13
17
|
export type RequestBody = z.infer<typeof RequestSchema>;
|
|
14
18
|
|
|
15
19
|
export const ResponseSchema = z.object({
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { FolderSchema } from '../../models';
|
|
3
|
+
|
|
4
|
+
export namespace CreateFolderCommand {
|
|
5
|
+
export const RequestSchema = FolderSchema.pick({
|
|
6
|
+
title: true,
|
|
7
|
+
prompt: true,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
11
|
+
|
|
12
|
+
export const ResponseSchema = z.object({
|
|
13
|
+
data: FolderSchema,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { FolderSchema } from '../..';
|
|
3
|
+
|
|
4
|
+
export namespace DeleteFolderCommand {
|
|
5
|
+
export const RequestSchema = FolderSchema.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,31 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { ChatSchema, FolderSchema, MessageSchema } from '../../models';
|
|
3
|
+
|
|
4
|
+
export namespace FindFolderByUuidWithChatsCommand {
|
|
5
|
+
export const RequestParamSchema = FolderSchema.pick({
|
|
6
|
+
uuid: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export type RequestParam = z.infer<typeof RequestParamSchema>;
|
|
10
|
+
|
|
11
|
+
export const RequestSchema = z.object({
|
|
12
|
+
limit: z.coerce.number().min(1),
|
|
13
|
+
offset: z.coerce.number().min(0).default(0),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
17
|
+
|
|
18
|
+
export const ResponseSchema = z.object({
|
|
19
|
+
data: FolderSchema.extend({
|
|
20
|
+
chats: z.array(
|
|
21
|
+
ChatSchema.extend({
|
|
22
|
+
messages: z.array(MessageSchema),
|
|
23
|
+
}),
|
|
24
|
+
),
|
|
25
|
+
}),
|
|
26
|
+
page: z.number(),
|
|
27
|
+
totalPages: z.number(),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { FolderSchema } from '../../models';
|
|
3
|
+
|
|
4
|
+
export namespace FindFolderByUuidCommand {
|
|
5
|
+
export const RequestSchema = FolderSchema.pick({
|
|
6
|
+
uuid: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
10
|
+
|
|
11
|
+
export const ResponseSchema = z.object({
|
|
12
|
+
data: FolderSchema,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { FolderSchema } from '../../models';
|
|
3
|
+
|
|
4
|
+
export namespace FindFoldersByUserCommand {
|
|
5
|
+
export const RequestSchema = z.object({
|
|
6
|
+
limit: z.coerce.number().min(1),
|
|
7
|
+
offset: z.coerce.number().min(0).default(0),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
11
|
+
|
|
12
|
+
export const ResponseSchema = z.object({
|
|
13
|
+
data: z.array(FolderSchema),
|
|
14
|
+
page: z.number(),
|
|
15
|
+
totalPages: z.number(),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './create-folder.command';
|
|
2
|
+
export * from './delete-folder.command';
|
|
3
|
+
export * from './find-folders-by-user.command';
|
|
4
|
+
export * from './find-folder-by-uuid.command';
|
|
5
|
+
export * from './update-folder.command';
|
|
6
|
+
export * from './find-folder-by-uuid-with-chats.command';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { FolderSchema } from '../../models';
|
|
3
|
+
|
|
4
|
+
export namespace UpdateFolderCommand {
|
|
5
|
+
export const RequestParamSchema = FolderSchema.pick({
|
|
6
|
+
uuid: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export type RequestParam = z.infer<typeof RequestParamSchema>;
|
|
10
|
+
|
|
11
|
+
export const RequestSchema = FolderSchema.pick({
|
|
12
|
+
title: true,
|
|
13
|
+
prompt: true,
|
|
14
|
+
}).partial();
|
|
15
|
+
|
|
16
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
17
|
+
|
|
18
|
+
export const ResponseSchema = z.object({
|
|
19
|
+
data: FolderSchema,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
23
|
+
}
|
package/commands/index.ts
CHANGED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export namespace RecurrentNotificationCommand {
|
|
4
|
+
export const RequestSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
Id: z.string(),
|
|
7
|
+
AccountId: z.string(),
|
|
8
|
+
Description: z.string(),
|
|
9
|
+
Email: z.string(),
|
|
10
|
+
Amount: z.number(),
|
|
11
|
+
Currency: z.string(), // "RUB", "USD", "EUR", "GBP"
|
|
12
|
+
RequireConfirmation: z.boolean(),
|
|
13
|
+
StartDate: z.string(), // ISO‐8601 datetime in UTC, e.g. "2025-07-21T14:30:00Z"
|
|
14
|
+
Interval: z.string(), // "Week", "Month", "Year"
|
|
15
|
+
Period: z.number(),
|
|
16
|
+
Status: z.string(),
|
|
17
|
+
SuccessfulTransactionsNumber: z.number(),
|
|
18
|
+
FailedTransactionsNumber: z.number(),
|
|
19
|
+
MaxPeriods: z.number().optional(),
|
|
20
|
+
LastTransactionDate: z.string().optional(), // "yyyy-MM-dd HH:mm:ss"
|
|
21
|
+
NextTransactionDate: z.string().optional(), // "yyyy-MM-dd HH:mm:ss"
|
|
22
|
+
})
|
|
23
|
+
.transform((data) => ({
|
|
24
|
+
id: data.Id,
|
|
25
|
+
accountId: data.AccountId,
|
|
26
|
+
description: data.Description,
|
|
27
|
+
email: data.Email,
|
|
28
|
+
amount: data.Amount,
|
|
29
|
+
currency: data.Currency,
|
|
30
|
+
requireConfirmation: data.RequireConfirmation,
|
|
31
|
+
startDate: data.StartDate,
|
|
32
|
+
interval: data.Interval,
|
|
33
|
+
period: data.Period,
|
|
34
|
+
status: data.Status,
|
|
35
|
+
successfulTransactionsNumber: data.SuccessfulTransactionsNumber,
|
|
36
|
+
failedTransactionsNumber: data.FailedTransactionsNumber,
|
|
37
|
+
maxPeriods: data.MaxPeriods,
|
|
38
|
+
lastTransactionDate: data.LastTransactionDate,
|
|
39
|
+
nextTransactionDate: data.NextTransactionDate,
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
43
|
+
|
|
44
|
+
export const ResponseSchema = z.object({
|
|
45
|
+
code: z.number(),
|
|
46
|
+
});
|
|
47
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { UserToSubscriptionSchema } from '../../models';
|
|
3
|
+
|
|
4
|
+
export namespace DismissSubscriptionRenewalCommand {
|
|
5
|
+
export const RequestParamSchema = z.object({
|
|
6
|
+
uuidSiteUserToSubscription: z.string(),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export type RequestParam = z.infer<typeof RequestParamSchema>;
|
|
10
|
+
|
|
11
|
+
export const ResponseSchema = UserToSubscriptionSchema;
|
|
12
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
13
|
+
}
|
|
@@ -10,6 +10,7 @@ export namespace GetSubscriptionsSummaryCommand {
|
|
|
10
10
|
features: z.array(SubscriptionFeatureSchema),
|
|
11
11
|
subscriptions: z.array(UserToSubscriptionWithSubscriptionSchema),
|
|
12
12
|
products: z.array(UserToProductWithProductSchema),
|
|
13
|
+
latest: UserToSubscriptionWithSubscriptionSchema.nullable(),
|
|
13
14
|
});
|
|
14
15
|
|
|
15
16
|
export type Response = z.infer<typeof ResponseSchema>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { UserSchema } from '../../models';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export namespace FindUserByUuidCommand {
|
|
5
|
+
export const RequestSchema = z.object({
|
|
6
|
+
uuid: z.string().uuid(),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
10
|
+
|
|
11
|
+
export const ResponseSchema = z.object({
|
|
12
|
+
data: UserSchema.omit({
|
|
13
|
+
verifyTokenHash: true,
|
|
14
|
+
password: true,
|
|
15
|
+
passwordHash: true,
|
|
16
|
+
restoreTokenHash: true,
|
|
17
|
+
}).extend({
|
|
18
|
+
telegramId: z.number().nullable(),
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { UserSchema } from '../../models';
|
|
3
|
+
import { ROLE, SORT_ORDER, USER_SORT_BY, USER_STATUS } from '../../constants';
|
|
4
|
+
|
|
5
|
+
export namespace FindUsersByCriteriaCommand {
|
|
6
|
+
export const RequestSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
uuid: z.string().uuid().optional(),
|
|
9
|
+
email: z.string().email().optional(),
|
|
10
|
+
status: z.nativeEnum(USER_STATUS).optional(),
|
|
11
|
+
role: z.nativeEnum(ROLE).optional(),
|
|
12
|
+
createdAt: z.date().optional(),
|
|
13
|
+
updatedAt: z.date().optional(),
|
|
14
|
+
|
|
15
|
+
sortBy: z.nativeEnum(USER_SORT_BY).optional(),
|
|
16
|
+
sortOrder: z.nativeEnum(SORT_ORDER).default(SORT_ORDER.DESC).optional(),
|
|
17
|
+
})
|
|
18
|
+
.partial();
|
|
19
|
+
|
|
20
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
21
|
+
|
|
22
|
+
export const ResponseSchema = z.object({
|
|
23
|
+
data: z.array(
|
|
24
|
+
UserSchema.omit({
|
|
25
|
+
verifyTokenHash: true,
|
|
26
|
+
password: true,
|
|
27
|
+
passwordHash: true,
|
|
28
|
+
restoreTokenHash: true,
|
|
29
|
+
}),
|
|
30
|
+
),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
34
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { UserSchema } from '../../models';
|
|
2
1
|
import { z } from 'zod';
|
|
3
2
|
|
|
4
|
-
export namespace
|
|
3
|
+
export namespace GetUserBalanceCommand {
|
|
5
4
|
export const RequestSchema = z.object({
|
|
6
5
|
uuid: z.string().uuid(),
|
|
7
6
|
});
|
|
@@ -9,7 +8,9 @@ export namespace FindUserCommand {
|
|
|
9
8
|
export type Request = z.infer<typeof RequestSchema>;
|
|
10
9
|
|
|
11
10
|
export const ResponseSchema = z.object({
|
|
12
|
-
data:
|
|
11
|
+
data: z.object({
|
|
12
|
+
totalTokenBalance: z.number(),
|
|
13
|
+
}),
|
|
13
14
|
});
|
|
14
15
|
|
|
15
16
|
export type Response = z.infer<typeof ResponseSchema>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { ORDER_STATUS, ORDER_TYPE, SORT_ORDER } from '../../constants';
|
|
3
|
+
import { OrderSchema } from '../../models';
|
|
4
|
+
import { ORDER_SORT_BY } from '../../constants/order/enums/order-sort-by.enum';
|
|
5
|
+
|
|
6
|
+
export namespace GetUserOrdersCommand {
|
|
7
|
+
export const RequestParamSchema = z.object({
|
|
8
|
+
uuid: z.string().uuid(),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export type RequestParam = z.infer<typeof RequestParamSchema>;
|
|
12
|
+
|
|
13
|
+
export const RequestSchema = z
|
|
14
|
+
.object({
|
|
15
|
+
status: z.nativeEnum(ORDER_STATUS).optional(),
|
|
16
|
+
type: z.nativeEnum(ORDER_TYPE).optional(),
|
|
17
|
+
|
|
18
|
+
sortBy: z.nativeEnum(ORDER_SORT_BY).optional(),
|
|
19
|
+
sortOrder: z.nativeEnum(SORT_ORDER).default(SORT_ORDER.DESC).optional(),
|
|
20
|
+
})
|
|
21
|
+
.partial();
|
|
22
|
+
|
|
23
|
+
export const ResponseSchema = z.object({
|
|
24
|
+
data: z.array(OrderSchema),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { PRODUCT_SORT_BY, PRODUCT_STATUS, SORT_ORDER } from '../../constants';
|
|
3
|
+
import { UserToProductSchema } from '../../models';
|
|
4
|
+
|
|
5
|
+
export namespace GetUserProductsCommand {
|
|
6
|
+
export const RequestParamSchema = z.object({
|
|
7
|
+
uuid: z.string().uuid(),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export type RequestParam = z.infer<typeof RequestParamSchema>;
|
|
11
|
+
|
|
12
|
+
export const RequestSchema = z
|
|
13
|
+
.object({
|
|
14
|
+
status: z.nativeEnum(PRODUCT_STATUS).optional(),
|
|
15
|
+
|
|
16
|
+
sortBy: z.nativeEnum(PRODUCT_SORT_BY).optional(),
|
|
17
|
+
sortOrder: z.nativeEnum(SORT_ORDER).default(SORT_ORDER.DESC).optional(),
|
|
18
|
+
})
|
|
19
|
+
.partial();
|
|
20
|
+
|
|
21
|
+
export const ResponseSchema = z.object({
|
|
22
|
+
data: z.array(UserToProductSchema),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { SORT_ORDER, SUBSCRIPTION_SORT_BY, SUBSCRIPTION_STATUS } from '../../constants';
|
|
3
|
+
import { UserToSubscriptionSchema } from '../../models';
|
|
4
|
+
|
|
5
|
+
export namespace GetUserSubscriptionsCommand {
|
|
6
|
+
export const RequestParamSchema = z.object({
|
|
7
|
+
uuid: z.string().uuid(),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export type RequestParam = z.infer<typeof RequestParamSchema>;
|
|
11
|
+
|
|
12
|
+
export const RequestSchema = z
|
|
13
|
+
.object({
|
|
14
|
+
status: z.nativeEnum(SUBSCRIPTION_STATUS).optional(),
|
|
15
|
+
|
|
16
|
+
sortBy: z.nativeEnum(SUBSCRIPTION_SORT_BY).optional(),
|
|
17
|
+
sortOrder: z.nativeEnum(SORT_ORDER).default(SORT_ORDER.DESC).optional(),
|
|
18
|
+
})
|
|
19
|
+
.partial();
|
|
20
|
+
|
|
21
|
+
export const ResponseSchema = z.object({
|
|
22
|
+
data: z.array(UserToSubscriptionSchema),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
26
|
+
}
|
package/commands/user/index.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export * from './check-email.command';
|
|
2
|
-
export * from './find-user.command';
|
|
2
|
+
export * from './find-user-by-uuid.command';
|
|
3
3
|
export * from './get-me.command';
|
|
4
4
|
export * from './up-token-bonus-balance.command';
|
|
5
|
+
export * from './find-users-by-criteria.command';
|
|
6
|
+
export * from './get-user-balance.command';
|
|
7
|
+
export * from './get-user-orders.command';
|
|
8
|
+
export * from './get-user-subscriptions.command';
|
|
9
|
+
export * from './get-user-products.command';
|
|
@@ -226,11 +226,11 @@ export const ERRORS = {
|
|
|
226
226
|
},
|
|
227
227
|
SUBSCRIPTION_DELETE_ERROR: { code: 'A051', message: 'Подписка не была удалена', httpCode: 500 },
|
|
228
228
|
SUBSCRIPTION_CREATE_ERROR: { code: 'A052', message: 'Подписка не была создана', httpCode: 500 },
|
|
229
|
-
SUBSCRIPTION_FIND_ERROR: { code: 'A053', message: 'Подписка не найдена', httpCode:
|
|
229
|
+
SUBSCRIPTION_FIND_ERROR: { code: 'A053', message: 'Подписка не найдена', httpCode: 500 },
|
|
230
230
|
SUBSCRIPTIONS_FIND_ERROR: {
|
|
231
231
|
code: 'A054',
|
|
232
232
|
message: 'Подписки не найдены',
|
|
233
|
-
httpCode:
|
|
233
|
+
httpCode: 500,
|
|
234
234
|
},
|
|
235
235
|
SUBSCRIPTION_BUY_ERROR: {
|
|
236
236
|
code: 'A097',
|
|
@@ -1444,8 +1444,48 @@ export const ERRORS = {
|
|
|
1444
1444
|
message: 'Произошла ошибка при построении списка функций подписки',
|
|
1445
1445
|
httpCode: 500,
|
|
1446
1446
|
},
|
|
1447
|
-
|
|
1447
|
+
USER_TO_SUBSCRIPTION_NOT_FOUND: {
|
|
1448
1448
|
code: 'A311',
|
|
1449
|
+
message: 'Подписка пользователя не найдена',
|
|
1450
|
+
httpCode: 404,
|
|
1451
|
+
},
|
|
1452
|
+
SUBSCRIPTION_NOT_ACTIVE: {
|
|
1453
|
+
code: 'A312',
|
|
1454
|
+
message: 'Подписка не активна',
|
|
1455
|
+
httpCode: 401,
|
|
1456
|
+
},
|
|
1457
|
+
FOLDER_DELETE_ERROR: {
|
|
1458
|
+
code: 'A311',
|
|
1459
|
+
message: 'Папка не была удалена',
|
|
1460
|
+
httpCode: 500,
|
|
1461
|
+
},
|
|
1462
|
+
FOLDER_CREATE_ERROR: {
|
|
1463
|
+
code: 'A312',
|
|
1464
|
+
message: 'Папка не был создана',
|
|
1465
|
+
httpCode: 500,
|
|
1466
|
+
},
|
|
1467
|
+
FOLDER_FIND_ERROR: {
|
|
1468
|
+
code: 'A313',
|
|
1469
|
+
message: 'Папка не найдена',
|
|
1470
|
+
httpCode: 404,
|
|
1471
|
+
},
|
|
1472
|
+
FOLDERS_FIND_ERROR: {
|
|
1473
|
+
code: 'A314',
|
|
1474
|
+
message: 'Папки не найдены',
|
|
1475
|
+
httpCode: 404,
|
|
1476
|
+
},
|
|
1477
|
+
FOLDER_UPDATE_ERROR: {
|
|
1478
|
+
code: 'A315',
|
|
1479
|
+
message: 'Папка не был обновлена',
|
|
1480
|
+
httpCode: 500,
|
|
1481
|
+
},
|
|
1482
|
+
FOLDER_OWNERSHIP_ERROR: {
|
|
1483
|
+
code: 'A316',
|
|
1484
|
+
message: 'Юзер не является владельцем папки',
|
|
1485
|
+
httpCode: 400,
|
|
1486
|
+
},
|
|
1487
|
+
CHECK_USER_HAS_ACTIVE_SUBSCRIPTION_OR_PRODUCT_ERROR: {
|
|
1488
|
+
code: 'A317',
|
|
1449
1489
|
message:
|
|
1450
1490
|
'Произошла ошибка при проверке наличия активной подписки или пакета у пользователя',
|
|
1451
1491
|
httpCode: 500,
|
package/models/index.ts
CHANGED