UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

73 lines • 2.98 kB
// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. ========= // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // ========= Copyright 2026 @ Strukto.AI All Rights Reserved. ========= import { append as tfsAppend } from "../../core/tidb_filesystem/append.js"; import { create as tfsCreate } from "../../core/tidb_filesystem/create.js"; import { exists as tfsExists } from "../../core/tidb_filesystem/exists.js"; import { mkdir as tfsMkdir } from "../../core/tidb_filesystem/mkdir.js"; import { read as tfsRead } from "../../core/tidb_filesystem/read.js"; import { readdir as tfsReaddir } from "../../core/tidb_filesystem/readdir.js"; import { rename as tfsRename } from "../../core/tidb_filesystem/rename.js"; import { rmRecursive as tfsRmR } from "../../core/tidb_filesystem/rm.js"; import { rmdir as tfsRmdir } from "../../core/tidb_filesystem/rmdir.js"; import { stat as tfsStat } from "../../core/tidb_filesystem/stat.js"; import { readStream as tfsStream } from "../../core/tidb_filesystem/stream.js"; import { unlink as tfsUnlink } from "../../core/tidb_filesystem/unlink.js"; import { write as tfsWrite } from "../../core/tidb_filesystem/write.js"; import { BaseVFS } from "../base.js"; /** * TiDBFilesystem's functions over its accessor, which a host package builds * over its own transport. */ export class TiDBFilesystemVFS extends BaseVFS { readsRanges = true; readdir(path) { return tfsReaddir(this.accessor, path); } read(path, _handed, offset = 0, size = null) { if (offset === 0 && size === null) return tfsStream(this.accessor, path); return tfsRead(this.accessor, path, offset, size); } stat(path) { return tfsStat(this.accessor, path); } exists(path) { return tfsExists(this.accessor, path); } write(path, data) { return tfsWrite(this.accessor, path, data); } append(path, data) { return tfsAppend(this.accessor, path, data); } create(path) { return tfsCreate(this.accessor, path); } mkdir(path, parents = false) { return tfsMkdir(this.accessor, path, parents); } unlink(path) { return tfsUnlink(this.accessor, path); } rmdir(path) { return tfsRmdir(this.accessor, path); } rmR(path) { return tfsRmR(this.accessor, path); } rename(src, dst) { return tfsRename(this.accessor, src, dst); } } //# sourceMappingURL=tidb_filesystem.js.map