Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/server-route-validators-openapi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@tanstack/start-client-core': minor
'@tanstack/start-server-core': minor
'@tanstack/start-openapi': minor
---

Add slot-shaped `validator` (`body`, `query`, `path`, `headers`) to server route method builders, validated before the handler and passed as `ctx.data`. Method builders also accept `response`, `operationId`, `summary`, `description`, `tags` and `deprecated`. New `@tanstack/start-openapi` package generates OpenAPI 3.1 documents from server routes.
4 changes: 1 addition & 3 deletions DEBUGGING.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ console.log('[DEBUG buildLocation] output:', result)
```javascript
test('should reproduce the exact issue from bug report', async () => {
// Set up the exact scenario described
const router = createRouter({
/* exact config from bug report */
})
const router = createRouter({/* exact config from bug report */})

// Perform the exact user actions
await navigate({ to: '/initial-route' })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,10 @@ export function createWorkload(

return navigation
.then((value): NavigationSettlement => ({ status: 'fulfilled', value }))
.catch(
(reason: unknown): NavigationSettlement => ({
status: 'rejected',
reason,
}),
)
.catch((reason: unknown): NavigationSettlement => ({
status: 'rejected',
reason,
}))
}

await router.load()
Expand Down
3 changes: 1 addition & 2 deletions benchmarks/ssr/scenarios/assets/react/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import type {
} from '@tanstack/react-start/server'

type CreateTransformContext =
| { warmup: true }
| { request: Request; warmup: false }
{ warmup: true } | { request: Request; warmup: false }

const cdnOrigin = 'https://cdn.example.com'

Expand Down
3 changes: 1 addition & 2 deletions benchmarks/ssr/scenarios/assets/solid/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import type {
} from '@tanstack/solid-start/server'

type CreateTransformContext =
| { warmup: true }
| { request: Request; warmup: false }
{ warmup: true } | { request: Request; warmup: false }

const cdnOrigin = 'https://cdn.example.com'

Expand Down
3 changes: 1 addition & 2 deletions benchmarks/ssr/scenarios/assets/vue/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import type {
} from '@tanstack/vue-start/server'

type CreateTransformContext =
| { warmup: true }
| { request: Request; warmup: false }
{ warmup: true } | { request: Request; warmup: false }

const cdnOrigin = 'https://cdn.example.com'

Expand Down
3 changes: 1 addition & 2 deletions docs/router/api/router/LinkPropsType.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ The `LinkProps` type extends the [`ActiveLinkOptions`](./ActiveLinkOptionsType.m
type LinkProps = ActiveLinkOptions &
Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {
children?:
| React.ReactNode
| ((state: { isActive: boolean }) => React.ReactNode)
React.ReactNode | ((state: { isActive: boolean }) => React.ReactNode)
}
```

