Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
74 changes: 66 additions & 8 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,70 @@ work here.
that names every type.
- `crates/flowapi-ts`: the TypeScript target. `tests/cases/*.json` and the `.ts` kept beside each.
`src/sdk.rs` the opt-in SDK (`--sdk`): `sdk/request.rs`, `sdk/response.rs` and the runtime
printed once (`sdk/runtime.ts`); `tests/sdk/*.json` kept like the cases.
printed once (`sdk/runtime.ts` writes requests, `sdk/multipart.ts` their `multipart/form-data`
bodies, `sdk/read.ts` reads responses);
`tests/sdk/*.json` kept like the cases.
- `crates/flowapi-rust`: the Rust target (serde types). `tests/cases/*.rs`, kept like the TypeScript ones.
`src/sdk.rs` the opt-in SDK (`--target rust --sdk`): `sdk/request.rs`, `sdk/param.rs`,
`sdk/response.rs`, and the runtime printed once as `pub mod sdk` (`sdk/runtime.rs` and
`sdk/errors.rs`, its modules `sdk/write.rs`, `sdk/expand.rs` and `sdk/finite.rs`, never compiled
here: this crate has no serde); `src/print/integer.rs` the `Integer` type printed with the types;
`tests/sdk/*.rs` kept for the TypeScript SDK's cases and `tests/sdk/names.json`.
- `crates/flowapi-cli`: the `flowapi` command, all of flowapi's I/O.
- `crates/flowapi-wasm`: the core and the TypeScript target as a WebAssembly module for the npm
package, behind four exports of its own (`src/abi.rs`: JSON in and out through linear memory,
no wasm-bindgen); the one crate with `unsafe` (`deny`, not `forbid`; `tests/lints.rs`).
- `npm/`: `@localix-ai/flowapi`, the module with a typed API (`src/index.ts`), the files a
description reaches read from disk (`src/node.ts`) and the `flowapi` command (`src/cli.ts`);
JSON only. `bun run check` in `npm/` builds it and holds it to the Rust command byte for byte.
- `crates/flowapi-sdk`: the SDK layer, above the targets: what a client needs beside a target's
SDK, which no type depends on. It reads the documents through the core's public modules
(`doc.rs`: references followed, each endpoint's Operation Object found again), `servers.rs`
(3.x `servers` at three levels with variables; 2.0's `host`, `basePath`, `schemes` lifted) and
`security.rs` (`securitySchemes` or 2.0's `securityDefinitions`, `security`) into `model.rs`,
and `print.rs` prints the TypeScript table put after `--sdk`'s output (`flowapiServers`,
`flowapiSecuritySchemes`, `flowapiOperations`), naming the functions as `flowapi-ts` does. No
I/O (G5). `tests/cases/*.json` and the `.ts` kept beside each (`--test table`, each case's
`x-flowapi-covers` the ledger's markers); `tests/tsc.mjs` type-checks and imports them after the
`--sdk` output. The `flowapi-sdk.yml` config, also no I/O: `config/shape.rs` (and
`shape/schemes.rs`) its format once, as tables that `config/read.rs` validates by,
`config/build.rs` reads into `config/model.rs` and `config/schema.rs` prints as JSON Schema;
`config/check.rs` and `config/names.rs` hold it to the description, `config/issue.rs` the
issues; `ops.rs` the operations by id and route, `words.rs` names as words, `paging/` the
pagination a schema fits (`fit.rs`) or suggests (`suggest.rs`), `draft.rs` (`draft/naming.rs`)
a first config, `summary.rs` the compact summary. `tests/config/*.yml` with the issues kept
beside each (`--test config`), `tests/schema.json` (`--test schema`, the reader and the schema
agree both ways), `tests/draft/` (`--test draft`), `tests/summary/` (`--test summary`).
`encoding.rs` a `multipart/form-data` body's encoding, put in the table. `client.rs` the whole
TypeScript client from a config (`client_files`): `client/resources.rs` a class per resource,
`client/entry.rs` the client class and `index.ts`, `client/core/*.ts` the runtime, kept as
TypeScript and printed as it is (each file held to 300 working lines by `tests/client.mjs`).
`tests/client/<case>/` a config and a description with the client kept beside them
(`--test client`); `tests/client.mjs` type-checks them and runs `tests/client/*.mjs` against a
stub `fetch`, each test naming the pitfall it holds. `repo.rs` the whole repository around the
client (`repo_files`): `repo/package.rs` `package.json`, the TypeScript configs and the
license, `repo/texts.rs` the scripts, CI, release-please and the repository's `AGENTS.md`,
`repo/mock.rs` the mock server's routes, `repo/suite.rs` a test per resource, `repo/readme.rs`
`README.md` and `api.md`, `repo/example.rs` a schema's example value, `repo/lock.rs`
`.flowapi/lock.json` (the shape the `sdk-anything` plugin reads), `repo/plan.rs` what writing the
repository changes on disk (`plan`: by the lock and what the host found at each path; every host
runs it, none decides alone); `repo/files/` the texts printed
as they are (scripts, `server.mjs`, the licenses); `sha256.rs` our own SHA-256.
`tests/repo/<case>/` the repository of each client case but its `src/`, kept (`--test repo`).
- `crates/flowapi-cli`: the `flowapi` command, all of flowapi's I/O. `src/sdk.rs` the subcommands
put before the path (`summary`, `config draft|schema|check`; `tests/sdk_cli.rs`);
`src/generate.rs` `generate`, `generate/disk.rs` what is on disk for the SDK layer's `plan`,
`generate/apply.rs` the writes, staged first (`tests/generate_cli.rs`).
- `crates/flowapi-yaml`: a description's text as the core reads it, shared by the command and the
WebAssembly module: which document is YAML (`is_yaml`), YAML 1.2 read into JSON with each node's
YAML place (`reader.rs`, `saphyr-parser`), and the line and column of an offset. No I/O (G5).
- `crates/flowapi-wasm`: the core, the TypeScript target and the YAML reader as a WebAssembly
module for the npm package, behind four exports of its own (`src/abi.rs`: JSON in and out
through linear memory, no wasm-bindgen); the one crate with `unsafe` (`deny`, not `forbid`;
`tests/lints.rs`). Its `sdk` feature adds the SDK layer's config commands (`src/sdk.rs`, the
export `flowapi_sdk`) and `generate`'s two halves, `repo` and `plan` (`src/repo.rs`).
- `crates/flowapi-wasm-sdk`: the package's second module, `flowapi-wasm` with `sdk` linked into
a module of its own (no code, no `unsafe`; `tests/sdk.rs`), so the generator's module stays
without it. Built in a cargo run of its own: with `-p flowapi-wasm` it would turn `sdk` on.
- `npm/`: `@localix-ai/flowapi`, the modules with a typed API (`src/index.ts`, its requests in
`src/request.ts`), the files a description reaches read from disk (`src/node.ts`) and the
`flowapi` command (`src/cli.ts`; `summary` and `config` in `src/sdk-cli.ts`, `generate` in
`src/generate-cli.ts` with the disk it reads and writes in `src/generate-disk.ts`; paths joined
as Rust's in `src/paths.ts`); JSON and YAML.
`bun run check` in `npm/` builds it and holds it to the Rust command byte for byte.
- `conformance/`: the oracles that hold flowapi to the specifications
([conformance/README.md](conformance/README.md)): the official suites' pinned copies
(`suites/`), the suite oracle (`suite/`, O3; `suite-rust/` for the Rust target), the same
Expand Down Expand Up @@ -76,6 +126,14 @@ cargo test -p flowapi-rust --test sdk # the Rust SDK kept for e
(cd conformance/sdk-rust && cargo run --release -j 1 --bin corpus -- --build) # its corpus
(cd bench/sdk-rust && cargo run --release -j 1) # writing requests against progenitor's way
cargo test -p flowapi-ts --test fuzz # O7, no input panics
cargo test -p flowapi-sdk --test table # the SDK layer's tables (FLOWAPI_BLESS=1)
cargo test -p flowapi-sdk --test config # also --test schema, draft, summary (FLOWAPI_BLESS=1)
cargo test -p flowapi-sdk --test client # the clients kept in tests/client/ (FLOWAPI_BLESS=1)
node crates/flowapi-sdk/tests/client.mjs # them type-checked and run against a stub fetch
cargo test -p flowapi-cli --test sdk_cli # summary and config as the command runs them
cargo test -p flowapi-sdk --test repo # the repositories kept in tests/repo/ (FLOWAPI_BLESS=1)
cargo test -p flowapi-cli --test generate_cli # generate's writing rules as the command runs them
node crates/flowapi-sdk/tests/tsc.mjs # them type-checked after --sdk; after cargo build --release
cargo run --release -p flowapi-cli -- <description.json> -o types.ts
bench/run.sh # the benchmarks, then held to bench/budgets.json
```
Expand Down
101 changes: 101 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,107 @@

## Unreleased

## 0.2.0 — 2026-11-26

- `flowapi generate <flowapi-sdk.yml> --out <dir> [--check]` writes a TypeScript SDK's whole
repository: the client's `src/`, `package.json` (ES modules and CommonJS, each with its types,
`sideEffects: false`, `engines.node >=20`, `typescript` 7.0.2 the one development dependency),
the TypeScript configs (`tsconfig.json`, `.build`, `.cjs`, `.dist`), POSIX `scripts/` (`build`,
`lint`, `test`, `check`, `mock`), a mock server printed from the description (`mock/`, strict on
path, method, required parameters and the body's media type, a concrete path matched before a
templated one and, of two templated paths, the one literal at the first segment where they
differ; it answers with an example of each operation's schema: `example`, else `default`,
`const`, the first `enum` value, else one made from its type and `format`),
`tests/api-resources/*.test.mjs` calling every method against it under `node --test`,
`README.md` (its example's parameters from their own `example` or `examples`, 2.0's
`x-example`, the schema's value, else their name for a string, `true` for a boolean; CommonJS
takes the client by its name, `const { Client } = require(pkg)`), `api.md`, `AGENTS.md`,
`LICENSE` (MIT or Apache-2.0; another `package.license` is `error[repo.license]`),
`.github/workflows/ci.yml`, release-please's config,
`.gitignore`, `examples/.keep`, and on the first generation `CHANGELOG.md` and the release
manifest. `.flowapi/lock.json` records the flowapi version, the description's and the config's
SHA-256, the methods mapped and every file's SHA-256. A generated file changed since it was
written is a conflict (nothing is written, exit 1), except under `src/lib/` and `examples/`,
where it is kept; a file the lock does not list is never touched; one no longer generated is
deleted unless changed. A path out of `--out` or through a symbolic link is refused. `--check`
writes nothing and exits 1 when anything would change. In the SDK layer: `repo_files`, `Lock`,
`sha256_hex` (our own SHA-256, checked on FIPS 180-4's vectors).
- `flowapi-sdk.yml` has `package.version` (`0.1.0` unless given; release-please raises it);
`config draft` writes `0.1.0`.
- `npx -y @localix-ai/flowapi generate` writes what `flowapi generate` writes, byte for byte, with
the same lock, messages and exit codes. What a generation changes on disk is decided in the SDK
layer for both (`plan`: the output and the previous lock held to what the host found at each
path, a file's SHA-256 rather than its bytes), and printed there (`Plan::report`, `summary`);
the command and the package only read the disk and make the changes. The second WebAssembly
module answers `repo` and `plan` through `flowapi_sdk`, its one SDK export.

- The TypeScript SDK writes `multipart/form-data` request bodies: `<op>Request` takes the value
as its schema says (a string member also as a file: a `Uint8Array`, `flowapiFile(bytes or text,
name, type)`, or `await flowapiBlob(blobOrFile)`, the one step that waits) and returns the parts
as bytes, with `content-type: multipart/form-data; boundary=...`; the value was a string you had
encoded. The parts follow the Encoding Object's defaults: a file a file part (`filename` its
name's last path segment, `blob` when it has none; `application/octet-stream` when it has no
type), a string, number or boolean text, an object JSON, an array's items one part each under
its name in order; `undefined` is left out. The body's `encoding` (`contentType`, `headers`) sets
a part's type and headers; the description's `encoding` is not read yet, so it is given there.
The boundary is the content type's, else 128 random bits from `globalThis.crypto`, drawn again
while a part holds them. 3.2's array of objects is its parts in order. New `FlowapiRequestError`
reasons refuse what would change the parts: a CR, LF or NUL in a part's name, file name, type or
header (`control-character`), `null`, a `"` or `\` in a name (`quote`), a file name empty, `.` or
`..` (`file-name`), a header name not a token or `Content-Disposition` (`header-name`), a list or
a range as a part's type (`media-range`), a Blob not read (`unread-blob`), an item of the array
that is not an object (`unnamed-part`), a boundary RFC 2046 does not allow or a part holds
(`boundary`).
- A request body neither JSON, text nor a form (`application/octet-stream`, `image/png`, a range)
may be given to the TypeScript SDK as a `Uint8Array`, sent as it is; `$Request.body` is
`string | Uint8Array`. Another multipart type is still yours to write, now as a string or bytes.
- With the TypeScript SDK a schema named `Promise`, `ArrayBuffer`, `FlowapiRequestError`,
`FlowapiFile` or `FlowapiEncoding` is declared under another name, with a warning: the SDK names
them.
- Commands for an agent that writes an SDK's config, `flowapi-sdk.yml` (version 1), before the
description's path: `flowapi summary <description> [--tag T] [--path P] [--max-bytes N]`, the
description in compact JSON (servers, security schemes, counts, tags, each operation with its
parameters, the media types of its body and responses, and the pagination it looks like it has,
with a reason and how sure; over the budget, 60 KB by default, the tags alone);
`flowapi config draft <description> [-o file]`, a first config in YAML (the package named from
`info.title`, each word of the title one word of the name whatever its capitals: `GitHub v3 REST
API` is `github-v3-rest-api`, its client `GitHubV3RestApi`; resources by tag, else
by the path's first segment, the verbs `list`, `create`, `retrieve`, `update`, `delete`, the
suggested pagination, environments from the servers, `auth` from the security schemes,
`skip: []`), which passes `config check` and does not depend on the order the description is
written in; `flowapi config schema`, the format as JSON Schema 2020-12, printed from the
definitions the checker reads by; and `flowapi config check <config> [--spec D] [--json]`,
every issue at once with a code, the JSON Pointer, the YAML line and column and a hint: members
the format does not name, types, coverage (every operation in a resource or in `skip` with a
reason), references that name no operation (the closest named), an operation in two places,
names equal as words among siblings, names a generated class has itself or a schema has,
pagination fields missing from the parameters or the response schema or of the wrong type,
`auth`, environments and the README's methods. It exits 1 on an error. The old form,
`flowapi <description>`, is unchanged; a description named `summary` is read as `./summary`.
- The npm package runs the same four commands, `npx -y @localix-ai/flowapi summary|config …`,
with the Rust command's arguments, output and exit codes, byte for byte, and gives them as
functions: `summary`, `configDraft`, `configSchema` and `configCheck` (issues as data, as text
and as `--json` prints them), and `loadSdk()` with them synchronous and `configSpec`. They are a
second module, `flowapi-sdk.wasm`, loaded only when one of them is first used; the generator's
module is as it was.
- The TypeScript SDK reads binary responses as bytes, as the Rust SDK does: `<op>Response(status,
headers, body)` takes `body: string | Uint8Array` (it took a `string`) and reads it by the type
sent: JSON parsed, `text/*` a `string`, any other a `Uint8Array` (an `application/xml` or
`application/octet-stream` body was text before, and bytes that were not UTF-8 were lost on the
way). The response union says `Uint8Array` for such a type, and a media range each of those its
range allows. Bytes given for JSON or text are read as UTF-8; bytes that are not UTF-8 there
read as `response: null` with the body as given, as the Rust SDK refuses them. A string given
for a binary type is encoded as UTF-8. `flowapiReadsBytes(contentType)` (exported) says which
bodies are read as bytes. A schema named `Uint8Array` is declared under another name with the
SDK, with a warning.
- The npm package reads YAML descriptions as the command does, by the same code: the YAML reader
moved out of the command into a crate of its own, `flowapi-yaml`, which the command and the
WebAssembly module share (the core stays JSON-only with no dependency). Its output and its
diagnostics are the command's byte for byte; the module is about 43 KB larger gzipped.
- A YAML text that JSON cannot hold is printed as a diagnostic, `error[yaml.syntax]: <what>` then
` at <file>:<line>:<column>`, as a JSON syntax error is; it was `flowapi: <file>:<line>:<column>:
<what>`.

## 0.1.0 — 2026-11-24

- Both SDKs refuse a request that would mean something other than it says, rather than write
Expand Down
41 changes: 34 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# flowapi: types from API descriptions. The core (crates/flowapi) reads OpenAPI and JSON Schema
# into a type graph with no I/O; each target language is a crate of its own (crates/flowapi-ts),
# the CLI is the shell (crates/flowapi-cli). The bench and the conformance harness are crates of
# their own, outside this workspace: the tools compared with and the suites never reach a build.
# the CLI is the shell (crates/flowapi-cli). YAML is read into JSON for the core by a crate of its
# own (crates/flowapi-yaml), which the CLI and the WebAssembly module share. The SDK layer
# (crates/flowapi-sdk) sits above the targets: what a client needs beside a target's SDK. The
# bench and the conformance harness are crates of their own, outside this workspace: the tools
# compared with and the suites never reach a build.
[workspace]
resolver = "3"
members = ["crates/flowapi", "crates/flowapi-ts", "crates/flowapi-cli", "crates/flowapi-rust", "crates/flowapi-wasm"]
members = ["crates/flowapi", "crates/flowapi-ts", "crates/flowapi-cli", "crates/flowapi-rust", "crates/flowapi-wasm", "crates/flowapi-wasm-sdk", "crates/flowapi-yaml", "crates/flowapi-sdk"]
exclude = ["bench", "conformance"]

[workspace.package]
version = "0.1.0"
version = "0.2.0"
edition = "2024"
rust-version = "1.89"
license = "MIT"
Expand Down
Loading
Loading