@depict-ai/ui 3.0.2 → 3.0.4
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 +147 -136
- package/ES10/index.d.ts +214 -205
- package/ES10/index.js +149 -138
- package/latest/index.cjs +120 -98
- package/latest/index.d.ts +214 -205
- package/latest/index.js +122 -100
- package/package.json +4 -4
- package/server/ES10/index.cjs +122 -111
- package/server/ES10/index.d.ts +214 -205
- package/server/ES10/index.js +124 -113
- package/server/latest/index.cjs +109 -93
- package/server/latest/index.d.ts +214 -205
- package/server/latest/index.js +111 -95
- package/locales/require.js +0 -1152
package/server/latest/index.d.ts
CHANGED
|
@@ -1,17 +1,193 @@
|
|
|
1
|
+
import { ColsAtSize, Display, ModernDisplay, Amazing_Slider, Node_Array, report, Elem } from "@depict-ai/utilishared/latest";
|
|
1
2
|
import { JSX, Signal, Accessor, Setter } from "solid-js";
|
|
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
|
-
import { SearchFilter as _SearchFilter1,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { LegacyCategorySuggestion, SearchSuggestionsResponse } from "@depict-ai/types/api/SearchSuggestionsResponse";
|
|
4
|
+
import { ContentLink, SearchFilter as _SearchFilter1, SearchResponse } from "@depict-ai/types/api/SearchResponse";
|
|
5
|
+
import { ListingSuggestion, SearchSuggestionsResponseV3 } from "@depict-ai/types/api/SearchSuggestionsResponseV3";
|
|
6
|
+
import { ProductListing, GetListingResponse } from "@depict-ai/types/api/GetListingResponse";
|
|
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.4";
|
|
14
|
+
export type SDKColsAtSize = [number, number?][];
|
|
15
|
+
/**
|
|
16
|
+
* Transform SDK ColsAtSize into valid Layout ColsAtSize
|
|
17
|
+
* @param cols_at_size [nbCol, maxWidth]
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
export const convert_sdk_cols_at_size_to_layout: (cols_at_size: SDKColsAtSize) => ColsAtSize;
|
|
21
|
+
declare const LISTING_ID = "listingId";
|
|
22
|
+
declare const EXTERNAL_ID = "externalId";
|
|
23
|
+
export type SDKGridSpacing = string | {
|
|
24
|
+
horizontal: string;
|
|
25
|
+
vertical: string;
|
|
26
|
+
};
|
|
27
|
+
export type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
|
|
28
|
+
type FilterWithData = WithRequired<SearchFilter, "data">;
|
|
29
|
+
export interface SDKRenderingInfo {
|
|
30
|
+
/**
|
|
31
|
+
* If you call this function with a provided function, the provided function will be called whenever the index of the currently displayed product changes.
|
|
32
|
+
*/
|
|
33
|
+
set_on_index_change: (fn: (index: number) => void) => void;
|
|
34
|
+
}
|
|
35
|
+
export type ProductCardTemplate<T extends Display> = (display: T | null, info?: SDKRenderingInfo) => JSX.Element | Promise<JSX.Element>;
|
|
36
|
+
type AddActualFieldToArray<T> = T extends Array<infer U> ? (U & {
|
|
37
|
+
actual_field?: string;
|
|
38
|
+
})[] : never;
|
|
39
|
+
type AddActualFieldToFilters<T extends SearchFilter[] | undefined> = T extends undefined ? undefined : AddActualFieldToArray<T>;
|
|
40
|
+
type DisplayTransformerAlwaysThereData = {
|
|
41
|
+
merchant: string;
|
|
42
|
+
market: string;
|
|
43
|
+
};
|
|
44
|
+
type CanBePromiseWrapped<T> = T | Promise<T>;
|
|
45
|
+
export type ModernDisplayWithPageUrl<T extends ModernDisplay> = { [K in keyof T]: K extends "variant_displays" ? (T[K][number] & {
|
|
46
|
+
page_url: string;
|
|
47
|
+
})[] : T[K] };
|
|
48
|
+
/**
|
|
49
|
+
* DisplayTransformers supersede pageURLCreator
|
|
50
|
+
* DisplayTransformers are 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.
|
|
51
|
+
*/
|
|
52
|
+
export type DisplayTransformers<InputDisplay extends ModernDisplay, OutputDisplay extends ModernDisplay | never> = {
|
|
53
|
+
products?: (options: DisplayTransformerAlwaysThereData & {
|
|
54
|
+
displays: InputDisplay[];
|
|
55
|
+
}) => CanBePromiseWrapped<OutputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<OutputDisplay>[] : never>;
|
|
56
|
+
categories?: <T extends ProductListing | ListingSuggestion>(options: DisplayTransformerAlwaysThereData & {
|
|
57
|
+
data: T[];
|
|
58
|
+
}) => CanBePromiseWrapped<(T & {
|
|
59
|
+
page_url: string;
|
|
60
|
+
})[]>;
|
|
61
|
+
contentResults?: (options: DisplayTransformerAlwaysThereData & {
|
|
62
|
+
data: ContentLink[];
|
|
63
|
+
}) => CanBePromiseWrapped<ContentLink[]>;
|
|
64
|
+
};
|
|
65
|
+
export type SomethingTakingADisplayTransformers<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = InputDisplay extends ModernDisplay ? "page_url" extends keyof InputDisplay["variant_displays"][number] ? {
|
|
66
|
+
display_transformers: DisplayTransformers<InputDisplay, OutputDisplay>;
|
|
67
|
+
} : {
|
|
68
|
+
display_transformers: DisplayTransformers<InputDisplay, OutputDisplay>;
|
|
69
|
+
} : {
|
|
70
|
+
page_url_creator?: never;
|
|
71
|
+
display_transformers?: never;
|
|
72
|
+
};
|
|
73
|
+
export type BaseProviderConfig<InputDisplay extends Display, PossibleTransformedDisplay extends ModernDisplay | never> = {
|
|
74
|
+
/**
|
|
75
|
+
* The merchant to use for the search.
|
|
76
|
+
* @example "YOUR_MERCHANT", "stronger"
|
|
77
|
+
*/
|
|
78
|
+
merchant: string;
|
|
79
|
+
/**
|
|
80
|
+
* The market to use for the search.
|
|
81
|
+
* @example "YOUR_MARKET", "no", "en-de"
|
|
82
|
+
*/
|
|
83
|
+
market: string;
|
|
84
|
+
/**
|
|
85
|
+
* Optional unique identifer of the user. Only necessary when performing server side requests to Depict. All Depict tooling has a fallback ID that will be used when this isn't specified, but if you make requests to Depict directly, you need to specify this everywhere.
|
|
86
|
+
*/
|
|
87
|
+
sessionId?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Custom metadata to be sent with each request to the Depict API. Only necessary if specifically instructed by Depict.
|
|
90
|
+
*/
|
|
91
|
+
metaData?: Record<string, string>;
|
|
92
|
+
/**
|
|
93
|
+
* You can't have more than one instance of the same provider on the same page, unless you specify a unique instance key for each one.
|
|
94
|
+
* This is because there's state in the URL and history.state and the state of the different instances would collide.
|
|
95
|
+
* By setting this property, you can specify a unique key for each instance, so that the state of each instance is kept separate.
|
|
96
|
+
* We recommend to just use an incrementing number for this, e.g. "1", "2", "3", ...
|
|
97
|
+
*/
|
|
98
|
+
uniqueInstanceKeyForState?: string;
|
|
99
|
+
} & (InputDisplay extends ModernDisplay ? "page_url" extends keyof InputDisplay["variant_displays"][number] ? {
|
|
100
|
+
/**
|
|
101
|
+
* 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.
|
|
102
|
+
*/
|
|
103
|
+
displayTransformers: DisplayTransformers<InputDisplay, PossibleTransformedDisplay>;
|
|
104
|
+
} : {
|
|
105
|
+
/**
|
|
106
|
+
* 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.
|
|
107
|
+
*/
|
|
108
|
+
displayTransformers: DisplayTransformers<InputDisplay, PossibleTransformedDisplay>;
|
|
109
|
+
} : {
|
|
110
|
+
/**
|
|
111
|
+
* 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.
|
|
112
|
+
*/
|
|
113
|
+
displayTransformers?: never;
|
|
114
|
+
});
|
|
115
|
+
export type BaseSearchProviderConfig = {
|
|
116
|
+
/**
|
|
117
|
+
* The path to the search page.
|
|
118
|
+
* @example "/search", "/sok"
|
|
119
|
+
*/
|
|
120
|
+
searchPagePath: string;
|
|
121
|
+
/**
|
|
122
|
+
* The name of the url parameter that will be used for the search query.
|
|
123
|
+
* @example "q", "search_query", "query"
|
|
124
|
+
* @default "query"
|
|
125
|
+
*/
|
|
126
|
+
urlParamName?: string;
|
|
127
|
+
/**
|
|
128
|
+
* Whether to enable category suggestions in the search modal and search page.
|
|
129
|
+
* @default false
|
|
130
|
+
*/
|
|
131
|
+
enableCategorySuggestions?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Whether to enable content search in the search modal and search page.
|
|
134
|
+
* @default false
|
|
135
|
+
*/
|
|
136
|
+
enableContentSearch?: boolean;
|
|
137
|
+
};
|
|
138
|
+
export type BaseCategoryProviderConfig = {
|
|
139
|
+
/**
|
|
140
|
+
* The parameter `listing_id=` will override the regular category id that you have configured your SDK to use. You can consider the `listing_id` as an escape-hatch if you want to easily set a listing id.
|
|
141
|
+
* However, if your page already sets a listing_id, you can disable this behaviour by setting this property to `true` (to avoid a conflict).
|
|
142
|
+
*/
|
|
143
|
+
disableOverrideListingId?: boolean;
|
|
144
|
+
};
|
|
145
|
+
export interface BaseProductListingConfig {
|
|
146
|
+
/**
|
|
147
|
+
* How many columns to show at each media size.
|
|
148
|
+
* @default
|
|
149
|
+
* [[2, 901], [3, 1024], [4]]
|
|
150
|
+
* @example
|
|
151
|
+
* [[2, 901], [3, 1024], [4]]
|
|
152
|
+
* means 2 columns at sizes up to 901px, 3 columns at sizes up to 1024px and after that 4 columns at any viewport size.
|
|
153
|
+
*/
|
|
154
|
+
columnsAtSize?: SDKColsAtSize;
|
|
155
|
+
/**
|
|
156
|
+
* The spacing between products.
|
|
157
|
+
* @default "2%"
|
|
158
|
+
* @example
|
|
159
|
+
* "2%", "10px", "1rem", {horizontal: "1%", vertical: "5px"}
|
|
160
|
+
*/
|
|
161
|
+
gridSpacing?: SDKGridSpacing;
|
|
162
|
+
}
|
|
163
|
+
export interface BaseSearchPageConfig extends BaseProductListingConfig {
|
|
164
|
+
/**
|
|
165
|
+
* Whether to show the search input field in the search page.
|
|
166
|
+
* @default true
|
|
167
|
+
*/
|
|
168
|
+
includeInputField?: boolean;
|
|
169
|
+
}
|
|
170
|
+
export interface BaseCategoryPageConfig extends BaseProductListingConfig {
|
|
171
|
+
/**
|
|
172
|
+
* Whether to show the breadcrumbs in the category page.
|
|
173
|
+
* @default true
|
|
174
|
+
*/
|
|
175
|
+
showBreadcrumbs?: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Whether to show the quicklinks in the category page.
|
|
178
|
+
* @default true
|
|
179
|
+
*/
|
|
180
|
+
showQuicklinks?: boolean;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* The listing to query Depict for. `type` can be `"listingId"` or `"externalId"` and `id` is the actual id.
|
|
184
|
+
* If `id` is `"listingId"`, it should be a uuid where Depict is the source of truth, you can get them here: https://api.depict.ai/docs#tag/Listing/operation/Get_Listings_v3_listings_get.
|
|
185
|
+
* If `id` is `"externalId"`, it should be the id of the product listing in your system - whatever was passed to Depict during data ingestion.
|
|
186
|
+
*/
|
|
187
|
+
export type ListingQuery = {
|
|
188
|
+
type: typeof LISTING_ID | typeof EXTERNAL_ID;
|
|
189
|
+
id: string;
|
|
190
|
+
};
|
|
15
191
|
/** @jsxImportSource solid-js */
|
|
16
192
|
export function GenericSliderArrowButton(props?: {
|
|
17
193
|
width_?: number;
|
|
@@ -98,7 +274,7 @@ declare class PseudoRouter {
|
|
|
98
274
|
/**
|
|
99
275
|
* We store listing_id in history.state and do operate on this both here and in js-ui, this is the key to be used which js-ui provides
|
|
100
276
|
*/
|
|
101
|
-
|
|
277
|
+
listing_query_state_key: string | undefined;
|
|
102
278
|
navigate_: {
|
|
103
279
|
/**
|
|
104
280
|
* Call this if you *just* want to replace the state object in history.state
|
|
@@ -119,11 +295,11 @@ declare class PseudoRouter {
|
|
|
119
295
|
event_?: MouseEvent | undefined;
|
|
120
296
|
force_spa_navigation_?: boolean | undefined;
|
|
121
297
|
is_replace_: boolean;
|
|
122
|
-
|
|
298
|
+
listing_query_?: ListingQuery | undefined;
|
|
123
299
|
scroll?: boolean | undefined;
|
|
124
300
|
}) => Promise<void | undefined>;
|
|
125
301
|
};
|
|
126
|
-
constructor(on_navigation: OnNavigation,
|
|
302
|
+
constructor(on_navigation: OnNavigation, listing_query_state_key?: string);
|
|
127
303
|
}
|
|
128
304
|
/**
|
|
129
305
|
* Makes signals out of values in history.state so that you can use history state as an intuitive storage of application state.
|
|
@@ -132,23 +308,6 @@ declare class PseudoRouter {
|
|
|
132
308
|
* @returns An object with the same keys as provided with the value being a Signal containing the default value. When the signal is set, history.replaceState is called and the key/value is put into history.state. If something else pushes a new state or the state is poped the signal value will update to always be in-line with the value of history.state.
|
|
133
309
|
*/
|
|
134
310
|
export function history_dot_state_to_state<Param extends string, DefaultValue>(params_to_default_value: Record<Param, DefaultValue>, router_: PseudoRouter): Record<Param, Signal<any>>;
|
|
135
|
-
export type SDKGridSpacing = string | {
|
|
136
|
-
horizontal: string;
|
|
137
|
-
vertical: string;
|
|
138
|
-
};
|
|
139
|
-
export type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
|
|
140
|
-
type FilterWithData = WithRequired<SearchFilter, "data">;
|
|
141
|
-
export interface SDKRenderingInfo {
|
|
142
|
-
/**
|
|
143
|
-
* If you call this function with a provided function, the provided function will be called whenever the index of the currently displayed product changes.
|
|
144
|
-
*/
|
|
145
|
-
set_on_index_change: (fn: (index: number) => void) => void;
|
|
146
|
-
}
|
|
147
|
-
export type ProductCardTemplate<T extends Display> = (display: T | null, info?: SDKRenderingInfo) => JSX.Element | Promise<JSX.Element>;
|
|
148
|
-
type AddActualFieldToArray<T> = T extends Array<infer U> ? (U & {
|
|
149
|
-
actual_field?: string;
|
|
150
|
-
})[] : never;
|
|
151
|
-
type AddActualFieldToFilters<T extends SearchFilter[] | undefined> = T extends undefined ? undefined : AddActualFieldToArray<T>;
|
|
152
311
|
/**
|
|
153
312
|
* Disables scrolling until the solidjs reactive scoped is disposed (onCleanup)
|
|
154
313
|
* @returns A cleanup function to manually re-enable scrolling.
|
|
@@ -194,13 +353,6 @@ type ImagePlaceholderImageOptions = {
|
|
|
194
353
|
* @property style extra styles to add to the placeholder
|
|
195
354
|
*/
|
|
196
355
|
export function ImagePlaceholder(props: ImagePlaceholderBaseOptions & (ImagePlaceholderBlockOptions | ImagePlaceholderImageOptions)): JSX.Element;
|
|
197
|
-
export type SDKColsAtSize = [number, number?][];
|
|
198
|
-
/**
|
|
199
|
-
* Transform SDK ColsAtSize into valid Layout ColsAtSize
|
|
200
|
-
* @param cols_at_size [nbCol, maxWidth]
|
|
201
|
-
* @returns
|
|
202
|
-
*/
|
|
203
|
-
export const convert_sdk_cols_at_size_to_layout: (cols_at_size: SDKColsAtSize) => ColsAtSize;
|
|
204
356
|
/**
|
|
205
357
|
* A Placeholder to use instead of some text, while it's loading. This is the inline version, meant to be embedded into sentences (or exist instead of them), etc.
|
|
206
358
|
* If you want a block version, use `ImagePlaceholder` with `width`and `height` set instead.
|
|
@@ -587,39 +739,6 @@ export function create_modified_filters({
|
|
|
587
739
|
}[]>;
|
|
588
740
|
local_filter_cache_: Signal<_SearchFilter1[]>;
|
|
589
741
|
}): void;
|
|
590
|
-
type DisplayTransformerAlwaysThereData = {
|
|
591
|
-
merchant: string;
|
|
592
|
-
market: string;
|
|
593
|
-
};
|
|
594
|
-
type CanBePromiseWrapped<T> = T | Promise<T>;
|
|
595
|
-
export type ModernDisplayWithPageUrl<T extends ModernDisplay> = { [K in keyof T]: K extends "variant_displays" ? (T[K][number] & {
|
|
596
|
-
page_url: string;
|
|
597
|
-
})[] : T[K] };
|
|
598
|
-
/**
|
|
599
|
-
* DisplayTransformers supersede pageURLCreator
|
|
600
|
-
* DisplayTransformers are 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.
|
|
601
|
-
*/
|
|
602
|
-
export type DisplayTransformers<InputDisplay extends ModernDisplay, OutputDisplay extends ModernDisplay | never> = {
|
|
603
|
-
products?: (options: DisplayTransformerAlwaysThereData & {
|
|
604
|
-
displays: InputDisplay[];
|
|
605
|
-
}) => CanBePromiseWrapped<OutputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<OutputDisplay>[] : never>;
|
|
606
|
-
categories?: <T extends Breadcrumb | Quicklink | CategorySuggestion>(options: DisplayTransformerAlwaysThereData & {
|
|
607
|
-
data: T[];
|
|
608
|
-
}) => CanBePromiseWrapped<(T & {
|
|
609
|
-
page_url: string;
|
|
610
|
-
})[]>;
|
|
611
|
-
contentResults?: (options: DisplayTransformerAlwaysThereData & {
|
|
612
|
-
data: ContentLink[];
|
|
613
|
-
}) => CanBePromiseWrapped<ContentLink[]>;
|
|
614
|
-
};
|
|
615
|
-
export type SomethingTakingADisplayTransformers<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = InputDisplay extends ModernDisplay ? "page_url" extends keyof InputDisplay["variant_displays"][number] ? {
|
|
616
|
-
display_transformers: DisplayTransformers<InputDisplay, OutputDisplay>;
|
|
617
|
-
} : {
|
|
618
|
-
display_transformers: DisplayTransformers<InputDisplay, OutputDisplay>;
|
|
619
|
-
} : {
|
|
620
|
-
page_url_creator?: never;
|
|
621
|
-
display_transformers?: never;
|
|
622
|
-
};
|
|
623
742
|
export type ExclusiveId = {
|
|
624
743
|
categoryId: string;
|
|
625
744
|
productId?: undefined;
|
|
@@ -690,33 +809,33 @@ export type InstantCard<T extends Display> = (display: T, context: {
|
|
|
690
809
|
merchant: string;
|
|
691
810
|
market: string;
|
|
692
811
|
}) => JSX.Element;
|
|
693
|
-
type CategorySuggestionAfterURLCreator =
|
|
812
|
+
type CategorySuggestionAfterURLCreator = ListingSuggestion & {
|
|
694
813
|
page_url: string;
|
|
695
814
|
};
|
|
696
|
-
type ReplaceCategorySuggestion<T> = T extends
|
|
697
|
-
type SearchSuggestionsResponseAfterURLCreator = { [K in keyof
|
|
815
|
+
type ReplaceCategorySuggestion<T> = T extends ListingSuggestion ? CategorySuggestionAfterURLCreator : T extends ListingSuggestion[] ? CategorySuggestionAfterURLCreator[] : T;
|
|
816
|
+
type SearchSuggestionsResponseAfterURLCreator = { [K in keyof SearchSuggestionsResponseV3]: ReplaceCategorySuggestion<SearchSuggestionsResponseV3[K]> };
|
|
698
817
|
type AddPageUrlToDisplay<T extends any[]> = (T[number] & {
|
|
699
818
|
page_url: string;
|
|
700
819
|
})[];
|
|
701
820
|
type SearchResponseAfterDisplayTransformer = { [K in keyof SearchResponse]: K extends "displays" ? AddPageUrlToDisplay<SearchResponse[K]> : K extends "filters" ? AddActualFieldToFilters<SearchResponse[K]> : SearchResponse[K] };
|
|
702
|
-
type
|
|
821
|
+
type ProductListingWithPageURL = ProductListing & {
|
|
703
822
|
page_url: string;
|
|
704
823
|
};
|
|
705
824
|
type _AddPageUrlToDisplay1<T extends any[]> = (T[number] & {
|
|
706
825
|
page_url: string;
|
|
707
826
|
})[];
|
|
708
827
|
type ProductListingResponseAfterDisplayTransformer = { [K in keyof ProductListingResponseV3]: K extends "displays" ? _AddPageUrlToDisplay1<ProductListingResponseV3[K]> : K extends "filters" ? AddActualFieldToFilters<ProductListingResponseV3[K]> : ProductListingResponseV3[K] };
|
|
709
|
-
type GetListingResponseAfterDisplayTransformer = { [K in keyof GetListingResponse]: K extends "breadcrumbs" ?
|
|
828
|
+
type GetListingResponseAfterDisplayTransformer = { [K in keyof GetListingResponse]: K extends "breadcrumbs" ? ProductListingWithPageURL[] : K extends "quick_links" ? ProductListingWithPageURL[] : GetListingResponse[K] };
|
|
710
829
|
type DepictAPIConstructorOptions<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = {
|
|
711
830
|
get_metadata?: () => Promise<{
|
|
712
831
|
[k: string]: string;
|
|
713
832
|
} | undefined>;
|
|
714
833
|
get_session_id?: () => string | undefined;
|
|
715
834
|
} & SomethingTakingADisplayTransformers<InputDisplay, OutputDisplay>;
|
|
716
|
-
interface GetListingOptions extends GetListingRequest {
|
|
717
|
-
listing_id: string;
|
|
835
|
+
interface GetListingOptions extends Omit<GetListingRequest, "listing_id"> {
|
|
718
836
|
session_id?: string;
|
|
719
|
-
|
|
837
|
+
id_to_query_for_: string;
|
|
838
|
+
id_type_: typeof LISTING_ID | typeof EXTERNAL_ID;
|
|
720
839
|
}
|
|
721
840
|
/**
|
|
722
841
|
* Class that handles all communication done in PLP code with the Depict API. (Notably not for recommendations currently).
|
|
@@ -732,11 +851,20 @@ export class DepictAPI<InputDisplay extends Display, OutputDisplay extends Moder
|
|
|
732
851
|
query(input_req: SearchRequestV3): Promise<SearchResponseAfterDisplayTransformer & {
|
|
733
852
|
failed?: true;
|
|
734
853
|
}>;
|
|
735
|
-
get_listing(
|
|
854
|
+
get_listing({
|
|
855
|
+
id_type_,
|
|
856
|
+
id_to_query_for_,
|
|
857
|
+
...input_req
|
|
858
|
+
}: GetListingOptions): Promise<GetListingResponseAfterDisplayTransformer & {
|
|
736
859
|
failed?: true;
|
|
737
860
|
}>;
|
|
738
|
-
get_listing_products(
|
|
739
|
-
|
|
861
|
+
get_listing_products({
|
|
862
|
+
id_to_query_for_,
|
|
863
|
+
id_type_,
|
|
864
|
+
...input_req_
|
|
865
|
+
}: ProductListingRequestV3 & {
|
|
866
|
+
id_to_query_for_: string;
|
|
867
|
+
id_type_: typeof LISTING_ID | typeof EXTERNAL_ID;
|
|
740
868
|
}): Promise<ProductListingResponseAfterDisplayTransformer & {
|
|
741
869
|
failed?: true;
|
|
742
870
|
}>;
|
|
@@ -779,7 +907,7 @@ type GeneralCategoryListingOptions = {
|
|
|
779
907
|
localization: category_i18n;
|
|
780
908
|
unique_instance_key_for_state?: string;
|
|
781
909
|
on_navigation?: OnNavigation;
|
|
782
|
-
|
|
910
|
+
listing_query_state_key?: string;
|
|
783
911
|
};
|
|
784
912
|
type CategoryConstructorOptionsWithApi<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = GeneralCategoryListingOptions & {
|
|
785
913
|
api: DepictAPI<InputDisplay, OutputDisplay>;
|
|
@@ -795,14 +923,12 @@ export class DepictCategory<InputDisplay extends Display, OutputDisplay extends
|
|
|
795
923
|
#private;
|
|
796
924
|
get localization(): category_i18n;
|
|
797
925
|
set localization(locale_obj: category_i18n);
|
|
798
|
-
get
|
|
799
|
-
set
|
|
926
|
+
get listing_query(): ListingQuery;
|
|
927
|
+
set listing_query(query: ListingQuery);
|
|
800
928
|
get merchant(): string;
|
|
801
929
|
set merchant(merchant: string);
|
|
802
930
|
get market(): string;
|
|
803
931
|
set market(market: string);
|
|
804
|
-
get meta_title_suffix(): string | undefined;
|
|
805
|
-
set meta_title_suffix(new_suffix: string | undefined);
|
|
806
932
|
get disable_override_listing_id(): boolean | undefined;
|
|
807
933
|
set disable_override_listing_id(new_value: boolean | undefined);
|
|
808
934
|
get on_navigation(): OnNavigation;
|
|
@@ -812,7 +938,7 @@ export class DepictCategory<InputDisplay extends Display, OutputDisplay extends
|
|
|
812
938
|
on_navigation,
|
|
813
939
|
display_transformers,
|
|
814
940
|
unique_instance_key_for_state,
|
|
815
|
-
|
|
941
|
+
listing_query_state_key,
|
|
816
942
|
...props_on_class
|
|
817
943
|
}: DepictCategoryConstructorOptions<InputDisplay, OutputDisplay>);
|
|
818
944
|
}
|
|
@@ -829,23 +955,23 @@ export function CategoryPage<OriginalDisplay extends Display, OutputDisplay exte
|
|
|
829
955
|
show_quicklinks?: boolean;
|
|
830
956
|
show_breadcrumbs?: boolean;
|
|
831
957
|
category_title: typeof CategoryTitle | typeof embedded_num_products;
|
|
832
|
-
|
|
958
|
+
on_listing_query_change?: (new_listing_query?: ListingQuery | undefined, old_listing_query?: ListingQuery | undefined) => void;
|
|
833
959
|
content_blocks_by_row?: ContentBlocksByRow;
|
|
834
|
-
}): import("@depict-ai/utilishared").Node_Array;
|
|
960
|
+
}): import("@depict-ai/utilishared/latest").Node_Array;
|
|
835
961
|
export function BreadCrumbs<T extends Display>({
|
|
836
962
|
depict_category
|
|
837
963
|
}: {
|
|
838
964
|
depict_category: DepictCategory<T>;
|
|
839
|
-
}):
|
|
965
|
+
}): HTMLDivElement;
|
|
840
966
|
export function QuickLinks<T extends Display>({
|
|
841
967
|
depict_category
|
|
842
968
|
}: {
|
|
843
969
|
depict_category: DepictCategory<T>;
|
|
844
|
-
}):
|
|
970
|
+
}): HTMLDivElement;
|
|
845
971
|
/**
|
|
846
972
|
* Gets available listings for a given merchant, market and locale
|
|
847
973
|
*/
|
|
848
|
-
export function get_listings(merchant: string, market: string, locale: string): Promise<import("@depict-ai/types/api/
|
|
974
|
+
export function get_listings(merchant: string, market: string, locale: string): Promise<import("@depict-ai/types/api/ListListingsResponseItem").ListListingsResponseItem1[]>;
|
|
849
975
|
export function DefaultInstantCardPlaceholder(): HTMLDivElement;
|
|
850
976
|
/**
|
|
851
977
|
* Useful for aligning the search modal to an element, like an existing input field
|
|
@@ -961,123 +1087,6 @@ interface SearchFieldParams {
|
|
|
961
1087
|
aligner_ref?: HTMLElement | null;
|
|
962
1088
|
}
|
|
963
1089
|
export function SearchField(props: SearchFieldParams): HTMLDivElement[];
|
|
964
|
-
export type BaseProviderConfig<InputDisplay extends Display, PossibleTransformedDisplay extends ModernDisplay | never> = {
|
|
965
|
-
/**
|
|
966
|
-
* The merchant to use for the search.
|
|
967
|
-
* @example "YOUR_MERCHANT", "stronger"
|
|
968
|
-
*/
|
|
969
|
-
merchant: string;
|
|
970
|
-
/**
|
|
971
|
-
* The market to use for the search.
|
|
972
|
-
* @example "YOUR_MARKET", "no", "en-de"
|
|
973
|
-
*/
|
|
974
|
-
market: string;
|
|
975
|
-
/**
|
|
976
|
-
* Optional unique identifer of the user. Only necessary when performing server side requests to Depict. All Depict tooling has a fallback ID that will be used when this isn't specified, but if you make requests to Depict directly, you need to specify this everywhere.
|
|
977
|
-
*/
|
|
978
|
-
sessionId?: string;
|
|
979
|
-
/**
|
|
980
|
-
* Custom metadata to be sent with each request to the Depict API. Only necessary if specifically instructed by Depict.
|
|
981
|
-
*/
|
|
982
|
-
metaData?: Record<string, string>;
|
|
983
|
-
/**
|
|
984
|
-
* You can't have more than one instance of the same provider on the same page, unless you specify a unique instance key for each one.
|
|
985
|
-
* This is because there's state in the URL and history.state and the state of the different instances would collide.
|
|
986
|
-
* By setting this property, you can specify a unique key for each instance, so that the state of each instance is kept separate.
|
|
987
|
-
* We recommend to just use an incrementing number for this, e.g. "1", "2", "3", ...
|
|
988
|
-
*/
|
|
989
|
-
uniqueInstanceKeyForState?: string;
|
|
990
|
-
} & (InputDisplay extends ModernDisplay ? "page_url" extends keyof InputDisplay["variant_displays"][number] ? {
|
|
991
|
-
/**
|
|
992
|
-
* 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.
|
|
993
|
-
*/
|
|
994
|
-
displayTransformers: DisplayTransformers<InputDisplay, PossibleTransformedDisplay>;
|
|
995
|
-
} : {
|
|
996
|
-
/**
|
|
997
|
-
* 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.
|
|
998
|
-
*/
|
|
999
|
-
displayTransformers: DisplayTransformers<InputDisplay, PossibleTransformedDisplay>;
|
|
1000
|
-
} : {
|
|
1001
|
-
/**
|
|
1002
|
-
* 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.
|
|
1003
|
-
*/
|
|
1004
|
-
displayTransformers?: never;
|
|
1005
|
-
});
|
|
1006
|
-
export type BaseSearchProviderConfig = {
|
|
1007
|
-
/**
|
|
1008
|
-
* The path to the search page.
|
|
1009
|
-
* @example "/search", "/sok"
|
|
1010
|
-
*/
|
|
1011
|
-
searchPagePath: string;
|
|
1012
|
-
/**
|
|
1013
|
-
* The name of the url parameter that will be used for the search query.
|
|
1014
|
-
* @example "q", "search_query", "query"
|
|
1015
|
-
* @default "query"
|
|
1016
|
-
*/
|
|
1017
|
-
urlParamName?: string;
|
|
1018
|
-
/**
|
|
1019
|
-
* Whether to enable category suggestions in the search modal and search page.
|
|
1020
|
-
* @default false
|
|
1021
|
-
*/
|
|
1022
|
-
enableCategorySuggestions?: boolean;
|
|
1023
|
-
/**
|
|
1024
|
-
* Whether to enable content search in the search modal and search page.
|
|
1025
|
-
* @default false
|
|
1026
|
-
*/
|
|
1027
|
-
enableContentSearch?: boolean;
|
|
1028
|
-
};
|
|
1029
|
-
export type BaseCategoryProviderConfig = {
|
|
1030
|
-
/**
|
|
1031
|
-
* Currently used for SEO long tail only.
|
|
1032
|
-
* Read more about SEO collections here https://docs.depict.ai/other-guides/seo-collections-guide/introduction
|
|
1033
|
-
* @default ""
|
|
1034
|
-
* @example
|
|
1035
|
-
* If the generated SEO title is "Blue Jeans", and you specify metaTitleSuffix to " | My Store", the final SEO title will be "Blue Jeans | My Store".
|
|
1036
|
-
*/
|
|
1037
|
-
metaTitleSuffix?: string;
|
|
1038
|
-
/**
|
|
1039
|
-
* The parameter `listing_id=` will override the regular category id that you have configured your SDK to use. You can consider the `listing_id` as an escape-hatch if you want to easily set a listing id.
|
|
1040
|
-
* However, if your page already sets a listing_id, you can disable this behaviour by setting this property to `true` (to avoid a conflict).
|
|
1041
|
-
*/
|
|
1042
|
-
disableOverrideListingId?: boolean;
|
|
1043
|
-
};
|
|
1044
|
-
export interface BaseProductListingConfig {
|
|
1045
|
-
/**
|
|
1046
|
-
* How many columns to show at each media size.
|
|
1047
|
-
* @default
|
|
1048
|
-
* [[2, 901], [3, 1024], [4]]
|
|
1049
|
-
* @example
|
|
1050
|
-
* [[2, 901], [3, 1024], [4]]
|
|
1051
|
-
* means 2 columns at sizes up to 901px, 3 columns at sizes up to 1024px and after that 4 columns at any viewport size.
|
|
1052
|
-
*/
|
|
1053
|
-
columnsAtSize?: SDKColsAtSize;
|
|
1054
|
-
/**
|
|
1055
|
-
* The spacing between products.
|
|
1056
|
-
* @default "2%"
|
|
1057
|
-
* @example
|
|
1058
|
-
* "2%", "10px", "1rem", {horizontal: "1%", vertical: "5px"}
|
|
1059
|
-
*/
|
|
1060
|
-
gridSpacing?: SDKGridSpacing;
|
|
1061
|
-
}
|
|
1062
|
-
export interface BaseSearchPageConfig extends BaseProductListingConfig {
|
|
1063
|
-
/**
|
|
1064
|
-
* Whether to show the search input field in the search page.
|
|
1065
|
-
* @default true
|
|
1066
|
-
*/
|
|
1067
|
-
includeInputField?: boolean;
|
|
1068
|
-
}
|
|
1069
|
-
export interface BaseCategoryPageConfig extends BaseProductListingConfig {
|
|
1070
|
-
/**
|
|
1071
|
-
* Whether to show the breadcrumbs in the category page.
|
|
1072
|
-
* @default true
|
|
1073
|
-
*/
|
|
1074
|
-
showBreadcrumbs?: boolean;
|
|
1075
|
-
/**
|
|
1076
|
-
* Whether to show the quicklinks in the category page.
|
|
1077
|
-
* @default true
|
|
1078
|
-
*/
|
|
1079
|
-
showQuicklinks?: boolean;
|
|
1080
|
-
}
|
|
1081
1090
|
type CenteredLocation = {
|
|
1082
1091
|
location?: "centered";
|
|
1083
1092
|
};
|