Skip to content

flowapi 0.2.0: the SDK layer and generate - #1

Merged
rsaryev merged 16 commits into
mainfrom
sdk
Nov 26, 2026
Merged

rsaryev merged 16 commits into
mainfrom
sdk

Conversation

@rsaryev

@rsaryev rsaryev commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

flowapi 0.2.0. The sections of CHANGELOG.md and npm/CHANGELOG.md for 0.2.0 list every change; in short:

  • The npm package reads YAML, through the same reader as the Rust command.
  • The TypeScript SDK reads binary responses as bytes and writes multipart/form-data bodies.
  • A new layer, crates/flowapi-sdk: it reads servers and security; adds summary and config draft|schema|check for an agent that writes flowapi-sdk.yml; and adds generate, which writes a whole TypeScript SDK repository (client, package, tests against a mock server, README, CI, .flowapi/lock.json). These work the same in the Rust command and the npm package.
  • The core grew by 15 lines (5,997 of 6,000).

Checked locally on the release tree:

  • scripts/check: all checks pass.
  • bun run check in npm/: 116 of 116.
  • npm run check in site/: passes.
  • Benchmark budgets hold. Writing a request is no slower (bench/results/sdk.md).

An SDK generated from GitHub's description (130 files) passes typecheck, lint, build, the package checks and 1,281 of 1,281 tests against its mock server.

🤖 Generated with Claude Code

rsaryev and others added 16 commits November 26, 2026 00:46
The YAML reader moves out of the command into crates/flowapi-yaml (no I/O, G5; saphyr-parser
with its reason, G11), used by the command and the WebAssembly module, so both decide what is
YAML and where an error is in one place. The core stays JSON-only. A YAML syntax error is now
a diagnostic, error[yaml.syntax] with its line and column (G8), the same bytes from both
commands. Three of four real descriptions in the corpus are YAML; the package refused them.

