diff --git a/bun.lock b/bun.lock index 87f0e0b..daaa242 100644 --- a/bun.lock +++ b/bun.lock @@ -5,7 +5,7 @@ "": { "name": "@ellipsis/cli", "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", @@ -35,7 +35,7 @@ "@colors/colors": ["@colors/colors@1.5.0", "", {}, "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ=="], - "@ellipsis-dev/sdk": ["@ellipsis-dev/sdk@0.4.0", "", {}, "sha512-9BdMBn7bDOsffJ9i8EyPxchBMnxOqxWwCzTJgIZOQHu6PE6VgIQ4MrBs1FzFx4nrVmLYmpR9hHEmwnsRoX4X4g=="], + "@ellipsis-dev/sdk": ["@ellipsis-dev/sdk@0.5.0", "", {}, "sha512-14g9g9Mrt10hfoPpaqeIqZsr8vsDYkBtIwdkd6Rz/3Izs5pvtVm4zys5znRL9UH8dC+R02B1Ljz2AGKGrtEEsQ=="], "@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.27.7", "", { "os": "aix", "cpu": "ppc64" }, "sha512-EKX3Qwmhz1eMdEJokhALr0YiD0lhQNwDqkPYyPhiSwKrh7/4KRjQc04sZ8db+5DVVnZ1LmbNDI1uAMPEUBnQPg=="], diff --git a/package.json b/package.json index 17bb34e..1984a10 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/commands/variable.ts b/src/commands/variable.ts index a6b35a4..d61f02e 100644 --- a/src/commands/variable.ts +++ b/src/commands/variable.ts @@ -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 }) => { @@ -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 ', 'load variables from a .env or .json file') .option('--json', 'output raw JSON') @@ -52,7 +52,7 @@ export function registerVariable(program: Command): void { apiRoutes( alsoKnownAs(variable.command('delete ').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 }) => { diff --git a/src/lib/api.ts b/src/lib/api.ts index 4ae1582..5e79d61 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -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 { - const res = await this.request( - 'GET', - '/v1/sandboxes/variables', - ) + const res = await this.request('GET', '/v1/variables') return res.variables } async putSandboxVariables( variables: SandboxVariableInput[], ): Promise { - const res = await this.request( - 'PUT', - '/v1/sandboxes/variables', - { variables }, - ) + const res = await this.request('PUT', '/v1/variables', { + variables, + }) return res.variables } async deleteSandboxVariable(name: string): Promise { const res = await this.request( 'DELETE', - `/v1/sandboxes/variables/${encodeURIComponent(name)}`, + `/v1/variables/${encodeURIComponent(name)}`, ) return res.variables } diff --git a/test/api.test.ts b/test/api.test.ts index 5035351..1741e13 100644 --- a/test/api.test.ts +++ b/test/api.test.ts @@ -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') }) @@ -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' }], @@ -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') }) })