1- declare module ' astro:content' {
1+ declare module " astro:content" {
22 export interface RenderResult {
3- Content : import ( ' astro/runtime/server/index.js' ) . AstroComponentFactory ;
4- headings : import ( ' astro' ) . MarkdownHeading [ ] ;
3+ Content : import ( " astro/runtime/server/index.js" ) . AstroComponentFactory ;
4+ headings : import ( " astro" ) . MarkdownHeading [ ] ;
55 remarkPluginFrontmatter: Record < string , any > ;
66 }
77 interface Render {
8- ' .md' : Promise < RenderResult > ;
8+ " .md" : Promise < RenderResult > ;
99 }
1010
1111 export interface RenderedContent {
@@ -19,7 +19,9 @@ declare module 'astro:content' {
1919 type Flatten < T > = T extends { [ K : string ] : infer U } ? U : never ;
2020
2121 export type CollectionKey = keyof DataEntryMap ;
22- export type CollectionEntry < C extends CollectionKey > = Flatten < DataEntryMap [ C ] > ;
22+ export type CollectionEntry < C extends CollectionKey > = Flatten <
23+ DataEntryMap [ C ]
24+ > ;
2325
2426 type AllValuesOf < T > = T extends any ? T [ keyof T ] : never ;
2527
@@ -31,12 +33,17 @@ declare module 'astro:content' {
3133 id : E ;
3234 } ;
3335
34- export type ReferenceLiveEntry < C extends keyof LiveContentConfig [ 'collections' ] > = {
36+ export type ReferenceLiveEntry <
37+ C extends keyof LiveContentConfig [ "collections" ] ,
38+ > = {
3539 collection : C ;
3640 id : string ;
3741 } ;
3842
39- export function getCollection < C extends keyof DataEntryMap , E extends CollectionEntry < C > > (
43+ export function getCollection <
44+ C extends keyof DataEntryMap ,
45+ E extends CollectionEntry < C > ,
46+ > (
4047 collection : C ,
4148 filter ?: ( entry : CollectionEntry < C > ) => entry is E ,
4249 ) : Promise < E [ ] > ;
@@ -45,11 +52,16 @@ declare module 'astro:content' {
4552 filter ?: ( entry : CollectionEntry < C > ) => unknown ,
4653 ) : Promise < CollectionEntry < C > [ ] > ;
4754
48- export function getLiveCollection < C extends keyof LiveContentConfig [ 'collections' ] > (
55+ export function getLiveCollection <
56+ C extends keyof LiveContentConfig [ "collections" ] ,
57+ > (
4958 collection : C ,
5059 filter ?: LiveLoaderCollectionFilterType < C > ,
5160 ) : Promise <
52- import ( 'astro' ) . LiveDataCollectionResult < LiveLoaderDataType < C > , LiveLoaderErrorType < C > >
61+ import ( "astro" ) . LiveDataCollectionResult <
62+ LiveLoaderDataType < C > ,
63+ LiveLoaderErrorType < C >
64+ >
5365 > ;
5466
5567 export function getEntry <
@@ -71,10 +83,17 @@ declare module 'astro:content' {
7183 ? Promise < DataEntryMap [ C ] [ E ] > | undefined
7284 : Promise < DataEntryMap [ C ] [ E ] >
7385 : Promise < CollectionEntry < C > | undefined > ;
74- export function getLiveEntry < C extends keyof LiveContentConfig [ 'collections' ] > (
86+ export function getLiveEntry <
87+ C extends keyof LiveContentConfig [ "collections" ] ,
88+ > (
7589 collection : C ,
7690 filter : string | LiveLoaderEntryFilterType < C > ,
77- ) : Promise < import ( 'astro' ) . LiveDataEntryResult < LiveLoaderDataType < C > , LiveLoaderErrorType < C > > > ;
91+ ) : Promise <
92+ import ( "astro" ) . LiveDataEntryResult <
93+ LiveLoaderDataType < C > ,
94+ LiveLoaderErrorType < C >
95+ >
96+ > ;
7897
7998 /** Resolve an array of entry references from the same collection */
8099 export function getEntries < C extends keyof DataEntryMap > (
@@ -94,9 +113,9 @@ declare module 'astro:content' {
94113 | ( string & { } ) ,
95114 > (
96115 collection : C ,
97- ) : import ( ' astro/zod' ) . ZodPipe <
98- import ( ' astro/zod' ) . ZodString ,
99- import ( ' astro/zod' ) . ZodTransform <
116+ ) : import ( " astro/zod" ) . ZodPipe <
117+ import ( " astro/zod" ) . ZodString ,
118+ import ( " astro/zod" ) . ZodTransform <
100119 C extends keyof DataEntryMap
101120 ? {
102121 collection : C ;
@@ -107,47 +126,67 @@ declare module 'astro:content' {
107126 >
108127 > ;
109128
110- type ReturnTypeOrOriginal < T > = T extends ( ...args : any [ ] ) = > infer R ? R : T ;
111- type InferEntrySchema < C extends keyof DataEntryMap > = import ( 'astro/zod' ) . infer <
112- ReturnTypeOrOriginal < Required < ContentConfig [ 'collections' ] [ C ] > [ 'schema' ] >
113- > ;
129+ type ReturnTypeOrOriginal < T > = T extends ( ...args : any [ ] ) = > infer R
130+ ? R
131+ : T ;
132+ type InferEntrySchema < C extends keyof DataEntryMap > =
133+ import ( "astro/zod" ) . infer <
134+ ReturnTypeOrOriginal <
135+ Required < ContentConfig [ "collections" ] [ C ] > [ "schema" ]
136+ >
137+ > ;
114138 type ExtractLoaderConfig < T > = T extends { loader : infer L } ? L : never ;
115139 type InferLoaderSchema <
116140 C extends keyof DataEntryMap ,
117- L = ExtractLoaderConfig < ContentConfig [ ' collections' ] [ C ] > ,
118- > = L extends { schema : import ( ' astro/zod' ) . ZodSchema }
119- ? import ( ' astro/zod' ) . infer < L [ ' schema' ] >
141+ L = ExtractLoaderConfig < ContentConfig [ " collections" ] [ C ] > ,
142+ > = L extends { schema : import ( " astro/zod" ) . ZodSchema }
143+ ? import ( " astro/zod" ) . infer < L [ " schema" ] >
120144 : any ;
121145
122- type DataEntryMap = {
123-
124- } ;
146+ type DataEntryMap = { } ;
125147
126- type ExtractLoaderTypes < T > = T extends import ( ' astro/loaders' ) . LiveLoader <
148+ type ExtractLoaderTypes < T > = T extends import ( " astro/loaders" ) . LiveLoader <
127149 infer TData ,
128150 infer TEntryFilter ,
129151 infer TCollectionFilter ,
130152 infer TError
131153 >
132- ? { data : TData ; entryFilter : TEntryFilter ; collectionFilter : TCollectionFilter ; error : TError }
133- : { data : never ; entryFilter : never ; collectionFilter : never ; error : never } ;
134- type ExtractEntryFilterType < T > = ExtractLoaderTypes < T > [ 'entryFilter' ] ;
135- type ExtractCollectionFilterType < T > = ExtractLoaderTypes < T > [ 'collectionFilter' ] ;
136- type ExtractErrorType < T > = ExtractLoaderTypes < T > [ 'error' ] ;
137-
138- type LiveLoaderDataType < C extends keyof LiveContentConfig [ 'collections' ] > =
139- LiveContentConfig [ 'collections' ] [ C ] [ 'schema' ] extends undefined
140- ? ExtractDataType < LiveContentConfig [ 'collections' ] [ C ] [ 'loader' ] >
141- : import ( 'astro/zod' ) . infer <
142- Exclude < LiveContentConfig [ 'collections' ] [ C ] [ 'schema' ] , undefined >
154+ ? {
155+ data : TData ;
156+ entryFilter : TEntryFilter ;
157+ collectionFilter : TCollectionFilter ;
158+ error : TError ;
159+ }
160+ : {
161+ data : never ;
162+ entryFilter : never ;
163+ collectionFilter : never ;
164+ error : never ;
165+ } ;
166+ type ExtractEntryFilterType < T > = ExtractLoaderTypes < T > [ "entryFilter" ] ;
167+ type ExtractCollectionFilterType < T > =
168+ ExtractLoaderTypes < T > [ "collectionFilter" ] ;
169+ type ExtractErrorType < T > = ExtractLoaderTypes < T > [ "error" ] ;
170+
171+ type LiveLoaderDataType < C extends keyof LiveContentConfig [ "collections" ] > =
172+ LiveContentConfig [ "collections" ] [ C ] [ "schema" ] extends undefined
173+ ? ExtractDataType < LiveContentConfig [ "collections" ] [ C ] [ "loader" ] >
174+ : import ( "astro/zod" ) . infer <
175+ Exclude <
176+ LiveContentConfig [ "collections" ] [ C ] [ "schema" ] ,
177+ undefined
178+ >
143179 > ;
144- type LiveLoaderEntryFilterType < C extends keyof LiveContentConfig [ 'collections' ] > =
145- ExtractEntryFilterType < LiveContentConfig [ 'collections' ] [ C ] [ 'loader' ] > ;
146- type LiveLoaderCollectionFilterType < C extends keyof LiveContentConfig [ 'collections' ] > =
147- ExtractCollectionFilterType < LiveContentConfig [ 'collections' ] [ C ] [ 'loader' ] > ;
148- type LiveLoaderErrorType < C extends keyof LiveContentConfig [ 'collections' ] > = ExtractErrorType <
149- LiveContentConfig [ 'collections' ] [ C ] [ 'loader' ]
180+ type LiveLoaderEntryFilterType <
181+ C extends keyof LiveContentConfig [ "collections" ] ,
182+ > = ExtractEntryFilterType < LiveContentConfig [ "collections" ] [ C ] [ "loader" ] > ;
183+ type LiveLoaderCollectionFilterType <
184+ C extends keyof LiveContentConfig [ "collections" ] ,
185+ > = ExtractCollectionFilterType <
186+ LiveContentConfig [ "collections" ] [ C ] [ "loader" ]
150187 > ;
188+ type LiveLoaderErrorType < C extends keyof LiveContentConfig [ "collections" ] > =
189+ ExtractErrorType < LiveContentConfig [ "collections" ] [ C ] [ "loader" ] > ;
151190
152191 export type ContentConfig = never ;
153192 export type LiveContentConfig = never ;
0 commit comments