@pie-qti/element-schemas 0.1.1

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 (40) hide show
  1. package/.turbo/turbo-build.log +2 -0
  2. package/CHANGELOG.md +7 -0
  3. package/README.md +107 -0
  4. package/dist/index.d.ts +33 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +80 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/schemas/drag-in-the-blank.json +1181 -0
  9. package/dist/schemas/ebsr.json +2911 -0
  10. package/dist/schemas/explicit-constructed-response.json +1130 -0
  11. package/dist/schemas/extended-text-entry.json +954 -0
  12. package/dist/schemas/hotspot.json +1204 -0
  13. package/dist/schemas/image-cloze-association.json +1085 -0
  14. package/dist/schemas/inline-dropdown.json +1152 -0
  15. package/dist/schemas/match-list.json +170 -0
  16. package/dist/schemas/match.json +1530 -0
  17. package/dist/schemas/multiple-choice.json +1332 -0
  18. package/dist/schemas/passage.json +775 -0
  19. package/dist/schemas/placement-ordering.json +1613 -0
  20. package/dist/schemas/select-text.json +1248 -0
  21. package/package.json +34 -0
  22. package/schema-versions.json +80 -0
  23. package/scripts/check-schema-versions.ts +112 -0
  24. package/scripts/sync-schemas.ts +171 -0
  25. package/src/index.ts +94 -0
  26. package/src/schemas/drag-in-the-blank.json +1181 -0
  27. package/src/schemas/ebsr.json +2911 -0
  28. package/src/schemas/explicit-constructed-response.json +1130 -0
  29. package/src/schemas/extended-text-entry.json +954 -0
  30. package/src/schemas/hotspot.json +1204 -0
  31. package/src/schemas/image-cloze-association.json +1085 -0
  32. package/src/schemas/inline-dropdown.json +1152 -0
  33. package/src/schemas/match-list.json +170 -0
  34. package/src/schemas/match.json +1530 -0
  35. package/src/schemas/multiple-choice.json +1332 -0
  36. package/src/schemas/passage.json +775 -0
  37. package/src/schemas/placement-ordering.json +1613 -0
  38. package/src/schemas/select-text.json +1248 -0
  39. package/tsconfig.json +9 -0
  40. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,2 @@
