first commit
This commit is contained in:
6
apps/suman-bosna/src/app/ucp/mcp/route.ts
Normal file
6
apps/suman-bosna/src/app/ucp/mcp/route.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { handleMcpRequest } from "@lib/ucp/mcp"
|
||||
|
||||
export const POST = (request: Request) => handleMcpRequest(request)
|
||||
|
||||
export const GET = () =>
|
||||
new Response("Method Not Allowed", { status: 405, headers: { Allow: "POST" } })
|
||||
15
apps/suman-bosna/src/app/ucp/v1/cart/[cartId]/route.ts
Normal file
15
apps/suman-bosna/src/app/ucp/v1/cart/[cartId]/route.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { cancelCart, getCart, updateCart } from "@lib/ucp/operations"
|
||||
import { readJsonBody, toResponse } from "@lib/ucp/ucp"
|
||||
|
||||
type Context = { params: Promise<{ cartId: string }> }
|
||||
|
||||
export const GET = async (request: Request, { params }: Context) =>
|
||||
toResponse(await getCart(request, (await params).cartId))
|
||||
|
||||
export const PUT = async (request: Request, { params }: Context) =>
|
||||
toResponse(
|
||||
await updateCart(request, (await params).cartId, (await readJsonBody(request)) ?? {})
|
||||
)
|
||||
|
||||
export const DELETE = async (request: Request, { params }: Context) =>
|
||||
toResponse(await cancelCart(request, (await params).cartId))
|
||||
11
apps/suman-bosna/src/app/ucp/v1/cart/route.ts
Normal file
11
apps/suman-bosna/src/app/ucp/v1/cart/route.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { createCart } from "@lib/ucp/operations"
|
||||
import { readJsonBody, toResponse } from "@lib/ucp/ucp"
|
||||
|
||||
export const POST = async (request: Request) =>
|
||||
toResponse(
|
||||
await createCart(
|
||||
request,
|
||||
(await readJsonBody(request)) ?? {},
|
||||
request.headers.get("idempotency-key")
|
||||
)
|
||||
)
|
||||
5
apps/suman-bosna/src/app/ucp/v1/catalog/lookup/route.ts
Normal file
5
apps/suman-bosna/src/app/ucp/v1/catalog/lookup/route.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { lookupCatalog } from "@lib/ucp/operations"
|
||||
import { readJsonBody, toResponse } from "@lib/ucp/ucp"
|
||||
|
||||
export const POST = async (request: Request) =>
|
||||
toResponse(await lookupCatalog(request, (await readJsonBody(request)) ?? {}))
|
||||
5
apps/suman-bosna/src/app/ucp/v1/catalog/search/route.ts
Normal file
5
apps/suman-bosna/src/app/ucp/v1/catalog/search/route.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { searchCatalog } from "@lib/ucp/operations"
|
||||
import { readJsonBody, toResponse } from "@lib/ucp/ucp"
|
||||
|
||||
export const POST = async (request: Request) =>
|
||||
toResponse(await searchCatalog(request, (await readJsonBody(request)) ?? {}))
|
||||
@@ -0,0 +1,7 @@
|
||||
import { cancelCheckout } from "@lib/ucp/operations"
|
||||
import { toResponse } from "@lib/ucp/ucp"
|
||||
|
||||
export const POST = async (
|
||||
request: Request,
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) => toResponse(await cancelCheckout(request, (await params).id))
|
||||
@@ -0,0 +1,7 @@
|
||||
import { completeCheckout } from "@lib/ucp/operations"
|
||||
import { toResponse } from "@lib/ucp/ucp"
|
||||
|
||||
export const POST = async (
|
||||
request: Request,
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) => toResponse(await completeCheckout(request, (await params).id))
|
||||
@@ -0,0 +1,12 @@
|
||||
import { getCheckout, updateCheckout } from "@lib/ucp/operations"
|
||||
import { readJsonBody, toResponse } from "@lib/ucp/ucp"
|
||||
|
||||
type Context = { params: Promise<{ id: string }> }
|
||||
|
||||
export const GET = async (request: Request, { params }: Context) =>
|
||||
toResponse(await getCheckout(request, (await params).id))
|
||||
|
||||
export const PUT = async (request: Request, { params }: Context) =>
|
||||
toResponse(
|
||||
await updateCheckout(request, (await params).id, (await readJsonBody(request)) ?? {})
|
||||
)
|
||||
11
apps/suman-bosna/src/app/ucp/v1/checkout-sessions/route.ts
Normal file
11
apps/suman-bosna/src/app/ucp/v1/checkout-sessions/route.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { createCheckout } from "@lib/ucp/operations"
|
||||
import { readJsonBody, toResponse } from "@lib/ucp/ucp"
|
||||
|
||||
export const POST = async (request: Request) =>
|
||||
toResponse(
|
||||
await createCheckout(
|
||||
request,
|
||||
(await readJsonBody(request)) ?? {},
|
||||
request.headers.get("idempotency-key")
|
||||
)
|
||||
)
|
||||
26
apps/suman-bosna/src/app/ucp/v1/route.ts
Normal file
26
apps/suman-bosna/src/app/ucp/v1/route.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { handleMcpRequest } from "@lib/ucp/mcp"
|
||||
import { UCP_MCP_PATH, UCP_REST_BASE_PATH, UCP_VERSION } from "@lib/ucp/ucp"
|
||||
import { getRequestOrigin } from "@lib/util/site"
|
||||
|
||||
export const GET = (request: Request) => {
|
||||
const origin = getRequestOrigin(request)
|
||||
const base = `${origin}${UCP_REST_BASE_PATH}`
|
||||
return Response.json({
|
||||
ucp: { version: UCP_VERSION },
|
||||
profile: `${origin}/.well-known/ucp`,
|
||||
mcp: `${origin}${UCP_MCP_PATH}`,
|
||||
operations: [
|
||||
`POST ${base}/catalog/search`,
|
||||
`POST ${base}/catalog/lookup`,
|
||||
`POST ${base}/cart`,
|
||||
`GET|PUT|DELETE ${base}/cart/{id}`,
|
||||
`POST ${base}/checkout-sessions`,
|
||||
`GET|PUT ${base}/checkout-sessions/{id}`,
|
||||
`POST ${base}/checkout-sessions/{id}/complete`,
|
||||
`POST ${base}/checkout-sessions/{id}/cancel`,
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
// Agents that only know the service URL may probe it with MCP JSON-RPC.
|
||||
export const POST = (request: Request) => handleMcpRequest(request)
|
||||
Reference in New Issue
Block a user