@purpleschool/gptbot 0.8.2 → 0.8.4

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 (33) hide show
  1. package/api/controllers/http/index.ts +1 -0
  2. package/api/controllers/http/user-profile.ts +8 -0
  3. package/api/routes.ts +6 -0
  4. package/build/api/controllers/http/index.js +1 -0
  5. package/build/api/controllers/http/user-profile.js +10 -0
  6. package/build/api/routes.js +6 -0
  7. package/build/commands/index.js +1 -0
  8. package/build/commands/user-profile/delete-avatar.command.js +12 -0
  9. package/build/commands/user-profile/get-user-profile-by-user-id.command.js +14 -0
  10. package/build/commands/user-profile/index.js +20 -0
  11. package/build/commands/user-profile/update-profile.command.js +14 -0
  12. package/build/commands/user-profile/upload-avatar.command.js +12 -0
  13. package/build/constants/errors/errors.js +18 -8
  14. package/build/constants/index.js +1 -0
  15. package/build/constants/user-profile/index.js +17 -0
  16. package/build/constants/user-profile/user-profile.constant.js +10 -0
  17. package/build/models/index.js +1 -0
  18. package/build/models/user-profile.schema.js +16 -0
  19. package/build/models/webmaster-click.schema.js +2 -2
  20. package/commands/index.ts +1 -0
  21. package/commands/user-profile/delete-avatar.command.ts +14 -0
  22. package/commands/user-profile/get-user-profile-by-user-id.command.ts +16 -0
  23. package/commands/user-profile/index.ts +4 -0
  24. package/commands/user-profile/update-profile.command.ts +16 -0
  25. package/commands/user-profile/upload-avatar.command.ts +14 -0
  26. package/constants/errors/errors.ts +18 -8
  27. package/constants/index.ts +1 -0
  28. package/constants/user-profile/index.ts +1 -0
  29. package/constants/user-profile/user-profile.constant.ts +14 -0
  30. package/models/index.ts +1 -0
  31. package/models/user-profile.schema.ts +15 -0
  32. package/models/webmaster-click.schema.ts +2 -2
  33. package/package.json +1 -1
@@ -53,3 +53,4 @@ export * from './cabinet';
53
53
  export * from './webmaster';
54
54
  export * from './music';
55
55
  export * from './webmaster-click';
56
+ export * from './user-profile';
@@ -0,0 +1,8 @@
1
+ export const USER_PROFILE_CONTROLLER = 'user-profile' as const;
2
+
3
+ export const USER_PROFILE_ROUTES = {
4
+ GET_PROFILE_INFO: 'profile',
5
+ UPDATE_PROFILE: 'profile',
6
+ UPLOAD_AVATAR: 'upload-avatar',
7
+ DELETE_AVATAR: 'avatar',
8
+ } as const;
package/api/routes.ts CHANGED
@@ -796,4 +796,10 @@ export const REST_API = {
796
796
  CLOUD_PAYMENTS: {
797
797
  CALLBACK: `${ROOT}/${CONTROLLERS.CLOUD_PAYMENTS_CONTROLLER}/${CONTROLLERS.CLOUD_PAYMENTS_ROUTES.CALLBACK}`,
798
798
  },
799
+ USER_PROFILE: {
800
+ GET_PROFILE_INFO: `${ROOT}/${CONTROLLERS.USER_PROFILE_CONTROLLER}/${CONTROLLERS.USER_PROFILE_ROUTES.GET_PROFILE_INFO}`,
801
+ UPLOAD_AVATAR: `${ROOT}/${CONTROLLERS.USER_PROFILE_CONTROLLER}/${CONTROLLERS.USER_PROFILE_ROUTES.UPLOAD_AVATAR}`,
802
+ UPDATE_PROFILE: `${ROOT}/${CONTROLLERS.USER_PROFILE_CONTROLLER}/${CONTROLLERS.USER_PROFILE_ROUTES.UPDATE_PROFILE}`,
803
+ DELETE_AVATAR: `${ROOT}/${CONTROLLERS.USER_PROFILE_CONTROLLER}/${CONTROLLERS.USER_PROFILE_ROUTES.DELETE_AVATAR}`,
804
+ },
799
805
  } as const;
