Appearance
EF Doc Template — <function-name>
Copy this page to
documentation/portal/backend/edge-functions/<function-name>.mdwhen a function is complex enough to warrant its own contract page. The index is auto-generated; per-function pages are hand-written.
Type: Type A (authenticated) · JWT verify: true · EDGE_FN key: MANAGE_X
Purpose
One or two sentences: what this function does and why it's an EF (write / secret / external HTTP / multi-step).
Request
ts
// invoked from services/{feature}Service.ts
supabase.functions.invoke(EDGE_FN.MANAGE_X, {
body: {
action: 'create' | 'update' | 'delete',
// ...validated fields (mirror the Zod schema)
},
})| Field | Type | Required | Notes |
|---|---|---|---|
action | enum | ✅ | Discriminates the operation. |
... |
Response
jsonc
// ok({ result })
{ "result": { /* row_to_json(...) */ } }Errors: ValidationError (400), AuthError (401), ForbiddenError (403), NotFoundError (404), ConflictError (409), safe 500 on anything else.
Authorization
- Guard:
requireAuth/requireAdmin/optionalAuth. - Ownership check:
<how ownership is verified before mutation>. - RLS backstop:
<which policy also guards the table>.
Side effects
- Tables written:
<table(s)> - External calls:
<Cloudflare purge / none> - Cache invalidation / query keys the client should invalidate:
[<feature>]
Tests (tests/)
- ✅ success path
- ✅ validation failure
- ✅ auth / authz failure
- ✅ safe 500 (no leakage)
- ✅ edge cases:
<...>
Notes / gotchas
<version pin, idempotency, partial-failure behaviour, etc.>