Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

Commit 158d75b

Browse files
baozhoutaoclaude
andauthored
docs(auth): compile every README snippet against the shipped surface (#8189)
Burns down the `packages/auth/README.md` row of `UNGATED_DOCS` in `scripts/check-doc-snippet-types.mjs`: the page's ten `tsx` fences now compile in the gate's covered tier instead of being ledgered. Census on the base, with the gate's own analyzer, matched the ledger row exactly (17 = 1 parse + 15 TS2304 + 1 TS2741). Re-measured after adding only the missing import lines and `declare` stand-ins, the real debt is 2 TS2741, both the same defect: `AuthProviderOptions.authUrl` is required and the Quick Start omitted it. The second one was hidden -- an unresolved `AuthProvider` tag suppresses the prop check on its own element. - Every continuation fence gets its own import line and typed bindings (`declare const X: () => ReactNode`) for the names it uses. - The three-form fence parsed as one JSX expression (TS2657); the elements are now separate statements. Measured: it hid no prop defect. - `authUrl` added beside `client` in the two `AuthProvider` examples -- the spelling every call site in this repository already writes, including `skills/objectui/guides/auth-permissions.md`. - No type was widened, no fragment marker added, no `src/` file touched. Part of #5174 (batch 28) Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr Co-authored-by: Claude <noreply@anthropic.com>
1 parent 0c8dbc4 commit 158d75b

2 files changed

Lines changed: 45 additions & 16 deletions

File tree

‎packages/auth/README.md‎

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,18 @@ npm install @object-ui/auth
2525
## Quick Start
2626

2727
```tsx
28-
import { AuthProvider, useAuth, AuthGuard } from '@object-ui/auth';
29-
import { createAuthClient } from '@object-ui/auth';
28+
import type { ReactNode } from 'react';
29+
import { AuthProvider, AuthGuard, createAuthClient, useAuth } from '@object-ui/auth';
3030

31-
const authClient = createAuthClient({
32-
baseURL: 'https://api.example.com/auth',
33-
});
31+
// Your app supplies the sign-in page shown to unauthenticated visitors.
32+
declare const LoginPage: () => ReactNode;
33+
34+
const authUrl = 'https://api.example.com/auth';
35+
const authClient = createAuthClient({ baseURL: authUrl });
3436

3537
function App() {
3638
return (
37-
<AuthProvider client={authClient}>
39+
<AuthProvider authUrl={authUrl} client={authClient}>
3840
<AuthGuard fallback={<LoginPage />}>
3941
<Dashboard />
4042
</AuthGuard>
@@ -57,19 +59,30 @@ function Dashboard() {
5759

5860
### AuthProvider
5961

60-
Wraps your application with authentication context:
62+
Wraps your application with authentication context. `authUrl` is **required**;
63+
`client` is optional, and when you pass one it is used instead of the client
64+
`AuthProvider` would otherwise build from `authUrl`:
6165

6266
```tsx
63-
<AuthProvider client={authClient}>
67+
import type { ReactNode } from 'react';
68+
import { AuthProvider } from '@object-ui/auth';
69+
import type { AuthClient } from '@object-ui/auth';
70+
71+
declare const authClient: AuthClient;
72+
declare const App: () => ReactNode;
73+
74+
<AuthProvider authUrl="/api/v1/auth" client={authClient}>
6475
<App />
65-
</AuthProvider>
76+
</AuthProvider>;
6677
```
6778

6879
### useAuth
6980

7081
Hook for accessing auth state and methods:
7182

7283
```tsx
84+
import { useAuth } from '@object-ui/auth';
85+
7386
const {
7487
user,
7588
session,
@@ -100,27 +113,38 @@ const {
100113
Protects children from unauthenticated access:
101114

102115
```tsx
116+
import type { ReactNode } from 'react';
117+
import { AuthGuard, LoginForm } from '@object-ui/auth';
118+
119+
declare const ProtectedContent: () => ReactNode;
120+
103121
<AuthGuard fallback={<LoginForm />}>
104122
<ProtectedContent />
105-
</AuthGuard>
123+
</AuthGuard>;
106124
```
107125

108126
### LoginForm / RegisterForm / ForgotPasswordForm
109127

110128
Pre-built authentication form components:
111129

112130
```tsx
113-
<LoginForm onSuccess={() => navigate('/dashboard')} />
114-
<RegisterForm onSuccess={() => navigate('/welcome')} />
115-
<ForgotPasswordForm onSuccess={() => navigate('/check-email')} />
131+
import { ForgotPasswordForm, LoginForm, RegisterForm } from '@object-ui/auth';
132+
133+
declare const navigate: (to: string) => void;
134+
135+
<LoginForm onSuccess={() => navigate('/dashboard')} />;
136+
<RegisterForm onSuccess={() => navigate('/welcome')} />;
137+
<ForgotPasswordForm onSuccess={() => navigate('/check-email')} />;
116138
```
117139

118140
### UserMenu
119141

120142
Displays current user info with avatar and sign-out:
121143

122144
```tsx
123-
<UserMenu />
145+
import { UserMenu } from '@object-ui/auth';
146+
147+
<UserMenu />;
124148
```
125149

126150
### createAuthenticatedFetch
@@ -129,6 +153,8 @@ Creates a fetch wrapper that injects the stored Bearer token (plus
129153
`X-Tenant-ID` and `Accept-Language`) into API requests:
130154

131155
```tsx
156+
import { createAuthenticatedFetch } from '@object-ui/auth';
157+
132158
const authedFetch = createAuthenticatedFetch();
133159

134160
// For fetches whose target URL comes from view metadata (`provider: 'api'`
@@ -330,8 +356,11 @@ This feature aligns with the `PreviewModeConfig` from `@objectstack/spec/kernel`
330356
### Usage
331357

332358
```tsx
359+
import type { ReactNode } from 'react';
333360
import { AuthProvider, PreviewBanner } from '@object-ui/auth';
334361

362+
declare const Dashboard: () => ReactNode;
363+
335364
function App() {
336365
return (
337366
<AuthProvider
@@ -377,6 +406,8 @@ import { PreviewBanner } from '@object-ui/auth';
377406
Use the `useAuth` hook to check if the app is in preview mode:
378407

379408
```tsx
409+
import { useAuth } from '@object-ui/auth';
410+
380411
function MyComponent() {
381412
const { isPreviewMode, previewMode } = useAuth();
382413

‎scripts/check-doc-snippet-types.mjs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,8 +775,6 @@ const UNGATED_DOCS = {
775775
'diagnostic(s) (TS2420, TS2355) — a `DataSource` implementation written as `// ... other ' +
776776
'methods`. This entry read 9 until objectui#7417 paid down the three TS2305s it carried; ' +
777777
'what is left is fragment shape, and no gate reads this page\'s import names.',
778-
'packages/auth/README.md':
779-
'1 parse diagnostic(s) — blocks fenced `ts` that are bare object literals or elided bodies; 15 undefined-name diagnostic(s) — blocks continue an earlier block, or use ambient names the page never defines; plus TS2741x1 — candidate real defects, un-triaged',
780778
'packages/fields/README.md':
781779
'2 undefined-name diagnostic(s) — blocks continue an earlier block, or use ambient names the page never defines; 1 unresolved-module diagnostic(s)',
782780
'packages/plugin-charts/README.md':

0 commit comments

Comments
 (0)