@purpleschool/gptbot-tools 0.0.1

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 (50) hide show
  1. package/build/common/errors/error.interface.js +2 -0
  2. package/build/common/errors/errors.js +71 -0
  3. package/build/common/errors/index.js +18 -0
  4. package/build/common/index.js +17 -0
  5. package/build/common/models/command-response.schema.js +17 -0
  6. package/build/common/models/index.js +17 -0
  7. package/build/paraphrase/commands/index.js +17 -0
  8. package/build/paraphrase/commands/paraphrase.command.js +20 -0
  9. package/build/paraphrase/enums/index.js +17 -0
  10. package/build/paraphrase/enums/paraphrasing-intesity.enum.js +9 -0
  11. package/build/paraphrase/index.js +20 -0
  12. package/build/paraphrase/models/index.js +20 -0
  13. package/build/paraphrase/models/paraphrase-job.schema.js +19 -0
  14. package/build/paraphrase/models/paraphrase-model.schema.js +12 -0
  15. package/build/paraphrase/models/paraphrase-style.schema.js +12 -0
  16. package/build/paraphrase/models/paraphrase-tool.schema.js +10 -0
  17. package/build/paraphrase/paraphrase.amqp.routes.js +8 -0
  18. package/build/paraphrase/queries/find-paraphrase-job-by-uuid.query.js +10 -0
  19. package/build/paraphrase/queries/get-paraphrase-tool.query.js +9 -0
  20. package/build/paraphrase/queries/index.js +18 -0
  21. package/build/tools/enums/index.js +17 -0
  22. package/build/tools/enums/job-status.enum.js +9 -0
  23. package/build/tools/index.js +18 -0
  24. package/build/tools/tools.aqmp.routes.js +7 -0
  25. package/common/errors/error.interface.ts +5 -0
  26. package/common/errors/errors.ts +69 -0
  27. package/common/errors/index.ts +2 -0
  28. package/common/index.ts +1 -0
  29. package/common/models/command-response.schema.ts +18 -0
  30. package/common/models/index.ts +1 -0
  31. package/package.json +17 -0
  32. package/paraphrase/commands/index.ts +1 -0
  33. package/paraphrase/commands/paraphrase.command.ts +20 -0
  34. package/paraphrase/enums/index.ts +1 -0
  35. package/paraphrase/enums/paraphrasing-intesity.enum.ts +5 -0
  36. package/paraphrase/index.ts +4 -0
  37. package/paraphrase/models/index.ts +4 -0
  38. package/paraphrase/models/paraphrase-job.schema.ts +17 -0
  39. package/paraphrase/models/paraphrase-model.schema.ts +10 -0
  40. package/paraphrase/models/paraphrase-style.schema.ts +10 -0
  41. package/paraphrase/models/paraphrase-tool.schema.ts +8 -0
  42. package/paraphrase/paraphrase.amqp.routes.ts +5 -0
  43. package/paraphrase/queries/find-paraphrase-job-by-uuid.query.ts +11 -0
  44. package/paraphrase/queries/get-paraphrase-tool.query.ts +8 -0
  45. package/paraphrase/queries/index.ts +2 -0
  46. package/tools/enums/index.ts +1 -0
  47. package/tools/enums/job-status.enum.ts +5 -0
  48. package/tools/index.ts +2 -0
  49. package/tools/tools.aqmp.routes.ts +4 -0
  50. package/tsconfig.json +12 -0
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ERRORS = void 0;
4
+ exports.ERRORS = {
5
+ // INTERNAL
6
+ INTERNAL_SERVER_ERROR: { code: 'A001', message: 'Ошибка севера', httpCode: 500 },
7
+ // PARAPHRASE
8
+ PARAPHRASE: {
9
+ INTERNAL_ERROR: {
10
+ code: 'P001',
11
+ message: 'Произошла ошибка при перефразировании текста',
12
+ httpCode: 500,
13
+ },
14
+ AI_ERROR: {
15
+ code: 'P002',
16
+ message: 'Произошла ошибка во время запроса к AI',
17
+ httpCode: 500,
18
+ },
19
+ },
20
+ PARAPHRASE_REQUEST: {
21
+ SAVE_ERROR: {
22
+ code: 'PR001',
23
+ message: 'Произошла ошибка при сохранении запроса на перефразирование',
24
+ httpCode: 500,
25
+ },
26
+ FIND_ERROR: {
27
+ code: 'PR002',
28
+ message: 'Произошла ошибка при поиске запроса на перефразирование',
29
+ httpCode: 500,
30
+ },
31
+ NOT_FOUND: {
32
+ code: 'PR003',
33
+ message: 'Запрос на перефразирование не найден',
34
+ httpCode: 404,
35
+ },
36
+ },
37
+ PARAPHRASE_STYLE: {
38
+ SAVE_ERROR: {
39
+ code: 'PS001',
40
+ message: 'Произошла ошибка при сохранении стиля перефразирования',
41
+ httpCode: 500,
42
+ },
43
+ FIND_ERROR: {
44
+ code: 'PS002',
45
+ message: 'Произошла ошибка при поиске стиля перефразирования',
46
+ httpCode: 500,
47
+ },
48
+ NOT_FOUND: {
49
+ code: 'PS003',
50
+ message: 'Стиль перефразирования не найден',
51
+ httpCode: 404,
52
+ },
53
+ },
54
+ PARAPHRASE_MODEL: {
55
+ SAVE_ERROR: {
56
+ code: 'PM001',
57
+ message: 'Произошла ошибка при сохранении модели для перефразирования',
58
+ httpCode: 500,
59
+ },
60
+ FIND_ERROR: {
61
+ code: 'PM002',
62
+ message: 'Произошла ошибка при поиске модели для перефразирования',
63
+ httpCode: 500,
64
+ },
65
+ NOT_FOUND: {
66
+ code: 'PM003',
67
+ message: 'Модель для перефразирования не найдена',
68
+ httpCode: 404,
69
+ },
70
+ },
71
+ };
@@ -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("./error.interface"), exports);
18
+ __exportStar(require("./errors"), 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("./errors"), exports);
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommandHandlerExecuteResponseSchema = exports.ICommandResponseSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const ICommandResponseSchema = (dataSchema) => zod_1.z.object({
6
+ isSuccess: zod_1.z.boolean(),
7
+ data: dataSchema.optional(),
8
+ code: zod_1.z.string().optional(),
9
+ message: zod_1.z.string().optional(),
10
+ });
11
+ exports.ICommandResponseSchema = ICommandResponseSchema;
12
+ const CommandHandlerExecuteResponseSchema = (payloadSchema) => zod_1.z.promise(zod_1.z.object({
13
+ isSuccess: zod_1.z.boolean(),
14
+ errorCode: zod_1.z.string().optional(),
15
+ payload: payloadSchema.optional(),
16
+ }));
17
+ exports.CommandHandlerExecuteResponseSchema = CommandHandlerExecuteResponseSchema;
@@ -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("./command-response.schema"), 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("./paraphrase.command"), exports);
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ParaphraseCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const command_response_schema_1 = require("../../common/models/command-response.schema");
6
+ const paraphrase_job_schema_1 = require("../models/paraphrase-job.schema");
7
+ const enums_1 = require("../enums");
8
+ var ParaphraseCommand;
9
+ (function (ParaphraseCommand) {
10
+ ParaphraseCommand.RequestSchema = zod_1.z.object({
11
+ jobId: zod_1.z.string().uuid(),
12
+ userId: zod_1.z.string().uuid().nullable(),
13
+ unregisteredUserId: zod_1.z.string().uuid().nullable(),
14
+ prompt: zod_1.z.string(),
15
+ modelId: zod_1.z.string().uuid(),
16
+ styleId: zod_1.z.string().uuid(),
17
+ intensity: zod_1.z.nativeEnum(enums_1.PARAPHRASING_INTENSITY),
18
+ });
19
+ ParaphraseCommand.ResponseSchema = (0, command_response_schema_1.ICommandResponseSchema)(paraphrase_job_schema_1.ParaphraseJobSchema);
20
+ })(ParaphraseCommand || (exports.ParaphraseCommand = ParaphraseCommand = {}));
@@ -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("./paraphrasing-intesity.enum"), exports);
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PARAPHRASING_INTENSITY = void 0;
4
+ var PARAPHRASING_INTENSITY;
5
+ (function (PARAPHRASING_INTENSITY) {
6
+ PARAPHRASING_INTENSITY["LOW"] = "low";
7
+ PARAPHRASING_INTENSITY["MEDIUM"] = "medium";
8
+ PARAPHRASING_INTENSITY["HIGH"] = "high";
9
+ })(PARAPHRASING_INTENSITY || (exports.PARAPHRASING_INTENSITY = PARAPHRASING_INTENSITY = {}));
@@ -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("./commands"), exports);
18
+ __exportStar(require("./enums"), exports);
19
+ __exportStar(require("./models"), exports);
20
+ __exportStar(require("./queries"), exports);
@@ -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("./paraphrase-model.schema"), exports);
18
+ __exportStar(require("./paraphrase-style.schema"), exports);
19
+ __exportStar(require("./paraphrase-job.schema"), exports);
20
+ __exportStar(require("./paraphrase-tool.schema"), exports);
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ParaphraseJobSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.ParaphraseJobSchema = zod_1.z.object({
6
+ uuid: zod_1.z.string(),
7
+ userId: zod_1.z.string().nullable(),
8
+ unregisteredUserId: zod_1.z.string().nullable(),
9
+ userInput: zod_1.z.string(),
10
+ aiOutput: zod_1.z.string().nullable(),
11
+ aiTokenUsage: zod_1.z.number().nullable(),
12
+ cost: zod_1.z.number().nullable(),
13
+ status: zod_1.z.string(),
14
+ modelId: zod_1.z.string().nullable(),
15
+ styleId: zod_1.z.string().nullable(),
16
+ createdAt: zod_1.z.date(),
17
+ updatedAt: zod_1.z.date(),
18
+ completedAt: zod_1.z.date().nullable(),
19
+ });
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ParaphraseModelSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.ParaphraseModelSchema = zod_1.z.object({
6
+ uuid: zod_1.z.string(),
7
+ name: zod_1.z.string(),
8
+ icon: zod_1.z.string(),
9
+ aiModel: zod_1.z.string(),
10
+ createdAt: zod_1.z.date(),
11
+ updatedAt: zod_1.z.date(),
12
+ });
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ParaphraseStyleSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.ParaphraseStyleSchema = zod_1.z.object({
6
+ uuid: zod_1.z.string(),
7
+ name: zod_1.z.string(),
8
+ icon: zod_1.z.string(),
9
+ prompt: zod_1.z.string(),
10
+ createdAt: zod_1.z.date(),
11
+ updatedAt: zod_1.z.date(),
12
+ });
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ParaphraseToolSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const paraphrase_style_schema_1 = require("./paraphrase-style.schema");
6
+ const paraphrase_model_schema_1 = require("./paraphrase-model.schema");
7
+ exports.ParaphraseToolSchema = zod_1.z.object({
8
+ styles: zod_1.z.array(paraphrase_style_schema_1.ParaphraseStyleSchema),
9
+ models: zod_1.z.array(paraphrase_model_schema_1.ParaphraseModelSchema),
10
+ });
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PARAPHRASE_ARMQ_ROUTES = void 0;
4
+ exports.PARAPHRASE_ARMQ_ROUTES = {
5
+ EXECUTE: 'tools.paraphrase.execute',
6
+ CONFIG: 'tools.paraphrase.config.rpc',
7
+ GET_JOB: 'tools.paraphrase.jobs.get.rpc',
8
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FindParaphraseJobByUuidQuery = void 0;
4
+ const command_response_schema_1 = require("../../common/models/command-response.schema");
5
+ const models_1 = require("../models");
6
+ var FindParaphraseJobByUuidQuery;
7
+ (function (FindParaphraseJobByUuidQuery) {
8
+ FindParaphraseJobByUuidQuery.RequestSchema = models_1.ParaphraseJobSchema.pick({ uuid: true });
9
+ FindParaphraseJobByUuidQuery.ResponseSchema = (0, command_response_schema_1.ICommandResponseSchema)(models_1.ParaphraseJobSchema);
10
+ })(FindParaphraseJobByUuidQuery || (exports.FindParaphraseJobByUuidQuery = FindParaphraseJobByUuidQuery = {}));
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetParaphraseToolQuery = void 0;
4
+ const command_response_schema_1 = require("../../common/models/command-response.schema");
5
+ const models_1 = require("../models");
6
+ var GetParaphraseToolQuery;
7
+ (function (GetParaphraseToolQuery) {
8
+ GetParaphraseToolQuery.ResponseSchema = (0, command_response_schema_1.ICommandResponseSchema)(models_1.ParaphraseToolSchema);
9
+ })(GetParaphraseToolQuery || (exports.GetParaphraseToolQuery = GetParaphraseToolQuery = {}));
@@ -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-paraphrase-job-by-uuid.query"), exports);
18
+ __exportStar(require("./get-paraphrase-tool.query"), 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("./job-status.enum"), exports);
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JOB_STATUS = void 0;
4
+ var JOB_STATUS;
5
+ (function (JOB_STATUS) {
6
+ JOB_STATUS["PEDNING"] = "pending";
7
+ JOB_STATUS["COMPLETED"] = "completed";
8
+ JOB_STATUS["FAILED"] = "failed";
9
+ })(JOB_STATUS || (exports.JOB_STATUS = JOB_STATUS = {}));
@@ -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("./enums"), exports);
18
+ __exportStar(require("./tools.aqmp.routes"), exports);
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TOOLS_AQMP_ROUTES = void 0;
4
+ exports.TOOLS_AQMP_ROUTES = {
5
+ JOB_COMPLETED: 'tools.job.completed',
6
+ JOB_FAILED: 'tools.job.failed',
7
+ };
@@ -0,0 +1,5 @@
1
+ export interface IErrorResponse extends Record<string, unknown> {
2
+ code: string; // Код ошибки
3
+ message: string;
4
+ httpCode: number;
5
+ }
@@ -0,0 +1,69 @@
1
+ export const ERRORS = {
2
+ // INTERNAL
3
+ INTERNAL_SERVER_ERROR: { code: 'A001', message: 'Ошибка севера', httpCode: 500 },
4
+
5
+ // PARAPHRASE
6
+ PARAPHRASE: {
7
+ INTERNAL_ERROR: {
8
+ code: 'P001',
9
+ message: 'Произошла ошибка при перефразировании текста',
10
+ httpCode: 500,
11
+ },
12
+ AI_ERROR: {
13
+ code: 'P002',
14
+ message: 'Произошла ошибка во время запроса к AI',
15
+ httpCode: 500,
16
+ },
17
+ },
18
+ PARAPHRASE_REQUEST: {
19
+ SAVE_ERROR: {
20
+ code: 'PR001',
21
+ message: 'Произошла ошибка при сохранении запроса на перефразирование',
22
+ httpCode: 500,
23
+ },
24
+ FIND_ERROR: {
25
+ code: 'PR002',
26
+ message: 'Произошла ошибка при поиске запроса на перефразирование',
27
+ httpCode: 500,
28
+ },
29
+ NOT_FOUND: {
30
+ code: 'PR003',
31
+ message: 'Запрос на перефразирование не найден',
32
+ httpCode: 404,
33
+ },
34
+ },
35
+ PARAPHRASE_STYLE: {
36
+ SAVE_ERROR: {
37
+ code: 'PS001',
38
+ message: 'Произошла ошибка при сохранении стиля перефразирования',
39
+ httpCode: 500,
40
+ },
41
+ FIND_ERROR: {
42
+ code: 'PS002',
43
+ message: 'Произошла ошибка при поиске стиля перефразирования',
44
+ httpCode: 500,
45
+ },
46
+ NOT_FOUND: {
47
+ code: 'PS003',
48
+ message: 'Стиль перефразирования не найден',
49
+ httpCode: 404,
50
+ },
51
+ },
52
+ PARAPHRASE_MODEL: {
53
+ SAVE_ERROR: {
54
+ code: 'PM001',
55
+ message: 'Произошла ошибка при сохранении модели для перефразирования',
56
+ httpCode: 500,
57
+ },
58
+ FIND_ERROR: {
59
+ code: 'PM002',
60
+ message: 'Произошла ошибка при поиске модели для перефразирования',
61
+ httpCode: 500,
62
+ },
63
+ NOT_FOUND: {
64
+ code: 'PM003',
65
+ message: 'Модель для перефразирования не найдена',
66
+ httpCode: 404,
67
+ },
68
+ },
69
+ } as const;
@@ -0,0 +1,2 @@
1
+ export * from './error.interface';
2
+ export * from './errors';
@@ -0,0 +1 @@
1
+ export * from './errors';
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+
3
+ export const ICommandResponseSchema = <T>(dataSchema: z.ZodType<T>) =>
4
+ z.object({
5
+ isSuccess: z.boolean(),
6
+ data: dataSchema.optional(),
7
+ code: z.string().optional(),
8
+ message: z.string().optional(),
9
+ });
10
+
11
+ export const CommandHandlerExecuteResponseSchema = <Payload>(payloadSchema: z.ZodType<Payload>) =>
12
+ z.promise(
13
+ z.object({
14
+ isSuccess: z.boolean(),
15
+ errorCode: z.string().optional(),
16
+ payload: payloadSchema.optional(),
17
+ }),
18
+ );
@@ -0,0 +1 @@
1
+ export * from './command-response.schema';
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@purpleschool/gptbot-tools",
3
+ "version": "0.0.1",
4
+ "main": "build/index.js",
5
+ "types": "build/index.d.ts",
6
+ "scripts": {
7
+ "prepublish": "rm -rf build && tsc",
8
+ "build": "tsc"
9
+ },
10
+ "keywords": [],
11
+ "author": "",
12
+ "license": "ISC",
13
+ "description": "",
14
+ "dependencies": {
15
+ "zod": "^3.24.2"
16
+ }
17
+ }
@@ -0,0 +1 @@
1
+ export * from './paraphrase.command';
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ import { ICommandResponseSchema } from '../../common/models/command-response.schema';
3
+ import { ParaphraseJobSchema } from '../models/paraphrase-job.schema';
4
+ import { PARAPHRASING_INTENSITY } from '../enums';
5
+
6
+ export namespace ParaphraseCommand {
7
+ export const RequestSchema = z.object({
8
+ jobId: z.string().uuid(),
9
+ userId: z.string().uuid().nullable(),
10
+ unregisteredUserId: z.string().uuid().nullable(),
11
+ prompt: z.string(),
12
+ modelId: z.string().uuid(),
13
+ styleId: z.string().uuid(),
14
+ intensity: z.nativeEnum(PARAPHRASING_INTENSITY),
15
+ });
16
+ export type Request = z.infer<typeof RequestSchema>;
17
+
18
+ export const ResponseSchema = ICommandResponseSchema(ParaphraseJobSchema);
19
+ export type Response = z.infer<typeof ResponseSchema>;
20
+ }
@@ -0,0 +1 @@
1
+ export * from './paraphrasing-intesity.enum';
@@ -0,0 +1,5 @@
1
+ export enum PARAPHRASING_INTENSITY {
2
+ LOW = 'low',
3
+ MEDIUM = 'medium',
4
+ HIGH = 'high',
5
+ }
@@ -0,0 +1,4 @@
1
+ export * from './commands';
2
+ export * from './enums';
3
+ export * from './models';
4
+ export * from './queries';
@@ -0,0 +1,4 @@
1
+ export * from './paraphrase-model.schema';
2
+ export * from './paraphrase-style.schema';
3
+ export * from './paraphrase-job.schema';
4
+ export * from './paraphrase-tool.schema';
@@ -0,0 +1,17 @@
1
+ import { z } from 'zod';
2
+
3
+ export const ParaphraseJobSchema = z.object({
4
+ uuid: z.string(),
5
+ userId: z.string().nullable(),
6
+ unregisteredUserId: z.string().nullable(),
7
+ userInput: z.string(),
8
+ aiOutput: z.string().nullable(),
9
+ aiTokenUsage: z.number().nullable(),
10
+ cost: z.number().nullable(),
11
+ status: z.string(),
12
+ modelId: z.string().nullable(),
13
+ styleId: z.string().nullable(),
14
+ createdAt: z.date(),
15
+ updatedAt: z.date(),
16
+ completedAt: z.date().nullable(),
17
+ });
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+
3
+ export const ParaphraseModelSchema = z.object({
4
+ uuid: z.string(),
5
+ name: z.string(),
6
+ icon: z.string(),
7
+ aiModel: z.string(),
8
+ createdAt: z.date(),
9
+ updatedAt: z.date(),
10
+ });
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+
3
+ export const ParaphraseStyleSchema = z.object({
4
+ uuid: z.string(),
5
+ name: z.string(),
6
+ icon: z.string(),
7
+ prompt: z.string(),
8
+ createdAt: z.date(),
9
+ updatedAt: z.date(),
10
+ });
@@ -0,0 +1,8 @@
1
+ import { z } from 'zod';
2
+ import { ParaphraseStyleSchema } from './paraphrase-style.schema';
3
+ import { ParaphraseModelSchema } from './paraphrase-model.schema';
4
+
5
+ export const ParaphraseToolSchema = z.object({
6
+ styles: z.array(ParaphraseStyleSchema),
7
+ models: z.array(ParaphraseModelSchema),
8
+ });
@@ -0,0 +1,5 @@
1
+ export const PARAPHRASE_ARMQ_ROUTES = {
2
+ EXECUTE: 'tools.paraphrase.execute',
3
+ CONFIG: 'tools.paraphrase.config.rpc',
4
+ GET_JOB: 'tools.paraphrase.jobs.get.rpc',
5
+ } as const;
@@ -0,0 +1,11 @@
1
+ import { z } from 'zod';
2
+ import { ICommandResponseSchema } from '../../common/models/command-response.schema';
3
+ import { ParaphraseJobSchema } from '../models';
4
+
5
+ export namespace FindParaphraseJobByUuidQuery {
6
+ export const RequestSchema = ParaphraseJobSchema.pick({ uuid: true });
7
+ export type Request = z.infer<typeof RequestSchema>;
8
+
9
+ export const ResponseSchema = ICommandResponseSchema(ParaphraseJobSchema);
10
+ export type Response = z.infer<typeof ResponseSchema>;
11
+ }
@@ -0,0 +1,8 @@
1
+ import { z } from 'zod';
2
+ import { ICommandResponseSchema } from '../../common/models/command-response.schema';
3
+ import { ParaphraseToolSchema } from '../models';
4
+
5
+ export namespace GetParaphraseToolQuery {
6
+ export const ResponseSchema = ICommandResponseSchema(ParaphraseToolSchema);
7
+ export type Response = z.infer<typeof ResponseSchema>;
8
+ }
@@ -0,0 +1,2 @@
1
+ export * from './find-paraphrase-job-by-uuid.query';
2
+ export * from './get-paraphrase-tool.query';
@@ -0,0 +1 @@
1
+ export * from './job-status.enum';
@@ -0,0 +1,5 @@
1
+ export enum JOB_STATUS {
2
+ PEDNING = 'pending',
3
+ COMPLETED = 'completed',
4
+ FAILED = 'failed',
5
+ }
package/tools/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './enums';
2
+ export * from './tools.aqmp.routes';
@@ -0,0 +1,4 @@
1
+ export const TOOLS_AQMP_ROUTES = {
2
+ JOB_COMPLETED: 'tools.job.completed',
3
+ JOB_FAILED: 'tools.job.failed',
4
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2017",
4
+ "module": "commonjs",
5
+ "outDir": "./build",
6
+ "esModuleInterop": true,
7
+ "forceConsistentCasingInFileNames": true,
8
+ "strict": true,
9
+ "strictPropertyInitialization": false,
10
+ "skipLibCheck": true
11
+ }
12
+ }