Skip to content

Commit

Permalink
update test command
Browse files Browse the repository at this point in the history
  • Loading branch information
clementvt committed Jan 1, 2025
1 parent 6de607c commit 3631cbe
Show file tree
Hide file tree
Showing 12 changed files with 281 additions and 236 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,6 @@ dist
.pnp.*

# test folder
test
test
/prisma/schema/*
/prisma/ERD.md
157 changes: 69 additions & 88 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,125 +1,127 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init

generator client {
provider = "prisma-client-js"
}

generator zod {
provider = "zod-prisma"
output = "./schema"
relationModel = "true"
modelSuffix = "Model"
useDecimalJs = "true"
prismaJsonNullability = "true"
modelCase = "PascalCase"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model Guild {
id String @id @unique
welcomer Welcomer?
createdAt DateTime? @default(now())
updatedAt DateTime? @updatedAt
leaver Leaver?
createdAt DateTime? @default(now())
updatedAt DateTime? @updatedAt
welcomer Welcomer?
}

model Welcomer {
id Int @unique @default(autoincrement()) /// @zod.optional()
guildId String @unique
guild Guild? @relation(fields: [guildId], references: [id])
channelId String
content String
embeds Embed[] /// @zod.max(10)
id Int @id @default(autoincrement()) /// @zod.optional()
guildId String @unique
channelId String?
content String?
createdAt DateTime? @default(now())
updatedAt DateTime? @updatedAt
DM DM?
createdAt DateTime? @default(now())
updatedAt DateTime? @updatedAt
embeds Embed[]
guild Guild? @relation(fields: [guildId], references: [id])
}

model Leaver {
id Int @unique @default(autoincrement()) /// @zod.optional()
guildId String @unique
guild Guild? @relation(fields: [guildId], references: [id])
channelId String
content String
embeds Embed[]
id Int @id @default(autoincrement()) /// @zod.optional()
guildId String @unique
channelId String?
content String?
createdAt DateTime? @default(now())
updatedAt DateTime? @updatedAt
embeds Embed[]
guild Guild? @relation(fields: [guildId], references: [id])
}

model DM {
id Int @unique @default(autoincrement())
moduleId Int @unique
module Welcomer @relation(fields: [moduleId], references: [id])
id Int @id @default(autoincrement()) /// @zod.optional()
moduleId Int @unique
message String
embeds Embed[]
createdAt DateTime? @default(now())
updatedAt DateTime? @updatedAt
module Welcomer @relation(fields: [moduleId], references: [id])
embeds Embed[]
}

model Embed {
id Int @id @default(autoincrement()) /// @zod.optional()
title String? @db.VarChar(256)
id Int @id @default(autoincrement()) /// @zod.optional()
title String? @db.VarChar(256)
description String? @db.VarChar(4096)
color String?
timestamp DateTime?
timestampNow Boolean?
footer EmbedFooter?
fields EmbedField[]
author EmbedAuthor?
image EmbedImage?
thumbnail String?
url String?
created DateTime? @default(now()) /// @zod.optional()
updated DateTime? @default(now()) /// @zod.optional()
// relations
welcomerId Int?
welcomer Welcomer? @relation(fields: [welcomerId], references: [id])
leaverId Int?
leaver Leaver? @relation(fields: [leaverId], references: [id])
DMId Int?
DM DM? @relation(fields: [DMId], references: [id])
created DateTime? @default(now())
updated DateTime? @default(now())
welcomerId Int?
leaverId Int?
DMId Int?
DM DM? @relation(fields: [DMId], references: [id])
leaver Leaver? @relation(fields: [leaverId], references: [id])
welcomer Welcomer? @relation(fields: [welcomerId], references: [id])
author EmbedAuthor?
fields EmbedField[]
footer EmbedFooter?
image EmbedImage?
}

model EmbedImage {
id Int @id @default(autoincrement())
embedId Int @unique
embed Embed @relation(fields: [embedId], references: [id])
id Int @id @default(autoincrement()) /// @zod.optional()
embedId Int @unique
url String
width Int?
heigth Int?
createdAt DateTime? @default(now())
updatedAt DateTime? @updatedAt
embed Embed? @relation(fields: [embedId], references: [id])
}

model EmbedAuthor {
id Int @id @default(autoincrement())/// @zod.optional()
embedId Int? @unique/// @zod.optional()
embed Embed? @relation(fields: [embedId], references: [id])/// @zod.optional()
id Int @id @default(autoincrement()) /// @zod.optional()
embedId Int? @unique
name String?
iconUrl String?
url String? @db.VarChar(256)
url String? @db.VarChar(256)
createdAt DateTime? @default(now())
updatedAt DateTime? @updatedAt
embed Embed? @relation(fields: [embedId], references: [id])
}

model EmbedField {
id Int @id @default(autoincrement())/// @zod.optional()
embedId Int? @unique/// @zod.optional()
embed Embed? @relation(fields: [embedId], references: [id])/// @zod.optional()
id Int @id @default(autoincrement()) /// @zod.optional()
embedId Int? @unique
name String
value String
inline Boolean?
createdAt DateTime? @default(now())
updatedAt DateTime? @updatedAt
embed Embed? @relation(fields: [embedId], references: [id])
}

model EmbedFooter {
id Int @id @default(autoincrement())/// @zod.optional()
embedId Int? @unique /// @zod.optional()
embed Embed? @relation(fields: [embedId], references: [id]) /// @zod.optional()
id Int @id @default(autoincrement()) /// @zod.optional()
embedId Int? @unique
text String? @db.VarChar(2048)
iconUrl String?
createdAt DateTime? @default(now())/// @zod.optional()
updatedAt DateTime? @updatedAt/// @zod.optional()
createdAt DateTime? @default(now())
updatedAt DateTime? @updatedAt
embed Embed? @relation(fields: [embedId], references: [id])
}

model User {
Expand All @@ -129,8 +131,8 @@ model User {
avatar String?
accessToken String?
refreshToken String?
createdAt DateTime? @default(now())
updatedAt DateTime? @updatedAt
createdAt DateTime? @default(now())
updatedAt DateTime? @updatedAt
guilds UserGuild[]
}

Expand All @@ -140,41 +142,20 @@ model UserGuild {
icon String?
banner String?
permissions String?
channels Channels[]
userId String
createdAt DateTime? @default(now())
updatedAt DateTime? @updatedAt
channels Channels[]
user User @relation(fields: [userId], references: [id])
createdAt DateTime? @default(now())
updatedAt DateTime? @updatedAt
}

model Channels {
id String @id
type String
name String
guildId String
guild UserGuild @relation(fields: [guildId], references: [id])
channelId String
createdAt DateTime? @default(now())
updatedAt DateTime? @updatedAt
createdAt DateTime? @default(now())
updatedAt DateTime? @updatedAt
guild UserGuild @relation(fields: [guildId], references: [id])
}

generator zod {
provider = "zod-prisma"
output = "./schema" // (default) the directory where generated zod schemas will be saved
relationModel = true // (default) Create and export both plain and related models.
// relationModel = "default" // Do not export model without relations.
// relationModel = false // Do not generate related model
modelCase = "PascalCase" // (default) Output models using pascal case (ex. UserModel, PostModel)
// modelCase = "camelCase" // Output models using camel case (ex. userModel, postModel)
modelSuffix = "Model" // (default) Suffix to apply to your prisma models when naming Zod schemas
// useDecimalJs = false // (default) represent the prisma Decimal type using as a JS number
useDecimalJs = true // represent the prisma Decimal type using Decimal.js (as Prisma does)
// https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-by-null-values
prismaJsonNullability = true // (default) uses prisma's scheme for JSON field nullability
// prismaJsonNullability = false // allows null assignment to optional JSON fields
}
22 changes: 11 additions & 11 deletions prisma/schema/embed.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as z from "zod"
import { CompleteEmbedFooter, RelatedEmbedFooterModel, CompleteEmbedField, RelatedEmbedFieldModel, CompleteEmbedAuthor, RelatedEmbedAuthorModel, CompleteEmbedImage, RelatedEmbedImageModel, CompleteWelcomer, RelatedWelcomerModel, CompleteLeaver, RelatedLeaverModel, CompleteDM, RelatedDMModel } from "./index"
import { CompleteDM, RelatedDMModel, CompleteLeaver, RelatedLeaverModel, CompleteWelcomer, RelatedWelcomerModel, CompleteEmbedAuthor, RelatedEmbedAuthorModel, CompleteEmbedField, RelatedEmbedFieldModel, CompleteEmbedFooter, RelatedEmbedFooterModel, CompleteEmbedImage, RelatedEmbedImageModel } from "./index"

export const EmbedModel = z.object({
id: z.number().int().optional(),
Expand All @@ -18,13 +18,13 @@ export const EmbedModel = z.object({
})

export interface CompleteEmbed extends z.infer<typeof EmbedModel> {
footer?: CompleteEmbedFooter | null
fields: CompleteEmbedField[]
DM?: CompleteDM | null
leaver?: CompleteLeaver | null
welcomer?: CompleteWelcomer | null
author?: CompleteEmbedAuthor | null
fields?: CompleteEmbedField | null
footer?: CompleteEmbedFooter | null
image?: CompleteEmbedImage | null
welcomer?: CompleteWelcomer | null
leaver?: CompleteLeaver | null
DM?: CompleteDM | null
}

/**
Expand All @@ -33,11 +33,11 @@ export interface CompleteEmbed extends z.infer<typeof EmbedModel> {
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const RelatedEmbedModel: z.ZodSchema<CompleteEmbed> = z.lazy(() => EmbedModel.extend({
footer: RelatedEmbedFooterModel.nullish(),
fields: RelatedEmbedFieldModel.array(),
DM: RelatedDMModel.nullish(),
leaver: RelatedLeaverModel.nullish(),
welcomer: RelatedWelcomerModel.nullish(),
author: RelatedEmbedAuthorModel.nullish(),
fields: RelatedEmbedFieldModel.nullish(),
footer: RelatedEmbedFooterModel.nullish(),
image: RelatedEmbedImageModel.nullish(),
welcomer: RelatedWelcomerModel.nullish(),
leaver: RelatedLeaverModel.nullish(),
DM: RelatedDMModel.nullish(),
}))
2 changes: 1 addition & 1 deletion prisma/schema/embedauthor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ export interface CompleteEmbedAuthor extends z.infer<typeof EmbedAuthorModel> {
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const RelatedEmbedAuthorModel: z.ZodSchema<CompleteEmbedAuthor> = z.lazy(() => EmbedAuthorModel.extend({
embed: RelatedEmbedModel.optional().nullish(),
embed: RelatedEmbedModel.nullish(),
}))
2 changes: 1 addition & 1 deletion prisma/schema/embedfield.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ export interface CompleteEmbedField extends z.infer<typeof EmbedFieldModel> {
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const RelatedEmbedFieldModel: z.ZodSchema<CompleteEmbedField> = z.lazy(() => EmbedFieldModel.extend({
embed: RelatedEmbedModel.optional().nullish(),
embed: RelatedEmbedModel.nullish(),
}))
2 changes: 1 addition & 1 deletion prisma/schema/embedfooter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ export interface CompleteEmbedFooter extends z.infer<typeof EmbedFooterModel> {
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const RelatedEmbedFooterModel: z.ZodSchema<CompleteEmbedFooter> = z.lazy(() => EmbedFooterModel.extend({
embed: RelatedEmbedModel.optional().nullish(),
embed: RelatedEmbedModel.nullish(),
}))
6 changes: 3 additions & 3 deletions prisma/schema/guild.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as z from "zod"
import { CompleteWelcomer, RelatedWelcomerModel, CompleteLeaver, RelatedLeaverModel } from "./index"
import { CompleteLeaver, RelatedLeaverModel, CompleteWelcomer, RelatedWelcomerModel } from "./index"

export const GuildModel = z.object({
id: z.string(),
Expand All @@ -8,8 +8,8 @@ export const GuildModel = z.object({
})

export interface CompleteGuild extends z.infer<typeof GuildModel> {
welcomer?: CompleteWelcomer | null
leaver?: CompleteLeaver | null
welcomer?: CompleteWelcomer | null
}

/**
Expand All @@ -18,6 +18,6 @@ export interface CompleteGuild extends z.infer<typeof GuildModel> {
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const RelatedGuildModel: z.ZodSchema<CompleteGuild> = z.lazy(() => GuildModel.extend({
welcomer: RelatedWelcomerModel.nullish(),
leaver: RelatedLeaverModel.nullish(),
welcomer: RelatedWelcomerModel.nullish(),
}))
10 changes: 5 additions & 5 deletions prisma/schema/leaver.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import * as z from "zod"
import { CompleteGuild, RelatedGuildModel, CompleteEmbed, RelatedEmbedModel } from "./index"
import { CompleteEmbed, RelatedEmbedModel, CompleteGuild, RelatedGuildModel } from "./index"

export const LeaverModel = z.object({
id: z.number().int().optional(),
guildId: z.string(),
channelId: z.string(),
content: z.string(),
channelId: z.string().nullish(),
content: z.string().nullish(),
createdAt: z.date().nullish(),
updatedAt: z.date().nullish(),
})

export interface CompleteLeaver extends z.infer<typeof LeaverModel> {
guild?: CompleteGuild | null
embeds: CompleteEmbed[]
guild: CompleteGuild
}

/**
Expand All @@ -21,6 +21,6 @@ export interface CompleteLeaver extends z.infer<typeof LeaverModel> {
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const RelatedLeaverModel: z.ZodSchema<CompleteLeaver> = z.lazy(() => LeaverModel.extend({
guild: RelatedGuildModel.nullish(),
embeds: RelatedEmbedModel.array(),
guild: RelatedGuildModel,
}))
Loading

0 comments on commit 3631cbe

Please sign in to comment.