-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(content-schema): add content-schema
- Loading branch information
arturvoloshyn
committed
Mar 8, 2024
1 parent
cf21478
commit 21e794d
Showing
18 changed files
with
736 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
playgound |
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 @@ | ||
# Content schema |
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,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" |
45 changes: 45 additions & 0 deletions
45
content-schema/example/courses/test-course-1/lessons/lesson-1/lesson.yaml
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,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.** |
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,3 @@ | ||
# yaml-language-server: $schema=../schemas/manifest.schema.json | ||
courses: | ||
- "test-course-1" |
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,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" | ||
} | ||
} |
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,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; | ||
} |
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,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" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
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,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; | ||
} |
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,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 | ||
} | ||
} | ||
} |
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,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[]; | ||
} |
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,14 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"properties": { | ||
"courses": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"required": ["courses"] | ||
} |
Oops, something went wrong.