@flowscripter/io-plugin-filesystem
v2.0.5
Published
Local filesystem source/sink plugin for https://github.com/flowscripter/pluggable-io-framework
Maintainers
Readme
io-plugin-filesystem
Local filesystem source/sink plugin for pluggable-io-framework, loaded via dynamic-plugin-framework
Key Features
- Implements the
IOProviderFactory/IOProvidercontract from pluggable-io-framework-api for the local filesystem - both source and sink. - Factory for the
fileprotocol with thejspayload kind. Locations arefile:URLs (file:///fooorfile:/foo) or bare paths, validated byfilesystemLocationSchema(path, plus an optionalfilenamefor a single entry or a globpatternfor matching entries).toProviderInputsjoinspathandfilenamewith the OS path separator into aLocationTarget. - Config:
{ rootPath?: string }(validated with Zod) -rootPathis optional, defaulting to"". All paths passed to provider methods are resolved and sandboxed againstrootPath- a path that would escape it is rejected.rootPath: ""(or omitted) is an explicit sentinel for "no restriction" (full filesystem access), since POSIX"/"isn't a meaningful "everything" root on Windows (multiple drive letters, no single filesystem root). Locations parsed from strings always use the unrestricted config. list(recursive, regex-filterable),getProperties(size/lastModified/isContainer plus amodeextension property),setProperties(lastModifiedplus amodeproperty validated byfilesystemSettablePropertySchema),delete,createContainerandjoinKey.- Readable handles implement
RangeReadable(readRange(start, end)with an exclusiveend). Writable handles implementResumableWritable: resuming appends from the file's current size, reported asstartOffset. - Multipart writes (concurrent byte-range parts written directly to file
offsets via a single shared file handle) at a caller-supplied part size -
getPartSizeConstraintsreports unconstrained bounds with an 8MB default, since the local filesystem imposes no real part-size limits. canDirectTransfer/directCopy/directMove: twoFilesystemIOProviderinstances with the samerootPathcopy/move directly (cp/rename, with anEXDEVcross-device fallback to recursive copy+delete) instead of streaming.supportsRecursiveDirectTransferistrue- a directorysourcePathis copied/moved recursively in onedirectCopy/directMovecall, preserving empty subdirectories.- Bundled (
bun build --target bun) as a single-file plugin, loaded bydynamic-plugin-frameworkviaimport()- proven end to end in this repo's tests via a realLocalFolderPluginRepository, not just type-checking. - Discoverable via
NpmPluginRepository(the mechanism behinddynamic-cli-framework'splugin add/plugin listcommands): the package.jsonpluggable-io-frameworkfield declares this package's extension points, so once installed into a CLI's local plugin store it is found without the consuming CLI needing a direct npm dependency on it - also proven end to end in this repo's tests, not just type-checking.
String and Structured Locations
A file location can be given in two forms:
- A string: a
file:URL (file:///fooorfile:/foo, no host) or a bare path.parseLocationStringreturns only{ path }, so a string always addresses the wholepathas acontainertarget. Strings are the convenient form for code holding a path or URL, and the form other providers use when they resolve afilelocation. - A structured location object,
{ path, filename?, pattern? }, validated byfilesystemLocationSchemadirectly. It is needed to address a single file (filename, anentrytarget) or the files matching a glob (pattern, apatterntarget), which a string cannot express.
Bundled Bun Module Usage
Loaded as a dynamic-plugin-framework
plugin - see that project's docs for how a host application discovers and
instantiates plugins. Direct usage of the bundle, where registry is a
pluggable-io-framework ProviderRegistry (or any ProviderResolver):
import filesystemPlugin, {
filesystemIOProviderFactory,
} from "https://unpkg.com/@flowscripter/io-plugin-filesystem/dist/bundle.js";
const provider = await filesystemIOProviderFactory.createProvider(
{ rootPath: "/data" },
{ resolver: registry },
);Development
Install dependencies:
bun install
Test:
bun test
Bundle for usage as a dynamic-plugin-framework plugin:
bun run build
Format:
bunx oxfmt
Lint:
bunx oxlint index.ts src/ tests/
Generate HTML API Documentation:
bunx typedoc index.ts
Documentation
Overview
Refer to pluggable-io-framework-api and pluggable-io-framework for the contract and orchestration this plugin implements.
API
Link to auto-generated API docs:
License
MIT © Flowscripter
