11import type { H3Event } from 'h3'
2+ import type { ContentEvent } from './internal/event'
23import { collectionQueryBuilder } from './internal/query'
34import { generateNavigationTree } from './internal/navigation'
45import { generateItemSurround } from './internal/surround'
@@ -7,6 +8,7 @@ import { fetchQuery } from './internal/api'
78import type { Collections , CollectionQueryBuilder , PageCollections , SurroundOptions , SQLOperator , QueryGroupFunction } from '@nuxt/content'
89
910export type { GenerateSearchSectionsOptions , Section } from './internal/search'
11+ export type { ContentEvent , RequestEvent } from './internal/event'
1012
1113interface ChainablePromise < T extends keyof PageCollections , R > extends Promise < R > {
1214 where ( field : keyof PageCollections [ T ] | string , operator : SQLOperator , value ?: unknown ) : ChainablePromise < T , R >
@@ -15,37 +17,37 @@ interface ChainablePromise<T extends keyof PageCollections, R> extends Promise<R
1517 order ( field : keyof PageCollections [ T ] , direction : 'ASC' | 'DESC' ) : ChainablePromise < T , R >
1618}
1719
18- export const queryCollection = < T extends keyof Collections > ( event : H3Event , collection : T ) : CollectionQueryBuilder < Collections [ T ] > => {
19- return collectionQueryBuilder < T > ( collection , ( collection , sql ) => fetchQuery ( event , collection , sql ) )
20+ export const queryCollection = < T extends keyof Collections > ( event : ContentEvent , collection : T ) : CollectionQueryBuilder < Collections [ T ] > => {
21+ return collectionQueryBuilder < T > ( collection , ( collection , sql ) => fetchQuery ( event as H3Event , collection , sql ) )
2022}
2123
22- export function queryCollectionNavigation < T extends keyof PageCollections > ( event : H3Event , collection : T , fields ?: Array < keyof PageCollections [ T ] > ) {
24+ export function queryCollectionNavigation < T extends keyof PageCollections > ( event : ContentEvent , collection : T , fields ?: Array < keyof PageCollections [ T ] > ) {
2325 return chainablePromise ( event , collection , qb => generateNavigationTree ( qb , fields ) )
2426}
2527
26- export function queryCollectionItemSurroundings < T extends keyof PageCollections > ( event : H3Event , collection : T , path : string , opts ?: SurroundOptions < keyof PageCollections [ T ] > ) {
28+ export function queryCollectionItemSurroundings < T extends keyof PageCollections > ( event : ContentEvent , collection : T , path : string , opts ?: SurroundOptions < keyof PageCollections [ T ] > ) {
2729 return chainablePromise ( event , collection , qb => generateItemSurround ( qb , path , opts ) )
2830}
2931
3032export function queryCollectionSearchSections < T extends keyof PageCollections , const K extends keyof PageCollections [ T ] > (
31- event : H3Event ,
33+ event : ContentEvent ,
3234 collection : T ,
3335 opts : Omit < GenerateSearchSectionsOptions , 'extraFields' > & { extraFields : K [ ] } ,
3436) : ChainablePromise < T , Array < Section & Pick < PageCollections [ T ] , K > > >
3537export function queryCollectionSearchSections < T extends keyof PageCollections > (
36- event : H3Event ,
38+ event : ContentEvent ,
3739 collection : T ,
3840 opts ?: GenerateSearchSectionsOptions ,
3941) : ChainablePromise < T , Section [ ] >
4042export function queryCollectionSearchSections < T extends keyof PageCollections > (
41- event : H3Event ,
43+ event : ContentEvent ,
4244 collection : T ,
4345 opts ?: GenerateSearchSectionsOptions ,
4446) {
4547 return chainablePromise ( event , collection , qb => generateSearchSections ( qb , opts ) )
4648}
4749
48- function chainablePromise < T extends keyof PageCollections , Result > ( event : H3Event , collection : T , fn : ( qb : CollectionQueryBuilder < PageCollections [ T ] > ) => Promise < Result > ) {
50+ function chainablePromise < T extends keyof PageCollections , Result > ( event : ContentEvent , collection : T , fn : ( qb : CollectionQueryBuilder < PageCollections [ T ] > ) => Promise < Result > ) {
4951 const queryBuilder = queryCollection ( event , collection )
5052
5153 const chainable : ChainablePromise < T , Result > = {
0 commit comments