@@ -56,6 +56,10 @@ declare module 'astro:content' {
5656 collection : C ;
5757 slug : E ;
5858 } ;
59+ export type ReferenceLiveEntry < C extends keyof LiveContentConfig [ 'collections' ] > = {
60+ collection : C ;
61+ id : string ;
62+ } ;
5963
6064 /** @deprecated Use `getEntry` instead. */
6165 export function getEntryBySlug <
@@ -84,6 +88,13 @@ declare module 'astro:content' {
8488 filter ?: ( entry : CollectionEntry < C > ) => unknown ,
8589 ) : Promise < CollectionEntry < C > [ ] > ;
8690
91+ export function getLiveCollection < C extends keyof LiveContentConfig [ 'collections' ] > (
92+ collection : C ,
93+ filter ?: LiveLoaderCollectionFilterType < C > ,
94+ ) : Promise <
95+ import ( 'astro' ) . LiveDataCollectionResult < LiveLoaderDataType < C > , LiveLoaderErrorType < C > >
96+ > ;
97+
8798 export function getEntry <
8899 C extends keyof ContentEntryMap ,
89100 E extends ValidContentEntrySlug < C > | ( string & { } ) ,
@@ -120,6 +131,10 @@ declare module 'astro:content' {
120131 ? Promise < DataEntryMap [ C ] [ E ] > | undefined
121132 : Promise < DataEntryMap [ C ] [ E ] >
122133 : Promise < CollectionEntry < C > | undefined > ;
134+ export function getLiveEntry < C extends keyof LiveContentConfig [ 'collections' ] > (
135+ collection : C ,
136+ filter : string | LiveLoaderEntryFilterType < C > ,
137+ ) : Promise < import ( 'astro' ) . LiveDataEntryResult < LiveLoaderDataType < C > , LiveLoaderErrorType < C > > > ;
123138
124139 /** Resolve an array of entry references from the same collection */
125140 export function getEntries < C extends keyof ContentEntryMap > (
@@ -187,5 +202,33 @@ declare module 'astro:content' {
187202
188203 type AnyEntryMap = ContentEntryMap & DataEntryMap ;
189204
205+ type ExtractLoaderTypes < T > = T extends import ( 'astro/loaders' ) . LiveLoader <
206+ infer TData ,
207+ infer TEntryFilter ,
208+ infer TCollectionFilter ,
209+ infer TError
210+ >
211+ ? { data : TData ; entryFilter : TEntryFilter ; collectionFilter : TCollectionFilter ; error : TError }
212+ : { data : never ; entryFilter : never ; collectionFilter : never ; error : never } ;
213+ type ExtractDataType < T > = ExtractLoaderTypes < T > [ 'data' ] ;
214+ type ExtractEntryFilterType < T > = ExtractLoaderTypes < T > [ 'entryFilter' ] ;
215+ type ExtractCollectionFilterType < T > = ExtractLoaderTypes < T > [ 'collectionFilter' ] ;
216+ type ExtractErrorType < T > = ExtractLoaderTypes < T > [ 'error' ] ;
217+
218+ type LiveLoaderDataType < C extends keyof LiveContentConfig [ 'collections' ] > =
219+ LiveContentConfig [ 'collections' ] [ C ] [ 'schema' ] extends undefined
220+ ? ExtractDataType < LiveContentConfig [ 'collections' ] [ C ] [ 'loader' ] >
221+ : import ( 'astro/zod' ) . infer <
222+ Exclude < LiveContentConfig [ 'collections' ] [ C ] [ 'schema' ] , undefined >
223+ > ;
224+ type LiveLoaderEntryFilterType < C extends keyof LiveContentConfig [ 'collections' ] > =
225+ ExtractEntryFilterType < LiveContentConfig [ 'collections' ] [ C ] [ 'loader' ] > ;
226+ type LiveLoaderCollectionFilterType < C extends keyof LiveContentConfig [ 'collections' ] > =
227+ ExtractCollectionFilterType < LiveContentConfig [ 'collections' ] [ C ] [ 'loader' ] > ;
228+ type LiveLoaderErrorType < C extends keyof LiveContentConfig [ 'collections' ] > = ExtractErrorType <
229+ LiveContentConfig [ 'collections' ] [ C ] [ 'loader' ]
230+ > ;
231+
190232 export type ContentConfig = typeof import ( "../src/content.config.js" ) ;
233+ export type LiveContentConfig = never ;
191234}
0 commit comments