@@ -69,3 +69,4 @@ __exportStar(require("./cabinet"), exports);
69
69
  __exportStar(require("./webmaster"), exports);
70
70
  __exportStar(require("./music"), exports);
71
71
  __exportStar(require("./webmaster-click"), exports);
72
+ __exportStar(require("./user-profile"), exports);
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.USER_PROFILE_ROUTES = exports.USER_PROFILE_CONTROLLER = void 0;
4
+ exports.USER_PROFILE_CONTROLLER = 'user-profile';
5
+ exports.USER_PROFILE_ROUTES = {
6
+ GET_PROFILE_INFO: 'profile',
7
+ UPDATE_PROFILE: 'profile',
8
+ UPLOAD_AVATAR: 'upload-avatar',
9
+ DELETE_AVATAR: 'avatar',
10
+ };
@@ -625,4 +625,10 @@ exports.REST_API = {
625
625
  CLOUD_PAYMENTS: {
626
626
  CALLBACK: `${exports.ROOT}/${CONTROLLERS.CLOUD_PAYMENTS_CONTROLLER}/${CONTROLLERS.CLOUD_PAYMENTS_ROUTES.CALLBACK}`,
627
627
  },
628
+ USER_PROFILE: {
629
+ GET_PROFILE_INFO: `${exports.ROOT}/${CONTROLLERS.USER_PROFILE_CONTROLLER}/${CONTROLLERS.USER_PROFILE_ROUTES.GET_PROFILE_INFO}`,
630
+ UPLOAD_AVATAR: `${exports.ROOT}/${CONTROLLERS.USER_PROFILE_CONTROLLER}/${CONTROLLERS.USER_PROFILE_ROUTES.UPLOAD_AVATAR}`,
631
+ UPDATE_PROFILE: `${exports.ROOT}/${CONTROLLERS.USER_PROFILE_CONTROLLER}/${CONTROLLERS.USER_PROFILE_ROUTES.UPDATE_PROFILE}`,
632
+ DELETE_AVATAR: `${exports.ROOT}/${CONTROLLERS.USER_PROFILE_CONTROLLER}/${CONTROLLERS.USER_PROFILE_ROUTES.DELETE_AVATAR}`,
633
+ },
628
634
  };
@@ -55,3 +55,4 @@ __exportStar(require("./daily-streak"), exports);
55
55
  __exportStar(require("./cabinet"), exports);
56
56
  __exportStar(require("./webmaster"), exports);
57
57
  __exportStar(require("./webmaster-click"), exports);
58
+ __exportStar(require("./user-profile"), exports);
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeleteAvatarCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
6
+ var DeleteAvatarCommand;
7
+ (function (DeleteAvatarCommand) {
8
+ DeleteAvatarCommand.RequestSchema = zod_1.z.object({});
9
+ DeleteAvatarCommand.ResponseSchema = zod_1.z.object({
10
+ data: models_1.UserProfileResponseSchema,
11
+ });
12
+ })(DeleteAvatarCommand || (exports.DeleteAvatarCommand = DeleteAvatarCommand = {}));
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetUserProfileByUserIdCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
6
+ var GetUserProfileByUserIdCommand;
7
+ (function (GetUserProfileByUserIdCommand) {
8
+ GetUserProfileByUserIdCommand.RequestSchema = zod_1.z.object({
9
+ userId: zod_1.z.string().uuid(),
10
+ });
11
+ GetUserProfileByUserIdCommand.ResponseSchema = zod_1.z.object({
12
+ data: models_1.UserProfileResponseSchema,
13
+ });
14
+ })(GetUserProfileByUserIdCommand || (exports.GetUserProfileByUserIdCommand = GetUserProfileByUserIdCommand = {}));
@@ -0,0 +1,20 @@
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-user-profile-by-user-id.command"), exports);
18
+ __exportStar(require("./upload-avatar.command"), exports);
19
+ __exportStar(require("./update-profile.command"), exports);
20
+ __exportStar(require("./delete-avatar.command"), exports);
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UpdateProfileCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
6
+ var UpdateProfileCommand;
7
+ (function (UpdateProfileCommand) {
8
+ UpdateProfileCommand.RequestSchema = zod_1.z.object({
9
+ name: zod_1.z.string().min(1).max(100).optional(),
10
+ });
11
+ UpdateProfileCommand.ResponseSchema = zod_1.z.object({
12
+ data: models_1.UserProfileResponseSchema,
13
+ });
14
+ })(UpdateProfileCommand || (exports.UpdateProfileCommand = UpdateProfileCommand = {}));
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UploadAvatarCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
6
+ var UploadAvatarCommand;
7
+ (function (UploadAvatarCommand) {
8
+ UploadAvatarCommand.RequestSchema = zod_1.z.object({});
9
+ UploadAvatarCommand.ResponseSchema = zod_1.z.object({
10
+ data: models_1.UserProfileResponseSchema,
11
+ });
12
+ })(UploadAvatarCommand || (exports.UploadAvatarCommand = UploadAvatarCommand = {}));
@@ -2336,24 +2336,34 @@ exports.ERRORS = {
2336
2336
  message: 'Ошибка при получении записей о переходе по ссылке вебмастера',
2337
2337
  httpCode: 500,
2338
2338
  },
