Files
kemal.earth 8ffdcfc145 feat(studio): scoped pat ui (#38170)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Introduces UI for Scoped PAT's.

## Additional context

WIP. Testing endpoints.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Scoped access tokens: create, view, delete, and manage granular
resource/action permissions with custom expiry options and scoped
creation flows.
* New scoped token UI: modal/sheet creation flow, resource access
selectors, permissions editor, and a scoped token list.

* **UI Improvements**
* Tabbed Classic vs Scoped tokens layout, refreshed tokens page,
improved forms, search/filtering, and table tweaks.

* **Bug Fixes / Maintenance**
  * New data hooks and utilities for scoped tokens and token handling.

* **Removed**
  * Legacy account settings layout and legacy token banner.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-02-09 11:32:55 +00:00

24 lines
984 B
TypeScript

import { z } from 'zod'
export const PermissionRowSchema = z.object({
resource: z.string().min(1, 'Please select a resource'),
actions: z.array(z.string()).min(1, 'Please select at least one action'),
})
export const TokenSchema = z
.object({
tokenName: z.string().min(1, 'Please enter a name for the token'),
expiresAt: z.preprocess((val) => (val === 'never' ? undefined : val), z.string().optional()),
customExpiryDate: z.string().optional(),
resourceAccess: z.enum(['all-orgs', 'selected-orgs', 'selected-projects']),
selectedOrganizations: z.array(z.string()).optional(),
selectedProjects: z.array(z.string()).optional(),
permissionRows: z.array(PermissionRowSchema).min(1, 'Please configure at least one permission'),
})
.refine((data) => !(data.expiresAt === 'custom' && !data.customExpiryDate), {
message: 'Please select a custom expiry date',
path: ['expiresAt'],
})
export type TokenFormValues = z.infer<typeof TokenSchema>