chorus/src/types.ts

83 lines
1.6 KiB
TypeScript
Raw Normal View History

2024-12-24 14:43:23 +00:00
import {z} from "zod";
const commentsConfigSchema = z.object({
mail: z.object({
imap: z.object({
host: z.string(),
port: z.number({ coerce: true }),
auth: z.object({
user: z.string(),
pass: z.string(),
}),
}),
threads: z.object({
type: z.string(), // fixme : in validation
template: z.string(),
2024-12-31 02:36:12 +00:00
idPrefix: z.string(),
2025-01-06 00:55:54 +00:00
replyPrefix: z.string(),
2024-12-24 14:43:23 +00:00
}),
}),
dirs: z.object({
data: z.string(),
}),
2024-12-24 14:43:23 +00:00
})
export type CommentsConfig = z.infer<typeof commentsConfigSchema>
export const castCommentsConfig = (what: unknown): CommentsConfig => {
return commentsConfigSchema.parse(what)
}
2024-12-31 02:36:12 +00:00
export type Message = {
id: string,
2025-01-06 00:55:54 +00:00
idHash: string,
2024-12-31 02:36:12 +00:00
date: Date,
recipients: string[],
from: {
name?: string,
address?: string,
},
subject: string,
content: string,
html?: string,
mailbox: string,
modseq: BigInt,
thread?: string,
2025-01-06 00:55:54 +00:00
replyToHash?: string,
2024-12-31 02:36:12 +00:00
}
export type ThreadUser = {
name: string,
mailId: string,
domainId: string,
color: string,
}
export type ThreadComment = {
2025-01-06 00:55:54 +00:00
idHash: string,
replyToHash?: string,
replyAddress: string,
user: ThreadUser,
date: Date,
subject: string,
text: string,
rendered: string,
2025-01-06 00:55:54 +00:00
replies?: ThreadComment[],
}
export type ThreadData = {
thread: string,
refresh: {
date: Date,
markers: {[key: string]: BigInt},
},
comments: ThreadComment[],
}
export type RootData = {
refresh?: {
date: Date,
},
}