@purpleschool/student-works 0.0.15 → 0.0.17

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 (49) hide show
  1. package/api/controller/http/index.ts +1 -0
  2. package/api/controller/http/page-question.ts +9 -0
  3. package/api/controller/http/page.ts +7 -4
  4. package/api/routes.ts +21 -7
  5. package/build/api/controller/http/index.js +1 -0
  6. package/build/api/controller/http/page-question.js +11 -0
  7. package/build/api/controller/http/page.js +7 -4
  8. package/build/api/routes.js +14 -7
  9. package/build/commands/page/create-page-question.command.js +16 -0
  10. package/build/commands/page/delete-page-question.command.js +11 -0
  11. package/build/commands/page/index.js +3 -0
  12. package/build/commands/page/update-page-question.command.js +19 -0
  13. package/build/common/enums/index.js +17 -0
  14. package/build/common/enums/tool-type.enum.js +7 -0
  15. package/build/common/index.js +1 -0
  16. package/build/constants/email/subjects.js +1 -1
  17. package/build/constants/errors/errors.js +31 -0
  18. package/build/constants/page/enums/page-type.enum.js +2 -3
  19. package/build/index.js +1 -0
  20. package/build/models/index.js +1 -1
  21. package/build/models/page-question.schema.js +12 -0
  22. package/build/models/page.schema.js +14 -1
  23. package/build/queries/index.js +17 -0
  24. package/build/queries/page/find-all-page-questions.query.js +11 -0
  25. package/build/queries/page/find-page-question-by-uuid.query.js +14 -0
  26. package/build/queries/page/find-page-questions-by-page-id.query.js +14 -0
  27. package/build/queries/page/index.js +19 -0
  28. package/commands/page/create-page-question.command.ts +18 -0
  29. package/commands/page/delete-page-question.command.ts +13 -0
  30. package/commands/page/index.ts +3 -0
  31. package/commands/page/update-page-question.command.ts +24 -0
  32. package/common/enums/index.ts +1 -0
  33. package/common/enums/tool-type.enum.ts +3 -0
  34. package/common/index.ts +1 -0
  35. package/constants/email/subjects.ts +1 -1
  36. package/constants/errors/errors.ts +31 -2
  37. package/constants/page/enums/page-type.enum.ts +2 -3
  38. package/index.ts +1 -0
  39. package/models/index.ts +1 -1
  40. package/models/page-question.schema.ts +10 -0
  41. package/models/page.schema.ts +16 -1
  42. package/package.json +1 -1
  43. package/queries/index.ts +1 -0
  44. package/queries/page/find-all-page-questions.query.ts +10 -0
  45. package/queries/page/find-page-question-by-uuid.query.ts +16 -0
  46. package/queries/page/find-page-questions-by-page-id.query.ts +16 -0
  47. package/queries/page/index.ts +3 -0
  48. package/build/models/tool.schema.js +0 -16
  49. package/models/tool.schema.ts +0 -20
@@ -13,3 +13,4 @@ export * from './page';
13
13
  export * from './writer';
14
14
  export * from './files';
15
15
  export * from './user-balance';
16
+ export * from './page-question';
@@ -0,0 +1,9 @@
1
+ export const PAGE_QUESTION_CONTROLLER = 'page-question' as const;
2
+
3
+ export const PAGE_QUESTION_ROUTES = {
4
+ FIND_BY_UUID: (uuid: string) => `${uuid}`,
5
+ CREATE: '',
6
+ UPDATE: (uuid: string) => `update/${uuid}`,
7
+ DELETE: (uuid: string) => `delete/${uuid}`,
8
+ GET_ALL: '',
9
+ } as const;
@@ -1,8 +1,11 @@
1
1
  export const PAGE_CONTROLLER = 'page' as const;
2
2
 
3
3
  export const PAGE_ROUTES = {
4
- FIND_BY_UUID: 'by/uuid',
5
- GET_ALL: 'all',
6
- FIND_BY_ALIAS: 'by/alias',
7
- GET_ALL_WITH_RELATIONS: 'by/all',
4
+ FIND_BY_UUID: (uuid: string) => `${uuid}`,
5
+ GET_ALL: '',
6
+ FIND_BY_ALIAS: (alias: string) => `${alias}`,
7
+ CREATE: '',
8
+ UPDATE: (uuid: string) => `update/${uuid}`,
9
+ DELETE: (uuid: string) => `delete/${uuid}`,
10
+ CREATE_QUESTIONS_BULK: (pageId: string) => `${pageId}/questions/bulk`,
8
11
  } as const;
package/api/routes.ts CHANGED
@@ -80,14 +80,28 @@ export const REST_API = {
80
80
  `${ROOT}/${CONTROLLERS.PROMOCODE_PUBLIC_CONTROLLER}/${CONTROLLERS.PROMOCODE_ROUTES.VALIDATE}/${code}`,
81
81
  },
82
82
  PAGE: {
83
- GET: `${ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${CONTROLLERS.PAGE_ROUTES.GET_ALL}`,
84
- PATCH: (uuid: string) => `${ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${uuid}`,
85
- DELETE: (uuid: string) => `${ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${uuid}`,
86
- CREATE: `${ROOT}/${CONTROLLERS.PAGE_CONTROLLER}`,
83
+ FIND_BY_UUID: (uuid: string): string =>
84
+ `${ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${CONTROLLERS.PAGE_ROUTES.FIND_BY_UUID(uuid)}`,
85
+ GET_ALL: `${ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${CONTROLLERS.PAGE_ROUTES.GET_ALL}`,
86
+ FIND_BY_ALIAS: (alias: string): string =>
87
+ `${ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${CONTROLLERS.PAGE_ROUTES.FIND_BY_ALIAS(alias)}`,
88
+ CREATE: `${ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${CONTROLLERS.PAGE_ROUTES.CREATE}`,
89
+ UPDATE: (uuid: string): string =>
90
+ `${ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${CONTROLLERS.PAGE_ROUTES.UPDATE(uuid)}`,
91
+ DELETE: (uuid: string): string =>
92
+ `${ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${CONTROLLERS.PAGE_ROUTES.DELETE(uuid)}`,
93
+ CREATE_QUESTIONS_BULK: (uuid: string): string =>
94
+ `${ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${CONTROLLERS.PAGE_ROUTES.CREATE_QUESTIONS_BULK(uuid)}`,
95
+ },
96
+ PAGE_QUESTION: {
97
+ GET_ALL: `${ROOT}/${CONTROLLERS.PAGE_QUESTION_CONTROLLER}/${CONTROLLERS.PAGE_QUESTION_ROUTES.GET_ALL}`,
87
98
  GET_BY_UUID: (uuid: string): string =>
88
- `${ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${CONTROLLERS.PAGE_ROUTES.FIND_BY_UUID}/${uuid}`,
89
- GET_BY_ALIAS: `${ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${CONTROLLERS.PAGE_ROUTES.FIND_BY_ALIAS}`,
90
- GET_BY_ALL_WITH_RELATIONS: `${ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${CONTROLLERS.PAGE_ROUTES.GET_ALL_WITH_RELATIONS}`,
99
+ `${ROOT}/${CONTROLLERS.PAGE_QUESTION_CONTROLLER}/${CONTROLLERS.PAGE_QUESTION_ROUTES.FIND_BY_UUID(uuid)}`,
100
+ CREATE: `${ROOT}/${CONTROLLERS.PAGE_QUESTION_CONTROLLER}/${CONTROLLERS.PAGE_QUESTION_ROUTES.CREATE}`,
101
+ UPDATE: (uuid: string): string =>
102
+ `${ROOT}/${CONTROLLERS.PAGE_QUESTION_CONTROLLER}/${CONTROLLERS.PAGE_QUESTION_ROUTES.UPDATE(uuid)}`,
103
+ DELETE: (uuid: string): string =>
104
+ `${ROOT}/${CONTROLLERS.PAGE_QUESTION_CONTROLLER}/${CONTROLLERS.PAGE_QUESTION_ROUTES.DELETE(uuid)}`,
91
105
  },
92
106
  WRITER_PRIVATE: {
93
107
  CONFIG: `${ROOT}/${CONTROLLERS.WRITER_CONTROLLER_PRIVATE}/${CONTROLLERS.WRITER_ROUTES.CONFIG}`,
@@ -29,3 +29,4 @@ __exportStar(require("./page"), exports);
29
29
  __exportStar(require("./writer"), exports);
30
30
  __exportStar(require("./files"), exports);
31
31
  __exportStar(require("./user-balance"), exports);
32
+ __exportStar(require("./page-question"), exports);
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PAGE_QUESTION_ROUTES = exports.PAGE_QUESTION_CONTROLLER = void 0;
4
+ exports.PAGE_QUESTION_CONTROLLER = 'page-question';
5
+ exports.PAGE_QUESTION_ROUTES = {
6
+ FIND_BY_UUID: (uuid) => `${uuid}`,
7
+ CREATE: '',
8
+ UPDATE: (uuid) => `update/${uuid}`,
9
+ DELETE: (uuid) => `delete/${uuid}`,
10
+ GET_ALL: '',
11
+ };
@@ -3,8 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PAGE_ROUTES = exports.PAGE_CONTROLLER = void 0;
4
4
  exports.PAGE_CONTROLLER = 'page';
5
5
  exports.PAGE_ROUTES = {
6
- FIND_BY_UUID: 'by/uuid',
7
- GET_ALL: 'all',
8
- FIND_BY_ALIAS: 'by/alias',
9
- GET_ALL_WITH_RELATIONS: 'by/all',
6
+ FIND_BY_UUID: (uuid) => `${uuid}`,
7
+ GET_ALL: '',
8
+ FIND_BY_ALIAS: (alias) => `${alias}`,
9
+ CREATE: '',
10
+ UPDATE: (uuid) => `update/${uuid}`,
11
+ DELETE: (uuid) => `delete/${uuid}`,
12
+ CREATE_QUESTIONS_BULK: (pageId) => `${pageId}/questions/bulk`,
10
13
  };
@@ -102,13 +102,20 @@ exports.REST_API = {
102
102
  VALIDATE_PUBLIC: (code) => `${exports.ROOT}/${CONTROLLERS.PROMOCODE_PUBLIC_CONTROLLER}/${CONTROLLERS.PROMOCODE_ROUTES.VALIDATE}/${code}`,
103
103
  },
104
104
  PAGE: {
105
- GET: `${exports.ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${CONTROLLERS.PAGE_ROUTES.GET_ALL}`,
106
- PATCH: (uuid) => `${exports.ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${uuid}`,
107
- DELETE: (uuid) => `${exports.ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${uuid}`,
108
- CREATE: `${exports.ROOT}/${CONTROLLERS.PAGE_CONTROLLER}`,
109
- GET_BY_UUID: (uuid) => `${exports.ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${CONTROLLERS.PAGE_ROUTES.FIND_BY_UUID}/${uuid}`,
110
- GET_BY_ALIAS: `${exports.ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${CONTROLLERS.PAGE_ROUTES.FIND_BY_ALIAS}`,
111
- GET_BY_ALL_WITH_RELATIONS: `${exports.ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${CONTROLLERS.PAGE_ROUTES.GET_ALL_WITH_RELATIONS}`,
105
+ FIND_BY_UUID: (uuid) => `${exports.ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${CONTROLLERS.PAGE_ROUTES.FIND_BY_UUID(uuid)}`,
106
+ GET_ALL: `${exports.ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${CONTROLLERS.PAGE_ROUTES.GET_ALL}`,
107
+ FIND_BY_ALIAS: (alias) => `${exports.ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${CONTROLLERS.PAGE_ROUTES.FIND_BY_ALIAS(alias)}`,
108
+ CREATE: `${exports.ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${CONTROLLERS.PAGE_ROUTES.CREATE}`,
109
+ UPDATE: (uuid) => `${exports.ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${CONTROLLERS.PAGE_ROUTES.UPDATE(uuid)}`,
110
+ DELETE: (uuid) => `${exports.ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${CONTROLLERS.PAGE_ROUTES.DELETE(uuid)}`,
111
+ CREATE_QUESTIONS_BULK: (uuid) => `${exports.ROOT}/${CONTROLLERS.PAGE_CONTROLLER}/${CONTROLLERS.PAGE_ROUTES.CREATE_QUESTIONS_BULK(uuid)}`,
112
+ },
113
+ PAGE_QUESTION: {
114
+ GET_ALL: `${exports.ROOT}/${CONTROLLERS.PAGE_QUESTION_CONTROLLER}/${CONTROLLERS.PAGE_QUESTION_ROUTES.GET_ALL}`,
115
+ GET_BY_UUID: (uuid) => `${exports.ROOT}/${CONTROLLERS.PAGE_QUESTION_CONTROLLER}/${CONTROLLERS.PAGE_QUESTION_ROUTES.FIND_BY_UUID(uuid)}`,
116
+ CREATE: `${exports.ROOT}/${CONTROLLERS.PAGE_QUESTION_CONTROLLER}/${CONTROLLERS.PAGE_QUESTION_ROUTES.CREATE}`,
117
+ UPDATE: (uuid) => `${exports.ROOT}/${CONTROLLERS.PAGE_QUESTION_CONTROLLER}/${CONTROLLERS.PAGE_QUESTION_ROUTES.UPDATE(uuid)}`,
118
+ DELETE: (uuid) => `${exports.ROOT}/${CONTROLLERS.PAGE_QUESTION_CONTROLLER}/${CONTROLLERS.PAGE_QUESTION_ROUTES.DELETE(uuid)}`,
112
119
  },
113
120
  WRITER_PRIVATE: {
114
121
  CONFIG: `${exports.ROOT}/${CONTROLLERS.WRITER_CONTROLLER_PRIVATE}/${CONTROLLERS.WRITER_ROUTES.CONFIG}`,
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreatePageQuestionCommand = void 0;
4
+ const models_1 = require("../../models");
5
+ const zod_1 = require("zod");
6
+ var CreatePageQuestionCommand;
7
+ (function (CreatePageQuestionCommand) {
8
+ CreatePageQuestionCommand.RequestSchema = models_1.PageQuestionSchema.omit({
9
+ uuid: true,
10
+ createdAt: true,
11
+ updatedAt: true,
12
+ });
13
+ CreatePageQuestionCommand.ResponseSchema = zod_1.z.object({
14
+ data: models_1.PageQuestionSchema,
15
+ });
16
+ })(CreatePageQuestionCommand || (exports.CreatePageQuestionCommand = CreatePageQuestionCommand = {}));
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeletePageQuestionCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ var DeletePageQuestionCommand;
6
+ (function (DeletePageQuestionCommand) {
7
+ DeletePageQuestionCommand.RequestParamsSchema = zod_1.z.object({
8
+ uuid: zod_1.z.string().uuid(),
9
+ });
10
+ DeletePageQuestionCommand.ResponseSchema = zod_1.z.object({});
11
+ })(DeletePageQuestionCommand || (exports.DeletePageQuestionCommand = DeletePageQuestionCommand = {}));
@@ -14,6 +14,9 @@ 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("./create-page-question.command"), exports);
18
+ __exportStar(require("./update-page-question.command"), exports);
19
+ __exportStar(require("./delete-page-question.command"), exports);
17
20
  __exportStar(require("./create-page.command"), exports);
18
21
  __exportStar(require("./delete-page.command"), exports);
19
22
  __exportStar(require("./find-page-by-alias.command"), exports);
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UpdatePageQuestionCommand = void 0;
4
+ const models_1 = require("../../models");
5
+ const zod_1 = require("zod");
6
+ var UpdatePageQuestionCommand;
7
+ (function (UpdatePageQuestionCommand) {
8
+ UpdatePageQuestionCommand.RequestSchema = models_1.PageQuestionSchema.omit({
9
+ uuid: true,
10
+ createdAt: true,
11
+ updatedAt: true,
12
+ });
13
+ UpdatePageQuestionCommand.RequestParamsSchema = zod_1.z.object({
14
+ uuid: zod_1.z.string().uuid(),
15
+ });
16
+ UpdatePageQuestionCommand.ResponseSchema = zod_1.z.object({
17
+ data: models_1.PageQuestionSchema,
18
+ });
19
+ })(UpdatePageQuestionCommand || (exports.UpdatePageQuestionCommand = UpdatePageQuestionCommand = {}));
@@ -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("./tool-type.enum"), exports);
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TOOL_TYPE = void 0;
4
+ var TOOL_TYPE;
5
+ (function (TOOL_TYPE) {
6
+ TOOL_TYPE["WRITER"] = "WRITER";
7
+ })(TOOL_TYPE || (exports.TOOL_TYPE = TOOL_TYPE = {}));
@@ -14,4 +14,5 @@ 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("./enums"), exports);
17
18
  __exportStar(require("./models"), exports);
