-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add redundant code to post QB to neon (#216)
- Loading branch information
Showing
64 changed files
with
1,506 additions
and
966 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
export * from "./assert/assert-type"; | ||
export * from "./js/chunk"; | ||
export * from "./js/deep-clone"; | ||
export * from "./js/keep-unique"; | ||
export * from "./js/make-map"; | ||
export * from "./js/noop"; | ||
export * from "./random/random"; | ||
export * from "./js/keep-unique"; | ||
export * from "./js/sha256"; | ||
export * from "./random/random"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export const chunk = <T>(array: T[], chunkSize: number): T[][] => { | ||
const chunks: T[][] = []; | ||
const nChunks = Math.ceil(array.length / chunkSize); | ||
for (let i = 0; i < nChunks; i++) { | ||
chunks.push(array.slice(i * nChunks, (i + 1) * nChunks)); | ||
} | ||
return chunks; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extends": ["../../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "core-blog", | ||
"$schema": "../../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "libs/core/blog/src", | ||
"projectType": "library", | ||
"tags": [], | ||
"targets": { | ||
"lint": {}, | ||
"types": {}, | ||
"format": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { z } from "zod"; | ||
|
||
export const blogPostIdSchema = z.string(); | ||
|
||
export const blogPostSchema = z.object({ | ||
id: blogPostIdSchema, | ||
createdAt: z.date(), | ||
updatedAt: z.date(), | ||
title: z.string(), | ||
description: z.string(), | ||
author: z.string(), | ||
content: z.string(), | ||
tag: z.string(), | ||
imageUrl: z.string(), | ||
}); | ||
|
||
export type BlogPostId = z.infer<typeof blogPostIdSchema>; | ||
export type BlogPost = z.infer<typeof blogPostSchema>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./entities/blog-post"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "../../../tsconfig.base.json", | ||
"include": ["src/**/*.ts"], | ||
"files": ["../../../types.d.ts"], | ||
"compilerOptions": { | ||
"types": ["vitest/globals"] | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
libs/core/question-bank/src/entities/deprecated-question-bank-provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { z } from "zod"; | ||
import type { Annex } from "./question-bank-annex"; | ||
import type { Course } from "./question-bank-course"; | ||
import type { Doc } from "./question-bank-doc"; | ||
import type { FlashcardCollection } from "./question-bank-flashcards"; | ||
import type { QuestionBankName } from "./question-bank-ids"; | ||
import type { LearningObjective } from "./question-bank-learning-objectives"; | ||
import type { QuestionTemplate } from "./question-bank-question"; | ||
import type { Subject } from "./question-bank-subject"; | ||
|
||
export type QuestionBankNameToType = { | ||
questions: QuestionTemplate; | ||
learningObjectives: LearningObjective; | ||
annexes: Annex; | ||
flashcards: FlashcardCollection; | ||
subjects: Subject; | ||
courses: Course; | ||
docs: Doc; | ||
}; | ||
|
||
export type QuestionBankResource = keyof QuestionBankNameToType; | ||
|
||
export const questionBankResourceSchema = z.enum([ | ||
"questions", | ||
"learningObjectives", | ||
"annexes", | ||
"flashcards", | ||
"courses", | ||
"subjects", | ||
"docs", | ||
]); | ||
|
||
export type QuestionBankResourceArrays = { | ||
[K in QuestionBankResource]: QuestionBankNameToType[K][] | undefined; | ||
}; | ||
|
||
export type QuestionBankResourceMaps = { | ||
[K in QuestionBankResource]: | ||
| Record<string, QuestionBankNameToType[K]> | ||
| undefined; | ||
}; | ||
|
||
export type QuestionBankProvider = { | ||
preloadForStaticRender: (args: MiniFs) => Promise<void>; | ||
getName: () => QuestionBankName; | ||
has: (r: QuestionBankResource) => Promise<boolean>; | ||
|
||
getAll: <T extends QuestionBankResource>( | ||
r: T, | ||
) => Promise<QuestionBankNameToType[T][]>; | ||
getSome: <T extends QuestionBankResource>( | ||
r: T, | ||
id: string[], | ||
) => Promise<QuestionBankNameToType[T][]>; | ||
getOne: <T extends QuestionBankResource>( | ||
r: T, | ||
id: string, | ||
) => Promise<QuestionBankNameToType[T]>; | ||
}; |
This file was deleted.
Oops, something went wrong.
48 changes: 14 additions & 34 deletions
48
libs/core/question-bank/src/entities/question-bank-annex.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,25 @@ | ||
import { z } from "zod"; | ||
import { assertType } from "@cf/base/utils"; | ||
import { questionBankNameSchema } from "./question-bank-name"; | ||
import type { | ||
AnnexId, | ||
DocId, | ||
LearningObjectiveId, | ||
QuestionTemplateId, | ||
SubjectId, | ||
} from "./ids"; | ||
import type { QuestionBankName } from "./question-bank-name"; | ||
import type { IsEqual } from "@cf/base/utils"; | ||
|
||
export type AnnexFormat = "jpg"; | ||
|
||
export type Annex = { | ||
id: AnnexId; | ||
href: string; | ||
source: string; | ||
srcLocation: string; | ||
questionBank: QuestionBankName; | ||
format: AnnexFormat; | ||
description: string; | ||
docs: DocId[]; | ||
questions: QuestionTemplateId[]; | ||
subjects: SubjectId[]; | ||
learningObjectives: LearningObjectiveId[]; | ||
}; | ||
import { | ||
annexIdSchema, | ||
docIdSchema, | ||
learningObjectiveIdSchema, | ||
questionBankNameSchema, | ||
questionTemplateIdSchema, | ||
subjectIdSchema, | ||
} from "./question-bank-ids"; | ||
|
||
export const annexSchema = z.object({ | ||
id: z.string(), | ||
id: annexIdSchema, | ||
href: z.string(), | ||
srcLocation: z.string(), | ||
source: z.string(), | ||
questionBank: questionBankNameSchema, | ||
format: z.enum(["jpg"]), | ||
description: z.string(), | ||
docs: z.array(z.string().min(3)), | ||
questions: z.array(z.string().min(3)), | ||
subjects: z.array(z.string().min(3)).min(1), | ||
learningObjectives: z.array(z.string().min(3)).min(1), | ||
docs: z.array(docIdSchema), | ||
questions: z.array(questionTemplateIdSchema), | ||
subjects: z.array(subjectIdSchema).min(1), | ||
learningObjectives: z.array(learningObjectiveIdSchema).min(1), | ||
}); | ||
|
||
type IAnnex = z.infer<typeof annexSchema>; | ||
assertType<IsEqual<Annex, IAnnex>>(); | ||
export type Annex = z.infer<typeof annexSchema>; |
14 changes: 3 additions & 11 deletions
14
libs/core/question-bank/src/entities/question-bank-course.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,9 @@ | ||
import { z } from "zod"; | ||
import { assertType } from "@cf/base/utils"; | ||
import type { CourseId } from "./ids"; | ||
import type { IsEqual } from "@cf/base/utils"; | ||
|
||
export type Course = { | ||
id: CourseId; | ||
text: string; | ||
}; | ||
import { courseIdSchema } from "./question-bank-ids"; | ||
|
||
export const courseSchema = z.object({ | ||
id: z.string(), | ||
id: courseIdSchema, | ||
text: z.string(), | ||
}); | ||
|
||
type ICourse = z.infer<typeof courseSchema>; | ||
assertType<IsEqual<ICourse, Course>>(); | ||
export type Course = z.infer<typeof courseSchema>; |
Oops, something went wrong.