@purpleschool/gptbot 0.20.4-stage-2 → 0.20.4

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.
@@ -28,6 +28,7 @@ export declare namespace CreateCanvasTemplateCommand {
28
28
  }, z.core.$strip>;
29
29
  }, z.core.$strip>;
30
30
  params: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
31
+ output: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
31
32
  }, z.core.$strip>>;
32
33
  edges: z.ZodArray<z.ZodObject<{
33
34
  sourceId: z.ZodString;
@@ -68,6 +69,7 @@ export declare namespace CreateCanvasTemplateCommand {
68
69
  }, z.core.$strip>;
69
70
  }, z.core.$strip>;
70
71
  params: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
72
+ output: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
71
73
  }, z.core.$strip>>;
72
74
  edges: z.ZodArray<z.ZodObject<{
73
75
  sourceId: z.ZodString;
@@ -34,6 +34,7 @@ export declare namespace FindCanvasTemplateByUuidQuery {
34
34
  }, z.core.$strip>;
35
35
  }, z.core.$strip>;
36
36
  params: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
37
+ output: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
37
38
  }, z.core.$strip>>;
38
39
  edges: z.ZodArray<z.ZodObject<{
39
40
  sourceId: z.ZodString;
@@ -40,6 +40,7 @@ export declare namespace FindCanvasTemplatesQuery {
40
40
  }, z.core.$strip>;
41
41
  }, z.core.$strip>;
42
42
  params: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
43
+ output: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
43
44
  }, z.core.$strip>>;
44
45
  edges: z.ZodArray<z.ZodObject<{
45
46
  sourceId: z.ZodString;
@@ -32,6 +32,7 @@ export declare namespace UpdateCanvasTemplateCommand {
32
32
  }, z.core.$strip>;
33
33
  }, z.core.$strip>;
34
34
  params: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
35
+ output: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
35
36
  }, z.core.$strip>>;
36
37
  edges: z.ZodArray<z.ZodObject<{
37
38
  sourceId: z.ZodString;
@@ -72,6 +73,7 @@ export declare namespace UpdateCanvasTemplateCommand {
72
73
  }, z.core.$strip>;
73
74
  }, z.core.$strip>;
74
75
  params: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
76
+ output: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
75
77
  }, z.core.$strip>>;
76
78
  edges: z.ZodArray<z.ZodObject<{
77
79
  sourceId: z.ZodString;
@@ -367,6 +367,10 @@ export declare const CanvasNodeOutputSchemaByType: {
367
367
  }, z.core.$strict>>>;
368
368
  }, z.core.$strict>;
369
369
  };
370
+ /** Определяет блоки, пользовательские данные которых хранятся в output. */
371
+ export declare const isCanvasStaticNodeType: (nodeType: string) => boolean;
372
+ /** Читает статические данные, включая старые шаблоны с текстом в params.prompt. */
373
+ export declare const resolveCanvasStaticNodeOutput: (nodeType: string, params: unknown, output: unknown) => CanvasNodeOutput | null;
370
374
  export declare const CanvasNodeErrorDetailsSchema: z.ZodObject<{
371
375
  nodeId: z.ZodOptional<z.ZodUUID>;
372
376
  errorKind: z.ZodOptional<z.ZodEnum<typeof CANVAS_NODE_ERROR_KIND>>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CanvasNodeSchema = exports.CanvasNodeBaseSchema = exports.validateCanvasNodeOutputByType = exports.validateCanvasNodeParamsByType = exports.CanvasNodeErrorSchema = exports.CanvasNodeErrorDetailsSchema = exports.CanvasNodeOutputSchemaByType = exports.CanvasNodeParamsSchemaByType = exports.AudioBlockOutputSchema = exports.VarBlockOutputSchema = exports.NoteOutputSchema = exports.FileBlockOutputSchema = exports.VideoBlockOutputSchema = exports.ImageBlockOutputSchema = exports.TextBlockOutputSchema = exports.HtmlGenOutputSchema = exports.VarGenOutputSchema = exports.MotionControlOutputSchema = exports.ColorPaletteOutputSchema = exports.AudioGenSTTOutputSchema = exports.AudioGenTTSOutputSchema = exports.VideoGenOutputSchema = exports.ImageGenOutputSchema = exports.TextGenOutputSchema = exports.NoParamsSchema = exports.HtmlGenParamsSchema = exports.VarGenParamsSchema = exports.MotionControlParamsSchema = exports.ColorPaletteParamsSchema = exports.AudioGenParamsSchema = exports.VideoGenParamsSchema = exports.ImageGenParamsSchema = exports.TextGenParamsSchema = exports.CanvasNodePositionSchema = exports.CanvasFileRefSchema = void 0;
3
+ exports.CanvasNodeSchema = exports.CanvasNodeBaseSchema = exports.validateCanvasNodeOutputByType = exports.validateCanvasNodeParamsByType = exports.CanvasNodeErrorSchema = exports.CanvasNodeErrorDetailsSchema = exports.resolveCanvasStaticNodeOutput = exports.isCanvasStaticNodeType = exports.CanvasNodeOutputSchemaByType = exports.CanvasNodeParamsSchemaByType = exports.AudioBlockOutputSchema = exports.VarBlockOutputSchema = exports.NoteOutputSchema = exports.FileBlockOutputSchema = exports.VideoBlockOutputSchema = exports.ImageBlockOutputSchema = exports.TextBlockOutputSchema = exports.HtmlGenOutputSchema = exports.VarGenOutputSchema = exports.MotionControlOutputSchema = exports.ColorPaletteOutputSchema = exports.AudioGenSTTOutputSchema = exports.AudioGenTTSOutputSchema = exports.VideoGenOutputSchema = exports.ImageGenOutputSchema = exports.TextGenOutputSchema = exports.NoParamsSchema = exports.HtmlGenParamsSchema = exports.VarGenParamsSchema = exports.MotionControlParamsSchema = exports.ColorPaletteParamsSchema = exports.AudioGenParamsSchema = exports.VideoGenParamsSchema = exports.ImageGenParamsSchema = exports.TextGenParamsSchema = exports.CanvasNodePositionSchema = exports.CanvasFileRefSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const constants_1 = require("../constants");
6
6
  const strictObject = (shape) => zod_1.z.strictObject(shape);
@@ -173,6 +173,39 @@ exports.CanvasNodeOutputSchemaByType = {
173
173
  [constants_1.CANVAS_NODE_TYPE.htmlGen]: exports.HtmlGenOutputSchema,
174
174
  [constants_1.CANVAS_NODE_TYPE.audioBlock]: exports.AudioBlockOutputSchema,
175
175
  };
176
+ /** Определяет блоки, пользовательские данные которых хранятся в output. */
177
+ const isCanvasStaticNodeType = (nodeType) => nodeType in exports.CanvasNodeParamsSchemaByType &&
178
+ exports.CanvasNodeParamsSchemaByType[nodeType] === exports.NoParamsSchema;
179
+ exports.isCanvasStaticNodeType = isCanvasStaticNodeType;
180
+ /** Читает статические данные, включая старые шаблоны с текстом в params.prompt. */
181
+ const resolveCanvasStaticNodeOutput = (nodeType, params, output) => {
182
+ var _a, _b, _c, _d;
183
+ if (!(0, exports.isCanvasStaticNodeType)(nodeType)) {
184
+ return null;
185
+ }
186
+ const schema = exports.CanvasNodeOutputSchemaByType[nodeType];
187
+ if (output !== null && output !== undefined) {
188
+ const parsed = schema.safeParse(output);
189
+ return parsed.success ? parsed.data : null;
190
+ }
191
+ if (!params || typeof params !== 'object' || Array.isArray(params)) {
192
+ return null;
193
+ }
194
+ const legacy = params;
195
+ let candidate = params;
196
+ if (nodeType === constants_1.CANVAS_NODE_TYPE.textBlock) {
197
+ candidate = { text: (_a = legacy.text) !== null && _a !== void 0 ? _a : legacy.prompt };
198
+ }
199
+ else if (nodeType === constants_1.CANVAS_NODE_TYPE.note) {
200
+ candidate = { content: (_b = legacy.content) !== null && _b !== void 0 ? _b : legacy.prompt };
201
+ }
202
+ else if (nodeType === constants_1.CANVAS_NODE_TYPE.varBlock) {
203
+ candidate = { name: (_c = legacy.name) !== null && _c !== void 0 ? _c : '', value: (_d = legacy.value) !== null && _d !== void 0 ? _d : legacy.prompt };
204
+ }
205
+ const parsed = schema.safeParse(candidate);
206
+ return parsed.success ? parsed.data : null;
207
+ };
208
+ exports.resolveCanvasStaticNodeOutput = resolveCanvasStaticNodeOutput;
176
209
  exports.CanvasNodeErrorDetailsSchema = zod_1.z
177
210
  .object({
178
211
  nodeId: zod_1.z.uuid().optional(),
@@ -15,6 +15,7 @@ export declare const CanvasTemplateGraphSchema: z.ZodObject<{
15
15
  }, z.core.$strip>;
16
16
  }, z.core.$strip>;
17
17
  params: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
18
+ output: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
18
19
  }, z.core.$strip>>;
19
20
  edges: z.ZodArray<z.ZodObject<{
20
21
  sourceId: z.ZodString;
@@ -62,6 +63,7 @@ export declare const CanvasTemplateSchema: z.ZodObject<{
62
63
  }, z.core.$strip>;
63
64
  }, z.core.$strip>;
64
65
  params: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
66
+ output: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
65
67
  }, z.core.$strip>>;
66
68
  edges: z.ZodArray<z.ZodObject<{
67
69
  sourceId: z.ZodString;
@@ -100,6 +102,7 @@ export declare const GeneratedCanvasTemplateSchema: z.ZodObject<{
100
102
  }, z.core.$strip>;
101
103
  }, z.core.$strip>;
102
104
  params: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
105
+ output: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
103
106
  }, z.core.$strip>>;
104
107
  edges: z.ZodArray<z.ZodObject<{
105
108
  sourceId: z.ZodString;
@@ -10,9 +10,14 @@ const CanvasTemplateGraphNodeSchema = zod_1.z
10
10
  nodeDefinitionId: zod_1.z.enum(constants_1.CANVAS_NODE_TYPE),
11
11
  position: canvas_node_schema_1.CanvasNodePositionSchema,
12
12
  params: zod_1.z.unknown().nullable().optional(),
13
+ output: zod_1.z.unknown().nullable().optional(),
13
14
  })
14
15
  .superRefine((node, ctx) => {
15
- (0, canvas_node_schema_1.validateCanvasNodeParamsByType)(node.nodeDefinitionId, node.params, ctx);
16
+ const staticOutput = (0, canvas_node_schema_1.resolveCanvasStaticNodeOutput)(node.nodeDefinitionId, node.params, node.output);
17
+ (0, canvas_node_schema_1.validateCanvasNodeParamsByType)(node.nodeDefinitionId, staticOutput ? null : node.params, ctx);
18
+ if ((0, canvas_node_schema_1.isCanvasStaticNodeType)(node.nodeDefinitionId)) {
19
+ (0, canvas_node_schema_1.validateCanvasNodeOutputByType)(node.nodeDefinitionId, staticOutput !== null && staticOutput !== void 0 ? staticOutput : node.output, ctx);
20
+ }
16
21
  });
17
22
  const CanvasTemplateGraphEdgeSchema = zod_1.z.object({
18
23
  sourceId: zod_1.z.string().trim().min(1),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.20.4-stage-2",
3
+ "version": "0.20.4",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",