|
1 | 1 | import type { Base$Fetch } from 'nitropack/types' |
2 | | -import type { AuthApiEndpointPath, AuthApiEndpointResponse } from '#nuxt-better-auth' |
| 2 | +import type { AuthApiEndpointPath } from '#nuxt-better-auth' |
3 | 3 |
|
4 | 4 | declare const requestFetch: Base$Fetch |
5 | 5 |
|
6 | 6 | type CustomerStatePath = Extract<AuthApiEndpointPath, '/api/auth/customer/state'> |
7 | 7 | const customerStatePath: CustomerStatePath = '/api/auth/customer/state' |
8 | 8 |
|
9 | | -async function assertEndpointInference() { |
| 9 | +async function assertNoGlobalEndpointInference() { |
10 | 10 | const customerState = await requestFetch('/api/auth/customer/state') |
| 11 | + // @ts-expect-error use useAuthRequestFetch for typed auth endpoint payloads |
11 | 12 | customerState.activeSubscriptions[0]?.toUpperCase() |
12 | | - customerState.hasBillingIssue.valueOf() |
13 | | - // @ts-expect-error no unknown key |
14 | | - void customerState.missingField |
15 | | - |
16 | | - const customerViaHelper: AuthApiEndpointResponse<'/api/auth/customer/state'> = customerState |
17 | | - void customerViaHelper |
18 | | - |
19 | | - const customerSessionGet = await requestFetch('/api/auth/customer/session') |
20 | | - const customerSessionPost = await requestFetch('/api/auth/customer/session', { method: 'POST' }) |
21 | | - customerSessionGet.ok.valueOf() |
22 | | - customerSessionPost.ok.valueOf() |
23 | | - |
24 | | - const session = await requestFetch('/api/auth/get-session') |
25 | | - if (session) { |
26 | | - void session.user.id |
27 | | - void session.session.expiresAt |
28 | | - } |
29 | | - // @ts-expect-error get-session can be null |
30 | | - const shouldFailNullability: { user: { id: string } } = session |
31 | | - void shouldFailNullability |
32 | | - |
33 | | - const sessionViaHelper: AuthApiEndpointResponse<'/api/auth/get-session', 'get'> = session |
34 | | - void sessionViaHelper |
35 | 13 | } |
36 | 14 |
|
37 | 15 | void customerStatePath |
38 | | -void assertEndpointInference |
| 16 | +void assertNoGlobalEndpointInference |
0 commit comments