diff --git a/docs/api/v1/schemas/entity-testing.yaml b/docs/api/v1/schemas/entity-testing.yaml index efd7a2c..0e5238a 100644 --- a/docs/api/v1/schemas/entity-testing.yaml +++ b/docs/api/v1/schemas/entity-testing.yaml @@ -86,12 +86,11 @@ ReleaseEvaluation: EvaluateRequest: type: object required: - - databaseId - releases properties: databaseId: type: integer - description: Database ID to use for custom format evaluation + description: Database ID to use for custom format evaluation. If omitted, only parsing is performed (no CF matching). releases: type: array items: diff --git a/src/routes/api/v1/entity-testing/evaluate/+server.ts b/src/routes/api/v1/entity-testing/evaluate/+server.ts index 0f40fef..380c272 100644 --- a/src/routes/api/v1/entity-testing/evaluate/+server.ts +++ b/src/routes/api/v1/entity-testing/evaluate/+server.ts @@ -28,10 +28,6 @@ export const POST: RequestHandler = async ({ request }) => { const body: EvaluateRequest = await request.json(); const { databaseId, releases } = body; - if (!databaseId) { - throw error(400, 'Missing databaseId'); - } - if (!releases || !Array.isArray(releases) || releases.length === 0) { throw error(400, 'Missing or empty releases array'); } @@ -49,16 +45,36 @@ export const POST: RequestHandler = async ({ request }) => { } satisfies EvaluateResponse); } - // Get the PCD cache - const cache = pcdManager.getCache(databaseId); - if (!cache) { - throw error(500, 'Database cache not available'); - } - // Parse all releases in batch (uses cache) const parseItems = releases.map((r) => ({ title: r.title, type: r.type })); const parseResults = await parseWithCacheBatch(parseItems); + // If no databaseId, just return parsed info without CF evaluation + if (!databaseId) { + const evaluations: ReleaseEvaluation[] = releases.map((release) => { + const cacheKey = `${release.title}:${release.type}`; + const parsed = parseResults.get(cacheKey); + + return { + releaseId: release.id, + title: release.title, + parsed: parsed ? getParsedInfo(parsed) : undefined, + cfMatches: {} + }; + }); + + return json({ + parserAvailable: true, + evaluations + } satisfies EvaluateResponse); + } + + // Get the PCD cache for CF evaluation + const cache = pcdManager.getCache(databaseId); + if (!cache) { + throw error(404, 'Database not found or cache not available'); + } + // Get all custom formats with conditions const customFormats = await getAllConditionsForEvaluation(cache);