refactor: bump nodes-sdk-alpha and refactor image commands#262
Conversation
The new SDK's `client.vms.images.list({ workspace })` hits
/preview/v2/images and now requires the workspace parameter; the list
response also renamed `image_id` to `id`.
Switches `sf nodes images upload` from the legacy /v1/vms/images
endpoints (vmorch) to /preview/v2/images (market-api), matching the
pattern used in src/lib/images/upload.ts.
`sf nodes images list` now uses the SDK directly (which targets
/preview/v2/images). `sf nodes images show` is migrated in the
follow-up commit alongside the other v2/images callers.
CLI surface (commands, flags, output) is unchanged.
Generated with [Indent](https://indent.com)
Co-Authored-By: Indent <noreply@indent.com>
HAProxy blocks external /v2/* in production (sfcompute/sfcompute#5494), so any caller hitting /v2/images gets a 404. Migrates the remaining image commands off /v2/images: - `sf images list`: use Stainless SDK `client.vms.images.list({ workspace })` (hits /preview/v2/images automatically). - `sf images upload`: swap raw fetch URLs from /v2/images, /v2/images/{id}/parts, /v2/images/{id}/complete to /preview/v2/images*. - `sf images get` and `sf nodes images show`: use SDK `client.vms.images.get(id)` for the lookup; download URL fetch goes to /preview/v2/images/{id}/download via raw fetch since the SDK has no download method. SDK field rename sha256_hash -> sha256. CLI surface (commands, flags, output) is unchanged. Generated with [Indent](https://indent.com) Co-Authored-By: Indent <noreply@indent.com>
Changed Files
|
|
|
|
||
| const spinner = ora("Fetching images...").start(); | ||
| const { data: images } = await client.vms.images.list(); | ||
| const { data: images } = await client.vms.images.list({ workspace }); |
There was a problem hiding this comment.
Latent: public images no longer listed by default. The alpha.31 SDK requires a workspace, and the new call scopes results to the caller's default workspace only. The SDK docs note that to see sfc-provided public images you must pass sfc:workspace:sfcompute:public explicitly. Before this PR, client.vms.images.list() had no workspace arg — worth confirming whether the previous behavior surfaced public images; if it did, this is a UX regression. Consider adding a --public flag (or a second list call against the public workspace) so users can still discover the prebuilt images. Trigger: any user invoking sf nodes images list without their own uploads, or trying to find a public image id to pass to sf nodes create --image.
8a6043d to
0c33025
Compare
0c33025 to
4c1dd5f
Compare
4c1dd5f to
24a37c2
Compare
Convert the get/list/upload subcommands into createGet/createList/ createUpload factories and add a top-level createImagesCommand so the same images CLI surface can be reused under sf nodes images and sf vm images. Swap the remaining nodesClient and raw fetch calls for the typed apiClient against preview/v2, and regenerate schema types (adds revoked upload_status, etc.).
24a37c2 to
f60fb3e
Compare
nodes-sdk-alpha and refactor image commands
Remove the duplicate image command implementations under nodes/image/ and instead instantiate the shared createImagesCommand factory from sf images. sf nodes images and sf vm images now stay in sync with sf images automatically.
Generated file drifted from biome's formatting output after the openapi regen in 2c94afc; running `biome format --write` brings it back in line and lets `biome ci .` pass on CI. Generated with [Indent](https://indent.com) Co-Authored-By: Indent <noreply@indent.com>
78f3d98 to
81109ce
Compare
Three regressions reported by the AI reviewer on the shared image-command factory: - Re-add the `os` alias on `sf nodes images` and `sf vm images` so scripts using `sf nodes os list` / `sf vm os list` keep working. - `sf nodes images list --json` / `sf vm images list --json` print the bare image array again (new `sf images list --json` keeps the envelope shape); controlled by a new `legacyJsonShape` factory option. - Help text, "next steps", and overflow messages reference the actual parent invocation path (`sf nodes images …` / `sf vm images …`) via a new `parentPath` factory option.
Schema regen in e35a88c dropped /v0/me. The typed equivalent is getAccountMe at /v1/account/me, with the same `id` field.
The regenerated error response types wrap the payload as
`{ error: { type, message } }`, so callers need `error?.error?.message`.
The endpoint is live in market-api (v2_routes.rs:593) but its handler lacks a `#[utoipa::path]` macro, so it's absent from the regenerated OpenAPI schema. Drop the typed client for this call and use fetch directly — matches the pattern in sfcompute.com's feature-flags provider.
81109ce to
2e1124c
Compare
Collapse the shared images factory back to a zero-arg function: - always alias `os` and reference `sf images` in help/next-steps text - always print the envelope shape for `list --json` - delete the unused `sf nodes image` wrapper BREAKING CHANGE: `sf nodes images list --json` and `sf vm images list --json` now print the envelope object instead of a bare array. Scripts using `... --json | jq '.[]'` need to switch to `... | jq '.data[]'`. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
@indent fix biome and commit style: fix biome |
Generated with [Indent](https://indent.com) Co-Authored-By: Indent <noreply@indent.com>
d7ebf2b to
db73844
Compare
|
Amended d7ebf2b → db73844 with the Generated by Indent - session link |
Summary
Get the image commands off the now-blocked
/v1/vms/imagesand/v2/imagesroutes onto/preview/v2/images, and refactor along the way sosf images,sf nodes images, andsf vm imagesshare one implementation.Commits
@sfcompute/nodes-sdk-alpha0.1.0-alpha.27→0.1.0-alpha.31and migrate thesf nodes imagesupload/list/show calls onto/preview/v2/images. The new SDK already targets that prefix;listnow requires{ workspace }and list rows exposeidinstead ofimage_id.sf images list/upload/get) from/v2/imagesto/preview/v2/imagesvia the typedapiClient. Field renamedsha256_hash→sha256to match the new response shape.src/lib/images/*— exposecreateGet/createList/createUpload/createImagesCommandfactories.sf nodes imagesandsf vm imagesnow instantiate the shared factory instead of carrying duplicate implementations (deletes ~780 lines).sf nodes createconverted to acreateCreateCommand()factory for consistency.Breaking changes for
--jsonconsumerssf [nodes] images list --jsonrows now useid(wasimage_id).sf nodes images listis now scoped to the caller's default workspace, likesf images listalready was. Public images undersfc:workspace:sfcompute:publicno longer appear in the default listing.Out of scope
src/schema.ts(openapi-typescript output) is regenerated as part of commit 1 since the typedapiClientcalls insf imagesneed the new/preview/v2/imagespaths. The regen surfaces a handful of pre-existing TS errors inscale/,contracts/, andposthog.tsthat are unrelated to this PR — left for a follow-up.Testing
bun install— clean lockfile.bun run lint— passes (same 9 pre-existing warnings).bun run check— pre-existing failures unrelated to this PR (see "Out of scope").