Add graph schema loading and validation functionality
- Introduced methods for loading and reloading graph schema, including debounced reload on file changes. - Enhanced the semantic mapping builder to utilize the new graph schema loading mechanism for improved caching and live updates. - Added a validation button in the settings interface to check the existence and validity of the graph schema file, providing user feedback on the schema status. - Improved error handling for graph schema loading to ensure clear notifications for users in case of issues.
This commit is contained in:
1 parent
58b6ffffed
commit
1f9211cbc5
5 files changed
+164
-8
No files matched your search
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Graph Schema loader with caching.
|
||||
*/
|
||||
|
||||
import { App, Notice } from "obsidian";
|
||||
import { normalizeVaultPath } from "../settings";
|
||||
import { parseGraphSchema, type GraphSchema } from "../mapping/graphSchema";
|
||||
import { VocabularyLoader } from "../vocab/VocabularyLoader";
|
||||
|
||||
export class GraphSchemaLoader {
|
||||
/**
|
||||
* Load graph schema from vault.
|
||||
*/
|
||||
static async load(app: App, vaultRelativePath: string): Promise<GraphSchema> {
|
||||
const text = await VocabularyLoader.loadText(app, vaultRelativePath);
|
||||
return parseGraphSchema(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that graph schema file exists in vault.
|
||||
*/
|
||||
static async validate(app: App, vaultRelativePath: string): Promise<boolean> {
|
||||
try {
|
||||
await VocabularyLoader.loadText(app, vaultRelativePath);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user