apps/api/src/lib/schemas.ts (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
import type { APIEmbed, APIMessageTopLevelComponent } from "@stealth-developers/db";
import { type Static, t } from "elysia";
export const GuildSchema = t.Object({
id: t.Number(),
discordId: t.String(),
name: t.String(),
icon: t.Nullable(t.String()),
createdAt: t.Date(),
updatedAt: t.Date(),
});
export type SanitisedGuild = Static<typeof GuildSchema>;
export const UserSchema = t.Object({
id: t.Number(),
discordId: t.Nullable(t.String()),
username: t.Nullable(t.String()),
displayName: t.Nullable(t.String()),
createdAt: t.Date(),
updatedAt: t.Date(),
});
export type SanitisedUser = Static<typeof UserSchema>;
export const ActorSchema = t.Object({
actorId: t.Number(),
guildId: t.Nullable(t.Number()),
userId: t.Nullable(t.Number()),
discordId: t.Nullable(t.String()),
username: t.Nullable(t.String()),
displayName: t.Nullable(t.String()),
avatar: t.Nullable(t.String()),
createdAt: t.Date(),
updatedAt: t.Date(),
});
export type SanitisedActor = Static<typeof ActorSchema>;
export const TicketSchema = t.Object({
id: t.String(),
guildId: t.Number(),
localId: t.Number(),
status: t.String(),
channelId: t.Nullable(t.String()),
threadId: t.Nullable(t.String()),
closeReason: t.Nullable(t.String()),
privateReason: t.Nullable(t.String()),
openedAt: t.Date(),
closedAt: t.Nullable(t.Date()),
closedBy: t.Nullable(t.Number()),
lastSubjectActivityAt: t.Nullable(t.Date()),
lastClaimantActivityAt: t.Nullable(t.Date()),
openedBy: t.Number(),
openReason: t.Nullable(t.String()),
subject: t.Nullable(t.Number()),
claimedBy: t.Nullable(t.Number()),
claimedAt: t.Nullable(t.Date()),
thankedAt: t.Nullable(t.Date()),
warnedAt: t.Nullable(t.Date()),
lastMessageAt: t.Nullable(t.Date()),
hasModeratorMessage: t.Nullable(t.Boolean()),
hasAuthorMessage: t.Nullable(t.Boolean()),
});
export type SanitisedTicket = Static<typeof TicketSchema>;
export const TicketMessageSchema = t.Object({
id: t.String(),
messageId: t.Nullable(t.String()),
ticketId: t.String(),
actorId: t.Nullable(t.Number()),
actorRole: t.String(),
isPrivate: t.Boolean(),
content: t.String(),
embeds: t.Unsafe<APIEmbed[]>({ type: "array" }),
components: t.Unsafe<APIMessageTopLevelComponent[]>({ type: "array" }),
createdAt: t.Date(),
editedAt: t.Nullable(t.Date()),
deletedAt: t.Nullable(t.Date()),
});
export type SanitisedTicketMessage = Static<typeof TicketMessageSchema>;
export const TicketParticipantSchema = t.Object({
id: t.Number(),
ticketId: t.String(),
actorId: t.Number(),
role: t.String(),
reason: t.Nullable(t.String()),
createdAt: t.Date(),
});
export type SanitisedTicketParticipant = Static<typeof TicketParticipantSchema>;
export const TicketCommentSchema = t.Object({
id: t.String(),
ticketId: t.String(),
actorId: t.Number(),
content: t.String(),
createdAt: t.Date(),
updatedAt: t.Date(),
});
export type SanitisedTicketComment = Static<typeof TicketCommentSchema>;
export const TicketAttachmentSchema = t.Object({
id: t.String(),
messageId: t.Nullable(t.String()),
ticketId: t.String(),
actorId: t.Nullable(t.Number()),
fileName: t.String(),
fileType: t.String(),
fileSize: t.Number(),
});
export type SanitisedTicketAttachment = Static<typeof TicketAttachmentSchema>;
export const ErrorSchema = t.Object({
message: t.String(),
});
export type ErrorResponse = Static<typeof ErrorSchema>;
//
export const GuildAccessSchema = t.Object({
id: t.Number(),
discordId: t.String(),
name: t.String(),
icon: t.Nullable(t.String()),
actor: t.Object({
username: t.Nullable(t.String()),
displayName: t.Nullable(t.String()),
avatar: t.Nullable(t.String()),
actorId: t.Number(),
userId: t.Nullable(t.Number()),
discordId: t.Nullable(t.String()),
}),
});
export type GuildAccess = Static<typeof GuildAccessSchema>;
export const TicketsResponseSchema = t.Object({
tickets: t.Array(TicketSchema),
count: t.Number(),
});
export type TicketsResponse = Static<typeof TicketsResponseSchema>;
|