@oaknational/oak-curriculum-schema-v2 0.0.7 → 0.0.9-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.
Files changed (30) hide show
  1. package/README.md +37 -13
  2. package/cjs/index.cjs +345 -54
  3. package/cjs/index.cjs.map +1 -1
  4. package/esm/index.js +345 -54
  5. package/esm/index.js.map +1 -1
  6. package/package.json +4 -3
  7. package/src/index.ts +9 -6
  8. package/src/schema/components/deprecated-fields.ts +5 -0
  9. package/src/schema/components/equipment-and-resource.ts +7 -0
  10. package/src/schema/components/key-learning-point.ts +7 -0
  11. package/src/schema/components/keyword.ts +8 -0
  12. package/src/schema/components/lesson-outline-item.ts +5 -0
  13. package/src/schema/components/misconception-and-common-mistake.ts +10 -0
  14. package/src/schema/components/teacher-tip.ts +5 -0
  15. package/src/schema/draft-documents-with-status-by-lesson.ts +18 -0
  16. package/src/schema/draft-lesson-video-with-status-by-lesson.ts +24 -0
  17. package/src/schema/draft-lesson-with-status.ts +35 -0
  18. package/src/schema/published-document-with-release-by-lesson-and-document-type.ts +17 -0
  19. package/src/schema/published-documents-with-release-by-lesson.ts +18 -0
  20. package/src/schema/published-lesson-video-with-release-by-lesson.ts +24 -0
  21. package/src/schema/published-lesson-with-release.ts +36 -0
  22. package/src/schema/unit-contexts-by-unit.ts +14 -0
  23. package/src/schema/units-by-lesson.ts +10 -0
  24. package/types.d.ts +17427 -1600
  25. package/src/schema/content-guidance.ts +0 -35
  26. package/src/schema/document.ts +0 -9
  27. package/src/schema/gdrive-file.ts +0 -9
  28. package/src/schema/lesson-component-status.ts +0 -15
  29. package/src/schema/lesson.ts +0 -14
  30. package/src/schema/media-status.ts +0 -9
package/README.md CHANGED
@@ -15,24 +15,48 @@ 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
+ draftLessonWithStatusSchema,
19
+ draftLessonWithStatusCamelSchema,
20
+ type DraftLessonWithStatusType,
21
+ type DraftLessonWithStatusCamelType,
24
22
  } from "@oaknational/oak-curriculum-schema-v2";
25
23
 
26
- // Validate a full row selected from the database
27
- const lesson = lessonSelectSchema.parse(row);
24
+ // Validate a snake_case row selected from the draft_lesson_with_status view
25
+ const draftLesson = draftLessonWithStatusSchema.parse(row);
28
26
 
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);
27
+ // Parse the same snake_case row and get camelCase keys back
28
+ const draftLessonCamel = draftLessonWithStatusCamelSchema.parse(row);
34
29
  ```
35
30
 
31
+ Raw table schemas are not exported. Schemas for tables live with the
32
+ service that uses them (for example `mutation-api`).
33
+
34
+ ## Naming
35
+
36
+ - Schemas are camelCase with a `Schema` suffix, for example
37
+ `draftLessonWithStatusSchema`.
38
+ - camelCase-key schemas use the suffix `CamelSchema`.
39
+ - Types are PascalCase with a `Type` suffix, or `CamelType` for the
40
+ camelCase-key type.
41
+
42
+ ## Row types
43
+
44
+ The schema declarations in `types.d.ts` are built by `drizzle-zod` and are
45
+ hard to read. To see a view's fields, hover (or go to definition on) the
46
+ matching row type, which is `z.infer` of the schema and resolves to a flat
47
+ list of columns.
48
+
49
+ | Schema | Type | Camel schema | Camel type |
50
+ | --- | --- | --- | --- |
51
+ | `draftLessonWithStatusSchema` | `DraftLessonWithStatusType` | `draftLessonWithStatusCamelSchema` | `DraftLessonWithStatusCamelType` |
52
+ | `draftLessonVideoWithStatusByLessonSchema` | `DraftLessonVideoWithStatusByLessonType` | `draftLessonVideoWithStatusByLessonCamelSchema` | `DraftLessonVideoWithStatusByLessonCamelType` |
53
+ | `draftDocumentsWithStatusByLessonSchema` | `DraftDocumentsWithStatusByLessonType` | `draftDocumentsWithStatusByLessonCamelSchema` | `DraftDocumentsWithStatusByLessonCamelType` |
54
+ | `publishedDocumentWithReleaseByLessonAndDocumentTypeSchema` | `PublishedDocumentWithReleaseByLessonAndDocumentTypeType` | `publishedDocumentWithReleaseByLessonAndDocumentTypeCamelSchema` | `PublishedDocumentWithReleaseByLessonAndDocumentTypeCamelType` |
55
+ | `publishedDocumentsWithReleaseByLessonSchema` | `PublishedDocumentsWithReleaseByLessonType` | `publishedDocumentsWithReleaseByLessonCamelSchema` | `PublishedDocumentsWithReleaseByLessonCamelType` |
56
+ | `publishedLessonVideoWithReleaseByLessonSchema` | `PublishedLessonVideoWithReleaseByLessonType` | `publishedLessonVideoWithReleaseByLessonCamelSchema` | `PublishedLessonVideoWithReleaseByLessonCamelType` |
57
+ | `unitContextsByUnitSchema` | `UnitContextsByUnitType` | `unitContextsByUnitCamelSchema` | `UnitContextsByUnitCamelType` |
58
+ | `unitsByLessonSchema` | `UnitsByLessonType` | `unitsByLessonCamelSchema` | `UnitsByLessonCamelType` |
59
+
36
60
  ## Links
37
61
 
38
62
  - [npm package](https://www.npmjs.com/package/@oaknational/oak-curriculum-schema-v2)