Skip to content

Commit

Permalink
feat(content-schema): add content-schema
Browse files Browse the repository at this point in the history
  • Loading branch information
arturvoloshyn committed Mar 8, 2024
1 parent cf21478 commit 21e794d
Show file tree
Hide file tree
Showing 18 changed files with 736 additions and 4 deletions.
2 changes: 2 additions & 0 deletions content-schema/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
playgound
1 change: 1 addition & 0 deletions content-schema/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Content schema
14 changes: 14 additions & 0 deletions content-schema/example/courses/test-course-1/course.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/ArturW1998/course-app/main/content-schema/schemas/course.schema.json

id: "{cuid}"
thumbnail: "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/React-icon.svg/2300px-React-icon.svg.png"
dependencies:
- "test-course-2"
title: "Test course"
description: |
## Course the best
- 1
- 2
- [3](https://google.com)
lessons:
- "lesson-1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/ArturW1998/course-app/main/content-schema/schemas/lesson.schema.json
id: "{cuid}"
title: "Advanced Python Programming"
blocks:
- type: "text"
id: "{cuid}"
text: |
<img width="50%" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f8/Python_logo_and_wordmark.svg/1280px-Python_logo_and_wordmark.svg.png"/>
## What we're going to study today
It's an open question.
Some text
- type: "video"
id: "{cuid}"
url: "https://example.com/video/python-advanced"

- type: "text"
id: "{cuid}"
text: |
## Introduction to Advanced Python Programming
In this section, we'll dive into advanced Python programming topics, including:
- OOP (Object Oriented Programming)
- Working with databases
- Multithreading and asynchronous programming
- type: "question"
id: "{cuid}"
answerOptions:
- text: "What design patterns are most commonly used in Python?"
id: "{cuid}"
isRight: false
- text: "What is a list in Python and how is it used?"
id: "{cuid}"
isRight: true
explanation: |
### Explanation
This quiz will help consolidate your knowledge of advanced Python topics.
Each question is designed to test understanding of key concepts.
successMessage: |
🎉 **Great! You have successfully completed the Advanced Python Topics quiz.**
3 changes: 3 additions & 0 deletions content-schema/example/manifeset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# yaml-language-server: $schema=../schemas/manifest.schema.json
courses:
- "test-course-1"
31 changes: 31 additions & 0 deletions content-schema/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "@core/content-schema",
"version": "1.0.0",
"description": "",
"main": "index.js",
"directories": {
"example": "example"
},
"scripts": {
"gen:types": "ts-node ./scripts/generate-schema-types.ts ./schemas",
"replace-cuid:playgound": "ts-node ./scripts/replace-cuid.ts ./playgound",
"replace-cuid": "ts-node ./scripts/replace-cuid.ts",
"validate": "ts-node ./scripts/validate.ts",
"dev": "concurrently -P --kill-others \"npm:replace-cuid -- {@}\" \"npm:validate -- {@}\" --",
"dev:staging": "npm run dev -- ../staging-content/",
"dev:prod": "npm run dev -- ../prod-content/"
},
"license": "MIT",
"devDependencies": {
"concurrently": "^8.2.2",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
},
"dependencies": {
"ajv": "^8.12.0",
"chokidar": "^3.5.3",
"cuid": "^3.0.0",
"json-schema-to-typescript": "^13.1.2",
"yaml": "^2.3.4"
}
}
28 changes: 28 additions & 0 deletions content-schema/schemas/course.schema.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/

export type Cuid = string;
export type Product =
| {
access: "free";
}
| {
access: "paid";
price: number;
};

