Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add redundant code to post QB to neon #216

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions libs/base/utils/src/index.ts
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";
8 changes: 8 additions & 0 deletions libs/base/utils/src/js/chunk.ts
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;
};
30 changes: 15 additions & 15 deletions libs/content/question-bank-atpl/content/learning-objectives.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- id: "010"
subject: "010"
parentId: ""
parentId: null
courses: []
text: Air Law
source: ""
Expand Down Expand Up @@ -8070,7 +8070,7 @@
source: Regulation (EU) No 376/2014, Articles 6, 8, 13 and 14
- id: "021"
subject: "021"
parentId: ""
parentId: null
courses: []
text: Aircraft General Knowledge — Airframe, Systems And Power Plant
source: No entries in v.3 of this TK Syllabus Comparison Document
Expand Down Expand Up @@ -17172,7 +17172,7 @@
source: ""
- id: "022"
subject: "022"
parentId: ""
parentId: null
courses: []
text: Aircraft General Knowledge - Instrumentation
source: No entries in v.3 of this TK Syllabus Comparison Document
Expand Down Expand Up @@ -24169,7 +24169,7 @@
source: ""
- id: "031"
subject: "031"
parentId: ""
parentId: null
courses: []
text: Mass And Balance - Aeroplanes/Helicopters
source: No entries in v.3 of this TK Syllabus Comparison Document
Expand Down Expand Up @@ -25463,7 +25463,7 @@
source: ""
- id: "032"
subject: "032"
parentId: ""
parentId: null
courses: []
text: Performance - Aeroplanes
source: ""
Expand Down Expand Up @@ -28104,7 +28104,7 @@
source: ""
- id: "033"
subject: "033"
parentId: ""
parentId: null
courses: []
text: Flight Planning And Monitoring
source: No entries in v.3 of this TK Syllabus Comparison Document
Expand Down Expand Up @@ -29920,7 +29920,7 @@
source: ""
- id: "034"
subject: "034"
parentId: ""
parentId: null
courses: []
text: "Performance - Helicopters "
source: No entries in v.3 of this TK Syllabus Comparison Document
Expand Down Expand Up @@ -31093,7 +31093,7 @@
source: ""
- id: "040"
subject: "040"
parentId: ""
parentId: null
courses: []
text: "Human Performance And Limitations "
source: No entries in v.3 of this TK Syllabus Comparison Document
Expand Down Expand Up @@ -36174,7 +36174,7 @@
source: ""
- id: "050"
subject: "050"
parentId: ""
parentId: null
courses: []
text: "Meteorology "
source: ""
Expand Down Expand Up @@ -43420,7 +43420,7 @@
source: ""
- id: "061"
subject: "061"
parentId: ""
parentId: null
courses: []
text: General Navigation
source: No entries in v.3 of this TK Syllabus Comparison Document
Expand Down Expand Up @@ -45278,7 +45278,7 @@
source: ""
- id: "062"
subject: "062"
parentId: ""
parentId: null
courses: []
text: Radio Navigation
source: No entries in v.3 of this TK Syllabus Comparison Document
Expand Down Expand Up @@ -50303,7 +50303,7 @@
source: ""
- id: "070"
subject: "070"
parentId: ""
parentId: null
courses: []
text: Operational Procedures
source: ""
Expand Down Expand Up @@ -55399,7 +55399,7 @@
‘Specific HEC equipment’ and related AMCs/GM"
- id: "081"
subject: "081"
parentId: ""
parentId: null
courses: []
text: Principles Of Flight - Aeroplanes
source: No entries in v.3 of this TK Syllabus Comparison Document
Expand Down Expand Up @@ -61103,7 +61103,7 @@
source: ""
- id: "082"
subject: "082"
parentId: ""
parentId: null
courses: []
text: Principles Of Flight - Helicopters
source: No entries in v.3 of this TK Syllabus Comparison Document
Expand Down Expand Up @@ -63766,7 +63766,7 @@
source: ""
- id: "090"
subject: "090"
parentId: ""
parentId: null
courses: []
text: Communications
source: No entries in v.3 of this TK Syllabus Comparison Document
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- id: A320
subject: A320
parentId: ""
parentId: null
courses:
- A320
text: A320 Type Rating Course
Expand Down Expand Up @@ -140,7 +140,7 @@
source: A320 FCOM
- id: B737
subject: B737
parentId: ""
parentId: null
courses:
- B737
text: B737 Type Rating Course
Expand Down
5 changes: 5 additions & 0 deletions libs/core/blog/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": ["../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": []
}
12 changes: 12 additions & 0 deletions libs/core/blog/project.json
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": {}
}
}
18 changes: 18 additions & 0 deletions libs/core/blog/src/entities/blog-post.ts
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>;
1 change: 1 addition & 0 deletions libs/core/blog/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./entities/blog-post";
8 changes: 8 additions & 0 deletions libs/core/blog/tsconfig.json
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"]
}
}
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]>;
};
12 changes: 0 additions & 12 deletions libs/core/question-bank/src/entities/ids.ts

This file was deleted.

48 changes: 14 additions & 34 deletions libs/core/question-bank/src/entities/question-bank-annex.ts
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 libs/core/question-bank/src/entities/question-bank-course.ts
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>;
Loading
Loading