@pie-qti/element-schemas
v0.1.12
Published
JSON schemas for PIE element validation
Downloads
896
Readme
@pie-qti/element-schemas
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.
Usage
import { loadSchema, loadAllSchemas } from '@pie-qti/element-schemas';
// Load a specific schema
const mcSchema = await loadSchema('multiple-choice');
// Load all schemas
const allSchemas = await loadAllSchemas();
// Returns Map: '@pie-element/multiple-choice' => schema objectAvailable Schemas
multiple-choice- Multiple choice questionsextended-text-entry- Extended text entry questions
Keeping Schemas Up-to-Date
Schemas are synced from the pie-elements repository.
Prerequisites
Ensure pie-elements is checked out as a sibling directory:
cd /path/to/projects
git clone https://github.com/pie-framework/pie-elements.gitSync Schemas
To update schemas from pie-elements:
bun --filter @pie-qti/element-schemas syncThis will:
- Read schemas from
pie-elements/packages/*/docs/pie-schema.json - Copy them to
src/schemas/ - Update
schema-versions.jsonwith version metadata - Skip schemas that haven't changed (based on content hash)
Check for Updates
To check if local schemas are up-to-date:
bun --filter @pie-qti/element-schemas check-updatesThis is useful in CI to detect schema drift.
Schema Versions
The schema-versions.json file tracks:
- Source package version
- Content hash (SHA-256)
- Sync timestamp
- Source file path
Example:
{
"multiple-choice": {
"version": "7.2.1",
"schemaHash": "abc123def456",
"syncedAt": "2025-12-24T10:00:00Z",
"sourcePath": "/path/to/pie-elements/packages/multiple-choice/docs/pie-schema.json"
}
}Adding New Elements
To add a new PIE element schema:
- Add the element name to
ELEMENTS_TO_SYNCinscripts/sync-schemas.ts - Add the element type to
AVAILABLE_SCHEMASinsrc/index.ts - Run
bun --filter @pie-qti/element-schemas syncto pull the schema - Commit the new schema file and updated metadata
CI Integration
Example GitHub Action to check for schema drift:
name: Check PIE Schemas
on: [push, pull_request]
jobs:
check-schemas:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: oven-sh/setup-bun@v1
- run: bun install
- name: Clone pie-elements
run: git clone --depth 1 https://github.com/pie-framework/pie-elements.git ../pie-elements
- name: Check schema versions
run: bun --filter @pie-qti/element-schemas check-updates