44 v2UpdateCustomToolContract ,
55} from '@/lib/api/contracts/v2/custom-tools'
66import {
7+ createV2ResourceConcealmentPolicy ,
78 defineV2JsonRoute ,
89 v2ApiKeyAuth ,
9- v2OrchestrationErrorPolicy ,
1010 v2RateLimits ,
1111} from '@/lib/api/server/routes'
1212import { customToolOperations } from '@/lib/custom-tools/application/operations'
@@ -20,13 +20,17 @@ import { toV2CustomTool } from '@/app/api/v2/custom-tools/utils'
2020export const dynamic = 'force-dynamic'
2121export const revalidate = 0
2222
23+ const customToolResourceErrorPolicy = createV2ResourceConcealmentPolicy ( {
24+ notFoundMessage : 'Custom tool not found' ,
25+ } )
26+
2327/** GET /api/v2/custom-tools/[id] — Fetch a single custom tool. */
2428export const GET = defineV2JsonRoute ( {
2529 contract : v2GetCustomToolContract ,
2630 operation : customToolOperations . read ,
2731 auth : v2ApiKeyAuth ,
2832 rateLimit : v2RateLimits . publicApi ,
29- errorPolicy : v2OrchestrationErrorPolicy ,
33+ errorPolicy : customToolResourceErrorPolicy ,
3034 mapInput : ( { params, query } ) => ( { workspaceId : query . workspaceId , toolId : params . id } ) ,
3135 useCase : getWorkspaceCustomToolUseCase ,
3236 present : ( { tool } ) => ( { data : { customTool : toV2CustomTool ( tool ) } } ) ,
@@ -38,7 +42,7 @@ export const PATCH = defineV2JsonRoute({
3842 operation : customToolOperations . update ,
3943 auth : v2ApiKeyAuth ,
4044 rateLimit : v2RateLimits . publicApi ,
41- errorPolicy : v2OrchestrationErrorPolicy ,
45+ errorPolicy : customToolResourceErrorPolicy ,
4246 mapInput : ( { params, body } ) => ( {
4347 ...body ,
4448 toolId : params . id ,
@@ -54,7 +58,7 @@ export const DELETE = defineV2JsonRoute({
5458 operation : customToolOperations . delete ,
5559 auth : v2ApiKeyAuth ,
5660 rateLimit : v2RateLimits . publicApi ,
57- errorPolicy : v2OrchestrationErrorPolicy ,
61+ errorPolicy : customToolResourceErrorPolicy ,
5862 mapInput : ( { params, query } ) => ( {
5963 workspaceId : query . workspaceId ,
6064 toolId : params . id ,
0 commit comments