File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import ora from "ora";
66import { apiClient } from "../../apiClient.ts" ;
77import { logAndQuit } from "../../helpers/errors.ts" ;
88import { formatDate } from "../../helpers/format-time.ts" ;
9+ import { getDefaultWorkspace } from "./utils.ts" ;
910
1011const list = new Command ( "list" )
1112 . alias ( "ls" )
@@ -28,9 +29,12 @@ Examples:\n
2829 )
2930 . action ( async ( options ) => {
3031 const client = await apiClient ( ) ;
32+ const workspace = await getDefaultWorkspace ( ) ;
3133
3234 const spinner = ora ( "Fetching images..." ) . start ( ) ;
33- const { data : result , response } = await client . GET ( "/v2/images" ) ;
35+ const { data : result , response } = await client . GET ( "/v2/images" , {
36+ params : { query : { workspace } } ,
37+ } ) ;
3438 spinner . stop ( ) ;
3539
3640 if ( ! response . ok || ! result ) {
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import cliSpinners from "cli-spinners";
1212import ora , { type Ora } from "ora" ;
1313import { getAuthToken , loadConfig } from "../../helpers/config.ts" ;
1414import { logAndQuit } from "../../helpers/errors.ts" ;
15+ import { getDefaultWorkspace } from "./utils.ts" ;
1516
1617async function readChunk (
1718 filePath : string ,
@@ -84,11 +85,13 @@ const upload = new Command("upload")
8485
8586 preparingSpinner = ora ( `Preparing upload for ${ name } ...` ) . start ( ) ;
8687
88+ const workspace = await getDefaultWorkspace ( ) ;
89+
8790 // Create image via v2 API
8891 const startResponse = await fetch ( `${ config . api_url } /v2/images` , {
8992 method : "POST" ,
9093 headers : apiHeaders ,
91- body : JSON . stringify ( { name } ) ,
94+ body : JSON . stringify ( { name, workspace } ) ,
9295 } ) ;
9396
9497 if ( ! startResponse . ok ) {
Original file line number Diff line number Diff line change 1+ import { apiClient } from "../../apiClient.ts" ;
2+ import { loadConfig , saveConfig } from "../../helpers/config.ts" ;
3+
4+ export async function getDefaultWorkspace ( ) : Promise < string > {
5+ const config = await loadConfig ( ) ;
6+ let accountId = config . account_id ;
7+ if ( ! accountId ) {
8+ const client = await apiClient ( ) ;
9+ const { data } = await client . GET ( "/v0/me" ) ;
10+ if ( data ?. id ) {
11+ await saveConfig ( { ...config , account_id : data . id } ) ;
12+ accountId = data . id ;
13+ } else {
14+ throw new Error ( "Could not determine account ID. Run 'sf login' first." ) ;
15+ }
16+ }
17+ return `sfc:workspace:${ accountId } :default` ;
18+ }
Original file line number Diff line number Diff line change @@ -2414,6 +2414,8 @@ export interface components {
24142414 } ;
24152415 vmorch_StartUploadRequest : {
24162416 name : components [ "schemas" ] [ "vmorch_Name" ] ;
2417+ /** @description Workspace URN (e.g. sfc:workspace:{account_id}:default). */
2418+ workspace ?: string ;
24172419 } ;
24182420 /**
24192421 * Format: int64
@@ -4988,6 +4990,8 @@ export interface operations {
49884990 starting_after ?: components [ "schemas" ] [ "vmorch_ImagesCursor" ] ;
49894991 /** @description Cursor for backward pagination. */
49904992 ending_before ?: components [ "schemas" ] [ "vmorch_ImagesCursor" ] ;
4993+ /** @description Workspace URN (e.g. sfc:workspace:{account_id}:default). */
4994+ workspace ?: string ;
49914995 } ;
49924996 header ?: never ;
49934997 path ?: never ;
You can’t perform that action at this time.
0 commit comments