2339
- WEBMASTER_CLICK_CONFLICT_ERROR: {
2340
- code: 'A478',
2341
- message: 'Запись о переходе этого юзера по ссылке вебмастера уже существует',
2342
- httpCode: 409,
2343
- },
2344
2339
  WEBMASTER_CLICK_GET_OVERVIEW_ERROR: {
2345
- code: 'A479',
2340
+ code: 'A478',
2346
2341
  message: 'Ошибка при получении сводки записей о переходе по ссылке вебмастера',
2347
2342
  httpCode: 409,
2348
2343
  },
2349
2344
  TOOL_GET_GLOBAL_CONFIG_ERROR: {
2350
- code: 'A480',
2345
+ code: 'A479',
2351
2346
  message: 'Ошибка при получении глобальной конфигурации инструментов',
2352
2347
  httpCode: 500,
2353
2348
  },
2354
2349
  TOOL_GET_TOOLS_WITH_CONFIGS_ERROR: {
2355
- code: 'A481',
2350
+ code: 'A480',
2356
2351
  message: 'Ошибка при получении инструментов с конфигурациями',
2357
2352
  httpCode: 500,
2358
2353
  },
2354
+ WEBMASTER_CLICK_UPDATE_ERROR: {
2355
+ code: 'A481',
2356
+ message: 'Ошибка при обновлении записи о переходе по ссылке вебмастера',
2357
+ httpCode: 500,
2358
+ },
2359
+ USER_PROFILE_NOT_FOUND: {
2360
+ code: 'A482',
2361
+ message: 'Профиль пользователя не найден или пуст',
2362
+ httpCode: 404,
2363
+ },
2364
+ USER_PROFILE_UPSERT_ERROR: {
2365
+ code: 'A483',
2366
+ message: 'Ошибка при обновлении профиля пользователя',
2367
+ httpCode: 500,
2368
+ },
2359
2369
  };
@@ -56,3 +56,4 @@ __exportStar(require("./cabinet"), exports);
56
56
  __exportStar(require("./webmaster"), exports);
57
57
  __exportStar(require("./webmaster-balance"), exports);
58
58
  __exportStar(require("./tool-music"), exports);
59
+ __exportStar(require("./user-profile"), exports);
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./user-profile.constant"), exports);
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SUPPORTED_AVATAR_FILES = void 0;
4
+ const file_1 = require("../file");
5
+ const enums_1 = require("../file/enums");
6
+ exports.SUPPORTED_AVATAR_FILES = new Map([
7
+ ['image/jpeg', { type: enums_1.FILE_TYPE.IMAGE, size: file_1.MAX_IMAGE_UPLOAD_SIZE }],
8
+ ['image/png', { type: enums_1.FILE_TYPE.IMAGE, size: file_1.MAX_IMAGE_UPLOAD_SIZE }],
9
+ ['image/webp', { type: enums_1.FILE_TYPE.IMAGE, size: file_1.MAX_IMAGE_UPLOAD_SIZE }],
10
+ ]);
@@ -70,3 +70,4 @@ __exportStar(require("./webmaster.schema"), exports);
70
70
  __exportStar(require("./webmaster-balance.schema"), exports);
71
71
  __exportStar(require("./user-referrals.schema"), exports);
72
72
  __exportStar(require("./webmaster-click.schema"), exports);
