Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-balitskyi committed Dec 12, 2024
1 parent df03e4b commit cc2ca15
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/lib/layout/api-endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ type AuthMethodDisplayName =
| 'Personal access token'
| 'Publishable key'

type InternalSeamAuthMethod = Extract<SeamAuthMethod, 'console_session_token'>
type PublicSeamAuthMethod = Exclude<SeamAuthMethod, 'console_session_token'>

const seamAuthMethodToDisplayNameMap: Record<
Exclude<SeamAuthMethod, InternalSeamAuthMethod>,
PublicSeamAuthMethod,
AuthMethodDisplayName
> = {
api_key: 'API key',
Expand All @@ -74,9 +74,11 @@ export function setEndpointLayoutContext(
file.title = endpoint.title
file.path = endpoint.path

const internalAuthMethod: InternalSeamAuthMethod = 'console_session_token'
file.authMethods = endpoint.authMethods
.filter((method) => method !== internalAuthMethod)
.filter(
(method): method is PublicSeamAuthMethod =>
method in seamAuthMethodToDisplayNameMap,
)
.map((method) => seamAuthMethodToDisplayNameMap[method])

file.request = {
Expand Down

0 comments on commit cc2ca15

Please sign in to comment.