Skip to main content

table_editor/
lib.rs

1//! A browser-based editor for a repository's JSONL tables.
2//!
3//! A repository describes its tables by implementing [`TableLogic`] once per
4//! table—parse, serialize, validate, derive, siblings, and a column
5//! [`Schema`]—and [`App`] once for the collection. [`Server`] turns that into a
6//! local HTTP server: it serves the embedded browser bundle at `/` and the
7//! editor's API under `/api`.
8//!
9//! The API is `GET /api/app` for the shell (the app's name and its tables) and
10//! three endpoints per table: `GET /api/<table>` reads, `PUT /api/<table>`
11//! writes, and `POST /api/<table>/derive` validates and derives without
12//! writing. `GET /api/health` and `POST /api/shutdown` control the process. All
13//! file I/O runs here, through the [`Context`] that resolves the `Data/`
14//! directory; the browser is a thin UI that renders whatever the schema in the
15//! GET payload describes.
16//!
17//! Launching reuses an already-running server on the same port (it just opens a
18//! browser at it); `--restart` shuts the old one down first and starts fresh.
19//! The server itself runs as a detached worker process, marked by an
20//! environment variable so it serves rather than re-spawning itself.
21//!
22//! # Features
23//!
24//! `server` is on by default and is everything above. Without it the crate is
25//! the file format alone—[`jsonl`], [`ParseError`], [`ValidationError`], and
26//! [`ApiError`]—and depends on nothing but `serde` and `serde_json`, which is
27//! what a crate that only reads and writes the tables wants.
28
29mod error;
30pub mod jsonl;
31
32#[cfg(feature = "server")]
33mod context;
34#[cfg(feature = "server")]
35mod launch;
36#[cfg(feature = "server")]
37mod probe;
38#[cfg(feature = "server")]
39mod routes;
40#[cfg(feature = "server")]
41mod schema;
42#[cfg(feature = "server")]
43mod server;
44#[cfg(feature = "server")]
45mod table;
46#[cfg(feature = "server")]
47mod view;
48
49#[cfg(all(test, feature = "server"))]
50mod fixture;
51
52pub use error::{ApiError, ParseError, ValidationError};
53
54#[cfg(feature = "server")]
55pub use context::Context;
56#[cfg(feature = "server")]
57pub use probe::{probe, probe_status};
58#[cfg(feature = "server")]
59pub use schema::{
60    ChipContent, Column, ColumnType, Datalist, FromRows, MapSpec, NewRow, OptionsBy, Schema,
61    SelectOption, Speak,
62};
63#[cfg(feature = "server")]
64pub use server::{Server, ServerArgs, ServerCommand};
65#[cfg(feature = "server")]
66pub use table::{App, Front, Table, TableLogic};
67#[cfg(feature = "server")]
68pub use view::{Param, Section, View, ViewArgs, ViewData, ViewLogic};