@purpleschool/student-works 1.0.0 → 1.2.0

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.
@@ -15,3 +15,4 @@ export * from './files';
15
15
  export * from './user-balance';
16
16
  export * from './page-question';
17
17
  export * from './solving-edu-task';
18
+ export * from './tools';
@@ -0,0 +1,7 @@
1
+ export const TOOLS_CONTROLLER_PRIVATE = 'private/tools' as const;
2
+ export const TOOLS_CONTROLLER_PUBLIC = 'public/tools' as const;
3
+
4
+ export const TOOLS_ROUTES = {
5
+ HISTORY: 'history',
6
+ HISTORY_FULL: 'history/full',
7
+ } as const;
package/api/routes.ts CHANGED
@@ -239,4 +239,12 @@ export const REST_API = {
239
239
  RETRY: (uuid: string) =>
240
240
  `${ROOT}/${CONTROLLERS.SOLVING_EDU_TASK_CONTROLLER_PUBLIC}/${CONTROLLERS.SOLVING_EDU_TASK_ROUTES.RETRY(uuid)}`,
241
241
  },
242
+ TOOLS_PRIVATE: {
243
+ HISTORY: `${ROOT}/${CONTROLLERS.TOOLS_CONTROLLER_PRIVATE}/${CONTROLLERS.TOOLS_ROUTES.HISTORY}`,
244
+ HISTORY_FULL: `${ROOT}/${CONTROLLERS.TOOLS_CONTROLLER_PRIVATE}/${CONTROLLERS.TOOLS_ROUTES.HISTORY_FULL}`,
245
+ },
246
+ TOOLS_PUBLIC: {
247
+ HISTORY: `${ROOT}/${CONTROLLERS.TOOLS_CONTROLLER_PUBLIC}/${CONTROLLERS.TOOLS_ROUTES.HISTORY}`,
248
+ HISTORY_FULL: `${ROOT}/${CONTROLLERS.TOOLS_CONTROLLER_PUBLIC}/${CONTROLLERS.TOOLS_ROUTES.HISTORY_FULL}`,
249
+ },
242
250
  } as const;
@@ -31,3 +31,4 @@ __exportStar(require("./files"), exports);
31
31
  __exportStar(require("./user-balance"), exports);
32
32
  __exportStar(require("./page-question"), exports);
33
33
  __exportStar(require("./solving-edu-task"), exports);
34
+ __exportStar(require("./tools"), exports);
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TOOLS_ROUTES = exports.TOOLS_CONTROLLER_PUBLIC = exports.TOOLS_CONTROLLER_PRIVATE = void 0;
4
+ exports.TOOLS_CONTROLLER_PRIVATE = 'private/tools';
5
+ exports.TOOLS_CONTROLLER_PUBLIC = 'public/tools';
6
+ exports.TOOLS_ROUTES = {
7
+ HISTORY: 'history',
8
+ HISTORY_FULL: 'history/full',
9
+ };
@@ -201,4 +201,12 @@ exports.REST_API = {
201
201
  DELETE_ALL: `${exports.ROOT}/${CONTROLLERS.SOLVING_EDU_TASK_CONTROLLER_PUBLIC}/${CONTROLLERS.SOLVING_EDU_TASK_ROUTES.DELETE_ALL}`,
202
202
  RETRY: (uuid) => `${exports.ROOT}/${CONTROLLERS.SOLVING_EDU_TASK_CONTROLLER_PUBLIC}/${CONTROLLERS.SOLVING_EDU_TASK_ROUTES.RETRY(uuid)}`,
203
203
  },
204
+ TOOLS_PRIVATE: {
205
+ HISTORY: `${exports.ROOT}/${CONTROLLERS.TOOLS_CONTROLLER_PRIVATE}/${CONTROLLERS.TOOLS_ROUTES.HISTORY}`,
206
+ HISTORY_FULL: `${exports.ROOT}/${CONTROLLERS.TOOLS_CONTROLLER_PRIVATE}/${CONTROLLERS.TOOLS_ROUTES.HISTORY_FULL}`,
207
+ },
208
+ TOOLS_PUBLIC: {
209
+ HISTORY: `${exports.ROOT}/${CONTROLLERS.TOOLS_CONTROLLER_PUBLIC}/${CONTROLLERS.TOOLS_ROUTES.HISTORY}`,
210
+ HISTORY_FULL: `${exports.ROOT}/${CONTROLLERS.TOOLS_CONTROLLER_PUBLIC}/${CONTROLLERS.TOOLS_ROUTES.HISTORY_FULL}`,
211
+ },
204
212
  };
