From 454ed2b889f6511e0ac72cd3d6233d2e7dff251f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 2 Jul 2026 02:06:56 +0000 Subject: [PATCH] feat: sync CLI with API changes --- package.json | 2 +- src/__tests__/resources.test.ts | 26 -------------------- src/commands/resources.ts | 43 --------------------------------- src/index.ts | 31 ------------------------ 4 files changed, 1 insertion(+), 101 deletions(-) diff --git a/package.json b/package.json index cce8e4d..660a0e0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@blindpay/cli", "type": "module", - "version": "0.3.1", + "version": "0.4.0", "description": "Blindpay CLI - manage receivers, bank accounts, payouts, payins, and more from the terminal", "license": "MIT", "author": "Blindpay (https://blindpay.com/)", diff --git a/src/__tests__/resources.test.ts b/src/__tests__/resources.test.ts index ad5f5cb..1cd6a8e 100644 --- a/src/__tests__/resources.test.ts +++ b/src/__tests__/resources.test.ts @@ -555,32 +555,6 @@ describe('Partner Fees', () => { }) }) -describe('API Keys', () => { - beforeEach(setupTestEnv) - afterEach(teardownTestEnv) - - test('lists API keys', async () => { - mockResponse.body = [] - await resources.listApiKeys({ json: true }) - expect(lastCall().url).toBe(`${BASE}/api-keys`) - }) - - test('creates an API key', async () => { - mockResponse.body = { id: 'ak_new', key: 'sk_...' } - await resources.createApiKey({ name: 'test', permission: 'read', json: true }) - expect(lastCall().method).toBe('POST') - expect(lastCall().url).toBe(`${BASE}/api-keys`) - expect(lastCall().body).toEqual({ name: 'test', permission: 'read' }) - }) - - test('deletes an API key', async () => { - mockResponse.body = { success: true } - await resources.deleteApiKey('ak_1', { json: true }) - expect(lastCall().method).toBe('DELETE') - expect(lastCall().url).toBe(`${BASE}/api-keys/ak_1`) - }) -}) - describe('Virtual Accounts', () => { beforeEach(setupTestEnv) afterEach(teardownTestEnv) diff --git a/src/commands/resources.ts b/src/commands/resources.ts index cd92478..20f7cc9 100644 --- a/src/commands/resources.ts +++ b/src/commands/resources.ts @@ -645,49 +645,6 @@ export async function deletePartnerFee(id: string, options: { json?: boolean } = } } -// API Keys -export async function listApiKeys(options: { json: boolean }) { - try { - const ctx = resolveContext() - const res = await apiGet(ctx, `${instancePath(ctx)}/api-keys`) - const list = extractList(res) - const maskKey = (s: string | null) => (!s ? '-' : s.length > 8 ? `${s.slice(0, 4)}...${s.slice(-4)}` : '***') - const display = list.map((k: any) => ({ id: k.id, name: k.name, key: maskKey(k.key), permission: k.permission })) - printResult(options.json ? list : display, options.json, ['id', 'name', 'key', 'permission']) - } - catch (e) { - handleApiError(e, options.json) - } -} - -export async function createApiKey(options: { name?: string, permission?: string, json: boolean }) { - try { - const ctx = resolveContext() - const body: Record = { name: options.name || 'CLI API Key' } - if (options.permission) body.permission = options.permission - const key = await apiPost<{ id: string, key: string }>(ctx, `${instancePath(ctx)}/api-keys`, body) - clack.log.success(`Created API key ${key.id}`) - clack.log.warning(`Secret: ${key.key}`) - clack.log.message('Save this key now — it will not be shown again.') - if (options.json) - console.log(formatOutput(key, true)) - } - catch (e) { - handleApiError(e, options.json) - } -} - -export async function deleteApiKey(id: string, options: { json?: boolean } = {}) { - try { - const ctx = resolveContext() - await apiDelete(ctx, `${instancePath(ctx)}/api-keys/${id}`) - clack.log.success(`Deleted API key ${id}`) - } - catch (e) { - handleApiError(e, options.json) - } -} - // Virtual Accounts export async function listVirtualAccounts(options: { customerId: string, json: boolean }) { try { diff --git a/src/index.ts b/src/index.ts index e7ec060..34a26d1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -36,9 +36,6 @@ import { listPartnerFees, createPartnerFee, deletePartnerFee, - listApiKeys, - createApiKey, - deleteApiKey, listVirtualAccounts, createVirtualAccount, getVirtualAccount, @@ -517,34 +514,6 @@ partnerFees .option('--json', 'Output as JSON', false) .action((id, opts) => deletePartnerFee(id, opts)) -// ── API Keys ──────────────────────────────────────────────────────────── -const apiKeys = program.command('api_keys').description('Manage API keys') - .addHelpText('after', ` -Examples: - $ blindpay api_keys list - $ blindpay api_keys create --name "Production Key" - $ blindpay api_keys delete `) - -apiKeys - .command('list') - .description('List API keys') - .option('--json', 'Output as JSON', false) - .action(opts => listApiKeys(opts)) - -apiKeys - .command('create') - .description('Create an API key') - .option('--name ', 'Key name', 'CLI API Key') - .option('--permission ', 'Permission level') - .option('--json', 'Output as JSON', false) - .action(opts => createApiKey(opts)) - -apiKeys - .command('delete ') - .description('Delete an API key') - .option('--json', 'Output as JSON', false) - .action((id, opts) => deleteApiKey(id, opts)) - // ── Virtual Accounts ──────────────────────────────────────────────────── const virtualAccounts = program.command('virtual_accounts').description('Manage virtual accounts') .addHelpText('after', `