fcfa1ba974
* feat(connect): extract the connector wire contract into packages/connect-contract The definitions in lib/connect/contract.ts (key prefix, headers, entitlements path, entitlement and sync-report shapes) move into a standalone MIT package, packages/connect-contract (published as @accounted/connect-contract), joined by the error envelope, the stable error codes, and Zod schemas for every Peppol connector operation (lookup, submit, status, evidence, register, unregister, inbound list and xml) with an operation table. Shape only: no behaviour, no provider code. In-repo callers import through the tsconfig and vitest alias; lib/connect/contract.ts re-exports so nothing else changes. The point of the package is that either side of the connection can be built outside this repository: a self-hosted ledger talking to Accounted Connect, or another connector service talking to the open ledger. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com> * docs(decisions): record the Connect direction, the Peppol proxy shape, and the contract package Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com> --------- Signed-off-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com> Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
96 lines
3.4 KiB
TypeScript
96 lines
3.4 KiB
TypeScript
import { defineConfig } from 'vitest/config'
|
|
import path from 'path'
|
|
|
|
const alias = {
|
|
'@': path.resolve(__dirname, '.'),
|
|
// The connect contract is consumed from source in-repo (published separately).
|
|
'@accounted/connect-contract': path.resolve(__dirname, 'packages/connect-contract/src/index.ts'),
|
|
// `server-only` is a build-time guard whose real entry point always throws;
|
|
// Next.js swaps it out during bundling, Vitest cannot. Without this stub any
|
|
// test that transitively imports a server-only module fails at import time.
|
|
'server-only': path.resolve(__dirname, 'tests/stubs/server-only.ts'),
|
|
}
|
|
|
|
const unitProject = {
|
|
resolve: { alias },
|
|
test: {
|
|
name: 'unit',
|
|
globals: true,
|
|
environment: 'node' as const,
|
|
include: ['**/*.test.ts'],
|
|
// `.claude/worktrees/*` are ephemeral agent checkouts whose `@/*` imports
|
|
// resolve back to this root: never part of the suite.
|
|
// Two additions to the exclude list, both learned the hard way:
|
|
// * `*.tool.test.ts` also matches `**/*.test.ts`, so without it the unit
|
|
// project runs the PostgREST suite with no stack up.
|
|
// * `.next/standalone` is a traced COPY of the repo left by a local
|
|
// build, so `npm run build && npm test` collects those files a second
|
|
// time. Only two match here today, but the duplication is silent and
|
|
// grows with the build's tracing.
|
|
exclude: [
|
|
'**/node_modules/**',
|
|
'**/*.pg.test.ts',
|
|
'**/*.tool.test.ts',
|
|
'**/.claude/**',
|
|
'**/.next/**',
|
|
],
|
|
},
|
|
}
|
|
|
|
const pgRealProject = {
|
|
resolve: { alias },
|
|
test: {
|
|
name: 'pg-real',
|
|
globals: true,
|
|
environment: 'node' as const,
|
|
include: ['**/*.pg.test.ts'],
|
|
// `.next/standalone` holds a traced copy of these files after a local
|
|
// build; 128 of them match this project's glob.
|
|
exclude: ['**/node_modules/**', '**/.claude/**', '**/.next/**'],
|
|
setupFiles: ['tests/pg/setup.ts'],
|
|
// One-connection-at-a-time to avoid cross-file DB contention.
|
|
fileParallelism: false,
|
|
testTimeout: 15000,
|
|
},
|
|
}
|
|
|
|
// MCP tools queried through a REAL supabase-js client against a REAL
|
|
// PostgREST. Separate from pg-real because that project holds a `pg` Pool and
|
|
// writes SQL, which cannot see the half of a tool that PostgREST resolves: the
|
|
// `.select()` column strings, the resource embeds, the or=(...) grammar.
|
|
const toolPgProject = {
|
|
resolve: { alias },
|
|
test: {
|
|
name: 'tool-pg',
|
|
globals: true,
|
|
environment: 'node' as const,
|
|
include: ['**/*.tool.test.ts'],
|
|
// See the unit project's note: `.next/standalone` is a build artifact that
|
|
// would otherwise be collected as a second copy of this suite.
|
|
exclude: ['**/node_modules/**', '**/.claude/**', '**/.next/**'],
|
|
setupFiles: ['tests/tool-pg/setup.ts'],
|
|
// The suite shares one database; parallel files would race on seeded rows.
|
|
fileParallelism: false,
|
|
testTimeout: 30000,
|
|
},
|
|
}
|
|
|
|
// Only register the pg-real project when DATABASE_URL is set. Local devs
|
|
// running a bare `vitest run` would otherwise hit the schema sanity check
|
|
// against a non-existent DB. `npm run test:pg` is the opt-in entry point, and
|
|
// `npm run test:tools` is the equivalent for tool-pg.
|
|
const projects = [
|
|
unitProject,
|
|
...(process.env.DATABASE_URL ? [pgRealProject] : []),
|
|
...(process.env.TOOL_PG_REST_URL ? [toolPgProject] : []),
|
|
]
|
|
|
|
export default defineConfig({
|
|
resolve: { alias },
|
|
test: {
|
|
globals: true,
|
|
environment: 'node',
|
|
projects,
|
|
},
|
|
})
|