Repository navigation
feat(templates): read templates from api instead of dashboard-api - #539
Draft
nalekseev-e2b wants to merge 2 commits into
Draft
nalekseev-e2b wants to merge 2 commits into
nalekseev-e2b wants to merge 2 commits into
Conversation
Copied from e2b-dev/infra main, as the daily sync workflow does, and regenerated infra-api.types.ts. Brings in the template search, default templates, template tag and template detail routes the templates module moves to next.
The template list, detail, tag reads and default templates now call api
routes: GET /unstable/templates/search, GET /templates/{templateID}?limit=1,
GET /templates/{templateID}/tags/* and GET /default-templates. The tag
writes, deletes and visibility updates already used api, so the templates
module no longer depends on the dashboard-api client.
- The detail sorts names and aliases, since api returns them unordered and
the list orders them by alias; the title matches the list row.
- The specs line hides a disk size of 0, which api reports for a build that
recorded none (dashboard-api returned null).
- Default templates map api's Template items directly; descriptions come
from description.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
api now serves the template routes the dashboard reads from dashboard-api: the template search, the default templates, the template tag reads and the template detail fields. This moves the templates module onto api, so dashboard-api's template routes can be removed later without breaking the dashboard.
Changes
listTeamTemplates)GET /templatesGET /unstable/templates/searchgetTemplate)GET /templates/{templateID}GET /templates/{templateID}?limit=1GET /templates/{templateID}/tags/...getDefaultTemplatesCached)GET /templates/defaultsGET /default-templatesspec/openapi.infra.yamlcopied from e2b-dev/inframain, as the daily sync workflow does, andinfra-api.types.tsregenerated. This overlaps with the open sync PR chore: sync infra OpenAPI specs #520; whichever merges second rebases with a regen.search,sort,public,limitandcursoroptions and the same{data, nextCursor}response. A default template's description comes fromdescriptioninstead ofdefaultDescription.limit=1keeps the builds page small, because the overview doesn't use builds. api returnsnamesandaliasesunordered while the list orders them by alias, sogetTemplatesorts both and the title (the first plain name) matches the list row. api reports a build with no recorded disk size as0, so the specs line hides a disk size of 0, as it hid dashboard-api'snull.Templateitems withnamesalready asnamespace/alias, so the mapping no longer rebuilds names. Defaults without a successful build are listed too, as api's list does.TemplateDetail,TemplatesSort,ListTeamTemplatesOptions, tag types) come from api's types. The templates module no longer uses the dashboard-api client. Sandboxes and builds still use it.Verification
templates-repository-api-reads.test.ts(detail call andlimit=1, name order, list call and description mapping, tag groups call, default templates mapping) andtemplate-specs.test.tsx(disk size shown, and hidden at 0; the second fails without the fix).templates-repository-assign-tag.test.tsdrops the unused dashboard-api client.bun run test:unit: 31 files, 317 tests pass.tsc --noEmit(afternext typegen),biome cilint,bun run formatandknip:ciare clean.Rollout