Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"test:watch": "vitest"
},
"dependencies": {
"@ellipsis-dev/sdk": "^0.4.0",
"@ellipsis-dev/sdk": "^0.5.0",
"chalk": "^5.6.2",
"cli-table3": "^0.6.5",
"commander": "^12.1.0",
Expand Down
6 changes: 3 additions & 3 deletions src/commands/variable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function registerVariable(program: Command): void {
variable.command('list').description('List the variable names (never their values)'),
'ls',
),
'GET /v1/sandboxes/variables',
'GET /v1/variables',
)
.option('--json', 'output raw JSON')
.action(async (opts: { json?: boolean }) => {
Expand All @@ -34,7 +34,7 @@ export function registerVariable(program: Command): void {
variable
.command('set [assignments...]')
.description('Create or update variables, e.g. `set A=1 B=2`'),
'PUT /v1/sandboxes/variables',
'PUT /v1/variables',
)
.option('-f, --from-file <path>', 'load variables from a .env or .json file')
.option('--json', 'output raw JSON')
Expand All @@ -52,7 +52,7 @@ export function registerVariable(program: Command): void {

apiRoutes(
alsoKnownAs(variable.command('delete <name>').description('Delete a variable'), 'rm'),
'DELETE /v1/sandboxes/variables/{name}',
'DELETE /v1/variables/{name}',
)
.option('--json', 'output raw JSON')
.action(async (name: string, opts: { json?: boolean }) => {
Expand Down
17 changes: 6 additions & 11 deletions src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,33 +400,28 @@ export class ApiClient {
return this.request('DELETE', '/v1/defaults', undefined, { repository })
}

// -------------------------- sandbox variables ---------------------------
// ------------------------------- variables --------------------------------
// All three return the full current list (the backend echoes it after every
// mutation), so callers can render the resulting state.

async listSandboxVariables(): Promise<SandboxVariableSummary[]> {
const res = await this.request<GetSandboxVariablesResponse>(
'GET',
'/v1/sandboxes/variables',
)
const res = await this.request<GetSandboxVariablesResponse>('GET', '/v1/variables')
return res.variables
}

async putSandboxVariables(
variables: SandboxVariableInput[],
): Promise<SandboxVariableSummary[]> {
const res = await this.request<GetSandboxVariablesResponse>(
'PUT',
'/v1/sandboxes/variables',
{ variables },
)
const res = await this.request<GetSandboxVariablesResponse>('PUT', '/v1/variables', {
variables,
})
return res.variables
}

async deleteSandboxVariable(name: string): Promise<SandboxVariableSummary[]> {
const res = await this.request<GetSandboxVariablesResponse>(
'DELETE',
`/v1/sandboxes/variables/${encodeURIComponent(name)}`,
`/v1/variables/${encodeURIComponent(name)}`,
)
return res.variables
}
Expand Down
6 changes: 3 additions & 3 deletions test/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ describe('ApiClient sandbox variables', () => {

const out = await new ApiClient('http://api.test', 't').listSandboxVariables()
expect(out).toEqual([{ name: 'A', created_at: '', updated_at: '' }])
expect(fetchMock.mock.calls[0][0]).toBe('http://api.test/v1/sandboxes/variables')
expect(fetchMock.mock.calls[0][0]).toBe('http://api.test/v1/variables')
expect((fetchMock.mock.calls[0][1] as RequestInit).method).toBe('GET')
})

Expand All @@ -172,7 +172,7 @@ describe('ApiClient sandbox variables', () => {

await new ApiClient('http://api.test', 't').putSandboxVariables([{ name: 'TOKEN', value: 'x' }])
const [url, init] = fetchMock.mock.calls[0]
expect(url).toBe('http://api.test/v1/sandboxes/variables')
expect(url).toBe('http://api.test/v1/variables')
expect((init as RequestInit).method).toBe('PUT')
expect(JSON.parse((init as RequestInit).body as string)).toEqual({
variables: [{ name: 'TOKEN', value: 'x' }],
Expand All @@ -187,7 +187,7 @@ describe('ApiClient sandbox variables', () => {

await new ApiClient('http://api.test', 't').deleteSandboxVariable('MY/VAR')
const [url, init] = fetchMock.mock.calls[0]
expect(url).toBe('http://api.test/v1/sandboxes/variables/MY%2FVAR')
expect(url).toBe('http://api.test/v1/variables/MY%2FVAR')
expect((init as RequestInit).method).toBe('DELETE')
})
})
Expand Down