import { describe, expect, it } from 'vitest' import { isKbxProblem, kbxApiCatalog } from '@kbx/contracts' describe('KBX API contract', () => { it('keeps operation IDs and routes unique', () => { const operations = Object.values(kbxApiCatalog) expect(new Set(operations.map(x => x.id)).size).toBe(operations.length) expect(new Set(operations.map(x => `${x.method} ${x.path}`)).size).toBe(operations.length) }) it('requires a stable key only for mutation operations', () => { const required = Object.values(kbxApiCatalog).filter(x => x.idempotency === 'required') expect(required.length).toBeGreaterThan(0) expect(required.every(x => x.method !== 'GET')).toBe(true) }) it('recognizes the public problem discriminator family', () => { for (const type of ['validation','business-rule','conflict','permission','not-found','integration','system']) { expect(isKbxProblem({ type, title: 'test' })).toBe(true) } }) })