73
+ __exportStar(require("./user-profile.schema"), exports);
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserProfileResponseSchema = exports.UserProfileSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.UserProfileSchema = zod_1.z.object({
6
+ userId: zod_1.z.string().uuid(),
7
+ name: zod_1.z.string().nullable(),
8
+ avatarUrl: zod_1.z.string().url().nullable(),
9
+ avatarKey: zod_1.z.string().nullable(),
10
+ createdAt: zod_1.z.date(),
11
+ updatedAt: zod_1.z.date(),
12
+ });
13
+ exports.UserProfileResponseSchema = exports.UserProfileSchema.omit({
14
+ createdAt: true,
15
+ updatedAt: true,
16
+ });
@@ -7,9 +7,9 @@ exports.WebmasterClickSchema = void 0;
7
7
  const zod_1 = __importDefault(require("zod"));
8
8
  exports.WebmasterClickSchema = zod_1.default.object({
9
9
  uuid: zod_1.default.string().uuid(),
10
- aliasUsed: zod_1.default.string(),
11
10
  webmasterId: zod_1.default.string().uuid(),
12
- unregisteredUserId: zod_1.default.string().uuid().nullable(),
11
+ counter: zod_1.default.number(),
12
+ day: zod_1.default.date().nullable(),
13
13
  createdAt: zod_1.default.date(),
14
14
  updatedAt: zod_1.default.date(),
15
15
  });
package/commands/index.ts CHANGED
@@ -39,3 +39,4 @@ export * from './daily-streak';
39
39
  export * from './cabinet';
40
40
  export * from './webmaster';
41
41
  export * from './webmaster-click';
42
+ export * from './user-profile';
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ import { UserProfileResponseSchema } from '../../models';
3
+
4
+ export namespace DeleteAvatarCommand {
5
+ export const RequestSchema = z.object({});
6
+
7
+ export type Request = z.infer<typeof RequestSchema>;
8
+
9
+ export const ResponseSchema = z.object({
10
+ data: UserProfileResponseSchema,
11
+ });
12
+
13
+ export type Response = z.infer<typeof ResponseSchema>;
14
+ }
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ import { UserProfileResponseSchema } from '../../models';
3
+
4
+ export namespace GetUserProfileByUserIdCommand {
5
+ export const RequestSchema = z.object({
6
+ userId: z.string().uuid(),
7
+ });
8
+
9
+ export type Request = z.infer<typeof RequestSchema>;
10
+
11
+ export const ResponseSchema = z.object({
12
+ data: UserProfileResponseSchema,
13
+ });
14
+
15
+ export type Response = z.infer<typeof ResponseSchema>;
16
+ }
@@ -0,0 +1,4 @@
1
+ export * from './get-user-profile-by-user-id.command';
2
+ export * from './upload-avatar.command';
3
+ export * from './update-profile.command';
4
+ export * from './delete-avatar.command';
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ import { UserProfileResponseSchema } from '../../models';
3
+
4
+ export namespace UpdateProfileCommand {
5
+ export const RequestSchema = z.object({
6
+ name: z.string().min(1).max(100).optional(),
7
+ });
8
+
9
+ export type Request = z.infer<typeof RequestSchema>;
10
+
11
+ export const ResponseSchema = z.object({
12
+ data: UserProfileResponseSchema,
13
+ });
14
+
15
+ export type Response = z.infer<typeof ResponseSchema>;
16
+ }
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ import { UserProfileResponseSchema } from '../../models';
3
+
4
+ export namespace UploadAvatarCommand {
5
+ export const RequestSchema = z.object({});
6
+
7
+ export type Request = z.infer<typeof RequestSchema>;
8
+
9
+ export const ResponseSchema = z.object({
10
+ data: UserProfileResponseSchema,
11
+ });
12
+
13
+ export type Response = z.infer<typeof ResponseSchema>;
14
+ }
@@ -2344,24 +2344,34 @@ export const ERRORS = {
2344
2344
  message: 'Ошибка при получении записей о переходе по ссылке вебмастера',
2345
2345
  httpCode: 500,
2346
2346
  },
