@purpleschool/gptbot 0.0.3 → 0.0.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.
@@ -3,4 +3,5 @@ export const CATEGORY_CONTROLLER = 'category' as const;
3
3
  export const CATEGORY_ROUTES = {
4
4
  FIND_BY_UUID: 'by/uuid',
5
5
  GET_ALL: 'all',
6
+ GET_FORMATTED: 'by/formatted',
6
7
  } as const;
@@ -5,4 +5,5 @@ exports.CATEGORY_CONTROLLER = 'category';
5
5
  exports.CATEGORY_ROUTES = {
6
6
  FIND_BY_UUID: 'by/uuid',
7
7
  GET_ALL: 'all',
8
+ GET_FORMATTED: 'by/formatted',
8
9
  };
@@ -2,15 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CreateCategoryCommand = void 0;
4
4
  const zod_1 = require("zod");
5
- const category_schema_1 = require("../../models/category.schema");
5
+ const models_1 = require("../../models");
6
6
  var CreateCategoryCommand;
7
7
  (function (CreateCategoryCommand) {
8
- CreateCategoryCommand.RequestSchema = category_schema_1.CategorySchema.omit({
8
+ CreateCategoryCommand.RequestSchema = models_1.CategorySchema.omit({
9
9
  uuid: true,
10
10
  createdAt: true,
11
11
  updatedAt: true,
12
12
  });
13
13
  CreateCategoryCommand.ResponseSchema = zod_1.z.object({
14
- data: category_schema_1.CategorySchema,
14
+ data: models_1.CategorySchema,
15
15
  });
16
16
  })(CreateCategoryCommand || (exports.CreateCategoryCommand = CreateCategoryCommand = {}));
@@ -2,16 +2,29 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FindCategoryCommand = void 0;
4
4
  const zod_1 = require("zod");
5
- const category_schema_1 = require("../../models/category.schema");
5
+ const models_1 = require("../../models");
6
+ const models_2 = require("../../models");
6
7
  var FindCategoryCommand;
7
8
  (function (FindCategoryCommand) {
8
- FindCategoryCommand.RequestSchema = category_schema_1.CategorySchema.pick({
9
+ FindCategoryCommand.RequestSchema = models_1.CategorySchema.pick({
9
10
  uuid: true,
10
11
  });
11
12
  FindCategoryCommand.ResponseSchema = zod_1.z.object({
12
- data: zod_1.z.array(category_schema_1.CategorySchema),
13
+ data: zod_1.z.array(models_1.CategorySchema),
14
+ });
15
+ FindCategoryCommand.RequestByFormattedSchema = zod_1.z.object({
16
+ type: zod_1.z.enum(['short', 'long']),
17
+ });
18
+ FindCategoryCommand.ResponseByFormattedSchema = zod_1.z.object({
19
+ data: zod_1.z.array(models_1.CategorySchema.extend({
20
+ subCategories: zod_1.z.array(models_1.CategorySchema.extend({
21
+ page: zod_1.z.nullable(models_2.PageSchema.pick({
22
+ alias: true,
23
+ })),
24
+ })),
25
+ })),
13
26
  });
14
27
  FindCategoryCommand.ResponseByUUIDSchema = zod_1.z.object({
15
- data: category_schema_1.CategorySchema,
28
+ data: models_1.CategorySchema,
16
29
  });
17
30
  })(FindCategoryCommand || (exports.FindCategoryCommand = FindCategoryCommand = {}));
@@ -182,4 +182,9 @@ exports.ERRORS = {
182
182
  message: 'Сообщение не было создано',
183
183
  httpCode: 500,
184
184
  },
185
+ CATEGORY_CHILD_LIMIT_ERROR: {
186
+ code: 'C409',
187
+ message: 'Категория не может иметь более одной дочерней категории. Выберите другую родительскую категорию.',
188
+ httpCode: 409,
189
+ },
185
190
  };
@@ -4,7 +4,7 @@ exports.CategorySchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  exports.CategorySchema = zod_1.z.object({
6
6
  uuid: zod_1.z.string().uuid(),
7
- mainCategory: zod_1.z.nullable(zod_1.z.string().uuid()),
7
+ mainCategoryId: zod_1.z.nullable(zod_1.z.string().uuid()),
8
8
  name: zod_1.z.string().min(3).max(16384),
9
9
  prompt: zod_1.z.string().min(3).max(16384),
10
10
  createdAt: zod_1.z.date(),
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { CategorySchema } from '../../models/category.schema';
2
+ import { CategorySchema } from '../../models';
3
3
 
4
4
  export namespace CreateCategoryCommand {
5
5
  export const RequestSchema = CategorySchema.omit({
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { CategorySchema } from '../../models/category.schema';
2
+ import { CategorySchema } from '../../models';
3
+ import { PageSchema } from '../../models';
3
4
 
4
5
  export namespace FindCategoryCommand {
5
6
  export const RequestSchema = CategorySchema.pick({
@@ -12,6 +13,26 @@ export namespace FindCategoryCommand {
12
13
  data: z.array(CategorySchema),
13
14
  });
14
15
 
16
+ export const RequestByFormattedSchema = z.object({
17
+ type: z.enum(['short', 'long']),
18
+ });
19
+
20
+ export const ResponseByFormattedSchema = z.object({
21
+ data: z.array(
22
+ CategorySchema.extend({
23
+ subCategories: z.array(
24
+ CategorySchema.extend({
25
+ page: z.nullable(
26
+ PageSchema.pick({
27
+ alias: true,
28
+ }),
29
+ ),
30
+ }),
31
+ ),
32
+ }),
33
+ ),
34
+ });
35
+
15
36
  export type Response = z.infer<typeof ResponseSchema>;
16
37
 
17
38
  export const ResponseByUUIDSchema = z.object({
@@ -180,4 +180,10 @@ export const ERRORS = {
180
180
  message: 'Сообщение не было создано',
181
181
  httpCode: 500,
182
182
  },
183
+ CATEGORY_CHILD_LIMIT_ERROR: {
184
+ code: 'C409',
185
+ message:
186
+ 'Категория не может иметь более одной дочерней категории. Выберите другую родительскую категорию.',
187
+ httpCode: 409,
188
+ },
183
189
  };
@@ -2,7 +2,7 @@ import { z } from 'zod';
2
2
 
3
3
  export const CategorySchema = z.object({
4
4
  uuid: z.string().uuid(),
5
- mainCategory: z.nullable(z.string().uuid()),
5
+ mainCategoryId: z.nullable(z.string().uuid()),
6
6
  name: z.string().min(3).max(16384),
7
7
  prompt: z.string().min(3).max(16384),
8
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {