@purpleschool/gptbot-tools 0.0.36 → 0.0.37-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 (99) hide show
  1. package/build/common/errors/errors.js +104 -8
  2. package/build/image-editor/commands/delete-all-image-editor-jobs.command.js +13 -0
  3. package/build/image-editor/commands/delete-image-editor-job-by-uuid.command.js +14 -0
  4. package/build/image-editor/commands/image-editor.command.js +21 -0
  5. package/build/image-editor/commands/index.js +22 -0
  6. package/build/image-editor/commands/retry-image-editor-job.command.js +16 -0
  7. package/build/image-editor/commands/set-reaction-to-image-editor-job.command.js +17 -0
  8. package/build/image-editor/commands/update-image-editor-job-title.command.js +16 -0
  9. package/build/image-editor/enums/image-editor-model-type.enum.js +7 -0
  10. package/build/image-editor/enums/image-editor-strategy.enum.js +8 -0
  11. package/build/image-editor/enums/index.js +18 -0
  12. package/build/image-editor/index.js +21 -0
  13. package/build/image-editor/models/image-editor-config.schema.js +32 -0
  14. package/build/image-editor/models/image-editor-job.schema.js +30 -0
  15. package/build/image-editor/models/image-editor-model.schema.js +27 -0
  16. package/build/image-editor/models/index.js +19 -0
  17. package/build/image-editor/queries/find-image-editor-job-by-id.query.js +10 -0
  18. package/build/image-editor/queries/find-image-editor-jobs.query.js +21 -0
  19. package/build/image-editor/queries/find-image-jobs.query.js +21 -0
  20. package/build/image-editor/queries/get-image-editor-config.query.js +9 -0
  21. package/build/image-editor/queries/index.js +19 -0
  22. package/build/image-editor/routes/image-editor.amqp.routes.js +14 -0
  23. package/build/image-editor/routes/image-editor.http.routes.js +7 -0
  24. package/build/image-editor/routes/index.js +18 -0
  25. package/build/index.js +3 -0
  26. package/build/writer/commands/create-writer-document.command.js +1 -1
  27. package/build/writer/commands/generate-document-contents.command.js +1 -0
  28. package/build/writer/commands/index.js +6 -0
  29. package/build/writer/commands/update-writer-document-contents.command.js +17 -0
  30. package/build/writer/commands/update-writer-document-final-md.command.js +17 -0
  31. package/build/writer/commands/writer-extend-text.command.js +18 -0
  32. package/build/writer/commands/writer-fix-errors.command.js +18 -0
  33. package/build/writer/commands/writer-generate-text.command.js +21 -0
  34. package/build/writer/commands/writer-paraphrase.command.js +18 -0
  35. package/build/writer/commands/writer-shorten-text.command.js +18 -0
  36. package/build/writer/enums/index.js +3 -2
  37. package/build/writer/enums/writer-ai-action-call.enum.js +9 -0
  38. package/build/writer/enums/writer-ai-action-pricing-type.enum.js +8 -0
  39. package/build/writer/enums/writer-ai-action-type.enum.js +11 -0
  40. package/build/writer/index.js +1 -0
  41. package/build/writer/models/index.js +1 -1
  42. package/build/writer/models/writer-ai-action.schema.js +26 -0
  43. package/build/writer/models/writer-config.schema.js +3 -3
  44. package/build/writer/routes/writer.routes.js +6 -0
  45. package/build/writer/utils/calculate-writer-ai-action-price.util.js +16 -0
  46. package/build/writer/utils/calculate-writer-content-generation-price.util.js +6 -0
  47. package/build/writer/utils/index.js +18 -0
  48. package/common/errors/errors.ts +105 -8
  49. package/image-editor/commands/delete-all-image-editor-jobs.command.ts +13 -0
  50. package/image-editor/commands/delete-image-editor-job-by-uuid.command.ts +14 -0
  51. package/image-editor/commands/image-editor.command.ts +21 -0
  52. package/image-editor/commands/index.ts +6 -0
  53. package/image-editor/commands/retry-image-editor-job.command.ts +16 -0
  54. package/image-editor/commands/set-reaction-to-image-editor-job.command.ts +17 -0
  55. package/image-editor/commands/update-image-editor-job-title.command.ts +16 -0
  56. package/image-editor/enums/image-editor-model-type.enum.ts +3 -0
  57. package/image-editor/enums/image-editor-strategy.enum.ts +4 -0
  58. package/image-editor/enums/index.ts +2 -0
  59. package/image-editor/index.ts +5 -0
  60. package/image-editor/models/image-editor-config.schema.ts +34 -0
  61. package/image-editor/models/image-editor-job.schema.ts +33 -0
  62. package/image-editor/models/image-editor-model.schema.ts +30 -0
  63. package/image-editor/models/index.ts +3 -0
  64. package/image-editor/queries/find-image-editor-job-by-id.query.ts +11 -0
  65. package/image-editor/queries/find-image-editor-jobs.query.ts +23 -0
  66. package/image-editor/queries/find-image-jobs.query.ts +23 -0
  67. package/image-editor/queries/get-image-editor-config.query.ts +8 -0
  68. package/image-editor/queries/index.ts +3 -0
  69. package/image-editor/routes/image-editor.amqp.routes.ts +11 -0
  70. package/image-editor/routes/image-editor.http.routes.ts +5 -0
  71. package/image-editor/routes/index.ts +2 -0
  72. package/index.ts +3 -0
  73. package/package.json +1 -1
  74. package/writer/commands/create-writer-document.command.ts +1 -1
  75. package/writer/commands/generate-document-contents.command.ts +1 -0
  76. package/writer/commands/index.ts +6 -0
  77. package/writer/commands/update-writer-document-contents.command.ts +19 -0
  78. package/writer/commands/update-writer-document-final-md.command.ts +19 -0
  79. package/writer/commands/writer-extend-text.command.ts +20 -0
  80. package/writer/commands/writer-fix-errors.command.ts +20 -0
  81. package/writer/commands/writer-generate-text.command.ts +23 -0
  82. package/writer/commands/writer-paraphrase.command.ts +20 -0
  83. package/writer/commands/writer-shorten-text.command.ts +20 -0
  84. package/writer/enums/index.ts +3 -2
  85. package/writer/enums/writer-ai-action-call.enum.ts +5 -0
  86. package/writer/enums/{writer-ai-operation-pricing-type.enum.ts → writer-ai-action-pricing-type.enum.ts} +1 -1
  87. package/writer/enums/{writer-ai-operation-type.enum.ts → writer-ai-action-type.enum.ts} +3 -1
  88. package/writer/index.ts +1 -0
  89. package/writer/models/index.ts +1 -1
  90. package/writer/models/writer-ai-action.schema.ts +27 -0
  91. package/writer/models/writer-config.schema.ts +4 -4
  92. package/writer/routes/writer.routes.ts +6 -0
  93. package/writer/utils/calculate-writer-ai-action-price.util.ts +20 -0
  94. package/writer/utils/calculate-writer-content-generation-price.util.ts +3 -0
  95. package/writer/utils/index.ts +2 -0
  96. package/build/writer/enums/writer-ai-operation-pricing-type.enum.js +0 -8
  97. package/build/writer/enums/writer-ai-operation-type.enum.js +0 -9
  98. package/build/writer/models/writer-ai-operation.schema.js +0 -26
  99. package/writer/models/writer-ai-operation.schema.ts +0 -27
@@ -0,0 +1,33 @@
1
+ import { z } from 'zod';
2
+ import { JOB_STATUS } from '../../tools';
3
+ import { USER_REACTION } from '../../common';
4
+
5
+ export const ImageEditorJobParamsSchema = z.object({
6
+ imageUrls: z.array(z.string()).optional(),
7
+ systemPromptId: z.string().optional(),
8
+ });
9
+
10
+ export type ImageEditorJobParams = z.infer<typeof ImageEditorJobParamsSchema>;
11
+
12
+ export const ImageEditorJobSchema = z.object({
13
+ uuid: z.string(),
14
+ prompt: z.string(),
15
+ reaction: z.nativeEnum(USER_REACTION).nullable(),
16
+ externalId: z.string().nullable(),
17
+ title: z.string(),
18
+ status: z.nativeEnum(JOB_STATUS),
19
+ error: z.string().nullable(),
20
+ modelId: z.string(),
21
+ price: z.number(),
22
+ params: ImageEditorJobParamsSchema,
23
+ imageUrls: z.array(z.string()).nullable(),
24
+ attempts: z.array(z.any()),
25
+ userId: z.string().nullable().optional(),
26
+ unregisteredUserId: z.string().nullable().optional(),
27
+ isDeleted: z.boolean(),
28
+ createdAt: z.date(),
29
+ completedAt: z.date().nullable().optional(),
30
+ updatedAt: z.date(),
31
+ });
32
+
33
+ export type ImageEditorJob = z.infer<typeof ImageEditorJobSchema>;
@@ -0,0 +1,30 @@
1
+ import { z } from 'zod';
2
+ import { IconVariantsSchema } from '../../common';
3
+ import { IMAGE_EDITING_STRATEGY } from '../enums';
4
+
5
+ export const ImageEditorModelParamsSchema = z.object({
6
+ imageAttachment: z.object({
7
+ supported: z.boolean(),
8
+ maxImages: z.number(),
9
+ acceptedTypes: z.array(z.string()),
10
+ }),
11
+ });
12
+
13
+ export type ImageEditorModelParams = z.infer<typeof ImageEditorModelParamsSchema>;
14
+
15
+ export const ImageEditorModelSchema = z.object({
16
+ uuid: z.string(),
17
+ title: z.string(),
18
+ description: z.string(),
19
+ aiModel: z.string(),
20
+ pricePerImage: z.number(),
21
+ order: z.number(),
22
+ icons: IconVariantsSchema,
23
+ strategy: z.nativeEnum(IMAGE_EDITING_STRATEGY),
24
+ maxInputLength: z.number(),
25
+ params: ImageEditorModelParamsSchema,
26
+ createdAt: z.date(),
27
+ updatedAt: z.date(),
28
+ });
29
+
30
+ export type ImageEditorModel = z.infer<typeof ImageEditorModelSchema>;
@@ -0,0 +1,3 @@
1
+ export * from './image-editor-config.schema';
2
+ export * from './image-editor-job.schema';
3
+ export * from './image-editor-model.schema';
@@ -0,0 +1,11 @@
1
+ import { z } from 'zod';
2
+ import { ICommandResponseSchema } from '../../common/models/command-response.schema';
3
+ import { ImageEditorJobSchema } from '../models';
4
+
5
+ export namespace FindImageEditorJobByIdQuery {
6
+ export const RequestSchema = ImageEditorJobSchema.pick({ uuid: true });
7
+ export type Request = z.infer<typeof RequestSchema>;
8
+
9
+ export const ResponseSchema = ICommandResponseSchema(ImageEditorJobSchema);
10
+ export type Response = z.infer<typeof ResponseSchema>;
11
+ }
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod';
2
+ import { ICommandResponseSchema } from '../../common/models/command-response.schema';
3
+ import { ImageEditorJobSchema } from '../models';
4
+
5
+ export namespace FindImageEditorJobsQuery {
6
+ export const RequestSchema = z.object({
7
+ userId: z.string().uuid().optional(),
8
+ unregisteredUserId: z.string().uuid().optional(),
9
+ title: z.string().optional(),
10
+ limit: z.coerce.number().min(1).optional(),
11
+ offset: z.coerce.number().min(0).default(0).optional(),
12
+ });
13
+ export type Request = z.infer<typeof RequestSchema>;
14
+
15
+ export const ResponseSchema = ICommandResponseSchema(
16
+ z.object({
17
+ data: z.array(ImageEditorJobSchema),
18
+ page: z.number(),
19
+ totalPages: z.number(),
20
+ }),
21
+ );
22
+ export type Response = z.infer<typeof ResponseSchema>;
23
+ }
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod';
2
+ import { ICommandResponseSchema } from '../../common/models/command-response.schema';
3
+ import { ImageEditorJobSchema } from '../models';
4
+
5
+ export namespace FindImageJobsQuery {
6
+ export const RequestSchema = z.object({
7
+ userId: z.string().uuid().optional(),
8
+ unregisteredUserId: z.string().uuid().optional(),
9
+ title: z.string().optional(),
10
+ limit: z.coerce.number().min(1).optional(),
11
+ offset: z.coerce.number().min(0).default(0).optional(),
12
+ });
13
+ export type Request = z.infer<typeof RequestSchema>;
14
+
15
+ export const ResponseSchema = ICommandResponseSchema(
16
+ z.object({
17
+ data: z.array(ImageEditorJobSchema),
18
+ page: z.number(),
19
+ totalPages: z.number(),
20
+ }),
21
+ );
22
+ export type Response = z.infer<typeof ResponseSchema>;
23
+ }
@@ -0,0 +1,8 @@
1
+ import { z } from 'zod';
2
+ import { ICommandResponseSchema } from '../../common/models/command-response.schema';
3
+ import { ImageEditorConfigSchema } from '../models';
4
+
5
+ export namespace GetImageEditorConfigQuery {
6
+ export const ResponseSchema = ICommandResponseSchema(ImageEditorConfigSchema);
7
+ export type Response = z.infer<typeof ResponseSchema>;
8
+ }
@@ -0,0 +1,3 @@
1
+ export * from './find-image-editor-job-by-id.query';
2
+ export * from './find-image-editor-jobs.query';
3
+ export * from './get-image-editor-config.query';
@@ -0,0 +1,11 @@
1
+ export const IMAGE_EDITOR_AMQP_ROUTES = {
2
+ EXECUTE: 'tools.image.execute.rpc',
3
+ CONFIG: 'tools.image.config.rpc',
4
+ GET_JOB: 'tools.image.jobs.get.rpc',
5
+ LIST_JOBS: 'tools.image.jobs.list.rpc',
6
+ SET_REACTION: 'tools.image.jobs.set-reaction.rpc',
7
+ UPDATE_TITLE: 'tools.image.jobs.update-title.rpc',
8
+ SOFT_DELETE: 'tools.image.jobs.soft-delete.rpc',
9
+ SOFT_DELETE_ALL: 'tools.image.jobs.soft-delete-all.rpc',
10
+ RETRY: 'tools.image.jobs.retry.rpc',
11
+ } as const;
@@ -0,0 +1,5 @@
1
+ export const IMAGE_EDITOR_CONTROLLER = 'image-editor';
2
+
3
+ export const IMAGE_EDITOR_ROUTES = {
4
+ KIE_NANO_BANANA_CALLBACK: 'kie/nano-banana/callback',
5
+ };
@@ -0,0 +1,2 @@
1
+ export * from './image-editor.amqp.routes';
2
+ export * from './image-editor.http.routes';
package/index.ts CHANGED
@@ -6,6 +6,7 @@ export * from './tts';
6
6
  export * from './language';
7
7
  export * from './video';
8
8
  export * from './writer';
9
+ export * from './image-editor';
9
10
 
10
11
  import * as common from './common';
11
12
  import * as paraphrase from './paraphrase';
@@ -16,6 +17,7 @@ import * as presentation from './presentation';
16
17
  import * as language from './language';
17
18
  import * as video from './video';
18
19
  import * as writer from './writer';
20
+ import * as imageEditor from './image-editor';
19
21
 
20
22
  export namespace ToolService {
21
23
  export import Common = common;
@@ -27,4 +29,5 @@ export namespace ToolService {
27
29
  export import Language = language;
28
30
  export import Video = video;
29
31
  export import Writer = writer;
32
+ export import ImageEditor = imageEditor;
30
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot-tools",
3
- "version": "0.0.36",
3
+ "version": "0.0.37-texteditor+01",
4
4
  "main": "build/index.js",
5
5
  "types": "build/index.d.ts",
6
6
  "scripts": {
@@ -6,7 +6,7 @@ export namespace CreateWriterDocumentCommand {
6
6
  export const RequestSchema = z.object({
7
7
  userId: z.string().uuid().nullable().optional(),
8
8
  unregisteredUserId: z.string().uuid().nullable().optional(),
9
- topic: z.string(),
9
+ prompt: z.string(),
10
10
  numPages: z.number(),
11
11
  documentTypeId: z.string().uuid(),
12
12
  });
@@ -7,6 +7,7 @@ export namespace GenerateWriterDocumentContentsCommand {
7
7
  documentId: z.string().uuid(),
8
8
  userId: z.string().uuid().nullable().optional(),
9
9
  unregisteredUserId: z.string().uuid().nullable().optional(),
10
+ userBalance: z.number(),
10
11
  });
11
12
  export type Request = z.infer<typeof RequestSchema>;
12
13
 
@@ -3,3 +3,9 @@ export * from './delete-writer-document.command';
3
3
  export * from './delete-all-user-writer-documents.command';
4
4
  export * from './update-writer-document-outline.command';
5
5
  export * from './generate-document-contents.command';
6
+ export * from './writer-paraphrase.command';
7
+ export * from './writer-extend-text.command';
8
+ export * from './writer-shorten-text.command';
9
+ export * from './writer-fix-errors.command';
10
+ export * from './writer-generate-text.command';
11
+ export * from './update-writer-document-contents.command';
@@ -0,0 +1,19 @@
1
+ import { z } from 'zod';
2
+ import { ICommandResponseSchema } from '../../common';
3
+
4
+ export namespace UpdateWriterDocumentContentsCommand {
5
+ export const RequestSchema = z.object({
6
+ userId: z.string().uuid().nullable().optional(),
7
+ unregisteredUserId: z.string().uuid().nullable().optional(),
8
+ documentId: z.string().uuid(),
9
+ contents: z.string(),
10
+ });
11
+ export type Request = z.infer<typeof RequestSchema>;
12
+
13
+ export const ResponseSchema = ICommandResponseSchema(
14
+ z.object({
15
+ success: z.boolean(),
16
+ }),
17
+ );
18
+ export type Response = z.infer<typeof ResponseSchema>;
19
+ }
@@ -0,0 +1,19 @@
1
+ import { z } from 'zod';
2
+ import { ICommandResponseSchema } from '../../common';
3
+
4
+ export namespace UpdateWriterDocumentContentsCommand {
5
+ export const RequestSchema = z.object({
6
+ userId: z.string().uuid().nullable().optional(),
7
+ unregisteredUserId: z.string().uuid().nullable().optional(),
8
+ documentId: z.string().uuid(),
9
+ contents: z.string(),
10
+ });
11
+ export type Request = z.infer<typeof RequestSchema>;
12
+
13
+ export const ResponseSchema = ICommandResponseSchema(
14
+ z.object({
15
+ success: z.boolean(),
16
+ }),
17
+ );
18
+ export type Response = z.infer<typeof ResponseSchema>;
19
+ }
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ import { ICommandResponseSchema } from '../../common';
3
+
4
+ export namespace WriterExtendTextCommand {
5
+ export const RequestSchema = z.object({
6
+ userId: z.string().uuid().nullable().optional(),
7
+ unregisteredUserId: z.string().uuid().nullable().optional(),
8
+ documentId: z.string().uuid(),
9
+ selectionText: z.string(),
10
+ userBalance: z.number(),
11
+ });
12
+ export type Request = z.infer<typeof RequestSchema>;
13
+
14
+ export const ResponseSchema = ICommandResponseSchema(
15
+ z.object({
16
+ output: z.string(),
17
+ }),
18
+ );
19
+ export type Response = z.infer<typeof ResponseSchema>;
20
+ }
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ import { ICommandResponseSchema } from '../../common';
3
+
4
+ export namespace WriterFixErrorsCommand {
5
+ export const RequestSchema = z.object({
6
+ userId: z.string().uuid().nullable().optional(),
7
+ unregisteredUserId: z.string().uuid().nullable().optional(),
8
+ documentId: z.string().uuid(),
9
+ selectionText: z.string(),
10
+ userBalance: z.number(),
11
+ });
12
+ export type Request = z.infer<typeof RequestSchema>;
13
+
14
+ export const ResponseSchema = ICommandResponseSchema(
15
+ z.object({
16
+ output: z.string(),
17
+ }),
18
+ );
19
+ export type Response = z.infer<typeof ResponseSchema>;
20
+ }
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod';
2
+ import { ICommandResponseSchema } from '../../common';
3
+
4
+ export namespace WriterGenerateTextCommand {
5
+ export const RequestSchema = z.object({
6
+ documentId: z.string().uuid(),
7
+ prompt: z.string().min(1).max(500),
8
+ selectionText: z.string(),
9
+ contextBefore: z.string().optional(),
10
+ contextAfter: z.string().optional(),
11
+ userId: z.string().uuid().nullable().optional(),
12
+ unregisteredUserId: z.string().uuid().nullable().optional(),
13
+ userBalance: z.number(),
14
+ });
15
+ export type Request = z.infer<typeof RequestSchema>;
16
+
17
+ export const ResponseSchema = ICommandResponseSchema(
18
+ z.object({
19
+ output: z.string(),
20
+ }),
21
+ );
22
+ export type Response = z.infer<typeof ResponseSchema>;
23
+ }
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ import { ICommandResponseSchema } from '../../common';
3
+
4
+ export namespace WriterParaphraseCommand {
5
+ export const RequestSchema = z.object({
6
+ userId: z.string().uuid().nullable().optional(),
7
+ unregisteredUserId: z.string().uuid().nullable().optional(),
8
+ documentId: z.string().uuid(),
9
+ selectionText: z.string(),
10
+ userBalance: z.number(),
11
+ });
12
+ export type Request = z.infer<typeof RequestSchema>;
13
+
14
+ export const ResponseSchema = ICommandResponseSchema(
15
+ z.object({
16
+ output: z.string(),
17
+ }),
18
+ );
19
+ export type Response = z.infer<typeof ResponseSchema>;
20
+ }
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ import { ICommandResponseSchema } from '../../common';
3
+
4
+ export namespace WriterShortenTextCommand {
5
+ export const RequestSchema = z.object({
6
+ userId: z.string().uuid().nullable().optional(),
7
+ unregisteredUserId: z.string().uuid().nullable().optional(),
8
+ documentId: z.string().uuid(),
9
+ selectionText: z.string(),
10
+ userBalance: z.number(),
11
+ });
12
+ export type Request = z.infer<typeof RequestSchema>;
13
+
14
+ export const ResponseSchema = ICommandResponseSchema(
15
+ z.object({
16
+ output: z.string(),
17
+ }),
18
+ );
19
+ export type Response = z.infer<typeof ResponseSchema>;
20
+ }
@@ -1,4 +1,5 @@
1
- export * from './writer-ai-operation-pricing-type.enum';
2
- export * from './writer-ai-operation-type.enum';
1
+ export * from './writer-ai-action-call.enum';
2
+ export * from './writer-ai-action-pricing-type.enum';
3
+ export * from './writer-ai-action-type.enum';
3
4
  export * from './writer-document-section-type.enum';
4
5
  export * from './writer-document-stage.enum';
@@ -0,0 +1,5 @@
1
+ export enum WRITER_AI_ACTION_CALL_STATUS {
2
+ PROCESSING = 'processing',
3
+ COMPLETED = 'completed',
4
+ FAILED = 'failed',
5
+ }
@@ -1,4 +1,4 @@
1
- export enum WRITER_AI_OPERATION_PRICING_TYPE {
1
+ export enum WRITER_AI_ACTION_PRICING_TYPE {
2
2
  PER_CHARACTER = 'PER_CHARACTER',
3
3
  FLAT = 'FLAT',
4
4
  }
@@ -1,5 +1,7 @@
1
- export enum WRITER_AI_OPERATION_TYPE {
1
+ export enum WRITER_AI_ACTION_TYPE {
2
2
  PARAPHRASE = 'PARAPHRASE',
3
3
  EXTEND_TEXT = 'EXTEND_TEXT',
4
+ SHORTEN_TEXT = 'SHORTEN_TEXT',
4
5
  GENERATE_TEXT = 'GENERATE_TEXT',
6
+ FIX_ERRORS = 'FIX_ERRORS',
5
7
  }
package/writer/index.ts CHANGED
@@ -3,3 +3,4 @@ export * from './models';
3
3
  export * from './queries';
4
4
  export * from './enums';
5
5
  export * from './routes';
6
+ export * from './utils';
@@ -1,5 +1,5 @@
1
1
  export * from './writer-config.schema';
2
- export * from './writer-ai-operation.schema';
2
+ export * from './writer-ai-action.schema';
3
3
  export * from './writer-document-outline.schema';
4
4
  export * from './writer-document.schema';
5
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 '../enums';
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>;
@@ -1,12 +1,12 @@
1
1
  import { z } from 'zod';
2
2
  import { WriterDocumentTypeSchema } from './writer-document-type.schema';
3
- import { WriterAiOperationSchema } from './writer-ai-operation.schema';
3
+ import { WriterAiActionSchema } from './writer-ai-action.schema';
4
4
 
5
5
  export const WriterConfigSchema = z.object({
6
6
  minPages: z.number(),
7
7
  maxPages: z.number(),
8
- maxTopicLength: z.number(),
8
+ maxPromptLength: z.number(),
9
9
  documentTypes: z.array(WriterDocumentTypeSchema),
10
- aiOperations: z.array(WriterAiOperationSchema),
10
+ aiActions: z.array(WriterAiActionSchema),
11
11
  });
12
- export type PresentationConfig = z.infer<typeof WriterConfigSchema>;
12
+ export type WriterConfig = z.infer<typeof WriterConfigSchema>;
@@ -6,5 +6,11 @@ export const WRITER_AMQP_ROUTES = {
6
6
  DELETE_DOCUMENT: 'tools.writer.delete-document.rpc',
7
7
  DELETE_ALL_USER_DOCUMENTS: 'tools.writer.delete-all-user-documents.rpc',
8
8
  UPDATE_DOCUMENT_OUTLINE: 'tools.writer.update-document-outline.rpc',
9
+ UPDATE_DOCUMENT_CONTENTS: 'tools.writer.update-document-contents.rpc',
9
10
  GENERATE_DOCUMENT_CONTENTS: 'tools.writer.generate-document-contents.rpc',
11
+ PARAPHRASE: 'tools.writer.actions.paraphrase.rpc',
12
+ EXTEND_TEXT: 'tools.writer.actions.extend-text.rpc',
13
+ SHORTEN_TEXT: 'tools.writer.actions.shorten-text.rpc',
14
+ FIX_ERRORS: 'tools.writer.actions.fix-errors.rpc',
15
+ GENERATE_TEXT: 'tools.writer.actions.generate-text.rpc',
10
16
  } as const;
@@ -0,0 +1,20 @@
1
+ import { WRITER_AI_ACTION_PRICING_TYPE } from '../enums';
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,2 @@
1
+ export * from './calculate-writer-ai-action-price.util';
2
+ export * from './calculate-writer-content-generation-price.util';
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WRITER_AI_OPERATION_PRICING_TYPE = void 0;
4
- var WRITER_AI_OPERATION_PRICING_TYPE;
5
- (function (WRITER_AI_OPERATION_PRICING_TYPE) {
6
- WRITER_AI_OPERATION_PRICING_TYPE["PER_CHARACTER"] = "PER_CHARACTER";
7
- WRITER_AI_OPERATION_PRICING_TYPE["FLAT"] = "FLAT";
8
- })(WRITER_AI_OPERATION_PRICING_TYPE || (exports.WRITER_AI_OPERATION_PRICING_TYPE = WRITER_AI_OPERATION_PRICING_TYPE = {}));
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WRITER_AI_OPERATION_TYPE = void 0;
4
- var WRITER_AI_OPERATION_TYPE;
5
- (function (WRITER_AI_OPERATION_TYPE) {
6
- WRITER_AI_OPERATION_TYPE["PARAPHRASE"] = "PARAPHRASE";
7
- WRITER_AI_OPERATION_TYPE["EXTEND_TEXT"] = "EXTEND_TEXT";
8
- WRITER_AI_OPERATION_TYPE["GENERATE_TEXT"] = "GENERATE_TEXT";
9
- })(WRITER_AI_OPERATION_TYPE || (exports.WRITER_AI_OPERATION_TYPE = WRITER_AI_OPERATION_TYPE = {}));
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WriterAiOperationSchema = exports.WriterAiOperationPricingRulesSchema = void 0;
4
- const zod_1 = require("zod");
5
- const enums_1 = require("../enums");
6
- exports.WriterAiOperationPricingRulesSchema = zod_1.z.discriminatedUnion('type', [
7
- zod_1.z.object({
8
- type: zod_1.z.literal(enums_1.WRITER_AI_OPERATION_PRICING_TYPE.PER_CHARACTER),
9
- price: zod_1.z.number(),
10
- }),
11
- zod_1.z.object({
12
- type: zod_1.z.literal(enums_1.WRITER_AI_OPERATION_PRICING_TYPE.FLAT),
13
- price: zod_1.z.number(),
14
- }),
15
- ]);
16
- exports.WriterAiOperationSchema = zod_1.z.object({
17
- uuid: zod_1.z.string(),
18
- type: zod_1.z.nativeEnum(enums_1.WRITER_AI_OPERATION_TYPE),
19
- pricingRules: exports.WriterAiOperationPricingRulesSchema,
20
- maxPromptLength: zod_1.z.number(),
21
- title: zod_1.z.string(),
22
- icon: zod_1.z.string(),
23
- order: zod_1.z.number(),
24
- createdAt: zod_1.z.date(),
25
- updatedAt: zod_1.z.date(),
26
- });
@@ -1,27 +0,0 @@
1
- import { z } from 'zod';
2
- import { WRITER_AI_OPERATION_PRICING_TYPE, WRITER_AI_OPERATION_TYPE } from '../enums';
3
-
4
- export const WriterAiOperationPricingRulesSchema = z.discriminatedUnion('type', [
5
- z.object({
6
- type: z.literal(WRITER_AI_OPERATION_PRICING_TYPE.PER_CHARACTER),
7
- price: z.number(),
8
- }),
9
- z.object({
10
- type: z.literal(WRITER_AI_OPERATION_PRICING_TYPE.FLAT),
11
- price: z.number(),
12
- }),
13
- ]);
14
-
15
- export const WriterAiOperationSchema = z.object({
16
- uuid: z.string(),
17
- type: z.nativeEnum(WRITER_AI_OPERATION_TYPE),
18
- pricingRules: WriterAiOperationPricingRulesSchema,
19
- maxPromptLength: z.number(),
20
- title: z.string(),
21
- icon: z.string(),
22
- order: z.number(),
23
- createdAt: z.date(),
24
- updatedAt: z.date(),
25
- });
26
-
27
- export type WriterAiOperation = z.infer<typeof WriterAiOperationSchema>;