2347
- WEBMASTER_CLICK_CONFLICT_ERROR: {
2348
- code: 'A478',
2349
- message: 'Запись о переходе этого юзера по ссылке вебмастера уже существует',
2350
- httpCode: 409,
2351
- },
2352
2347
  WEBMASTER_CLICK_GET_OVERVIEW_ERROR: {
2353
- code: 'A479',
2348
+ code: 'A478',
2354
2349
  message: 'Ошибка при получении сводки записей о переходе по ссылке вебмастера',
2355
2350
  httpCode: 409,
2356
2351
  },
2357
2352
  TOOL_GET_GLOBAL_CONFIG_ERROR: {
2358
- code: 'A480',
2353
+ code: 'A479',
2359
2354
  message: 'Ошибка при получении глобальной конфигурации инструментов',
2360
2355
  httpCode: 500,
2361
2356
  },
2362
2357
  TOOL_GET_TOOLS_WITH_CONFIGS_ERROR: {
2363
- code: 'A481',
2358
+ code: 'A480',
2364
2359
  message: 'Ошибка при получении инструментов с конфигурациями',
2365
2360
  httpCode: 500,
2366
2361
  },
2362
+ WEBMASTER_CLICK_UPDATE_ERROR: {
2363
+ code: 'A481',
2364
+ message: 'Ошибка при обновлении записи о переходе по ссылке вебмастера',
2365
+ httpCode: 500,
2366
+ },
2367
+ USER_PROFILE_NOT_FOUND: {
2368
+ code: 'A482',
2369
+ message: 'Профиль пользователя не найден или пуст',
2370
+ httpCode: 404,
2371
+ },
2372
+ USER_PROFILE_UPSERT_ERROR: {
2373
+ code: 'A483',
2374
+ message: 'Ошибка при обновлении профиля пользователя',
2375
+ httpCode: 500,
2376
+ },
2367
2377
  };
@@ -40,3 +40,4 @@ export * from './cabinet';
40
40
  export * from './webmaster';
41
41
  export * from './webmaster-balance';
42
42
  export * from './tool-music';
43
+ export * from './user-profile';
@@ -0,0 +1 @@
1
+ export * from './user-profile.constant';
@@ -0,0 +1,14 @@
1
+ import { MAX_IMAGE_UPLOAD_SIZE } from '../file';
2
+ import { FILE_TYPE } from '../file/enums';
3
+
4
+ export const SUPPORTED_AVATAR_FILES = new Map<
5
+ string,
6
+ {
7
+ type: FILE_TYPE;
8
+ size: number;
9
+ }
10
+ >([
11
+ ['image/jpeg', { type: FILE_TYPE.IMAGE, size: MAX_IMAGE_UPLOAD_SIZE }],
12
+ ['image/png', { type: FILE_TYPE.IMAGE, size: MAX_IMAGE_UPLOAD_SIZE }],
13
+ ['image/webp', { type: FILE_TYPE.IMAGE, size: MAX_IMAGE_UPLOAD_SIZE }],
14
+ ]);
package/models/index.ts CHANGED
@@ -54,3 +54,4 @@ export * from './webmaster.schema';
54
54
  export * from './webmaster-balance.schema';
55
55
  export * from './user-referrals.schema';
56
56
  export * from './webmaster-click.schema';
57
+ export * from './user-profile.schema';
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod';
2
+
3
+ export const UserProfileSchema = z.object({
4
+ userId: z.string().uuid(),
5
+ name: z.string().nullable(),
6
+ avatarUrl: z.string().url().nullable(),
7
+ avatarKey: z.string().nullable(),
8
+ createdAt: z.date(),
9
+ updatedAt: z.date(),
10
+ });
11
+
12
+ export const UserProfileResponseSchema = UserProfileSchema.omit({
13
+ createdAt: true,
14
+ updatedAt: true,
15
+ });
@@ -2,9 +2,9 @@ import z from 'zod';
2
2
 
3
3
  export const WebmasterClickSchema = z.object({
4
4
  uuid: z.string().uuid(),
5
- aliasUsed: z.string(),
6
5
  webmasterId: z.string().uuid(),
7
- unregisteredUserId: z.string().uuid().nullable(),
6
+ counter: z.number(),
7
+ day: z.date().nullable(),
8
8
 
9
9
  createdAt: z.date(),
10
10
  updatedAt: z.date(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.8.2",
3
+ "version": "0.8.4",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",