Skip to content

Rewrite gen-api in TypeScript - #3402

Merged
david-crespo merged 1 commit into
mainfrom
gen-api-typescript
Oct 9, 2026
Merged

david-crespo merged 1 commit into
mainfrom
gen-api-typescript

Conversation

@david-crespo

@david-crespo david-crespo commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Converts the shell part of the API client gen into TS to go with the TS we wrote in #3312 for pulling the timeseries schemas. Taken alone there is not a huge reason to do this, but on top of this PR I have another one adding some clever tests for the CSP and the Nexus console route paths that fetch more stuff from omicron, and at that point it makes more sense to have it all in TS.

This isn't a pure rewrite: it also changes the way we represent the current version of the generated stuff on disk. Before, each generated output had its own record of the omicron commit it came from: __generated__/OMICRON_VERSION for the API client and an omicronVersion const in timeseries-metadata.ts. The followup would have added two more of those. Now that one script does everything, a single version stamp file is enough. __generated__/OMICRON_VERSION is written only after every step succeeds. The timeseries step skips refetching when the stamp already matches, since it makes a lot of requests to GitHub. The API client always regenerates because an openapi-gen-ts upgrade can change the generated output even if we didn't change the API version.

@vercel

vercel Bot commented Oct 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
console Ready Ready Preview Oct 9, 2026 3:56pm UTC

Request Review

@david-crespo
david-crespo added this pull request to stack #3404 October 9, 2026 19:15
@david-crespo
david-crespo merged commit f468410 into main Oct 9, 2026
11 of 12 checks passed
@david-crespo
david-crespo deleted the gen-api-typescript branch October 9, 2026 19:45
david-crespo added a commit that referenced this pull request Oct 9, 2026
While doing #3400, I realized I wanted a way to test the CSP from Nexus
against our actual production bundle. I decide that because CSP is
enforced in the browser, we don't need Nexus for this at all, we just
need the CSP string. So all we have to do is use regex to extract that
from the pinned Omicron commit, and then we can test the CSP with `vite
preview` and a Playwright test. I was able to confirm the test fails
when it's supposed to: on the #3400 branch, if I comment out the step
that moves React Router's inline bootstrap scripts into separate files,
the app never renders and the test fails with the browser's CSP errors:

```
Error: expect(received).toEqual(expected) // deep equality
- Array []
+ Array [
+   "Executing inline script violates the following Content Security Policy directive 'default-src 'self''. [...] The action has been blocked.",
+   [3 more of those]
+   "CSP violation: script-src-elem inline",
+   "CSP violation: script-src-elem inline",
```

Once I had that in place, I thought about what else we might want to
test about the contract with Nexus, and I remembered that I have
sometimes forgotten to add a new route handler on the Nexus side when we
added a new top-level route prefix in the console. So I added a test
that similarly extracts the console routes from Nexus and makes sure all
the client-side routes are covered by those handlers. That immediately
turned up a bug (go to https://oxide.sys.r3.oxide-preview.com/images,
click an image, and then refresh — 404), which is fixed in
oxidecomputer/omicron#11467. So the test will
fail until that is merged and omicron is bumped.

This is nice and neat because #3402 pulls out the setup.
david-crespo added a commit to oxidecomputer/omicron that referenced this pull request Nov 20, 2026
oxidecomputer/console@00cc6bf...fe921de

* [fe921de7](oxidecomputer/console@fe921de7)
oxidecomputer/console#3447
* [0d501853](oxidecomputer/console@0d501853)
oxidecomputer/console#3440
* [f9f6fee6](oxidecomputer/console@f9f6fee6)
oxidecomputer/console#3445
* [84c2b7d9](oxidecomputer/console@84c2b7d9)
oxidecomputer/console#3446
* [ece52b51](oxidecomputer/console@ece52b51)
oxidecomputer/console#3411
* [a67b1684](oxidecomputer/console@a67b1684)
oxidecomputer/console#3444
* [e9c1e3c9](oxidecomputer/console@e9c1e3c9)
oxidecomputer/console#3443
* [efc2149c](oxidecomputer/console@efc2149c)
oxidecomputer/console#3442
* [3b76a1ef](oxidecomputer/console@3b76a1ef)
oxidecomputer/console#3441
* [47477f2d](oxidecomputer/console@47477f2d)
oxidecomputer/console#3439
* [e78bb08a](oxidecomputer/console@e78bb08a)
oxidecomputer/console#3437
* [129a4a55](oxidecomputer/console@129a4a55)
oxidecomputer/console#3436
* [bc4acfba](oxidecomputer/console@bc4acfba)
oxidecomputer/console#3419
* [595b391c](oxidecomputer/console@595b391c)
oxidecomputer/console#3431
* [3a0b5a94](oxidecomputer/console@3a0b5a94)
oxidecomputer/console#3421
* [7b9d2e38](oxidecomputer/console@7b9d2e38)
oxidecomputer/console#3430
* [94f1e9e0](oxidecomputer/console@94f1e9e0)
oxidecomputer/console#3422
* [d8b40dfa](oxidecomputer/console@d8b40dfa)
oxidecomputer/console#3428
* [12bb33ec](oxidecomputer/console@12bb33ec)
oxidecomputer/console#3426
* [615ac0f2](oxidecomputer/console@615ac0f2)
oxidecomputer/console#3425
* [294d7066](oxidecomputer/console@294d7066)
oxidecomputer/console#3420
* [31b93cbc](oxidecomputer/console@31b93cbc)
oxidecomputer/console#3418
* [d84d7104](oxidecomputer/console@d84d7104)
oxidecomputer/console#3393
* [7988361e](oxidecomputer/console@7988361e)
oxidecomputer/console#3412
* [bae3b7a6](oxidecomputer/console@bae3b7a6)
oxidecomputer/console#3400
* [b9503394](oxidecomputer/console@b9503394)
oxidecomputer/console#3409
* [5147e774](oxidecomputer/console@5147e774)
oxidecomputer/console#3408
* [16b3d164](oxidecomputer/console@16b3d164)
oxidecomputer/console#3407
* [a64d548d](oxidecomputer/console@a64d548d)
oxidecomputer/console#3406
* [df32a018](oxidecomputer/console@df32a018)
oxidecomputer/console#3405
* [1cd46185](oxidecomputer/console@1cd46185)
oxidecomputer/console#3403
* [f4684104](oxidecomputer/console@f4684104)
oxidecomputer/console#3402

This branch was successfully deployed

1 active deployment
Preview — 204862a4 Deployed Oct 9, 2026 by vercel[bot]
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