From d0abb0cce63d75c0f2e88648c37de42e7197272a Mon Sep 17 00:00:00 2001 From: Bailey Herbert Date: Wed, 20 Jul 2022 18:03:08 -0700 Subject: [PATCH] Fix missing `href` key for `live_site` previews --- src/endpoints/catalog.ts | 4 ++-- src/types/api.ts | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/endpoints/catalog.ts b/src/endpoints/catalog.ts index 3469439..b0415de 100644 --- a/src/endpoints/catalog.ts +++ b/src/endpoints/catalog.ts @@ -1,6 +1,6 @@ import { Client } from '../clients/client'; import { ItemSearchOptions, CommentSearchOptions } from '../types/options'; -import { MarketName, Collection, Item, ItemConversation, ItemShort, ItemMedium } from '../types/api'; +import { MarketName, Collection, Item, ItemConversation, ItemShort, ItemMedium, SearchItem } from '../types/api'; import url from '../util/url'; import mutate from '../util/mutate'; @@ -168,7 +168,7 @@ export interface IItemVersionResponse { export interface ISearchItemsResponse { took: number; - matches: Item[]; + matches: SearchItem[]; item: Item | null; timed_out: boolean; total_hits: number; diff --git a/src/types/api.ts b/src/types/api.ts index a59c428..ac61ba7 100644 --- a/src/types/api.ts +++ b/src/types/api.ts @@ -132,7 +132,13 @@ export interface Item { type: string; }, live_site ?: { + /** + * @deprecated The `url` field is not available except through search, but has been preserved for backwards + * compatibility. Please use the explicit `SearchItem` type if you need this field, as it will be removed + * in a future update. + */ url: string; + href: string; }, icon_preview ?: { icon_url: string; @@ -145,6 +151,17 @@ export interface Item { } }; +/** + * Full details about a marketplace item found in search results. + */ +export type SearchItem = Omit & { + previews: Omit & { + live_site ?: { + url: string; + } + } +}; + /** * An image resource used in items. */