Open History to see the last commit
1import * as Schema from "effect/Schema";
2import { EnvironmentId, PastedTextAttachmentSource } from "@t3tools/contracts";
3
4export 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
24export 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
36export const DraftComposerAttachmentSchema = Schema.Union([
37 DraftComposerImageAttachmentSchema,
38 DraftComposerFileAttachmentSchema,
39]);