@noyrax/5d-database-plugin 0.1.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/ADR_VORSCHLAEGE.md +247 -0
- package/CHROMADB_SETUP.md +69 -0
- package/IMPROVEMENT_ROADMAP.md +435 -0
- package/INSTALLATION_READINESS.md +150 -0
- package/KNOWN_ISSUES.md +210 -0
- package/LICENSE +21 -0
- package/MCP_SERVER_SETUP.md +359 -0
- package/MCP_SERVER_TEST_REPORT.md +206 -0
- package/NOYRAX_INTEGRATION.md +224 -0
- package/QUICK_START.md +316 -0
- package/README.md +240 -0
- package/SETUP_NEW_PROJECT.md +260 -0
- package/SYSTEM_ANALYSIS_REPORT.md +341 -0
- package/out/api/adr-api.d.ts +22 -0
- package/out/api/adr-api.d.ts.map +1 -0
- package/out/api/adr-api.js +38 -0
- package/out/api/adr-api.js.map +1 -0
- package/out/api/bootstrap-api.d.ts +43 -0
- package/out/api/bootstrap-api.d.ts.map +1 -0
- package/out/api/bootstrap-api.js +88 -0
- package/out/api/bootstrap-api.js.map +1 -0
- package/out/api/change-api.d.ts +30 -0
- package/out/api/change-api.d.ts.map +1 -0
- package/out/api/change-api.js +54 -0
- package/out/api/change-api.js.map +1 -0
- package/out/api/context-builder.d.ts +81 -0
- package/out/api/context-builder.d.ts.map +1 -0
- package/out/api/context-builder.js +288 -0
- package/out/api/context-builder.js.map +1 -0
- package/out/api/cross-dimension-api.d.ts +43 -0
- package/out/api/cross-dimension-api.d.ts.map +1 -0
- package/out/api/cross-dimension-api.js +55 -0
- package/out/api/cross-dimension-api.js.map +1 -0
- package/out/api/dependency-api.d.ts +26 -0
- package/out/api/dependency-api.d.ts.map +1 -0
- package/out/api/dependency-api.js +46 -0
- package/out/api/dependency-api.js.map +1 -0
- package/out/api/learning-path-api.d.ts +49 -0
- package/out/api/learning-path-api.d.ts.map +1 -0
- package/out/api/learning-path-api.js +174 -0
- package/out/api/learning-path-api.js.map +1 -0
- package/out/api/module-api.d.ts +26 -0
- package/out/api/module-api.d.ts.map +1 -0
- package/out/api/module-api.js +46 -0
- package/out/api/module-api.js.map +1 -0
- package/out/api/search-api.d.ts +64 -0
- package/out/api/search-api.d.ts.map +1 -0
- package/out/api/search-api.js +235 -0
- package/out/api/search-api.js.map +1 -0
- package/out/api/self-explanation-api.d.ts +71 -0
- package/out/api/self-explanation-api.d.ts.map +1 -0
- package/out/api/self-explanation-api.js +153 -0
- package/out/api/self-explanation-api.js.map +1 -0
- package/out/api/semantic-search-api.d.ts +64 -0
- package/out/api/semantic-search-api.d.ts.map +1 -0
- package/out/api/semantic-search-api.js +205 -0
- package/out/api/semantic-search-api.js.map +1 -0
- package/out/api/symbol-api.d.ts +22 -0
- package/out/api/symbol-api.d.ts.map +1 -0
- package/out/api/symbol-api.js +38 -0
- package/out/api/symbol-api.js.map +1 -0
- package/out/api/vector-api.d.ts +26 -0
- package/out/api/vector-api.d.ts.map +1 -0
- package/out/api/vector-api.js +49 -0
- package/out/api/vector-api.js.map +1 -0
- package/out/cli/embedding-cli.d.ts +3 -0
- package/out/cli/embedding-cli.d.ts.map +1 -0
- package/out/cli/embedding-cli.js +151 -0
- package/out/cli/embedding-cli.js.map +1 -0
- package/out/cli/ingest-cli.d.ts +3 -0
- package/out/cli/ingest-cli.d.ts.map +1 -0
- package/out/cli/ingest-cli.js +145 -0
- package/out/cli/ingest-cli.js.map +1 -0
- package/out/cli/mcp-server-cli.d.ts +3 -0
- package/out/cli/mcp-server-cli.d.ts.map +1 -0
- package/out/cli/mcp-server-cli.js +159 -0
- package/out/cli/mcp-server-cli.js.map +1 -0
- package/out/cli/query-cli.d.ts +3 -0
- package/out/cli/query-cli.d.ts.map +1 -0
- package/out/cli/query-cli.js +217 -0
- package/out/cli/query-cli.js.map +1 -0
- package/out/cli/semantic-search-cli.d.ts +3 -0
- package/out/cli/semantic-search-cli.d.ts.map +1 -0
- package/out/cli/semantic-search-cli.js +196 -0
- package/out/cli/semantic-search-cli.js.map +1 -0
- package/out/cli/test-chromadb.d.ts +3 -0
- package/out/cli/test-chromadb.d.ts.map +1 -0
- package/out/cli/test-chromadb.js +204 -0
- package/out/cli/test-chromadb.js.map +1 -0
- package/out/cli/test-v-dimension.d.ts +3 -0
- package/out/cli/test-v-dimension.d.ts.map +1 -0
- package/out/cli/test-v-dimension.js +330 -0
- package/out/cli/test-v-dimension.js.map +1 -0
- package/out/cli/tool-cli.d.ts +3 -0
- package/out/cli/tool-cli.d.ts.map +1 -0
- package/out/cli/tool-cli.js +237 -0
- package/out/cli/tool-cli.js.map +1 -0
- package/out/cli/verify-openai-key.d.ts +3 -0
- package/out/cli/verify-openai-key.d.ts.map +1 -0
- package/out/cli/verify-openai-key.js +141 -0
- package/out/cli/verify-openai-key.js.map +1 -0
- package/out/cli/verify-vss-status.d.ts +3 -0
- package/out/cli/verify-vss-status.d.ts.map +1 -0
- package/out/cli/verify-vss-status.js +185 -0
- package/out/cli/verify-vss-status.js.map +1 -0
- package/out/core/chromadb-vector-database.d.ts +52 -0
- package/out/core/chromadb-vector-database.d.ts.map +1 -0
- package/out/core/chromadb-vector-database.js +276 -0
- package/out/core/chromadb-vector-database.js.map +1 -0
- package/out/core/docs-path-resolver.d.ts +43 -0
- package/out/core/docs-path-resolver.d.ts.map +1 -0
- package/out/core/docs-path-resolver.js +137 -0
- package/out/core/docs-path-resolver.js.map +1 -0
- package/out/core/id-mapper.d.ts +68 -0
- package/out/core/id-mapper.d.ts.map +1 -0
- package/out/core/id-mapper.js +132 -0
- package/out/core/id-mapper.js.map +1 -0
- package/out/core/migration-manager.d.ts +75 -0
- package/out/core/migration-manager.d.ts.map +1 -0
- package/out/core/migration-manager.js +212 -0
- package/out/core/migration-manager.js.map +1 -0
- package/out/core/multi-db-manager.d.ts +84 -0
- package/out/core/multi-db-manager.d.ts.map +1 -0
- package/out/core/multi-db-manager.js +206 -0
- package/out/core/multi-db-manager.js.map +1 -0
- package/out/core/transaction-manager.d.ts +69 -0
- package/out/core/transaction-manager.d.ts.map +1 -0
- package/out/core/transaction-manager.js +138 -0
- package/out/core/transaction-manager.js.map +1 -0
- package/out/core/vector-database-factory.d.ts +25 -0
- package/out/core/vector-database-factory.d.ts.map +1 -0
- package/out/core/vector-database-factory.js +82 -0
- package/out/core/vector-database-factory.js.map +1 -0
- package/out/core/vector-database-interface.d.ts +50 -0
- package/out/core/vector-database-interface.d.ts.map +1 -0
- package/out/core/vector-database-interface.js +3 -0
- package/out/core/vector-database-interface.js.map +1 -0
- package/out/core/vss-loader.d.ts +29 -0
- package/out/core/vss-loader.d.ts.map +1 -0
- package/out/core/vss-loader.js +150 -0
- package/out/core/vss-loader.js.map +1 -0
- package/out/core/vss-manager.d.ts +81 -0
- package/out/core/vss-manager.d.ts.map +1 -0
- package/out/core/vss-manager.js +323 -0
- package/out/core/vss-manager.js.map +1 -0
- package/out/core/vss-vector-database.d.ts +71 -0
- package/out/core/vss-vector-database.d.ts.map +1 -0
- package/out/core/vss-vector-database.js +284 -0
- package/out/core/vss-vector-database.js.map +1 -0
- package/out/embedding/embedding-generator.d.ts +45 -0
- package/out/embedding/embedding-generator.d.ts.map +1 -0
- package/out/embedding/embedding-generator.js +143 -0
- package/out/embedding/embedding-generator.js.map +1 -0
- package/out/embedding/embedding-pipeline.d.ts +42 -0
- package/out/embedding/embedding-pipeline.d.ts.map +1 -0
- package/out/embedding/embedding-pipeline.js +290 -0
- package/out/embedding/embedding-pipeline.js.map +1 -0
- package/out/extension.d.ts +10 -0
- package/out/extension.d.ts.map +1 -0
- package/out/extension.js +164 -0
- package/out/extension.js.map +1 -0
- package/out/ingestors/adr-ingestor.d.ts +41 -0
- package/out/ingestors/adr-ingestor.d.ts.map +1 -0
- package/out/ingestors/adr-ingestor.js +329 -0
- package/out/ingestors/adr-ingestor.js.map +1 -0
- package/out/ingestors/base-ingestor.d.ts +30 -0
- package/out/ingestors/base-ingestor.d.ts.map +1 -0
- package/out/ingestors/base-ingestor.js +3 -0
- package/out/ingestors/base-ingestor.js.map +1 -0
- package/out/ingestors/change-ingestor.d.ts +36 -0
- package/out/ingestors/change-ingestor.d.ts.map +1 -0
- package/out/ingestors/change-ingestor.js +216 -0
- package/out/ingestors/change-ingestor.js.map +1 -0
- package/out/ingestors/dependency-ingestor.d.ts +32 -0
- package/out/ingestors/dependency-ingestor.d.ts.map +1 -0
- package/out/ingestors/dependency-ingestor.js +194 -0
- package/out/ingestors/dependency-ingestor.js.map +1 -0
- package/out/ingestors/module-ingestor.d.ts +27 -0
- package/out/ingestors/module-ingestor.d.ts.map +1 -0
- package/out/ingestors/module-ingestor.js +137 -0
- package/out/ingestors/module-ingestor.js.map +1 -0
- package/out/ingestors/symbol-ingestor.d.ts +26 -0
- package/out/ingestors/symbol-ingestor.d.ts.map +1 -0
- package/out/ingestors/symbol-ingestor.js +183 -0
- package/out/ingestors/symbol-ingestor.js.map +1 -0
- package/out/mcp/resources/adrs.d.ts +13 -0
- package/out/mcp/resources/adrs.d.ts.map +1 -0
- package/out/mcp/resources/adrs.js +26 -0
- package/out/mcp/resources/adrs.js.map +1 -0
- package/out/mcp/resources/changes.d.ts +13 -0
- package/out/mcp/resources/changes.d.ts.map +1 -0
- package/out/mcp/resources/changes.js +26 -0
- package/out/mcp/resources/changes.js.map +1 -0
- package/out/mcp/resources/dependencies.d.ts +13 -0
- package/out/mcp/resources/dependencies.d.ts.map +1 -0
- package/out/mcp/resources/dependencies.js +26 -0
- package/out/mcp/resources/dependencies.js.map +1 -0
- package/out/mcp/resources/modules.d.ts +13 -0
- package/out/mcp/resources/modules.d.ts.map +1 -0
- package/out/mcp/resources/modules.js +26 -0
- package/out/mcp/resources/modules.js.map +1 -0
- package/out/mcp/resources/symbols.d.ts +13 -0
- package/out/mcp/resources/symbols.d.ts.map +1 -0
- package/out/mcp/resources/symbols.js +26 -0
- package/out/mcp/resources/symbols.js.map +1 -0
- package/out/mcp/server.d.ts +29 -0
- package/out/mcp/server.d.ts.map +1 -0
- package/out/mcp/server.js +300 -0
- package/out/mcp/server.js.map +1 -0
- package/out/mcp/tools/architecture-mining.d.ts +46 -0
- package/out/mcp/tools/architecture-mining.d.ts.map +1 -0
- package/out/mcp/tools/architecture-mining.js +272 -0
- package/out/mcp/tools/architecture-mining.js.map +1 -0
- package/out/mcp/tools/bootstrap.d.ts +9 -0
- package/out/mcp/tools/bootstrap.d.ts.map +1 -0
- package/out/mcp/tools/bootstrap.js +14 -0
- package/out/mcp/tools/bootstrap.js.map +1 -0
- package/out/mcp/tools/cross-analysis.d.ts +18 -0
- package/out/mcp/tools/cross-analysis.d.ts.map +1 -0
- package/out/mcp/tools/cross-analysis.js +23 -0
- package/out/mcp/tools/cross-analysis.js.map +1 -0
- package/out/mcp/tools/gap-analysis.d.ts +34 -0
- package/out/mcp/tools/gap-analysis.d.ts.map +1 -0
- package/out/mcp/tools/gap-analysis.js +106 -0
- package/out/mcp/tools/gap-analysis.js.map +1 -0
- package/out/mcp/tools/learning-path.d.ts +10 -0
- package/out/mcp/tools/learning-path.d.ts.map +1 -0
- package/out/mcp/tools/learning-path.js +18 -0
- package/out/mcp/tools/learning-path.js.map +1 -0
- package/out/mcp/tools/query-dependencies.d.ts +18 -0
- package/out/mcp/tools/query-dependencies.d.ts.map +1 -0
- package/out/mcp/tools/query-dependencies.js +31 -0
- package/out/mcp/tools/query-dependencies.js.map +1 -0
- package/out/mcp/tools/query-modules.d.ts +17 -0
- package/out/mcp/tools/query-modules.d.ts.map +1 -0
- package/out/mcp/tools/query-modules.js +22 -0
- package/out/mcp/tools/query-modules.js.map +1 -0
- package/out/mcp/tools/query-symbols.d.ts +18 -0
- package/out/mcp/tools/query-symbols.d.ts.map +1 -0
- package/out/mcp/tools/query-symbols.js +32 -0
- package/out/mcp/tools/query-symbols.js.map +1 -0
- package/out/mcp/tools/semantic-discovery.d.ts +12 -0
- package/out/mcp/tools/semantic-discovery.d.ts.map +1 -0
- package/out/mcp/tools/semantic-discovery.js +35 -0
- package/out/mcp/tools/semantic-discovery.js.map +1 -0
- package/out/mcp/tools/system-explanation.d.ts +9 -0
- package/out/mcp/tools/system-explanation.d.ts.map +1 -0
- package/out/mcp/tools/system-explanation.js +14 -0
- package/out/mcp/tools/system-explanation.js.map +1 -0
- package/out/mcp/types.d.ts +19 -0
- package/out/mcp/types.d.ts.map +1 -0
- package/out/mcp/types.js +6 -0
- package/out/mcp/types.js.map +1 -0
- package/out/models/adr.d.ts +26 -0
- package/out/models/adr.d.ts.map +1 -0
- package/out/models/adr.js +3 -0
- package/out/models/adr.js.map +1 -0
- package/out/models/change.d.ts +42 -0
- package/out/models/change.d.ts.map +1 -0
- package/out/models/change.js +3 -0
- package/out/models/change.js.map +1 -0
- package/out/models/dependency.d.ts +37 -0
- package/out/models/dependency.d.ts.map +1 -0
- package/out/models/dependency.js +3 -0
- package/out/models/dependency.js.map +1 -0
- package/out/models/entity-reference.d.ts +20 -0
- package/out/models/entity-reference.d.ts.map +1 -0
- package/out/models/entity-reference.js +19 -0
- package/out/models/entity-reference.js.map +1 -0
- package/out/models/module.d.ts +26 -0
- package/out/models/module.d.ts.map +1 -0
- package/out/models/module.js +3 -0
- package/out/models/module.js.map +1 -0
- package/out/models/symbol.d.ts +31 -0
- package/out/models/symbol.d.ts.map +1 -0
- package/out/models/symbol.js +3 -0
- package/out/models/symbol.js.map +1 -0
- package/out/repositories/adr-repository.d.ts +41 -0
- package/out/repositories/adr-repository.d.ts.map +1 -0
- package/out/repositories/adr-repository.js +128 -0
- package/out/repositories/adr-repository.js.map +1 -0
- package/out/repositories/base-repository.d.ts +86 -0
- package/out/repositories/base-repository.d.ts.map +1 -0
- package/out/repositories/base-repository.js +66 -0
- package/out/repositories/base-repository.js.map +1 -0
- package/out/repositories/change-repository.d.ts +40 -0
- package/out/repositories/change-repository.d.ts.map +1 -0
- package/out/repositories/change-repository.js +150 -0
- package/out/repositories/change-repository.js.map +1 -0
- package/out/repositories/dependency-repository.d.ts +40 -0
- package/out/repositories/dependency-repository.d.ts.map +1 -0
- package/out/repositories/dependency-repository.js +129 -0
- package/out/repositories/dependency-repository.js.map +1 -0
- package/out/repositories/embedding-repository.d.ts +64 -0
- package/out/repositories/embedding-repository.d.ts.map +1 -0
- package/out/repositories/embedding-repository.js +126 -0
- package/out/repositories/embedding-repository.js.map +1 -0
- package/out/repositories/importance-repository.d.ts +63 -0
- package/out/repositories/importance-repository.d.ts.map +1 -0
- package/out/repositories/importance-repository.js +117 -0
- package/out/repositories/importance-repository.js.map +1 -0
- package/out/repositories/module-repository.d.ts +37 -0
- package/out/repositories/module-repository.d.ts.map +1 -0
- package/out/repositories/module-repository.js +122 -0
- package/out/repositories/module-repository.js.map +1 -0
- package/out/repositories/navigation-repository.d.ts +117 -0
- package/out/repositories/navigation-repository.d.ts.map +1 -0
- package/out/repositories/navigation-repository.js +211 -0
- package/out/repositories/navigation-repository.js.map +1 -0
- package/out/repositories/symbol-repository.d.ts +37 -0
- package/out/repositories/symbol-repository.d.ts.map +1 -0
- package/out/repositories/symbol-repository.js +136 -0
- package/out/repositories/symbol-repository.js.map +1 -0
- package/out/services/cross-dimension-linker.d.ts +45 -0
- package/out/services/cross-dimension-linker.d.ts.map +1 -0
- package/out/services/cross-dimension-linker.js +98 -0
- package/out/services/cross-dimension-linker.js.map +1 -0
- package/out/services/importance-scorer.d.ts +47 -0
- package/out/services/importance-scorer.d.ts.map +1 -0
- package/out/services/importance-scorer.js +188 -0
- package/out/services/importance-scorer.js.map +1 -0
- package/out/services/ingestion-orchestrator.d.ts +49 -0
- package/out/services/ingestion-orchestrator.d.ts.map +1 -0
- package/out/services/ingestion-orchestrator.js +140 -0
- package/out/services/ingestion-orchestrator.js.map +1 -0
- package/out/services/navigation-builder.d.ts +29 -0
- package/out/services/navigation-builder.d.ts.map +1 -0
- package/out/services/navigation-builder.js +229 -0
- package/out/services/navigation-builder.js.map +1 -0
- package/out/services/system-model-builder.d.ts +40 -0
- package/out/services/system-model-builder.d.ts.map +1 -0
- package/out/services/system-model-builder.js +88 -0
- package/out/services/system-model-builder.js.map +1 -0
- package/out/ui/commands.d.ts +9 -0
- package/out/ui/commands.d.ts.map +1 -0
- package/out/ui/commands.js +123 -0
- package/out/ui/commands.js.map +1 -0
- package/out/ui/database-explorer.d.ts +27 -0
- package/out/ui/database-explorer.d.ts.map +1 -0
- package/out/ui/database-explorer.js +169 -0
- package/out/ui/database-explorer.js.map +1 -0
- package/out/ui/detail-view-provider.d.ts +86 -0
- package/out/ui/detail-view-provider.d.ts.map +1 -0
- package/out/ui/detail-view-provider.js +1037 -0
- package/out/ui/detail-view-provider.js.map +1 -0
- package/out/ui/search-provider.d.ts +30 -0
- package/out/ui/search-provider.d.ts.map +1 -0
- package/out/ui/search-provider.js +240 -0
- package/out/ui/search-provider.js.map +1 -0
- package/out/ui/status-provider.d.ts +17 -0
- package/out/ui/status-provider.d.ts.map +1 -0
- package/out/ui/status-provider.js +76 -0
- package/out/ui/status-provider.js.map +1 -0
- package/out/validators/consistency-validator.d.ts +37 -0
- package/out/validators/consistency-validator.d.ts.map +1 -0
- package/out/validators/consistency-validator.js +93 -0
- package/out/validators/consistency-validator.js.map +1 -0
- package/out/validators/integrity-validator.d.ts +45 -0
- package/out/validators/integrity-validator.d.ts.map +1 -0
- package/out/validators/integrity-validator.js +115 -0
- package/out/validators/integrity-validator.js.map +1 -0
- package/package.json +173 -0
- package/schemas/sqlite/001_initial_modules.sql +39 -0
- package/schemas/sqlite/002_initial_symbols.sql +46 -0
- package/schemas/sqlite/003_initial_dependencies.sql +51 -0
- package/schemas/sqlite/004_initial_adrs.sql +41 -0
- package/schemas/sqlite/005_initial_changes.sql +54 -0
- package/schemas/sqlite/006_initial_ingestion.sql +34 -0
- package/schemas/sqlite/006_vectors_schema.sql +73 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IdMapper = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Manages ID mappings between external IDs (from documentation) and internal DB IDs (UUIDs).
|
|
6
|
+
* Each dimension has its own ID mapping table.
|
|
7
|
+
*/
|
|
8
|
+
class IdMapper {
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new IdMapper instance.
|
|
11
|
+
*
|
|
12
|
+
* @param dbManager The MultiDbManager instance
|
|
13
|
+
*/
|
|
14
|
+
constructor(dbManager) {
|
|
15
|
+
this.dbManager = dbManager;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Gets the table name for ID mappings for a dimension.
|
|
19
|
+
*
|
|
20
|
+
* @param dimension The dimension
|
|
21
|
+
* @returns The table name
|
|
22
|
+
*/
|
|
23
|
+
getMappingTableName(dimension) {
|
|
24
|
+
const tableNames = {
|
|
25
|
+
X: 'module_id_mapping',
|
|
26
|
+
Y: 'symbol_id_mapping',
|
|
27
|
+
Z: 'dependency_id_mapping',
|
|
28
|
+
W: 'adr_id_mapping',
|
|
29
|
+
T: 'change_id_mapping',
|
|
30
|
+
V: 'vector_id_mapping' // V-dimension doesn't use ID mapping, but included for completeness
|
|
31
|
+
};
|
|
32
|
+
return tableNames[dimension];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Maps an external ID to an internal ID for a dimension.
|
|
36
|
+
* If the mapping doesn't exist, creates a new one.
|
|
37
|
+
*
|
|
38
|
+
* @param dimension The dimension
|
|
39
|
+
* @param externalId The external ID (e.g., symbol_id from JSONL, adr_number)
|
|
40
|
+
* @param internalId The internal UUID
|
|
41
|
+
* @param pluginId The plugin ID
|
|
42
|
+
* @returns Promise that resolves when the mapping is stored
|
|
43
|
+
*/
|
|
44
|
+
async setMapping(dimension, externalId, internalId, pluginId) {
|
|
45
|
+
const db = await this.dbManager.getDatabase(dimension);
|
|
46
|
+
const tableName = this.getMappingTableName(dimension);
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
db.run(`INSERT OR REPLACE INTO ${tableName} (internal_id, external_id, plugin_id) VALUES (?, ?, ?)`, [internalId, externalId, pluginId], (err) => {
|
|
49
|
+
if (err) {
|
|
50
|
+
reject(err);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
resolve();
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Gets the internal ID for an external ID.
|
|
60
|
+
*
|
|
61
|
+
* @param dimension The dimension
|
|
62
|
+
* @param externalId The external ID
|
|
63
|
+
* @param pluginId The plugin ID
|
|
64
|
+
* @returns Promise that resolves to the internal ID, or null if not found
|
|
65
|
+
*/
|
|
66
|
+
async getInternalId(dimension, externalId, pluginId) {
|
|
67
|
+
const db = await this.dbManager.getDatabase(dimension);
|
|
68
|
+
const tableName = this.getMappingTableName(dimension);
|
|
69
|
+
return new Promise((resolve, reject) => {
|
|
70
|
+
db.get(`SELECT internal_id FROM ${tableName} WHERE external_id = ? AND plugin_id = ?`, [externalId, pluginId], (err, row) => {
|
|
71
|
+
if (err) {
|
|
72
|
+
reject(err);
|
|
73
|
+
}
|
|
74
|
+
else if (row) {
|
|
75
|
+
resolve(row.internal_id);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
resolve(null);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Gets the external ID for an internal ID.
|
|
85
|
+
*
|
|
86
|
+
* @param dimension The dimension
|
|
87
|
+
* @param internalId The internal UUID
|
|
88
|
+
* @param pluginId The plugin ID
|
|
89
|
+
* @returns Promise that resolves to the external ID, or null if not found
|
|
90
|
+
*/
|
|
91
|
+
async getExternalId(dimension, internalId, pluginId) {
|
|
92
|
+
const db = await this.dbManager.getDatabase(dimension);
|
|
93
|
+
const tableName = this.getMappingTableName(dimension);
|
|
94
|
+
return new Promise((resolve, reject) => {
|
|
95
|
+
db.get(`SELECT external_id FROM ${tableName} WHERE internal_id = ? AND plugin_id = ?`, [internalId, pluginId], (err, row) => {
|
|
96
|
+
if (err) {
|
|
97
|
+
reject(err);
|
|
98
|
+
}
|
|
99
|
+
else if (row) {
|
|
100
|
+
resolve(row.external_id);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
resolve(null);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Deletes a mapping for an external ID.
|
|
110
|
+
*
|
|
111
|
+
* @param dimension The dimension
|
|
112
|
+
* @param externalId The external ID
|
|
113
|
+
* @param pluginId The plugin ID
|
|
114
|
+
* @returns Promise that resolves when the mapping is deleted
|
|
115
|
+
*/
|
|
116
|
+
async deleteMapping(dimension, externalId, pluginId) {
|
|
117
|
+
const db = await this.dbManager.getDatabase(dimension);
|
|
118
|
+
const tableName = this.getMappingTableName(dimension);
|
|
119
|
+
return new Promise((resolve, reject) => {
|
|
120
|
+
db.run(`DELETE FROM ${tableName} WHERE external_id = ? AND plugin_id = ?`, [externalId, pluginId], (err) => {
|
|
121
|
+
if (err) {
|
|
122
|
+
reject(err);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
resolve();
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.IdMapper = IdMapper;
|
|
132
|
+
//# sourceMappingURL=id-mapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id-mapper.js","sourceRoot":"","sources":["../../src/core/id-mapper.ts"],"names":[],"mappings":";;;AAYA;;;GAGG;AACH,MAAa,QAAQ;IAGjB;;;;OAIG;IACH,YAAY,SAAyB;QACjC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACK,mBAAmB,CAAC,SAAoB;QAC5C,MAAM,UAAU,GAA8B;YAC1C,CAAC,EAAE,mBAAmB;YACtB,CAAC,EAAE,mBAAmB;YACtB,CAAC,EAAE,uBAAuB;YAC1B,CAAC,EAAE,gBAAgB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AAC;QAEtD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACnC,EAAE,CAAC,GAAG,CACF,eAAe,SAAS,0CAA0C,EAClE,CAAC,UAAU,EAAE,QAAQ,CAAC,EACtB,CAAC,GAAG,EAAE,EAAE;gBACJ,IAAI,GAAG,EAAE,CAAC;oBACN,MAAM,CAAC,GAAG,CAAC,CAAC;gBAChB,CAAC;qBAAM,CAAC;oBACJ,OAAO,EAAE,CAAC;gBACd,CAAC;YACL,CAAC,CACJ,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAhKD,4BAgKC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { MultiDbManager, Dimension } from './multi-db-manager';
|
|
2
|
+
/**
|
|
3
|
+
* Manages database schema migrations for all 5 dimensions.
|
|
4
|
+
* Migrations are stored in the schemas/sqlite/ directory.
|
|
5
|
+
*/
|
|
6
|
+
export declare class MigrationManager {
|
|
7
|
+
private dbManager;
|
|
8
|
+
private migrationsDirectory;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new MigrationManager instance.
|
|
11
|
+
*
|
|
12
|
+
* @param dbManager The MultiDbManager instance
|
|
13
|
+
* @param pluginRoot The root directory of the plugin (where schemas/ is located)
|
|
14
|
+
*/
|
|
15
|
+
constructor(dbManager: MultiDbManager, pluginRoot: string);
|
|
16
|
+
/**
|
|
17
|
+
* Ensures the migrations table exists in a database.
|
|
18
|
+
*
|
|
19
|
+
* @param db The SQLite database instance
|
|
20
|
+
* @returns Promise that resolves when the table is created
|
|
21
|
+
*/
|
|
22
|
+
private ensureMigrationsTable;
|
|
23
|
+
/**
|
|
24
|
+
* Gets the list of applied migrations for a database.
|
|
25
|
+
*
|
|
26
|
+
* @param db The SQLite database instance
|
|
27
|
+
* @returns Promise that resolves to an array of migration records
|
|
28
|
+
*/
|
|
29
|
+
private getAppliedMigrations;
|
|
30
|
+
/**
|
|
31
|
+
* Reads a migration file from disk.
|
|
32
|
+
*
|
|
33
|
+
* @param migrationFile The migration file name (e.g., "001_initial_modules.sql")
|
|
34
|
+
* @returns The SQL content of the migration file
|
|
35
|
+
*/
|
|
36
|
+
private readMigrationFile;
|
|
37
|
+
/**
|
|
38
|
+
* Applies a migration to a database.
|
|
39
|
+
*
|
|
40
|
+
* @param db The SQLite database instance
|
|
41
|
+
* @param version The migration version number
|
|
42
|
+
* @param name The migration name
|
|
43
|
+
* @param sql The SQL content to execute
|
|
44
|
+
* @returns Promise that resolves when the migration is applied
|
|
45
|
+
*/
|
|
46
|
+
private applyMigration;
|
|
47
|
+
/**
|
|
48
|
+
* Gets all migration files for a dimension, sorted by version.
|
|
49
|
+
*
|
|
50
|
+
* @param dimension The dimension
|
|
51
|
+
* @returns Array of migration file names
|
|
52
|
+
*/
|
|
53
|
+
private getMigrationFilesForDimension;
|
|
54
|
+
/**
|
|
55
|
+
* Gets the dimension prefix for migration files.
|
|
56
|
+
*
|
|
57
|
+
* @param dimension The dimension
|
|
58
|
+
* @returns The prefix (e.g., "001" for X, "002" for Y, etc.)
|
|
59
|
+
*/
|
|
60
|
+
private getDimensionPrefix;
|
|
61
|
+
/**
|
|
62
|
+
* Runs all pending migrations for a dimension.
|
|
63
|
+
*
|
|
64
|
+
* @param dimension The dimension to migrate
|
|
65
|
+
* @returns Promise that resolves when all migrations are applied
|
|
66
|
+
*/
|
|
67
|
+
migrate(dimension: Dimension): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Runs all pending migrations for all dimensions.
|
|
70
|
+
*
|
|
71
|
+
* @returns Promise that resolves when all migrations are applied
|
|
72
|
+
*/
|
|
73
|
+
migrateAll(): Promise<void>;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=migration-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-manager.d.ts","sourceRoot":"","sources":["../../src/core/migration-manager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAW/D;;;GAGG;AACH,qBAAa,gBAAgB;IACzB,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,mBAAmB,CAAS;IAEpC;;;;;OAKG;gBACS,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM;IAKzD;;;;;OAKG;YACW,qBAAqB;IAkBnC;;;;;OAKG;YACW,oBAAoB;IAclC;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAQzB;;;;;;;;OAQG;YACW,cAAc;IAsB5B;;;;;OAKG;IACH,OAAO,CAAC,6BAA6B;IAgBrC;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAY1B;;;;;OAKG;IACU,OAAO,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAyBzD;;;;OAIG;IACU,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAM3C"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.MigrationManager = void 0;
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
/**
|
|
40
|
+
* Manages database schema migrations for all 5 dimensions.
|
|
41
|
+
* Migrations are stored in the schemas/sqlite/ directory.
|
|
42
|
+
*/
|
|
43
|
+
class MigrationManager {
|
|
44
|
+
/**
|
|
45
|
+
* Creates a new MigrationManager instance.
|
|
46
|
+
*
|
|
47
|
+
* @param dbManager The MultiDbManager instance
|
|
48
|
+
* @param pluginRoot The root directory of the plugin (where schemas/ is located)
|
|
49
|
+
*/
|
|
50
|
+
constructor(dbManager, pluginRoot) {
|
|
51
|
+
this.dbManager = dbManager;
|
|
52
|
+
this.migrationsDirectory = path.join(pluginRoot, 'schemas', 'sqlite');
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Ensures the migrations table exists in a database.
|
|
56
|
+
*
|
|
57
|
+
* @param db The SQLite database instance
|
|
58
|
+
* @returns Promise that resolves when the table is created
|
|
59
|
+
*/
|
|
60
|
+
async ensureMigrationsTable(db) {
|
|
61
|
+
return new Promise((resolve, reject) => {
|
|
62
|
+
db.run(`
|
|
63
|
+
CREATE TABLE IF NOT EXISTS migrations (
|
|
64
|
+
version INTEGER PRIMARY KEY,
|
|
65
|
+
name TEXT NOT NULL,
|
|
66
|
+
applied_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
67
|
+
)
|
|
68
|
+
`, (err) => {
|
|
69
|
+
if (err) {
|
|
70
|
+
reject(err);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
resolve();
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Gets the list of applied migrations for a database.
|
|
80
|
+
*
|
|
81
|
+
* @param db The SQLite database instance
|
|
82
|
+
* @returns Promise that resolves to an array of migration records
|
|
83
|
+
*/
|
|
84
|
+
async getAppliedMigrations(db) {
|
|
85
|
+
await this.ensureMigrationsTable(db);
|
|
86
|
+
return new Promise((resolve, reject) => {
|
|
87
|
+
db.all('SELECT version, name, applied_at FROM migrations ORDER BY version', (err, rows) => {
|
|
88
|
+
if (err) {
|
|
89
|
+
reject(err);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
resolve(rows);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Reads a migration file from disk.
|
|
99
|
+
*
|
|
100
|
+
* @param migrationFile The migration file name (e.g., "001_initial_modules.sql")
|
|
101
|
+
* @returns The SQL content of the migration file
|
|
102
|
+
*/
|
|
103
|
+
readMigrationFile(migrationFile) {
|
|
104
|
+
const filePath = path.join(this.migrationsDirectory, migrationFile);
|
|
105
|
+
if (!fs.existsSync(filePath)) {
|
|
106
|
+
throw new Error(`Migration file not found: ${filePath}`);
|
|
107
|
+
}
|
|
108
|
+
return fs.readFileSync(filePath, 'utf-8');
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Applies a migration to a database.
|
|
112
|
+
*
|
|
113
|
+
* @param db The SQLite database instance
|
|
114
|
+
* @param version The migration version number
|
|
115
|
+
* @param name The migration name
|
|
116
|
+
* @param sql The SQL content to execute
|
|
117
|
+
* @returns Promise that resolves when the migration is applied
|
|
118
|
+
*/
|
|
119
|
+
async applyMigration(db, version, name, sql) {
|
|
120
|
+
return new Promise((resolve, reject) => {
|
|
121
|
+
db.exec(sql, (err) => {
|
|
122
|
+
if (err) {
|
|
123
|
+
reject(new Error(`Failed to apply migration ${version}_${name}: ${err.message}`));
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
db.run('INSERT INTO migrations (version, name) VALUES (?, ?)', [version, name], (insertErr) => {
|
|
127
|
+
if (insertErr) {
|
|
128
|
+
reject(insertErr);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
resolve();
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Gets all migration files for a dimension, sorted by version.
|
|
140
|
+
*
|
|
141
|
+
* @param dimension The dimension
|
|
142
|
+
* @returns Array of migration file names
|
|
143
|
+
*/
|
|
144
|
+
getMigrationFilesForDimension(dimension) {
|
|
145
|
+
if (!fs.existsSync(this.migrationsDirectory)) {
|
|
146
|
+
return [];
|
|
147
|
+
}
|
|
148
|
+
const files = fs.readdirSync(this.migrationsDirectory)
|
|
149
|
+
.filter(file => file.endsWith('.sql'))
|
|
150
|
+
.filter(file => {
|
|
151
|
+
const dimensionPrefix = this.getDimensionPrefix(dimension);
|
|
152
|
+
return file.startsWith(dimensionPrefix);
|
|
153
|
+
})
|
|
154
|
+
.sort();
|
|
155
|
+
return files;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Gets the dimension prefix for migration files.
|
|
159
|
+
*
|
|
160
|
+
* @param dimension The dimension
|
|
161
|
+
* @returns The prefix (e.g., "001" for X, "002" for Y, etc.)
|
|
162
|
+
*/
|
|
163
|
+
getDimensionPrefix(dimension) {
|
|
164
|
+
const prefixes = {
|
|
165
|
+
X: '001',
|
|
166
|
+
Y: '002',
|
|
167
|
+
Z: '003',
|
|
168
|
+
W: '004',
|
|
169
|
+
T: '005',
|
|
170
|
+
V: '006' // V-dimension (vectors)
|
|
171
|
+
};
|
|
172
|
+
return prefixes[dimension];
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Runs all pending migrations for a dimension.
|
|
176
|
+
*
|
|
177
|
+
* @param dimension The dimension to migrate
|
|
178
|
+
* @returns Promise that resolves when all migrations are applied
|
|
179
|
+
*/
|
|
180
|
+
async migrate(dimension) {
|
|
181
|
+
const db = await this.dbManager.getDatabase(dimension);
|
|
182
|
+
const appliedMigrations = await this.getAppliedMigrations(db);
|
|
183
|
+
const appliedVersions = new Set(appliedMigrations.map(m => m.version));
|
|
184
|
+
const migrationFiles = this.getMigrationFilesForDimension(dimension);
|
|
185
|
+
for (const migrationFile of migrationFiles) {
|
|
186
|
+
const versionMatch = migrationFile.match(/^(\d+)_/);
|
|
187
|
+
if (!versionMatch) {
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
const version = parseInt(versionMatch[1], 10);
|
|
191
|
+
if (appliedVersions.has(version)) {
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
const name = migrationFile.replace(/^\d+_/, '').replace(/\.sql$/, '');
|
|
195
|
+
const sql = this.readMigrationFile(migrationFile);
|
|
196
|
+
await this.applyMigration(db, version, name, sql);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Runs all pending migrations for all dimensions.
|
|
201
|
+
*
|
|
202
|
+
* @returns Promise that resolves when all migrations are applied
|
|
203
|
+
*/
|
|
204
|
+
async migrateAll() {
|
|
205
|
+
const dimensions = ['X', 'Y', 'Z', 'W', 'T'];
|
|
206
|
+
for (const dimension of dimensions) {
|
|
207
|
+
await this.migrate(dimension);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
exports.MigrationManager = MigrationManager;
|
|
212
|
+
//# sourceMappingURL=migration-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-manager.js","sourceRoot":"","sources":["../../src/core/migration-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,uCAAyB;AAYzB;;;GAGG;AACH,MAAa,gBAAgB;IAIzB;;;;;OAKG;IACH,YAAY,SAAyB,EAAE,UAAkB;QACrD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC1E,CAAC;IAED;;;;;OAKG;IACK,KAAK,CAAC,qBAAqB,CAAC,EAAoB;QACpD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACnC,EAAE,CAAC,GAAG,CAAC;;;;;;aAMN,EAAE,CAAC,GAAG,EAAE,EAAE;gBACP,IAAI,GAAG,EAAE,CAAC;oBACN,MAAM,CAAC,GAAG,CAAC,CAAC;gBAChB,CAAC;qBAAM,CAAC;oBACJ,OAAO,EAAE,CAAC;gBACd,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;OAKG;IACK,KAAK,CAAC,oBAAoB,CAAC,EAAoB;QACnD,MAAM,IAAI,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC;QAErC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACnC,EAAE,CAAC,GAAG,CAAC,mEAAmE,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;gBACtF,IAAI,GAAG,EAAE,CAAC;oBACN,MAAM,CAAC,GAAG,CAAC,CAAC;gBAChB,CAAC;qBAAM,CAAC;oBACJ,OAAO,CAAC,IAAyB,CAAC,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YACzC,MAAM,YAAY,GAAG,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YACpD,IAAI,CAAC,YAAY,EAAE,CAAC;gBAChB,SAAS;YACb,CAAC;YAED,MAAM,OAAO,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC9C,IAAI,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC/B,SAAS;YACb,CAAC;YAED,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YACtE,MAAM,GAAG,GAAG,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;YAElD,MAAM,IAAI,CAAC,cAAc,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;QACtD,CAAC;IACL,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,UAAU;QACnB,MAAM,UAAU,GAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAC1D,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACjC,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAClC,CAAC;IACL,CAAC;CACJ;AA1LD,4CA0LC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as sqlite3 from 'sqlite3';
|
|
2
|
+
import { VectorDatabase } from './vector-database-interface';
|
|
3
|
+
/**
|
|
4
|
+
* Dimension types for the 5D database system + 6th dimension (V for vectors)
|
|
5
|
+
*/
|
|
6
|
+
export type Dimension = 'X' | 'Y' | 'Z' | 'W' | 'T' | 'V';
|
|
7
|
+
/**
|
|
8
|
+
* Manages 5 separate SQLite databases, one for each dimension.
|
|
9
|
+
* Each database is stored in the workspace-specific .database-plugin directory.
|
|
10
|
+
*/
|
|
11
|
+
export declare class MultiDbManager {
|
|
12
|
+
private databases;
|
|
13
|
+
private dbDirectory;
|
|
14
|
+
private workspaceRoot;
|
|
15
|
+
private pluginId;
|
|
16
|
+
private vssLoader;
|
|
17
|
+
private vectorDatabase;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new MultiDbManager instance.
|
|
20
|
+
* @param workspaceRoot The root directory of the workspace
|
|
21
|
+
*/
|
|
22
|
+
constructor(workspaceRoot: string);
|
|
23
|
+
/**
|
|
24
|
+
* Computes a stable plugin_id from the workspace root path.
|
|
25
|
+
* Uses SHA256 hash of normalized path, takes first 16 characters.
|
|
26
|
+
*
|
|
27
|
+
* @param workspaceRoot The workspace root directory
|
|
28
|
+
* @returns Stable plugin ID (16 hex characters)
|
|
29
|
+
*/
|
|
30
|
+
private computePluginId;
|
|
31
|
+
/**
|
|
32
|
+
* Ensures the database directory exists.
|
|
33
|
+
*/
|
|
34
|
+
private ensureDbDirectory;
|
|
35
|
+
/**
|
|
36
|
+
* Gets the plugin ID for this workspace.
|
|
37
|
+
*/
|
|
38
|
+
getPluginId(): string;
|
|
39
|
+
/**
|
|
40
|
+
* Gets the database directory path.
|
|
41
|
+
*/
|
|
42
|
+
getDbDirectory(): string;
|
|
43
|
+
/**
|
|
44
|
+
* Opens a database connection for the specified dimension.
|
|
45
|
+
* If the database is already open, returns the existing connection.
|
|
46
|
+
* For V-dimension (vectors.db), loads VSS extension before opening.
|
|
47
|
+
*
|
|
48
|
+
* @param dimension The dimension (X, Y, Z, W, T, or V)
|
|
49
|
+
* @returns Promise that resolves to the SQLite database instance
|
|
50
|
+
*/
|
|
51
|
+
getDatabase(dimension: Dimension): Promise<sqlite3.Database>;
|
|
52
|
+
/**
|
|
53
|
+
* Closes a database connection for the specified dimension.
|
|
54
|
+
*
|
|
55
|
+
* @param dimension The dimension to close
|
|
56
|
+
* @returns Promise that resolves when the database is closed
|
|
57
|
+
*/
|
|
58
|
+
closeDatabase(dimension: Dimension): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Closes all database connections.
|
|
61
|
+
*
|
|
62
|
+
* @returns Promise that resolves when all databases are closed
|
|
63
|
+
*/
|
|
64
|
+
closeAll(): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Gets all open database connections.
|
|
67
|
+
*
|
|
68
|
+
* @returns Map of dimension to database instance
|
|
69
|
+
*/
|
|
70
|
+
getOpenDatabases(): Map<Dimension, sqlite3.Database>;
|
|
71
|
+
/**
|
|
72
|
+
* Gets the Vector Database for vector similarity search.
|
|
73
|
+
* Only available for V-dimension after initialization.
|
|
74
|
+
*
|
|
75
|
+
* @returns Vector Database instance or null if not available
|
|
76
|
+
*/
|
|
77
|
+
getVectorDatabase(): VectorDatabase | null;
|
|
78
|
+
/**
|
|
79
|
+
* @deprecated Use getVectorDatabase() instead
|
|
80
|
+
* Gets the VSS Manager for backward compatibility.
|
|
81
|
+
*/
|
|
82
|
+
getVssManager(): any | null;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=multi-db-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multi-db-manager.d.ts","sourceRoot":"","sources":["../../src/core/multi-db-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAKnC,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAG7D;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAc1D;;;GAGG;AACH,qBAAa,cAAc;IACvB,OAAO,CAAC,SAAS,CAA+C;IAChE,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,cAAc,CAA+B;IAErD;;;OAGG;gBACS,aAAa,EAAE,MAAM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