@oaknational/oak-curriculum-schema 1.67.3 → 1.69.0

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.
@@ -0,0 +1,26 @@
1
+ import { AssetType } from "@/schema/assets.schema";
2
+
3
+ export const assetsFixture = (
4
+ overrides: Partial<AssetType> = {},
5
+ ): AssetType => ({
6
+ asset_id: 1,
7
+ asset_uid: "asset-uid-123",
8
+ _state: "new",
9
+ title: "Sample Asset",
10
+ description: "This is a sample asset for testing.",
11
+ asset_type: "worksheet",
12
+ url: "https://example.com/asset.pdf",
13
+ asset_object: {
14
+ pdf: {
15
+ bucket_name: "sample-bucket",
16
+ bucket_path: "path/to/asset.pdf",
17
+ },
18
+ google_drive: {
19
+ id: "google-drive-id-123",
20
+ url: "https://drive.google.com/file/d/google-drive-id-123/view",
21
+ },
22
+ },
23
+ tpc_media_ids: [101, 102],
24
+ tpc_works_ids: [201, 202],
25
+ ...overrides,
26
+ });
@@ -0,0 +1,54 @@
1
+ import { z } from "zod";
2
+ import { _stateSchema } from "./base.schema";
3
+
4
+ export const assetTypeSchema = z.enum([
5
+ "lesson_guide",
6
+ "downloadable_file",
7
+ "slidedeck",
8
+ "worksheet",
9
+ "worksheet_answers",
10
+ "supplementary_resource",
11
+ ]);
12
+
13
+ export type AssetTypeType = z.infer<typeof assetTypeSchema>;
14
+
15
+ export const googleSchema = z.object({
16
+ id: z.string().nullable(),
17
+ url: z.string().url().nullable(),
18
+ });
19
+
20
+ export type GoogleType = z.infer<typeof googleSchema>;
21
+
22
+ export const bucketSchema = z.object({
23
+ bucket_name: z.string().nullable(),
24
+ bucket_path: z.string().nullable(),
25
+ });
26
+
27
+ export type BucketType = z.infer<typeof bucketSchema>;
28
+
29
+ export const assetObjectSchema = z
30
+ .object({
31
+ pdf: bucketSchema,
32
+ powerpoint: bucketSchema,
33
+ opendocument_presentation: bucketSchema,
34
+ google_drive: googleSchema,
35
+ google_slide: googleSchema.pick({ url: true }),
36
+ })
37
+ .partial();
38
+
39
+ export type AssetObjectType = z.infer<typeof assetObjectSchema>;
40
+
41
+ export const assetsSchema = z.object({
42
+ asset_id: z.number(),
43
+ asset_uid: z.string(),
44
+ _state: _stateSchema,
45
+ title: z.string(),
46
+ description: z.string(),
47
+ asset_type: assetTypeSchema,
48
+ url: z.string().url(),
49
+ asset_object: assetObjectSchema,
50
+ tpc_media_ids: z.array(z.number()).nullable(),
51
+ tpc_works_ids: z.array(z.number()).nullable(),
52
+ });
53
+
54
+ export type AssetType = z.infer<typeof assetsSchema>;
@@ -0,0 +1,11 @@
1
+ import { describe, it, expect } from "vitest";
2
+
3
+ import { assetsSchema } from "@/schema/assets.schema";
4
+ import { assetsFixture } from "@/fixtures/assets.fixture";
5
+
6
+ describe("assets schema", () => {
7
+ it("assets fixture conforms to the schema", () => {
8
+ const asset = assetsFixture();
9
+ expect(() => assetsSchema.parse(asset)).not.toThrow();
10
+ });
11
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oaknational/oak-curriculum-schema",
3
- "version": "1.67.3",
3
+ "version": "1.69.0",
4
4
  "description": "Contract tests to ensure data integrity between Oak apps and their data",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -33,7 +33,7 @@
33
33
  "@rollup/plugin-terser": "^0.4.4",
34
34
  "@rollup/plugin-typescript": "^11.1.6",
35
35
  "@semantic-release/git": "^10.0.1",
36
- "@semantic-release/npm": "^12.0.0",
36
+ "@semantic-release/npm": "^13.1.1",
37
37
  "@typescript-eslint/eslint-plugin": "^6.21.0",
38
38
  "eslint": "^8.57.0",
39
39
  "eslint-config-standard-with-typescript": "^43.0.1",
@@ -48,6 +48,7 @@
48
48
  "rollup-plugin-dts": "^6.1.0",
49
49
  "rollup-plugin-peer-deps-external": "^2.2.4",
50
50
  "rollup-plugin-typescript-paths": "^1.5.0",
51
+ "semantic-release": "^25.0.1",
51
52
  "tslib": "^2.6.2",
52
53
  "typescript": "^5.4.5",
53
54
  "vitest": "^1.5.0",