@purpleschool/gptbot 0.7.38 → 0.7.39-texteditor

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 (83) hide show
  1. package/api/controllers/http/index.ts +1 -0
  2. package/api/controllers/http/writer.ts +20 -0
  3. package/build/api/controllers/http/index.js +1 -0
  4. package/build/api/controllers/http/writer.js +22 -0
  5. package/build/commands/tools/index.js +1 -0
  6. package/build/commands/tools/writer/create-writer-document.command.js +16 -0
  7. package/build/commands/tools/writer/delete-all-writer-documents.command.js +8 -0
  8. package/build/commands/tools/writer/delete-writer-document-by-uuid.command.js +11 -0
  9. package/build/commands/tools/writer/export-writer-document-as-docx.command.js +15 -0
  10. package/build/commands/tools/writer/find-writer-document-by-uuid.command.js +14 -0
  11. package/build/commands/tools/writer/find-writer-documents.command.js +18 -0
  12. package/build/commands/tools/writer/generate-writer-document-contents.command.js +14 -0
  13. package/build/commands/tools/writer/get-writer-tool-config.command.js +11 -0
  14. package/build/commands/tools/writer/index.js +31 -0
  15. package/build/commands/tools/writer/update-writer-document-contents.command.js +18 -0
  16. package/build/commands/tools/writer/update-writer-document-outline.command.js +17 -0
  17. package/build/commands/tools/writer/writer-extend-text.command.js +18 -0
  18. package/build/commands/tools/writer/writer-fix-errors.command.js +18 -0
  19. package/build/commands/tools/writer/writer-generate-text.command.js +21 -0
  20. package/build/commands/tools/writer/writer-paraphrase.command.js +18 -0
  21. package/build/commands/tools/writer/writer-shorten-text.command.js +18 -0
  22. package/build/constants/errors/errors.js +78 -58
  23. package/build/constants/file/enums/file-type.enum.js +0 -1
  24. package/build/constants/file/file.constants.js +1 -11
  25. package/build/constants/index.js +1 -0
  26. package/build/constants/writer/enums/index.js +20 -0
  27. package/build/constants/writer/enums/writer-ai-action-pricing-type.enum.js +8 -0
  28. package/build/constants/writer/enums/writer-ai-action-type.enum.js +11 -0
  29. package/build/constants/writer/enums/writer-document-section-type.enum.js +9 -0
  30. package/build/constants/writer/enums/writer-document-stage.enum.js +14 -0
  31. package/build/constants/writer/index.js +17 -0
  32. package/build/helpers/index.js +1 -0
  33. package/build/helpers/writer/calculate-page-count.util.js +37 -0
  34. package/build/helpers/writer/calculate-writer-ai-action-price.util.js +16 -0
  35. package/build/helpers/writer/calculate-writer-content-generation-price.util.js +6 -0
  36. package/build/helpers/writer/index.js +19 -0
  37. package/build/models/tools/index.js +1 -0
  38. package/build/models/tools/writer/index.js +21 -0
  39. package/build/models/tools/writer/writer-ai-action.schema.js +26 -0
  40. package/build/models/tools/writer/writer-config.schema.js +11 -0
  41. package/build/models/tools/writer/writer-document-outline.schema.js +21 -0
  42. package/build/models/tools/writer/writer-document-type.schema.js +16 -0
  43. package/build/models/tools/writer/writer-document.schema.js +22 -0
  44. package/commands/tools/index.ts +1 -0
  45. package/commands/tools/writer/create-writer-document.command.ts +16 -0
  46. package/commands/tools/writer/delete-all-writer-documents.command.ts +6 -0
  47. package/commands/tools/writer/delete-writer-document-by-uuid.command.ts +11 -0
  48. package/commands/tools/writer/export-writer-document-as-docx.command.ts +15 -0
  49. package/commands/tools/writer/find-writer-document-by-uuid.command.ts +14 -0
  50. package/commands/tools/writer/find-writer-documents.command.ts +18 -0
  51. package/commands/tools/writer/generate-writer-document-contents.command.ts +14 -0
  52. package/commands/tools/writer/get-writer-tool-config.command.ts +10 -0
  53. package/commands/tools/writer/index.ts +15 -0
  54. package/commands/tools/writer/update-writer-document-contents.command.ts +20 -0
  55. package/commands/tools/writer/update-writer-document-outline.command.ts +19 -0
  56. package/commands/tools/writer/writer-extend-text.command.ts +20 -0
  57. package/commands/tools/writer/writer-fix-errors.command.ts +20 -0
  58. package/commands/tools/writer/writer-generate-text.command.ts +23 -0
  59. package/commands/tools/writer/writer-paraphrase.command.ts +20 -0
  60. package/commands/tools/writer/writer-shorten-text.command.ts +20 -0
  61. package/constants/errors/errors.ts +78 -59
  62. package/constants/file/enums/file-type.enum.ts +0 -1
  63. package/constants/file/file.constants.ts +0 -12
  64. package/constants/index.ts +1 -0
  65. package/constants/writer/enums/index.ts +4 -0
  66. package/constants/writer/enums/writer-ai-action-pricing-type.enum.ts +4 -0
  67. package/constants/writer/enums/writer-ai-action-type.enum.ts +7 -0
  68. package/constants/writer/enums/writer-document-section-type.enum.ts +5 -0
  69. package/constants/writer/enums/writer-document-stage.enum.ts +13 -0
  70. package/constants/writer/index.ts +1 -0
  71. package/helpers/index.ts +1 -0
  72. package/helpers/writer/calculate-page-count.util.ts +46 -0
  73. package/helpers/writer/calculate-writer-ai-action-price.util.ts +20 -0
  74. package/helpers/writer/calculate-writer-content-generation-price.util.ts +3 -0
  75. package/helpers/writer/index.ts +3 -0
  76. package/models/tools/index.ts +1 -0
  77. package/models/tools/writer/index.ts +5 -0
  78. package/models/tools/writer/writer-ai-action.schema.ts +27 -0
  79. package/models/tools/writer/writer-config.schema.ts +10 -0
  80. package/models/tools/writer/writer-document-outline.schema.ts +28 -0
  81. package/models/tools/writer/writer-document-type.schema.ts +15 -0
  82. package/models/tools/writer/writer-document.schema.ts +21 -0
  83. package/package.json +1 -1
@@ -1715,114 +1715,133 @@ export const ERRORS = {
1715
1715
  httpCode: 500,
1716
1716
  },
1717
1717
  DAILY_REWARD_COLLECT_ERROR: {
1718
- code: 'A353',
1718
+ code: 'A362',
1719
1719
  message: 'Ошибка при получении ежедневной награды',
1720
1720
  httpCode: 500,
1721
1721
  },
1722
1722
  DAILY_STREAK_CREATE_ERROR: {
1723
- code: 'A354',
1723
+ code: 'A363',
1724
1724
  message: 'Ошибка при создании ежедневного стрика',
1725
1725
  httpCode: 500,
1726
1726
  },
1727
1727
  DAILY_STREAK_FIND_ERROR: {
1728
- code: 'A355',
1728
+ code: 'A364',
1729
1729
  message: 'Ошибка при поиске ежедневного стрика',
1730
1730
  httpCode: 500,
1731
1731
  },
1732
1732
  DAILY_STREAK_PROMOCODE_ALREADY_EXISTS_ERROR: {
1733
- code: 'A356',
1733
+ code: 'A365',
1734
1734
  message: 'Промокод для ежедневного стрика уже существует',
1735
1735
  httpCode: 409,
1736
1736
  },
1737
1737
  DAILY_REWARD_NOT_READY_ERROR: {
1738
- code: 'A357',
1738
+ code: 'A366',
1739
1739
  message: 'Запрашиваемая награда ещё недоступна для получения',
1740
1740
  httpCode: 429,
1741
1741
  },
1742
1742
  DAILY_REWARD_ALREADY_COLLECTED_ERROR: {
1743
- code: 'A358',
1743
+ code: 'A367',
1744
1744
  message: 'Запрашиваемая награда уже получена',
1745
1745
  httpCode: 429,
1746
1746
  },
1747
1747
  DAILY_STREAK_UPDATE_ERROR: {
1748
- code: 'A359',
1748
+ code: 'A368',
1749
1749
  message: 'Ошибка при обновлении ежедневного стрика',
1750
1750
  httpCode: 500,
1751
1751
  },
1752
+ WRITER_CONFIG_ERROR: {
1753
+ code: 'A369',
1754
+ message: 'Произошла ошибка при получении конфигурации Writer',
1755
+ httpCode: 500,
1756
+ },
1757
+ WRITER_CREATE_DOCUMENT_ERROR: {
1758
+ code: 'A370',
1759
+ message: 'Произошла ошибка при создании документа',
1760
+ httpCode: 500,
1761
+ },
1762
+ WRITER_DOCUMENT_FIND_ERROR: {
1763
+ code: 'A371',
1764
+ message: 'Произошла ошибка при поиске документа',
1765
+ httpCode: 500,
1766
+ },
1767
+ WRITER_DOCUMENTS_FIND_ERROR: {
1768
+ code: 'A372',
1769
+ message: 'Произошла ошибка при поиске документов',
1770
+ httpCode: 500,
1771
+ },
1772
+ WRITER_DELETE_DOCUMENT_ERROR: {
1773
+ code: 'A373',
1774
+ message: 'Произошла ошибка при удалении документа',
1775
+ httpCode: 500,
1776
+ },
1777
+ WRITER_DELETE_ALL_DOCUMENTS_ERROR: {
1778
+ code: 'A374',
1779
+ message: 'Произошла ошибка при удалении всех документов пользователя',
1780
+ httpCode: 500,
1781
+ },
1782
+ WRITER_UPDATE_DOCUMENT_OUTLINE_ERROR: {
1783
+ code: 'A375',
1784
+ message: 'Произошла ошибка при обновлении структуры документа',
1785
+ httpCode: 500,
1786
+ },
1787
+ WRITER_GENERATE_DOCUMENT_CONTENTS_ERROR: {
1788
+ code: 'A376',
1789
+ message: 'Произошла ошибка при генерации содержимого документа',
1790
+ httpCode: 500,
1791
+ },
1752
1792
  ACCOUNT_DELETE_ERROR: {
1753
- code: 'A360',
1793
+ code: 'A377',
1754
1794
  message: 'Аккаунт не был удалён',
1755
1795
  httpCode: 500,
1756
1796
  },
1757
1797
  ACCOUNT_DELETED: {
1758
- code: 'A361',
1798
+ code: 'A378',
1759
1799
  message: 'Операция невозможна, аккаунт был удалён',
1760
1800
  httpCode: 400,
1761
1801
  },
1762
- TELEGRAM_PROFILE_DELETE_ERROR: {
1763
- code: 'A362',
1764
- message: 'Произошла ошибка при удалении Telegram профиля',
1765
- httpCode: 500,
1766
- },
1767
1802
  TOOL_NOT_FOUND_ERROR: {
1768
- code: 'A363',
1803
+ code: 'A379',
1769
1804
  message: 'Инструмент не найден',
1770
1805
  httpCode: 404,
1771
1806
  },
1772
- ORDER_CHECK_FIRST_PURCHASE_ERROR: {
1773
- code: 'A364',
1774
- message: 'Произошла ошибка при проверке первой покупки',
1807
+ TELEGRAM_PROFILE_DELETE_ERROR: {
1808
+ code: 'A380',
1809
+ message: 'Произошла ошибка при удалении Telegram профиля',
1775
1810
  httpCode: 500,
1776
1811
  },
1777
- ORDER_CURRENT_ORDER_NOT_FOUND_ERROR: {
1778
- code: 'A365',
1779
- message: 'Текущий заказ не найден',
1780
- httpCode: 404,
1781
- },
1782
- ORDER_GET_USER_ORDERS_ERROR: {
1783
- code: 'A366',
1784
- message: 'Произошла ошибка при получении заказов пользователя',
1812
+ WRITER_PARAPHRASE_ERROR: {
1813
+ code: 'A381',
1814
+ message: 'Произошла ошибка при перефразировании текста',
1785
1815
  httpCode: 500,
1786
1816
  },
1787
- ORDER_NO_SUBSCRIPTION_ID_OR_PRODUCT_ID_PROVIDED_ERROR: {
1788
- code: 'A367',
1789
- message: 'Не указан subscriptionId или productId',
1790
- httpCode: 400,
1791
- },
1792
- FILE_TO_MD_FORMAT_ERROR: {
1793
- code: 'A364',
1794
- message: 'Неверный формат файла, варианты: .xlsx, .docx, .pdf',
1795
- httpCode: 400,
1796
- },
1797
- FILE_TO_MD_ERROR: {
1798
- code: 'A365',
1799
- message: 'Произошла ошибка при конвертации файла в markdown',
1817
+ WRITER_EXTEND_TEXT_ERROR: {
1818
+ code: 'A382',
1819
+ message: 'Произошла ошибка при расширении текста',
1800
1820
  httpCode: 500,
1801
1821
  },
1802
- FILE_TO_MD_CONVERT_ERROR: {
1803
- code: 'A366',
1804
- message:
1805
- 'Не получилось конвертировать файл в markdown, возможно файл поврежден или невалиден',
1822
+ WRITER_SHORTEN_TEXT_ERROR: {
1823
+ code: 'A383',
1824
+ message: 'Произошла ошибка при сокращении текста',
1806
1825
  httpCode: 500,
1807
1826
  },
1808
- IMAGE_EDITOR_MODEL_INACTIVE: {
1809
- code: 'A367',
1810
- message: 'Модель редактирования картинок архивирована и недоступна для пользования',
1811
- httpCode: 403,
1827
+ WRITER_FIX_ERRORS_ERROR: {
1828
+ code: 'A384',
1829
+ message: 'Произошла ошибка при исправлении ошибок в тексте',
1830
+ httpCode: 500,
1812
1831
  },
1813
- TTS_MODEL_INACTIVE: {
1814
- code: 'A368',
1815
- message: 'Модель генерации текста в голос архивирована и недоступна для пользования',
1816
- httpCode: 403,
1832
+ WRITER_UPDATE_DOCUMENT_CONTENTS_ERROR: {
1833
+ code: 'A385',
1834
+ message: 'Произошла ошибка при обновлении содержимого документа',
1835
+ httpCode: 500,
1817
1836
  },
1818
- STT_MODEL_INACTIVE: {
1819
- code: 'A369',
1820
- message: 'Модель генерации голоса в текст архивирована и недоступна для пользования',
1821
- httpCode: 403,
1837
+ WRITER_GENERATE_TEXT_ERROR: {
1838
+ code: 'A386',
1839
+ message: 'Произошла ошибка при генерации текста',
1840
+ httpCode: 500,
1822
1841
  },
1823
- VIDEO_MODEL_INACTIVE: {
1824
- code: 'A370',
1825
- message: 'Модель генерации видео архивирована и недоступна для пользования',
1826
- httpCode: 403,
1842
+ WRITER_EXPORT_DOCX_ERROR: {
1843
+ code: 'A387',
1844
+ message: 'Произошла ошибка при экспорте документа в DOCX',
1845
+ httpCode: 500,
1827
1846
  },
1828
1847
  };
@@ -2,6 +2,5 @@ export enum FILE_TYPE {
2
2
  IMAGE = 'image',
3
3
  AUDIO = 'audio',
4
4
  TEXT = 'text',
5
- DOCUMENT = 'document',
6
5
  OTHER = 'other',
7
6
  }
@@ -3,7 +3,6 @@ import { FILE_TYPE } from './enums';
3
3
  export const MAX_IMAGE_UPLOAD_SIZE = 5 * 1024 * 1024; // 5 MB
4
4
  export const MAX_AUDIO_UPLOAD_SIZE = 500 * 1024 * 1024; // 500 MB
5
5
  export const MAX_TEXT_UPLOAD_SIZE = 10 * 1024 * 1024; // 10 MB
6
- export const MAX_DOC_UPLOAD_SIZE = 20 * 1024 * 1024; // 20 MB
7
6
 
8
7
  export const SUPPORTED_FILES = new Map<
9
8
  string,
@@ -49,17 +48,6 @@ export const SUPPORTED_FILES = new Map<
49
48
  ['text/x-ini', { type: FILE_TYPE.TEXT, size: MAX_TEXT_UPLOAD_SIZE }],
50
49
  ['text/x-properties', { type: FILE_TYPE.TEXT, size: MAX_TEXT_UPLOAD_SIZE }],
51
50
  ['text/x-config', { type: FILE_TYPE.TEXT, size: MAX_TEXT_UPLOAD_SIZE }],
52
- [
53
- 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
54
- { type: FILE_TYPE.DOCUMENT, size: MAX_DOC_UPLOAD_SIZE },
55
- ], //.docx
56
-
57
- [
58
- 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
59
- { type: FILE_TYPE.DOCUMENT, size: MAX_DOC_UPLOAD_SIZE },
60
- ], //.xlsx
61
-
62
- ['application/pdf', { type: FILE_TYPE.DOCUMENT, size: MAX_DOC_UPLOAD_SIZE }],
63
51
  ]);
64
52
 
65
53
  export const DELETE_UNUSED_FILES_AFTER_HOURS = 12;
@@ -31,6 +31,7 @@ export * from './promocode';
31
31
  export * from './ui-notification';
32
32
  export * from './review';
33
33
  export * from './tool-video';
34
+ export * from './writer';
34
35
  export * from './tool-image-editor';
35
36
  export * from './feedback';
36
37
  export * from './daily-streak';
@@ -0,0 +1,4 @@
1
+ export * from './writer-document-section-type.enum';
2
+ export * from './writer-document-stage.enum';
3
+ export * from './writer-ai-action-pricing-type.enum';
4
+ export * from './writer-ai-action-type.enum';
@@ -0,0 +1,4 @@
1
+ export enum WRITER_AI_ACTION_PRICING_TYPE {
2
+ PER_CHARACTER = 'PER_CHARACTER',
3
+ FLAT = 'FLAT',
4
+ }
@@ -0,0 +1,7 @@
1
+ export enum WRITER_AI_ACTION_TYPE {
2
+ PARAPHRASE = 'PARAPHRASE',
3
+ EXTEND_TEXT = 'EXTEND_TEXT',
4
+ SHORTEN_TEXT = 'SHORTEN_TEXT',
5
+ GENERATE_TEXT = 'GENERATE_TEXT',
6
+ FIX_ERRORS = 'FIX_ERRORS',
7
+ }
@@ -0,0 +1,5 @@
1
+ export enum WRITER_DOCUMENT_SECTION_TYPE {
2
+ INTRODUCTION = 'introduction',
3
+ CONCLUSION = 'conclusion',
4
+ SECTION = 'section',
5
+ }
@@ -0,0 +1,13 @@
1
+ export enum WRITER_DOCUMENT_STAGE {
2
+ CREATED = 'CREATED',
3
+
4
+ GENERATING_OUTLINE = 'GENERATING_OUTLINE',
5
+ OUTLINE_GENERATED = 'OUTLINE_GENERATED',
6
+ OUTLINE_GENERATION_FAILED = 'OUTLINE_GENERATION_FAILED',
7
+
8
+ GENERATING_CONTENT = 'GENERATING_CONTENT',
9
+ CONTENT_GENERATED = 'CONTENT_GENERATED',
10
+ CONTENT_GENERATION_FAILED = 'CONTENT_GENERATION_FAILED',
11
+
12
+ DELETED = 'DELETED',
13
+ }
@@ -0,0 +1 @@
1
+ export * from './enums';
package/helpers/index.ts CHANGED
@@ -3,3 +3,4 @@ export * from './stt';
3
3
  export * from './subscription';
4
4
  export * from './tts';
5
5
  export * from './video';
6
+ export * from './writer';
@@ -0,0 +1,46 @@
1
+ const WORD_FONT_SIZE_PT = 14;
2
+ const WORD_LINE_SPACING = 1.5;
3
+
4
+ const A4_WIDTH_MM = 210;
5
+ const A4_HEIGHT_MM = 297;
6
+
7
+ const MARGIN_TOP_MM = 20;
8
+ const MARGIN_BOTTOM_MM = 20;
9
+ const MARGIN_LEFT_MM = 30;
10
+ const MARGIN_RIGHT_MM = 10;
11
+
12
+ const FIRST_LINE_INDENT_MM = 12.5;
13
+
14
+ const MM_PER_POINT = 0.3527777778;
15
+
16
+ const TEXT_WIDTH_MM = A4_WIDTH_MM - MARGIN_LEFT_MM - MARGIN_RIGHT_MM;
17
+ const TEXT_HEIGHT_MM = A4_HEIGHT_MM - MARGIN_TOP_MM - MARGIN_BOTTOM_MM;
18
+
19
+ const LINE_HEIGHT_MM = WORD_FONT_SIZE_PT * WORD_LINE_SPACING * MM_PER_POINT;
20
+ const LINES_PER_PAGE = Math.floor(TEXT_HEIGHT_MM / LINE_HEIGHT_MM);
21
+
22
+ const AVG_CHAR_WIDTH_EM = 0.58;
23
+ const AVG_CHAR_WIDTH_MM = WORD_FONT_SIZE_PT * AVG_CHAR_WIDTH_EM * MM_PER_POINT;
24
+
25
+ const CHARS_PER_LINE = Math.floor(TEXT_WIDTH_MM / AVG_CHAR_WIDTH_MM);
26
+ const AVG_PARAGRAPHS_PER_PAGE = 4; // average paragraph count across typical student papers
27
+ const INDENT_CHARS_LOSS = Math.round(
28
+ (FIRST_LINE_INDENT_MM / AVG_CHAR_WIDTH_MM) * AVG_PARAGRAPHS_PER_PAGE,
29
+ );
30
+
31
+ const LAYOUT_FUDGE_FACTOR = 0.96;
32
+
33
+ export const CHARACTERS_PER_PAGE = Math.round(
34
+ (LINES_PER_PAGE * CHARS_PER_LINE - INDENT_CHARS_LOSS) * LAYOUT_FUDGE_FACTOR,
35
+ );
36
+
37
+ export function pagesToCharacters(pages: number): number {
38
+ if (!Number.isFinite(pages) || pages <= 0) return 0;
39
+ return Math.max(0, Math.round(pages * CHARACTERS_PER_PAGE));
40
+ }
41
+
42
+ export function charactersToPages(characters: number): number {
43
+ if (!Number.isFinite(characters) || characters <= 0) return 0;
44
+ const raw = characters / CHARACTERS_PER_PAGE;
45
+ return Math.max(0, Math.ceil(raw));
46
+ }
@@ -0,0 +1,20 @@
1
+ import { WRITER_AI_ACTION_PRICING_TYPE } from '../../constants';
2
+ import { WriterAiActionPricingRules } from '../../models';
3
+
4
+ export function calculateWriterAiActionPrice(
5
+ pricingRules: WriterAiActionPricingRules,
6
+ selectionText: string,
7
+ ): number {
8
+ switch (pricingRules.type) {
9
+ case WRITER_AI_ACTION_PRICING_TYPE.PER_CHARACTER:
10
+ const characterCount = selectionText.length;
11
+ const price = characterCount * pricingRules.price;
12
+ return Math.max(1, Math.ceil(price));
13
+
14
+ case WRITER_AI_ACTION_PRICING_TYPE.FLAT:
15
+ return Math.max(1, Math.ceil(pricingRules.price));
16
+
17
+ default:
18
+ throw new Error(`Unknown pricing type`);
19
+ }
20
+ }
@@ -0,0 +1,3 @@
1
+ export function calculateWriterContentGenerationPrice(pages: number): number {
2
+ return Math.max(1, pages);
3
+ }
@@ -0,0 +1,3 @@
1
+ export * from './calculate-writer-ai-action-price.util';
2
+ export * from './calculate-writer-content-generation-price.util';
3
+ export * from './calculate-page-count.util';
@@ -3,4 +3,5 @@ export * from './paraphrase';
3
3
  export * from './stt';
4
4
  export * from './tts';
5
5
  export * from './video';
6
+ export * from './writer';
6
7
  export * from './image-editor';
@@ -0,0 +1,5 @@
1
+ export * from './writer-config.schema';
2
+ export * from './writer-ai-action.schema';
3
+ export * from './writer-document-outline.schema';
4
+ export * from './writer-document.schema';
5
+ export * from './writer-document-type.schema';
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+ import { WRITER_AI_ACTION_PRICING_TYPE, WRITER_AI_ACTION_TYPE } from '../../../constants';
3
+
4
+ export const WriterAiActionPricingRulesSchema = z.discriminatedUnion('type', [
5
+ z.object({
6
+ type: z.literal(WRITER_AI_ACTION_PRICING_TYPE.PER_CHARACTER),
7
+ price: z.number(),
8
+ }),
9
+ z.object({
10
+ type: z.literal(WRITER_AI_ACTION_PRICING_TYPE.FLAT),
11
+ price: z.number(),
12
+ }),
13
+ ]);
14
+ export type WriterAiActionPricingRules = z.infer<typeof WriterAiActionPricingRulesSchema>;
15
+
16
+ export const WriterAiActionSchema = z.object({
17
+ uuid: z.string(),
18
+ type: z.nativeEnum(WRITER_AI_ACTION_TYPE),
19
+ pricingRules: WriterAiActionPricingRulesSchema,
20
+ maxPromptLength: z.number(),
21
+ title: z.string(),
22
+ icon: z.string(),
23
+ order: z.number(),
24
+ createdAt: z.date(),
25
+ updatedAt: z.date(),
26
+ });
27
+ export type WriterAiAction = z.infer<typeof WriterAiActionSchema>;
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+ import { WriterDocumentTypeSchema } from './writer-document-type.schema';
3
+ import { WriterAiActionSchema } from './writer-ai-action.schema';
4
+
5
+ export const WriterConfigSchema = z.object({
6
+ maxPromptLength: z.number(),
7
+ documentTypes: z.array(WriterDocumentTypeSchema),
8
+ aiActions: z.array(WriterAiActionSchema),
9
+ });
10
+ export type WriterConfig = z.infer<typeof WriterConfigSchema>;
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+ import { WRITER_DOCUMENT_SECTION_TYPE } from '../../../constants';
3
+
4
+ export const WriterDocumentOutlineSubsectionSchema = z.object({
5
+ title: z
6
+ .string()
7
+ .min(3)
8
+ .max(120)
9
+ .describe(
10
+ `Concise title of the subsection. Meant to elaborate on its parent section's title.`,
11
+ ),
12
+ });
13
+ export type WriterDocumentOutlineSubsection = z.infer<typeof WriterDocumentOutlineSubsectionSchema>;
14
+
15
+ export const WriterDocumentOutlineSectionSchema = z.object({
16
+ title: z.string().min(3).max(120).describe(`Concise title of the paper section.`),
17
+ type: z.nativeEnum(WRITER_DOCUMENT_SECTION_TYPE),
18
+ subsections: z
19
+ .array(WriterDocumentOutlineSubsectionSchema)
20
+ .optional()
21
+ .describe(
22
+ `Subsections of the paper section. Each subsection is a single idea that is a part of the parent section.`,
23
+ ),
24
+ });
25
+
26
+ export const WriterDocumentOutlineSchema = z.array(WriterDocumentOutlineSectionSchema);
27
+
28
+ export type WriterDocumentOutline = z.infer<typeof WriterDocumentOutlineSchema>;
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod';
2
+ import { IconVariantsSchema } from '../../icon-variants.schema';
3
+
4
+ export const WriterDocumentTypeSchema = z.object({
5
+ uuid: z.string().uuid(),
6
+ title: z.string(),
7
+ icons: IconVariantsSchema,
8
+ order: z.number(),
9
+ minPages: z.number(),
10
+ maxPages: z.number(),
11
+ pageRange: z.array(z.number()),
12
+ createdAt: z.date(),
13
+ updatedAt: z.date(),
14
+ });
15
+ export type WriterDocumentType = z.infer<typeof WriterDocumentTypeSchema>;
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+ import { WriterDocumentOutlineSchema } from './writer-document-outline.schema';
3
+ import { WRITER_DOCUMENT_STAGE } from '../../../constants';
4
+
5
+ export const WriterDocumentSchema = z.object({
6
+ uuid: z.string().uuid(),
7
+ prompt: z.string(),
8
+ topic: z.string(),
9
+ typeId: z.string(),
10
+ stage: z.nativeEnum(WRITER_DOCUMENT_STAGE),
11
+ outline: WriterDocumentOutlineSchema,
12
+ sourceMd: z.string().nullable(),
13
+ finalMd: z.string().nullable(),
14
+ userId: z.string().nullable(),
15
+ unregisteredUserId: z.string().nullable(),
16
+ pages: z.number(),
17
+ createdAt: z.date(),
18
+ updatedAt: z.date(),
19
+ completedAt: z.date().nullable(),
20
+ });
21
+ export type WriterDocument = z.infer<typeof WriterDocumentSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.7.38",
3
+ "version": "0.7.39-texteditor",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",