learngraph 0.1.1 → 0.2.0
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/LICENSE +190 -21
- package/README.md +83 -2
- package/dist/cjs/parsers/base.js +189 -0
- package/dist/cjs/parsers/base.js.map +1 -0
- package/dist/cjs/parsers/demo.js +159 -0
- package/dist/cjs/parsers/demo.js.map +1 -0
- package/dist/cjs/parsers/extractor.js +191 -0
- package/dist/cjs/parsers/extractor.js.map +1 -0
- package/dist/cjs/parsers/index.js +43 -4
- package/dist/cjs/parsers/index.js.map +1 -1
- package/dist/cjs/parsers/json.js +157 -0
- package/dist/cjs/parsers/json.js.map +1 -0
- package/dist/cjs/parsers/markdown.js +168 -0
- package/dist/cjs/parsers/markdown.js.map +1 -0
- package/dist/cjs/parsers/samples.js +139 -0
- package/dist/cjs/parsers/samples.js.map +1 -0
- package/dist/cjs/storage/base.js +231 -0
- package/dist/cjs/storage/base.js.map +1 -0
- package/dist/cjs/storage/errors.js +128 -0
- package/dist/cjs/storage/errors.js.map +1 -0
- package/dist/cjs/storage/index.js +92 -5
- package/dist/cjs/storage/index.js.map +1 -1
- package/dist/cjs/storage/levelgraph.js +855 -0
- package/dist/cjs/storage/levelgraph.js.map +1 -0
- package/dist/cjs/storage/memory.js +447 -0
- package/dist/cjs/storage/memory.js.map +1 -0
- package/dist/cjs/storage/neo4j.js +866 -0
- package/dist/cjs/storage/neo4j.js.map +1 -0
- package/dist/cjs/storage/seeds.js +565 -0
- package/dist/cjs/storage/seeds.js.map +1 -0
- package/dist/cjs/types/parser.js +8 -0
- package/dist/cjs/types/parser.js.map +1 -0
- package/dist/esm/parsers/base.js +179 -0
- package/dist/esm/parsers/base.js.map +1 -0
- package/dist/esm/parsers/demo.js +154 -0
- package/dist/esm/parsers/demo.js.map +1 -0
- package/dist/esm/parsers/extractor.js +187 -0
- package/dist/esm/parsers/extractor.js.map +1 -0
- package/dist/esm/parsers/index.js +24 -5
- package/dist/esm/parsers/index.js.map +1 -1
- package/dist/esm/parsers/json.js +153 -0
- package/dist/esm/parsers/json.js.map +1 -0
- package/dist/esm/parsers/markdown.js +164 -0
- package/dist/esm/parsers/markdown.js.map +1 -0
- package/dist/esm/parsers/samples.js +136 -0
- package/dist/esm/parsers/samples.js.map +1 -0
- package/dist/esm/storage/base.js +221 -0
- package/dist/esm/storage/base.js.map +1 -0
- package/dist/esm/storage/errors.js +116 -0
- package/dist/esm/storage/errors.js.map +1 -0
- package/dist/esm/storage/index.js +71 -6
- package/dist/esm/storage/index.js.map +1 -1
- package/dist/esm/storage/levelgraph.js +818 -0
- package/dist/esm/storage/levelgraph.js.map +1 -0
- package/dist/esm/storage/memory.js +443 -0
- package/dist/esm/storage/memory.js.map +1 -0
- package/dist/esm/storage/neo4j.js +829 -0
- package/dist/esm/storage/neo4j.js.map +1 -0
- package/dist/esm/storage/seeds.js +561 -0
- package/dist/esm/storage/seeds.js.map +1 -0
- package/dist/esm/types/parser.js +7 -0
- package/dist/esm/types/parser.js.map +1 -0
- package/dist/types/parsers/base.d.ts +39 -0
- package/dist/types/parsers/base.d.ts.map +1 -0
- package/dist/types/parsers/demo.d.ts +87 -0
- package/dist/types/parsers/demo.d.ts.map +1 -0
- package/dist/types/parsers/extractor.d.ts +43 -0
- package/dist/types/parsers/extractor.d.ts.map +1 -0
- package/dist/types/parsers/index.d.ts +10 -0
- package/dist/types/parsers/index.d.ts.map +1 -1
- package/dist/types/parsers/json.d.ts +71 -0
- package/dist/types/parsers/json.d.ts.map +1 -0
- package/dist/types/parsers/markdown.d.ts +43 -0
- package/dist/types/parsers/markdown.d.ts.map +1 -0
- package/dist/types/parsers/samples.d.ts +27 -0
- package/dist/types/parsers/samples.d.ts.map +1 -0
- package/dist/types/storage/base.d.ts +39 -0
- package/dist/types/storage/base.d.ts.map +1 -0
- package/dist/types/storage/errors.d.ts +74 -0
- package/dist/types/storage/errors.d.ts.map +1 -0
- package/dist/types/storage/index.d.ts +50 -2
- package/dist/types/storage/index.d.ts.map +1 -1
- package/dist/types/storage/levelgraph.d.ts +92 -0
- package/dist/types/storage/levelgraph.d.ts.map +1 -0
- package/dist/types/storage/memory.d.ts +70 -0
- package/dist/types/storage/memory.d.ts.map +1 -0
- package/dist/types/storage/neo4j.d.ts +88 -0
- package/dist/types/storage/neo4j.d.ts.map +1 -0
- package/dist/types/storage/seeds.d.ts +27 -0
- package/dist/types/storage/seeds.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/types/parser.d.ts +208 -0
- package/dist/types/types/parser.d.ts.map +1 -0
- package/package.json +4 -2
- package/scripts/postinstall.js +68 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base parser utilities
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { ParseResult, ParseOptions, ParseStats, LearningObjective, ParseFormat } from '../types/parser.js';
|
|
7
|
+
/**
|
|
8
|
+
* Default parse options
|
|
9
|
+
*/
|
|
10
|
+
export declare const DEFAULT_PARSE_OPTIONS: Required<ParseOptions>;
|
|
11
|
+
/**
|
|
12
|
+
* Extract estimated time from text
|
|
13
|
+
*/
|
|
14
|
+
export declare function extractTime(text: string): number | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Detect if a line is a learning objective
|
|
17
|
+
*/
|
|
18
|
+
export declare function isObjectiveLine(line: string, markers: string[]): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Clean and normalize text
|
|
21
|
+
*/
|
|
22
|
+
export declare function cleanText(text: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Generate a skill name from an objective
|
|
25
|
+
*/
|
|
26
|
+
export declare function objectiveToSkillName(objective: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Create a learning objective from text
|
|
29
|
+
*/
|
|
30
|
+
export declare function createObjective(text: string, section?: string, week?: number): LearningObjective;
|
|
31
|
+
/**
|
|
32
|
+
* Create empty parse result
|
|
33
|
+
*/
|
|
34
|
+
export declare function createEmptyResult(source: string, format: ParseFormat): ParseResult;
|
|
35
|
+
/**
|
|
36
|
+
* Calculate parse statistics
|
|
37
|
+
*/
|
|
38
|
+
export declare function calculateStats(result: ParseResult, startTime: number): ParseStats;
|
|
39
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/parsers/base.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,WAAW,EACZ,MAAM,oBAAoB,CAAC;AAG5B;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,YAAY,CA6BxD,CAAC;AAYF;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAY5D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAGxE;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM9C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CA2B9D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,MAAM,GACZ,iBAAiB,CAmBnB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,WAAW,GAClB,WAAW,CAmBb;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU,CA6BjF"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Demo utilities for quick testing and exploration
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { ParseResult, SkillExtractionResult, ExtractionOptions } from '../types/parser.js';
|
|
7
|
+
import type { SkillNode, PrerequisiteEdge, GraphStats } from '../types/index.js';
|
|
8
|
+
import { type SampleSyllabusName } from './samples.js';
|
|
9
|
+
/**
|
|
10
|
+
* Result of the demo function
|
|
11
|
+
*/
|
|
12
|
+
export interface DemoResult {
|
|
13
|
+
/** Parse result with extracted modules, topics, objectives */
|
|
14
|
+
parseResult: ParseResult;
|
|
15
|
+
/** Skill extraction result */
|
|
16
|
+
extraction: SkillExtractionResult;
|
|
17
|
+
/** Skills created in storage */
|
|
18
|
+
skills: SkillNode[];
|
|
19
|
+
/** Prerequisite edges created */
|
|
20
|
+
edges: PrerequisiteEdge[];
|
|
21
|
+
/** Graph statistics */
|
|
22
|
+
stats: GraphStats;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Try LearnGraph with a sample syllabus
|
|
26
|
+
*
|
|
27
|
+
* This is the easiest way to see LearnGraph in action.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import { tryWithSample } from 'learngraph/parsers';
|
|
32
|
+
*
|
|
33
|
+
* // Try with physics syllabus
|
|
34
|
+
* const result = await tryWithSample('physics');
|
|
35
|
+
* console.log(`Created ${result.skills.length} skills!`);
|
|
36
|
+
* console.log('Skills:', result.skills.map(s => s.name));
|
|
37
|
+
*
|
|
38
|
+
* // Try with kindergarten math
|
|
39
|
+
* const kResult = await tryWithSample('kindergarten');
|
|
40
|
+
* console.log(`Kindergarten: ${kResult.skills.length} skills`);
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function tryWithSample(sample?: SampleSyllabusName): Promise<DemoResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Try LearnGraph with your own syllabus
|
|
46
|
+
*
|
|
47
|
+
* Paste your syllabus as markdown and see the magic happen!
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* import { tryWithSyllabus } from 'learngraph/parsers';
|
|
52
|
+
*
|
|
53
|
+
* const mySyllabus = `
|
|
54
|
+
* # My Course
|
|
55
|
+
*
|
|
56
|
+
* ## Week 1: Introduction
|
|
57
|
+
*
|
|
58
|
+
* ### Learning Objectives
|
|
59
|
+
* - Understand the course structure
|
|
60
|
+
* - Identify key topics
|
|
61
|
+
* - Apply basic concepts
|
|
62
|
+
* `;
|
|
63
|
+
*
|
|
64
|
+
* const result = await tryWithSyllabus(mySyllabus);
|
|
65
|
+
* console.log('Found', result.parseResult.stats.objectiveCount, 'objectives');
|
|
66
|
+
* console.log('Created', result.skills.length, 'skills');
|
|
67
|
+
*
|
|
68
|
+
* // See the skills
|
|
69
|
+
* for (const skill of result.skills) {
|
|
70
|
+
* console.log(`- ${skill.name} (${skill.bloomLevel}, difficulty: ${skill.difficulty})`);
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare function tryWithSyllabus(syllabus: string, options?: ExtractionOptions): Promise<DemoResult>;
|
|
75
|
+
/**
|
|
76
|
+
* Quick console output of demo results
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* import { tryWithSample, printDemoResults } from 'learngraph/parsers';
|
|
81
|
+
*
|
|
82
|
+
* const result = await tryWithSample('physics');
|
|
83
|
+
* printDemoResults(result);
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare function printDemoResults(result: DemoResult): void;
|
|
87
|
+
//# sourceMappingURL=demo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demo.d.ts","sourceRoot":"","sources":["../../../src/parsers/demo.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAChG,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAIjF,OAAO,EAAkB,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,8DAA8D;IAC9D,WAAW,EAAE,WAAW,CAAC;IACzB,8BAA8B;IAC9B,UAAU,EAAE,qBAAqB,CAAC;IAClC,gCAAgC;IAChC,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,iCAAiC;IACjC,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,uBAAuB;IACvB,KAAK,EAAE,UAAU,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,aAAa,CACjC,MAAM,GAAE,kBAA8B,GACrC,OAAO,CAAC,UAAU,CAAC,CAGrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,UAAU,CAAC,CA2DrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAsCzD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill extractor - converts parsed syllabi into graph-ready skills
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { SkillExtractor, ParseResult, ExtractionOptions, SkillExtractionResult } from '../types/parser.js';
|
|
7
|
+
/**
|
|
8
|
+
* Default extraction options
|
|
9
|
+
*/
|
|
10
|
+
export declare const DEFAULT_EXTRACTION_OPTIONS: Required<ExtractionOptions>;
|
|
11
|
+
/**
|
|
12
|
+
* Basic skill extractor
|
|
13
|
+
*
|
|
14
|
+
* Converts parsed syllabus content into skills ready for graph storage.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { MarkdownParser, BasicExtractor } from 'learngraph/parsers';
|
|
19
|
+
*
|
|
20
|
+
* const parser = new MarkdownParser();
|
|
21
|
+
* const extractor = new BasicExtractor();
|
|
22
|
+
*
|
|
23
|
+
* const parseResult = await parser.parse(syllabusMarkdown);
|
|
24
|
+
* const extraction = await extractor.extract(parseResult, {
|
|
25
|
+
* tags: ['physics', 'intro'],
|
|
26
|
+
* domain: 'Physics',
|
|
27
|
+
* gradeLevel: 'Undergraduate'
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* // Now create skills in storage
|
|
31
|
+
* for (const { skill } of extraction.skills) {
|
|
32
|
+
* await storage.createSkill(skill);
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare class BasicExtractor implements SkillExtractor {
|
|
37
|
+
extract(parseResult: ParseResult, options?: ExtractionOptions): Promise<SkillExtractionResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Suggest prerequisite relationships based on skill order and Bloom's levels
|
|
40
|
+
*/
|
|
41
|
+
private suggestEdges;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractor.d.ts","sourceRoot":"","sources":["../../../src/parsers/extractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,qBAAqB,EAKtB,MAAM,oBAAoB,CAAC;AAI5B;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,iBAAiB,CAalE,CAAC;AAwBF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,cAAe,YAAW,cAAc;IAC7C,OAAO,CACX,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,qBAAqB,CAAC;IAmGjC;;OAEG;IACH,OAAO,CAAC,YAAY;CAkCrB"}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Content parsers for educational materials
|
|
3
3
|
*
|
|
4
|
+
* Parse syllabi, course outlines, and learning objectives into
|
|
5
|
+
* structured skill graphs.
|
|
6
|
+
*
|
|
4
7
|
* @packageDocumentation
|
|
5
8
|
*/
|
|
9
|
+
export type { ParseFormat, DocumentMetadata, LearningObjective, Topic, Module, ParseResult, ParseWarning, ParseStats, ExtractedSkill, SkillExtractionResult, ParseOptions, ExtractionOptions, Parser, SkillExtractor, } from '../types/parser.js';
|
|
10
|
+
export { MarkdownParser } from './markdown.js';
|
|
11
|
+
export { JSONParser, type SyllabusJSON } from './json.js';
|
|
12
|
+
export { BasicExtractor, DEFAULT_EXTRACTION_OPTIONS } from './extractor.js';
|
|
13
|
+
export { DEFAULT_PARSE_OPTIONS, extractTime, isObjectiveLine, cleanText, objectiveToSkillName, createObjective, } from './base.js';
|
|
14
|
+
export { PHYSICS_101_SYLLABUS, KINDERGARTEN_MATH_SYLLABUS, PROGRAMMING_101_SYLLABUS, SAMPLE_SYLLABI, type SampleSyllabusName, } from './samples.js';
|
|
15
|
+
export { tryWithSample, tryWithSyllabus, printDemoResults, type DemoResult, } from './demo.js';
|
|
6
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/parsers/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/parsers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,EACL,MAAM,EACN,WAAW,EACX,YAAY,EACZ,UAAU,EACV,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,iBAAiB,EACjB,MAAM,EACN,cAAc,GACf,MAAM,oBAAoB,CAAC;AAK5B,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAK1D,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAK5E,OAAO,EACL,qBAAqB,EACrB,WAAW,EACX,eAAe,EACf,SAAS,EACT,oBAAoB,EACpB,eAAe,GAChB,MAAM,WAAW,CAAC;AAKnB,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,cAAc,EACd,KAAK,kBAAkB,GACxB,MAAM,cAAc,CAAC;AAKtB,OAAO,EACL,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,KAAK,UAAU,GAChB,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON/YAML syllabus parser
|
|
3
|
+
*
|
|
4
|
+
* Parses structured JSON or YAML syllabi into the standard format.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
import type { Parser, ParseResult, ParseOptions } from '../types/parser.js';
|
|
9
|
+
/**
|
|
10
|
+
* Expected JSON structure for syllabus input
|
|
11
|
+
*/
|
|
12
|
+
export interface SyllabusJSON {
|
|
13
|
+
title?: string;
|
|
14
|
+
course?: string;
|
|
15
|
+
institution?: string;
|
|
16
|
+
gradeLevel?: string;
|
|
17
|
+
modules?: Array<{
|
|
18
|
+
id?: string;
|
|
19
|
+
title: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
week?: number;
|
|
22
|
+
estimatedMinutes?: number;
|
|
23
|
+
topics?: Array<{
|
|
24
|
+
name: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
estimatedMinutes?: number;
|
|
27
|
+
objectives?: string[];
|
|
28
|
+
}>;
|
|
29
|
+
objectives?: string[];
|
|
30
|
+
}>;
|
|
31
|
+
topics?: Array<{
|
|
32
|
+
name: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
estimatedMinutes?: number;
|
|
35
|
+
objectives?: string[];
|
|
36
|
+
}>;
|
|
37
|
+
objectives?: string[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* JSON/YAML parser for structured syllabi
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* import { JSONParser } from 'learngraph/parsers';
|
|
45
|
+
*
|
|
46
|
+
* const parser = new JSONParser();
|
|
47
|
+
* const result = await parser.parse(JSON.stringify({
|
|
48
|
+
* title: "Kindergarten Math",
|
|
49
|
+
* modules: [
|
|
50
|
+
* {
|
|
51
|
+
* title: "Counting",
|
|
52
|
+
* week: 1,
|
|
53
|
+
* objectives: [
|
|
54
|
+
* "Count objects from 1 to 10",
|
|
55
|
+
* "Recognize number symbols 1-10",
|
|
56
|
+
* "Compare groups using more, less, same"
|
|
57
|
+
* ]
|
|
58
|
+
* }
|
|
59
|
+
* ]
|
|
60
|
+
* }));
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare class JSONParser implements Parser {
|
|
64
|
+
readonly format: "json";
|
|
65
|
+
parse(content: string, _options?: ParseOptions): Promise<ParseResult>;
|
|
66
|
+
/**
|
|
67
|
+
* Parse simple key-value format (basic YAML-like)
|
|
68
|
+
*/
|
|
69
|
+
private parseSimpleFormat;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/parsers/json.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,MAAM,EACN,WAAW,EACX,YAAY,EAGb,MAAM,oBAAoB,CAAC;AAG5B;;GAEG;AACH,MAAM,WAAW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-formatted syllabi into structured content.
|
|
5
|
+
* Works with common syllabus formats from universities and K-12.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import type { Parser, ParseResult, ParseOptions } from '../types/parser.js';
|
|
10
|
+
/**
|
|
11
|
+
* Markdown parser for syllabi and course outlines
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { MarkdownParser } from 'learngraph/parsers';
|
|
16
|
+
*
|
|
17
|
+
* const parser = new MarkdownParser();
|
|
18
|
+
* const result = await parser.parse(`
|
|
19
|
+
* # Introduction to Physics
|
|
20
|
+
*
|
|
21
|
+
* ## Week 1: Motion
|
|
22
|
+
*
|
|
23
|
+
* ### Learning Objectives
|
|
24
|
+
* - Describe the relationship between position, velocity, and acceleration
|
|
25
|
+
* - Calculate velocity from displacement and time
|
|
26
|
+
* - Apply kinematic equations to solve motion problems
|
|
27
|
+
*
|
|
28
|
+
* ## Week 2: Forces
|
|
29
|
+
*
|
|
30
|
+
* ### Learning Objectives
|
|
31
|
+
* - Identify forces acting on objects
|
|
32
|
+
* - Apply Newton's laws to predict motion
|
|
33
|
+
* `);
|
|
34
|
+
*
|
|
35
|
+
* console.log(result.modules); // 2 modules (Week 1, Week 2)
|
|
36
|
+
* console.log(result.stats.objectiveCount); // 5 objectives
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare class MarkdownParser implements Parser {
|
|
40
|
+
readonly format: "markdown";
|
|
41
|
+
parse(content: string, options?: ParseOptions): Promise<ParseResult>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../src/parsers/markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,MAAM,EACN,WAAW,EACX,YAAY,EAIb,MAAM,oBAAoB,CAAC;AAU5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,cAAe,YAAW,MAAM;IAC3C,QAAQ,CAAC,MAAM,EAAG,UAAU,CAAU;IAEhC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;CA4J3E"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sample syllabi for testing and demonstration
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Sample physics syllabus (university level)
|
|
8
|
+
*/
|
|
9
|
+
export declare const PHYSICS_101_SYLLABUS = "# Introduction to Physics\n\n## Course Information\nPHYS 101 - Introduction to Physics\nFall Semester\n\n## Week 1: Motion and Kinematics\n\n### Learning Objectives\n- Define position, displacement, velocity, and acceleration\n- Calculate average and instantaneous velocity from position data\n- Apply kinematic equations to solve motion problems in one dimension\n- Analyze position-time and velocity-time graphs\n\n## Week 2: Forces and Newton's Laws\n\n### Learning Objectives\n- Identify all forces acting on an object using free-body diagrams\n- Apply Newton's First Law to explain equilibrium conditions\n- Calculate net force and acceleration using Newton's Second Law\n- Analyze action-reaction pairs using Newton's Third Law\n\n## Week 3: Work and Energy\n\n### Learning Objectives\n- Calculate work done by constant and variable forces\n- Apply the work-energy theorem to solve problems\n- Distinguish between kinetic and potential energy\n- Analyze systems using conservation of energy\n\n## Week 4: Momentum and Collisions\n\n### Learning Objectives\n- Calculate linear momentum of objects and systems\n- Apply impulse-momentum theorem to analyze collisions\n- Distinguish between elastic and inelastic collisions\n- Solve collision problems using conservation of momentum\n";
|
|
10
|
+
/**
|
|
11
|
+
* Sample kindergarten math syllabus
|
|
12
|
+
*/
|
|
13
|
+
export declare const KINDERGARTEN_MATH_SYLLABUS = "# Kindergarten Mathematics\n\n## Course Information\nGrade: Kindergarten\nSubject: Mathematics\n\n## Unit 1: Counting and Cardinality\n\n### Learning Objectives\n- Count objects from 1 to 20\n- Recognize and write number symbols 0-20\n- Compare groups using words: more, less, same\n- Understand that the last number counted tells how many\n\n## Unit 2: Number Operations\n\n### Learning Objectives\n- Understand addition as putting together\n- Understand subtraction as taking apart\n- Represent addition and subtraction with objects\n- Solve simple addition problems within 10\n\n## Unit 3: Shapes and Geometry\n\n### Learning Objectives\n- Identify circles, squares, triangles, and rectangles\n- Describe shapes using words like sides and corners\n- Compare shapes by size and orientation\n- Create pictures using basic shapes\n\n## Unit 4: Measurement\n\n### Learning Objectives\n- Compare objects by length (longer, shorter)\n- Compare objects by weight (heavier, lighter)\n- Sort objects by size, color, or shape\n- Describe position using words: above, below, beside\n";
|
|
14
|
+
/**
|
|
15
|
+
* Sample programming course syllabus
|
|
16
|
+
*/
|
|
17
|
+
export declare const PROGRAMMING_101_SYLLABUS = "# Introduction to Programming\n\n## Course Information\nCS 101 - Introduction to Programming with Python\n\n## Module 1: Getting Started\n\n### Learning Objectives\n- Install and configure Python development environment\n- Write and execute a simple Python program\n- Identify syntax errors in Python code\n- Use print statements to display output\n\n## Module 2: Variables and Data Types\n\n### Learning Objectives\n- Define variables and assign values\n- Distinguish between integers, floats, and strings\n- Apply type conversion between data types\n- Calculate results using arithmetic operators\n\n## Module 3: Control Flow\n\n### Learning Objectives\n- Write conditional statements using if-else\n- Evaluate boolean expressions\n- Create loops using for and while statements\n- Design nested control structures\n\n## Module 4: Functions\n\n### Learning Objectives\n- Define functions with parameters\n- Apply return values from functions\n- Design functions that call other functions\n- Analyze scope and local variables\n";
|
|
18
|
+
/**
|
|
19
|
+
* All sample syllabi
|
|
20
|
+
*/
|
|
21
|
+
export declare const SAMPLE_SYLLABI: {
|
|
22
|
+
readonly physics: "# Introduction to Physics\n\n## Course Information\nPHYS 101 - Introduction to Physics\nFall Semester\n\n## Week 1: Motion and Kinematics\n\n### Learning Objectives\n- Define position, displacement, velocity, and acceleration\n- Calculate average and instantaneous velocity from position data\n- Apply kinematic equations to solve motion problems in one dimension\n- Analyze position-time and velocity-time graphs\n\n## Week 2: Forces and Newton's Laws\n\n### Learning Objectives\n- Identify all forces acting on an object using free-body diagrams\n- Apply Newton's First Law to explain equilibrium conditions\n- Calculate net force and acceleration using Newton's Second Law\n- Analyze action-reaction pairs using Newton's Third Law\n\n## Week 3: Work and Energy\n\n### Learning Objectives\n- Calculate work done by constant and variable forces\n- Apply the work-energy theorem to solve problems\n- Distinguish between kinetic and potential energy\n- Analyze systems using conservation of energy\n\n## Week 4: Momentum and Collisions\n\n### Learning Objectives\n- Calculate linear momentum of objects and systems\n- Apply impulse-momentum theorem to analyze collisions\n- Distinguish between elastic and inelastic collisions\n- Solve collision problems using conservation of momentum\n";
|
|
23
|
+
readonly kindergarten: "# Kindergarten Mathematics\n\n## Course Information\nGrade: Kindergarten\nSubject: Mathematics\n\n## Unit 1: Counting and Cardinality\n\n### Learning Objectives\n- Count objects from 1 to 20\n- Recognize and write number symbols 0-20\n- Compare groups using words: more, less, same\n- Understand that the last number counted tells how many\n\n## Unit 2: Number Operations\n\n### Learning Objectives\n- Understand addition as putting together\n- Understand subtraction as taking apart\n- Represent addition and subtraction with objects\n- Solve simple addition problems within 10\n\n## Unit 3: Shapes and Geometry\n\n### Learning Objectives\n- Identify circles, squares, triangles, and rectangles\n- Describe shapes using words like sides and corners\n- Compare shapes by size and orientation\n- Create pictures using basic shapes\n\n## Unit 4: Measurement\n\n### Learning Objectives\n- Compare objects by length (longer, shorter)\n- Compare objects by weight (heavier, lighter)\n- Sort objects by size, color, or shape\n- Describe position using words: above, below, beside\n";
|
|
24
|
+
readonly programming: "# Introduction to Programming\n\n## Course Information\nCS 101 - Introduction to Programming with Python\n\n## Module 1: Getting Started\n\n### Learning Objectives\n- Install and configure Python development environment\n- Write and execute a simple Python program\n- Identify syntax errors in Python code\n- Use print statements to display output\n\n## Module 2: Variables and Data Types\n\n### Learning Objectives\n- Define variables and assign values\n- Distinguish between integers, floats, and strings\n- Apply type conversion between data types\n- Calculate results using arithmetic operators\n\n## Module 3: Control Flow\n\n### Learning Objectives\n- Write conditional statements using if-else\n- Evaluate boolean expressions\n- Create loops using for and while statements\n- Design nested control structures\n\n## Module 4: Functions\n\n### Learning Objectives\n- Define functions with parameters\n- Apply return values from functions\n- Design functions that call other functions\n- Analyze scope and local variables\n";
|
|
25
|
+
};
|
|
26
|
+
export type SampleSyllabusName = keyof typeof SAMPLE_SYLLABI;
|
|
27
|
+
//# sourceMappingURL=samples.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"samples.d.ts","sourceRoot":"","sources":["../../../src/parsers/samples.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,oBAAoB,2wCAqChC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,wjCAqCtC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,wgCAoCpC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc;;;;CAIjB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,cAAc,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class and utilities for storage adapters
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { SkillNode, SkillNodeInput, PrerequisiteEdge, PrerequisiteEdgeInput, GraphStats } from '../types/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Generate a unique ID with optional prefix
|
|
9
|
+
*/
|
|
10
|
+
export declare function generateId(prefix?: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Get current ISO timestamp
|
|
13
|
+
*/
|
|
14
|
+
export declare function nowISO(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Convert SkillNodeInput to full SkillNode with generated fields
|
|
17
|
+
*/
|
|
18
|
+
export declare function inputToSkillNode(input: SkillNodeInput): SkillNode;
|
|
19
|
+
/**
|
|
20
|
+
* Convert PrerequisiteEdgeInput to full PrerequisiteEdge with generated fields
|
|
21
|
+
*/
|
|
22
|
+
export declare function inputToEdge(input: PrerequisiteEdgeInput): PrerequisiteEdge;
|
|
23
|
+
/**
|
|
24
|
+
* Validate skill input data
|
|
25
|
+
*/
|
|
26
|
+
export declare function validateSkillInput(input: SkillNodeInput): void;
|
|
27
|
+
/**
|
|
28
|
+
* Validate edge input data
|
|
29
|
+
*/
|
|
30
|
+
export declare function validateEdgeInput(input: PrerequisiteEdgeInput): void;
|
|
31
|
+
/**
|
|
32
|
+
* Ensure adapter is connected before operations
|
|
33
|
+
*/
|
|
34
|
+
export declare function requireConnection(connected: boolean): void;
|
|
35
|
+
/**
|
|
36
|
+
* Calculate graph statistics from nodes and edges
|
|
37
|
+
*/
|
|
38
|
+
export declare function calculateStats(nodes: SkillNode[], edges: PrerequisiteEdge[]): GraphStats;
|
|
39
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/storage/base.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EACX,MAAM,mBAAmB,CAAC;AAI3B;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,SAAK,GAAG,MAAM,CAI9C;AAED;;GAEG;AACH,wBAAgB,MAAM,IAAI,MAAM,CAE/B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,CA6BjE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,qBAAqB,GAAG,gBAAgB,CAiB1E;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CA4B9D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,qBAAqB,GAAG,IAAI,CAwBpE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAI1D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,SAAS,EAAE,EAClB,KAAK,EAAE,gBAAgB,EAAE,GACxB,UAAU,CAkHZ"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage-specific errors for LearnGraph
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Base error class for storage operations
|
|
8
|
+
*/
|
|
9
|
+
export declare class StorageError extends Error {
|
|
10
|
+
readonly code: string;
|
|
11
|
+
readonly cause?: Error | undefined;
|
|
12
|
+
constructor(message: string, code: string, cause?: Error | undefined);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Thrown when connection to storage backend fails
|
|
16
|
+
*/
|
|
17
|
+
export declare class ConnectionError extends StorageError {
|
|
18
|
+
constructor(message: string, cause?: Error);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Thrown when attempting operation without active connection
|
|
22
|
+
*/
|
|
23
|
+
export declare class NotConnectedError extends StorageError {
|
|
24
|
+
constructor();
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Thrown when a skill or edge is not found
|
|
28
|
+
*/
|
|
29
|
+
export declare class NotFoundError extends StorageError {
|
|
30
|
+
readonly entityType: 'skill' | 'edge';
|
|
31
|
+
readonly entityId: string;
|
|
32
|
+
constructor(entityType: 'skill' | 'edge', entityId: string);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Thrown when attempting to create a duplicate entity
|
|
36
|
+
*/
|
|
37
|
+
export declare class DuplicateError extends StorageError {
|
|
38
|
+
readonly entityType: 'skill' | 'edge';
|
|
39
|
+
readonly entityId: string;
|
|
40
|
+
constructor(entityType: 'skill' | 'edge', entityId: string);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Thrown when edge references non-existent skill
|
|
44
|
+
*/
|
|
45
|
+
export declare class ReferenceError extends StorageError {
|
|
46
|
+
readonly edgeId: string;
|
|
47
|
+
readonly missingSkillId: string;
|
|
48
|
+
readonly role: 'source' | 'target';
|
|
49
|
+
constructor(edgeId: string, missingSkillId: string, role: 'source' | 'target');
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Thrown when data validation fails
|
|
53
|
+
*/
|
|
54
|
+
export declare class ValidationError extends StorageError {
|
|
55
|
+
readonly field?: string | undefined;
|
|
56
|
+
readonly value?: unknown | undefined;
|
|
57
|
+
constructor(message: string, field?: string | undefined, value?: unknown | undefined);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Thrown when a query times out
|
|
61
|
+
*/
|
|
62
|
+
export declare class TimeoutError extends StorageError {
|
|
63
|
+
readonly operation: string;
|
|
64
|
+
readonly timeoutMs: number;
|
|
65
|
+
constructor(operation: string, timeoutMs: number);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Thrown when a cycle is detected in the graph
|
|
69
|
+
*/
|
|
70
|
+
export declare class CycleDetectedError extends StorageError {
|
|
71
|
+
readonly path: string[];
|
|
72
|
+
constructor(path: string[]);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/storage/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,qBAAa,YAAa,SAAQ,KAAK;aAGnB,IAAI,EAAE,MAAM;aACZ,KAAK,CAAC,EAAE,KAAK;gBAF7B,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,KAAK,YAAA;CAMhC;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,YAAY;gBACnC,OAAO,EAA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+
* Graph storage adapters for LearnGraph
|
|
3
|
+
*
|
|
4
|
+
* Provides a unified interface for storing skill graphs with multiple
|
|
5
|
+
* backend options:
|
|
6
|
+
* - **MemoryStorage**: In-memory storage for testing
|
|
7
|
+
* - **LevelGraphStorage**: Browser/local storage using triples
|
|
8
|
+
* - **Neo4jStorage**: Production graph database
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { MemoryStorage, Neo4jStorage, LevelGraphStorage } from 'learngraph/storage';
|
|
13
|
+
*
|
|
14
|
+
* // For testing
|
|
15
|
+
* const testStorage = new MemoryStorage();
|
|
16
|
+
* await testStorage.connect({ backend: 'memory' });
|
|
17
|
+
*
|
|
18
|
+
* // For browser/local development
|
|
19
|
+
* const localStorage = new LevelGraphStorage();
|
|
20
|
+
* await localStorage.connect({ backend: 'levelgraph', path: './my-graph' });
|
|
21
|
+
*
|
|
22
|
+
* // For production
|
|
23
|
+
* const prodStorage = new Neo4jStorage();
|
|
24
|
+
* await prodStorage.connect({
|
|
25
|
+
* backend: 'neo4j',
|
|
26
|
+
* uri: 'bolt://localhost:7687',
|
|
27
|
+
* username: 'neo4j',
|
|
28
|
+
* password: 'password',
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* // Same API for all!
|
|
32
|
+
* const skill = await storage.createSkill({ ... });
|
|
33
|
+
* const prereqs = await storage.getPrerequisitesOf(skill.id);
|
|
34
|
+
* ```
|
|
3
35
|
*
|
|
4
36
|
* @packageDocumentation
|
|
5
37
|
*/
|
|
6
|
-
export type { StorageBackend, StorageConfig, Neo4jConfig, LevelGraphConfig, MemoryConfig, ConnectionStatus, ImportResult, GraphStorage, StorageFactory, } from '../types/storage.js';
|
|
38
|
+
export type { StorageBackend, StorageConfig, StorageConfigBase, Neo4jConfig, LevelGraphConfig, MemoryConfig, ConnectionStatus, ImportResult, GraphStorage, StorageFactory, } from '../types/storage.js';
|
|
39
|
+
export { StorageError, ConnectionError, NotConnectedError, NotFoundError, DuplicateError, ReferenceError, ValidationError, TimeoutError, CycleDetectedError, } from './errors.js';
|
|
40
|
+
export { generateId, nowISO, inputToSkillNode, inputToEdge, validateSkillInput, validateEdgeInput, calculateStats, } from './base.js';
|
|
41
|
+
export { MemoryStorage } from './memory.js';
|
|
42
|
+
export { LevelGraphStorage } from './levelgraph.js';
|
|
43
|
+
export { Neo4jStorage } from './neo4j.js';
|
|
44
|
+
import type { StorageConfig, GraphStorage } from '../types/storage.js';
|
|
45
|
+
/**
|
|
46
|
+
* Create a storage adapter based on configuration.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const storage = createStorage({ backend: 'memory' });
|
|
51
|
+
* await storage.connect({ backend: 'memory' });
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function createStorage(config: StorageConfig): GraphStorage;
|
|
7
55
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAKH,YAAY,EACV,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,cAAc,GACf,MAAM,qBAAqB,CAAC;AAK7B,OAAO,EACL,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,cAAc,EACd,eAAe,EACf,YAAY,EACZ,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAKrB,OAAO,EACL,UAAU,EACV,MAAM,EACN,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,GACf,MAAM,WAAW,CAAC;AAKnB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAK1C,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAKvE;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,YAAY,CAWjE"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LevelGraph storage adapter
|
|
3
|
+
*
|
|
4
|
+
* Browser-compatible graph storage using LevelGraph (triple store)
|
|
5
|
+
* built on LevelDB/IndexedDB.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import type { SkillNode, SkillId, SkillNodeInput, SkillNodeUpdate, PrerequisiteEdge, EdgeId, PrerequisiteEdgeInput, GraphStorage, StorageConfig, ConnectionStatus, ImportResult, GraphExport, GraphStats, Subgraph, SkillQuery } from '../types/index.js';
|
|
10
|
+
/**
|
|
11
|
+
* LevelGraph storage adapter.
|
|
12
|
+
*
|
|
13
|
+
* Stores skill graphs using RDF-style triples, compatible with
|
|
14
|
+
* LevelDB (Node.js) and IndexedDB (browser).
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { LevelGraphStorage } from 'learngraph/storage';
|
|
19
|
+
* import levelgraph from 'levelgraph';
|
|
20
|
+
* import level from 'level';
|
|
21
|
+
*
|
|
22
|
+
* // Node.js usage
|
|
23
|
+
* const storage = new LevelGraphStorage();
|
|
24
|
+
* await storage.connect({
|
|
25
|
+
* backend: 'levelgraph',
|
|
26
|
+
* path: './my-graph-db',
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* // Browser usage (with level-js)
|
|
30
|
+
* await storage.connect({
|
|
31
|
+
* backend: 'levelgraph',
|
|
32
|
+
* dbName: 'my-graph-db',
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare class LevelGraphStorage implements GraphStorage {
|
|
37
|
+
private db;
|
|
38
|
+
private _connected;
|
|
39
|
+
private config;
|
|
40
|
+
/**
|
|
41
|
+
* Convert a SkillNode to triples
|
|
42
|
+
*/
|
|
43
|
+
private skillToTriples;
|
|
44
|
+
/**
|
|
45
|
+
* Convert triples back to a SkillNode
|
|
46
|
+
*/
|
|
47
|
+
private triplesToSkill;
|
|
48
|
+
/**
|
|
49
|
+
* Convert a PrerequisiteEdge to triples
|
|
50
|
+
*/
|
|
51
|
+
private edgeToTriples;
|
|
52
|
+
/**
|
|
53
|
+
* Convert triples back to a PrerequisiteEdge
|
|
54
|
+
*/
|
|
55
|
+
private triplesToEdge;
|
|
56
|
+
private put;
|
|
57
|
+
private del;
|
|
58
|
+
private get;
|
|
59
|
+
connect(config: StorageConfig): Promise<void>;
|
|
60
|
+
disconnect(): Promise<void>;
|
|
61
|
+
isConnected(): boolean;
|
|
62
|
+
getStatus(): Promise<ConnectionStatus>;
|
|
63
|
+
createSkill(input: SkillNodeInput): Promise<SkillNode>;
|
|
64
|
+
getSkill(id: SkillId): Promise<SkillNode | null>;
|
|
65
|
+
getSkills(ids: SkillId[]): Promise<SkillNode[]>;
|
|
66
|
+
updateSkill(id: SkillId, updates: SkillNodeUpdate): Promise<SkillNode>;
|
|
67
|
+
deleteSkill(id: SkillId): Promise<void>;
|
|
68
|
+
findSkills(query: Partial<SkillQuery>): Promise<SkillNode[]>;
|
|
69
|
+
countSkills(query?: Partial<SkillQuery>): Promise<number>;
|
|
70
|
+
createPrerequisite(input: PrerequisiteEdgeInput): Promise<PrerequisiteEdge>;
|
|
71
|
+
getPrerequisite(id: EdgeId): Promise<PrerequisiteEdge | null>;
|
|
72
|
+
deletePrerequisite(id: EdgeId): Promise<void>;
|
|
73
|
+
findPrerequisites(criteria: {
|
|
74
|
+
sourceId?: SkillId;
|
|
75
|
+
targetId?: SkillId;
|
|
76
|
+
type?: string;
|
|
77
|
+
minStrength?: number;
|
|
78
|
+
}): Promise<PrerequisiteEdge[]>;
|
|
79
|
+
getPrerequisitesOf(skillId: SkillId): Promise<SkillNode[]>;
|
|
80
|
+
getDependentsOf(skillId: SkillId): Promise<SkillNode[]>;
|
|
81
|
+
getSubgraph(rootId: SkillId, depth: number): Promise<Subgraph>;
|
|
82
|
+
getRootSkills(): Promise<SkillNode[]>;
|
|
83
|
+
getLeafSkills(): Promise<SkillNode[]>;
|
|
84
|
+
getPath(fromId: SkillId, toId: SkillId): Promise<SkillNode[] | null>;
|
|
85
|
+
importGraph(nodes: SkillNodeInput[], edges: PrerequisiteEdgeInput[], options?: {
|
|
86
|
+
clearExisting?: boolean;
|
|
87
|
+
}): Promise<ImportResult>;
|
|
88
|
+
exportGraph(): Promise<GraphExport>;
|
|
89
|
+
clearAll(): Promise<void>;
|
|
90
|
+
getStats(): Promise<GraphStats>;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=levelgraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"levelgraph.d.ts","sourceRoot":"","sources":["../../../src/storage/levelgraph.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,OAAO,EACP,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,MAAM,EACN,qBAAqB,EACrB,YAAY,EACZ,aAAa,EAEb,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,UAAU,EACV,QAAQ,EACR,UAAU,EAGX,MAAM,mBAAmB,CAAC;AA+E3B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,iBAAkB,YAAW,YAAY;IACpD,OAAO,CAAC,EAAE,CAA6B;IACvC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,MAAM,CAAiC;IAM/C;;OAEG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