@purpleschool/gptbot 0.5.20 → 0.5.22

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 (43) hide show
  1. package/api/controllers/ai-model.ts +1 -0
  2. package/api/controllers/feedback.ts +2 -0
  3. package/api/controllers/index.ts +1 -0
  4. package/build/api/controllers/ai-model.js +1 -0
  5. package/build/api/controllers/feedback.js +5 -0
  6. package/build/api/controllers/index.js +1 -0
  7. package/build/commands/ai-model/find-formatted-ai-model.command.js +18 -0
  8. package/build/commands/ai-model/index.js +1 -0
  9. package/build/commands/feedback/create-feedback.command.js +18 -0
  10. package/build/commands/feedback/index.js +18 -0
  11. package/build/commands/feedback/udpate-feedback.command.js +21 -0
  12. package/build/commands/index.js +1 -0
  13. package/build/commands/page/create-page.command.js +18 -0
  14. package/build/commands/page/find-page-by-alias.command.js +4 -2
  15. package/build/commands/page/find-page.command.js +2 -1
  16. package/build/constants/errors/errors.js +25 -0
  17. package/build/constants/index.js +1 -0
  18. package/build/constants/page/enums/index.js +17 -0
  19. package/build/constants/page/enums/page-type.enum.js +9 -0
  20. package/build/constants/page/index.js +17 -0
  21. package/build/models/ai-model-formatted.schema.js +7 -0
  22. package/build/models/feedback.schema.js +13 -0
  23. package/build/models/index.js +2 -0
  24. package/build/models/page.schema.js +4 -1
  25. package/commands/ai-model/find-formatted-ai-model.command.ts +22 -0
  26. package/commands/ai-model/index.ts +1 -0
  27. package/commands/feedback/create-feedback.command.ts +20 -0
  28. package/commands/feedback/index.ts +2 -0
  29. package/commands/feedback/udpate-feedback.command.ts +26 -0
  30. package/commands/index.ts +1 -0
  31. package/commands/page/create-page.command.ts +25 -1
  32. package/commands/page/find-page-by-alias.command.ts +5 -3
  33. package/commands/page/find-page.command.ts +3 -2
  34. package/constants/errors/errors.ts +25 -0
  35. package/constants/index.ts +1 -0
  36. package/constants/page/enums/index.ts +1 -0
  37. package/constants/page/enums/page-type.enum.ts +5 -0
  38. package/constants/page/index.ts +1 -0
  39. package/models/ai-model-formatted.schema.ts +8 -0
  40. package/models/feedback.schema.ts +11 -0
  41. package/models/index.ts +2 -0
  42. package/models/page.schema.ts +4 -1
  43. package/package.json +1 -1
@@ -4,4 +4,5 @@ export const AI_MODEL_CONTROLLER_PUBLIC = 'ai-module/public' as const;
4
4
  export const AI_MODEL_ROUTES = {
5
5
  FIND_BY_UUID: 'by/uuid',
6
6
  GET_ALL: 'all',
7
+ GET_FORMATTED: 'formatted',
7
8
  } as const;
@@ -0,0 +1,2 @@
1
+ export const FEEDBACK_CONTROLLER_PRIVATE = 'private/feedback' as const;
2
+ export const FEEDBACK_CONTROLLER_PUBLIC = 'public/feedback' as const;
@@ -6,6 +6,7 @@ export * from './chat-private';
6
6
  export * from './chat-public';
7
7
  export * from './cloud-payments';
8
8
  export * from './course';
9
+ export * from './feedback';
9
10
  export * from './files';
10
11
  export * from './referral';
11
12
  export * from './message';
@@ -6,4 +6,5 @@ exports.AI_MODEL_CONTROLLER_PUBLIC = 'ai-module/public';
6
6
  exports.AI_MODEL_ROUTES = {
7
7
  FIND_BY_UUID: 'by/uuid',
8
8
  GET_ALL: 'all',
9
+ GET_FORMATTED: 'formatted',
9
10
  };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FEEDBACK_CONTROLLER_PUBLIC = exports.FEEDBACK_CONTROLLER_PRIVATE = void 0;
4
+ exports.FEEDBACK_CONTROLLER_PRIVATE = 'private/feedback';
5
+ exports.FEEDBACK_CONTROLLER_PUBLIC = 'public/feedback';
@@ -22,6 +22,7 @@ __exportStar(require("./chat-private"), exports);
22
22
  __exportStar(require("./chat-public"), exports);
23
23
  __exportStar(require("./cloud-payments"), exports);
24
24
  __exportStar(require("./course"), exports);
25
+ __exportStar(require("./feedback"), exports);
25
26
  __exportStar(require("./files"), exports);
26
27
  __exportStar(require("./referral"), exports);
27
28
  __exportStar(require("./message"), exports);
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FindFormattedAIModelCommand = void 0;
4
+ const models_1 = require("../../models");
5
+ const zod_1 = require("zod");
6
+ const ai_model_formatted_schema_1 = require("../../models/ai-model-formatted.schema");
7
+ var FindFormattedAIModelCommand;
8
+ (function (FindFormattedAIModelCommand) {
9
+ FindFormattedAIModelCommand.RequestSchema = models_1.AiModelSchema.pick({
10
+ uuid: true,
11
+ });
12
+ FindFormattedAIModelCommand.ResponseSchema = zod_1.z.object({
13
+ data: zod_1.z.array(ai_model_formatted_schema_1.AiModelFormmattedSchema),
14
+ });
15
+ FindFormattedAIModelCommand.ResponseByUUIDSchema = zod_1.z.object({
16
+ data: models_1.AiModelSchema,
17
+ });
18
+ })(FindFormattedAIModelCommand || (exports.FindFormattedAIModelCommand = FindFormattedAIModelCommand = {}));
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./create-ai-model.command"), exports);
18
18
  __exportStar(require("./delete-ai-model.command"), exports);
19
19
  __exportStar(require("./find-ai-model.command"), exports);
20
+ __exportStar(require("./find-formatted-ai-model.command"), exports);
20
21
  __exportStar(require("./update-ai-model.command"), exports);
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateFeedbackCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
6
+ var CreateFeedbackCommand;
7
+ (function (CreateFeedbackCommand) {
8
+ CreateFeedbackCommand.RequestSchema = models_1.FeedbackSchema.omit({
9
+ uuid: true,
10
+ createdAt: true,
11
+ updatedAt: true,
12
+ userId: true,
13
+ unregisteredUserId: true,
14
+ });
15
+ CreateFeedbackCommand.ResponseSchema = zod_1.z.object({
16
+ data: models_1.FeedbackSchema,
17
+ });
18
+ })(CreateFeedbackCommand || (exports.CreateFeedbackCommand = CreateFeedbackCommand = {}));
@@ -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("./create-feedback.command"), exports);
18
+ __exportStar(require("./udpate-feedback.command"), exports);
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UpdateFeedbackCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
6
+ var UpdateFeedbackCommand;
7
+ (function (UpdateFeedbackCommand) {
8
+ UpdateFeedbackCommand.RequestSchema = models_1.FeedbackSchema.omit({
9
+ createdAt: true,
10
+ updatedAt: true,
11
+ uuid: true,
12
+ userId: true,
13
+ unregisteredUserId: true,
14
+ }).partial();
15
+ UpdateFeedbackCommand.RequestParamSchema = zod_1.z.object({
16
+ uuid: zod_1.z.string().uuid(),
17
+ });
18
+ UpdateFeedbackCommand.ResponseSchema = zod_1.z.object({
19
+ data: models_1.FeedbackSchema,
20
+ });
21
+ })(UpdateFeedbackCommand || (exports.UpdateFeedbackCommand = UpdateFeedbackCommand = {}));
@@ -20,6 +20,7 @@ __exportStar(require("./blog"), exports);
20
20
  __exportStar(require("./category"), exports);
21
21
  __exportStar(require("./chat"), exports);
22
22
  __exportStar(require("./course"), exports);
23
+ __exportStar(require("./feedback"), exports);
23
24
  __exportStar(require("./message"), exports);
24
25
  __exportStar(require("./page"), exports);
25
26
  __exportStar(require("./payment"), exports);
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CreatePageCommand = void 0;
4
+ const constants_1 = require("../../constants");
4
5
  const models_1 = require("../../models");
5
6
  const zod_1 = require("zod");
6
7
  var CreatePageCommand;
@@ -9,6 +10,23 @@ var CreatePageCommand;
9
10
  uuid: true,
10
11
  createdAt: true,
11
12
  updatedAt: true,
13
+ })
14
+ .refine((data) => {
15
+ if (data.type === constants_1.PageType.AI_MODEL) {
16
+ return !!data.aIModelId;
17
+ }
18
+ return true;
19
+ }, {
20
+ message: 'aIModelId is required when type is AI_MODEL',
21
+ path: ['aIModelId'],
22
+ })
23
+ .refine((data) => {
24
+ if (data.type === constants_1.PageType.CATEGORY) {
25
+ return !!data.categoryId;
26
+ }
27
+ return true;
28
+ }, {
29
+ message: 'categoryId is required when type is CATEGORY',
12
30
  });
13
31
  CreatePageCommand.ResponseSchema = zod_1.z.object({
14
32
  data: models_1.PageSchema,
@@ -13,13 +13,15 @@ var FindPageByAliasCommand;
13
13
  });
14
14
  FindPageByAliasCommand.ResponseByAliasSchema = zod_1.z.object({
15
15
  data: models_1.PageSchema.extend({
16
- category: models_1.CategorySchema,
16
+ category: zod_1.z.union([models_1.CategorySchema, zod_1.z.null()]),
17
+ aIModel: zod_1.z.union([models_1.AiModelSchema, zod_1.z.null()]),
17
18
  questions: zod_1.z.array(models_1.QuestionSchema),
18
19
  }),
19
20
  });
20
21
  FindPageByAliasCommand.ResponseByAllSchema = zod_1.z.object({
21
22
  data: zod_1.z.array(models_1.PageSchema.extend({
22
- category: models_1.CategorySchema,
23
+ category: zod_1.z.union([models_1.CategorySchema, zod_1.z.null()]),
24
+ aIModel: zod_1.z.union([models_1.AiModelSchema, zod_1.z.null()]),
23
25
  questions: zod_1.z.array(models_1.QuestionSchema),
24
26
  })),
25
27
  });
@@ -13,7 +13,8 @@ var FindPageCommand;
13
13
  });
14
14
  FindPageCommand.ResponseByUUIDSchema = zod_1.z.object({
15
15
  data: models_1.PageSchema.extend({
16
- category: models_1.CategorySchema,
16
+ category: zod_1.z.union([models_1.CategorySchema, zod_1.z.null()]),
17
+ aIModel: zod_1.z.union([models_1.AiModelSchema, zod_1.z.null()]),
17
18
  questions: zod_1.z.array(models_1.QuestionSchema),
18
19
  }),
19
20
  });
@@ -625,4 +625,29 @@ exports.ERRORS = {
625
625
  message: 'Подписка не поддерживает автопродление',
626
626
  httpCode: 400,
627
627
  },
628
+ FEEDBACK_CREATE_ERROR: {
629
+ code: 'A139',
630
+ message: 'Не удалось создать отзыв',
631
+ httpCode: 500,
632
+ },
633
+ FEEDBACK_NOT_FOUND: {
634
+ code: 'A140',
635
+ message: 'Отзыв не найден',
636
+ httpCode: 404,
637
+ },
638
+ FEEDBACK_UPDATE_ERROR: {
639
+ code: 'A141',
640
+ message: 'Не удалось обновить отзыв',
641
+ httpCode: 500,
642
+ },
643
+ FEEDBACK_DELETE_ERROR: {
644
+ code: 'A142',
645
+ message: 'Не удалось удалить отзыв',
646
+ httpCode: 500,
647
+ },
648
+ FEEDBACK_OWNERSHIP_ERROR: {
649
+ code: 'A143',
650
+ message: 'Пользователь не является владельцем отзыва',
651
+ httpCode: 400,
652
+ },
628
653
  };
@@ -24,6 +24,7 @@ __exportStar(require("./email"), exports);
24
24
  __exportStar(require("./errors"), exports);
25
25
  __exportStar(require("./message"), exports);
26
26
  __exportStar(require("./order"), exports);
27
+ __exportStar(require("./page"), exports);
27
28
  __exportStar(require("./payment"), exports);
28
29
  __exportStar(require("./product"), exports);
