Skip to content

Commit 7c11a82

Browse files
committed
serialize and store datashape schema during reg..
istration
1 parent 307abeb commit 7c11a82

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/studio-ui/src/utils/courseConfigRegistration.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CourseConfig, DataShape, NameSpacer } from '@vue-skuilder/common';
1+
import { CourseConfig, DataShape, NameSpacer, toZodJSON } from '@vue-skuilder/common';
22
import { CourseDBInterface } from '@vue-skuilder/db';
33
import { Displayable, getCurrentUser, ViewComponent } from '@vue-skuilder/common-ui';
44
import { CourseWare } from '@vue-skuilder/courseware';
@@ -132,9 +132,19 @@ export function registerDataShape(
132132
course: dataShape.course,
133133
});
134134

135+
// Generate JSON Schema for the DataShape
136+
let serializedZodSchema: string | undefined;
137+
try {
138+
serializedZodSchema = toZodJSON(dataShape.dataShape);
139+
} catch (error) {
140+
console.warn(` ⚠️ Failed to generate schema for ${namespacedName}:`, error);
141+
serializedZodSchema = undefined;
142+
}
143+
135144
courseConfig.dataShapes.push({
136145
name: namespacedName,
137146
questionTypes: [],
147+
serializedZodSchema,
138148
});
139149

140150
console.log(` ✅ Registered DataShape: ${namespacedName}`);

0 commit comments

Comments
 (0)