export interface Course {
id: Cuid;
title: string;
description: string;
shortDescription?: string;
thumbnail: string;
image: string;
dependencies?: Cuid[];
lessons: Cuid[];
product: Product;
}
85 changes: 85 additions & 0 deletions content-schema/schemas/course.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": [
"id",
"title",
"description",
"lessons",
"thumbnail",
"image",
"product"
],
"additionalProperties": false,
"properties": {
"id": {
"$ref": "#/definitions/cuid"
},
"title": {
"type": "string",
"maxLength": 100
},
"description": {
"type": "string"
},
"shortDescription": {
"type": "string"
},
"thumbnail": {
"type": "string",
"$comment": "url to image sizes 600x300"
},
"image": {
"type": "string",
"$comment": "url to image sizes 1920x600"
},
"dependencies": {
"type": "array",
"items": {
"$ref": "#/definitions/cuid"
}
},
"lessons": {
"type": "array",
"items": {
"$ref": "#/definitions/cuid"
}
},
"product": {
"$ref": "#/definitions/product"
}
},
"definitions": {
"cuid": {
"type": "string",
"title": "cuid"
},
"product": {
"oneOf": [
{
"type": "object",
"additionalProperties": false,
"required": ["access"],
"properties": {
"access": {
"const": "free"
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": ["access", "price"],
"properties": {
"access": {
"const": "paid"
},
"price": {
"type": "number"
}
}
}
]
}
}
}
38 changes: 38 additions & 0 deletions content-schema/schemas/lesson.schema.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/

export type Cuid = string;

export interface Lesson {
id: Cuid;
title: string;
shortDescription?: string;
blocks: (TextBlock | VideoBlock | QuestionBlock)[];
}
export interface TextBlock {
id: Cuid;
type: "text";
text: string;
}
export interface VideoBlock {
id: Cuid;
type: "video";
url: string;
}
export interface QuestionBlock {
id: Cuid;
type: "question";
answerOptions: AnswerOption[];
explanation?: string;
successMessage?: string;
text?: string;
}
export interface AnswerOption {
id: Cuid;
text: string;
isRight: boolean;
}
106 changes: 106 additions & 0 deletions content-schema/schemas/lesson.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": ["id", "title", "blocks"],
"properties": {
"id": {
"$ref": "#/definitions/cuid"
},
"title": {
"type": "string"
},
"shortDescription": {
"type": "string"
},
"blocks": {
"type": "array",
"items": {
"oneOf": [
{ "$ref": "#/block/textBlock" },
{ "$ref": "#/block/videoBlock" },
{ "$ref": "#/block/questionBlock" }
]
}
}
},
"additionalProperties": false,
"block": {
"textBlock": {
"required": ["id", "type", "text"],
"properties": {
"id": {
"$ref": "#/definitions/cuid"
},
"type": {
"const": "text"
},
"text": {
"type": "string"
}
},
"additionalProperties": false
},
"videoBlock": {
"required": ["id", "type", "url"],
"properties": {
"id": {
"$ref": "#/definitions/cuid"
},
"type": {
"const": "video"
},
"url": {
"type": "string"
}
},
"additionalProperties": false
},
"questionBlock": {
"required": ["id", "type", "answerOptions"],
"properties": {
"id": {
"$ref": "#/definitions/cuid"
},
"type": {
"const": "question"
},
"answerOptions": {
"type": "array",
"items": { "$ref": "#/definitions/answerOption" }
},
"explanation": {
"type": "string"
},
"successMessage": {
"type": "string"
},
"text": {
"type": "string"
}
},
"additionalProperties": false
}
},
"definitions": {
"cuid": {
"type": "string",
"title": "cuid"
},
"answerOption": {
"type": "object",
"required": ["id", "text", "isRight"],
"properties": {
"id": {
"$ref": "#/definitions/cuid"
},
"text": {
"type": "string"
},
"isRight": {
"type": "boolean"
}
},
"additionalProperties": false
}
}
}
10 changes: 10 additions & 0 deletions content-schema/schemas/manifest.schema.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/

export interface Manifest {
courses: string[];
}
14 changes: 14 additions & 0 deletions content-schema/schemas/manifest.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"courses": {
"type": "array",
"items": {
"type": "string"
}
}
},
"additionalProperties": false,
"required": ["courses"]
}
Loading

0 comments on commit 21e794d

Please sign in to comment.