@oaknational/oak-curriculum-schema-v2 0.0.5-alpha → 0.0.6-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 +20 -7
- package/cjs/index.cjs +169 -19
- package/cjs/index.cjs.map +1 -1
- package/esm/index.js +169 -19
- package/esm/index.js.map +1 -1
- package/package.json +4 -3
- package/src/schema/components/deprecated-fields.ts +5 -0
- package/src/schema/components/equipment-and-resource.ts +7 -0
- package/src/schema/components/key-learning-point.ts +7 -0
- package/src/schema/components/keyword.ts +8 -0
- package/src/schema/components/lesson-outline-item.ts +5 -0
- package/src/schema/components/misconception-and-common-mistake.ts +10 -0
- package/src/schema/components/teacher-tip.ts +5 -0
- package/src/schema/draft-lesson-with-status.ts +29 -3
- package/types.d.ts +1999 -5
package/README.md
CHANGED
|
@@ -15,17 +15,30 @@ pnpm add @oaknational/oak-curriculum-schema-v2 drizzle-orm zod
|
|
|
15
15
|
|
|
16
16
|
```ts
|
|
17
17
|
import {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
draftLessonWithStatusSchema,
|
|
19
|
+
draftLessonWithStatusCamelSchema,
|
|
20
|
+
type DraftLessonWithStatusType,
|
|
21
|
+
type DraftLessonWithStatusCamelType,
|
|
20
22
|
} from "@oaknational/oak-curriculum-schema-v2";
|
|
21
23
|
|
|
22
|
-
// Validate a row selected from the draft_lesson_with_status view
|
|
23
|
-
const draftLesson =
|
|
24
|
+
// Validate a snake_case row selected from the draft_lesson_with_status view
|
|
25
|
+
const draftLesson = draftLessonWithStatusSchema.parse(row);
|
|
26
|
+
|
|
27
|
+
// Parse the same snake_case row and get camelCase keys back
|
|
28
|
+
const draftLessonCamel = draftLessonWithStatusCamelSchema.parse(row);
|
|
24
29
|
```
|
|
25
30
|
|
|
26
31
|
Raw table schemas are not exported. Schemas for tables live with the
|
|
27
32
|
service that uses them (for example `mutation-api`).
|
|
28
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
|
+
|
|
29
42
|
## Row types
|
|
30
43
|
|
|
31
44
|
The schema declarations in `types.d.ts` are built by `drizzle-zod` and are
|
|
@@ -33,9 +46,9 @@ hard to read. To see a view's fields, hover (or go to definition on) the
|
|
|
33
46
|
matching row type, which is `z.infer` of the schema and resolves to a flat
|
|
34
47
|
list of columns.
|
|
35
48
|
|
|
36
|
-
| Schema |
|
|
37
|
-
| --- | --- |
|
|
38
|
-
| `
|
|
49
|
+
| Schema | Type | Camel schema | Camel type |
|
|
50
|
+
| --- | --- | --- | --- |
|
|
51
|
+
| `draftLessonWithStatusSchema` | `DraftLessonWithStatusType` | `draftLessonWithStatusCamelSchema` | `DraftLessonWithStatusCamelType` |
|
|
39
52
|
|
|
40
53
|
## Links
|
|
41
54
|
|