1
+ $ tsc && bun run copy-schemas
2
+ $ mkdir -p dist/schemas && cp src/schemas/*.json dist/schemas/
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @pie-qti/element-schemas
2
+
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 2243643: Publish the initial public release of all publishable PIE-QTI packages.
package/README.md ADDED
@@ -0,0 +1,107 @@
1
+ # @pie-qti/element-schemas
2
+
3
+ JSON schemas for PIE element validation. This package contains schemas extracted from PIE element packages for use in validation without requiring the full element packages as dependencies.
4
+
5
+ ## Usage
6
+
7
+ ```typescript
8
+ import { loadSchema, loadAllSchemas } from '@pie-qti/element-schemas';
9
+
10
+ // Load a specific schema
11
+ const mcSchema = await loadSchema('multiple-choice');
12
+
13
+ // Load all schemas
14
+ const allSchemas = await loadAllSchemas();
15
+ // Returns Map: '@pie-element/multiple-choice' => schema object
16
+ ```
17
+
18
+ ## Available Schemas
19
+
20
+ - `multiple-choice` - Multiple choice questions
21
+ - `extended-text-entry` - Extended text entry questions
22
+
23
+ ## Keeping Schemas Up-to-Date
24
+
25
+ Schemas are synced from the [pie-elements](https://github.com/pie-framework/pie-elements) repository.
26
+
27
+ ### Prerequisites
28
+
29
+ Ensure `pie-elements` is checked out as a sibling directory:
30
+
31
+ ```bash
32
+ cd /path/to/projects
33
+ git clone https://github.com/pie-framework/pie-elements.git
34
+ ```
35
+
36
+ ### Sync Schemas
37
+
38
+ To update schemas from pie-elements:
39
+
40
+ ```bash
41
+ bun --filter @pie-qti/element-schemas sync
42
+ ```
43
+
44
+ This will:
45
+ 1. Read schemas from `pie-elements/packages/*/docs/pie-schema.json`
46
+ 2. Copy them to `src/schemas/`
47
+ 3. Update `schema-versions.json` with version metadata
48
+ 4. Skip schemas that haven't changed (based on content hash)
49
+
50
+ ### Check for Updates
51
+
52
+ To check if local schemas are up-to-date:
53
+
54
+ ```bash
55
+ bun --filter @pie-qti/element-schemas check-updates
56
+ ```
57
+
58
+ This is useful in CI to detect schema drift.
59
+
60
+ ## Schema Versions
61
+
62
+ The `schema-versions.json` file tracks:
63
+ - Source package version
64
+ - Content hash (SHA-256)
65
+ - Sync timestamp
66
+ - Source file path
67
+
68
+ Example:
69
+ ```json
70
+ {
71
+ "multiple-choice": {
72
+ "version": "7.2.1",
73
+ "schemaHash": "abc123def456",
74
+ "syncedAt": "2025-12-24T10:00:00Z",
75
+ "sourcePath": "/path/to/pie-elements/packages/multiple-choice/docs/pie-schema.json"
76
+ }
77
+ }
78
+ ```
79
+
80
+ ## Adding New Elements
81
+
82
+ To add a new PIE element schema:
83
+
84
+ 1. Add the element name to `ELEMENTS_TO_SYNC` in `scripts/sync-schemas.ts`
85
+ 2. Add the element type to `AVAILABLE_SCHEMAS` in `src/index.ts`
86
+ 3. Run `bun --filter @pie-qti/element-schemas sync` to pull the schema
87
+ 4. Commit the new schema file and updated metadata
88
+
89
+ ## CI Integration
90
+
91
+ Example GitHub Action to check for schema drift:
92
+
93
+ ```yaml
94
+ name: Check PIE Schemas
95
+ on: [push, pull_request]
96
+ jobs:
97
+ check-schemas:
98
+ runs-on: ubuntu-latest
99
+ steps:
100
+ - uses: actions/checkout@v3
101
+ - uses: oven-sh/setup-bun@v1
102
+ - run: bun install
103
+ - name: Clone pie-elements
104
+ run: git clone --depth 1 https://github.com/pie-framework/pie-elements.git ../pie-elements
105
+ - name: Check schema versions
106
+ run: bun --filter @pie-qti/element-schemas check-updates
107
+ ```
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @pie-qti/element-schemas
3
+ *
4
+ * PIE element JSON schemas for validation
5
+ */
6
+ /**
7
+ * Available PIE element schemas
8
+ */
9
+ export declare const AVAILABLE_SCHEMAS: readonly ["multiple-choice", "extended-text-entry", "placement-ordering", "match", "explicit-constructed-response", "select-text", "inline-dropdown", "drag-in-the-blank", "ebsr", "hotspot", "image-cloze-association", "match-list", "passage"];
10
+ export type ElementType = typeof AVAILABLE_SCHEMAS[number];
11
+ /**
12
+ * Load a PIE element schema
13
+ * @param elementType - Element type (e.g., 'multiple-choice')
14
+ * @returns JSON schema object
15
+ */
16
+ export declare function loadSchema(elementType: ElementType): Promise<object>;
17
+ /**
18
+ * Load all available schemas
19
+ * @returns Map of element type to schema
20
+ */
21
+ export declare function loadAllSchemas(): Promise<Map<string, object>>;
22
+ /**
23
+ * Get schema synchronously (must be loaded first)
24
+ * @param elementType - Element type
25
+ * @returns Cached schema or undefined
26
+ */
27
+ export declare function getSchema(elementType: ElementType): object | undefined;
28
+ /**
29
+ * Check if a schema is available
30
+ * @param elementType - Element type to check
31
+ */
32
+ export declare function hasSchema(elementType: string): elementType is ElementType;
33
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH;;GAEG;AACH,eAAO,MAAM,iBAAiB,mPAcpB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAO3D;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAkB1E;AAED;;;GAGG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CASnE;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAEtE;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,WAAW,IAAI,WAAW,CAEzE"}
package/dist/index.js ADDED
@@ -0,0 +1,80 @@
1
+ /**
2
+ * @pie-qti/element-schemas
3
+ *
4
+ * PIE element JSON schemas for validation
5
+ */
6
+ import { readFile } from 'node:fs/promises';
7
+ import { dirname, resolve } from 'node:path';
8
+ import { fileURLToPath } from 'node:url';
9
+ const __dirname = dirname(fileURLToPath(import.meta.url));
10
+ /**
11
+ * Available PIE element schemas
12
+ */
13
+ export const AVAILABLE_SCHEMAS = [
14
+ 'multiple-choice',
15
+ 'extended-text-entry',
16
+ 'placement-ordering',
17
+ 'match',
18
+ 'explicit-constructed-response',
19
+ 'select-text',
20
+ 'inline-dropdown',
21
+ 'drag-in-the-blank',
22
+ 'ebsr',
23
+ 'hotspot',
24
+ 'image-cloze-association',
25
+ 'match-list',
26
+ 'passage',
27
+ ];
28
+ /**
29
+ * Schema cache
30
+ */
31
+ const schemaCache = new Map();
32
+ /**
33
+ * Load a PIE element schema
34
+ * @param elementType - Element type (e.g., 'multiple-choice')
35
+ * @returns JSON schema object
36
+ */
37
+ export async function loadSchema(elementType) {
38
+ // Check cache first
39
+ if (schemaCache.has(elementType)) {
40
+ return schemaCache.get(elementType);
41
+ }
42
+ const schemaPath = resolve(__dirname, `schemas/${elementType}.json`);
43
+ try {
44
+ const content = await readFile(schemaPath, 'utf-8');
45
+ const schema = JSON.parse(content);
46
+ schemaCache.set(elementType, schema);
47
+ return schema;
48
+ }
49
+ catch (error) {
50
+ throw new Error(`Failed to load schema for ${elementType}: ${error.message}`);
51
+ }
52
+ }
53
+ /**
54
+ * Load all available schemas
55
+ * @returns Map of element type to schema
56
+ */
57
+ export async function loadAllSchemas() {
58
+ const schemas = new Map();
59
+ for (const elementType of AVAILABLE_SCHEMAS) {
60
+ const schema = await loadSchema(elementType);
61
+ schemas.set(`@pie-element/${elementType}`, schema);
62
+ }
63
+ return schemas;
64
+ }
65
+ /**
66
+ * Get schema synchronously (must be loaded first)
67
+ * @param elementType - Element type
68
+ * @returns Cached schema or undefined
69
+ */
70
+ export function getSchema(elementType) {
71
+ return schemaCache.get(elementType);
72
+ }
73
+ /**
74
+ * Check if a schema is available
75
+ * @param elementType - Element type to check
76
+ */
77
+ export function hasSchema(elementType) {
78
+ return AVAILABLE_SCHEMAS.includes(elementType);
79
+ }
80
+ //# sourceMappingURL=index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