Expand Down
4 changes: 1 addition & 3 deletions docs/router/api/router/ToOptionsType.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ type SearchParamOptions = {

type PathParamOptions = {
params?:
| true
| Record<string, TPathParam>
| ((prev: TFromParams) => TToParams)
true | Record<string, TPathParam> | ((prev: TFromParams) => TToParams)
}

type MaskOptions = {
Expand Down
10 changes: 5 additions & 5 deletions docs/router/api/router/ViewTransitionOptionsType.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ The `ViewTransitionOptions` type accepts an object with a single property:
### `types` property

- Type: `Array<string> | ((locationChangeInfo: {
fromLocation?: ParsedLocation
toLocation: ParsedLocation
pathChanged: boolean
hrefChanged: boolean
hashChanged: boolean
fromLocation?: ParsedLocation
toLocation: ParsedLocation
pathChanged: boolean
hrefChanged: boolean
hashChanged: boolean
}) => (Array<string> | false))`
- Required
- Either one of:
Expand Down
6 changes: 2 additions & 4 deletions docs/router/guide/navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,10 @@ export type LinkProps<
> = LinkOptions<RegisteredRouter['routeTree'], TFrom, TTo> & {
// A function that returns additional props for the `active` state of this link. These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)
activeProps?:
| FrameworkHTMLAnchorTagAttributes
| (() => FrameworkHTMLAnchorAttributes)
FrameworkHTMLAnchorTagAttributes | (() => FrameworkHTMLAnchorAttributes)
// A function that returns additional props for the `inactive` state of this link. These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)
inactiveProps?:
| FrameworkHTMLAnchorAttributes
| (() => FrameworkHTMLAnchorAttributes)
FrameworkHTMLAnchorAttributes | (() => FrameworkHTMLAnchorAttributes)
}
```

Expand Down
12 changes: 3 additions & 9 deletions docs/router/how-to/debug-router-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,7 @@ const route = createRoute({
// Add to router configuration
const router = createRouter({
routeTree,
context: {
/* ... */
},
context: {/* ... */},
// Log all navigation events
onNavigate: ({ location, type }) => {
console.log(`Navigation (${type}):`, location.pathname)
Expand Down Expand Up @@ -479,9 +477,7 @@ function MyComponent() {
// Add to router configuration
const router = createRouter({
routeTree,
context: {
/* ... */
},
context: {/* ... */},
onUpdate: (router) => {
console.log('Router state updated:', {
pathname: router.state.location.pathname,
Expand Down Expand Up @@ -723,9 +719,7 @@ Monitor these requests when debugging:
```tsx
const router = createRouter({
routeTree,
context: {
/* ... */
},
context: {/* ... */},
onUpdate: (router) => {
performance.mark('router-update')
},
Expand Down
3 changes: 1 addition & 2 deletions docs/start/framework/react/guide/early-hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ export default createServerEntry({
if (phase !== 'static' || !links.length) return

const response = getNodeResponseSomehow(request) as
| ServerResponse
| undefined
ServerResponse | undefined

response?.writeEarlyHints({ link: links })
},
Expand Down
4 changes: 1 addition & 3 deletions docs/start/framework/react/guide/import-protection.md
Original file line number Diff line number Diff line change
Expand Up @@ -525,9 +525,7 @@ importProtection: {
interface ImportProtectionOptions {
enabled?: boolean
behavior?:
| 'error'
| 'mock'
| { dev?: 'error' | 'mock'; build?: 'error' | 'mock' }
'error' | 'mock' | { dev?: 'error' | 'mock'; build?: 'error' | 'mock' }
log?: 'once' | 'always'
include?: Array<string | RegExp>
exclude?: Array<string | RegExp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,8 @@ type NoExpand<T> = T extends unknown ? T : never
// this type assumes the passed object is entirely optional
export type AtLeast<O extends object, K extends string> = NoExpand<
O extends unknown
?
| (K extends keyof O ? { [P in K]: O[P] } & O : O)
| ({ [P in keyof O as P extends K ? P : never]-?: O[P] } & O)
? | (K extends keyof O ? { [P in K]: O[P] } & O : O)
| ({ [P in keyof O as P extends K ? P : never]-?: O[P] } & O)
: never
>

Expand Down
34 changes: 12 additions & 22 deletions e2e/react-start/basic-auth/src/prisma-generated/models/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ export type UserAggregateArgs<
* Determine the order of Users to fetch.
*/
orderBy?:
| Prisma.UserOrderByWithRelationInput
| Prisma.UserOrderByWithRelationInput[]
Prisma.UserOrderByWithRelationInput | Prisma.UserOrderByWithRelationInput[]
/**
* {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs}
*
Expand Down Expand Up @@ -780,18 +779,18 @@ export interface UserDelegate<
Prisma.Extends<'skip', Prisma.Keys<T>>,
Prisma.Extends<'take', Prisma.Keys<T>>
>,
OrderByArg extends Prisma.True extends HasSelectOrTake
OrderByArg extends (Prisma.True extends HasSelectOrTake
? { orderBy: UserGroupByArgs['orderBy'] }
: { orderBy?: UserGroupByArgs['orderBy'] },
: { orderBy?: UserGroupByArgs['orderBy'] }),
OrderFields extends Prisma.ExcludeUnderscoreKeys<
Prisma.Keys<Prisma.MaybeTupleToUnion<T['orderBy']>>
>,
ByFields extends Prisma.MaybeTupleToUnion<T['by']>,
ByValid extends Prisma.Has<ByFields, OrderFields>,
HavingFields extends Prisma.GetHavingFields<T['having']>,
HavingValid extends Prisma.Has<ByFields, HavingFields>,
ByEmpty extends T['by'] extends never[] ? Prisma.True : Prisma.False,
InputErrors extends ByEmpty extends Prisma.True
ByEmpty extends (T['by'] extends never[] ? Prisma.True : Prisma.False),
InputErrors extends (ByEmpty extends Prisma.True
? `Error: "by" must not be empty.`
: HavingValid extends Prisma.False
? {
Expand Down Expand Up @@ -832,7 +831,7 @@ export interface UserDelegate<
[P in OrderFields]: P extends ByFields
? never
: `Error: Field "${P}" in "orderBy" needs to be provided in "by"`
}[OrderFields],
}[OrderFields]),
>(
args: Prisma.SubsetIntersection<T, UserGroupByArgs, OrderByArg> &
InputErrors,
Expand Down Expand Up @@ -867,13 +866,9 @@ export interface Prisma__UserClient<
*/
then<TResult1 = T, TResult2 = never>(
onfulfilled?:
| ((value: T) => TResult1 | PromiseLike<TResult1>)
| undefined
| null,
((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null,
onrejected?:
| ((reason: any) => TResult2 | PromiseLike<TResult2>)
| undefined
| null,
((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null,
): runtime.Types.Utils.JsPromise<TResult1 | TResult2>
/**
* Attaches a callback for only the rejection of the Promise.
Expand All @@ -882,9 +877,7 @@ export interface Prisma__UserClient<
*/
catch<TResult = never>(
onrejected?:
| ((reason: any) => TResult | PromiseLike<TResult>)
| undefined
| null,
((reason: any) => TResult | PromiseLike<TResult>) | undefined | null,
): runtime.Types.Utils.JsPromise<T | TResult>
/**
* Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
Expand Down Expand Up @@ -973,8 +966,7 @@ export type UserFindFirstArgs<
* Determine the order of Users to fetch.
*/
orderBy?:
| Prisma.UserOrderByWithRelationInput
| Prisma.UserOrderByWithRelationInput[]
Prisma.UserOrderByWithRelationInput | Prisma.UserOrderByWithRelationInput[]
/**
* {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs}
*
Expand Down Expand Up @@ -1026,8 +1018,7 @@ export type UserFindFirstOrThrowArgs<
* Determine the order of Users to fetch.
*/
orderBy?:
| Prisma.UserOrderByWithRelationInput
| Prisma.UserOrderByWithRelationInput[]
Prisma.UserOrderByWithRelationInput | Prisma.UserOrderByWithRelationInput[]
/**
* {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs}
*
Expand Down Expand Up @@ -1079,8 +1070,7 @@ export type UserFindManyArgs<
* Determine the order of Users to fetch.
*/
orderBy?:
| Prisma.UserOrderByWithRelationInput
| Prisma.UserOrderByWithRelationInput[]
Prisma.UserOrderByWithRelationInput | Prisma.UserOrderByWithRelationInput[]
/**
* {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,8 @@ type NoExpand<T> = T extends unknown ? T : never
// this type assumes the passed object is entirely optional
export type AtLeast<O extends object, K extends string> = NoExpand<
O extends unknown
?
| (K extends keyof O ? { [P in K]: O[P] } & O : O)
| ({ [P in keyof O as P extends K ? P : never]-?: O[P] } & O)
? | (K extends keyof O ? { [P in K]: O[P] } & O : O)
| ({ [P in keyof O as P extends K ? P : never]-?: O[P] } & O)
: never
>

Expand Down
34 changes: 12 additions & 22 deletions e2e/solid-start/basic-auth/src/prisma-generated/models/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ export type UserAggregateArgs<
* Determine the order of Users to fetch.
*/
orderBy?:
| Prisma.UserOrderByWithRelationInput
| Prisma.UserOrderByWithRelationInput[]
Prisma.UserOrderByWithRelationInput | Prisma.UserOrderByWithRelationInput[]
/**
* {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs}
*
Expand Down Expand Up @@ -780,18 +779,18 @@ export interface UserDelegate<
Prisma.Extends<'skip', Prisma.Keys<T>>,
Prisma.Extends<'take', Prisma.Keys<T>>
>,
OrderByArg extends Prisma.True extends HasSelectOrTake
OrderByArg extends (Prisma.True extends HasSelectOrTake
? { orderBy: UserGroupByArgs['orderBy'] }
: { orderBy?: UserGroupByArgs['orderBy'] },
: { orderBy?: UserGroupByArgs['orderBy'] }),
OrderFields extends Prisma.ExcludeUnderscoreKeys<
Prisma.Keys<Prisma.MaybeTupleToUnion<T['orderBy']>>
>,
ByFields extends Prisma.MaybeTupleToUnion<T['by']>,
ByValid extends Prisma.Has<ByFields, OrderFields>,
HavingFields extends Prisma.GetHavingFields<T['having']>,
HavingValid extends Prisma.Has<ByFields, HavingFields>,
ByEmpty extends T['by'] extends never[] ? Prisma.True : Prisma.False,
InputErrors extends ByEmpty extends Prisma.True
ByEmpty extends (T['by'] extends never[] ? Prisma.True : Prisma.False),
InputErrors extends (ByEmpty extends Prisma.True
? `Error: "by" must not be empty.`
: HavingValid extends Prisma.False
? {
Expand Down Expand Up @@ -832,7 +831,7 @@ export interface UserDelegate<
[P in OrderFields]: P extends ByFields
? never
: `Error: Field "${P}" in "orderBy" needs to be provided in "by"`
}[OrderFields],
}[OrderFields]),
>(
args: Prisma.SubsetIntersection<T, UserGroupByArgs, OrderByArg> &
InputErrors,
Expand Down Expand Up @@ -867,13 +866,9 @@ export interface Prisma__UserClient<
*/
then<TResult1 = T, TResult2 = never>(
onfulfilled?:
| ((value: T) => TResult1 | PromiseLike<TResult1>)
| undefined
| null,
((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null,
onrejected?:
| ((reason: any) => TResult2 | PromiseLike<TResult2>)
| undefined
| null,
((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null,
): runtime.Types.Utils.JsPromise<TResult1 | TResult2>
/**
* Attaches a callback for only the rejection of the Promise.
Expand All @@ -882,9 +877,7 @@ export interface Prisma__UserClient<
*/
catch<TResult = never>(
onrejected?:
| ((reason: any) => TResult | PromiseLike<TResult>)
| undefined
| null,
((reason: any) => TResult | PromiseLike<TResult>) | undefined | null,
): runtime.Types.Utils.JsPromise<T | TResult>
/**
* Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
Expand Down Expand Up @@ -973,8 +966,7 @@ export type UserFindFirstArgs<
* Determine the order of Users to fetch.
*/
orderBy?:
| Prisma.UserOrderByWithRelationInput
| Prisma.UserOrderByWithRelationInput[]
Prisma.UserOrderByWithRelationInput | Prisma.UserOrderByWithRelationInput[]
/**
* {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs}
*
Expand Down Expand Up @@ -1026,8 +1018,7 @@ export type UserFindFirstOrThrowArgs<
* Determine the order of Users to fetch.
*/
orderBy?:
| Prisma.UserOrderByWithRelationInput
| Prisma.UserOrderByWithRelationInput[]
Prisma.UserOrderByWithRelationInput | Prisma.UserOrderByWithRelationInput[]
/**
* {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs}
*
Expand Down Expand Up @@ -1079,8 +1070,7 @@ export type UserFindManyArgs<
* Determine the order of Users to fetch.
*/
orderBy?:
| Prisma.UserOrderByWithRelationInput
| Prisma.UserOrderByWithRelationInput[]
Prisma.UserOrderByWithRelationInput | Prisma.UserOrderByWithRelationInput[]
/**
* {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs}
*
Expand Down
Loading
Loading