@pie-qti/transform-core 0.1.1 → 0.1.5
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.
- package/dist/config/config-loader.d.ts +25 -0
- package/dist/config/config-loader.d.ts.map +1 -0
- package/dist/config/config-loader.js +142 -0
- package/dist/config/config-loader.js.map +1 -0
- package/dist/config/plugin-loader.d.ts +19 -0
- package/dist/config/plugin-loader.d.ts.map +1 -0
- package/dist/config/plugin-loader.js +62 -0
- package/dist/config/plugin-loader.js.map +1 -0
- package/dist/config/vendor-registry.d.ts +21 -0
- package/dist/config/vendor-registry.d.ts.map +1 -0
- package/dist/config/vendor-registry.js +91 -0
- package/dist/config/vendor-registry.js.map +1 -0
- package/dist/detectors/pie-detector.d.ts +19 -0
- package/dist/detectors/pie-detector.d.ts.map +1 -0
- package/dist/detectors/pie-detector.js +46 -0
- package/dist/detectors/pie-detector.js.map +1 -0
- package/dist/detectors/qti-detector.d.ts +20 -0
- package/dist/detectors/qti-detector.d.ts.map +1 -0
- package/dist/detectors/qti-detector.js +34 -0
- package/dist/detectors/qti-detector.js.map +1 -0
- package/dist/detectors/qti22-detector.d.ts +20 -0
- package/dist/detectors/qti22-detector.d.ts.map +1 -0
- package/dist/detectors/qti22-detector.js +34 -0
- package/dist/detectors/qti22-detector.js.map +1 -0
- package/dist/engine/index.d.ts +1 -1
- package/dist/engine/index.d.ts.map +1 -1
- package/dist/engine/index.js +1 -1
- package/dist/engine/index.js.map +1 -1
- package/dist/engine/transform-engine.d.ts +27 -10
- package/dist/engine/transform-engine.d.ts.map +1 -1
- package/dist/engine/transform-engine.js +96 -85
- package/dist/engine/transform-engine.js.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/orchestration/activities/detect-format-activity.d.ts +18 -0
- package/dist/orchestration/activities/detect-format-activity.d.ts.map +1 -0
- package/dist/orchestration/activities/detect-format-activity.js +51 -0
- package/dist/orchestration/activities/detect-format-activity.js.map +1 -0
- package/dist/orchestration/activities/detect-vendor-activity.d.ts +25 -0
- package/dist/orchestration/activities/detect-vendor-activity.d.ts.map +1 -0
- package/dist/orchestration/activities/detect-vendor-activity.js +27 -0
- package/dist/orchestration/activities/detect-vendor-activity.js.map +1 -0
- package/dist/orchestration/activities/index.d.ts +18 -0
- package/dist/orchestration/activities/index.d.ts.map +1 -0
- package/dist/orchestration/activities/index.js +11 -0
- package/dist/orchestration/activities/index.js.map +1 -0
- package/dist/orchestration/activities/parse-xml-activity.d.ts +18 -0
- package/dist/orchestration/activities/parse-xml-activity.d.ts.map +1 -0
- package/dist/orchestration/activities/parse-xml-activity.js +37 -0
- package/dist/orchestration/activities/parse-xml-activity.js.map +1 -0
- package/dist/orchestration/activities/read-content-activity.d.ts +24 -0
- package/dist/orchestration/activities/read-content-activity.d.ts.map +1 -0
- package/dist/orchestration/activities/read-content-activity.js +49 -0
- package/dist/orchestration/activities/read-content-activity.js.map +1 -0
- package/dist/orchestration/activities/transform-qti-to-pie-activity.d.ts +23 -0
- package/dist/orchestration/activities/transform-qti-to-pie-activity.d.ts.map +1 -0
- package/dist/orchestration/activities/transform-qti-to-pie-activity.js +48 -0
- package/dist/orchestration/activities/transform-qti-to-pie-activity.js.map +1 -0
- package/dist/orchestration/activities/validate-qti-activity.d.ts +19 -0
- package/dist/orchestration/activities/validate-qti-activity.d.ts.map +1 -0
- package/dist/orchestration/activities/validate-qti-activity.js +47 -0
- package/dist/orchestration/activities/validate-qti-activity.js.map +1 -0
- package/dist/orchestration/activities/write-content-activity.d.ts +22 -0
- package/dist/orchestration/activities/write-content-activity.d.ts.map +1 -0
- package/dist/orchestration/activities/write-content-activity.js +36 -0
- package/dist/orchestration/activities/write-content-activity.js.map +1 -0
- package/dist/orchestration/in-memory-orchestrator.d.ts +44 -0
- package/dist/orchestration/in-memory-orchestrator.d.ts.map +1 -0
- package/dist/orchestration/in-memory-orchestrator.js +375 -0
- package/dist/orchestration/in-memory-orchestrator.js.map +1 -0
- package/dist/orchestration/index.d.ts +7 -0
- package/dist/orchestration/index.d.ts.map +1 -0
- package/dist/orchestration/index.js +10 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/orchestration/workflows/batch-transform-workflow.d.ts +58 -0
- package/dist/orchestration/workflows/batch-transform-workflow.d.ts.map +1 -0
- package/dist/orchestration/workflows/batch-transform-workflow.js +100 -0
- package/dist/orchestration/workflows/batch-transform-workflow.js.map +1 -0
- package/dist/orchestration/workflows/index.d.ts +8 -0
- package/dist/orchestration/workflows/index.d.ts.map +1 -0
- package/dist/orchestration/workflows/index.js +6 -0
- package/dist/orchestration/workflows/index.js.map +1 -0
- package/dist/orchestration/workflows/transform-item-workflow.d.ts +57 -0
- package/dist/orchestration/workflows/transform-item-workflow.d.ts.map +1 -0
- package/dist/orchestration/workflows/transform-item-workflow.js +148 -0
- package/dist/orchestration/workflows/transform-item-workflow.js.map +1 -0
- package/dist/registry/format-detector-registry.d.ts +55 -0
- package/dist/registry/format-detector-registry.d.ts.map +1 -0
- package/dist/registry/format-detector-registry.js +55 -0
- package/dist/registry/format-detector-registry.js.map +1 -0
- package/dist/registry/index.d.ts +1 -1
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/index.js +1 -1
- package/dist/registry/index.js.map +1 -1
- package/dist/registry/plugin-registry.d.ts +1 -0
- package/dist/registry/plugin-registry.d.ts.map +1 -1
- package/dist/registry/plugin-registry.js +6 -2
- package/dist/registry/plugin-registry.js.map +1 -1
- package/dist/utils/errors.d.ts +79 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +159 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/logger.d.ts +9 -37
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +10 -58
- package/dist/utils/logger.js.map +1 -1
- package/package.json +69 -36
- package/.turbo/turbo-build.log +0 -1
- package/CHANGELOG.md +0 -10
- package/VALIDATION.md +0 -217
- package/src/engine/index.ts +0 -1
- package/src/engine/transform-engine.ts +0 -257
- package/src/index.ts +0 -18
- package/src/registry/index.ts +0 -1
- package/src/registry/plugin-registry.ts +0 -116
- package/src/utils/index.ts +0 -1
- package/src/utils/logger.ts +0 -79
- package/src/utils/validator.ts +0 -193
- package/tests/plugin-registry.test.ts +0 -154
- package/tests/transform-engine.test.ts +0 -168
- package/tests/validator.test.ts +0 -234
- package/tsconfig.json +0 -13
- package/tsconfig.tsbuildinfo +0 -1
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './logger';
|
|
1
|
+
export * from './logger.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './logger';
|
|
1
|
+
export * from './logger.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
package/dist/utils/logger.d.ts
CHANGED
|
@@ -1,40 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Logger Utilities
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export declare
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
error(message: string, itemId?: string): void;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Silent logger (no output)
|
|
16
|
-
*/
|
|
17
|
-
export declare class SilentLogger implements TransformLogger {
|
|
18
|
-
debug(): void;
|
|
19
|
-
info(): void;
|
|
20
|
-
warn(): void;
|
|
21
|
-
error(): void;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Memory logger (stores messages in memory)
|
|
25
|
-
*/
|
|
26
|
-
export declare class MemoryLogger implements TransformLogger {
|
|
27
|
-
messages: Array<{
|
|
28
|
-
level: 'debug' | 'info' | 'warn' | 'error';
|
|
29
|
-
message: string;
|
|
30
|
-
itemId?: string;
|
|
31
|
-
timestamp: Date;
|
|
32
|
-
}>;
|
|
33
|
-
debug(message: string, itemId?: string): void;
|
|
34
|
-
info(message: string, itemId?: string): void;
|
|
35
|
-
warn(message: string, itemId?: string): void;
|
|
36
|
-
error(message: string, itemId?: string): void;
|
|
37
|
-
clear(): void;
|
|
38
|
-
getMessages(level?: 'debug' | 'info' | 'warn' | 'error'): typeof this.messages;
|
|
39
|
-
}
|
|
3
|
+
*
|
|
4
|
+
* @deprecated Import from @pie-qti/logger/server instead
|
|
5
|
+
* This module re-exports from @pie-qti/logger for backward compatibility
|
|
6
|
+
*/
|
|
7
|
+
import { ConsoleLogger as ServerConsoleLogger, JsonLogger as ServerJsonLogger, SilentLogger as ServerSilentLogger, MemoryLogger as ServerMemoryLogger } from '@pie-qti/logger/server';
|
|
8
|
+
export declare const ConsoleLogger: typeof ServerConsoleLogger;
|
|
9
|
+
export declare const JsonLogger: typeof ServerJsonLogger;
|
|
10
|
+
export declare const SilentLogger: typeof ServerSilentLogger;
|
|
11
|
+
export declare const MemoryLogger: typeof ServerMemoryLogger;
|
|
40
12
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACN,aAAa,IAAI,mBAAmB,EACpC,UAAU,IAAI,gBAAgB,EAC9B,YAAY,IAAI,kBAAkB,EAClC,YAAY,IAAI,kBAAkB,EAClC,MAAM,wBAAwB,CAAC;AAGhC,eAAO,MAAM,aAAa,4BAAsB,CAAC;AACjD,eAAO,MAAM,UAAU,yBAAmB,CAAC;AAC3C,eAAO,MAAM,YAAY,2BAAqB,CAAC;AAC/C,eAAO,MAAM,YAAY,2BAAqB,CAAC"}
|
package/dist/utils/logger.js
CHANGED
|
@@ -1,61 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Logger Utilities
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const prefix = itemId ? `[${itemId}]` : '';
|
|
14
|
-
console.info(`[INFO] ${prefix} ${message}`);
|
|
15
|
-
}
|
|
16
|
-
warn(message, itemId) {
|
|
17
|
-
const prefix = itemId ? `[${itemId}]` : '';
|
|
18
|
-
console.warn(`[WARN] ${prefix} ${message}`);
|
|
19
|
-
}
|
|
20
|
-
error(message, itemId) {
|
|
21
|
-
const prefix = itemId ? `[${itemId}]` : '';
|
|
22
|
-
console.error(`[ERROR] ${prefix} ${message}`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Silent logger (no output)
|
|
27
|
-
*/
|
|
28
|
-
export class SilentLogger {
|
|
29
|
-
debug() { }
|
|
30
|
-
info() { }
|
|
31
|
-
warn() { }
|
|
32
|
-
error() { }
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Memory logger (stores messages in memory)
|
|
36
|
-
*/
|
|
37
|
-
export class MemoryLogger {
|
|
38
|
-
messages = [];
|
|
39
|
-
debug(message, itemId) {
|
|
40
|
-
this.messages.push({ level: 'debug', message, itemId, timestamp: new Date() });
|
|
41
|
-
}
|
|
42
|
-
info(message, itemId) {
|
|
43
|
-
this.messages.push({ level: 'info', message, itemId, timestamp: new Date() });
|
|
44
|
-
}
|
|
45
|
-
warn(message, itemId) {
|
|
46
|
-
this.messages.push({ level: 'warn', message, itemId, timestamp: new Date() });
|
|
47
|
-
}
|
|
48
|
-
error(message, itemId) {
|
|
49
|
-
this.messages.push({ level: 'error', message, itemId, timestamp: new Date() });
|
|
50
|
-
}
|
|
51
|
-
clear() {
|
|
52
|
-
this.messages = [];
|
|
53
|
-
}
|
|
54
|
-
getMessages(level) {
|
|
55
|
-
if (level) {
|
|
56
|
-
return this.messages.filter((msg) => msg.level === level);
|
|
57
|
-
}
|
|
58
|
-
return this.messages;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
3
|
+
*
|
|
4
|
+
* @deprecated Import from @pie-qti/logger/server instead
|
|
5
|
+
* This module re-exports from @pie-qti/logger for backward compatibility
|
|
6
|
+
*/
|
|
7
|
+
import { ConsoleLogger as ServerConsoleLogger, JsonLogger as ServerJsonLogger, SilentLogger as ServerSilentLogger, MemoryLogger as ServerMemoryLogger, } from '@pie-qti/logger/server';
|
|
8
|
+
// Re-export logger classes (types are now exported from @pie-qti/transform-types)
|
|
9
|
+
export const ConsoleLogger = ServerConsoleLogger;
|
|
10
|
+
export const JsonLogger = ServerJsonLogger;
|
|
11
|
+
export const SilentLogger = ServerSilentLogger;
|
|
12
|
+
export const MemoryLogger = ServerMemoryLogger;
|
|
61
13
|
//# sourceMappingURL=logger.js.map
|
package/dist/utils/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACN,aAAa,IAAI,mBAAmB,EACpC,UAAU,IAAI,gBAAgB,EAC9B,YAAY,IAAI,kBAAkB,EAClC,YAAY,IAAI,kBAAkB,GAClC,MAAM,wBAAwB,CAAC;AAEhC,kFAAkF;AAClF,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAC;AACjD,MAAM,CAAC,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAC3C,MAAM,CAAC,MAAM,YAAY,GAAG,kBAAkB,CAAC;AAC/C,MAAM,CAAC,MAAM,YAAY,GAAG,kBAAkB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,38 +1,71 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
2
|
+
"name": "@pie-qti/transform-core",
|
|
3
|
+
"version": "0.1.5",
|
|
4
|
+
"description": "Core transformation engine and plugin system for PIE Transform",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./config/config-loader.js": {
|
|
15
|
+
"types": "./dist/config/config-loader.d.ts",
|
|
16
|
+
"import": "./dist/config/config-loader.js"
|
|
17
|
+
},
|
|
18
|
+
"./config/plugin-loader.js": {
|
|
19
|
+
"types": "./dist/config/plugin-loader.d.ts",
|
|
20
|
+
"import": "./dist/config/plugin-loader.js"
|
|
21
|
+
},
|
|
22
|
+
"./config/vendor-registry.js": {
|
|
23
|
+
"types": "./dist/config/vendor-registry.d.ts",
|
|
24
|
+
"import": "./dist/config/vendor-registry.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc",
|
|
29
|
+
"clean": "rm -rf dist",
|
|
30
|
+
"test": "bun test tests",
|
|
31
|
+
"typecheck": "tsc --noEmit"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"pie",
|
|
35
|
+
"qti",
|
|
36
|
+
"assessment",
|
|
37
|
+
"transformation",
|
|
38
|
+
"plugin"
|
|
39
|
+
],
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@pie-qti/element-schemas": "0.1.5",
|
|
43
|
+
"@pie-qti/logger": "0.1.5",
|
|
44
|
+
"@pie-qti/transform-types": "0.1.5",
|
|
45
|
+
"ajv": "^8.17.1",
|
|
46
|
+
"node-html-parser": "^6.1.13"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"typescript": "^5.9.3",
|
|
50
|
+
"vitest": "^3.0.0"
|
|
51
|
+
},
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "https://github.com/pie-framework/pie-qti.git",
|
|
55
|
+
"directory": "packages/core"
|
|
56
|
+
},
|
|
57
|
+
"homepage": "https://github.com/pie-framework/pie-qti/tree/master/packages/core",
|
|
58
|
+
"bugs": {
|
|
59
|
+
"url": "https://github.com/pie-framework/pie-qti/issues"
|
|
60
|
+
},
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"access": "public"
|
|
63
|
+
},
|
|
64
|
+
"sideEffects": false,
|
|
65
|
+
"engines": {
|
|
66
|
+
"node": ">=20.19.0"
|
|
67
|
+
},
|
|
68
|
+
"files": [
|
|
69
|
+
"dist"
|
|
70
|
+
]
|
|
38
71
|
}
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
$ tsc
|
package/CHANGELOG.md
DELETED
package/VALIDATION.md
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
# PIE Item Validation
|
|
2
|
-
|
|
3
|
-
This package provides validation utilities for PIE items using JSON Schema validation.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
The validation system validates PIE items against:
|
|
8
|
-
1. **Basic structure** - Required fields like `id`, `uuid`, `config`
|
|
9
|
-
2. **Element-specific schemas** - JSON schemas from PIE element packages
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
### Basic Structural Validation
|
|
14
|
-
|
|
15
|
-
For quick validation without schemas:
|
|
16
|
-
|
|
17
|
-
```typescript
|
|
18
|
-
import { validatePieItemStructure } from '@pie-qti/transform-core';
|
|
19
|
-
|
|
20
|
-
const item = {
|
|
21
|
-
id: 'item-001',
|
|
22
|
-
uuid: '123e4567-e89b-12d3-a456-426614174000',
|
|
23
|
-
config: {
|
|
24
|
-
id: '123e4567-e89b-12d3-a456-426614174000',
|
|
25
|
-
models: [],
|
|
26
|
-
elements: {},
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const result = validatePieItemStructure(item);
|
|
31
|
-
|
|
32
|
-
if (!result.valid) {
|
|
33
|
-
console.error('Validation errors:', result.errors);
|
|
34
|
-
}
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### Schema-Based Validation
|
|
38
|
-
|
|
39
|
-
For validating against PIE element schemas:
|
|
40
|
-
|
|
41
|
-
```typescript
|
|
42
|
-
import { PieItemValidator } from '@pie-qti/transform-core';
|
|
43
|
-
|
|
44
|
-
const validator = new PieItemValidator();
|
|
45
|
-
|
|
46
|
-
// Load schema from schemas package (recommended)
|
|
47
|
-
await validator.loadSchemaForElement('@pie-element/multiple-choice');
|
|
48
|
-
|
|
49
|
-
// Or register schema directly
|
|
50
|
-
import { loadSchema } from '@pie-qti/element-schemas';
|
|
51
|
-
const schema = await loadSchema('multiple-choice');
|
|
52
|
-
validator.registerSchema('@pie-element/multiple-choice', schema);
|
|
53
|
-
|
|
54
|
-
// Validate an item
|
|
55
|
-
const result = validator.validate(pieItem);
|
|
56
|
-
|
|
57
|
-
if (!result.valid) {
|
|
58
|
-
for (const error of result.errors!) {
|
|
59
|
-
console.error(`${error.path}: ${error.message}`);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### Validation in Plugins
|
|
65
|
-
|
|
66
|
-
Plugins can implement the optional `validate()` method:
|
|
67
|
-
|
|
68
|
-
```typescript
|
|
69
|
-
export class Qti22ToPiePlugin implements TransformPlugin {
|
|
70
|
-
private validator: PieItemValidator;
|
|
71
|
-
|
|
72
|
-
constructor() {
|
|
73
|
-
this.validator = new PieItemValidator();
|
|
74
|
-
// Load schemas during initialization
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
async validate(output: TransformOutput): Promise<ValidationResult> {
|
|
78
|
-
const results = this.validator.validateMany(output.items);
|
|
79
|
-
|
|
80
|
-
const errors: ValidationError[] = [];
|
|
81
|
-
for (let i = 0; i < results.length; i++) {
|
|
82
|
-
if (!results[i].valid && results[i].errors) {
|
|
83
|
-
for (const error of results[i].errors) {
|
|
84
|
-
errors.push({
|
|
85
|
-
...error,
|
|
86
|
-
path: `items[${i}].${error.path}`,
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return {
|
|
93
|
-
valid: errors.length === 0,
|
|
94
|
-
errors: errors.length > 0 ? errors : undefined,
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
## PIE Element Schemas
|
|
101
|
-
|
|
102
|
-
Schemas are provided by the `@pie-qti/element-schemas` package, which contains JSON schemas synced from PIE element packages:
|
|
103
|
-
|
|
104
|
-
- **pie-schema.json** - Schema for the PIE item model
|
|
105
|
-
- **config-schema.json** - Schema for authoring configuration (future)
|
|
106
|
-
|
|
107
|
-
Available schemas:
|
|
108
|
-
|
|
109
|
-
- `multiple-choice` - Multiple choice questions (from @pie-element/multiple-choice v11.4.3)
|
|
110
|
-
- `extended-text-entry` - Extended text entry questions (from @pie-element/extended-text-entry v13.4.0)
|
|
111
|
-
|
|
112
|
-
See the [schemas package README](../schemas/README.md) for information on keeping schemas up-to-date.
|
|
113
|
-
|
|
114
|
-
## QTI Input Validation
|
|
115
|
-
|
|
116
|
-
For validating QTI input:
|
|
117
|
-
|
|
118
|
-
```typescript
|
|
119
|
-
import { QtiValidator } from '@pie-qti/qti2-to-pie';
|
|
120
|
-
|
|
121
|
-
const validator = new QtiValidator();
|
|
122
|
-
|
|
123
|
-
// Validate QTI XML
|
|
124
|
-
const result = await validator.validate(qtiXml);
|
|
125
|
-
|
|
126
|
-
if (!result.valid) {
|
|
127
|
-
console.error('QTI validation errors:', result.errors);
|
|
128
|
-
}
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
Notes:
|
|
132
|
-
- The current validator performs **well-formedness + structural checks** and warns on missing QTI 2.2 namespace.
|
|
133
|
-
- Full XSD validation is intentionally out of scope for now (it requires resolving/importing the full schema graph).
|
|
134
|
-
|
|
135
|
-
## Validation Results
|
|
136
|
-
|
|
137
|
-
All validation functions return a `ValidationResult`:
|
|
138
|
-
|
|
139
|
-
```typescript
|
|
140
|
-
interface ValidationResult {
|
|
141
|
-
valid: boolean;
|
|
142
|
-
errors?: ValidationError[];
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
interface ValidationError {
|
|
146
|
-
path: string; // JSON path to the error (e.g., "config.models[0].choices")
|
|
147
|
-
message: string; // Human-readable error message
|
|
148
|
-
value?: any; // The invalid value (optional)
|
|
149
|
-
}
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
## CLI Validation
|
|
153
|
-
|
|
154
|
-
The CLI tool can optionally validate transformations:
|
|
155
|
-
|
|
156
|
-
```bash
|
|
157
|
-
pie-transform transform input.xml -o output.json --validate
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
This will:
|
|
161
|
-
1. Transform the QTI to PIE
|
|
162
|
-
2. Validate the output against PIE schemas
|
|
163
|
-
3. Report any validation errors
|
|
164
|
-
4. Exit with error code if validation fails
|
|
165
|
-
|
|
166
|
-
## Integration Testing
|
|
167
|
-
|
|
168
|
-
For testing transformations with validation:
|
|
169
|
-
|
|
170
|
-
```typescript
|
|
171
|
-
import { describe, test, expect } from 'bun:test';
|
|
172
|
-
import { Qti22ToPiePlugin } from '@pie-qti/qti2-to-pie';
|
|
173
|
-
import { PieItemValidator } from '@pie-qti/transform-core';
|
|
174
|
-
|
|
175
|
-
describe('QTI to PIE transformation', () => {
|
|
176
|
-
test('should produce valid PIE output', async () => {
|
|
177
|
-
const plugin = new Qti22ToPiePlugin();
|
|
178
|
-
const validator = new PieItemValidator();
|
|
179
|
-
|
|
180
|
-
// Load schemas for elements you're testing
|
|
181
|
-
await validator.loadSchema(
|
|
182
|
-
'@pie-element/multiple-choice',
|
|
183
|
-
'./schemas/multiple-choice/pie-schema.json'
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
const output = await plugin.transform(
|
|
187
|
-
{ content: qtiXml },
|
|
188
|
-
{ logger: new SilentLogger() }
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
// Validate all items
|
|
192
|
-
const results = validator.validateMany(output.items);
|
|
193
|
-
|
|
194
|
-
for (let i = 0; i < results.length; i++) {
|
|
195
|
-
expect(results[i].valid).toBe(true);
|
|
196
|
-
if (!results[i].valid) {
|
|
197
|
-
console.log(`Item ${i} validation errors:`, results[i].errors);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
});
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
## Best Practices
|
|
205
|
-
|
|
206
|
-
1. **Load schemas once** - Create validator instances during initialization
|
|
207
|
-
2. **Cache schemas** - Don't reload schemas for every validation
|
|
208
|
-
3. **Validate in tests** - Always validate transformer output in tests
|
|
209
|
-
4. **Report clear errors** - Use validation errors to improve transformations
|
|
210
|
-
5. **Version schemas** - Pin to specific PIE element versions
|
|
211
|
-
|
|
212
|
-
## Performance
|
|
213
|
-
|
|
214
|
-
- Schema compilation is done once per element type
|
|
215
|
-
- Validation is fast (~1ms per item for typical items)
|
|
216
|
-
- Use `validateMany()` for batch validation
|
|
217
|
-
- Consider async validation for large batches
|
package/src/engine/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './transform-engine';
|