The module grows from 164 KB to 207 KB gzipped; the size budget is raised with that reason.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
<op>Response takes the body as string | Uint8Array and reads it by the Content-Type sent, as
the Rust target does: JSON parsed, text/* a string, any other type a Uint8Array. Before, the
body was text only, so a caller decoded a file to a string first and lost every byte that was
not UTF-8. Bytes that are not UTF-8 in a JSON or text body read as response: null, as Rust
refuses them. flowapiReadsBytes(contentType) tells a client whether to read text or bytes.

O8: 44 cases, 297 calls, 0 differ; the corpus (GitHub, Stripe, Cloudflare) 0 differ.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…of operations

A new layer above the targets (no I/O, G5) reads servers at three levels with their variables,
Swagger 2.0's host, basePath and schemes, securitySchemes and security requirements from the
same documents, and prints one table a client reads: servers, schemes, and per operation its
method, path, servers, effective security, how each response media type is read, and its
<op>Request and <op>Response. The core only exposes what the layer would otherwise copy:
program() split from generate(), spec::follow and self_uri (15 lines; 5,997 of G10's 6,000).
Diagnostics are warnings. The ledger: 555 of 555 in scope answered (was 494).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
<op>Request encodes a form body to bytes with its boundary, as OpenAPI and RFC 7578 say: a
file part (Uint8Array, flowapiFile, or a Blob read by flowapiBlob), a text part, an object as
one application/json part, an array as one part per item under its name, and the encoding a
caller passes (contentType, headers). The boundary is the one given or 128 random bits drawn
again while a part contains them. Names with quotes, CR, LF or NUL, unsafe filenames, a
forbidden boundary and an unread Blob are refused with a reason. A body of any other type can
be sent as bytes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
flowapi summary prints a description compactly for an agent (Cloudflare's 3,935 operations as
a 28 KB tag index by default, one tag on request); flowapi config draft prints a config to
start from (resources by tag or path, CRUD verbs, pagination where the response fits, servers
and security schemes); config schema prints its JSON Schema from the same tables the reader
uses; config check reports every issue at once with its code, JSON Pointer, line, column and
a hint. Names compare as words. A draft of each of 11 real descriptions (Slack, GitHub,
Stripe, Cloudflare and others) passes check with no issue.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	CHANGELOG.md
The module the npm package ships holds the TypeScript the SDK prints as text; reading bytes and
writing multipart bodies made it 553 KB raw, 213 KB gzipped. O8: 51 cases, 438 calls, none
differ.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
summary and config draft|schema|check run through npm as through the Rust command, the same
bytes and exit codes (89 parity cases). They live in flowapi-sdk.wasm, built by the thin crate
flowapi-wasm-sdk over flowapi-wasm's sdk feature and loaded on first use, so flowapi.wasm keeps
its size (213 KB gzipped) and generate never loads the other (323 KB). Each has its budget.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
client_files(docs, program, config) prints an SDK's src/: the --sdk functions with the table of
operations (now with each body's encoding read from the description), a runtime of 13 files
(options from the config and the environment, retries by status and x-should-retry, retry-after-ms
and Retry-After, a refused wait past maxRetryDelay, timeouts over the body's read, abort, error
classes by status, auth per operation's security, masked logs, no redirect to another origin,
pages by six schemes, SSE and JSON Lines streams), a class per resource and the client. 60
runtime tests against a stub fetch name the pitfall each covers; scripts/check runs them.
GitHub's description: 62 files, tsc strict in 2.0 s with no error.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
flowapi is a tool of its own; a plugin that writes SDKs with it is one of its users. The config
an agent writes is flowapi-sdk.yml and its schema flowapi-sdk-1.json, in the commands' help,
the docs, the kept outputs and the generated files' first line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ited

From a description and flowapi-sdk.yml: the client's src/, package.json (ES modules and
CommonJS, types for each, typescript the one dependency), the TypeScript configs, POSIX
scripts, a mock server and a node:test suite per resource, README.md and api.md (counts from
the config), AGENTS.md, the license, CI and release-please, and .flowapi/lock.json with each
file's SHA-256 (our own, FIPS 180-4 vectors). Writes are staged and all or nothing; a generated
file edited since is a conflict, src/lib/ and examples/ are kept, an unchanged orphan is
deleted, paths out of --out or through a link are refused; --check writes nothing. The
plugin's judge passes all its steps on a generated repository.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
config draft names the package as the title splits (GitHub stays one word: github-v3-rest-api)
and writes package.version. The README's example takes a parameter's example, then its schema's
value, then a placeholder from its name, never "string". The mock matches a concrete path
before a templated one, as OpenAPI's Paths Object says (found on GitHub's SDK: 1,280 of 1,281
resource tests, the one left matched to /orgs/{org}/{security_product}/{enablement}). The
README shows the CommonJS form that type-checks, and the build checks it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
flowapi generate through npm writes the same files, the same lock and the same messages, with
the same exit codes, as the Rust command (shop, auth and GitHub; every write rule). The plan
of what to write, keep, delete or refuse moved into flowapi-sdk, so both hosts run one copy and
only read the disk and apply it. It lives in flowapi-sdk.wasm, whose budget grows with the
repository's texts it prints (424 KB gzipped); flowapi.wasm keeps its size.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	CHANGELOG.md
YAML through npm, binary responses and multipart bodies in the TypeScript SDK, servers and
security read, and the SDK layer: summary, config draft|schema|check, and generate, which writes a
whole TypeScript SDK repository from a description and flowapi-sdk.yml, in the Rust command and
the npm package alike. The changesets are in npm/CHANGELOG.md; CHANGELOG.md has the release's
section. Writing a request is no slower (bench/results/sdk.md).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rsaryev
rsaryev merged commit 45ee5e9 into main Nov 26, 2026
1 check passed
@rsaryev
rsaryev deleted the sdk branch November 26, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant