Skip to content

Commit 5402b01

Browse files
NiallJoeMaherclaude
andcommitted
workshop: add Chapter 4 preview stubs (artifact server handlers)
- Add artifacts/flashcard/server.ts with schema and TODO for handler - Add artifacts/study-plan/server.ts with schema and TODO for handler - Type definitions ready for Chapter 4 implementation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 2dac250 commit 5402b01

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

artifacts/flashcard/server.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// TODO CHAPTER 4: Implement flashcard server handler
2+
//
3+
// This file should:
4+
// 1. Define FlashcardData type schema
5+
// 2. Create document handler for flashcard artifacts
6+
// 3. Handle creation and updates of flashcard quizzes
7+
//
8+
// See CHAPTER-4.md for the complete implementation.
9+
10+
import { z } from "zod";
11+
12+
/**
13+
* Schema for flashcard quiz data
14+
*/
15+
export const flashcardSchema = z.object({
16+
topic: z.string(),
17+
questions: z.array(
18+
z.object({
19+
question: z.string(),
20+
options: z.array(z.string()).length(4),
21+
correctAnswer: z.number().min(0).max(3),
22+
explanation: z.string(),
23+
})
24+
),
25+
});
26+
27+
export type FlashcardData = z.infer<typeof flashcardSchema>;
28+
29+
// TODO: Add createDocumentHandler for flashcard artifacts
30+
// export const flashcardDocumentHandler = createDocumentHandler<"flashcard">({
31+
// kind: "flashcard",
32+
// onCreateDocument: async ({ title, dataStream }) => { ... },
33+
// onUpdateDocument: async ({ document, description, dataStream }) => { ... },
34+
// });

artifacts/study-plan/server.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// TODO CHAPTER 4: Implement study-plan server handler
2+
//
3+
// This file should:
4+
// 1. Define StudyPlanData type schema
5+
// 2. Create document handler for study-plan artifacts
6+
// 3. Handle creation and updates with progress tracking
7+
//
8+
// See CHAPTER-4.md for the complete implementation.
9+
10+
import { z } from "zod";
11+
12+
/**
13+
* Schema for study plan data
14+
*/
15+
export const studyPlanSchema = z.object({
16+
topic: z.string(),
17+
duration: z.string(),
18+
overview: z.string(),
19+
weeks: z.array(
20+
z.object({
21+
week: z.number(),
22+
title: z.string(),
23+
goals: z.array(z.string()),
24+
tasks: z.array(
25+
z.object({
26+
task: z.string(),
27+
duration: z.string(),
28+
completed: z.boolean().default(false),
29+
})
30+
),
31+
resources: z.array(z.string()),
32+
})
33+
),
34+
tips: z.array(z.string()),
35+
});
36+
37+
export type StudyPlanData = z.infer<typeof studyPlanSchema>;
38+
39+
// TODO: Add createDocumentHandler for study-plan artifacts
40+
// export const studyPlanDocumentHandler = createDocumentHandler<"study-plan">({
41+
// kind: "study-plan",
42+
// onCreateDocument: async ({ title, dataStream }) => { ... },
43+
// onUpdateDocument: async ({ document, description, dataStream }) => { ... },
44+
// });

0 commit comments

Comments
 (0)