feat(proxies): CM-9 backend — polymorphic point-of-contact + resolver
- proxies table (migration 0095, port_id cascade), one per client/interest/yacht - service: get/set(upsert)/clear + resolveEffectiveProxy (yacht → interest → client precedence), port-scoped with entity-in-port guard - per-entity sub-resource routes (/clients|interests|yachts/[id]/proxy) reusing each entity's existing view/edit permission (no new permission resource) - 3 integration tests (CRUD/upsert, tenant guard, resolution precedence) Backend only — ProxyCard UI on the 3 detail pages to follow. tsc clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
8
src/app/api/v1/clients/[id]/proxy/route.ts
Normal file
8
src/app/api/v1/clients/[id]/proxy/route.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { withAuth, withPermission } from '@/lib/api/helpers';
|
||||
import { makeProxyHandlers } from '@/lib/api/proxy-route-handlers';
|
||||
|
||||
const { getHandler, putHandler, deleteHandler } = makeProxyHandlers('client');
|
||||
|
||||
export const GET = withAuth(withPermission('clients', 'view', getHandler));
|
||||
export const PUT = withAuth(withPermission('clients', 'edit', putHandler));
|
||||
export const DELETE = withAuth(withPermission('clients', 'edit', deleteHandler));
|
||||
8
src/app/api/v1/interests/[id]/proxy/route.ts
Normal file
8
src/app/api/v1/interests/[id]/proxy/route.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { withAuth, withPermission } from '@/lib/api/helpers';
|
||||
import { makeProxyHandlers } from '@/lib/api/proxy-route-handlers';
|
||||
|
||||
const { getHandler, putHandler, deleteHandler } = makeProxyHandlers('interest');
|
||||
|
||||
export const GET = withAuth(withPermission('interests', 'view', getHandler));
|
||||
export const PUT = withAuth(withPermission('interests', 'edit', putHandler));
|
||||
export const DELETE = withAuth(withPermission('interests', 'edit', deleteHandler));
|
||||
8
src/app/api/v1/yachts/[id]/proxy/route.ts
Normal file
8
src/app/api/v1/yachts/[id]/proxy/route.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { withAuth, withPermission } from '@/lib/api/helpers';
|
||||
import { makeProxyHandlers } from '@/lib/api/proxy-route-handlers';
|
||||
|
||||
const { getHandler, putHandler, deleteHandler } = makeProxyHandlers('yacht');
|
||||
|
||||
export const GET = withAuth(withPermission('yachts', 'view', getHandler));
|
||||
export const PUT = withAuth(withPermission('yachts', 'edit', putHandler));
|
||||
export const DELETE = withAuth(withPermission('yachts', 'edit', deleteHandler));
|
||||
Reference in New Issue
Block a user