File tree Expand file tree Collapse file tree
packages/client/src/clients/feed Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " @knocklabs/client " : patch
3+ ---
4+
5+ Improve ` FetchFeedOptionsForRequest ` type
Original file line number Diff line number Diff line change @@ -65,14 +65,25 @@ export type FetchFeedOptions = {
6565 __fetchSource ?: "socket" | "http" ;
6666} & Omit < FeedClientOptions , "__experimentalCrossBrowserUpdates" > ;
6767
68- // The final data shape that is sent to the API
69- // Should match types here: https://docs.knock.app/reference#get-feed
68+ /**
69+ * The final data shape that is sent to the the list feed items endpoint of the Knock API.
70+ *
71+ * @see https://docs.knock.app/api-reference/users/feeds/list_items
72+ */
7073export type FetchFeedOptionsForRequest = Omit <
7174 FeedClientOptions ,
72- "trigger_data"
75+ "trigger_data" | "inserted_at_date_range"
7376> & {
74- // Formatted trigger data into a string
77+ /** The trigger data of the feed items (as a JSON string). */
7578 trigger_data ?: string ;
79+ /** Limits the results to items inserted after or on the given date. */
80+ "inserted_at.gte" ?: string ;
81+ /** Limits the results to items inserted before or on the given date. */
82+ "inserted_at.lte" ?: string ;
83+ /** Limits the results to items inserted after the given date. */
84+ "inserted_at.gt" ?: string ;
85+ /** Limits the results to items inserted before the given date. */
86+ "inserted_at.lt" ?: string ;
7687 // Unset options that should not be sent to the API
7788 __loadingType : undefined ;
7889 __fetchSource : undefined ;
Original file line number Diff line number Diff line change 1- import type { FeedClientOptions , FeedItem } from "./interfaces" ;
1+ import type {
2+ FeedClientOptions ,
3+ FeedItem ,
4+ FetchFeedOptionsForRequest ,
5+ } from "./interfaces" ;
26
37export function deduplicateItems ( items : FeedItem [ ] ) : FeedItem [ ] {
48 const seen : Record < string , boolean > = { } ;
@@ -22,14 +26,19 @@ export function sortItems(items: FeedItem[]) {
2226 } ) ;
2327}
2428
29+ type DateRangeParams = Pick <
30+ FetchFeedOptionsForRequest ,
31+ "inserted_at.gte" | "inserted_at.lte" | "inserted_at.gt" | "inserted_at.lt"
32+ > ;
33+
2534export function mergeDateRangeParams ( options : FeedClientOptions ) {
2635 const { inserted_at_date_range, ...rest } = options ;
2736
2837 if ( ! inserted_at_date_range ) {
2938 return rest ;
3039 }
3140
32- const dateRangeParams : Record < string , string > = { } ;
41+ const dateRangeParams : DateRangeParams = { } ;
3342
3443 // Determine which operators to use based on the inclusive flag
3544 const isInclusive = inserted_at_date_range . inclusive ?? false ;
You can’t perform that action at this time.
0 commit comments