Class FileEntityStore
- Namespace
- Kuestenlogik.Bowire.Workspace.Git
- Assembly
- Kuestenlogik.Bowire.Workspace.Git.dll
File-backed IBowireEntityStore implementation — one
.json per entity under <storageRoot>/<entityKind>/.
Collections get an additional per-request layout: each entry that
looks like an HTTP request (heuristic: requests array on the
document) writes a separate <request-id>.req.json sibling
under collections/<collection-id>/ so OpenAPI-shaped
collection diffs show one request per file in PR review — instead of
the whole collection's request array exploding on every edit.
JSON serialisation matches the workbench's bundle store: WriteIndented on, camelCase preserved (we don't reshape the document — we trust the caller's shape — but the pretty-print pass keeps diffs reviewable).
The store is robust against missing directories: every write creates
the per-kind directory on demand, every read against a missing file
returns null, every delete against a missing target is a
no-op. That lets the workbench's "save environment" path land
without a separate "create the folder skeleton first" round-trip.
public sealed class FileEntityStore : IBowireEntityStore
- Inheritance
-
FileEntityStore
- Implements
- Inherited Members
Constructors
FileEntityStore(string)
Construct a store rooted at storageRoot.
The path is expected to point at a workspace directory laid out
by bowire workspace init (or migrated via
BowireGitWorkspaceMigrator). The directory is created
lazily on first write — passing a path that doesn't exist yet is
fine.
public FileEntityStore(string storageRoot)
Parameters
storageRootstring
Properties
StorageRoot
The on-disk root this store reads + writes through. Exposed so the migrator can target the same path the workbench will read from, without re-deriving it from configuration.
public string StorageRoot { get; }
Property Value
Methods
DeleteAsync(string, string, CancellationToken)
Remove the entity (and any per-request side files for collections). No-op when the entity is already absent so callers can re-run a delete idempotently.
public Task DeleteAsync(string entityKind, string id, CancellationToken ct = default)
Parameters
entityKindstringidstringctCancellationToken
Returns
ListAsync(string, CancellationToken)
Enumerate the ids of every entity of entityKind
currently on disk. Order is implementation-defined; the workbench
sorts client-side for stable display.
public Task<IReadOnlyList<string>> ListAsync(string entityKind, CancellationToken ct = default)
Parameters
entityKindstringctCancellationToken
Returns
LoadAsync(string, string, CancellationToken)
Read the raw JSON document for id within
entityKind. Returns null when the entity
is absent — callers treat that as "the user hasn't authored one
yet" and don't surface an error.
public Task<string?> LoadAsync(string entityKind, string id, CancellationToken ct = default)
Parameters
entityKindstringidstringctCancellationToken
Returns
SaveAsync(string, string, string, CancellationToken)
Persist json as the canonical document for
id within entityKind.
Implementations create the per-kind directory on first write so
the workbench doesn't have to scaffold the layout up-front.
public Task SaveAsync(string entityKind, string id, string json, CancellationToken ct = default)
Parameters
entityKindstringidstringjsonstringctCancellationToken