29
30
  __exportStar(require("./referral"), 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("./page-type.enum"), exports);
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PageType = void 0;
4
+ var PageType;
5
+ (function (PageType) {
6
+ PageType["CATEGORY"] = "category";
7
+ PageType["AI_MODEL"] = "ai_model";
8
+ PageType["OTHER"] = "other";
9
+ })(PageType || (exports.PageType = PageType = {}));
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./enums"), exports);
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AiModelFormmattedSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const ai_model_schema_1 = require("./ai-model.schema");
6
+ const page_schema_1 = require("./page.schema");
7
+ exports.AiModelFormmattedSchema = zod_1.z.intersection(ai_model_schema_1.AiModelSchema, zod_1.z.object({ page: page_schema_1.PageSchema.pick({ alias: true }).optional() }));
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FeedbackSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.FeedbackSchema = zod_1.z.object({
6
+ uuid: zod_1.z.string().uuid(),
7
+ userId: zod_1.z.string().uuid().nullable().optional(),
8
+ unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
9
+ rating: zod_1.z.number().min(1).max(5),
10
+ comment: zod_1.z.string().nullable().optional(),
11
+ createdAt: zod_1.z.date(),
12
+ updatedAt: zod_1.z.date(),
13
+ });
@@ -14,11 +14,13 @@ 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("./ai-model-formatted.schema"), exports);
17
18
  __exportStar(require("./ai-model.schema"), exports);
18
19
  __exportStar(require("./category.schema"), exports);
19
20
  __exportStar(require("./chat.schema"), exports);
20
21
  __exportStar(require("./course-author.schema"), exports);
21
22
  __exportStar(require("./course.schema"), exports);
23
+ __exportStar(require("./feedback.schema"), exports);
22
24
  __exportStar(require("./lesson.schema"), exports);
23
25
  __exportStar(require("./message.schema"), exports);
24
26
  __exportStar(require("./order.schema"), exports);
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PageSchema = void 0;
4
4
  const zod_1 = require("zod");
5
+ const constants_1 = require("../constants");
5
6
  exports.PageSchema = zod_1.z.object({
6
7
  uuid: zod_1.z.string().uuid(),
7
8
  metaTitle: zod_1.z.string().min(3).max(16384),
@@ -10,7 +11,9 @@ exports.PageSchema = zod_1.z.object({
10
11
  subTitle: zod_1.z.string().min(3).max(16384),
11
12
  seoTextMd: zod_1.z.string().min(3).max(16384),
12
13
  alias: zod_1.z.string().min(3).max(16384),
13
- categoryId: zod_1.z.string().uuid(),
14
+ categoryId: zod_1.z.string().uuid().nullable().optional(),
15
+ aIModelId: zod_1.z.string().uuid().nullable().optional(),
16
+ type: zod_1.z.nativeEnum(constants_1.PageType),
14
17
  createdAt: zod_1.z.date(),
15
18
  updatedAt: zod_1.z.date(),
16
19
  });
@@ -0,0 +1,22 @@
1
+ import { AiModelSchema } from '../../models';
2
+ import { z } from 'zod';
3
+ import { AiModelFormmattedSchema } from '../../models/ai-model-formatted.schema';
4
+
5
+ export namespace FindFormattedAIModelCommand {
6
+ export const RequestSchema = AiModelSchema.pick({
7
+ uuid: true,
8
+ });
9
+
10
+ export type Request = z.infer<typeof RequestSchema>;
11
+
12
+ export const ResponseSchema = z.object({
13
+ data: z.array(AiModelFormmattedSchema),
14
+ });
15
+ export type Response = z.infer<typeof ResponseSchema>;
16
+
17
+ export const ResponseByUUIDSchema = z.object({
18
+ data: AiModelSchema,
19
+ });
20
+
21
+ export type ResponseByUUID = z.infer<typeof ResponseByUUIDSchema>;
22
+ }
@@ -1,4 +1,5 @@
1
1
  export * from './create-ai-model.command';
2
2
  export * from './delete-ai-model.command';
3
3
  export * from './find-ai-model.command';
4
+ export * from './find-formatted-ai-model.command';
4
5
  export * from './update-ai-model.command';
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ import { FeedbackSchema } from '../../models';
3
+
4
+ export namespace CreateFeedbackCommand {
5
+ export const RequestSchema = FeedbackSchema.omit({
6
+ uuid: true,
7
+ createdAt: true,
8
+ updatedAt: true,
9
+ userId: true,
10
+ unregisteredUserId: true,
11
+ });
12
+
13
+ export type Request = z.infer<typeof RequestSchema>;
14
+
15
+ export const ResponseSchema = z.object({
16
+ data: FeedbackSchema,
17
+ });
18
+
19
+ export type Response = z.infer<typeof ResponseSchema>;
20
+ }
@@ -0,0 +1,2 @@
1
+ export * from './create-feedback.command';
2
+ export * from './udpate-feedback.command';
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ import { FeedbackSchema } from '../../models';
3
+
4
+ export namespace UpdateFeedbackCommand {
5
+ export const RequestSchema = FeedbackSchema.omit({
6
+ createdAt: true,
7
+ updatedAt: true,
8
+ uuid: true,
9
+ userId: true,
10
+ unregisteredUserId: true,
11
+ }).partial();
12
+
13
+ export type Request = z.infer<typeof RequestSchema>;
14
+
15
+ export const RequestParamSchema = z.object({
16
+ uuid: z.string().uuid(),
17
+ });
18
+
19
+ export type RequestParam = z.infer<typeof RequestParamSchema>;
20
+
21
+ export const ResponseSchema = z.object({
22
+ data: FeedbackSchema,
23
+ });
24
+
25
+ export type Response = z.infer<typeof ResponseSchema>;
26
+ }
package/commands/index.ts CHANGED
@@ -4,6 +4,7 @@ export * from './blog';
4
4
  export * from './category';
5
5
  export * from './chat';
6
6
  export * from './course';
7
+ export * from './feedback';
7
8
  export * from './message';
8
9
  export * from './page';
9
10
  export * from './payment';
@@ -1,3 +1,4 @@
1
+ import { PageType } from '../../constants';
1
2
  import { PageSchema } from '../../models';
2
3
  import { z } from 'zod';
3
4
 
@@ -6,7 +7,30 @@ export namespace CreatePageCommand {
6
7
  uuid: true,
7
8
  createdAt: true,
8
9
  updatedAt: true,
9
- });
10
+ })
11
+ .refine(
12
+ (data) => {
13
+ if (data.type === PageType.AI_MODEL) {
14
+ return !!data.aIModelId;
15
+ }
16
+ return true;
17
+ },
18
+ {
19
+ message: 'aIModelId is required when type is AI_MODEL',
20
+ path: ['aIModelId'],
21
+ },
22
+ )
23
+ .refine(
24
+ (data) => {
25
+ if (data.type === PageType.CATEGORY) {
26
+ return !!data.categoryId;
27
+ }
28
+ return true;
29
+ },
30
+ {
31
+ message: 'categoryId is required when type is CATEGORY',
32
+ },
33
+ );
10
34
 