@@ -4,7 +4,7 @@ exports.EMAIL_SUBJECTS = void 0;
4
4
  exports.EMAIL_SUBJECTS = {
5
5
  EMAIL_VERIFICATION: 'Email Verification',
6
6
  WELCOME: 'Welcome',
7
- RESTORE_PASSWORD: 'Restore Password',
7
+ RESTORE_PASSWORD: 'Восстановление пароля в Studdy.io',
8
8
  FAST_REGISTRATION: 'Fast Registration',
9
9
  PRODUCT_PURCHASE: 'Product Purchase',
10
10
  RECURRENT_PAYMENT_FAILED: 'Recurrent Payment Failed',
@@ -1081,4 +1081,35 @@ exports.ERRORS = {
1081
1081
  code: 'FILE_003',
1082
1082
  httpCode: 500,
1083
1083
  },
1084
+ // PAGE QUESTION
1085
+ PAGE_QUESTION_NOT_FOUND: {
1086
+ message: 'Вопрос не найден',
1087
+ code: 'PAGE_QUESTION_001',
1088
+ httpCode: 404,
1089
+ },
1090
+ PAGE_QUESTION_FIND_ERROR: {
1091
+ message: 'Ошибка при поиске вопросов',
1092
+ code: 'PAGE_QUESTION_002',
1093
+ httpCode: 500,
1094
+ },
1095
+ PAGE_QUESTION_CREATE_ERROR: {
1096
+ message: 'Ошибка при создании вопроса',
1097
+ code: 'PAGE_QUESTION_003',
1098
+ httpCode: 500,
1099
+ },
1100
+ PAGE_QUESTION_UPDATE_ERROR: {
1101
+ message: 'Ошибка при обновлении вопроса',
1102
+ code: 'PAGE_QUESTION_004',
1103
+ httpCode: 500,
1104
+ },
1105
+ PAGE_QUESTION_SAVE_ERROR: {
1106
+ message: 'Ошибка при сохранении вопроса',
1107
+ code: 'PAGE_QUESTION_005',
1108
+ httpCode: 500,
1109
+ },
1110
+ PAGE_QUESTION_DELETE_ERROR: {
1111
+ message: 'Ошибка при удалении вопроса',
1112
+ code: 'PAGE_QUESTION_006',
1113
+ httpCode: 500,
1114
+ },
1084
1115
  };
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PageType = void 0;
4
4
  var PageType;
