Skip to content

fix(generate): emit TypeScript types; type /build's 207 and missing[] - #15

Merged
crisner1978 merged 2 commits into
mainfrom
fix/generate-ts-types-14
Oct 19, 2026
Merged

crisner1978 merged 2 commits into
mainfrom
fix/generate-ts-types-14

Conversation

@crisner1978

Copy link
Copy Markdown
Collaborator

Closes #14.

Summary

The generator pasted JSON-schema objects inside export interface; now it emits TypeScript. /build's 207 and missing[] are still absent from api.auto.dev/openapi, so they live by hand beside the generated file.

 scripts/
 ├── generate.ts            # loads a URL or local spec path, writes the file, prettiers it
+└── openapi-to-ts.ts       # pure OpenAPI → TS converter (tested)
 src/core/
 ├── types.generated.ts     # 4,702 → ~1,400 lines of real types
+└── types.build.ts         # BuildResponse.missing?, BuildPartialResponse (207), BuildCatalog*, isPartialBuild
 src/sdk/index.ts           # build(vin): Promise<AutoDevResponse<BuildResult>>
 src/core/endpoints.ts      # auto_build / CLI description names the 207
-export interface BuildResponse {
-  "additionalProperties": false,
-  "properties": { "build": { "$ref": "#/components/schemas/Build" } },
-  ...
+export interface BuildResponse {
+  build: Build
+}

Callers branch once:

const { data } = await auto.build(vin)
if (isPartialBuild(data)) data.catalog?.availableOptions   // 207: build is null
else data.build.options                                    // 200: data.missing? lists absent fields

Evidence

  • Before: types.generated.ts line 687 was a schema blob; build() returned unknown; the MCP description said nothing about the 207.
    After: pnpm typecheck 0 errors; pnpm test 23 files / 154 tests pass, including new test/scripts/openapi-to-ts.test.ts (refs, arrays, maps, enum/const/anyOf, not, JSDoc, Params), a client test that a 207 body passes through as data, a type-level test on build(), and an MCP test that auto_build mentions the 207. Re-running pnpm generate against the live spec reproduces the committed file byte-for-byte.

Merge Danger

Door: two-way. Revert restores the old generator and file; nothing persisted.

Blast Radius: consumers

  • build() narrows from AutoDevResponse<unknown> to AutoDevResponse<BuildResult>; code that cast unknown keeps compiling, code that passed it somewhere typed unknown is unaffected.
  • The generated param types (ListingsFilters etc.) keep their names; one new OpenrecallsVinParams appears because the live spec now lists it.
  • Not published: npm is at 0.1.24 (2026-08-18). Needs pnpm version patch && pnpm publish after merge to reach users.

🤖 Generated with Claude Code

crisner1978 and others added 2 commits October 19, 2026 13:13
… 207 and missing[] (#14)

- scripts/openapi-to-ts.ts: pure OpenAPI → TS converter (objects, $ref, arrays, maps, enum/const, type lists, anyOf, JSDoc, Params interfaces); generate.ts now uses it and accepts a URL or a local spec path, then prettiers the output.
- src/core/types.generated.ts regenerated from api.auto.dev/openapi (4,702 → ~1,400 lines of real types).
- src/core/types.build.ts: hand-kept BuildResponse.missing[], BuildPartialResponse (207), BuildCatalog, isPartialBuild; the live spec still documents one 200 per route.
- AutoDev.build() resolves AutoDevResponse<BuildResult>; types exported from the package root.
- auto_build / CLI description names the 207 so MCP clients branch on build === null.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- converter: `not` renders as never (keeps anyOf arms), bare objects as Record<string, unknown>, multiline descriptions as proper JSDoc; scalarToTs takes one type.
- generate.ts counts param interfaces from the spec, not by regexing its own output.
- types.build.ts: BuildMissReason drops invalid_vin (a 404, never a 207); vehicle named BuildVehicle and exported.
- CLI build command reads ENDPOINTS.build.description instead of a hand copy.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@crisner1978
crisner1978 merged commit eeaa016 into main Oct 19, 2026
1 check passed
@crisner1978
crisner1978 deleted the fix/generate-ts-types-14 branch October 19, 2026 17:26
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.

generate.ts writes JSON-schema blobs as TS interfaces; regenerate once /build's 207 and missing[] land

1 participant