vectra 0.12.3 → 0.14.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/README.md +92 -100
- package/lib/BrowserWebFetcher.d.ts +75 -0
- package/lib/BrowserWebFetcher.d.ts.map +1 -0
- package/lib/BrowserWebFetcher.js +290 -0
- package/lib/BrowserWebFetcher.js.map +1 -0
- package/lib/FileFetcher.d.ts.map +1 -1
- package/lib/FileFetcher.js +25 -15
- package/lib/FileFetcher.js.map +1 -1
- package/lib/FileFetcher.spec.d.ts +2 -0
- package/lib/FileFetcher.spec.d.ts.map +1 -0
- package/lib/FileFetcher.spec.js +244 -0
- package/lib/FileFetcher.spec.js.map +1 -0
- package/lib/FolderWatcher.d.ts +91 -0
- package/lib/FolderWatcher.d.ts.map +1 -0
- package/lib/FolderWatcher.js +304 -0
- package/lib/FolderWatcher.js.map +1 -0
- package/lib/FolderWatcher.spec.d.ts +2 -0
- package/lib/FolderWatcher.spec.d.ts.map +1 -0
- package/lib/FolderWatcher.spec.js +308 -0
- package/lib/FolderWatcher.spec.js.map +1 -0
- package/lib/GPT3Tokenizer.spec.d.ts +2 -0
- package/lib/GPT3Tokenizer.spec.d.ts.map +1 -0
- package/lib/GPT3Tokenizer.spec.js +45 -0
- package/lib/GPT3Tokenizer.spec.js.map +1 -0
- package/lib/ItemSelector.d.ts.map +1 -1
- package/lib/ItemSelector.js +19 -8
- package/lib/ItemSelector.js.map +1 -1
- package/lib/ItemSelector.spec.d.ts +2 -0
- package/lib/ItemSelector.spec.d.ts.map +1 -0
- package/lib/ItemSelector.spec.js +204 -0
- package/lib/ItemSelector.spec.js.map +1 -0
- package/lib/LocalDocument.d.ts +1 -1
- package/lib/LocalDocument.d.ts.map +1 -1
- package/lib/LocalDocument.js +5 -45
- package/lib/LocalDocument.js.map +1 -1
- package/lib/LocalDocument.spec.d.ts +2 -0
- package/lib/LocalDocument.spec.d.ts.map +1 -0
- package/lib/LocalDocument.spec.js +214 -0
- package/lib/LocalDocument.spec.js.map +1 -0
- package/lib/LocalDocumentIndex.d.ts +20 -0
- package/lib/LocalDocumentIndex.d.ts.map +1 -1
- package/lib/LocalDocumentIndex.js +16 -52
- package/lib/LocalDocumentIndex.js.map +1 -1
- package/lib/LocalDocumentIndex.spec.d.ts +2 -0
- package/lib/LocalDocumentIndex.spec.d.ts.map +1 -0
- package/lib/LocalDocumentIndex.spec.js +494 -0
- package/lib/LocalDocumentIndex.spec.js.map +1 -0
- package/lib/LocalDocumentResult.d.ts +32 -11
- package/lib/LocalDocumentResult.d.ts.map +1 -1
- package/lib/LocalDocumentResult.js +305 -257
- package/lib/LocalDocumentResult.js.map +1 -1
- package/lib/LocalDocumentResult.spec.d.ts +2 -0
- package/lib/LocalDocumentResult.spec.d.ts.map +1 -0
- package/lib/LocalDocumentResult.spec.js +373 -0
- package/lib/LocalDocumentResult.spec.js.map +1 -0
- package/lib/LocalEmbeddings.d.ts +59 -0
- package/lib/LocalEmbeddings.d.ts.map +1 -0
- package/lib/LocalEmbeddings.js +101 -0
- package/lib/LocalEmbeddings.js.map +1 -0
- package/lib/LocalEmbeddings.spec.d.ts +2 -0
- package/lib/LocalEmbeddings.spec.d.ts.map +1 -0
- package/lib/LocalEmbeddings.spec.js +155 -0
- package/lib/LocalEmbeddings.spec.js.map +1 -0
- package/lib/LocalIndex.d.ts +27 -18
- package/lib/LocalIndex.d.ts.map +1 -1
- package/lib/LocalIndex.js +109 -105
- package/lib/LocalIndex.js.map +1 -1
- package/lib/LocalIndex.spec.js +434 -43
- package/lib/LocalIndex.spec.js.map +1 -1
- package/lib/OpenAIEmbeddings.d.ts +4 -6
- package/lib/OpenAIEmbeddings.d.ts.map +1 -1
- package/lib/OpenAIEmbeddings.js +16 -24
- package/lib/OpenAIEmbeddings.js.map +1 -1
- package/lib/OpenAIEmbeddings.spec.d.ts +2 -0
- package/lib/OpenAIEmbeddings.spec.d.ts.map +1 -0
- package/lib/OpenAIEmbeddings.spec.js +298 -0
- package/lib/OpenAIEmbeddings.spec.js.map +1 -0
- package/lib/TextSplitter.d.ts +2 -0
- package/lib/TextSplitter.d.ts.map +1 -1
- package/lib/TextSplitter.js +154 -111
- package/lib/TextSplitter.js.map +1 -1
- package/lib/TextSplitter.spec.js +289 -61
- package/lib/TextSplitter.spec.js.map +1 -1
- package/lib/TransformersEmbeddings.d.ts +121 -0
- package/lib/TransformersEmbeddings.d.ts.map +1 -0
- package/lib/TransformersEmbeddings.js +176 -0
- package/lib/TransformersEmbeddings.js.map +1 -0
- package/lib/TransformersEmbeddings.spec.d.ts +2 -0
- package/lib/TransformersEmbeddings.spec.d.ts.map +1 -0
- package/lib/TransformersEmbeddings.spec.js +198 -0
- package/lib/TransformersEmbeddings.spec.js.map +1 -0
- package/lib/TransformersTokenizer.d.ts +33 -0
- package/lib/TransformersTokenizer.d.ts.map +1 -0
- package/lib/TransformersTokenizer.js +44 -0
- package/lib/TransformersTokenizer.js.map +1 -0
- package/lib/TransformersTokenizer.spec.d.ts +2 -0
- package/lib/TransformersTokenizer.spec.d.ts.map +1 -0
- package/lib/TransformersTokenizer.spec.js +112 -0
- package/lib/TransformersTokenizer.spec.js.map +1 -0
- package/lib/WebFetcher.d.ts +1 -2
- package/lib/WebFetcher.d.ts.map +1 -1
- package/lib/WebFetcher.js +58 -54
- package/lib/WebFetcher.js.map +1 -1
- package/lib/WebFetcher.spec.d.ts +2 -0
- package/lib/WebFetcher.spec.d.ts.map +1 -0
- package/lib/WebFetcher.spec.js +263 -0
- package/lib/WebFetcher.spec.js.map +1 -0
- package/lib/browser.d.ts +30 -0
- package/lib/browser.d.ts.map +1 -0
- package/lib/browser.js +52 -0
- package/lib/browser.js.map +1 -0
- package/lib/codecs/IndexCodec.d.ts +37 -0
- package/lib/codecs/IndexCodec.d.ts.map +1 -0
- package/lib/codecs/IndexCodec.js +3 -0
- package/lib/codecs/IndexCodec.js.map +1 -0
- package/lib/codecs/JsonCodec.d.ts +19 -0
- package/lib/codecs/JsonCodec.d.ts.map +1 -0
- package/lib/codecs/JsonCodec.js +35 -0
- package/lib/codecs/JsonCodec.js.map +1 -0
- package/lib/codecs/JsonCodec.spec.d.ts +2 -0
- package/lib/codecs/JsonCodec.spec.d.ts.map +1 -0
- package/lib/codecs/JsonCodec.spec.js +66 -0
- package/lib/codecs/JsonCodec.spec.js.map +1 -0
- package/lib/codecs/LocalIndex.protobuf.spec.d.ts +2 -0
- package/lib/codecs/LocalIndex.protobuf.spec.d.ts.map +1 -0
- package/lib/codecs/LocalIndex.protobuf.spec.js +108 -0
- package/lib/codecs/LocalIndex.protobuf.spec.js.map +1 -0
- package/lib/codecs/ProtobufCodec.d.ts +20 -0
- package/lib/codecs/ProtobufCodec.d.ts.map +1 -0
- package/lib/codecs/ProtobufCodec.js +225 -0
- package/lib/codecs/ProtobufCodec.js.map +1 -0
- package/lib/codecs/ProtobufCodec.spec.d.ts +2 -0
- package/lib/codecs/ProtobufCodec.spec.d.ts.map +1 -0
- package/lib/codecs/ProtobufCodec.spec.js +155 -0
- package/lib/codecs/ProtobufCodec.spec.js.map +1 -0
- package/lib/codecs/index.d.ts +5 -0
- package/lib/codecs/index.d.ts.map +1 -0
- package/lib/codecs/index.js +21 -0
- package/lib/codecs/index.js.map +1 -0
- package/lib/codecs/migrateIndex.d.ts +24 -0
- package/lib/codecs/migrateIndex.d.ts.map +1 -0
- package/lib/codecs/migrateIndex.js +119 -0
- package/lib/codecs/migrateIndex.js.map +1 -0
- package/lib/codecs/migrateIndex.spec.d.ts +2 -0
- package/lib/codecs/migrateIndex.spec.d.ts.map +1 -0
- package/lib/codecs/migrateIndex.spec.js +151 -0
- package/lib/codecs/migrateIndex.spec.js.map +1 -0
- package/lib/codecs/schemas/index.proto +34 -0
- package/lib/index.d.ts +9 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +9 -1
- package/lib/index.js.map +1 -1
- package/lib/internals/Colorize.d.ts.map +1 -1
- package/lib/internals/Colorize.js +20 -15
- package/lib/internals/Colorize.js.map +1 -1
- package/lib/server/IndexManager.d.ts +78 -0
- package/lib/server/IndexManager.d.ts.map +1 -0
- package/lib/server/IndexManager.js +259 -0
- package/lib/server/IndexManager.js.map +1 -0
- package/lib/server/VectraServer.d.ts +40 -0
- package/lib/server/VectraServer.d.ts.map +1 -0
- package/lib/server/VectraServer.js +151 -0
- package/lib/server/VectraServer.js.map +1 -0
- package/lib/server/VectraServer.spec.d.ts +2 -0
- package/lib/server/VectraServer.spec.d.ts.map +1 -0
- package/lib/server/VectraServer.spec.js +322 -0
- package/lib/server/VectraServer.spec.js.map +1 -0
- package/lib/server/handlers/documentHandlers.d.ts +15 -0
- package/lib/server/handlers/documentHandlers.d.ts.map +1 -0
- package/lib/server/handlers/documentHandlers.js +95 -0
- package/lib/server/handlers/documentHandlers.js.map +1 -0
- package/lib/server/handlers/helpers.d.ts +23 -0
- package/lib/server/handlers/helpers.d.ts.map +1 -0
- package/lib/server/handlers/helpers.js +138 -0
- package/lib/server/handlers/helpers.js.map +1 -0
- package/lib/server/handlers/index.d.ts +8 -0
- package/lib/server/handlers/index.d.ts.map +1 -0
- package/lib/server/handlers/index.js +22 -0
- package/lib/server/handlers/index.js.map +1 -0
- package/lib/server/handlers/indexHandlers.d.ts +14 -0
- package/lib/server/handlers/indexHandlers.d.ts.map +1 -0
- package/lib/server/handlers/indexHandlers.js +85 -0
- package/lib/server/handlers/indexHandlers.js.map +1 -0
- package/lib/server/handlers/itemHandlers.d.ts +34 -0
- package/lib/server/handlers/itemHandlers.d.ts.map +1 -0
- package/lib/server/handlers/itemHandlers.js +166 -0
- package/lib/server/handlers/itemHandlers.js.map +1 -0
- package/lib/server/handlers/lifecycleHandlers.d.ts +11 -0
- package/lib/server/handlers/lifecycleHandlers.d.ts.map +1 -0
- package/lib/server/handlers/lifecycleHandlers.js +31 -0
- package/lib/server/handlers/lifecycleHandlers.js.map +1 -0
- package/lib/server/handlers/queryHandlers.d.ts +27 -0
- package/lib/server/handlers/queryHandlers.d.ts.map +1 -0
- package/lib/server/handlers/queryHandlers.js +135 -0
- package/lib/server/handlers/queryHandlers.js.map +1 -0
- package/lib/server/handlers/statsHandlers.d.ts +17 -0
- package/lib/server/handlers/statsHandlers.d.ts.map +1 -0
- package/lib/server/handlers/statsHandlers.js +81 -0
- package/lib/server/handlers/statsHandlers.js.map +1 -0
- package/lib/server/index.d.ts +4 -0
- package/lib/server/index.d.ts.map +1 -0
- package/lib/server/index.js +23 -0
- package/lib/server/index.js.map +1 -0
- package/lib/storage/FileStorage.d.ts +92 -0
- package/lib/storage/FileStorage.d.ts.map +1 -0
- package/lib/storage/FileStorage.js +3 -0
- package/lib/storage/FileStorage.js.map +1 -0
- package/lib/storage/FileStorageUtilities.d.ts +36 -0
- package/lib/storage/FileStorageUtilities.d.ts.map +1 -0
- package/lib/storage/FileStorageUtilities.js +91 -0
- package/lib/storage/FileStorageUtilities.js.map +1 -0
- package/lib/storage/FileStorageUtilities.spec.d.ts +2 -0
- package/lib/storage/FileStorageUtilities.spec.d.ts.map +1 -0
- package/lib/storage/FileStorageUtilities.spec.js +98 -0
- package/lib/storage/FileStorageUtilities.spec.js.map +1 -0
- package/lib/storage/FileType.d.ts +29 -0
- package/lib/storage/FileType.d.ts.map +1 -0
- package/lib/storage/FileType.js +38 -0
- package/lib/storage/FileType.js.map +1 -0
- package/lib/storage/IndexedDBStorage.d.ts +47 -0
- package/lib/storage/IndexedDBStorage.d.ts.map +1 -0
- package/lib/storage/IndexedDBStorage.js +347 -0
- package/lib/storage/IndexedDBStorage.js.map +1 -0
- package/lib/storage/LocalFileStorage.browser.d.ts +19 -0
- package/lib/storage/LocalFileStorage.browser.d.ts.map +1 -0
- package/lib/storage/LocalFileStorage.browser.js +43 -0
- package/lib/storage/LocalFileStorage.browser.js.map +1 -0
- package/lib/storage/LocalFileStorage.d.ts +23 -0
- package/lib/storage/LocalFileStorage.d.ts.map +1 -0
- package/lib/storage/LocalFileStorage.js +152 -0
- package/lib/storage/LocalFileStorage.js.map +1 -0
- package/lib/storage/LocalFileStorage.spec.d.ts +2 -0
- package/lib/storage/LocalFileStorage.spec.d.ts.map +1 -0
- package/lib/storage/LocalFileStorage.spec.js +249 -0
- package/lib/storage/LocalFileStorage.spec.js.map +1 -0
- package/lib/storage/VirtualFileStorage.d.ts +18 -0
- package/lib/storage/VirtualFileStorage.d.ts.map +1 -0
- package/lib/storage/VirtualFileStorage.js +178 -0
- package/lib/storage/VirtualFileStorage.js.map +1 -0
- package/lib/storage/VirtualFileStorage.spec.d.ts +2 -0
- package/lib/storage/VirtualFileStorage.spec.d.ts.map +1 -0
- package/lib/storage/VirtualFileStorage.spec.js +302 -0
- package/lib/storage/VirtualFileStorage.spec.js.map +1 -0
- package/lib/storage/index.d.ts +6 -0
- package/lib/storage/index.d.ts.map +1 -0
- package/lib/storage/index.js +22 -0
- package/lib/storage/index.js.map +1 -0
- package/lib/templates/templates/csharp/README.md +48 -0
- package/lib/templates/templates/csharp/VectraClient.cs +234 -0
- package/lib/templates/templates/go/README.md +71 -0
- package/lib/templates/templates/go/vectra_client.go +322 -0
- package/lib/templates/templates/java/README.md +81 -0
- package/lib/templates/templates/java/VectraClient.java +232 -0
- package/lib/templates/templates/python/README.md +37 -0
- package/lib/templates/templates/python/vectra_client.py +279 -0
- package/lib/templates/templates/rust/Cargo.toml +14 -0
- package/lib/templates/templates/rust/README.md +39 -0
- package/lib/templates/templates/rust/build.rs +4 -0
- package/lib/templates/templates/rust/lib.rs +284 -0
- package/lib/templates/templates/typescript/README.md +96 -0
- package/lib/templates/templates/typescript/VectraClient.ts +374 -0
- package/lib/templates/typescript/VectraClient.d.ts +114 -0
- package/lib/templates/typescript/VectraClient.d.ts.map +1 -0
- package/lib/templates/typescript/VectraClient.js +328 -0
- package/lib/templates/typescript/VectraClient.js.map +1 -0
- package/lib/types.d.ts +7 -0
- package/lib/types.d.ts.map +1 -1
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/index.js +18 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/pathUtils.d.ts +40 -0
- package/lib/utils/pathUtils.d.ts.map +1 -0
- package/lib/utils/pathUtils.js +98 -0
- package/lib/utils/pathUtils.js.map +1 -0
- package/lib/vectra-cli.d.ts.map +1 -1
- package/lib/vectra-cli.generate.spec.d.ts +2 -0
- package/lib/vectra-cli.generate.spec.d.ts.map +1 -0
- package/lib/vectra-cli.generate.spec.js +112 -0
- package/lib/vectra-cli.generate.spec.js.map +1 -0
- package/lib/vectra-cli.js +446 -9
- package/lib/vectra-cli.js.map +1 -1
- package/lib/vectra-cli.spec.d.ts +1 -0
- package/lib/vectra-cli.spec.d.ts.map +1 -0
- package/lib/vectra-cli.spec.js +2 -0
- package/lib/vectra-cli.spec.js.map +1 -0
- package/package.json +89 -16
- package/proto/vectra_service.proto +276 -0
- package/src/BrowserWebFetcher.ts +345 -0
- package/src/FileFetcher.spec.ts +234 -0
- package/src/FileFetcher.ts +37 -25
- package/src/FolderWatcher.spec.ts +288 -0
- package/src/FolderWatcher.ts +304 -0
- package/src/GPT3Tokenizer.spec.ts +50 -0
- package/src/ItemSelector.spec.ts +252 -0
- package/src/ItemSelector.ts +163 -150
- package/src/LocalDocument.spec.ts +211 -0
- package/src/LocalDocument.ts +88 -94
- package/src/LocalDocumentIndex.spec.ts +481 -0
- package/src/LocalDocumentIndex.ts +39 -40
- package/src/LocalDocumentResult.spec.ts +373 -0
- package/src/LocalDocumentResult.ts +489 -319
- package/src/LocalEmbeddings.spec.ts +138 -0
- package/src/LocalEmbeddings.ts +120 -0
- package/src/LocalIndex.spec.ts +808 -323
- package/src/LocalIndex.ts +479 -430
- package/src/OpenAIEmbeddings.spec.ts +354 -0
- package/src/OpenAIEmbeddings.ts +26 -27
- package/src/TextSplitter.spec.ts +320 -65
- package/src/TextSplitter.ts +172 -115
- package/src/TransformersEmbeddings.spec.ts +188 -0
- package/src/TransformersEmbeddings.ts +232 -0
- package/src/TransformersTokenizer.spec.ts +143 -0
- package/src/TransformersTokenizer.ts +45 -0
- package/src/WebFetcher.spec.ts +288 -0
- package/src/WebFetcher.ts +184 -186
- package/src/browser.ts +69 -0
- package/src/codecs/IndexCodec.ts +40 -0
- package/src/codecs/JsonCodec.spec.ts +70 -0
- package/src/codecs/JsonCodec.ts +37 -0
- package/src/codecs/LocalIndex.protobuf.spec.ts +115 -0
- package/src/codecs/ProtobufCodec.spec.ts +166 -0
- package/src/codecs/ProtobufCodec.ts +193 -0
- package/src/codecs/index.ts +4 -0
- package/src/codecs/migrateIndex.spec.ts +176 -0
- package/src/codecs/migrateIndex.ts +125 -0
- package/src/codecs/schemas/index.proto +34 -0
- package/src/index.ts +9 -1
- package/src/internals/Colorize.ts +19 -16
- package/src/server/IndexManager.ts +243 -0
- package/src/server/VectraServer.spec.ts +303 -0
- package/src/server/VectraServer.ts +156 -0
- package/src/server/handlers/documentHandlers.ts +59 -0
- package/src/server/handlers/helpers.ts +93 -0
- package/src/server/handlers/index.ts +7 -0
- package/src/server/handlers/indexHandlers.ts +44 -0
- package/src/server/handlers/itemHandlers.ts +140 -0
- package/src/server/handlers/lifecycleHandlers.ts +26 -0
- package/src/server/handlers/queryHandlers.ts +96 -0
- package/src/server/handlers/statsHandlers.ts +38 -0
- package/src/server/index.ts +3 -0
- package/src/storage/FileStorage.ts +105 -0
- package/src/storage/FileStorageUtilities.spec.ts +106 -0
- package/src/storage/FileStorageUtilities.ts +77 -0
- package/src/storage/FileType.ts +61 -0
- package/src/storage/IndexedDBStorage.ts +365 -0
- package/src/storage/LocalFileStorage.browser.ts +52 -0
- package/src/storage/LocalFileStorage.spec.ts +292 -0
- package/src/storage/LocalFileStorage.ts +98 -0
- package/src/storage/VirtualFileStorage.spec.ts +307 -0
- package/src/storage/VirtualFileStorage.ts +169 -0
- package/src/storage/index.ts +5 -0
- package/src/templates/csharp/README.md +48 -0
- package/src/templates/csharp/VectraClient.cs +234 -0
- package/src/templates/go/README.md +71 -0
- package/src/templates/go/vectra_client.go +322 -0
- package/src/templates/java/README.md +81 -0
- package/src/templates/java/VectraClient.java +232 -0
- package/src/templates/python/README.md +37 -0
- package/src/templates/python/vectra_client.py +279 -0
- package/src/templates/rust/Cargo.toml +14 -0
- package/src/templates/rust/README.md +39 -0
- package/src/templates/rust/build.rs +4 -0
- package/src/templates/rust/lib.rs +284 -0
- package/src/templates/typescript/README.md +96 -0
- package/src/templates/typescript/VectraClient.ts +374 -0
- package/src/types.ts +131 -123
- package/src/utils/index.ts +1 -0
- package/src/utils/pathUtils.ts +106 -0
- package/src/vectra-cli.generate.spec.ts +72 -0
- package/src/vectra-cli.spec.ts +0 -0
- package/src/vectra-cli.ts +687 -246
- package/README.draft.md +0 -499
- package/README.draft.outline.md +0 -160
- package/README.research.md +0 -2159
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.IndexedDBStorage = void 0;
|
|
13
|
+
const buffer_1 = require("buffer");
|
|
14
|
+
const FileStorageUtilities_1 = require("./FileStorageUtilities");
|
|
15
|
+
const pathUtils_1 = require("../utils/pathUtils");
|
|
16
|
+
/**
|
|
17
|
+
* Browser-compatible FileStorage implementation using IndexedDB.
|
|
18
|
+
* @remarks
|
|
19
|
+
* This storage backend works in browsers and Electron renderer processes.
|
|
20
|
+
* Data persists across page reloads and browser sessions.
|
|
21
|
+
*/
|
|
22
|
+
class IndexedDBStorage {
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new `IndexedDBStorage` instance.
|
|
25
|
+
* @param dbName Name of the IndexedDB database. Defaults to 'vectra-db'.
|
|
26
|
+
*/
|
|
27
|
+
constructor(dbName = 'vectra-db') {
|
|
28
|
+
this._dbName = dbName;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Opens or creates the IndexedDB database.
|
|
32
|
+
*/
|
|
33
|
+
getDB() {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
if (this._db) {
|
|
36
|
+
return this._db;
|
|
37
|
+
}
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
const request = indexedDB.open(this._dbName, 1);
|
|
40
|
+
request.onerror = () => { var _a; return reject(new Error(`Failed to open IndexedDB: ${(_a = request.error) === null || _a === void 0 ? void 0 : _a.message}`)); };
|
|
41
|
+
request.onsuccess = () => {
|
|
42
|
+
this._db = request.result;
|
|
43
|
+
resolve(this._db);
|
|
44
|
+
};
|
|
45
|
+
request.onupgradeneeded = (event) => {
|
|
46
|
+
const db = event.target.result;
|
|
47
|
+
// Store for files: { path, content, createdAt, updatedAt }
|
|
48
|
+
if (!db.objectStoreNames.contains('files')) {
|
|
49
|
+
const fileStore = db.createObjectStore('files', { keyPath: 'path' });
|
|
50
|
+
fileStore.createIndex('parentPath', 'parentPath', { unique: false });
|
|
51
|
+
}
|
|
52
|
+
// Store for folders: { path, createdAt }
|
|
53
|
+
if (!db.objectStoreNames.contains('folders')) {
|
|
54
|
+
const folderStore = db.createObjectStore('folders', { keyPath: 'path' });
|
|
55
|
+
folderStore.createIndex('parentPath', 'parentPath', { unique: false });
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Normalizes a path for consistent storage.
|
|
63
|
+
*/
|
|
64
|
+
normalizePath(filePath) {
|
|
65
|
+
// Normalize and ensure forward slashes
|
|
66
|
+
let normalized = pathUtils_1.pathUtils.normalize(filePath);
|
|
67
|
+
// Remove trailing slash unless it's the root
|
|
68
|
+
if (normalized.length > 1 && normalized.endsWith('/')) {
|
|
69
|
+
normalized = normalized.slice(0, -1);
|
|
70
|
+
}
|
|
71
|
+
return normalized;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Gets the parent path of a given path.
|
|
75
|
+
*/
|
|
76
|
+
getParentPath(filePath) {
|
|
77
|
+
const normalized = this.normalizePath(filePath);
|
|
78
|
+
const parent = pathUtils_1.pathUtils.dirname(normalized);
|
|
79
|
+
return parent === normalized ? '' : parent;
|
|
80
|
+
}
|
|
81
|
+
createFile(filePath, content) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
const db = yield this.getDB();
|
|
84
|
+
const normalizedPath = this.normalizePath(filePath);
|
|
85
|
+
// Convert content to ArrayBuffer for storage
|
|
86
|
+
let arrayBuffer;
|
|
87
|
+
if (typeof content === 'string') {
|
|
88
|
+
arrayBuffer = new TextEncoder().encode(content).buffer;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
arrayBuffer = content.buffer.slice(content.byteOffset, content.byteOffset + content.byteLength);
|
|
92
|
+
}
|
|
93
|
+
return new Promise((resolve, reject) => {
|
|
94
|
+
const tx = db.transaction('files', 'readwrite');
|
|
95
|
+
const store = tx.objectStore('files');
|
|
96
|
+
const record = {
|
|
97
|
+
path: normalizedPath,
|
|
98
|
+
parentPath: this.getParentPath(normalizedPath),
|
|
99
|
+
content: arrayBuffer,
|
|
100
|
+
createdAt: Date.now(),
|
|
101
|
+
updatedAt: Date.now()
|
|
102
|
+
};
|
|
103
|
+
const request = store.add(record);
|
|
104
|
+
request.onsuccess = () => resolve();
|
|
105
|
+
request.onerror = () => reject(new Error(`File already exists: ${filePath}`));
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
createFolder(folderPath) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
const db = yield this.getDB();
|
|
112
|
+
const normalizedPath = this.normalizePath(folderPath);
|
|
113
|
+
// Create all parent folders recursively
|
|
114
|
+
const parts = normalizedPath.split('/').filter(Boolean);
|
|
115
|
+
let currentPath = '';
|
|
116
|
+
const tx = db.transaction('folders', 'readwrite');
|
|
117
|
+
const store = tx.objectStore('folders');
|
|
118
|
+
for (const part of parts) {
|
|
119
|
+
const parentPath = currentPath;
|
|
120
|
+
currentPath = currentPath ? `${currentPath}/${part}` : part;
|
|
121
|
+
// Use put to create or update (idempotent)
|
|
122
|
+
store.put({
|
|
123
|
+
path: currentPath,
|
|
124
|
+
parentPath: parentPath,
|
|
125
|
+
createdAt: Date.now()
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return new Promise((resolve, reject) => {
|
|
129
|
+
tx.oncomplete = () => resolve();
|
|
130
|
+
tx.onerror = () => reject(new Error(`Failed to create folder: ${folderPath}`));
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
deleteFile(filePath) {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
const db = yield this.getDB();
|
|
137
|
+
const normalizedPath = this.normalizePath(filePath);
|
|
138
|
+
return new Promise((resolve, reject) => {
|
|
139
|
+
const tx = db.transaction('files', 'readwrite');
|
|
140
|
+
const store = tx.objectStore('files');
|
|
141
|
+
const request = store.delete(normalizedPath);
|
|
142
|
+
request.onsuccess = () => resolve();
|
|
143
|
+
request.onerror = () => reject(new Error(`Failed to delete file: ${filePath}`));
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
deleteFolder(folderPath) {
|
|
148
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
+
const db = yield this.getDB();
|
|
150
|
+
const normalizedPath = this.normalizePath(folderPath);
|
|
151
|
+
const prefix = normalizedPath + '/';
|
|
152
|
+
return new Promise((resolve, reject) => {
|
|
153
|
+
const tx = db.transaction(['files', 'folders'], 'readwrite');
|
|
154
|
+
const fileStore = tx.objectStore('files');
|
|
155
|
+
const folderStore = tx.objectStore('folders');
|
|
156
|
+
// Delete all files with matching prefix
|
|
157
|
+
const filesCursor = fileStore.openCursor();
|
|
158
|
+
filesCursor.onsuccess = (event) => {
|
|
159
|
+
const cursor = event.target.result;
|
|
160
|
+
if (cursor) {
|
|
161
|
+
if (cursor.value.path === normalizedPath || cursor.value.path.startsWith(prefix)) {
|
|
162
|
+
cursor.delete();
|
|
163
|
+
}
|
|
164
|
+
cursor.continue();
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
// Delete all folders with matching prefix
|
|
168
|
+
const foldersCursor = folderStore.openCursor();
|
|
169
|
+
foldersCursor.onsuccess = (event) => {
|
|
170
|
+
const cursor = event.target.result;
|
|
171
|
+
if (cursor) {
|
|
172
|
+
if (cursor.value.path === normalizedPath || cursor.value.path.startsWith(prefix)) {
|
|
173
|
+
cursor.delete();
|
|
174
|
+
}
|
|
175
|
+
cursor.continue();
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
tx.oncomplete = () => resolve();
|
|
179
|
+
tx.onerror = () => reject(new Error(`Failed to delete folder: ${folderPath}`));
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
getDetails(fileOrFolderPath) {
|
|
184
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
+
const db = yield this.getDB();
|
|
186
|
+
const normalizedPath = this.normalizePath(fileOrFolderPath);
|
|
187
|
+
// Try to find as file first
|
|
188
|
+
const file = yield new Promise((resolve) => {
|
|
189
|
+
const tx = db.transaction('files', 'readonly');
|
|
190
|
+
const store = tx.objectStore('files');
|
|
191
|
+
const request = store.get(normalizedPath);
|
|
192
|
+
request.onsuccess = () => resolve(request.result);
|
|
193
|
+
request.onerror = () => resolve(undefined);
|
|
194
|
+
});
|
|
195
|
+
if (file) {
|
|
196
|
+
return {
|
|
197
|
+
name: pathUtils_1.pathUtils.basename(normalizedPath),
|
|
198
|
+
path: normalizedPath,
|
|
199
|
+
isFolder: false,
|
|
200
|
+
fileType: FileStorageUtilities_1.FileStorageUtilities.getFileType(normalizedPath)
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
// Try to find as folder
|
|
204
|
+
const folder = yield new Promise((resolve) => {
|
|
205
|
+
const tx = db.transaction('folders', 'readonly');
|
|
206
|
+
const store = tx.objectStore('folders');
|
|
207
|
+
const request = store.get(normalizedPath);
|
|
208
|
+
request.onsuccess = () => resolve(request.result);
|
|
209
|
+
request.onerror = () => resolve(undefined);
|
|
210
|
+
});
|
|
211
|
+
if (folder) {
|
|
212
|
+
return {
|
|
213
|
+
name: pathUtils_1.pathUtils.basename(normalizedPath),
|
|
214
|
+
path: normalizedPath,
|
|
215
|
+
isFolder: true
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
throw new Error(`Path not found: ${fileOrFolderPath}`);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
listFiles(folderPath, filter) {
|
|
222
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
223
|
+
const db = yield this.getDB();
|
|
224
|
+
const normalizedPath = this.normalizePath(folderPath);
|
|
225
|
+
const results = [];
|
|
226
|
+
// Get files in folder
|
|
227
|
+
if (filter !== 'folders') {
|
|
228
|
+
const files = yield new Promise((resolve) => {
|
|
229
|
+
const tx = db.transaction('files', 'readonly');
|
|
230
|
+
const store = tx.objectStore('files');
|
|
231
|
+
const index = store.index('parentPath');
|
|
232
|
+
const request = index.getAll(normalizedPath);
|
|
233
|
+
request.onsuccess = () => resolve(request.result || []);
|
|
234
|
+
request.onerror = () => resolve([]);
|
|
235
|
+
});
|
|
236
|
+
for (const file of files) {
|
|
237
|
+
results.push({
|
|
238
|
+
name: pathUtils_1.pathUtils.basename(file.path),
|
|
239
|
+
path: file.path,
|
|
240
|
+
isFolder: false,
|
|
241
|
+
fileType: FileStorageUtilities_1.FileStorageUtilities.getFileType(file.path)
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
// Get subfolders
|
|
246
|
+
if (filter !== 'files') {
|
|
247
|
+
const folders = yield new Promise((resolve) => {
|
|
248
|
+
const tx = db.transaction('folders', 'readonly');
|
|
249
|
+
const store = tx.objectStore('folders');
|
|
250
|
+
const index = store.index('parentPath');
|
|
251
|
+
const request = index.getAll(normalizedPath);
|
|
252
|
+
request.onsuccess = () => resolve(request.result || []);
|
|
253
|
+
request.onerror = () => resolve([]);
|
|
254
|
+
});
|
|
255
|
+
for (const folder of folders) {
|
|
256
|
+
results.push({
|
|
257
|
+
name: pathUtils_1.pathUtils.basename(folder.path),
|
|
258
|
+
path: folder.path,
|
|
259
|
+
isFolder: true
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return results;
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
pathExists(fileOrFolderPath) {
|
|
267
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
268
|
+
try {
|
|
269
|
+
yield this.getDetails(fileOrFolderPath);
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
catch (_a) {
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
readFile(filePath) {
|
|
278
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
279
|
+
const db = yield this.getDB();
|
|
280
|
+
const normalizedPath = this.normalizePath(filePath);
|
|
281
|
+
const file = yield new Promise((resolve, reject) => {
|
|
282
|
+
const tx = db.transaction('files', 'readonly');
|
|
283
|
+
const store = tx.objectStore('files');
|
|
284
|
+
const request = store.get(normalizedPath);
|
|
285
|
+
request.onsuccess = () => resolve(request.result);
|
|
286
|
+
request.onerror = () => reject(new Error(`Failed to read file: ${filePath}`));
|
|
287
|
+
});
|
|
288
|
+
if (!file) {
|
|
289
|
+
throw new Error(`File not found: ${filePath}`);
|
|
290
|
+
}
|
|
291
|
+
// Convert ArrayBuffer back to Buffer
|
|
292
|
+
return buffer_1.Buffer.from(file.content);
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
upsertFile(filePath, content) {
|
|
296
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
297
|
+
const db = yield this.getDB();
|
|
298
|
+
const normalizedPath = this.normalizePath(filePath);
|
|
299
|
+
// Convert content to ArrayBuffer for storage
|
|
300
|
+
let arrayBuffer;
|
|
301
|
+
if (typeof content === 'string') {
|
|
302
|
+
arrayBuffer = new TextEncoder().encode(content).buffer;
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
arrayBuffer = content.buffer.slice(content.byteOffset, content.byteOffset + content.byteLength);
|
|
306
|
+
}
|
|
307
|
+
return new Promise((resolve, reject) => {
|
|
308
|
+
const tx = db.transaction('files', 'readwrite');
|
|
309
|
+
const store = tx.objectStore('files');
|
|
310
|
+
const record = {
|
|
311
|
+
path: normalizedPath,
|
|
312
|
+
parentPath: this.getParentPath(normalizedPath),
|
|
313
|
+
content: arrayBuffer,
|
|
314
|
+
createdAt: Date.now(),
|
|
315
|
+
updatedAt: Date.now()
|
|
316
|
+
};
|
|
317
|
+
const request = store.put(record);
|
|
318
|
+
request.onsuccess = () => resolve();
|
|
319
|
+
request.onerror = () => reject(new Error(`Failed to write file: ${filePath}`));
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Closes the database connection.
|
|
325
|
+
*/
|
|
326
|
+
close() {
|
|
327
|
+
if (this._db) {
|
|
328
|
+
this._db.close();
|
|
329
|
+
this._db = undefined;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Deletes the entire database.
|
|
334
|
+
*/
|
|
335
|
+
destroy() {
|
|
336
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
337
|
+
this.close();
|
|
338
|
+
return new Promise((resolve, reject) => {
|
|
339
|
+
const request = indexedDB.deleteDatabase(this._dbName);
|
|
340
|
+
request.onsuccess = () => resolve();
|
|
341
|
+
request.onerror = () => reject(new Error(`Failed to delete database: ${this._dbName}`));
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
exports.IndexedDBStorage = IndexedDBStorage;
|
|
347
|
+
//# sourceMappingURL=IndexedDBStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IndexedDBStorage.js","sourceRoot":"","sources":["../../src/storage/IndexedDBStorage.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAAgC;AAEhC,iEAA8D;AAC9D,kDAA+C;AAE/C;;;;;GAKG;AACH,MAAa,gBAAgB;IAIzB;;;OAGG;IACH,YAAY,SAAiB,WAAW;QACpC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,CAAC;IAED;;OAEG;IACW,KAAK;;YACf,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;gBACX,OAAO,IAAI,CAAC,GAAG,CAAC;YACpB,CAAC;YAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACnC,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;gBAEhD,OAAO,CAAC,OAAO,GAAG,GAAG,EAAE,WAAC,OAAA,MAAM,CAAC,IAAI,KAAK,CAAC,6BAA6B,MAAA,OAAO,CAAC,KAAK,0CAAE,OAAO,EAAE,CAAC,CAAC,CAAA,EAAA,CAAC;gBAEjG,OAAO,CAAC,SAAS,GAAG,GAAG,EAAE;oBACrB,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;oBAC1B,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACtB,CAAC,CAAC;gBAEF,OAAO,CAAC,eAAe,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AE,CAAC;YACjB,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC;QACzB,CAAC;IACL,CAAC;IAED;;OAEG;IACG,OAAO;;YACT,IAAI,CAAC,KAAK,EAAE,CAAC;YAEb,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACnC,MAAM,OAAO,GAAG,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACvD,OAAO,CAAC,SAAS,GAAG,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;gBACpC,OAAO,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,8BAA8B,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YAC5F,CAAC,CAAC,CAAC;QACP,CAAC;KAAA;CACJ;AAjWD,4CAiWC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser stub for LocalFileStorage.
|
|
3
|
+
* This module throws an error if LocalFileStorage is used in a browser environment.
|
|
4
|
+
* Use IndexedDBStorage or VirtualFileStorage instead.
|
|
5
|
+
*/
|
|
6
|
+
import { FileStorage, FileDetails } from "./FileStorage";
|
|
7
|
+
export declare class LocalFileStorage implements FileStorage {
|
|
8
|
+
constructor();
|
|
9
|
+
createFile(): Promise<void>;
|
|
10
|
+
createFolder(): Promise<void>;
|
|
11
|
+
deleteFile(): Promise<void>;
|
|
12
|
+
deleteFolder(): Promise<void>;
|
|
13
|
+
getDetails(): Promise<FileDetails>;
|
|
14
|
+
listFiles(): Promise<FileDetails[]>;
|
|
15
|
+
pathExists(): Promise<boolean>;
|
|
16
|
+
readFile(): Promise<Buffer>;
|
|
17
|
+
upsertFile(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=LocalFileStorage.browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalFileStorage.browser.d.ts","sourceRoot":"","sources":["../../src/storage/LocalFileStorage.browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAmB,MAAM,eAAe,CAAC;AAE1E,qBAAa,gBAAiB,YAAW,WAAW;;IAQhD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B,UAAU,IAAI,OAAO,CAAC,WAAW,CAAC;IAIlC,SAAS,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAInC,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAI9B,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAG9B"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Browser stub for LocalFileStorage.
|
|
4
|
+
* This module throws an error if LocalFileStorage is used in a browser environment.
|
|
5
|
+
* Use IndexedDBStorage or VirtualFileStorage instead.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.LocalFileStorage = void 0;
|
|
9
|
+
class LocalFileStorage {
|
|
10
|
+
constructor() {
|
|
11
|
+
throw new Error('LocalFileStorage is not supported in browser environments. ' +
|
|
12
|
+
'Use IndexedDBStorage or VirtualFileStorage instead.');
|
|
13
|
+
}
|
|
14
|
+
createFile() {
|
|
15
|
+
throw new Error('LocalFileStorage is not supported in browser environments.');
|
|
16
|
+
}
|
|
17
|
+
createFolder() {
|
|
18
|
+
throw new Error('LocalFileStorage is not supported in browser environments.');
|
|
19
|
+
}
|
|
20
|
+
deleteFile() {
|
|
21
|
+
throw new Error('LocalFileStorage is not supported in browser environments.');
|
|
22
|
+
}
|
|
23
|
+
deleteFolder() {
|
|
24
|
+
throw new Error('LocalFileStorage is not supported in browser environments.');
|
|
25
|
+
}
|
|
26
|
+
getDetails() {
|
|
27
|
+
throw new Error('LocalFileStorage is not supported in browser environments.');
|
|
28
|
+
}
|
|
29
|
+
listFiles() {
|
|
30
|
+
throw new Error('LocalFileStorage is not supported in browser environments.');
|
|
31
|
+
}
|
|
32
|
+
pathExists() {
|
|
33
|
+
throw new Error('LocalFileStorage is not supported in browser environments.');
|
|
34
|
+
}
|
|
35
|
+
readFile() {
|
|
36
|
+
throw new Error('LocalFileStorage is not supported in browser environments.');
|
|
37
|
+
}
|
|
38
|
+
upsertFile() {
|
|
39
|
+
throw new Error('LocalFileStorage is not supported in browser environments.');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.LocalFileStorage = LocalFileStorage;
|
|
43
|
+
//# sourceMappingURL=LocalFileStorage.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalFileStorage.browser.js","sourceRoot":"","sources":["../../src/storage/LocalFileStorage.browser.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAIH,MAAa,gBAAgB;IACzB;QACI,MAAM,IAAI,KAAK,CACX,6DAA6D;YAC7D,qDAAqD,CACxD,CAAC;IACN,CAAC;IAED,UAAU;QACN,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,CAAC;IAED,YAAY;QACR,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,CAAC;IAED,UAAU;QACN,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,CAAC;IAED,YAAY;QACR,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,CAAC;IAED,UAAU;QACN,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,CAAC;IAED,SAAS;QACL,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,CAAC;IAED,UAAU;QACN,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,CAAC;IAED,QAAQ;QACJ,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,CAAC;IAED,UAAU;QACN,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,CAAC;CACJ;AA3CD,4CA2CC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FileDetails, FileStorage, ListFilesFilter } from "./FileStorage";
|
|
2
|
+
/**
|
|
3
|
+
* A `FileStorage` implementation that uses the local file system.
|
|
4
|
+
*/
|
|
5
|
+
export declare class LocalFileStorage implements FileStorage {
|
|
6
|
+
private _rootFolder;
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new `LocalFileStorage` instance.
|
|
9
|
+
* @param rootFolder Optional. Root folder to use for file operations. If not provided, paths passed to operations should be fully qualified.
|
|
10
|
+
*/
|
|
11
|
+
constructor(rootFolder?: string);
|
|
12
|
+
createFile(filePath: string, content: Buffer | string): Promise<void>;
|
|
13
|
+
createFolder(folderPath: string): Promise<void>;
|
|
14
|
+
deleteFile(filePath: string): Promise<void>;
|
|
15
|
+
deleteFolder(folderPath: string): Promise<void>;
|
|
16
|
+
getDetails(fileOrFolderPath: string): Promise<FileDetails>;
|
|
17
|
+
listFiles(folderPath: string, _filter?: ListFilesFilter | undefined): Promise<FileDetails[]>;
|
|
18
|
+
pathExists(fileOrFolderPath: string): Promise<boolean>;
|
|
19
|
+
readFile(filePath: string): Promise<Buffer>;
|
|
20
|
+
upsertFile(filePath: string, content: Buffer | string): Promise<void>;
|
|
21
|
+
private getFullPath;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=LocalFileStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalFileStorage.d.ts","sourceRoot":"","sources":["../../src/storage/LocalFileStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAK1E;;GAEG;AACH,qBAAa,gBAAiB,YAAW,WAAW;IAChD,OAAO,CAAC,WAAW,CAAqB;IAExC;;;OAGG;gBACS,UAAU,CAAC,EAAE,MAAM;IAIzB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAC,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUnE,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3C,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C,UAAU,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAU1D,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAa5F,UAAU,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAStD,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI3C,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAC,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUzE,OAAO,CAAC,WAAW;CAUtB"}
|
|
@@ -0,0 +1,152 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.LocalFileStorage = void 0;
|
|
49
|
+
const FileStorageUtilities_1 = require("./FileStorageUtilities");
|
|
50
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
51
|
+
const path = __importStar(require("node:path"));
|
|
52
|
+
/**
|
|
53
|
+
* A `FileStorage` implementation that uses the local file system.
|
|
54
|
+
*/
|
|
55
|
+
class LocalFileStorage {
|
|
56
|
+
/**
|
|
57
|
+
* Creates a new `LocalFileStorage` instance.
|
|
58
|
+
* @param rootFolder Optional. Root folder to use for file operations. If not provided, paths passed to operations should be fully qualified.
|
|
59
|
+
*/
|
|
60
|
+
constructor(rootFolder) {
|
|
61
|
+
this._rootFolder = rootFolder;
|
|
62
|
+
}
|
|
63
|
+
createFile(filePath, content) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
// Convert content to buffer if it's a string
|
|
66
|
+
if (typeof content == 'string') {
|
|
67
|
+
content = Buffer.from(content, 'utf8');
|
|
68
|
+
}
|
|
69
|
+
// Write the file
|
|
70
|
+
yield promises_1.default.writeFile(this.getFullPath(filePath), content, { flag: 'wx' });
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
createFolder(folderPath) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
yield promises_1.default.mkdir(this.getFullPath(folderPath), { recursive: true });
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
deleteFile(filePath) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
yield promises_1.default.unlink(this.getFullPath(filePath));
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
deleteFolder(folderPath) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
yield promises_1.default.rm(this.getFullPath(folderPath), { recursive: true });
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
getDetails(fileOrFolderPath) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
const stats = yield promises_1.default.stat(this.getFullPath(fileOrFolderPath));
|
|
91
|
+
return {
|
|
92
|
+
name: path.basename(fileOrFolderPath),
|
|
93
|
+
path: fileOrFolderPath,
|
|
94
|
+
isFolder: stats.isDirectory(),
|
|
95
|
+
fileType: stats.isFile() ? FileStorageUtilities_1.FileStorageUtilities.getFileType(fileOrFolderPath) : undefined
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
listFiles(folderPath, _filter) {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
const folder = this.getFullPath(folderPath);
|
|
102
|
+
const list = yield promises_1.default.readdir(folder, { withFileTypes: true });
|
|
103
|
+
return list.map((entry) => {
|
|
104
|
+
return {
|
|
105
|
+
name: entry.name,
|
|
106
|
+
path: path.join(folder, entry.name),
|
|
107
|
+
isFolder: entry.isDirectory(),
|
|
108
|
+
fileType: entry.isFile() ? FileStorageUtilities_1.FileStorageUtilities.getFileType(entry.name) : undefined
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
pathExists(fileOrFolderPath) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
try {
|
|
116
|
+
yield promises_1.default.access(this.getFullPath(fileOrFolderPath));
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
readFile(filePath) {
|
|
125
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
return yield promises_1.default.readFile(this.getFullPath(filePath));
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
upsertFile(filePath, content) {
|
|
130
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
// Convert content to buffer if it's a string
|
|
132
|
+
if (typeof content == 'string') {
|
|
133
|
+
content = Buffer.from(content, 'utf8');
|
|
134
|
+
}
|
|
135
|
+
// Write the file
|
|
136
|
+
yield promises_1.default.writeFile(this.getFullPath(filePath), content, { flag: 'w' });
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
getFullPath(relativePath) {
|
|
140
|
+
if (!this._rootFolder) {
|
|
141
|
+
return relativePath.length > 0 ? relativePath : '.';
|
|
142
|
+
}
|
|
143
|
+
else if (relativePath.length == 0) {
|
|
144
|
+
return this._rootFolder;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
return path.join(this._rootFolder, relativePath);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
exports.LocalFileStorage = LocalFileStorage;
|
|
152
|
+
//# sourceMappingURL=LocalFileStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalFileStorage.js","sourceRoot":"","sources":["../../src/storage/LocalFileStorage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iEAA8D;AAC9D,2DAA6B;AAC7B,gDAAkC;AAElC;;GAEG;AACH,MAAa,gBAAgB;IAGzB;;;OAGG;IACH,YAAY,UAAmB;QAC3B,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAClC,CAAC;IAEK,UAAU,CAAC,QAAgB,EAAE,OAAsB;;YACrD,6CAA6C;YAC7C,IAAI,OAAO,OAAO,IAAI,QAAQ,EAAE,CAAC;gBAC7B,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAC3C,CAAC;YAED,iBAAiB;YACjB,MAAM,kBAAE,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,OAAO,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