@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 39 lines 1.29 KB
Raw
1 import * as Schema from "effect/Schema";
2 import { EnvironmentId, PastedTextAttachmentSource } from "@t3tools/contracts";
3
4 export const DraftComposerImageAttachmentSchema = Schema.Struct({
5 id: Schema.String,
6 previewUri: Schema.String,
7 type: Schema.Literal("image"),
8 name: Schema.String,
9 mimeType: Schema.String,
10 sizeBytes: Schema.Number,
11 fileUri: Schema.optional(Schema.String.check(Schema.isNonEmpty())),
12 dataUrl: Schema.optional(Schema.String.check(Schema.isNonEmpty())),
13 uploadedAttachmentId: Schema.optional(Schema.String),
14 uploadEnvironmentId: Schema.optional(EnvironmentId),
15 }).check(
16 Schema.makeFilter(
17 ({ fileUri, dataUrl }) =>
18 fileUri !== undefined ||
19 dataUrl !== undefined ||
20 "Image attachment has no file or inline bytes.",
21 ),
22 );
23
24 export const DraftComposerFileAttachmentSchema = Schema.Struct({
25 id: Schema.String,
26 type: Schema.Literal("file"),
27 name: Schema.String,
28 mimeType: Schema.String,
29 sizeBytes: Schema.Number,
30 fileUri: Schema.String,
31 source: Schema.optional(PastedTextAttachmentSource),
32 uploadedAttachmentId: Schema.optional(Schema.String),
33 uploadEnvironmentId: Schema.optional(EnvironmentId),
34 });
35
36 export const DraftComposerAttachmentSchema = Schema.Union([
37 DraftComposerImageAttachmentSchema,
38 DraftComposerFileAttachmentSchema,
39 ]);