@duckpic/content-spec 0.2.10 → 0.2.11

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.
@@ -3,6 +3,15 @@ import type { ComponentSpec } from "./ComponentSpec";
3
3
  export declare const VocabularyListPropsSchema: z.ZodObject<{
4
4
  title: z.ZodOptional<z.ZodString>;
5
5
  staticVocabIds: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
6
+ staticVocabItems: z.ZodOptional<z.ZodArray<z.ZodObject<{
7
+ id: z.ZodNumber;
8
+ kind: z.ZodOptional<z.ZodEnum<{
9
+ vocabulary: "vocabulary";
10
+ alternative: "alternative";
11
+ }>>;
12
+ vocabularyId: z.ZodOptional<z.ZodNumber>;
13
+ alternativeVocabularyId: z.ZodOptional<z.ZodNumber>;
14
+ }, z.core.$loose>>>;
6
15
  userActions: z.ZodDefault<z.ZodArray<z.ZodEnum<{
7
16
  select: "select";
8
17
  "blur-select": "blur-select";
@@ -1,8 +1,10 @@
1
1
  import { z } from "zod";
2
2
  import { VisibleForLevelsSchema } from "../schema/Level";
3
+ import { VocabularyIdArraySchema, VocabularyItemRefArraySchema, VocabularyRuntimeSelectionSchema, VocabularyListStoredItemSchema, } from "../schema/Vocabulary";
3
4
  export const VocabularyListPropsSchema = z.object({
4
5
  title: z.string().optional(),
5
- staticVocabIds: z.array(z.number()).default([]),
6
+ staticVocabIds: VocabularyIdArraySchema.default([]),
7
+ staticVocabItems: z.array(VocabularyListStoredItemSchema).optional(),
6
8
  userActions: z.array(z.enum(["select", "blur-select", "add-to-my-vocabulary"])).default([]),
7
9
  visibleForLevels: VisibleForLevelsSchema,
8
10
  });
@@ -13,16 +15,21 @@ export const VocabularyListComponentSpec = {
13
15
  io: {
14
16
  inputs: {
15
17
  extraVocabIds: {
16
- schema: z.array(z.number()),
17
- valueType: "VocabId[]",
18
- description: "Additional vocab ids injected at runtime (e.g. incorrect answers)."
18
+ schema: VocabularyRuntimeSelectionSchema,
19
+ valueType: "VocabId[] | VocabItemRef[]",
20
+ description: "Additional vocabulary ids or refs injected at runtime."
19
21
  }
20
22
  },
21
23
  outputs: {
22
24
  selectedVocabIds: {
23
- schema: z.array(z.number()),
25
+ schema: VocabularyIdArraySchema,
24
26
  valueType: "VocabId[]",
25
- description: "Ids the student marked or selected in this list."
27
+ description: "Primary vocabulary ids the student marked or selected in this list."
28
+ },
29
+ selectedVocabRefs: {
30
+ schema: VocabularyItemRefArraySchema,
31
+ valueType: "VocabItemRef[]",
32
+ description: "Exact vocabulary items the student marked or selected in this list."
26
33
  }
27
34
  }
28
35
  },
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export * from "./components/VocabularyList";
8
8
  export * from "./components/SubmitButton";
9
9
  export * from "./schema/PageTree";
10
10
  export * from "./schema/Level";
11
+ export * from "./schema/Vocabulary";
11
12
  import type { ComponentSpec } from "./components/ComponentSpec.ts";
12
13
  export declare const ComponentRegistry: {
13
14
  Text: ComponentSpec;
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ export * from "./components/VocabularyList";
8
8
  export * from "./components/SubmitButton";
9
9
  export * from "./schema/PageTree";
10
10
  export * from "./schema/Level";
11
+ export * from "./schema/Vocabulary";
11
12
  import { TextComponentSpec } from "./components/Text";
12
13
  import { QuizComponentSpec } from "./components/Quiz";
13
14
  import { LayoutComponentSpec } from "./components/Layout";
@@ -0,0 +1,45 @@
1
+ import { z } from "zod";
2
+ export declare const VocabularyItemKindSchema: z.ZodEnum<{
3
+ vocabulary: "vocabulary";
4
+ alternative: "alternative";
5
+ }>;
6
+ export declare const VocabularyItemRefSchema: z.ZodObject<{
7
+ id: z.ZodNumber;
8
+ kind: z.ZodOptional<z.ZodEnum<{
9
+ vocabulary: "vocabulary";
10
+ alternative: "alternative";
11
+ }>>;
12
+ vocabularyId: z.ZodOptional<z.ZodNumber>;
13
+ alternativeVocabularyId: z.ZodOptional<z.ZodNumber>;
14
+ }, z.core.$strip>;
15
+ export declare const VocabularyListStoredItemSchema: z.ZodObject<{
16
+ id: z.ZodNumber;
17
+ kind: z.ZodOptional<z.ZodEnum<{
18
+ vocabulary: "vocabulary";
19
+ alternative: "alternative";
20
+ }>>;
21
+ vocabularyId: z.ZodOptional<z.ZodNumber>;
22
+ alternativeVocabularyId: z.ZodOptional<z.ZodNumber>;
23
+ }, z.core.$loose>;
24
+ export declare const VocabularyItemRefArraySchema: z.ZodArray<z.ZodObject<{
25
+ id: z.ZodNumber;
26
+ kind: z.ZodOptional<z.ZodEnum<{
27
+ vocabulary: "vocabulary";
28
+ alternative: "alternative";
29
+ }>>;
30
+ vocabularyId: z.ZodOptional<z.ZodNumber>;
31
+ alternativeVocabularyId: z.ZodOptional<z.ZodNumber>;
32
+ }, z.core.$strip>>;
33
+ export declare const VocabularyIdArraySchema: z.ZodArray<z.ZodNumber>;
34
+ export declare const VocabularyRuntimeSelectionSchema: z.ZodUnion<readonly [z.ZodArray<z.ZodNumber>, z.ZodArray<z.ZodObject<{
35
+ id: z.ZodNumber;
36
+ kind: z.ZodOptional<z.ZodEnum<{
37
+ vocabulary: "vocabulary";
38
+ alternative: "alternative";
39
+ }>>;
40
+ vocabularyId: z.ZodOptional<z.ZodNumber>;
41
+ alternativeVocabularyId: z.ZodOptional<z.ZodNumber>;
42
+ }, z.core.$strip>>]>;
43
+ export type VocabularyItemKind = z.infer<typeof VocabularyItemKindSchema>;
44
+ export type VocabularyItemRef = z.infer<typeof VocabularyItemRefSchema>;
45
+ export type VocabularyListStoredItem = z.infer<typeof VocabularyListStoredItemSchema>;
@@ -0,0 +1,17 @@
1
+ import { z } from "zod";
2
+ export const VocabularyItemKindSchema = z.enum(["vocabulary", "alternative"]);
3
+ export const VocabularyItemRefSchema = z.object({
4
+ id: z.number(),
5
+ kind: VocabularyItemKindSchema.optional(),
6
+ vocabularyId: z.number().optional(),
7
+ alternativeVocabularyId: z.number().optional(),
8
+ });
9
+ // Stored vocabulary items may be plain refs or hydrated item payloads.
10
+ // Keep this permissive so editor/runtime data survives validation.
11
+ export const VocabularyListStoredItemSchema = VocabularyItemRefSchema.passthrough();
12
+ export const VocabularyItemRefArraySchema = z.array(VocabularyItemRefSchema);
13
+ export const VocabularyIdArraySchema = z.array(z.number());
14
+ export const VocabularyRuntimeSelectionSchema = z.union([
15
+ VocabularyIdArraySchema,
16
+ VocabularyItemRefArraySchema,
17
+ ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duckpic/content-spec",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -1,10 +1,17 @@
1
1
  import { z } from "zod";
2
2
  import type { ComponentSpec } from "./ComponentSpec";
3
3
  import { VisibleForLevelsSchema } from "../schema/Level";
4
+ import {
5
+ VocabularyIdArraySchema,
6
+ VocabularyItemRefArraySchema,
7
+ VocabularyRuntimeSelectionSchema,
8
+ VocabularyListStoredItemSchema,
9
+ } from "../schema/Vocabulary";
4
10
 
5
11
  export const VocabularyListPropsSchema = z.object({
6
12
  title: z.string().optional(),
7
- staticVocabIds: z.array(z.number()).default([]),
13
+ staticVocabIds: VocabularyIdArraySchema.default([]),
14
+ staticVocabItems: z.array(VocabularyListStoredItemSchema).optional(),
8
15
  userActions: z.array(z.enum(["select", "blur-select", "add-to-my-vocabulary"])).default([]),
9
16
  visibleForLevels: VisibleForLevelsSchema,
10
17
  });
@@ -16,16 +23,21 @@ export const VocabularyListComponentSpec: ComponentSpec = {
16
23
  io: {
17
24
  inputs: {
18
25
  extraVocabIds: {
19
- schema: z.array(z.number()),
20
- valueType: "VocabId[]",
21
- description: "Additional vocab ids injected at runtime (e.g. incorrect answers)."
26
+ schema: VocabularyRuntimeSelectionSchema,
27
+ valueType: "VocabId[] | VocabItemRef[]",
28
+ description: "Additional vocabulary ids or refs injected at runtime."
22
29
  }
23
30
  },
24
31
  outputs: {
25
32
  selectedVocabIds: {
26
- schema: z.array(z.number()),
33
+ schema: VocabularyIdArraySchema,
27
34
  valueType: "VocabId[]",
28
- description: "Ids the student marked or selected in this list."
35
+ description: "Primary vocabulary ids the student marked or selected in this list."
36
+ },
37
+ selectedVocabRefs: {
38
+ schema: VocabularyItemRefArraySchema,
39
+ valueType: "VocabItemRef[]",
40
+ description: "Exact vocabulary items the student marked or selected in this list."
29
41
  }
30
42
  }
31
43
  },
package/src/index.ts CHANGED
@@ -8,6 +8,7 @@ export * from "./components/VocabularyList";
8
8
  export * from "./components/SubmitButton";
9
9
  export * from "./schema/PageTree";
10
10
  export * from "./schema/Level";
11
+ export * from "./schema/Vocabulary";
11
12
 
12
13
 
13
14
  import { TextComponentSpec } from "./components/Text";
@@ -0,0 +1,25 @@
1
+ import { z } from "zod";
2
+
3
+ export const VocabularyItemKindSchema = z.enum(["vocabulary", "alternative"]);
4
+
5
+ export const VocabularyItemRefSchema = z.object({
6
+ id: z.number(),
7
+ kind: VocabularyItemKindSchema.optional(),
8
+ vocabularyId: z.number().optional(),
9
+ alternativeVocabularyId: z.number().optional(),
10
+ });
11
+
12
+ // Stored vocabulary items may be plain refs or hydrated item payloads.
13
+ // Keep this permissive so editor/runtime data survives validation.
14
+ export const VocabularyListStoredItemSchema = VocabularyItemRefSchema.passthrough();
15
+
16
+ export const VocabularyItemRefArraySchema = z.array(VocabularyItemRefSchema);
17
+ export const VocabularyIdArraySchema = z.array(z.number());
18
+ export const VocabularyRuntimeSelectionSchema = z.union([
19
+ VocabularyIdArraySchema,
20
+ VocabularyItemRefArraySchema,
21
+ ]);
22
+
23
+ export type VocabularyItemKind = z.infer<typeof VocabularyItemKindSchema>;
24
+ export type VocabularyItemRef = z.infer<typeof VocabularyItemRefSchema>;
25
+ export type VocabularyListStoredItem = z.infer<typeof VocabularyListStoredItemSchema>;