@oaknational/oak-curriculum-schema-v2 0.0.4-alpha → 0.0.5-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,40 +15,27 @@ pnpm add @oaknational/oak-curriculum-schema-v2 drizzle-orm zod
15
15
 
16
16
  ```ts
17
17
  import {
18
- lessonSelectSchema,
19
- lessonInsertSchema,
20
- lessonPublishedSchema,
21
- type Lesson,
22
- type LessonInsert,
23
- type LessonPublished,
18
+ draftLessonWithStatusSelectSchema,
19
+ type DraftLessonWithStatus,
24
20
  } from "@oaknational/oak-curriculum-schema-v2";
25
21
 
26
- // Validate a full row selected from the database
27
- const lesson = lessonSelectSchema.parse(row);
28
-
29
- // Validate a row before inserting
30
- const newLesson = lessonInsertSchema.parse(payload);
31
-
32
- // A schema extended from the derived base to narrow to published rows
33
- const publishedLesson = lessonPublishedSchema.parse(row);
22
+ // Validate a row selected from the draft_lesson_with_status view
23
+ const draftLesson = draftLessonWithStatusSelectSchema.parse(row);
34
24
  ```
35
25
 
26
+ Raw table schemas are not exported. Schemas for tables live with the
27
+ service that uses them (for example `mutation-api`).
28
+
36
29
  ## Row types
37
30
 
38
31
  The schema declarations in `types.d.ts` are built by `drizzle-zod` and are
39
- hard to read. To see a table's fields, hover (or go to definition on) the
32
+ hard to read. To see a view's fields, hover (or go to definition on) the
40
33
  matching row type, which is `z.infer` of the schema and resolves to a flat
41
34
  list of columns.
42
35
 
43
- | Schema | Select type | Insert type |
44
- | --- | --- | --- |
45
- | `lessonSelectSchema` | `Lesson` | `LessonInsert` |
46
- | `documentSelectSchema` | `Document` | `DocumentInsert` |
47
- | `gdriveFileSelectSchema` | `GdriveFile` | `GdriveFileInsert` |
48
- | `lessonComponentStatusSelectSchema` | `LessonComponentStatus` | `LessonComponentStatusInsert` |
49
- | `mediaStatusSelectSchema` | `MediaStatus` | `MediaStatusInsert` |
50
- | `contentGuidanceSelectSchema` | `ContentGuidance` | `ContentGuidanceInsert` |
51
- | `draftLessonWithStatusSelectSchema` | `DraftLessonWithStatus` | n/a (view) |
36
+ | Schema | Select type |
37
+ | --- | --- |
38
+ | `draftLessonWithStatusSelectSchema` | `DraftLessonWithStatus` |
52
39
 
53
40
  ## Links
54
41