@depict-ai/ui 3.0.1 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ES10/index.cjs +38 -85
- package/ES10/index.d.ts +21 -88
- package/ES10/index.js +38 -85
- package/latest/index.cjs +34 -82
- package/latest/index.d.ts +21 -88
- package/latest/index.js +34 -82
- package/package.json +1 -1
- package/server/ES10/index.cjs +38 -85
- package/server/ES10/index.d.ts +21 -88
- package/server/ES10/index.js +38 -85
- package/server/latest/index.cjs +34 -82
- package/server/latest/index.d.ts +21 -88
- package/server/latest/index.js +34 -82
package/server/latest/index.d.ts
CHANGED
|
@@ -2,16 +2,15 @@ import { JSX, Signal, Accessor, Setter } from "solid-js";
|
|
|
2
2
|
import { Amazing_Slider, Node_Array, Display, report, ColsAtSize, Elem, ModernDisplay } from "@depict-ai/utilishared/latest";
|
|
3
3
|
import { SearchFilter, SortModel, SearchRequestV3 } from "@depict-ai/types/api/SearchRequestV3";
|
|
4
4
|
import { SearchFilter as _SearchFilter1, ContentLink, SearchResponse } from "@depict-ai/types/api/SearchResponse";
|
|
5
|
-
import { CategorySuggestion } from "@depict-ai/types/api/SearchSuggestionsResponseV3";
|
|
5
|
+
import { CategorySuggestion, SearchSuggestionsResponseV3 } from "@depict-ai/types/api/SearchSuggestionsResponseV3";
|
|
6
6
|
import { Breadcrumb, Quicklink, GetListingResponse } from "@depict-ai/types/api/GetListingResponse";
|
|
7
|
-
import { LegacyCategorySuggestion, SearchSuggestionsResponse } from "@depict-ai/types/api/SearchSuggestionsResponse";
|
|
8
7
|
import { ProductListingResponseV3 } from "@depict-ai/types/api/ProductListingResponseV3";
|
|
9
8
|
import { SearchSuggestionsRequestV3 } from "@depict-ai/types/api/SearchSuggestionsRequestV3";
|
|
10
9
|
import { ProductListingRequestV3 } from "@depict-ai/types/api/ProductListingRequestV3";
|
|
11
10
|
import { GetListingRequest } from "@depict-ai/types/api/GetListingRequest";
|
|
12
11
|
import { BaseSearchRequestV3 } from "@depict-ai/types/api/BaseSearchRequestV3";
|
|
13
12
|
import { SearchFilter as _SearchFilter2 } from "@depict-ai/types/api/SearchRequestV2";
|
|
14
|
-
export const version = "3.0.
|
|
13
|
+
export const version = "3.0.3";
|
|
15
14
|
/** @jsxImportSource solid-js */
|
|
16
15
|
export function GenericSliderArrowButton(props?: {
|
|
17
16
|
width_?: number;
|
|
@@ -603,56 +602,23 @@ export type DisplayTransformers<InputDisplay extends ModernDisplay, OutputDispla
|
|
|
603
602
|
products?: (options: DisplayTransformerAlwaysThereData & {
|
|
604
603
|
displays: InputDisplay[];
|
|
605
604
|
}) => CanBePromiseWrapped<OutputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<OutputDisplay>[] : never>;
|
|
606
|
-
categories?: (options: DisplayTransformerAlwaysThereData & {
|
|
607
|
-
data:
|
|
608
|
-
}) => CanBePromiseWrapped<{
|
|
605
|
+
categories?: <T extends Breadcrumb | Quicklink | CategorySuggestion>(options: DisplayTransformerAlwaysThereData & {
|
|
606
|
+
data: T[];
|
|
607
|
+
}) => CanBePromiseWrapped<(T & {
|
|
609
608
|
page_url: string;
|
|
610
|
-
}[]>;
|
|
609
|
+
})[]>;
|
|
611
610
|
contentResults?: (options: DisplayTransformerAlwaysThereData & {
|
|
612
611
|
data: ContentLink[];
|
|
613
612
|
}) => CanBePromiseWrapped<ContentLink[]>;
|
|
614
613
|
};
|
|
615
|
-
export type
|
|
616
|
-
page_url_creator?: PageURLCreator<InputDisplay, OutputDisplay>;
|
|
617
|
-
display_transformers?: never;
|
|
618
|
-
} | {
|
|
619
|
-
page_url_creator?: never;
|
|
614
|
+
export type SomethingTakingADisplayTransformers<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = InputDisplay extends ModernDisplay ? "page_url" extends keyof InputDisplay["variant_displays"][number] ? {
|
|
620
615
|
display_transformers: DisplayTransformers<InputDisplay, OutputDisplay>;
|
|
621
616
|
} : {
|
|
622
|
-
page_url_creator: PageURLCreator<InputDisplay, OutputDisplay>;
|
|
623
|
-
display_transformers?: never;
|
|
624
|
-
} | {
|
|
625
617
|
display_transformers: DisplayTransformers<InputDisplay, OutputDisplay>;
|
|
626
|
-
page_url_creator?: never;
|
|
627
618
|
} : {
|
|
628
619
|
page_url_creator?: never;
|
|
629
620
|
display_transformers?: never;
|
|
630
621
|
};
|
|
631
|
-
type PageURLCreatorAlwaysThereData = {
|
|
632
|
-
merchant: string;
|
|
633
|
-
market: string;
|
|
634
|
-
};
|
|
635
|
-
type PageURLCreatorCategoryData = {
|
|
636
|
-
type: "categories";
|
|
637
|
-
data: (Breadcrumb | Quicklink | CategorySuggestion)[];
|
|
638
|
-
};
|
|
639
|
-
type PageURLCreatorProductData<T extends ModernDisplay> = {
|
|
640
|
-
displays: T[];
|
|
641
|
-
type: "products";
|
|
642
|
-
};
|
|
643
|
-
type PageURLCreatorOptions<InputDisplay extends ModernDisplay> = PageURLCreatorAlwaysThereData & (PageURLCreatorCategoryData | PageURLCreatorProductData<InputDisplay>);
|
|
644
|
-
/**
|
|
645
|
-
* @deprecated use DisplayTransformers instead
|
|
646
|
-
* PageUrlCreator is, in its most basic form, a function that takes in a list of categories or products and returns a list of page_urls for the provided categories or products.
|
|
647
|
-
* It's main use case is to allow for the creation of links to the product or category pages on the merchant's site.
|
|
648
|
-
* It can also be used for the depict customers which already have links to change those links (i.e. for staging sites).
|
|
649
|
-
* Also, it can be used to enrich the data for each product card in a batched way, which is why it can be an async function and return a whole display in the case of products.
|
|
650
|
-
*/
|
|
651
|
-
export type PageURLCreator<InputDisplay extends ModernDisplay, OutputDisplay extends ModernDisplay | never> = (options: PageURLCreatorOptions<InputDisplay>) => (typeof options)["type"] extends "categories" ? CanBePromiseWrapped<{
|
|
652
|
-
page_url: string;
|
|
653
|
-
}[]> : CanBePromiseWrapped<{
|
|
654
|
-
page_url: string;
|
|
655
|
-
}[]> | CanBePromiseWrapped<OutputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<OutputDisplay>[] : never>;
|
|
656
622
|
export type ExclusiveId = {
|
|
657
623
|
categoryId: string;
|
|
658
624
|
productId?: undefined;
|
|
@@ -723,29 +689,29 @@ export type InstantCard<T extends Display> = (display: T, context: {
|
|
|
723
689
|
merchant: string;
|
|
724
690
|
market: string;
|
|
725
691
|
}) => JSX.Element;
|
|
726
|
-
type CategorySuggestionAfterURLCreator =
|
|
692
|
+
type CategorySuggestionAfterURLCreator = CategorySuggestion & {
|
|
727
693
|
page_url: string;
|
|
728
694
|
};
|
|
729
|
-
type ReplaceCategorySuggestion<T> = T extends
|
|
730
|
-
type SearchSuggestionsResponseAfterURLCreator = { [K in keyof
|
|
695
|
+
type ReplaceCategorySuggestion<T> = T extends CategorySuggestion ? CategorySuggestionAfterURLCreator : T extends CategorySuggestion[] ? CategorySuggestionAfterURLCreator[] : T;
|
|
696
|
+
type SearchSuggestionsResponseAfterURLCreator = { [K in keyof SearchSuggestionsResponseV3]: ReplaceCategorySuggestion<SearchSuggestionsResponseV3[K]> };
|
|
731
697
|
type AddPageUrlToDisplay<T extends any[]> = (T[number] & {
|
|
732
698
|
page_url: string;
|
|
733
699
|
})[];
|
|
734
|
-
type
|
|
700
|
+
type SearchResponseAfterDisplayTransformer = { [K in keyof SearchResponse]: K extends "displays" ? AddPageUrlToDisplay<SearchResponse[K]> : K extends "filters" ? AddActualFieldToFilters<SearchResponse[K]> : SearchResponse[K] };
|
|
735
701
|
type QuicklinksOrBreadCrumbsWithPageURL<T extends Breadcrumb | Quicklink> = T & {
|
|
736
702
|
page_url: string;
|
|
737
703
|
};
|
|
738
704
|
type _AddPageUrlToDisplay1<T extends any[]> = (T[number] & {
|
|
739
705
|
page_url: string;
|
|
740
706
|
})[];
|
|
741
|
-
type
|
|
742
|
-
type
|
|
707
|
+
type ProductListingResponseAfterDisplayTransformer = { [K in keyof ProductListingResponseV3]: K extends "displays" ? _AddPageUrlToDisplay1<ProductListingResponseV3[K]> : K extends "filters" ? AddActualFieldToFilters<ProductListingResponseV3[K]> : ProductListingResponseV3[K] };
|
|
708
|
+
type GetListingResponseAfterDisplayTransformer = { [K in keyof GetListingResponse]: K extends "breadcrumbs" ? QuicklinksOrBreadCrumbsWithPageURL<Breadcrumb>[] : K extends "quick_links" ? QuicklinksOrBreadCrumbsWithPageURL<Quicklink>[] : GetListingResponse[K] };
|
|
743
709
|
type DepictAPIConstructorOptions<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = {
|
|
744
710
|
get_metadata?: () => Promise<{
|
|
745
711
|
[k: string]: string;
|
|
746
712
|
} | undefined>;
|
|
747
713
|
get_session_id?: () => string | undefined;
|
|
748
|
-
} &
|
|
714
|
+
} & SomethingTakingADisplayTransformers<InputDisplay, OutputDisplay>;
|
|
749
715
|
interface GetListingOptions extends GetListingRequest {
|
|
750
716
|
listing_id: string;
|
|
751
717
|
session_id?: string;
|
|
@@ -757,21 +723,20 @@ interface GetListingOptions extends GetListingRequest {
|
|
|
757
723
|
*/
|
|
758
724
|
export class DepictAPI<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never = InputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<InputDisplay> : never> {
|
|
759
725
|
#private;
|
|
760
|
-
page_url_creator: PageURLCreator<ModernDisplay, OutputDisplay> | undefined;
|
|
761
726
|
display_transformers: DisplayTransformers<ModernDisplay, OutputDisplay> | undefined;
|
|
762
727
|
constructor(options: DepictAPIConstructorOptions<InputDisplay, OutputDisplay>);
|
|
763
728
|
suggest(input_req: SearchSuggestionsRequestV3): Promise<SearchSuggestionsResponseAfterURLCreator & {
|
|
764
729
|
failed?: true;
|
|
765
730
|
}>;
|
|
766
|
-
query(input_req: SearchRequestV3): Promise<
|
|
731
|
+
query(input_req: SearchRequestV3): Promise<SearchResponseAfterDisplayTransformer & {
|
|
767
732
|
failed?: true;
|
|
768
733
|
}>;
|
|
769
|
-
get_listing(input_req: GetListingOptions): Promise<
|
|
734
|
+
get_listing(input_req: GetListingOptions): Promise<GetListingResponseAfterDisplayTransformer & {
|
|
770
735
|
failed?: true;
|
|
771
736
|
}>;
|
|
772
737
|
get_listing_products(input_req: ProductListingRequestV3 & {
|
|
773
738
|
listing_id: string;
|
|
774
|
-
}): Promise<
|
|
739
|
+
}): Promise<ProductListingResponseAfterDisplayTransformer & {
|
|
775
740
|
failed?: true;
|
|
776
741
|
}>;
|
|
777
742
|
get_recommended<T extends Display>(input_req: BaseSearchRequestV3): Promise<{
|
|
@@ -823,7 +788,7 @@ type CategoryConstructorOptionsWithApi<InputDisplay extends Display, OutputDispl
|
|
|
823
788
|
};
|
|
824
789
|
type CategoryConstructorOptionsWithoutApi<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = GeneralCategoryListingOptions & {
|
|
825
790
|
api?: never;
|
|
826
|
-
} &
|
|
791
|
+
} & SomethingTakingADisplayTransformers<InputDisplay, OutputDisplay>;
|
|
827
792
|
type DepictCategoryConstructorOptions<InputDisplay extends Display, OutputDisplay extends ModernDisplay> = CategoryConstructorOptionsWithApi<InputDisplay, OutputDisplay> | CategoryConstructorOptionsWithoutApi<InputDisplay, OutputDisplay>;
|
|
828
793
|
export class DepictCategory<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never = InputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<InputDisplay> : never> {
|
|
829
794
|
#private;
|
|
@@ -844,7 +809,6 @@ export class DepictCategory<InputDisplay extends Display, OutputDisplay extends
|
|
|
844
809
|
constructor({
|
|
845
810
|
api,
|
|
846
811
|
on_navigation,
|
|
847
|
-
page_url_creator,
|
|
848
812
|
display_transformers,
|
|
849
813
|
unique_instance_key_for_state,
|
|
850
814
|
listing_id_state_key,
|
|
@@ -871,12 +835,12 @@ export function BreadCrumbs<T extends Display>({
|
|
|
871
835
|
depict_category
|
|
872
836
|
}: {
|
|
873
837
|
depict_category: DepictCategory<T>;
|
|
874
|
-
}):
|
|
838
|
+
}): HTMLDivElement;
|
|
875
839
|
export function QuickLinks<T extends Display>({
|
|
876
840
|
depict_category
|
|
877
841
|
}: {
|
|
878
842
|
depict_category: DepictCategory<T>;
|
|
879
|
-
}):
|
|
843
|
+
}): HTMLDivElement;
|
|
880
844
|
/**
|
|
881
845
|
* Gets available listings for a given merchant, market and locale
|
|
882
846
|
*/
|
|
@@ -929,7 +893,7 @@ type ConstructorOptionsWithApi<InputDisplay extends Display, OutputDisplay exten
|
|
|
929
893
|
};
|
|
930
894
|
type ConstructorOptionsWithoutAPI<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = GeneralConstructorOptions<InputDisplay, OutputDisplay> & {
|
|
931
895
|
api?: never;
|
|
932
|
-
} &
|
|
896
|
+
} & SomethingTakingADisplayTransformers<InputDisplay, OutputDisplay>;
|
|
933
897
|
type ConstructorOptions<InputDisplay extends Display, OutputDisplay extends ModernDisplay> = ConstructorOptionsWithApi<InputDisplay, OutputDisplay> | ConstructorOptionsWithoutAPI<InputDisplay, OutputDisplay>;
|
|
934
898
|
export type OpenModalArguments = [options_for_modal?: {
|
|
935
899
|
style_props_?: Signal<JSX.CSSProperties>;
|
|
@@ -947,7 +911,6 @@ export class DepictSearch<InputDisplay extends Display, OutputDisplay extends Mo
|
|
|
947
911
|
url_transformer,
|
|
948
912
|
on_navigation,
|
|
949
913
|
enable_category_suggestions,
|
|
950
|
-
page_url_creator,
|
|
951
914
|
display_transformers,
|
|
952
915
|
api,
|
|
953
916
|
disable_scrolling_during_modal,
|
|
@@ -1024,46 +987,16 @@ export type BaseProviderConfig<InputDisplay extends Display, PossibleTransformed
|
|
|
1024
987
|
*/
|
|
1025
988
|
uniqueInstanceKeyForState?: string;
|
|
1026
989
|
} & (InputDisplay extends ModernDisplay ? "page_url" extends keyof InputDisplay["variant_displays"][number] ? {
|
|
1027
|
-
/**
|
|
1028
|
-
* @deprecated use displayTransformers instead
|
|
1029
|
-
*/
|
|
1030
|
-
pageURLCreator?: PageURLCreator<InputDisplay, PossibleTransformedDisplay>;
|
|
1031
|
-
/**
|
|
1032
|
-
* Functions that take in a list of categories, content search results or products and then can transform or enrich the data for each category, content search result or product card in a batched way.
|
|
1033
|
-
*/
|
|
1034
|
-
displayTransformers?: never;
|
|
1035
|
-
} | {
|
|
1036
|
-
/**
|
|
1037
|
-
* @deprecated use displayTransformers instead
|
|
1038
|
-
*/
|
|
1039
|
-
pageURLCreator?: never;
|
|
1040
990
|
/**
|
|
1041
991
|
* Functions that take in a list of categories, content search results or products and then can transform or enrich the data for each category, content search result or product card in a batched way.
|
|
1042
992
|
*/
|
|
1043
993
|
displayTransformers: DisplayTransformers<InputDisplay, PossibleTransformedDisplay>;
|
|
1044
994
|
} : {
|
|
1045
|
-
/**
|
|
1046
|
-
* @deprecated use displayTransformers instead
|
|
1047
|
-
*/
|
|
1048
|
-
pageURLCreator: PageURLCreator<InputDisplay, PossibleTransformedDisplay>;
|
|
1049
|
-
/**
|
|
1050
|
-
* Functions that take in a list of categories, content search results or products and then can transform or enrich the data for each category, content search result or product card in a batched way.
|
|
1051
|
-
*/
|
|
1052
|
-
displayTransformers?: never;
|
|
1053
|
-
} | {
|
|
1054
995
|
/**
|
|
1055
996
|
* Functions that take in a list of categories, content search results or products and then can transform or enrich the data for each category, content search result or product card in a batched way.
|
|
1056
997
|
*/
|
|
1057
998
|
displayTransformers: DisplayTransformers<InputDisplay, PossibleTransformedDisplay>;
|
|
1058
|
-
/**
|
|
1059
|
-
* @deprecated use displayTransformers instead
|
|
1060
|
-
*/
|
|
1061
|
-
pageURLCreator?: never;
|
|
1062
999
|
} : {
|
|
1063
|
-
/**
|
|
1064
|
-
* @deprecated use displayTransformers instead
|
|
1065
|
-
*/
|
|
1066
|
-
pageURLCreator?: never;
|
|
1067
1000
|
/**
|
|
1068
1001
|
* Functions that take in a list of categories, content search results or products and then can transform or enrich the data for each category, content search result or product card in a batched way.
|
|
1069
1002
|
*/
|
package/server/latest/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { createStore as $i7OB2$createStore, reconcile as $i7OB2$reconcile } from
|
|
|
7
7
|
/*! Depict.ai search and product listing SDK */
|
|
8
8
|
import { register_es_version } from "../../multi_import_deduplicator.mjs";
|
|
9
9
|
register_es_version("ui", "latest");
|
|
10
|
-
const $ec291e0010116877$export$83d89fbfd8236492 = "3.0.
|
|
10
|
+
const $ec291e0010116877$export$83d89fbfd8236492 = "3.0.3";
|
|
11
11
|
const $fbbadcb080ad1d4a$var$_tmpl$ = ["<svg", ' xmlns="http://www.w3.org/2000/svg"', ' viewBox="0 0 14 26"><path d="M2 24.656c-.078 0-.156-.016-.234-.047s-.133-.066-.187-.129c-.117-.117-.176-.258-.176-.422s.059-.305.176-.422l10.371-10.371L1.578 2.883c-.117-.117-.176-.258-.176-.422s.059-.305.176-.422.258-.176.422-.176.305.059.422.176l10.805 10.793a.59.59 0 0 1 .176.434c0 .172-.059.305-.176.422L2.422 24.48a.42.42 0 0 1-.199.129.54.54 0 0 1-.223.047zm0 0" fill="#0f0f0f"></path></svg>'];
|
|
12
12
|
function $fbbadcb080ad1d4a$export$8be2714ec7f169ee(props = {}) {
|
|
13
13
|
return $i7OB2$ssr($fbbadcb080ad1d4a$var$_tmpl$, $i7OB2$ssrHydrationKey(), $i7OB2$ssrAttribute("width", $i7OB2$escape(props.width_, true) ?? 14, false) + $i7OB2$ssrAttribute("height", $i7OB2$escape(props.height_, true) ?? 26, false));
|
|
@@ -4405,100 +4405,54 @@ class $7fa23e2a0079eca4$export$e015ed2f2950f2e3 {
|
|
|
4405
4405
|
};
|
|
4406
4406
|
#get_metadata;
|
|
4407
4407
|
#get_session_id;
|
|
4408
|
-
#guard_url_creator_length(expected, received) {
|
|
4409
|
-
if (expected.length !== received.length) {
|
|
4410
|
-
const e = new Error("displayTransformer returned wrong number of page URLs, got " + received.length + ", expected " + expected.length);
|
|
4411
|
-
queueMicrotask(() => {
|
|
4412
|
-
throw e;
|
|
4413
|
-
});
|
|
4414
|
-
throw e;
|
|
4415
|
-
}
|
|
4416
|
-
}
|
|
4417
4408
|
async #run_url_creator_for_suggest(merchant, market, response) {
|
|
4418
|
-
const page_url_creator = this.page_url_creator;
|
|
4419
4409
|
const category_transformer = this.display_transformers?.categories;
|
|
4420
|
-
if (!
|
|
4410
|
+
if (!category_transformer) return response;
|
|
4421
4411
|
// find category suggestions, run thing with them, and then replace them
|
|
4422
4412
|
const category_suggestions = response.suggestions.filter(suggestion => suggestion.type === "category");
|
|
4423
|
-
const
|
|
4413
|
+
const transformed_category_suggestions = await category_transformer({
|
|
4424
4414
|
market: market,
|
|
4425
4415
|
merchant: merchant,
|
|
4426
|
-
data: [...category_suggestions]
|
|
4427
|
-
...(page_url_creator ? {
|
|
4428
|
-
type: "categories"
|
|
4429
|
-
} : {})
|
|
4416
|
+
data: [...category_suggestions]
|
|
4430
4417
|
});
|
|
4431
|
-
|
|
4432
|
-
while (page_urls.length)
|
|
4433
|
-
// Copy over getters so we sneakily can make this reactive
|
|
4434
|
-
Object.defineProperties(category_suggestions.pop(), Object.getOwnPropertyDescriptors(page_urls.pop()));
|
|
4418
|
+
response.suggestions = transformed_category_suggestions;
|
|
4435
4419
|
return response;
|
|
4436
4420
|
}
|
|
4437
4421
|
async #run_display_transformers_for_rest(merchant, market, input_data) {
|
|
4438
4422
|
const {
|
|
4439
|
-
page_url_creator: page_url_creator,
|
|
4440
4423
|
display_transformers: display_transformers
|
|
4441
4424
|
} = this;
|
|
4442
|
-
if (!
|
|
4425
|
+
if (!display_transformers) return input_data;
|
|
4443
4426
|
const product_transformer = display_transformers?.products;
|
|
4444
4427
|
const category_transformer = display_transformers?.categories;
|
|
4445
4428
|
const content_result_transformer = display_transformers?.contentResults;
|
|
4446
4429
|
const displays = input_data.displays;
|
|
4447
|
-
const owner = $i7OB2$getOwner();
|
|
4448
4430
|
const {
|
|
4449
|
-
breadcrumbs: breadcrumbs,
|
|
4450
|
-
quick_links: quick_links,
|
|
4451
4431
|
content_search_links: content_search_links
|
|
4452
4432
|
} = input_data;
|
|
4453
|
-
if (displays &&
|
|
4454
|
-
const
|
|
4433
|
+
if (displays && product_transformer) {
|
|
4434
|
+
const transformed_displays = await product_transformer({
|
|
4455
4435
|
merchant: merchant,
|
|
4456
4436
|
market: market,
|
|
4457
|
-
displays: [...
|
|
4458
|
-
...(page_url_creator ? {
|
|
4459
|
-
type: "products"
|
|
4460
|
-
} : {})
|
|
4437
|
+
displays: [...displays]
|
|
4461
4438
|
});
|
|
4462
|
-
|
|
4463
|
-
for (let i = 0; i < displays.length; i++) {
|
|
4464
|
-
const new_display_or_page_url = page_urls[i];
|
|
4465
|
-
const old_display = displays[i];
|
|
4466
|
-
if ("page_url" in new_display_or_page_url && Object.keys(new_display_or_page_url).length === 1) {
|
|
4467
|
-
// they only returned page_url, let's put it into the display
|
|
4468
|
-
const old_display_was_modern = ("variant_index" in old_display);
|
|
4469
|
-
if (old_display_was_modern) {
|
|
4470
|
-
const variant_displays = old_display.variant_displays;
|
|
4471
|
-
for (let i = 0; i < variant_displays.length; i++) variant_displays[i].page_url = new_display_or_page_url.page_url;
|
|
4472
|
-
} else old_display.page_url = new_display_or_page_url.page_url;
|
|
4473
|
-
} else
|
|
4474
|
-
// We got a whole new display, let's replace it
|
|
4475
|
-
displays[i] = new_display_or_page_url;
|
|
4476
|
-
}
|
|
4439
|
+
input_data.displays = transformed_displays;
|
|
4477
4440
|
}
|
|
4478
|
-
if (
|
|
4441
|
+
if (category_transformer) for (const key of ["breadcrumbs", "quick_links"]) {
|
|
4442
|
+
const category_display_array = input_data[key];
|
|
4479
4443
|
if (!category_display_array) continue;
|
|
4480
|
-
const
|
|
4481
|
-
merchant: merchant,
|
|
4482
|
-
market: market,
|
|
4483
|
-
data: [...category_display_array],
|
|
4484
|
-
...(page_url_creator ? {
|
|
4485
|
-
type: "categories"
|
|
4486
|
-
} : {})
|
|
4487
|
-
}));
|
|
4488
|
-
this.#guard_url_creator_length(category_display_array, page_urls);
|
|
4489
|
-
for (let i = 0; i < category_display_array.length; i++)
|
|
4490
|
-
// Copy over getters so we sneakily can make this reactive
|
|
4491
|
-
Object.defineProperties(category_display_array[i], Object.getOwnPropertyDescriptors(page_urls[i]));
|
|
4492
|
-
}
|
|
4493
|
-
if (content_search_links?.length && content_result_transformer) {
|
|
4494
|
-
const result = await $i7OB2$runWithOwner(owner, () => content_result_transformer({
|
|
4444
|
+
const transformed_category_displays = await category_transformer({
|
|
4495
4445
|
merchant: merchant,
|
|
4496
4446
|
market: market,
|
|
4497
|
-
data: [...
|
|
4498
|
-
})
|
|
4499
|
-
|
|
4500
|
-
input_data.content_search_links = result;
|
|
4447
|
+
data: [...category_display_array]
|
|
4448
|
+
});
|
|
4449
|
+
input_data[key] = transformed_category_displays;
|
|
4501
4450
|
}
|
|
4451
|
+
if (content_search_links?.length && content_result_transformer) input_data.content_search_links = await content_result_transformer({
|
|
4452
|
+
merchant: merchant,
|
|
4453
|
+
market: market,
|
|
4454
|
+
data: [...content_search_links]
|
|
4455
|
+
});
|
|
4502
4456
|
return input_data;
|
|
4503
4457
|
}
|
|
4504
4458
|
async #cached_request({
|
|
@@ -4510,7 +4464,6 @@ class $7fa23e2a0079eca4$export$e015ed2f2950f2e3 {
|
|
|
4510
4464
|
}) {
|
|
4511
4465
|
const cache_obj = this.#get_cache_obj_for_endpoint(endpoint_);
|
|
4512
4466
|
const with_ids = this.#add_ids_to_request(input_req_);
|
|
4513
|
-
const owner = $i7OB2$getOwner();
|
|
4514
4467
|
const metaData = await this.#get_metadata?.();
|
|
4515
4468
|
const request = metaData ? Object.assign(with_ids, {
|
|
4516
4469
|
metadata: metaData
|
|
@@ -4538,7 +4491,7 @@ class $7fa23e2a0079eca4$export$e015ed2f2950f2e3 {
|
|
|
4538
4491
|
let result;
|
|
4539
4492
|
try {
|
|
4540
4493
|
const unmodified_result = await api_response.json();
|
|
4541
|
-
result = await
|
|
4494
|
+
result = await this.#run_display_transformers_for_rest(input_req_.merchant, input_req_.market, unmodified_result);
|
|
4542
4495
|
} catch (e) {
|
|
4543
4496
|
$i7OB2$dwarn("displayTransformer or json decoding failed", e);
|
|
4544
4497
|
break return_successfully;
|
|
@@ -4569,17 +4522,14 @@ class $7fa23e2a0079eca4$export$e015ed2f2950f2e3 {
|
|
|
4569
4522
|
const {
|
|
4570
4523
|
get_metadata: get_metadata,
|
|
4571
4524
|
get_session_id: get_session_id,
|
|
4572
|
-
page_url_creator: page_url_creator,
|
|
4573
4525
|
display_transformers: display_transformers
|
|
4574
4526
|
} = options ?? {};
|
|
4575
4527
|
this.#get_metadata = get_metadata;
|
|
4576
4528
|
this.#get_session_id = get_session_id;
|
|
4577
|
-
this.page_url_creator = page_url_creator;
|
|
4578
4529
|
this.display_transformers = display_transformers;
|
|
4579
4530
|
}
|
|
4580
4531
|
async suggest(input_req) {
|
|
4581
4532
|
const with_ids = this.#add_ids_to_request(input_req);
|
|
4582
|
-
const owner = $i7OB2$getOwner();
|
|
4583
4533
|
const metaData = await this.#get_metadata?.();
|
|
4584
4534
|
const request = metaData ? Object.assign(with_ids, {
|
|
4585
4535
|
metadata: JSON.stringify(metaData)
|
|
@@ -4591,7 +4541,7 @@ class $7fa23e2a0079eca4$export$e015ed2f2950f2e3 {
|
|
|
4591
4541
|
const decoded_json = await results.json();
|
|
4592
4542
|
if (!Array.isArray(decoded_json?.suggestions)) break attempt_to_return_api_response;
|
|
4593
4543
|
try {
|
|
4594
|
-
return await
|
|
4544
|
+
return await this.#run_url_creator_for_suggest(input_req.merchant, input_req.market, decoded_json);
|
|
4595
4545
|
} catch (e) {
|
|
4596
4546
|
$i7OB2$dwarn("displayTransformer failed", e);
|
|
4597
4547
|
}
|
|
@@ -7258,7 +7208,6 @@ class $961b5c64bef4662f$export$f34314aa9505732e {
|
|
|
7258
7208
|
constructor({
|
|
7259
7209
|
api: api,
|
|
7260
7210
|
on_navigation: on_navigation,
|
|
7261
|
-
page_url_creator: page_url_creator,
|
|
7262
7211
|
display_transformers: display_transformers,
|
|
7263
7212
|
unique_instance_key_for_state = "",
|
|
7264
7213
|
listing_id_state_key: listing_id_state_key,
|
|
@@ -7309,7 +7258,6 @@ class $961b5c64bef4662f$export$f34314aa9505732e {
|
|
|
7309
7258
|
reset_history_state_: reset_history_state_,
|
|
7310
7259
|
// @ts-ignore
|
|
7311
7260
|
depict_api_: api ?? new (0, $7fa23e2a0079eca4$export$e015ed2f2950f2e3)({
|
|
7312
|
-
page_url_creator: page_url_creator,
|
|
7313
7261
|
display_transformers: display_transformers
|
|
7314
7262
|
}),
|
|
7315
7263
|
router_: this.#router,
|
|
@@ -7621,12 +7569,13 @@ function $897bd4a76f611b38$export$d757d54550ebfb3d({
|
|
|
7621
7569
|
category_suggestion_: category_suggestion_,
|
|
7622
7570
|
router_: router_
|
|
7623
7571
|
}) {
|
|
7572
|
+
const parentTitle = $i7OB2$createMemo(() => category_suggestion_().breadcrumbs.at(-1)?.title);
|
|
7624
7573
|
return $i7OB2$ssr($897bd4a76f611b38$var$_tmpl$2, $i7OB2$ssrHydrationKey(), $i7OB2$ssrAttribute("href", $i7OB2$escape(category_suggestion_().page_url, true), false), $i7OB2$escape(category_suggestion_().title), $i7OB2$escape($i7OB2$createComponent((0, $i7OB2$Show), {
|
|
7625
7574
|
get when() {
|
|
7626
|
-
return
|
|
7575
|
+
return parentTitle();
|
|
7627
7576
|
},
|
|
7628
7577
|
get children() {
|
|
7629
|
-
return $i7OB2$ssr($897bd4a76f611b38$var$_tmpl$, $i7OB2$ssrHydrationKey(), $i7OB2$escape(
|
|
7578
|
+
return $i7OB2$ssr($897bd4a76f611b38$var$_tmpl$, $i7OB2$ssrHydrationKey(), $i7OB2$escape(parentTitle()));
|
|
7630
7579
|
}
|
|
7631
7580
|
})));
|
|
7632
7581
|
}
|
|
@@ -8170,6 +8119,11 @@ function $cea52f6b24092f05$export$e872e2339fb04a7f({
|
|
|
8170
8119
|
}) : undefined);
|
|
8171
8120
|
const href = $i7OB2$createMemo(() => is_query() ? href_with_changed_params_accessor()() : input_obj().page_url);
|
|
8172
8121
|
const is_selected = $i7OB2$createMemo(() => read_selected_index_()?.[0] === autocomplete_data_index && read_selected_index_()?.[1] === index);
|
|
8122
|
+
const parent_title_if_exists = $i7OB2$createMemo(() => {
|
|
8123
|
+
const item = input_obj();
|
|
8124
|
+
if (!("breadcrumbs" in item)) return;
|
|
8125
|
+
return item.breadcrumbs.at(-1)?.title;
|
|
8126
|
+
});
|
|
8173
8127
|
return $i7OB2$ssr($cea52f6b24092f05$var$_tmpl$, $i7OB2$ssrHydrationKey(), `suggestion ${is_selected() ? "selected" : ""} ${is_history ? "history" : ""} ${$i7OB2$escape($i7OB2$escape("type-" + input_obj().type, true), true)}`, $i7OB2$ssrAttribute("href", $i7OB2$escape(href(), true), false), is_query() ? $i7OB2$escape([$i7OB2$createComponent((0, $i7OB2$Show), {
|
|
8174
8128
|
when: is_history,
|
|
8175
8129
|
get fallback() {
|
|
@@ -8184,13 +8138,13 @@ function $cea52f6b24092f05$export$e872e2339fb04a7f({
|
|
|
8184
8138
|
return $i7OB2$createMemo(() => input_obj().title);
|
|
8185
8139
|
},
|
|
8186
8140
|
searching_for_value_: searching_for_value_
|
|
8187
|
-
})]) : $i7OB2$escape([
|
|
8141
|
+
})]) : $i7OB2$escape([parent_title_if_exists() ? $i7OB2$ssr($cea52f6b24092f05$var$_tmpl$4, $i7OB2$ssrHydrationKey(), $i7OB2$escape($i7OB2$createComponent((0, $f3213c0640246d58$export$ba17c5b7e6dda39f), {
|
|
8188
8142
|
class_: "category line-clamp",
|
|
8189
8143
|
get whole_text_to_display_() {
|
|
8190
8144
|
return $i7OB2$createMemo(() => input_obj().title);
|
|
8191
8145
|
},
|
|
8192
8146
|
searching_for_value_: searching_for_value_
|
|
8193
|
-
})), $i7OB2$escape(
|
|
8147
|
+
})), $i7OB2$escape(parent_title_if_exists())) : input_obj().type === "content" ? $i7OB2$ssr($cea52f6b24092f05$var$_tmpl$5, $i7OB2$ssrHydrationKey(), $i7OB2$escape($i7OB2$createComponent((0, $190927650b4840eb$export$605674723bcc715c), {
|
|
8194
8148
|
width: "16",
|
|
8195
8149
|
height: "16"
|
|
8196
8150
|
})), $i7OB2$escape($i7OB2$createComponent((0, $f3213c0640246d58$export$ba17c5b7e6dda39f), {
|
|
@@ -8207,7 +8161,7 @@ function $cea52f6b24092f05$export$e872e2339fb04a7f({
|
|
|
8207
8161
|
searching_for_value_: searching_for_value_
|
|
8208
8162
|
}), $i7OB2$ssr($cea52f6b24092f05$var$_tmpl$3, $i7OB2$ssrHydrationKey(), $i7OB2$escape($i7OB2$createMemo(() => {
|
|
8209
8163
|
if (input_obj().type === "content") return i18n_.content_();
|
|
8210
|
-
if (input_obj().category_type === "
|
|
8164
|
+
if (input_obj().category_type === "brand") return i18n_.brand_();
|
|
8211
8165
|
return i18n_.category_();
|
|
8212
8166
|
})()))]));
|
|
8213
8167
|
};
|
|
@@ -9579,7 +9533,6 @@ class $806c97b931758897$export$ac6237957a15b3f0 {
|
|
|
9579
9533
|
url_transformer: url_transformer,
|
|
9580
9534
|
on_navigation: on_navigation,
|
|
9581
9535
|
enable_category_suggestions = true,
|
|
9582
|
-
page_url_creator: page_url_creator,
|
|
9583
9536
|
display_transformers: display_transformers,
|
|
9584
9537
|
api: api,
|
|
9585
9538
|
// Stuff needed for non-standard customer deployments that we shouldn't actually expose
|
|
@@ -9631,7 +9584,6 @@ class $806c97b931758897$export$ac6237957a15b3f0 {
|
|
|
9631
9584
|
});
|
|
9632
9585
|
// @ts-ignore
|
|
9633
9586
|
const depict_api_ = api ?? new (0, $7fa23e2a0079eca4$export$e015ed2f2950f2e3)({
|
|
9634
|
-
page_url_creator: page_url_creator,
|
|
9635
9587
|
display_transformers: display_transformers
|
|
9636
9588
|
});
|
|
9637
9589
|
const previous_searches = $21f51c14cb3f586f$export$84bba84a7b837187(get_search_query_);
|