11
35
  export type Request = z.infer<typeof RequestSchema>;
12
36
 
@@ -1,4 +1,4 @@
1
- import { CategorySchema, PageSchema, QuestionSchema } from '../../models';
1
+ import { AiModelSchema, CategorySchema, PageSchema, QuestionSchema } from '../../models';
2
2
  import { z } from 'zod';
3
3
 
4
4
  export namespace FindPageByAliasCommand {
@@ -16,7 +16,8 @@ export namespace FindPageByAliasCommand {
16
16
 
17
17
  export const ResponseByAliasSchema = z.object({
18
18
  data: PageSchema.extend({
19
- category: CategorySchema,
19
+ category: z.union([CategorySchema, z.null()]),
20
+ aIModel: z.union([AiModelSchema, z.null()]),
20
21
  questions: z.array(QuestionSchema),
21
22
  }),
22
23
  });
@@ -24,7 +25,8 @@ export namespace FindPageByAliasCommand {
24
25
  export const ResponseByAllSchema = z.object({
25
26
  data: z.array(
26
27
  PageSchema.extend({
27
- category: CategorySchema,
28
+ category: z.union([CategorySchema, z.null()]),
29
+ aIModel: z.union([AiModelSchema, z.null()]),
28
30
  questions: z.array(QuestionSchema),
29
31
  }),
30
32
  ),
@@ -1,4 +1,4 @@
1
- import { CategorySchema, PageSchema, QuestionSchema } from '../../models';
1
+ import { AiModelSchema, CategorySchema, PageSchema, QuestionSchema } from '../../models';
2
2
  import { z } from 'zod';
3
3
 
4
4
  export namespace FindPageCommand {
@@ -16,7 +16,8 @@ export namespace FindPageCommand {
16
16
 
17
17
  export const ResponseByUUIDSchema = z.object({
18
18
  data: PageSchema.extend({
19
- category: CategorySchema,
19
+ category: z.union([CategorySchema, z.null()]),
20
+ aIModel: z.union([AiModelSchema, z.null()]),
20
21
  questions: z.array(QuestionSchema),
21
22
  }),
22
23
  });
@@ -625,4 +625,29 @@ export const ERRORS = {
625
625
  message: 'Подписка не поддерживает автопродление',
626
626
  httpCode: 400,
627
627
  },
628
+ FEEDBACK_CREATE_ERROR: {
629
+ code: 'A139',
630
+ message: 'Не удалось создать отзыв',
631
+ httpCode: 500,
632
+ },
633
+ FEEDBACK_NOT_FOUND: {
634
+ code: 'A140',
635
+ message: 'Отзыв не найден',
636
+ httpCode: 404,
637
+ },
638
+ FEEDBACK_UPDATE_ERROR: {
639
+ code: 'A141',
640
+ message: 'Не удалось обновить отзыв',
641
+ httpCode: 500,
642
+ },
643
+ FEEDBACK_DELETE_ERROR: {
644
+ code: 'A142',
645
+ message: 'Не удалось удалить отзыв',
646
+ httpCode: 500,
647
+ },
648
+ FEEDBACK_OWNERSHIP_ERROR: {
649
+ code: 'A143',
650
+ message: 'Пользователь не является владельцем отзыва',
651
+ httpCode: 400,
652
+ },
628
653
  };
@@ -8,6 +8,7 @@ export * from './email';
8
8
  export * from './errors';
9
9
  export * from './message';
10
10
  export * from './order';
11
+ export * from './page';
11
12
  export * from './payment';
12
13
  export * from './product';
13
14
  export * from './referral';
@@ -0,0 +1 @@
1
+ export * from './page-type.enum';
@@ -0,0 +1,5 @@
1
+ export enum PageType {
2
+ CATEGORY = 'category',
3
+ AI_MODEL = 'ai_model',
4
+ OTHER = 'other',
5
+ }
@@ -0,0 +1 @@
1
+ export * from './enums';
@@ -0,0 +1,8 @@
1
+ import { z } from 'zod';
2
+ import { AiModelSchema } from './ai-model.schema';
3
+ import { PageSchema } from './page.schema';
4
+
5
+ export const AiModelFormmattedSchema = z.intersection(
6
+ AiModelSchema,
7
+ z.object({ page: PageSchema.pick({ alias: true }).optional() }),
8
+ );
@@ -0,0 +1,11 @@
1
+ import { z } from 'zod';
2
+
3
+ export const FeedbackSchema = z.object({
4
+ uuid: z.string().uuid(),
5
+ userId: z.string().uuid().nullable().optional(),
6
+ unregisteredUserId: z.string().uuid().nullable().optional(),
7
+ rating: z.number().min(1).max(5),
8
+ comment: z.string().nullable().optional(),
9
+ createdAt: z.date(),
10
+ updatedAt: z.date(),
11
+ });
package/models/index.ts CHANGED
@@ -1,8 +1,10 @@
1
+ export * from './ai-model-formatted.schema';
1
2
  export * from './ai-model.schema';
2
3
  export * from './category.schema';
3
4
  export * from './chat.schema';
4
5
  export * from './course-author.schema';
5
6
  export * from './course.schema';
7
+ export * from './feedback.schema';
6
8
  export * from './lesson.schema';
7
9
  export * from './message.schema';
8
10
  export * from './order.schema';
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { PageType } from '../constants';
2
3
 
3
4
  export const PageSchema = z.object({
4
5
  uuid: z.string().uuid(),
@@ -8,7 +9,9 @@ export const PageSchema = z.object({
8
9
  subTitle: z.string().min(3).max(16384),
9
10
  seoTextMd: z.string().min(3).max(16384),
10
11
  alias: z.string().min(3).max(16384),
11
- categoryId: z.string().uuid(),
12
+ categoryId: z.string().uuid().nullable().optional(),
13
+ aIModelId: z.string().uuid().nullable().optional(),
14
+ type: z.nativeEnum(PageType),
12
15
 
13
16
  createdAt: z.date(),
14
17
  updatedAt: z.date(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.5.20",
3
+ "version": "0.5.22",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {