@drawcall/design 0.3.0 → 0.4.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.
- package/dist/index.d.ts +1 -1
- package/dist/protocol.d.ts +1 -0
- package/dist/protocol.js +1 -0
- package/dist/v1/capabilities.d.ts +2 -2
- package/dist/v1/capabilities.js +7 -0
- package/dist/v1/contract.d.ts +145 -0
- package/dist/v1/contract.js +12 -1
- package/dist/v1/schemas.d.ts +89 -0
- package/dist/v1/schemas.js +99 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export { designSkill } from "./skill.generated.js";
|
|
|
3
3
|
export { frameCreationCapabilities, type FrameCreationCapability, type FrameCreationCapabilityId, type FrameCreationInput, } from "./v1/capabilities.js";
|
|
4
4
|
export { parseFrameSize } from "./target.js";
|
|
5
5
|
export { acknowledgesInspection, inspectionCommandSchema, inspectionFrameMessageSchema, inspectionMessageTypes, projectSyncMaps, projectSyncUrl, type InspectionAppliedMessage, type InspectionCommand, type InspectionFrameMessage, } from "./protocol.js";
|
|
6
|
-
export type { BinaryFile, CreateFrame, CreateProjectFromBrief, CreateGltsFrame, CreateImageFrame, CreateMarketFrame, DesignFile, FileList, FileMutation, Frame, GltsFrame, ImageFrame, MarketFrame, Project, ProjectDerivationStatus, Screenshot, TextFile, User, } from "./v1/schemas.js";
|
|
6
|
+
export type { BinaryFile, CreateFrame, CreateProjectFromBrief, CreateGltsFrame, CreateImageFrame, CreateMarketFrame, GenerateImageFrame, DesignFile, FileList, FileMutation, Frame, GltsFrame, ImageFrame, ImageGenerationOperation, ImageGenerationProvenance, ImageGenerationResult, MarketFrame, Project, ProjectDerivationStatus, Screenshot, TextFile, User, } from "./v1/schemas.js";
|
package/dist/protocol.d.ts
CHANGED
package/dist/protocol.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type FrameCreationCapabilityId = "add-image" | "create-glts" | "search-assets";
|
|
2
|
-
export type FrameCreationInput = "asset" | "height" | "image" | "name" | "width";
|
|
1
|
+
export type FrameCreationCapabilityId = "add-image" | "create-glts" | "generate-image" | "search-assets";
|
|
2
|
+
export type FrameCreationInput = "asset" | "height" | "image" | "name" | "prompt" | "references" | "width";
|
|
3
3
|
export interface FrameCreationCapability {
|
|
4
4
|
id: FrameCreationCapabilityId;
|
|
5
5
|
frameType: "glts" | "image" | "market";
|
package/dist/v1/capabilities.js
CHANGED
|
@@ -13,6 +13,13 @@ export const frameCreationCapabilities = [
|
|
|
13
13
|
description: "Create an empty programmable 3D frame",
|
|
14
14
|
inputs: ["name", "width", "height"],
|
|
15
15
|
},
|
|
16
|
+
{
|
|
17
|
+
id: "generate-image",
|
|
18
|
+
frameType: "image",
|
|
19
|
+
label: "Generate image",
|
|
20
|
+
description: "Create or edit an image with optional frame references",
|
|
21
|
+
inputs: ["name", "prompt", "references"],
|
|
22
|
+
},
|
|
16
23
|
{
|
|
17
24
|
id: "search-assets",
|
|
18
25
|
frameType: "market",
|
package/dist/v1/contract.d.ts
CHANGED
|
@@ -76,6 +76,24 @@ export declare const contract: {
|
|
|
76
76
|
createdAt: z.ZodString;
|
|
77
77
|
updatedAt: z.ZodString;
|
|
78
78
|
}, z.core.$strip>, Record<never, never>, Record<never, never>>;
|
|
79
|
+
rename: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
80
|
+
project: z.ZodString;
|
|
81
|
+
name: z.ZodString;
|
|
82
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
83
|
+
id: z.ZodString;
|
|
84
|
+
name: z.ZodString;
|
|
85
|
+
sourceBrief: z.ZodNullable<z.ZodString>;
|
|
86
|
+
title: z.ZodNullable<z.ZodString>;
|
|
87
|
+
summary: z.ZodNullable<z.ZodString>;
|
|
88
|
+
derivationStatus: z.ZodEnum<{
|
|
89
|
+
not_requested: "not_requested";
|
|
90
|
+
pending: "pending";
|
|
91
|
+
failed: "failed";
|
|
92
|
+
complete: "complete";
|
|
93
|
+
}>;
|
|
94
|
+
createdAt: z.ZodString;
|
|
95
|
+
updatedAt: z.ZodString;
|
|
96
|
+
}, z.core.$strip>, Record<never, never>, Record<never, never>>;
|
|
79
97
|
delete: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
80
98
|
project: z.ZodString;
|
|
81
99
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -110,6 +128,24 @@ export declare const contract: {
|
|
|
110
128
|
updatedAt: z.ZodString;
|
|
111
129
|
type: z.ZodLiteral<"image">;
|
|
112
130
|
file: z.ZodString;
|
|
131
|
+
provenance: z.ZodOptional<z.ZodObject<{
|
|
132
|
+
kind: z.ZodLiteral<"generated">;
|
|
133
|
+
operation: z.ZodEnum<{
|
|
134
|
+
generate: "generate";
|
|
135
|
+
edit: "edit";
|
|
136
|
+
}>;
|
|
137
|
+
prompt: z.ZodString;
|
|
138
|
+
references: z.ZodArray<z.ZodObject<{
|
|
139
|
+
frameId: z.ZodString;
|
|
140
|
+
frameUpdatedAt: z.ZodString;
|
|
141
|
+
}, z.core.$strip>>;
|
|
142
|
+
provider: z.ZodLiteral<"cloudflare-workers-ai">;
|
|
143
|
+
model: z.ZodLiteral<"@cf/black-forest-labs/flux-2-klein-4b">;
|
|
144
|
+
result: z.ZodEnum<{
|
|
145
|
+
replace: "replace";
|
|
146
|
+
new: "new";
|
|
147
|
+
}>;
|
|
148
|
+
}, z.core.$strip>>;
|
|
113
149
|
}, z.core.$strip>, z.ZodObject<{
|
|
114
150
|
id: z.ZodString;
|
|
115
151
|
projectId: z.ZodString;
|
|
@@ -171,6 +207,97 @@ export declare const contract: {
|
|
|
171
207
|
updatedAt: z.ZodString;
|
|
172
208
|
type: z.ZodLiteral<"image">;
|
|
173
209
|
file: z.ZodString;
|
|
210
|
+
provenance: z.ZodOptional<z.ZodObject<{
|
|
211
|
+
kind: z.ZodLiteral<"generated">;
|
|
212
|
+
operation: z.ZodEnum<{
|
|
213
|
+
generate: "generate";
|
|
214
|
+
edit: "edit";
|
|
215
|
+
}>;
|
|
216
|
+
prompt: z.ZodString;
|
|
217
|
+
references: z.ZodArray<z.ZodObject<{
|
|
218
|
+
frameId: z.ZodString;
|
|
219
|
+
frameUpdatedAt: z.ZodString;
|
|
220
|
+
}, z.core.$strip>>;
|
|
221
|
+
provider: z.ZodLiteral<"cloudflare-workers-ai">;
|
|
222
|
+
model: z.ZodLiteral<"@cf/black-forest-labs/flux-2-klein-4b">;
|
|
223
|
+
result: z.ZodEnum<{
|
|
224
|
+
replace: "replace";
|
|
225
|
+
new: "new";
|
|
226
|
+
}>;
|
|
227
|
+
}, z.core.$strip>>;
|
|
228
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
229
|
+
id: z.ZodString;
|
|
230
|
+
projectId: z.ZodString;
|
|
231
|
+
name: z.ZodString;
|
|
232
|
+
x: z.ZodNumber;
|
|
233
|
+
y: z.ZodNumber;
|
|
234
|
+
width: z.ZodNumber;
|
|
235
|
+
height: z.ZodNumber;
|
|
236
|
+
viewUrl: z.ZodString;
|
|
237
|
+
createdAt: z.ZodString;
|
|
238
|
+
updatedAt: z.ZodString;
|
|
239
|
+
type: z.ZodLiteral<"market">;
|
|
240
|
+
asset: z.ZodString;
|
|
241
|
+
}, z.core.$strip>], "type">, Record<never, never>, Record<never, never>>;
|
|
242
|
+
generateImage: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
243
|
+
project: z.ZodString;
|
|
244
|
+
operation: z.ZodEnum<{
|
|
245
|
+
generate: "generate";
|
|
246
|
+
edit: "edit";
|
|
247
|
+
}>;
|
|
248
|
+
prompt: z.ZodString;
|
|
249
|
+
target: z.ZodOptional<z.ZodString>;
|
|
250
|
+
references: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
251
|
+
result: z.ZodEnum<{
|
|
252
|
+
replace: "replace";
|
|
253
|
+
new: "new";
|
|
254
|
+
}>;
|
|
255
|
+
name: z.ZodOptional<z.ZodString>;
|
|
256
|
+
x: z.ZodOptional<z.ZodNumber>;
|
|
257
|
+
y: z.ZodOptional<z.ZodNumber>;
|
|
258
|
+
}, z.core.$strict>, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
259
|
+
id: z.ZodString;
|
|
260
|
+
projectId: z.ZodString;
|
|
261
|
+
name: z.ZodString;
|
|
262
|
+
x: z.ZodNumber;
|
|
263
|
+
y: z.ZodNumber;
|
|
264
|
+
width: z.ZodNumber;
|
|
265
|
+
height: z.ZodNumber;
|
|
266
|
+
viewUrl: z.ZodString;
|
|
267
|
+
createdAt: z.ZodString;
|
|
268
|
+
updatedAt: z.ZodString;
|
|
269
|
+
type: z.ZodLiteral<"glts">;
|
|
270
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
271
|
+
id: z.ZodString;
|
|
272
|
+
projectId: z.ZodString;
|
|
273
|
+
name: z.ZodString;
|
|
274
|
+
x: z.ZodNumber;
|
|
275
|
+
y: z.ZodNumber;
|
|
276
|
+
width: z.ZodNumber;
|
|
277
|
+
height: z.ZodNumber;
|
|
278
|
+
viewUrl: z.ZodString;
|
|
279
|
+
createdAt: z.ZodString;
|
|
280
|
+
updatedAt: z.ZodString;
|
|
281
|
+
type: z.ZodLiteral<"image">;
|
|
282
|
+
file: z.ZodString;
|
|
283
|
+
provenance: z.ZodOptional<z.ZodObject<{
|
|
284
|
+
kind: z.ZodLiteral<"generated">;
|
|
285
|
+
operation: z.ZodEnum<{
|
|
286
|
+
generate: "generate";
|
|
287
|
+
edit: "edit";
|
|
288
|
+
}>;
|
|
289
|
+
prompt: z.ZodString;
|
|
290
|
+
references: z.ZodArray<z.ZodObject<{
|
|
291
|
+
frameId: z.ZodString;
|
|
292
|
+
frameUpdatedAt: z.ZodString;
|
|
293
|
+
}, z.core.$strip>>;
|
|
294
|
+
provider: z.ZodLiteral<"cloudflare-workers-ai">;
|
|
295
|
+
model: z.ZodLiteral<"@cf/black-forest-labs/flux-2-klein-4b">;
|
|
296
|
+
result: z.ZodEnum<{
|
|
297
|
+
replace: "replace";
|
|
298
|
+
new: "new";
|
|
299
|
+
}>;
|
|
300
|
+
}, z.core.$strip>>;
|
|
174
301
|
}, z.core.$strip>, z.ZodObject<{
|
|
175
302
|
id: z.ZodString;
|
|
176
303
|
projectId: z.ZodString;
|
|
@@ -214,6 +341,24 @@ export declare const contract: {
|
|
|
214
341
|
updatedAt: z.ZodString;
|
|
215
342
|
type: z.ZodLiteral<"image">;
|
|
216
343
|
file: z.ZodString;
|
|
344
|
+
provenance: z.ZodOptional<z.ZodObject<{
|
|
345
|
+
kind: z.ZodLiteral<"generated">;
|
|
346
|
+
operation: z.ZodEnum<{
|
|
347
|
+
generate: "generate";
|
|
348
|
+
edit: "edit";
|
|
349
|
+
}>;
|
|
350
|
+
prompt: z.ZodString;
|
|
351
|
+
references: z.ZodArray<z.ZodObject<{
|
|
352
|
+
frameId: z.ZodString;
|
|
353
|
+
frameUpdatedAt: z.ZodString;
|
|
354
|
+
}, z.core.$strip>>;
|
|
355
|
+
provider: z.ZodLiteral<"cloudflare-workers-ai">;
|
|
356
|
+
model: z.ZodLiteral<"@cf/black-forest-labs/flux-2-klein-4b">;
|
|
357
|
+
result: z.ZodEnum<{
|
|
358
|
+
replace: "replace";
|
|
359
|
+
new: "new";
|
|
360
|
+
}>;
|
|
361
|
+
}, z.core.$strip>>;
|
|
217
362
|
}, z.core.$strip>, z.ZodObject<{
|
|
218
363
|
id: z.ZodString;
|
|
219
364
|
projectId: z.ZodString;
|
package/dist/v1/contract.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { oc } from "@orpc/contract";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { createFrameSchema, createProjectFromBriefSchema, designIdSchema, fileListSchema, fileMutationSchema, fileSchema, fileTextSchema, frameNameSchema, frameSchema, projectDirectoryPathSchema, projectNameSchema, projectPathSchema, projectSchema, screenshotSchema, userSchema, } from "./schemas.js";
|
|
3
|
+
import { createFrameSchema, createProjectFromBriefSchema, designIdSchema, fileListSchema, fileMutationSchema, fileSchema, fileTextSchema, frameNameSchema, frameSchema, generateImageFrameSchema, projectDirectoryPathSchema, projectNameSchema, projectPathSchema, projectSchema, screenshotSchema, userSchema, } from "./schemas.js";
|
|
4
4
|
const projectInputSchema = z.object({ project: designIdSchema });
|
|
5
5
|
const frameInputSchema = projectInputSchema.extend({ frame: designIdSchema });
|
|
6
6
|
const fileInputSchema = projectInputSchema.extend({ path: projectPathSchema });
|
|
@@ -28,6 +28,10 @@ export const contract = {
|
|
|
28
28
|
})
|
|
29
29
|
.input(projectInputSchema)
|
|
30
30
|
.output(projectSchema),
|
|
31
|
+
rename: oc
|
|
32
|
+
.route({ method: "PATCH", path: "/projects/{project}" })
|
|
33
|
+
.input(projectInputSchema.extend({ name: projectNameSchema }))
|
|
34
|
+
.output(projectSchema),
|
|
31
35
|
delete: oc
|
|
32
36
|
.route({ method: "DELETE", path: "/projects/{project}" })
|
|
33
37
|
.input(projectInputSchema)
|
|
@@ -42,6 +46,13 @@ export const contract = {
|
|
|
42
46
|
.route({ method: "POST", path: "/projects/{project}/frames" })
|
|
43
47
|
.input(createFrameSchema)
|
|
44
48
|
.output(frameSchema),
|
|
49
|
+
generateImage: oc
|
|
50
|
+
.route({
|
|
51
|
+
method: "POST",
|
|
52
|
+
path: "/projects/{project}/images/generations",
|
|
53
|
+
})
|
|
54
|
+
.input(generateImageFrameSchema)
|
|
55
|
+
.output(frameSchema),
|
|
45
56
|
rename: oc
|
|
46
57
|
.route({ method: "PATCH", path: "/projects/{project}/frames/{frame}" })
|
|
47
58
|
.input(frameInputSchema.extend({ name: frameNameSchema }))
|
package/dist/v1/schemas.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const MAX_FRAME_DIMENSION = 4096;
|
|
3
3
|
export declare const MAX_FILE_LENGTH = 512000;
|
|
4
|
+
export declare const MAX_IMAGE_GENERATION_PROMPT_LENGTH = 2048;
|
|
5
|
+
export declare const MAX_IMAGE_GENERATION_REFERENCES = 4;
|
|
4
6
|
export declare const designIdSchema: z.ZodString;
|
|
5
7
|
export declare const projectNameSchema: z.ZodString;
|
|
6
8
|
export declare const projectBriefSchema: z.ZodString;
|
|
@@ -62,6 +64,36 @@ export declare const gltsFrameSchema: z.ZodObject<{
|
|
|
62
64
|
updatedAt: z.ZodString;
|
|
63
65
|
type: z.ZodLiteral<"glts">;
|
|
64
66
|
}, z.core.$strip>;
|
|
67
|
+
export declare const imageGenerationOperationSchema: z.ZodEnum<{
|
|
68
|
+
generate: "generate";
|
|
69
|
+
edit: "edit";
|
|
70
|
+
}>;
|
|
71
|
+
export declare const imageGenerationResultSchema: z.ZodEnum<{
|
|
72
|
+
replace: "replace";
|
|
73
|
+
new: "new";
|
|
74
|
+
}>;
|
|
75
|
+
export declare const imageGenerationReferenceSchema: z.ZodObject<{
|
|
76
|
+
frameId: z.ZodString;
|
|
77
|
+
frameUpdatedAt: z.ZodString;
|
|
78
|
+
}, z.core.$strip>;
|
|
79
|
+
export declare const imageGenerationProvenanceSchema: z.ZodObject<{
|
|
80
|
+
kind: z.ZodLiteral<"generated">;
|
|
81
|
+
operation: z.ZodEnum<{
|
|
82
|
+
generate: "generate";
|
|
83
|
+
edit: "edit";
|
|
84
|
+
}>;
|
|
85
|
+
prompt: z.ZodString;
|
|
86
|
+
references: z.ZodArray<z.ZodObject<{
|
|
87
|
+
frameId: z.ZodString;
|
|
88
|
+
frameUpdatedAt: z.ZodString;
|
|
89
|
+
}, z.core.$strip>>;
|
|
90
|
+
provider: z.ZodLiteral<"cloudflare-workers-ai">;
|
|
91
|
+
model: z.ZodLiteral<"@cf/black-forest-labs/flux-2-klein-4b">;
|
|
92
|
+
result: z.ZodEnum<{
|
|
93
|
+
replace: "replace";
|
|
94
|
+
new: "new";
|
|
95
|
+
}>;
|
|
96
|
+
}, z.core.$strip>;
|
|
65
97
|
export declare const imageFrameSchema: z.ZodObject<{
|
|
66
98
|
id: z.ZodString;
|
|
67
99
|
projectId: z.ZodString;
|
|
@@ -75,6 +107,24 @@ export declare const imageFrameSchema: z.ZodObject<{
|
|
|
75
107
|
updatedAt: z.ZodString;
|
|
76
108
|
type: z.ZodLiteral<"image">;
|
|
77
109
|
file: z.ZodString;
|
|
110
|
+
provenance: z.ZodOptional<z.ZodObject<{
|
|
111
|
+
kind: z.ZodLiteral<"generated">;
|
|
112
|
+
operation: z.ZodEnum<{
|
|
113
|
+
generate: "generate";
|
|
114
|
+
edit: "edit";
|
|
115
|
+
}>;
|
|
116
|
+
prompt: z.ZodString;
|
|
117
|
+
references: z.ZodArray<z.ZodObject<{
|
|
118
|
+
frameId: z.ZodString;
|
|
119
|
+
frameUpdatedAt: z.ZodString;
|
|
120
|
+
}, z.core.$strip>>;
|
|
121
|
+
provider: z.ZodLiteral<"cloudflare-workers-ai">;
|
|
122
|
+
model: z.ZodLiteral<"@cf/black-forest-labs/flux-2-klein-4b">;
|
|
123
|
+
result: z.ZodEnum<{
|
|
124
|
+
replace: "replace";
|
|
125
|
+
new: "new";
|
|
126
|
+
}>;
|
|
127
|
+
}, z.core.$strip>>;
|
|
78
128
|
}, z.core.$strip>;
|
|
79
129
|
export declare const marketFrameSchema: z.ZodObject<{
|
|
80
130
|
id: z.ZodString;
|
|
@@ -115,6 +165,24 @@ export declare const frameSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
115
165
|
updatedAt: z.ZodString;
|
|
116
166
|
type: z.ZodLiteral<"image">;
|
|
117
167
|
file: z.ZodString;
|
|
168
|
+
provenance: z.ZodOptional<z.ZodObject<{
|
|
169
|
+
kind: z.ZodLiteral<"generated">;
|
|
170
|
+
operation: z.ZodEnum<{
|
|
171
|
+
generate: "generate";
|
|
172
|
+
edit: "edit";
|
|
173
|
+
}>;
|
|
174
|
+
prompt: z.ZodString;
|
|
175
|
+
references: z.ZodArray<z.ZodObject<{
|
|
176
|
+
frameId: z.ZodString;
|
|
177
|
+
frameUpdatedAt: z.ZodString;
|
|
178
|
+
}, z.core.$strip>>;
|
|
179
|
+
provider: z.ZodLiteral<"cloudflare-workers-ai">;
|
|
180
|
+
model: z.ZodLiteral<"@cf/black-forest-labs/flux-2-klein-4b">;
|
|
181
|
+
result: z.ZodEnum<{
|
|
182
|
+
replace: "replace";
|
|
183
|
+
new: "new";
|
|
184
|
+
}>;
|
|
185
|
+
}, z.core.$strip>>;
|
|
118
186
|
}, z.core.$strip>, z.ZodObject<{
|
|
119
187
|
id: z.ZodString;
|
|
120
188
|
projectId: z.ZodString;
|
|
@@ -177,6 +245,23 @@ export declare const createFrameSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
177
245
|
type: z.ZodLiteral<"market">;
|
|
178
246
|
asset: z.ZodString;
|
|
179
247
|
}, z.core.$strict>], "type">;
|
|
248
|
+
export declare const generateImageFrameSchema: z.ZodObject<{
|
|
249
|
+
project: z.ZodString;
|
|
250
|
+
operation: z.ZodEnum<{
|
|
251
|
+
generate: "generate";
|
|
252
|
+
edit: "edit";
|
|
253
|
+
}>;
|
|
254
|
+
prompt: z.ZodString;
|
|
255
|
+
target: z.ZodOptional<z.ZodString>;
|
|
256
|
+
references: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
257
|
+
result: z.ZodEnum<{
|
|
258
|
+
replace: "replace";
|
|
259
|
+
new: "new";
|
|
260
|
+
}>;
|
|
261
|
+
name: z.ZodOptional<z.ZodString>;
|
|
262
|
+
x: z.ZodOptional<z.ZodNumber>;
|
|
263
|
+
y: z.ZodOptional<z.ZodNumber>;
|
|
264
|
+
}, z.core.$strict>;
|
|
180
265
|
export declare const fileListSchema: z.ZodObject<{
|
|
181
266
|
paths: z.ZodArray<z.ZodString>;
|
|
182
267
|
}, z.core.$strip>;
|
|
@@ -218,12 +303,16 @@ export type CreateProjectFromBrief = z.infer<typeof createProjectFromBriefSchema
|
|
|
218
303
|
export type ProjectDerivationStatus = z.infer<typeof projectDerivationStatusSchema>;
|
|
219
304
|
export type GltsFrame = z.infer<typeof gltsFrameSchema>;
|
|
220
305
|
export type ImageFrame = z.infer<typeof imageFrameSchema>;
|
|
306
|
+
export type ImageGenerationOperation = z.infer<typeof imageGenerationOperationSchema>;
|
|
307
|
+
export type ImageGenerationResult = z.infer<typeof imageGenerationResultSchema>;
|
|
308
|
+
export type ImageGenerationProvenance = z.infer<typeof imageGenerationProvenanceSchema>;
|
|
221
309
|
export type MarketFrame = z.infer<typeof marketFrameSchema>;
|
|
222
310
|
export type Frame = z.infer<typeof frameSchema>;
|
|
223
311
|
export type CreateGltsFrame = z.infer<typeof createGltsFrameSchema>;
|
|
224
312
|
export type CreateImageFrame = z.infer<typeof createImageFrameSchema>;
|
|
225
313
|
export type CreateMarketFrame = z.infer<typeof createMarketFrameSchema>;
|
|
226
314
|
export type CreateFrame = z.infer<typeof createFrameSchema>;
|
|
315
|
+
export type GenerateImageFrame = z.infer<typeof generateImageFrameSchema>;
|
|
227
316
|
export type FileList = z.infer<typeof fileListSchema>;
|
|
228
317
|
export type TextFile = z.infer<typeof textFileSchema>;
|
|
229
318
|
export type BinaryFile = z.infer<typeof binaryFileSchema>;
|
package/dist/v1/schemas.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export const MAX_FRAME_DIMENSION = 4_096;
|
|
3
3
|
export const MAX_FILE_LENGTH = 512_000;
|
|
4
|
+
export const MAX_IMAGE_GENERATION_PROMPT_LENGTH = 2_048;
|
|
5
|
+
export const MAX_IMAGE_GENERATION_REFERENCES = 4;
|
|
4
6
|
export const designIdSchema = z
|
|
5
7
|
.string()
|
|
6
8
|
.regex(/^[a-z0-9]{14}$/, "IDs are 14 lowercase alphanumeric characters");
|
|
@@ -91,9 +93,27 @@ const frameBaseSchema = z.object({
|
|
|
91
93
|
export const gltsFrameSchema = frameBaseSchema.extend({
|
|
92
94
|
type: z.literal("glts"),
|
|
93
95
|
});
|
|
96
|
+
export const imageGenerationOperationSchema = z.enum(["generate", "edit"]);
|
|
97
|
+
export const imageGenerationResultSchema = z.enum(["new", "replace"]);
|
|
98
|
+
export const imageGenerationReferenceSchema = z.object({
|
|
99
|
+
frameId: designIdSchema,
|
|
100
|
+
frameUpdatedAt: z.string().datetime(),
|
|
101
|
+
});
|
|
102
|
+
export const imageGenerationProvenanceSchema = z.object({
|
|
103
|
+
kind: z.literal("generated"),
|
|
104
|
+
operation: imageGenerationOperationSchema,
|
|
105
|
+
prompt: z.string().min(1).max(MAX_IMAGE_GENERATION_PROMPT_LENGTH),
|
|
106
|
+
references: z
|
|
107
|
+
.array(imageGenerationReferenceSchema)
|
|
108
|
+
.max(MAX_IMAGE_GENERATION_REFERENCES),
|
|
109
|
+
provider: z.literal("cloudflare-workers-ai"),
|
|
110
|
+
model: z.literal("@cf/black-forest-labs/flux-2-klein-4b"),
|
|
111
|
+
result: imageGenerationResultSchema,
|
|
112
|
+
});
|
|
94
113
|
export const imageFrameSchema = frameBaseSchema.extend({
|
|
95
114
|
type: z.literal("image"),
|
|
96
115
|
file: projectPathSchema,
|
|
116
|
+
provenance: imageGenerationProvenanceSchema.optional(),
|
|
97
117
|
});
|
|
98
118
|
export const marketFrameSchema = frameBaseSchema.extend({
|
|
99
119
|
type: z.literal("market"),
|
|
@@ -137,6 +157,85 @@ export const createFrameSchema = z.discriminatedUnion("type", [
|
|
|
137
157
|
createImageFrameSchema,
|
|
138
158
|
createMarketFrameSchema,
|
|
139
159
|
]);
|
|
160
|
+
export const generateImageFrameSchema = z
|
|
161
|
+
.object({
|
|
162
|
+
project: designIdSchema,
|
|
163
|
+
operation: imageGenerationOperationSchema,
|
|
164
|
+
prompt: z.string().trim().min(1).max(MAX_IMAGE_GENERATION_PROMPT_LENGTH),
|
|
165
|
+
target: designIdSchema.optional(),
|
|
166
|
+
references: z
|
|
167
|
+
.array(designIdSchema)
|
|
168
|
+
.max(MAX_IMAGE_GENERATION_REFERENCES)
|
|
169
|
+
.default([]),
|
|
170
|
+
result: imageGenerationResultSchema,
|
|
171
|
+
name: frameNameSchema.optional(),
|
|
172
|
+
x: framePositionSchema.optional(),
|
|
173
|
+
y: framePositionSchema.optional(),
|
|
174
|
+
})
|
|
175
|
+
.strict()
|
|
176
|
+
.superRefine((input, context) => {
|
|
177
|
+
const orderedReferences = [
|
|
178
|
+
...(input.target ? [input.target] : []),
|
|
179
|
+
...input.references,
|
|
180
|
+
];
|
|
181
|
+
if (new Set(orderedReferences).size !== orderedReferences.length) {
|
|
182
|
+
context.addIssue({
|
|
183
|
+
code: "custom",
|
|
184
|
+
path: ["references"],
|
|
185
|
+
message: "Image references must be unique",
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
if (orderedReferences.length > MAX_IMAGE_GENERATION_REFERENCES) {
|
|
189
|
+
context.addIssue({
|
|
190
|
+
code: "custom",
|
|
191
|
+
path: ["references"],
|
|
192
|
+
message: `Image generation supports at most ${MAX_IMAGE_GENERATION_REFERENCES} references`,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
if (input.operation === "generate" && input.target) {
|
|
196
|
+
context.addIssue({
|
|
197
|
+
code: "custom",
|
|
198
|
+
path: ["target"],
|
|
199
|
+
message: "A generation request cannot have an edit target",
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
if (input.operation === "edit" && !input.target) {
|
|
203
|
+
context.addIssue({
|
|
204
|
+
code: "custom",
|
|
205
|
+
path: ["target"],
|
|
206
|
+
message: "An edit request requires an image target",
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
if (input.result === "replace" && input.operation !== "edit") {
|
|
210
|
+
context.addIssue({
|
|
211
|
+
code: "custom",
|
|
212
|
+
path: ["result"],
|
|
213
|
+
message: "Only an image edit can replace a frame",
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
if (input.result === "new" && !input.name) {
|
|
217
|
+
context.addIssue({
|
|
218
|
+
code: "custom",
|
|
219
|
+
path: ["name"],
|
|
220
|
+
message: "A new generated frame requires a name",
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
if (input.result === "replace" && input.name) {
|
|
224
|
+
context.addIssue({
|
|
225
|
+
code: "custom",
|
|
226
|
+
path: ["name"],
|
|
227
|
+
message: "A replacement keeps the target frame name",
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
if (input.result === "replace" &&
|
|
231
|
+
(input.x !== undefined || input.y !== undefined)) {
|
|
232
|
+
context.addIssue({
|
|
233
|
+
code: "custom",
|
|
234
|
+
path: [input.x !== undefined ? "x" : "y"],
|
|
235
|
+
message: "A replacement keeps the target frame position",
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
});
|
|
140
239
|
export const fileListSchema = z.object({
|
|
141
240
|
paths: z.array(projectPathSchema),
|
|
142
241
|
});
|