@@ -3,5 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TOOL_TYPE = void 0;
4
4
  var TOOL_TYPE;
5
5
  (function (TOOL_TYPE) {
6
- TOOL_TYPE["WRITER"] = "WRITER";
6
+ TOOL_TYPE["WRITER"] = "writer";
7
+ TOOL_TYPE["SOLVING_EDU_TASK"] = "solving-edu-task";
7
8
  })(TOOL_TYPE || (exports.TOOL_TYPE = TOOL_TYPE = {}));
@@ -1173,4 +1173,9 @@ exports.ERRORS = {
1173
1173
  code: 'SOLVING_EDU_TASK_012',
1174
1174
  httpCode: 400,
1175
1175
  },
1176
+ TOOLS_UNIFIED_HISTORY_FETCH_ERROR: {
1177
+ message: 'Ошибка при получении истории операций',
1178
+ code: 'TOOLS_001',
1179
+ httpCode: 500,
1180
+ },
1176
1181
  };
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PageType = void 0;
4
4
  var PageType;
5
5
  (function (PageType) {
6
- PageType["TOOL"] = "TOOL";
6
+ PageType["WRITER_TOOL"] = "WRITER_TOOL";
7
+ PageType["EDU_TASK_SOLVING_TOOL"] = "EDU_TASK_SOLVING_TOOL";
7
8
  PageType["WRITER_DOCUMENT_TYPE"] = "WRITER_DOCUMENT_TYPE";
8
9
  })(PageType || (exports.PageType = PageType = {}));
@@ -38,3 +38,4 @@ __exportStar(require("./referral-bonus.schema"), exports);
38
38
  __exportStar(require("./user-referrals.schema"), exports);
39
39
  __exportStar(require("./file.schema"), exports);
40
40
  __exportStar(require("./solving-edu-task"), exports);
41
+ __exportStar(require("./tools"), exports);
@@ -1,19 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PageWithQuestionsSchema = exports.PageSchema = exports.PageMetadataSchema = exports.WriterDocumentTypePageMetadataSchema = exports.ToolPageMetadataSchema = void 0;
3
+ exports.PageWithQuestionsSchema = exports.PageSchema = exports.PageMetadataSchema = exports.WriterDocumentTypePageMetadataSchema = exports.EduTaskSolvingToolPageMetadataSchema = exports.WriterToolPageMetadataSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const constants_1 = require("../constants");
6
6
  const page_question_schema_1 = require("./page-question.schema");
