4
4
FeedFetchError ,
5
5
FeedParsingError ,
6
6
FeedTimeoutError ,
7
- FeedURLRequiredError ,
8
- GetKeyRequiredError ,
9
7
InvalidPollingIntervalError ,
10
8
UnsupportedFeedFormatError ,
11
9
} from "./errors"
@@ -82,7 +80,7 @@ export interface HTTPOptions {
82
80
* Base configuration interface for feed collection options
83
81
*/
84
82
interface BaseFeedCollectionConfig <
85
- TExplicit = unknown ,
83
+ TExplicit extends object = Record < string , unknown > ,
86
84
TSchema extends StandardSchemaV1 = never ,
87
85
TFallback extends object = Record < string , unknown > ,
88
86
TKey extends string | number = string | number ,
@@ -169,7 +167,7 @@ interface BaseFeedCollectionConfig<
169
167
* Configuration interface for RSS collection options
170
168
*/
171
169
export interface RSSCollectionConfig <
172
- TExplicit = unknown ,
170
+ TExplicit extends object = RSSItem ,
173
171
TSchema extends StandardSchemaV1 = never ,
174
172
TFallback extends object = RSSItem ,
175
173
TKey extends string | number = string | number ,
@@ -184,7 +182,7 @@ export interface RSSCollectionConfig<
184
182
* Configuration interface for Atom collection options
185
183
*/
186
184
export interface AtomCollectionConfig <
187
- TExplicit = unknown ,
185
+ TExplicit extends object = AtomItem ,
188
186
TSchema extends StandardSchemaV1 = never ,
189
187
TFallback extends object = AtomItem ,
190
188
TKey extends string | number = string | number ,
@@ -197,18 +195,21 @@ export interface AtomCollectionConfig<
197
195
198
196
// Type resolution helper (copied from TanStack DB patterns)
199
197
type InferSchemaOutput < T > = T extends StandardSchemaV1
200
- ? StandardSchemaV1 . InferOutput < T >
198
+ ? StandardSchemaV1 . InferOutput < T > extends object
199
+ ? StandardSchemaV1 . InferOutput < T >
200
+ : Record < string , unknown >
201
201
: Record < string , unknown >
202
202
203
203
type ResolveType <
204
- TExplicit = unknown ,
204
+ TExplicit extends object = Record < string , unknown > ,
205
205
TSchema extends StandardSchemaV1 = never ,
206
206
TFallback extends object = Record < string , unknown > ,
207
- > = unknown extends TExplicit
208
- ? [ TSchema ] extends [ never ]
209
- ? TFallback
210
- : InferSchemaOutput < TSchema >
211
- : TExplicit
207
+ > =
208
+ Record < string , unknown > extends TExplicit
209
+ ? [ TSchema ] extends [ never ]
210
+ ? TFallback
211
+ : InferSchemaOutput < TSchema >
212
+ : TExplicit
212
213
213
214
/**
214
215
* Feed collection utilities
@@ -469,7 +470,7 @@ function getItemId(item: FeedItem, feedType: `rss` | `atom`): string {
469
470
* Internal implementation shared between RSS and Atom collections
470
471
*/
471
472
function createFeedCollectionOptions <
472
- TExplicit = unknown ,
473
+ TExplicit extends object = Record < string , unknown > ,
473
474
TSchema extends StandardSchemaV1 = never ,
474
475
TFallback extends object = Record < string , unknown > ,
475
476
TKey extends string | number = string | number ,
@@ -499,14 +500,6 @@ function createFeedCollectionOptions<
499
500
} = config
500
501
501
502
// Validation
502
- if ( ! feedUrl ) {
503
- throw new FeedURLRequiredError ( )
504
- }
505
-
506
- if ( ! getKey ) {
507
- throw new GetKeyRequiredError ( )
508
- }
509
-
510
503
if ( pollingInterval <= 0 ) {
511
504
throw new InvalidPollingIntervalError ( pollingInterval )
512
505
}
@@ -571,6 +564,7 @@ function createFeedCollectionOptions<
571
564
572
565
const xmlContent = await fetchFeed ( feedUrl , httpOptions )
573
566
567
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
574
568
if ( ! XMLValidator . validate ( xmlContent ) ) {
575
569
throw new FeedParsingError ( feedUrl , new Error ( `Invalid XML content` ) )
576
570
}
@@ -580,7 +574,10 @@ function createFeedCollectionOptions<
580
574
`Parsed ${ parsedFeed . items . length } items from ${ parsedFeed . type } feed`
581
575
)
582
576
583
- if ( expectedFeedType && expectedFeedType !== parsedFeed . type ) {
577
+ if (
578
+ expectedFeedType !== undefined &&
579
+ expectedFeedType !== parsedFeed . type
580
+ ) {
584
581
throw new UnsupportedFeedFormatError ( feedUrl )
585
582
}
586
583
@@ -763,7 +760,7 @@ function createFeedCollectionOptions<
763
760
* Creates RSS collection options for use with a standard Collection
764
761
*/
765
762
export function rssCollectionOptions <
766
- TExplicit = unknown ,
763
+ TExplicit extends object = RSSItem ,
767
764
TSchema extends StandardSchemaV1 = never ,
768
765
TFallback extends object = RSSItem ,
769
766
TKey extends string | number = string | number ,
@@ -781,7 +778,7 @@ export function rssCollectionOptions<
781
778
* Creates Atom collection options for use with a standard Collection
782
779
*/
783
780
export function atomCollectionOptions <
784
- TExplicit = unknown ,
781
+ TExplicit extends object = AtomItem ,
785
782
TSchema extends StandardSchemaV1 = never ,
786
783
TFallback extends object = AtomItem ,
787
784
TKey extends string | number = string | number ,
0 commit comments