@depict-ai/ui 0.0.82 → 1.0.1
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/dist/index.d.ts +25 -4
- package/dist/main.js +31 -19
- package/dist/module.js +32 -20
- package/dist/typescript_schema/BaseSearchRequest.d.ts +197 -0
- package/dist/typescript_schema/ProductListingQueriesRequest.d.ts +14 -0
- package/dist/typescript_schema/ProductListingQueriesResponse.d.ts +10 -0
- package/dist/typescript_schema/ProductListingRequest.d.ts +221 -0
- package/dist/typescript_schema/ProductListingResponse.d.ts +232 -0
- package/dist/typescript_schema/RecommendResponse.d.ts +15 -0
- package/dist/typescript_schema/SearchRequest.d.ts +213 -0
- package/dist/typescript_schema/SearchResponse.d.ts +192 -0
- package/dist/typescript_schema/SearchSuggestionsRequest.d.ts +18 -0
- package/dist/typescript_schema/SearchSuggestionsResponse.d.ts +182 -0
- package/dist/typescript_schema/TrackV2Request.d.ts +115 -0
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { SearchSuggestionsResponse, CategorySuggestion } from "@depict-ai/types/
|
|
|
7
7
|
import { SearchSuggestionsRequest } from "@depict-ai/types/api/SearchSuggestionsRequest";
|
|
8
8
|
import { ProductListingRequest } from "@depict-ai/types/api/ProductListingRequest";
|
|
9
9
|
import { ProductListingResponse } from "@depict-ai/types/api/ProductListingResponse";
|
|
10
|
-
export const version = "
|
|
10
|
+
export const version = "1.0.1";
|
|
11
11
|
export type OnNavigation = ((options: {
|
|
12
12
|
is_replace: boolean;
|
|
13
13
|
new_url: URL;
|
|
@@ -33,6 +33,8 @@ type RecsAPIWrapperOptions = {
|
|
|
33
33
|
type: string;
|
|
34
34
|
merchant: string;
|
|
35
35
|
market: string;
|
|
36
|
+
userId?: string;
|
|
37
|
+
sessionId?: string;
|
|
36
38
|
headers?: HeadersInit;
|
|
37
39
|
} & ExclusiveId;
|
|
38
40
|
/**
|
|
@@ -45,6 +47,8 @@ type RecsAPIWrapperOptions = {
|
|
|
45
47
|
* @param categoryId When requesting recommendations for a category page, pass the id of the category page as `categoryId`.
|
|
46
48
|
* @param productId When requesting recommendations for a single product, e.g. on a product detail page, pass the id of the product as `productId`.
|
|
47
49
|
* @param productIds When requesting recommendations that should take multiple products into account, i.e. the contents of the basket/cart, pass an array of product ids as `productIds`
|
|
50
|
+
* @param userId Optional unique identifier of a logged in user. Should be persistent across devices and sessions.
|
|
51
|
+
* @param sessionId Optional unique identifer of the current session. Only necessary when performing server side requests to Depict.
|
|
48
52
|
* @param headers Optional headers to send to the Depict API. This could be authentication for example. 99% of integrations can leave this unset.
|
|
49
53
|
* When no id is provided (none out of `categoryId`, `productId` and `productIds`) general recommendations will be fetched. This is for, for example, the frontpage where generally popular products get returned.
|
|
50
54
|
*
|
|
@@ -158,11 +162,16 @@ export type InstantCard<T extends Display> = (display: T, context: {
|
|
|
158
162
|
merchant: string;
|
|
159
163
|
market: string;
|
|
160
164
|
}) => JSX.Element;
|
|
165
|
+
interface DepictAPIConstructorOptions {
|
|
166
|
+
get_metadata?: () => Promise<{
|
|
167
|
+
[k: string]: string;
|
|
168
|
+
} | undefined>;
|
|
169
|
+
get_user_id?: () => string | undefined;
|
|
170
|
+
get_session_id?: () => string | undefined;
|
|
171
|
+
}
|
|
161
172
|
export class DepictAPI {
|
|
162
173
|
#private;
|
|
163
|
-
constructor(get_metadata?:
|
|
164
|
-
[k: string]: string;
|
|
165
|
-
} | undefined>);
|
|
174
|
+
constructor({ get_metadata, get_user_id, get_session_id }?: DepictAPIConstructorOptions);
|
|
166
175
|
suggest(input_req: SearchSuggestionsRequest): Promise<SearchSuggestionsResponse & {
|
|
167
176
|
failed?: true;
|
|
168
177
|
}>;
|
|
@@ -374,6 +383,18 @@ export type BaseProviderConfig = {
|
|
|
374
383
|
* @example "YOUR_MARKET", "no", "en-de"
|
|
375
384
|
*/
|
|
376
385
|
market: string;
|
|
386
|
+
/**
|
|
387
|
+
* Optional unique identifier of a logged in user. Should be persistent across devices and sessions.
|
|
388
|
+
*/
|
|
389
|
+
userId?: string;
|
|
390
|
+
/**
|
|
391
|
+
* Optional unique identifer of the current session. Only necessary when performing server side requests to Depict.
|
|
392
|
+
*/
|
|
393
|
+
sessionId?: string;
|
|
394
|
+
/**
|
|
395
|
+
* Custom metadata to be sent with each request to the Depict API. Only necessary if specifically instructed by Depict.
|
|
396
|
+
*/
|
|
397
|
+
metaData?: Record<string, string>;
|
|
377
398
|
};
|
|
378
399
|
export type BaseSearchProviderConfig = {
|
|
379
400
|
/**
|
package/dist/main.js
CHANGED
|
@@ -35,7 +35,7 @@ $parcel$export(module.exports, "SolidFormatPrice", () => $5fc9fc23df1591db$expor
|
|
|
35
35
|
$parcel$export(module.exports, "connect_search_field_height_to_aligner_height", () => $246e3e89a097f014$export$828dcdd425fd3231);
|
|
36
36
|
$parcel$export(module.exports, "PageReplacer", () => $37e96a5ebc768cc7$export$3ccaa27d81dd8556);
|
|
37
37
|
$parcel$export(module.exports, "version", () => $ae93561d5649a847$export$83d89fbfd8236492);
|
|
38
|
-
/*! Depict.ai search and product listing SDK */ const $ae93561d5649a847$export$83d89fbfd8236492 = "
|
|
38
|
+
/*! Depict.ai search and product listing SDK */ const $ae93561d5649a847$export$83d89fbfd8236492 = "1.0.1";
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
|
|
@@ -60,7 +60,9 @@ async function $8c4e48a4bf96b284$export$58e808b1db15d3bc({ merchant: merchant ,
|
|
|
60
60
|
function $1ee6da2465098194$export$e183a13865960371(params_to_default_value, router_) {
|
|
61
61
|
const signals = {};
|
|
62
62
|
const entries = Object.entries(params_to_default_value);
|
|
63
|
-
const event_handler = (0, $46MJV$depictaiutilishared.catchify)((
|
|
63
|
+
const event_handler = (0, $46MJV$depictaiutilishared.catchify)((what_happened, args)=>{
|
|
64
|
+
if (what_happened == "popstate") $1ee6da2465098194$var$history_state_change(signals, entries, args.state);
|
|
65
|
+
});
|
|
64
66
|
// createRenderEffect because we need the instant execution so the signals always contain values, even before solid's render phase
|
|
65
67
|
(0, $46MJV$solidjs.createRenderEffect)(()=>{
|
|
66
68
|
let signal_changed = false;
|
|
@@ -76,8 +78,9 @@ function $1ee6da2465098194$export$e183a13865960371(params_to_default_value, rout
|
|
|
76
78
|
}
|
|
77
79
|
if (signal_changed) router_.navigate_.replace_state_(state);
|
|
78
80
|
});
|
|
79
|
-
window.addEventListener("popstate"
|
|
80
|
-
(0, $46MJV$
|
|
81
|
+
// history_dot_state_to_state needs to update after its signals after url_state does BUT in the same task (might even have to be in the same tick in the microtask queue). If we'd use window.addEventListener("popstate") it would be guaranteed to be too late since each event listener has its own task
|
|
82
|
+
(0, $46MJV$depictaiutilishared.instant_exec_on_suspect_history_change).add(event_handler);
|
|
83
|
+
(0, $46MJV$solidjs.onCleanup)((0, $46MJV$depictaiutilishared.catchify)(()=>(0, $46MJV$depictaiutilishared.instant_exec_on_suspect_history_change).delete(event_handler)));
|
|
81
84
|
(0, $46MJV$solidjs.createEffect)((0, $46MJV$depictaiutilishared.catchify)(()=>(0, $46MJV$solidjs.untrack)((0, $46MJV$depictaiutilishared.catchify)(()=>$1ee6da2465098194$var$history_state_change(signals, entries, history.state))))); // we need this to run after reading the initial state from history.state to write the defaults to history.state
|
|
82
85
|
return signals;
|
|
83
86
|
}
|
|
@@ -111,15 +114,6 @@ function $0de081f67b6d15b5$export$9862539c89138352(get_default_values_, router_)
|
|
|
111
114
|
|
|
112
115
|
const $9ce64f69303c371e$var$v2_base_url = (0, $46MJV$depictaiutilishared.base_url) + "/v2/";
|
|
113
116
|
const $9ce64f69303c371e$var$search_base_url = $9ce64f69303c371e$var$v2_base_url + "search/";
|
|
114
|
-
const $9ce64f69303c371e$var$add_ids_to_request = (input_req)=>{
|
|
115
|
-
const request = {
|
|
116
|
-
...input_req
|
|
117
|
-
};
|
|
118
|
-
request.dsid ??= (0, $46MJV$depictaiutilishared.get_depict_id)();
|
|
119
|
-
request.user_id ??= (0, $46MJV$depictaiutilishared.get_user_id)();
|
|
120
|
-
request.session_id ??= (0, $46MJV$depictaiutilishared.get_session_id)();
|
|
121
|
-
return request;
|
|
122
|
-
};
|
|
123
117
|
class $9ce64f69303c371e$export$e015ed2f2950f2e3 {
|
|
124
118
|
#supports_finalization_registry = typeof FinalizationRegistry === "function";
|
|
125
119
|
#cache_objs = {};
|
|
@@ -134,12 +128,26 @@ class $9ce64f69303c371e$export$e015ed2f2950f2e3 {
|
|
|
134
128
|
})) : undefined
|
|
135
129
|
};
|
|
136
130
|
}
|
|
131
|
+
#add_ids_to_request = (input_req)=>{
|
|
132
|
+
const request = {
|
|
133
|
+
...input_req
|
|
134
|
+
};
|
|
135
|
+
request.dsid ??= (0, $46MJV$depictaiutilishared.get_depict_id)();
|
|
136
|
+
// Todo: remove the default user and session IDs once we've confirmed backend can handle it and do whatever fallback is necessary.
|
|
137
|
+
request.user_id ??= this.#get_user_id?.() || (0, $46MJV$depictaiutilishared.get_user_id)();
|
|
138
|
+
request.session_id ??= this.#get_session_id?.() || (0, $46MJV$depictaiutilishared.get_session_id)();
|
|
139
|
+
return request;
|
|
140
|
+
};
|
|
137
141
|
#get_metadata;
|
|
138
|
-
|
|
142
|
+
#get_user_id;
|
|
143
|
+
#get_session_id;
|
|
144
|
+
constructor({ get_metadata: get_metadata , get_user_id: get_user_id , get_session_id: get_session_id } = {}){
|
|
139
145
|
this.#get_metadata = get_metadata;
|
|
146
|
+
this.#get_user_id = get_user_id;
|
|
147
|
+
this.#get_session_id = get_session_id;
|
|
140
148
|
}
|
|
141
149
|
async suggest(input_req) {
|
|
142
|
-
const request =
|
|
150
|
+
const request = this.#add_ids_to_request(input_req);
|
|
143
151
|
const url = (0, $46MJV$depictaiutilishared.make_url_with_query_params)($9ce64f69303c371e$var$search_base_url + "suggestions", request);
|
|
144
152
|
const results = await (0, $46MJV$depictaiutilishared.fetch_retry)((0, $46MJV$depictaiutilishared.add_version_query_params)(url));
|
|
145
153
|
attempt_to_return_api_response: {
|
|
@@ -156,7 +164,7 @@ class $9ce64f69303c371e$export$e015ed2f2950f2e3 {
|
|
|
156
164
|
}
|
|
157
165
|
async #cached_post_request(endpoint1, input_req, fallback_response) {
|
|
158
166
|
const cache_obj = this.#get_cache_obj_for_endpoint(endpoint1);
|
|
159
|
-
const with_ids =
|
|
167
|
+
const with_ids = this.#add_ids_to_request(input_req);
|
|
160
168
|
const metaData = await this.#get_metadata?.();
|
|
161
169
|
const request = metaData ? Object.assign(with_ids, {
|
|
162
170
|
metadata: metaData
|
|
@@ -830,7 +838,8 @@ function $7b0b7e887b485a91$export$f33414a4df0afd3f({ product_card_template_: pro
|
|
|
830
838
|
if (!unwrapped_array?.length || !unwrapped_array.every((item)=>item)) // Haven't finished rendering yet in case of "async" rendering, so don't freeze the elements yet
|
|
831
839
|
return;
|
|
832
840
|
// placeholders have finished rendering, freeze the elements
|
|
833
|
-
|
|
841
|
+
// here we might receive the result of a promise that has already been received, tore down and put into cached_placeholder_element, so don't overwrite that more valid result if it's already set
|
|
842
|
+
$7b0b7e887b485a91$var$cached_placeholder_element ||= get_cloned_placeholders(unwrapped_array); // Clone initial return value so that who gave us the elements can't mutate them, which has caused issues before with react
|
|
834
843
|
$7b0b7e887b485a91$var$rendering_cached_placeholder_element = undefined;
|
|
835
844
|
dispose_original_copy(); // So that this memo will never re-run and the placeholder rendering function can clean up
|
|
836
845
|
return get_cloned_placeholders(); // clone, just in case. If we wouldn't, someone could modify the copy in the DOM, and it would affect the cached version
|
|
@@ -1192,8 +1201,11 @@ function $8d94abc871e13baf$export$3925f87b1545cfc6({ plp_results_: plp_results_
|
|
|
1192
1201
|
}
|
|
1193
1202
|
}));
|
|
1194
1203
|
(0, $46MJV$solidjs.createEffect)((0, $46MJV$solidjs.on)(plp_results_, ()=>{
|
|
1195
|
-
if (!fallback_is_alive)
|
|
1196
|
-
|
|
1204
|
+
if (!fallback_is_alive) {
|
|
1205
|
+
// if all product card rendering functions after the initial rendering are synchronous the suspense boundary will never go into the fallback, so we don't know when they have finished rendering, and we can't block the suspense. Therefore, we're just doing it with this effect
|
|
1206
|
+
block_suspense_if_needed();
|
|
1207
|
+
set_should_have_placeholders_rendered(false);
|
|
1208
|
+
}
|
|
1197
1209
|
}, {
|
|
1198
1210
|
defer: true
|
|
1199
1211
|
}));
|
package/dist/module.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {add_to_version_info as $g9l4l$add_to_version_info, fetch_recs as $g9l4l$fetch_recs, snakeCasifyObject as $g9l4l$snakeCasifyObject, GenericSliderArrowButton as $g9l4l$GenericSliderArrowButton, catchify as $g9l4l$catchify, base_url as $g9l4l$base_url,
|
|
1
|
+
import {add_to_version_info as $g9l4l$add_to_version_info, fetch_recs as $g9l4l$fetch_recs, snakeCasifyObject as $g9l4l$snakeCasifyObject, GenericSliderArrowButton as $g9l4l$GenericSliderArrowButton, catchify as $g9l4l$catchify, instant_exec_on_suspect_history_change as $g9l4l$instant_exec_on_suspect_history_change, base_url as $g9l4l$base_url, dlog as $g9l4l$dlog, get_depict_id as $g9l4l$get_depict_id, get_user_id as $g9l4l$get_user_id, get_session_id as $g9l4l$get_session_id, make_url_with_query_params as $g9l4l$make_url_with_query_params, fetch_retry as $g9l4l$fetch_retry, add_version_query_params as $g9l4l$add_version_query_params, sort_obj as $g9l4l$sort_obj, Placeholder as $g9l4l$Placeholder, report as $g9l4l$report, javascript_media_query as $g9l4l$javascript_media_query, standard_price_format as $g9l4l$standard_price_format, make_random_classname as $g9l4l$make_random_classname, n_col_styling_with_dist as $g9l4l$n_col_styling_with_dist, observer as $g9l4l$observer, CrossIcon as $g9l4l$CrossIcon, useExpandingContainer as $g9l4l$useExpandingContainer, Amazing_Slider as $g9l4l$Amazing_Slider, slider_snap_css as $g9l4l$slider_snap_css, slider_fading_factory as $g9l4l$slider_fading_factory, MinusIcon as $g9l4l$MinusIcon, FilterIcon as $g9l4l$FilterIcon, SortIconAsc as $g9l4l$SortIconAsc, SortIconDesc as $g9l4l$SortIconDesc, PlusIcon as $g9l4l$PlusIcon, hsl_to_rgb as $g9l4l$hsl_to_rgb, relative_luminance_from_rgb as $g9l4l$relative_luminance_from_rgb, TickIcon as $g9l4l$TickIcon, ArrowUp as $g9l4l$ArrowUp, queueMacroTask as $g9l4l$queueMacroTask, dwarn as $g9l4l$dwarn, ContainedPlaceholderImage as $g9l4l$ContainedPlaceholderImage, BackIcon as $g9l4l$BackIcon, SearchIcon as $g9l4l$SearchIcon, Layout as $g9l4l$Layout, async_iterable_ipns as $g9l4l$async_iterable_ipns, make_asyncIterable_exiter as $g9l4l$make_asyncIterable_exiter, href_change_ipns as $g9l4l$href_change_ipns, ContainedImage as $g9l4l$ContainedImage, buildThresholdList as $g9l4l$buildThresholdList, deparallelize_no_drop as $g9l4l$deparallelize_no_drop, PreviousSearchIcon as $g9l4l$PreviousSearchIcon, insert_surfaces as $g9l4l$insert_surfaces} from "@depict-ai/utilishared";
|
|
2
2
|
import {template as $g9l4l$template, insert as $g9l4l$insert, effect as $g9l4l$effect, setAttribute as $g9l4l$setAttribute, createComponent as $g9l4l$createComponent, use as $g9l4l$use, memo as $g9l4l$memo, addEventListener as $g9l4l$addEventListener, delegateEvents as $g9l4l$delegateEvents, spread as $g9l4l$spread, classList as $g9l4l$classList, style as $g9l4l$style, Dynamic as $g9l4l$Dynamic, mergeProps as $g9l4l$mergeProps, className as $g9l4l$className} from "solid-js/web";
|
|
3
3
|
import {createSignal as $g9l4l$createSignal, onCleanup as $g9l4l$onCleanup, createComputed as $g9l4l$createComputed, createRenderEffect as $g9l4l$createRenderEffect, createEffect as $g9l4l$createEffect, untrack as $g9l4l$untrack, batch as $g9l4l$batch, createResource as $g9l4l$createResource, createMemo as $g9l4l$createMemo, Show as $g9l4l$Show, createReaction as $g9l4l$createReaction, Suspense as $g9l4l$Suspense, on as $g9l4l$on, createRoot as $g9l4l$createRoot, ErrorBoundary as $g9l4l$ErrorBoundary, For as $g9l4l$For, getOwner as $g9l4l$getOwner, runWithOwner as $g9l4l$runWithOwner, Index as $g9l4l$Index} from "solid-js";
|
|
4
4
|
import {compressToBase64 as $g9l4l$compressToBase64, decompressFromBase64 as $g9l4l$decompressFromBase64} from "lz-string";
|
|
5
5
|
|
|
6
|
-
/*! Depict.ai search and product listing SDK */ const $18bf1d29fb889cca$export$83d89fbfd8236492 = "
|
|
6
|
+
/*! Depict.ai search and product listing SDK */ const $18bf1d29fb889cca$export$83d89fbfd8236492 = "1.0.1";
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -28,7 +28,9 @@ async function $e95f1855a5e3864f$export$58e808b1db15d3bc({ merchant: merchant ,
|
|
|
28
28
|
function $014a147d094b0d08$export$e183a13865960371(params_to_default_value, router_) {
|
|
29
29
|
const signals = {};
|
|
30
30
|
const entries = Object.entries(params_to_default_value);
|
|
31
|
-
const event_handler = (0, $g9l4l$catchify)((
|
|
31
|
+
const event_handler = (0, $g9l4l$catchify)((what_happened, args)=>{
|
|
32
|
+
if (what_happened == "popstate") $014a147d094b0d08$var$history_state_change(signals, entries, args.state);
|
|
33
|
+
});
|
|
32
34
|
// createRenderEffect because we need the instant execution so the signals always contain values, even before solid's render phase
|
|
33
35
|
(0, $g9l4l$createRenderEffect)(()=>{
|
|
34
36
|
let signal_changed = false;
|
|
@@ -44,8 +46,9 @@ function $014a147d094b0d08$export$e183a13865960371(params_to_default_value, rout
|
|
|
44
46
|
}
|
|
45
47
|
if (signal_changed) router_.navigate_.replace_state_(state);
|
|
46
48
|
});
|
|
47
|
-
window.addEventListener("popstate"
|
|
48
|
-
(0, $g9l4l$
|
|
49
|
+
// history_dot_state_to_state needs to update after its signals after url_state does BUT in the same task (might even have to be in the same tick in the microtask queue). If we'd use window.addEventListener("popstate") it would be guaranteed to be too late since each event listener has its own task
|
|
50
|
+
(0, $g9l4l$instant_exec_on_suspect_history_change).add(event_handler);
|
|
51
|
+
(0, $g9l4l$onCleanup)((0, $g9l4l$catchify)(()=>(0, $g9l4l$instant_exec_on_suspect_history_change).delete(event_handler)));
|
|
49
52
|
(0, $g9l4l$createEffect)((0, $g9l4l$catchify)(()=>(0, $g9l4l$untrack)((0, $g9l4l$catchify)(()=>$014a147d094b0d08$var$history_state_change(signals, entries, history.state))))); // we need this to run after reading the initial state from history.state to write the defaults to history.state
|
|
50
53
|
return signals;
|
|
51
54
|
}
|
|
@@ -79,15 +82,6 @@ function $3075a4497054bec6$export$9862539c89138352(get_default_values_, router_)
|
|
|
79
82
|
|
|
80
83
|
const $3846bb34098c738f$var$v2_base_url = (0, $g9l4l$base_url) + "/v2/";
|
|
81
84
|
const $3846bb34098c738f$var$search_base_url = $3846bb34098c738f$var$v2_base_url + "search/";
|
|
82
|
-
const $3846bb34098c738f$var$add_ids_to_request = (input_req)=>{
|
|
83
|
-
const request = {
|
|
84
|
-
...input_req
|
|
85
|
-
};
|
|
86
|
-
request.dsid ??= (0, $g9l4l$get_depict_id)();
|
|
87
|
-
request.user_id ??= (0, $g9l4l$get_user_id)();
|
|
88
|
-
request.session_id ??= (0, $g9l4l$get_session_id)();
|
|
89
|
-
return request;
|
|
90
|
-
};
|
|
91
85
|
class $3846bb34098c738f$export$e015ed2f2950f2e3 {
|
|
92
86
|
#supports_finalization_registry = typeof FinalizationRegistry === "function";
|
|
93
87
|
#cache_objs = {};
|
|
@@ -102,12 +96,26 @@ class $3846bb34098c738f$export$e015ed2f2950f2e3 {
|
|
|
102
96
|
})) : undefined
|
|
103
97
|
};
|
|
104
98
|
}
|
|
99
|
+
#add_ids_to_request = (input_req)=>{
|
|
100
|
+
const request = {
|
|
101
|
+
...input_req
|
|
102
|
+
};
|
|
103
|
+
request.dsid ??= (0, $g9l4l$get_depict_id)();
|
|
104
|
+
// Todo: remove the default user and session IDs once we've confirmed backend can handle it and do whatever fallback is necessary.
|
|
105
|
+
request.user_id ??= this.#get_user_id?.() || (0, $g9l4l$get_user_id)();
|
|
106
|
+
request.session_id ??= this.#get_session_id?.() || (0, $g9l4l$get_session_id)();
|
|
107
|
+
return request;
|
|
108
|
+
};
|
|
105
109
|
#get_metadata;
|
|
106
|
-
|
|
110
|
+
#get_user_id;
|
|
111
|
+
#get_session_id;
|
|
112
|
+
constructor({ get_metadata: get_metadata , get_user_id: get_user_id , get_session_id: get_session_id } = {}){
|
|
107
113
|
this.#get_metadata = get_metadata;
|
|
114
|
+
this.#get_user_id = get_user_id;
|
|
115
|
+
this.#get_session_id = get_session_id;
|
|
108
116
|
}
|
|
109
117
|
async suggest(input_req) {
|
|
110
|
-
const request =
|
|
118
|
+
const request = this.#add_ids_to_request(input_req);
|
|
111
119
|
const url = (0, $g9l4l$make_url_with_query_params)($3846bb34098c738f$var$search_base_url + "suggestions", request);
|
|
112
120
|
const results = await (0, $g9l4l$fetch_retry)((0, $g9l4l$add_version_query_params)(url));
|
|
113
121
|
attempt_to_return_api_response: {
|
|
@@ -124,7 +132,7 @@ class $3846bb34098c738f$export$e015ed2f2950f2e3 {
|
|
|
124
132
|
}
|
|
125
133
|
async #cached_post_request(endpoint1, input_req, fallback_response) {
|
|
126
134
|
const cache_obj = this.#get_cache_obj_for_endpoint(endpoint1);
|
|
127
|
-
const with_ids =
|
|
135
|
+
const with_ids = this.#add_ids_to_request(input_req);
|
|
128
136
|
const metaData = await this.#get_metadata?.();
|
|
129
137
|
const request = metaData ? Object.assign(with_ids, {
|
|
130
138
|
metadata: metaData
|
|
@@ -798,7 +806,8 @@ function $dc5df79ae78a9d00$export$f33414a4df0afd3f({ product_card_template_: pro
|
|
|
798
806
|
if (!unwrapped_array?.length || !unwrapped_array.every((item)=>item)) // Haven't finished rendering yet in case of "async" rendering, so don't freeze the elements yet
|
|
799
807
|
return;
|
|
800
808
|
// placeholders have finished rendering, freeze the elements
|
|
801
|
-
|
|
809
|
+
// here we might receive the result of a promise that has already been received, tore down and put into cached_placeholder_element, so don't overwrite that more valid result if it's already set
|
|
810
|
+
$dc5df79ae78a9d00$var$cached_placeholder_element ||= get_cloned_placeholders(unwrapped_array); // Clone initial return value so that who gave us the elements can't mutate them, which has caused issues before with react
|
|
802
811
|
$dc5df79ae78a9d00$var$rendering_cached_placeholder_element = undefined;
|
|
803
812
|
dispose_original_copy(); // So that this memo will never re-run and the placeholder rendering function can clean up
|
|
804
813
|
return get_cloned_placeholders(); // clone, just in case. If we wouldn't, someone could modify the copy in the DOM, and it would affect the cached version
|
|
@@ -1160,8 +1169,11 @@ function $57363319986950eb$export$3925f87b1545cfc6({ plp_results_: plp_results_
|
|
|
1160
1169
|
}
|
|
1161
1170
|
}));
|
|
1162
1171
|
(0, $g9l4l$createEffect)((0, $g9l4l$on)(plp_results_, ()=>{
|
|
1163
|
-
if (!fallback_is_alive)
|
|
1164
|
-
|
|
1172
|
+
if (!fallback_is_alive) {
|
|
1173
|
+
// if all product card rendering functions after the initial rendering are synchronous the suspense boundary will never go into the fallback, so we don't know when they have finished rendering, and we can't block the suspense. Therefore, we're just doing it with this effect
|
|
1174
|
+
block_suspense_if_needed();
|
|
1175
|
+
set_should_have_placeholders_rendered(false);
|
|
1176
|
+
}
|
|
1165
1177
|
}, {
|
|
1166
1178
|
defer: true
|
|
1167
1179
|
}));
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
4
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
5
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* An enumeration.
|
|
10
|
+
*/
|
|
11
|
+
export type SortingOrder = "asc" | "desc";
|
|
12
|
+
|
|
13
|
+
export interface BaseSearchRequest {
|
|
14
|
+
tenant: string;
|
|
15
|
+
market: string;
|
|
16
|
+
/**
|
|
17
|
+
* List of filters to apply to the results.
|
|
18
|
+
*/
|
|
19
|
+
filters?: SearchFilter[];
|
|
20
|
+
/**
|
|
21
|
+
* Specifies the sorting method. By default, the results are ordered by relevance. To find the possible values for this field, query the endpoint and look at the `sorts` field.
|
|
22
|
+
*/
|
|
23
|
+
sort?: SortModel;
|
|
24
|
+
/**
|
|
25
|
+
* User identifier
|
|
26
|
+
*/
|
|
27
|
+
user_id?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Session identifier
|
|
30
|
+
*/
|
|
31
|
+
session_id?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Populated for integrations performed by Depict.ai only. Depict.ai Session Id
|
|
34
|
+
*/
|
|
35
|
+
dsid?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Metadata that can be used to modify the behaviour of the search.
|
|
38
|
+
*/
|
|
39
|
+
metadata?: {
|
|
40
|
+
[k: string]: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* The search query.
|
|
44
|
+
*/
|
|
45
|
+
query?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface SearchFilter {
|
|
48
|
+
/**
|
|
49
|
+
* The field to filter by.
|
|
50
|
+
*/
|
|
51
|
+
field: string;
|
|
52
|
+
/**
|
|
53
|
+
* The operation used for filtering. The filtering should be read as `field op data`, for example `brand in ["Nike", "Adidas"]`.
|
|
54
|
+
*/
|
|
55
|
+
op: "eq" | "neq" | "in" | "nin" | "leq" | "geq" | "inrange";
|
|
56
|
+
/**
|
|
57
|
+
* Data for the filter.
|
|
58
|
+
*/
|
|
59
|
+
data?:
|
|
60
|
+
| ("true" | "false")
|
|
61
|
+
| number
|
|
62
|
+
| number
|
|
63
|
+
| string
|
|
64
|
+
| [number, number]
|
|
65
|
+
| [number, number]
|
|
66
|
+
| [number, number]
|
|
67
|
+
| [number, number]
|
|
68
|
+
| (
|
|
69
|
+
| ("true" | "false")
|
|
70
|
+
| number
|
|
71
|
+
| number
|
|
72
|
+
| string
|
|
73
|
+
| [number, number]
|
|
74
|
+
| [number, number]
|
|
75
|
+
| [number, number]
|
|
76
|
+
| [number, number]
|
|
77
|
+
)[]
|
|
78
|
+
| (("true" | "false") | number | number | string)[][];
|
|
79
|
+
/**
|
|
80
|
+
* Metadata about the filter that can be used for rendering. For example, this could contain the possible values to filter by and their counts in the results.
|
|
81
|
+
*/
|
|
82
|
+
meta?: RangeFilterMeta | ValuesFilterMeta | HierarchicalValuesFilterMeta;
|
|
83
|
+
/**
|
|
84
|
+
* ID of the filter. If multiple filters share the same ID, they should be grouped together in the UI.
|
|
85
|
+
*/
|
|
86
|
+
id?: string;
|
|
87
|
+
}
|
|
88
|
+
export interface RangeFilterMeta {
|
|
89
|
+
/**
|
|
90
|
+
* Title of the group, where a group consists of all the filters that share an ID.
|
|
91
|
+
*/
|
|
92
|
+
group_title?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Whether the filter group should be expanded by default or not.
|
|
95
|
+
*/
|
|
96
|
+
group_expanded?: boolean;
|
|
97
|
+
type?: "range";
|
|
98
|
+
/**
|
|
99
|
+
* The minimum value that can be selected in the range.
|
|
100
|
+
*/
|
|
101
|
+
min: number;
|
|
102
|
+
/**
|
|
103
|
+
* The maximum value that can be selected in the range.
|
|
104
|
+
*/
|
|
105
|
+
max: number;
|
|
106
|
+
/**
|
|
107
|
+
* The unit of the range values.
|
|
108
|
+
*/
|
|
109
|
+
unit?: string;
|
|
110
|
+
/**
|
|
111
|
+
* The currency of the range values.
|
|
112
|
+
*/
|
|
113
|
+
currency?: string;
|
|
114
|
+
}
|
|
115
|
+
export interface ValuesFilterMeta {
|
|
116
|
+
/**
|
|
117
|
+
* Title of the group, where a group consists of all the filters that share an ID.
|
|
118
|
+
*/
|
|
119
|
+
group_title?: string;
|
|
120
|
+
/**
|
|
121
|
+
* Whether the filter group should be expanded by default or not.
|
|
122
|
+
*/
|
|
123
|
+
group_expanded?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Type of filter.
|
|
126
|
+
*/
|
|
127
|
+
type?: "radio" | "checkbox" | "checkbox-grid";
|
|
128
|
+
/**
|
|
129
|
+
* Selectable values
|
|
130
|
+
*/
|
|
131
|
+
values: (
|
|
132
|
+
| ("true" | "false")
|
|
133
|
+
| number
|
|
134
|
+
| number
|
|
135
|
+
| string
|
|
136
|
+
| [number, number]
|
|
137
|
+
| [number, number]
|
|
138
|
+
| [number, number]
|
|
139
|
+
| [number, number]
|
|
140
|
+
)[];
|
|
141
|
+
/**
|
|
142
|
+
* Counts for values
|
|
143
|
+
*/
|
|
144
|
+
counts?: number[];
|
|
145
|
+
/**
|
|
146
|
+
* Names for values
|
|
147
|
+
*/
|
|
148
|
+
names?: string[];
|
|
149
|
+
}
|
|
150
|
+
export interface HierarchicalValuesFilterMeta {
|
|
151
|
+
/**
|
|
152
|
+
* Title of the group, where a group consists of all the filters that share an ID.
|
|
153
|
+
*/
|
|
154
|
+
group_title?: string;
|
|
155
|
+
/**
|
|
156
|
+
* Whether the filter group should be expanded by default or not.
|
|
157
|
+
*/
|
|
158
|
+
group_expanded?: boolean;
|
|
159
|
+
type?: "checkbox-hierarchical";
|
|
160
|
+
/**
|
|
161
|
+
* Selectable hierarchical values
|
|
162
|
+
*/
|
|
163
|
+
values: (("true" | "false") | number | number | string)[][];
|
|
164
|
+
/**
|
|
165
|
+
* Counts for values
|
|
166
|
+
*/
|
|
167
|
+
counts?: number[];
|
|
168
|
+
/**
|
|
169
|
+
* Names for hierarchical values
|
|
170
|
+
*/
|
|
171
|
+
names?: string[];
|
|
172
|
+
}
|
|
173
|
+
export interface SortModel {
|
|
174
|
+
/**
|
|
175
|
+
* The field to sort by.
|
|
176
|
+
*/
|
|
177
|
+
field: string;
|
|
178
|
+
/**
|
|
179
|
+
* The order to sort by.
|
|
180
|
+
*/
|
|
181
|
+
order: SortingOrder;
|
|
182
|
+
/**
|
|
183
|
+
* Metadata about the sort that can be used for rendering.
|
|
184
|
+
*/
|
|
185
|
+
meta?: SortMeta;
|
|
186
|
+
}
|
|
187
|
+
export interface SortMeta {
|
|
188
|
+
title: string;
|
|
189
|
+
/**
|
|
190
|
+
* Selectable values
|
|
191
|
+
*/
|
|
192
|
+
values?: SortingOrder[];
|
|
193
|
+
/**
|
|
194
|
+
* Names for orders
|
|
195
|
+
*/
|
|
196
|
+
names?: string[];
|
|
197
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
4
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
5
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface ProductListingQueriesRequest {
|
|
9
|
+
tenant: string;
|
|
10
|
+
market: string;
|
|
11
|
+
metadata?: {
|
|
12
|
+
[k: string]: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
4
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
5
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface ProductListingQueriesResponse {
|
|
9
|
+
query_ids?: string[];
|
|
10
|
+
}
|