7
- exports.ToolPageMetadataSchema = zod_1.z.object({
8
- type: zod_1.z.literal(constants_1.PageType.TOOL),
9
- toolType: zod_1.z.string().min(3).max(16384),
7
+ exports.WriterToolPageMetadataSchema = zod_1.z.object({
8
+ type: zod_1.z.literal(constants_1.PageType.WRITER_TOOL),
9
+ });
10
+ exports.EduTaskSolvingToolPageMetadataSchema = zod_1.z.object({
11
+ type: zod_1.z.literal(constants_1.PageType.EDU_TASK_SOLVING_TOOL),
10
12
  });
11
13
  exports.WriterDocumentTypePageMetadataSchema = zod_1.z.object({
12
14
  type: zod_1.z.literal(constants_1.PageType.WRITER_DOCUMENT_TYPE),
13
15
  writerDocumentTypeId: zod_1.z.string().uuid(),
14
16
  });
15
17
  exports.PageMetadataSchema = zod_1.z.discriminatedUnion('type', [
16
- exports.ToolPageMetadataSchema,
18
+ exports.WriterToolPageMetadataSchema,
19
+ exports.EduTaskSolvingToolPageMetadataSchema,
17
20
  exports.WriterDocumentTypePageMetadataSchema,
18
21
  ]);
19
22
  exports.PageSchema = zod_1.z.object({
@@ -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("./unified-tool-job.schema"), exports);
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnifiedToolJobSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const common_1 = require("../../common");
6
+ const constants_1 = require("../../constants");
7
+ const constants_2 = require("../../constants");
8
+ exports.UnifiedToolJobSchema = zod_1.z.object({
9
+ uuid: zod_1.z.string().uuid(),
10
+ title: zod_1.z.string(),
11
+ type: zod_1.z.nativeEnum(common_1.TOOL_TYPE),
12
+ status: zod_1.z.nativeEnum(constants_1.JOB_STATUS).optional().nullable(),
13
+ stage: zod_1.z.nativeEnum(constants_2.WRITER_DOCUMENT_STAGE).optional().nullable(),
14
+ documentTypeId: zod_1.z.string().uuid().optional().nullable(),
15
+ createdAt: zod_1.z.date().or(zod_1.z.string()),
16
+ updatedAt: zod_1.z.date().or(zod_1.z.string()),
17
+ });
@@ -14,4 +14,4 @@ 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("./page"), exports);
17
+ __exportStar(require("./tools"), exports);
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FindUnifiedToolJobHistoryFullQuery = void 0;
4
+ const zod_1 = require("zod");
5
+ const writer_1 = require("../../models/writer");
6
+ const solving_edu_task_1 = require("../../models/solving-edu-task");
7
+ var FindUnifiedToolJobHistoryFullQuery;
8
+ (function (FindUnifiedToolJobHistoryFullQuery) {
9
+ FindUnifiedToolJobHistoryFullQuery.RequestSchema = zod_1.z.object({
10
+ limit: zod_1.z.coerce.number().min(1).optional(),
11
+ offset: zod_1.z.coerce.number().min(0).default(0).optional(),
12
+ title: zod_1.z.string().optional(),
13
+ });
14
+ FindUnifiedToolJobHistoryFullQuery.ResponseSchema = zod_1.z.object({
15
+ data: zod_1.z.array(zod_1.z.union([writer_1.WriterDocumentSchema, solving_edu_task_1.SolvingEduTaskJobSchema])),
16
+ page: zod_1.z.number().int(),
17
+ totalPages: zod_1.z.number().int(),
18
+ });
19
+ })(FindUnifiedToolJobHistoryFullQuery || (exports.FindUnifiedToolJobHistoryFullQuery = FindUnifiedToolJobHistoryFullQuery = {}));
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FindUnifiedToolJobHistoryQuery = void 0;
4
+ const zod_1 = require("zod");
5
+ const tools_1 = require("../../models/tools");
6
+ var FindUnifiedToolJobHistoryQuery;
7
+ (function (FindUnifiedToolJobHistoryQuery) {
8
+ FindUnifiedToolJobHistoryQuery.RequestSchema = zod_1.z.object({
9
+ limit: zod_1.z.coerce.number().min(1).optional(),
10
+ offset: zod_1.z.coerce.number().min(0).default(0).optional(),
11
+ title: zod_1.z.string().optional(),
12
+ });
13
+ FindUnifiedToolJobHistoryQuery.ResponseSchema = zod_1.z.object({
14
+ data: zod_1.z.array(tools_1.UnifiedToolJobSchema),
15
+ page: zod_1.z.number().int(),
16
+ totalPages: zod_1.z.number().int(),
17
+ });
18
+ })(FindUnifiedToolJobHistoryQuery || (exports.FindUnifiedToolJobHistoryQuery = FindUnifiedToolJobHistoryQuery = {}));
@@ -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("./find-unified-tool-job-history.query"), exports);
18
+ __exportStar(require("./find-unified-tool-job-history-full.query"), exports);
@@ -1,3 +1,4 @@
1
1
  export enum TOOL_TYPE {
2
- WRITER = 'WRITER',
2
+ WRITER = 'writer',
3
+ SOLVING_EDU_TASK = 'solving-edu-task',
3
4
  }
@@ -1177,4 +1177,9 @@ export const ERRORS = {
1177
1177
  code: 'SOLVING_EDU_TASK_012',
1178
1178
  httpCode: 400,
1179
1179
  },
1180
+ TOOLS_UNIFIED_HISTORY_FETCH_ERROR: {
1181
+ message: 'Ошибка при получении истории операций',
1182
+ code: 'TOOLS_001',
1183
+ httpCode: 500,
1184
+ },
1180
1185
  };
@@ -1,4 +1,5 @@
1
1
  export enum PageType {
2
- TOOL = 'TOOL',
2
+ WRITER_TOOL = 'WRITER_TOOL',
3
+ EDU_TASK_SOLVING_TOOL = 'EDU_TASK_SOLVING_TOOL',
3
4
  WRITER_DOCUMENT_TYPE = 'WRITER_DOCUMENT_TYPE',
4
5
  }
package/models/index.ts CHANGED
@@ -22,3 +22,4 @@ export * from './referral-bonus.schema';
22
22
  export * from './user-referrals.schema';
23
23
  export * from './file.schema';
24
24
  export * from './solving-edu-task';
25
+ export * from './tools';
@@ -2,9 +2,12 @@ import { z } from 'zod';
2
2
  import { PageType } from '../constants';
3
3
  import { PageQuestionSchema } from './page-question.schema';
4
4
 
5
- export const ToolPageMetadataSchema = z.object({
6
- type: z.literal(PageType.TOOL),
7
- toolType: z.string().min(3).max(16384),
5
+ export const WriterToolPageMetadataSchema = z.object({
6
+ type: z.literal(PageType.WRITER_TOOL),
7
+ });
8
+
9
+ export const EduTaskSolvingToolPageMetadataSchema = z.object({
10
+ type: z.literal(PageType.EDU_TASK_SOLVING_TOOL),
8
11
  });
9
12
 
10
13
  export const WriterDocumentTypePageMetadataSchema = z.object({
@@ -13,7 +16,8 @@ export const WriterDocumentTypePageMetadataSchema = z.object({
13
16
  });
14
17
 
15
18
  export const PageMetadataSchema = z.discriminatedUnion('type', [
16
- ToolPageMetadataSchema,
19
+ WriterToolPageMetadataSchema,
20
+ EduTaskSolvingToolPageMetadataSchema,
17
21
  WriterDocumentTypePageMetadataSchema,
18
22
  ]);
19
23
 
@@ -0,0 +1 @@
1
+ export * from './unified-tool-job.schema';
@@ -0,0 +1,17 @@
1
+ import { z } from 'zod';
2
+ import { TOOL_TYPE } from '../../common';
3
+ import { JOB_STATUS } from '../../constants';
4
+ import { WRITER_DOCUMENT_STAGE } from '../../constants';
5
+
6
+ export const UnifiedToolJobSchema = z.object({
7
+ uuid: z.string().uuid(),
8
+ title: z.string(),
9
+ type: z.nativeEnum(TOOL_TYPE),
10
+ status: z.nativeEnum(JOB_STATUS).optional().nullable(),
11
+ stage: z.nativeEnum(WRITER_DOCUMENT_STAGE).optional().nullable(),
12
+ documentTypeId: z.string().uuid().optional().nullable(),
13
+ createdAt: z.date().or(z.string()),
14
+ updatedAt: z.date().or(z.string()),
15
+ });
16
+
17
+ export type UnifiedToolJob = z.infer<typeof UnifiedToolJobSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/student-works",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
package/queries/index.ts CHANGED
@@ -1 +1 @@
1
- export * from './page';
1
+ export * from './tools';
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+ import { WriterDocumentSchema } from '../../models/writer';
3
+ import { SolvingEduTaskJobSchema } from '../../models/solving-edu-task';
4
+
5
+ export namespace FindUnifiedToolJobHistoryFullQuery {
6
+ export const RequestSchema = z.object({
7
+ limit: z.coerce.number().min(1).optional(),
8
+ offset: z.coerce.number().min(0).default(0).optional(),
9
+ title: z.string().optional(),
10
+ });
11
+
12
+ export type Request = z.infer<typeof RequestSchema>;
13
+
14
+ export const ResponseSchema = z.object({
15
+ data: z.array(z.union([WriterDocumentSchema, SolvingEduTaskJobSchema])),
16
+ page: z.number().int(),
17
+ totalPages: z.number().int(),
18
+ });
19
+
20
+ export type Response = z.infer<typeof ResponseSchema>;
21
+ }
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ import { UnifiedToolJobSchema } from '../../models/tools';
3
+
4
+ export namespace FindUnifiedToolJobHistoryQuery {
5
+ export const RequestSchema = z.object({
6
+ limit: z.coerce.number().min(1).optional(),
7
+ offset: z.coerce.number().min(0).default(0).optional(),
8
+ title: z.string().optional(),
9
+ });
10
+
11
+ export type Request = z.infer<typeof RequestSchema>;
12
+
13
+ export const ResponseSchema = z.object({
14
+ data: z.array(UnifiedToolJobSchema),
15
+ page: z.number().int(),
16
+ totalPages: z.number().int(),
17
+ });
18
+
19
+ export type Response = z.infer<typeof ResponseSchema>;
20
+ }
@@ -0,0 +1,2 @@
1
+ export * from './find-unified-tool-job-history.query';
2
+ export * from './find-unified-tool-job-history-full.query';