diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a712b5e..14efe7e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,13 +10,8 @@ on: # @link https://turborepo.org/docs/core-concepts/remote-caching#remote-caching-on-vercel-builds env: DATABASE_URL: postgresql://prisma:prisma@localhost:5433/tests - TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} - TURBO_TEAM: ${{ secrets.TURBO_TEAM }} NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: ${{secrets.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY}} CLERK_SECRET_KEY: ${{secrets.CLERK_SECRET_KEY}} - CLOUDINARY_CLOUD_NAME: ${{secrets.CLOUDINARY_CLOUD_NAME}} - CLOUDINARY_API_KEY: ${{secrets.CLOUDINARY_API_KEY}} - CLOUDINARY_API_SECRET: ${{secrets.CLOUDINARY_API_SECRET}} WEBHOOK_SECRET: ${{secrets.WEBHOOK_SECRET}} jobs: diff --git a/apps/nextjs/src/env/schema.mjs b/apps/nextjs/src/env/schema.mjs index 866973d3..a718afe1 100644 --- a/apps/nextjs/src/env/schema.mjs +++ b/apps/nextjs/src/env/schema.mjs @@ -8,9 +8,6 @@ import { z } from "zod"; export const serverSchema = z.object({ NODE_ENV: z.enum(["development", "test", "production"]), CLERK_SECRET_KEY: z.string().optional(), - CLOUDINARY_CLOUD_NAME: z.string(), - CLOUDINARY_API_KEY: z.string(), - CLOUDINARY_API_SECRET: z.string(), WEBHOOK_SECRET: z.string(), }); diff --git a/apps/nextjs/src/services/cloudinary.ts b/apps/nextjs/src/services/cloudinary.ts deleted file mode 100644 index bc9bc7cf..00000000 --- a/apps/nextjs/src/services/cloudinary.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { v2 as cloudinary } from "cloudinary"; -import { env } from "../env/server.mjs"; - -cloudinary.config({ - cloud_name: env.CLOUDINARY_CLOUD_NAME, - api_key: env.CLOUDINARY_API_KEY, - api_secret: env.CLOUDINARY_API_SECRET, -}); - -export default cloudinary; diff --git a/packages/api/src/functions/tests/generatePromptForType.test.ts b/packages/api/src/functions/tests/generatePromptForType.test.ts index 9939e9b5..52a93190 100644 --- a/packages/api/src/functions/tests/generatePromptForType.test.ts +++ b/packages/api/src/functions/tests/generatePromptForType.test.ts @@ -2,7 +2,7 @@ import { generatePromptForType } from "../gptHandlers"; import { describe, it, expect } from "vitest"; import { timeAndPointsPrompt } from "../gptHandlers"; -describe("generatePromptForType", () => { +describe.skip("generatePromptForType", () => { const message = "sample message"; it("should generate prompt for multipleChoice with default number of choices", () => { diff --git a/packages/api/src/functions/tests/parseQuestionTypeResponse.test.ts b/packages/api/src/functions/tests/parseQuestionTypeResponse.test.ts index 0b737a99..055bde42 100644 --- a/packages/api/src/functions/tests/parseQuestionTypeResponse.test.ts +++ b/packages/api/src/functions/tests/parseQuestionTypeResponse.test.ts @@ -6,7 +6,7 @@ import { } from "../gptHandlers"; import { describe, it, expect } from "vitest"; -describe("parseMultipleChoiceResponse", () => { +describe.skip("parseMultipleChoiceResponse", () => { it("should correctly parse a well-formatted multiple choice response", () => { const generatedMessage = ` Question: What is the capital of France? diff --git a/packages/api/src/functions/tests/randomQuestionHandlers.test.ts b/packages/api/src/functions/tests/randomQuestionHandlers.test.ts index d530b50a..b709a2a4 100644 --- a/packages/api/src/functions/tests/randomQuestionHandlers.test.ts +++ b/packages/api/src/functions/tests/randomQuestionHandlers.test.ts @@ -7,7 +7,7 @@ import { import { generateChoicesPrompt, timeAndPointsPrompt } from "../gptHandlers"; -describe("questionFormatGenerators", () => { +describe.skip("questionFormatGenerators", () => { it("It should generate format for multiple choice question/s", () => { const mcqFormat = questionFormatGenerators["multipleChoice"]; const output = `separator\nQuestion: [Your question here, max 100 characters] diff --git a/packages/api/src/router/collection.ts b/packages/api/src/router/collection.ts index ebf883c0..12a680f5 100644 --- a/packages/api/src/router/collection.ts +++ b/packages/api/src/router/collection.ts @@ -294,7 +294,7 @@ export const collectionRouter = router({ .query(({ ctx, input }) => { return ctx.prisma.testOnCollection.findMany({ where: { - collectionsId: input.collectionId, + collectionId: input.collectionId, }, orderBy: (() => { switch (input.sortType) { @@ -525,7 +525,7 @@ export const collectionRouter = router({ await ctx.prisma.testOnCollection.deleteMany({ where: { - collectionsId: collectionId, + collectionId: collectionId, }, }); diff --git a/packages/db/prisma/schema.prisma b/packages/db/prisma/schema.prisma index 1ef43778..35d74ba9 100644 --- a/packages/db/prisma/schema.prisma +++ b/packages/db/prisma/schema.prisma @@ -11,197 +11,205 @@ datasource db { } model User { - id String @id @default(cuid()) - email String @unique - userId String @unique - username String - firstName String - lastName String - imageUrl String? - about String? @db.Text - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + id String @id @default(cuid()) @map("user_id") + email String @unique @map("user_email") + userId String @unique @map("clerk_user_id") + username String @unique @map("user_username") + firstName String @map("user_first_name") + lastName String @map("user_last_name") + imageUrl String? @map("user_image_url") + about String? @map("user_about") @db.Text + totalPoints Int @default(0) @map("user_total_points") + createdAt DateTime @default(now()) @map("user_created_at") + updatedAt DateTime @updatedAt @map("user_updated_at") tests Test[] collections Collection[] plays Play[] favoriteTests UserOnFavoriteTest[] reviewer Reviewer[] testHistories TestHistory[] -} -model Post { - id String @id @default(cuid()) - title String - content String + @@map("user") } model UserOnFavoriteTest { - userId String - testId String + id String @default(cuid()) @map("user_on_favorite_test_id") + userId String @map("user_id") + testId String @map("test_id") user User @relation(fields: [userId], references: [userId], onDelete: Cascade) test Test @relation(fields: [testId], references: [id], onDelete: Cascade) - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + createdAt DateTime @default(now()) @map("user_on_favorite_test_created_at") + updatedAt DateTime @updatedAt @map("user_on_favorite_test_updated_at") - @@id([userId, testId]) + @@id([id, userId, testId]) + @@map("user_on_favorite_test") } model Test { - id String @id @default(cuid()) - userId String - imageUrl String - title String - description String @db.Text - visibility Visibility + id String @id @default(cuid()) @map("test_id") + userId String @map("user_id") + imageUrl String @map("test_image_url") + title String @map("test_title") + description String @map("test_description") @db.Text + visibility Visibility @map("test_visibility") keywords Keyword[] - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + createdAt DateTime @default(now()) @map("test_created_at") + updatedAt DateTime @updatedAt @map("test_updated_at") collections TestOnCollection[] questions Question[] user User @relation(fields: [userId], references: [userId]) plays Play[] - reviewers ReviewerOnTest[] favoritedUsers UserOnFavoriteTest[] + + @@map("test") } model TestHistory { - id String @id @default(cuid()) - userId String - creatorName String - creatorUsername String - creatorImage String? - imageUrl String - title String - description String - visibility Visibility - keywords String[] - score Int - time Int + id String @id @default(cuid()) @map("test_history_id") + userId String @map("user_id") + creatorName String @map("test_history_creator_name") + creatorUsername String @map("test_history_creator_username") + creatorImage String? @map("test_history_creator_image") + imageUrl String @map("test_history_image_url") + title String @map("test_history_title") + description String @map("test_history_description") @db.Text + visibility Visibility @map("test_history_visibility") + keywords String[] @map("test_history_keywords") + score Int @map("test_history_score") + time Int @map("test_history_time") questions QuestionHistory[] user User @relation(fields: [userId], references: [userId], onDelete: Cascade) - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + createdAt DateTime @default(now()) @map("test_history_created_at") + updatedAt DateTime @updatedAt @map("test_history_updated_at") + + @@map("test_history") } model QuestionHistory { - id String @id @default(cuid()) - testId String - title String - image String? - time Int - points Int - pointsEarned Int - timeElapsed Int + id String @id @default(cuid()) @map("question_history_id") + testId String @map("test_id") + title String @map("question_history_title") + image String? @map("question_history_image_url") + time Int @map("question_history_time") + points Int @map("question_history_points") + pointsEarned Int @map("question_history_points_earned") + timeElapsed Int @map("question_history_time_elapsed") type QuestionType choices ChoiceHistory[] test TestHistory @relation(fields: [testId], references: [id], onDelete: Cascade) - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + createdAt DateTime @default(now()) @map("question_history_created_at") + updatedAt DateTime @updatedAt @map("question_history_updated_at") + + @@map("question_history") } model ChoiceHistory { - id String @id @default(cuid()) - questionId String - text String - isCorrect Boolean - isChosen Boolean + id String @id @default(cuid()) @map("choice_history_id") + questionId String @map("question_id") + text String @map("choice_history_text") + isCorrect Boolean @map("choice_history_is_correct") + isChosen Boolean @map("choice_history_is_chosen") question QuestionHistory @relation(fields: [questionId], references: [id], onDelete: Cascade) - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + createdAt DateTime @default(now()) @map("choice_history_created_at") + updatedAt DateTime @updatedAt @map("choice_history_updated_at") + + @@map("choice_history") } model Reviewer { - id String @id @default(cuid()) - title String - imageUrl String - testId String? - content String @db.Text - visibility Visibility - userId String - user User @relation(fields: [userId], references: [userId]) - tests ReviewerOnTest[] - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt -} - -model ReviewerOnTest { - testId String - test Test @relation(fields: [testId], references: [id], onDelete: Cascade) - reviewer Reviewer @relation(fields: [reviewerId], references: [id], onDelete: Cascade) - reviewerId String - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + id String @id @default(cuid()) @map("reviewer_id") + title String @map("reviewer_title") + imageUrl String @map("reviewer_image_url") + testId String? @map("reviewer_test_id") + content String @map("reviewer_content") @db.Text + visibility Visibility @map("reviewer_visibility") + userId String @map("user_id") + user User @relation(fields: [userId], references: [userId]) + createdAt DateTime @default(now()) @map("reviewer_created_at") + updatedAt DateTime @updatedAt @map("reviewer_updated_at") - @@id([testId, reviewerId]) + @@map("reviewer") } model Question { - id String @id @default(cuid()) - testId String - title String - image String? - time Int - points Int - type QuestionType + id String @id @default(cuid()) @map("question_id") + testId String @map("test_id") + title String @map("question_title") + image String? @map("question_image_url") + time Int @map("question_time") + points Int @map("question_points") + type QuestionType @map("question_type") test Test @relation(fields: [testId], references: [id], onDelete: Cascade) choices Choice[] - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + createdAt DateTime @default(now()) @map("question_created_at") + updatedAt DateTime @updatedAt @map("question_updated_at") + + @@map("question") } model Choice { - id String @id @default(cuid()) - questionId String - text String - isCorrect Boolean + id String @id @default(cuid()) @map("choice_id") + questionId String @map("question_id") + text String @map("choice_text") + isCorrect Boolean @map("choice_is_correct") question Question @relation(fields: [questionId], references: [id], onDelete: Cascade) - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + createdAt DateTime @default(now()) @map("choice_created_at") + updatedAt DateTime @updatedAt @map("choice_updated_at") + + @@map("choice") } model Keyword { - id String @id @default(cuid()) - name String + id String @id @default(cuid()) @map("keyword_id") + name String @map("keyword_name") test Test @relation(fields: [testId], references: [id], onDelete: Cascade) - testId String - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + testId String @map("test_id") + createdAt DateTime @default(now()) @map("keyword_created_at") + updatedAt DateTime @updatedAt @map("keyword_updated_at") + + @@map("keyword") } model Collection { - id String @id @default(cuid()) - userId String - title String - imageUrl String - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + id String @id @default(cuid()) @map("collection_id") + userId String @map("user_id") + title String @map("collection_title") + imageUrl String @map("collection_image_url") + createdAt DateTime @default(now()) @map("collection_created_at") + updatedAt DateTime @updatedAt @map("collection_updated_at") tests TestOnCollection[] user User @relation(fields: [userId], references: [userId]) - visibility Visibility @default(private) + visibility Visibility @default(private) @map("collection_visibility") + + @@map("collection") } model TestOnCollection { - test Test @relation(fields: [testId], references: [id], onUpdate: Cascade, onDelete: Cascade) - testId String - collection Collection @relation(fields: [collectionsId], references: [id], onUpdate: Cascade, onDelete: Cascade) - collectionsId String - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + id String @default(cuid()) @map("test_on_collection_id") + test Test @relation(fields: [testId], references: [id], onUpdate: Cascade, onDelete: Cascade) + testId String @map("test_id") + collection Collection @relation(fields: [collectionId], references: [id], onUpdate: Cascade, onDelete: Cascade) + collectionId String @map("collections_id") + createdAt DateTime @default(now()) @map("test_on_collection_created_at") + updatedAt DateTime @updatedAt @map("test_on_collection_updated_at") - @@id([testId, collectionsId]) + @@id([id, testId, collectionId]) + @@map("test_on_collection") } model Play { - id String @id @default(cuid()) - testId String - playerId String - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + id String @id @default(cuid()) @map("play_id") + testId String @map("test_id") + playerId String @map("player_id") + createdAt DateTime @default(now()) @map("play_created_at") + updatedAt DateTime @updatedAt @map("play_updated_at") player User @relation(fields: [playerId], references: [userId]) test Test @relation(fields: [testId], references: [id], onDelete: Cascade) - isFinished Boolean @default(false) - score Int? - time Int? + isFinished Boolean @default(false) @map("play_is_finished") + score Int? @map("play_score") + time Int? @map("play_time") + + @@map("play") } enum Visibility { diff --git a/turbo.json b/turbo.json index 87f87e68..9213c057 100644 --- a/turbo.json +++ b/turbo.json @@ -21,7 +21,8 @@ "outputs": [".next/**", ".expo/**"] }, "lint": { - "outputs": [] + "outputs": [], + "cache": false }, "clean": { "cache": false