Repository navigation
feat(api): search, grep and call any public Base44 API from the spec - #663
Conversation
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/cli@0.1.32-pr.663.1a6cb8ePrefer not to change any import paths? Install using npm alias so your code still imports npm i "base44@npm:@base44-preview/cli@0.1.32-pr.663.1a6cb8e"Or add it to your {
"dependencies": {
"base44": "npm:@base44-preview/cli@0.1.32-pr.663.1a6cb8e"
}
}
Preview published to npm registry — try new features instantly! |
|
Commands, cache behaviour and timings. The description is regenerated by CommandsEvery listing identifies an operation as
Cache
TimingsMeasured on the production spec (2.31 MB, 491 operations, about 390 KB compressed on the wire), Node 22, cold process, median of 9 runs:
End to end, Dependency
Known issue (not from this PR)On Node 20.11, which is below the package's Test status
HistoryThe branch is squashed into one commit for review. The step-by-step history (20 commits, review rounds included) is kept on |
f4ad008 to
660f759
Compare
|
Nice work. Blocking
Worth fixing
Nits
|
660f759 to
82055e6
Compare
base44 api catalog | search | grep | fetch, driven at runtime by the
server's OpenAPI spec (GET /api/openapi.json), cached per server under
~/.base44/cache/<server>/ for an hour (--refresh forces a download).
- Listings print {endpoint, summary}, as the MCP bridge does; --read-only
filters to operations a read-only token may call.
- catalog lists areas (the path segment after {app_id}, else after /api),
or one area's operations, capped at 200.
- search (MiniSearch) ranks summaries holding every query word first.
- grep matches each operation's contract with schemas inlined.
- fetch sends the path as is through base44Client, with no timeout and no
local validation; --help after a path prints the operation's contract;
--read-only refuses unsafe operations before sending; the body comes from
--body JSON, @file or @-, or --form for multipart (file uploads);
--output saves the response. A rate-limited call shows Retry-After.
- The path is normalized once (dot segments resolved as the request URL
resolves them), and that path is both checked by --read-only and sent.
- JSON is passed through byte for byte when piped (no int64 rounding) and
pretty-printed only in a terminal; bytes that aren't UTF-8 with no
content type are described as binary.
- Component $refs to parameters, request bodies and responses resolve.
- A malformed route in the spec is skipped, not fatal.
- A failed call reports no request or response body, --body, --form or
query string to telemetry.
The step-by-step history is on amitb/api-command-history.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
82055e6 to
2893932
Compare
|
@ronnyrin thanks, all addressed in 2893932:
|
- --read-only refuses paths with an encoded /, \ or ., which the server decodes before routing
- fetch fills {app_id} from --app-id or the project; other placeholders fail before sending
- error details include the request id
- drop the piped-stdin warning
- naming and undefined-check cleanups
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Note
Description
Adds a
base44 apicommand group that discovers and calls any public Base44 API operation, driven entirely by the server's OpenAPI spec at runtime (GET /api/openapi.json) with no per-endpoint code. The spec is cached per server under~/.base44/cache/<server>/for an hour (--refreshforces a download), so new server routes become callable without a CLI release. It gives humans and agent harnesses one escape hatch for endpoints that have no dedicated CLI command.Related Issue
None
Type of Change
Changes Made
src/core/api-spec/SDK module: spec download with a per-server disk cache written atomically (spec.ts), Zod spec schemas (schema.ts), operation extraction with component$refresolution and read-only detection from each operation'ssecuritylist (operations.ts), area grouping and catalog index (catalog.ts), MiniSearch-backed ranking (search.ts), regex grep over inlined contracts (grep.ts), contract rendering (contract.ts), request sending and error redaction (request.ts).base44 api catalog [area]: lists the API's areas (the path segment after{app_id}, else after/api), or every operation in one area.base44 api search <text...>: ranks operations by what they do; a custom tokenizer and stopword list make a vague query return nothing rather than noise. Supports--limit.base44 api grep <pattern>: regex match over each operation's full contract with schemas inlined, for when search misses. Supports--area,--ignore-case,--limit; an invalid regex fails with a clear error.base44 api fetch <METHOD> <path>: sends the path as-is throughbase44Client(no local validation, no timeout — a call such as a deploy can take minutes).--helpafter a path prints that operation's contract instead of command help;--bodytakes inline JSON,@fileor@-;--formsends multipart includingname=@fileuploads;--outputsaves the response body;{app_id}is filled from--app-idor the project, and any other placeholder fails before sending.--read-onlyfilters listings and refuses, before sending, any operation the spec does not mark read-only — including a path holding an encoded/,\or.that the server would decode after the check. The path is normalized once, so the checked path is the sent path. The server remains the real guard.fetchreports no request or response body,--body,--formor query string, since any endpoint can carry secrets; the reported error keeps status, request ID andRetry-After.toJsonStdout()gained acompactoption,writeFile()acceptsUint8Array,getBase44GlobalDir()is now exported,minisearchadded as a (bundled) dependency, and bothdocs/commands.mdandpackages/cli/README.mddocument the new commands.Testing
npm test)109 new tests:
tests/cli/api.spec.ts(54),tests/core/api-spec.spec.ts(47) andtests/cli/api_redaction.spec.ts(8), plus an OpenAPI fixture attests/fixtures/api-spec/openapi.json.build,typecheck,lintandknipare green on this PR; the fourtestmatrix jobs are still running, so the suite is left unchecked here.Checklist
docs/(AGENTS.md) if I made architectural changesAdditional Notes
The step-by-step development history is on
amitb/api-command-history. The follow-up commits address review feedback: the encoded-separator refusal under--read-only,{app_id}filling, request IDs in error details, and dropping the piped-stdin warning — stdin is now read only for--body @-, since an agent harness can hold stdin open forever.🤖 Generated by Claude | 2026-10-18 11:51 UTC | 462f7a4