5
5
  (function (PageType) {
6
- PageType["PAGE"] = "page";
7
- PageType["BOT"] = "bot";
8
- PageType["TOOL"] = "tool";
6
+ PageType["TOOL"] = "TOOL";
7
+ PageType["WRITER_DOCUMENT_TYPE"] = "WRITER_DOCUMENT_TYPE";
9
8
  })(PageType || (exports.PageType = PageType = {}));
package/build/index.js CHANGED
@@ -18,4 +18,5 @@ __exportStar(require("./models"), exports);
18
18
  __exportStar(require("./api"), exports);
19
19
  __exportStar(require("./constants"), exports);
20
20
  __exportStar(require("./commands"), exports);
21
+ __exportStar(require("./queries"), exports);
21
22
  __exportStar(require("./common"), exports);
@@ -29,7 +29,7 @@ __exportStar(require("./product.schema"), exports);
29
29
  __exportStar(require("./user-to-product.schema"), exports);
30
30
  __exportStar(require("./promocode.schema"), exports);
31
31
  __exportStar(require("./page.schema"), exports);
32
- __exportStar(require("./tool.schema"), exports);
32
+ __exportStar(require("./page-question.schema"), exports);
33
33
  __exportStar(require("./writer"), exports);
34
34
  __exportStar(require("./icon-variants.schema"), exports);
35
35
  __exportStar(require("./unlocked-by-subscription.schema"), exports);
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PageQuestionSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.PageQuestionSchema = zod_1.z.object({
6
+ uuid: zod_1.z.string().uuid(),
7
+ question: zod_1.z.string().min(3).max(16384),
8
+ answer: zod_1.z.string().min(3).max(16384),
9
+ pageId: zod_1.z.string().uuid(),
10
+ createdAt: zod_1.z.date(),
11
+ updatedAt: zod_1.z.date(),
12
+ });
@@ -1,8 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PageSchema = void 0;
3
+ exports.PageSchema = exports.PageMetadataSchema = exports.WriterDocumentTypePageMetadataSchema = exports.ToolPageMetadataSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const constants_1 = require("../constants");
6
+ exports.ToolPageMetadataSchema = zod_1.z.object({
7
+ type: zod_1.z.literal(constants_1.PageType.TOOL),
8
+ toolType: zod_1.z.string().min(3).max(16384),
9
+ });
10
+ exports.WriterDocumentTypePageMetadataSchema = zod_1.z.object({
11
+ type: zod_1.z.literal(constants_1.PageType.WRITER_DOCUMENT_TYPE),
12
+ writerDocumentTypeId: zod_1.z.string().uuid(),
13
+ });
14
+ exports.PageMetadataSchema = zod_1.z.discriminatedUnion('type', [
15
+ exports.ToolPageMetadataSchema,
16
+ exports.WriterDocumentTypePageMetadataSchema,
17
+ ]);
6
18
  exports.PageSchema = zod_1.z.object({
7
19
  uuid: zod_1.z.string().uuid(),
8
20
  metaTitle: zod_1.z.string().min(3).max(16384),
@@ -12,6 +24,7 @@ exports.PageSchema = zod_1.z.object({
12
24
  seoTextMd: zod_1.z.string().min(3).max(16384),
13
25
  alias: zod_1.z.string().min(3).max(16384),
14
26
  type: zod_1.z.nativeEnum(constants_1.PageType),
27
+ metadata: exports.PageMetadataSchema,
15
28
  createdAt: zod_1.z.date(),
16
29
  updatedAt: zod_1.z.date(),
17
30
  });
@@ -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"), exports);
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FindAllPageQuestionsQuery = void 0;
4
+ const models_1 = require("../../models");
5
+ const zod_1 = require("zod");
6
+ var FindAllPageQuestionsQuery;
7
+ (function (FindAllPageQuestionsQuery) {
8
+ FindAllPageQuestionsQuery.ResponseSchema = zod_1.z.object({
9
+ data: zod_1.z.array(models_1.PageQuestionSchema),
10
+ });
11
+ })(FindAllPageQuestionsQuery || (exports.FindAllPageQuestionsQuery = FindAllPageQuestionsQuery = {}));
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FindPageQuestionByUUIDQuery = void 0;
4
+ const models_1 = require("../../models");
5
+ const zod_1 = require("zod");
6
+ var FindPageQuestionByUUIDQuery;
7
+ (function (FindPageQuestionByUUIDQuery) {
8
+ FindPageQuestionByUUIDQuery.RequestParamsSchema = zod_1.z.object({
9
+ uuid: zod_1.z.string().uuid(),
10
+ });
11
+ FindPageQuestionByUUIDQuery.ResponseSchema = zod_1.z.object({
12
+ data: models_1.PageQuestionSchema.nullable(),
13
+ });
14
+ })(FindPageQuestionByUUIDQuery || (exports.FindPageQuestionByUUIDQuery = FindPageQuestionByUUIDQuery = {}));
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FindPageQuestionsByPageIdQuery = void 0;
4
+ const models_1 = require("../../models");
5
+ const zod_1 = require("zod");
6
+ var FindPageQuestionsByPageIdQuery;
7
+ (function (FindPageQuestionsByPageIdQuery) {
8
+ FindPageQuestionsByPageIdQuery.RequestParamsSchema = zod_1.z.object({
9
+ pageId: zod_1.z.string().uuid(),
10
+ });
11
+ FindPageQuestionsByPageIdQuery.ResponseSchema = zod_1.z.object({
12
+ data: zod_1.z.array(models_1.PageQuestionSchema),
13
+ });
14
+ })(FindPageQuestionsByPageIdQuery || (exports.FindPageQuestionsByPageIdQuery = FindPageQuestionsByPageIdQuery = {}));
@@ -0,0 +1,19 @@
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("./find-page-question-by-uuid.query"), exports);
18
+ __exportStar(require("./find-all-page-questions.query"), exports);
19
+ __exportStar(require("./find-page-questions-by-page-id.query"), exports);
@@ -0,0 +1,18 @@
1
+ import { PageQuestionSchema } from '../../models';
2
+ import { z } from 'zod';
3
+
4
+ export namespace CreatePageQuestionCommand {
5
+ export const RequestSchema = PageQuestionSchema.omit({
6
+ uuid: true,
7
+ createdAt: true,
8
+ updatedAt: true,
9
+ });
10
+
11
+ export type Request = z.infer<typeof RequestSchema>;
12
+
13
+ export const ResponseSchema = z.object({
14
+ data: PageQuestionSchema,
15
+ });
16
+
17
+ export type Response = z.infer<typeof ResponseSchema>;
18
+ }
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+
3
+ export namespace DeletePageQuestionCommand {
4
+ export const RequestParamsSchema = z.object({
5
+ uuid: z.string().uuid(),
6
+ });
7
+
8
+ export type RequestParams = z.infer<typeof RequestParamsSchema>;
9
+
10
+ export const ResponseSchema = z.object({});
11
+
12
+ export type Response = z.infer<typeof ResponseSchema>;
13
+ }
@@ -1,3 +1,6 @@
1
+ export * from './create-page-question.command';
2
+ export * from './update-page-question.command';
3
+ export * from './delete-page-question.command';
1
4
  export * from './create-page.command';
2
5
  export * from './delete-page.command';
3
6
  export * from './find-page-by-alias.command';
@@ -0,0 +1,24 @@
1
+ import { PageQuestionSchema } from '../../models';
2
+ import { z } from 'zod';
3
+
4
+ export namespace UpdatePageQuestionCommand {
5
+ export const RequestSchema = PageQuestionSchema.omit({
6
+ uuid: true,
7
+ createdAt: true,
8
+ updatedAt: true,
9
+ });
10
+
11
+ export type Request = z.infer<typeof RequestSchema>;
12
+
13
+ export const RequestParamsSchema = z.object({
14
+ uuid: z.string().uuid(),
15
+ });
16
+
17
+ export type RequestParams = z.infer<typeof RequestParamsSchema>;
18
+
19
+ export const ResponseSchema = z.object({
20
+ data: PageQuestionSchema,
21
+ });
22
+
23
+ export type Response = z.infer<typeof ResponseSchema>;
24
+ }
@@ -0,0 +1 @@
1
+ export * from './tool-type.enum';
@@ -0,0 +1,3 @@
1
+ export enum TOOL_TYPE {
2
+ WRITER = 'WRITER',
3
+ }
package/common/index.ts CHANGED
@@ -1 +1,2 @@
1
+ export * from './enums';
1
2
  export * from './models';
@@ -1,7 +1,7 @@
1
1
  export const EMAIL_SUBJECTS = {
2
2
  EMAIL_VERIFICATION: 'Email Verification',
3
3
  WELCOME: 'Welcome',
4
- RESTORE_PASSWORD: 'Restore Password',
4
+ RESTORE_PASSWORD: 'Восстановление пароля в Studdy.io',
5
5
  FAST_REGISTRATION: 'Fast Registration',
6
6
  PRODUCT_PURCHASE: 'Product Purchase',
7
7
  RECURRENT_PAYMENT_FAILED: 'Recurrent Payment Failed',
@@ -1058,14 +1058,12 @@ export const ERRORS = {
1058
1058
  code: 'TELEGRAM_002',
1059
1059
  httpCode: 500,
1060
1060
  },
1061
-
1062
1061
  // PARTNER
1063
1062
  PARTNER_NOT_FOUND: {
1064
1063
  message: 'Partner not found',
1065
1064
  code: 'PARTNER_001',
1066
1065
  httpCode: 404,
1067
1066
  },
1068
-
1069
1067
  // FILES
1070
1068
  FILE_NOT_FOUND: {
1071
1069
  message: 'Файл не найден',
@@ -1087,4 +1085,35 @@ export const ERRORS = {
1087
1085
  code: 'FILE_003',
1088
1086
  httpCode: 500,
1089
1087
  },
1088
+ // PAGE QUESTION
1089
+ PAGE_QUESTION_NOT_FOUND: {
1090
+ message: 'Вопрос не найден',
1091
+ code: 'PAGE_QUESTION_001',
1092
+ httpCode: 404,
1093
+ },
1094
+ PAGE_QUESTION_FIND_ERROR: {
1095
+ message: 'Ошибка при поиске вопросов',
1096
+ code: 'PAGE_QUESTION_002',
1097
+ httpCode: 500,
1098
+ },
1099
+ PAGE_QUESTION_CREATE_ERROR: {
1100
+ message: 'Ошибка при создании вопроса',
1101
+ code: 'PAGE_QUESTION_003',
1102
+ httpCode: 500,
1103
+ },
1104
+ PAGE_QUESTION_UPDATE_ERROR: {
1105
+ message: 'Ошибка при обновлении вопроса',
1106
+ code: 'PAGE_QUESTION_004',
1107
+ httpCode: 500,
1108
+ },
1109
+ PAGE_QUESTION_SAVE_ERROR: {
1110
+ message: 'Ошибка при сохранении вопроса',
1111
+ code: 'PAGE_QUESTION_005',
1112
+ httpCode: 500,
1113
+ },
1114
+ PAGE_QUESTION_DELETE_ERROR: {
1115
+ message: 'Ошибка при удалении вопроса',
1116
+ code: 'PAGE_QUESTION_006',
1117
+ httpCode: 500,
1118
+ },
1090
1119
  };
@@ -1,5 +1,4 @@
1
1
  export enum PageType {
2
- PAGE = 'page',
3
- BOT = 'bot',
4
- TOOL = 'tool',
2
+ TOOL = 'TOOL',
3
+ WRITER_DOCUMENT_TYPE = 'WRITER_DOCUMENT_TYPE',
5
4
  }
package/index.ts CHANGED
@@ -2,4 +2,5 @@ export * from './models';
2
2
  export * from './api';
3
3
  export * from './constants';
4
4
  export * from './commands';
5
+ export * from './queries';
5
6
  export * from './common';
package/models/index.ts CHANGED
@@ -13,7 +13,7 @@ export * from './product.schema';
13
13
  export * from './user-to-product.schema';
14
14
  export * from './promocode.schema';
15
15
  export * from './page.schema';
16
- export * from './tool.schema';
16
+ export * from './page-question.schema';
17
17
  export * from './writer';
18
18
  export * from './icon-variants.schema';
19
19
  export * from './unlocked-by-subscription.schema';
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+
3
+ export const PageQuestionSchema = z.object({
4
+ uuid: z.string().uuid(),
5
+ question: z.string().min(3).max(16384),
6
+ answer: z.string().min(3).max(16384),
7
+ pageId: z.string().uuid(),
8
+ createdAt: z.date(),
9
+ updatedAt: z.date(),
10
+ });
@@ -1,6 +1,21 @@
1
1
  import { z } from 'zod';
2
2
  import { PageType } from '../constants';
3
3
 
4
+ export const ToolPageMetadataSchema = z.object({
5
+ type: z.literal(PageType.TOOL),
6
+ toolType: z.string().min(3).max(16384),
7
+ });
8
+
9
+ export const WriterDocumentTypePageMetadataSchema = z.object({
10
+ type: z.literal(PageType.WRITER_DOCUMENT_TYPE),
11
+ writerDocumentTypeId: z.string().uuid(),
12
+ });
13
+
14
+ export const PageMetadataSchema = z.discriminatedUnion('type', [
15
+ ToolPageMetadataSchema,
16
+ WriterDocumentTypePageMetadataSchema,
17
+ ]);
18
+
4
19
  export const PageSchema = z.object({
5
20
  uuid: z.string().uuid(),
6
21
  metaTitle: z.string().min(3).max(16384),
@@ -10,7 +25,7 @@ export const PageSchema = z.object({
10
25
  seoTextMd: z.string().min(3).max(16384),
11
26
  alias: z.string().min(3).max(16384),
12
27
  type: z.nativeEnum(PageType),
13
-
28
+ metadata: PageMetadataSchema,
14
29
  createdAt: z.date(),
15
30
  updatedAt: z.date(),
16
31
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/student-works",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -0,0 +1 @@
1
+ export * from './page';
@@ -0,0 +1,10 @@
1
+ import { PageQuestionSchema } from '../../models';
2
+ import { z } from 'zod';
3
+
4
+ export namespace FindAllPageQuestionsQuery {
5
+ export const ResponseSchema = z.object({
6
+ data: z.array(PageQuestionSchema),
7
+ });
8
+
9
+ export type Response = z.infer<typeof ResponseSchema>;
10
+ }
@@ -0,0 +1,16 @@
1
+ import { PageQuestionSchema } from '../../models';
2
+ import { z } from 'zod';
3
+
4
+ export namespace FindPageQuestionByUUIDQuery {
5
+ export const RequestParamsSchema = z.object({
6
+ uuid: z.string().uuid(),
7
+ });
8
+
9
+ export type RequestParams = z.infer<typeof RequestParamsSchema>;
10
+
11
+ export const ResponseSchema = z.object({
12
+ data: PageQuestionSchema.nullable(),
13
+ });
14
+
15
+ export type Response = z.infer<typeof ResponseSchema>;
16
+ }
@@ -0,0 +1,16 @@
1
+ import { PageQuestionSchema } from '../../models';
2
+ import { z } from 'zod';
3
+
4
+ export namespace FindPageQuestionsByPageIdQuery {
5
+ export const RequestParamsSchema = z.object({
6
+ pageId: z.string().uuid(),
7
+ });
8
+
9
+ export type RequestParams = z.infer<typeof RequestParamsSchema>;
10
+
11
+ export const ResponseSchema = z.object({
12
+ data: z.array(PageQuestionSchema),
13
+ });
14
+
15
+ export type Response = z.infer<typeof ResponseSchema>;
16
+ }
@@ -0,0 +1,3 @@
1
+ export * from './find-page-question-by-uuid.query';
2
+ export * from './find-all-page-questions.query';
3
+ export * from './find-page-questions-by-page-id.query';
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ToolFormattedSchema = exports.ToolSchema = void 0;
4
- const zod_1 = require("zod");
5
- const page_schema_1 = require("./page.schema");
6
- exports.ToolSchema = zod_1.z.object({
7
- uuid: zod_1.z.string().uuid(),
8
- title: zod_1.z.string(),
9
- description: zod_1.z.string(),
10
- icon: zod_1.z.string(),
11
- order: zod_1.z.number(),
12
- contentType: zod_1.z.string(),
13
- });
14
- exports.ToolFormattedSchema = zod_1.z.intersection(exports.ToolSchema, zod_1.z.object({
15
- pages: zod_1.z.array(page_schema_1.PageSchema.pick({ alias: true, title: true, type: true }).optional().nullable()),
16
- }));
@@ -1,20 +0,0 @@
1
- import { z } from 'zod';
2
- import { PageSchema } from './page.schema';
3
-
4
- export const ToolSchema = z.object({
5
- uuid: z.string().uuid(),
6
- title: z.string(),
7
- description: z.string(),
8
- icon: z.string(),
9
- order: z.number(),
10
- contentType: z.string(),
11
- });
12
-
13
- export const ToolFormattedSchema = z.intersection(
14
- ToolSchema,
15
- z.object({
16
- pages: z.array(
17
- PageSchema.pick({ alias: true, title: true, type: true }).optional().nullable(),
18
- ),
19
- }),
20
- );