@depict-ai/ui 3.0.5 → 3.0.7
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 +95 -45
- package/ES10/index.d.ts +12 -4
- package/ES10/index.js +95 -45
- package/latest/index.cjs +90 -44
- package/latest/index.d.ts +12 -4
- package/latest/index.js +90 -44
- package/locales/ES10/index.cjs +12 -12
- package/locales/ES10/index.js +12 -12
- package/locales/latest/index.cjs +12 -12
- package/locales/latest/index.js +12 -12
- package/package.json +4 -4
- package/server/ES10/index.cjs +95 -45
- package/server/ES10/index.d.ts +12 -4
- package/server/ES10/index.js +95 -45
- package/server/latest/index.cjs +90 -44
- package/server/latest/index.d.ts +12 -4
- package/server/latest/index.js +90 -44
- package/locales/require.js +0 -1152
package/ES10/index.cjs
CHANGED
|
@@ -83,7 +83,7 @@ $parcel$export(module.exports, "defaultColsAtSize", () => $33eed84f447aa0c0$expo
|
|
|
83
83
|
$parcel$export(module.exports, "defaultCategoryTitlePlugin", () => $33eed84f447aa0c0$export$7bf543b9d9be2c22);
|
|
84
84
|
$parcel$export(module.exports, "version", () => $aa1938dec50d6c12$export$83d89fbfd8236492);
|
|
85
85
|
/*! Depict.ai search and product listing SDK */
|
|
86
|
-
const $aa1938dec50d6c12$export$83d89fbfd8236492 = "3.0.
|
|
86
|
+
const $aa1938dec50d6c12$export$83d89fbfd8236492 = "3.0.7";
|
|
87
87
|
const $9d19451330d04c3c$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<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>`);
|
|
88
88
|
function $9d19451330d04c3c$export$8be2714ec7f169ee() {
|
|
89
89
|
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -5839,6 +5839,69 @@ function $b3dc12c672c9df24$export$967e966fca9515e(api_response) {
|
|
|
5839
5839
|
// Why not use const enum? See https://gitlab.com/depict-ai/depict.ai/-/merge_requests/9223#note_1675965260
|
|
5840
5840
|
const $c3739e86187f2054$export$74ee7529ce0f8a00 = "listingId";
|
|
5841
5841
|
const $c3739e86187f2054$export$5aae649db1b959fc = "externalId";
|
|
5842
|
+
|
|
5843
|
+
/**
|
|
5844
|
+
* Converts a v3 API response into something that has quick_links and breadcrumbs that behave as in v2 instead of ancestors, children and siblings, but gives every quicklink and breadcrumb's transformer the ancestors of the listing they are for.
|
|
5845
|
+
*/
|
|
5846
|
+
async function $097d688689209955$export$d9792230b7c0203e(_ref) {
|
|
5847
|
+
let {
|
|
5848
|
+
input_data_: {
|
|
5849
|
+
ancestors: ancestors,
|
|
5850
|
+
children: children,
|
|
5851
|
+
siblings: siblings,
|
|
5852
|
+
...clonedInputData
|
|
5853
|
+
},
|
|
5854
|
+
category_transformer_ = v => v.data,
|
|
5855
|
+
merchant_:
|
|
5856
|
+
// in case no display transformer just pass the data through, so we don't break
|
|
5857
|
+
merchant_,
|
|
5858
|
+
market_: market_,
|
|
5859
|
+
locale_: locale_
|
|
5860
|
+
} = _ref;
|
|
5861
|
+
const breadcrumbs = [];
|
|
5862
|
+
const clonedAncestors = [...ancestors];
|
|
5863
|
+
while (clonedAncestors.length) {
|
|
5864
|
+
const ancestor = clonedAncestors.pop();
|
|
5865
|
+
if (!ancestor.show_in_breadcrumbs) continue;
|
|
5866
|
+
breadcrumbs.push({
|
|
5867
|
+
...ancestor,
|
|
5868
|
+
ancestors: [...clonedAncestors]
|
|
5869
|
+
});
|
|
5870
|
+
}
|
|
5871
|
+
breadcrumbs.reverse();
|
|
5872
|
+
const quicklinksIsChildren = children.length;
|
|
5873
|
+
const quickLinks = (quicklinksIsChildren ? children : siblings).filter(_ref2 => {
|
|
5874
|
+
let {
|
|
5875
|
+
show_in_quicklinks: show_in_quicklinks
|
|
5876
|
+
} = _ref2;
|
|
5877
|
+
return show_in_quicklinks;
|
|
5878
|
+
}).map(productListing => {
|
|
5879
|
+
const ancestorsForUs = [...ancestors];
|
|
5880
|
+
if (quicklinksIsChildren) ancestorsForUs.push({
|
|
5881
|
+
...clonedInputData
|
|
5882
|
+
});
|
|
5883
|
+
return {
|
|
5884
|
+
...productListing,
|
|
5885
|
+
ancestors: ancestorsForUs
|
|
5886
|
+
};
|
|
5887
|
+
});
|
|
5888
|
+
const [transformedBreadcrumbs, transformedQuickLinks] = await Promise.all([category_transformer_({
|
|
5889
|
+
merchant: merchant_,
|
|
5890
|
+
market: market_,
|
|
5891
|
+
locale: locale_,
|
|
5892
|
+
data: breadcrumbs
|
|
5893
|
+
}), category_transformer_({
|
|
5894
|
+
merchant: merchant_,
|
|
5895
|
+
market: market_,
|
|
5896
|
+
locale: locale_,
|
|
5897
|
+
data: quickLinks
|
|
5898
|
+
})]);
|
|
5899
|
+
return {
|
|
5900
|
+
...clonedInputData,
|
|
5901
|
+
breadcrumbs: transformedBreadcrumbs,
|
|
5902
|
+
quick_links: transformedQuickLinks
|
|
5903
|
+
};
|
|
5904
|
+
}
|
|
5842
5905
|
function $e270e9f953fcbc58$var$_classPrivateMethodInitSpec(obj, privateSet) {
|
|
5843
5906
|
$e270e9f953fcbc58$var$_checkPrivateRedeclaration(obj, privateSet);
|
|
5844
5907
|
privateSet.add(obj);
|
|
@@ -5866,6 +5929,9 @@ var $e270e9f953fcbc58$var$_run_url_creator_for_suggest = /*#__PURE__*/new WeakSe
|
|
|
5866
5929
|
var $e270e9f953fcbc58$var$_run_display_transformers_for_rest = /*#__PURE__*/new WeakSet();
|
|
5867
5930
|
var $e270e9f953fcbc58$var$_cached_request = /*#__PURE__*/new WeakSet();
|
|
5868
5931
|
class $e270e9f953fcbc58$export$e015ed2f2950f2e3 {
|
|
5932
|
+
/**
|
|
5933
|
+
* rest = everything except query suggestions
|
|
5934
|
+
*/
|
|
5869
5935
|
constructor(options) {
|
|
5870
5936
|
$e270e9f953fcbc58$var$_classPrivateMethodInitSpec(this, $e270e9f953fcbc58$var$_cached_request);
|
|
5871
5937
|
$e270e9f953fcbc58$var$_classPrivateMethodInitSpec(this, $e270e9f953fcbc58$var$_run_display_transformers_for_rest);
|
|
@@ -5922,7 +5988,7 @@ class $e270e9f953fcbc58$export$e015ed2f2950f2e3 {
|
|
|
5922
5988
|
const decoded_json = await results.json();
|
|
5923
5989
|
if (!Array.isArray(decoded_json === null || decoded_json === void 0 ? void 0 : decoded_json.suggestions)) break attempt_to_return_api_response;
|
|
5924
5990
|
try {
|
|
5925
|
-
return await $e270e9f953fcbc58$var$_classPrivateMethodGet(this, $e270e9f953fcbc58$var$_run_url_creator_for_suggest, $e270e9f953fcbc58$var$_run_url_creator_for_suggest2).call(this, input_req.merchant, input_req.market, decoded_json);
|
|
5991
|
+
return await $e270e9f953fcbc58$var$_classPrivateMethodGet(this, $e270e9f953fcbc58$var$_run_url_creator_for_suggest, $e270e9f953fcbc58$var$_run_url_creator_for_suggest2).call(this, input_req.merchant, input_req.market, input_req.locale, decoded_json);
|
|
5926
5992
|
} catch (e) {
|
|
5927
5993
|
$52FdA$depictaiutilishared.dwarn("displayTransformer failed", e);
|
|
5928
5994
|
}
|
|
@@ -5959,13 +6025,12 @@ class $e270e9f953fcbc58$export$e015ed2f2950f2e3 {
|
|
|
5959
6025
|
fallback_response_: () => ({
|
|
5960
6026
|
listing_id: "",
|
|
5961
6027
|
listing_type: "category",
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
"quick_links": [],
|
|
6028
|
+
title: "",
|
|
6029
|
+
slug: "",
|
|
6030
|
+
show_in_breadcrumbs: false,
|
|
6031
|
+
show_in_quicklinks: false,
|
|
6032
|
+
breadcrumbs: [],
|
|
6033
|
+
quick_links: [],
|
|
5969
6034
|
failed: true
|
|
5970
6035
|
}),
|
|
5971
6036
|
method_: "GET"
|
|
@@ -6012,7 +6077,7 @@ function $e270e9f953fcbc58$var$_get_cache_obj_for_endpoint2(endpoint) {
|
|
|
6012
6077
|
})) : undefined
|
|
6013
6078
|
});
|
|
6014
6079
|
}
|
|
6015
|
-
async function $e270e9f953fcbc58$var$_run_url_creator_for_suggest2(merchant, market, response) {
|
|
6080
|
+
async function $e270e9f953fcbc58$var$_run_url_creator_for_suggest2(merchant, market, locale, response) {
|
|
6016
6081
|
var _this$display_transfo;
|
|
6017
6082
|
const category_transformer = (_this$display_transfo = this.display_transformers) === null || _this$display_transfo === void 0 ? void 0 : _this$display_transfo.categories;
|
|
6018
6083
|
if (!category_transformer) return response;
|
|
@@ -6021,12 +6086,13 @@ async function $e270e9f953fcbc58$var$_run_url_creator_for_suggest2(merchant, mar
|
|
|
6021
6086
|
const transformed_category_suggestions = await category_transformer({
|
|
6022
6087
|
market: market,
|
|
6023
6088
|
merchant: merchant,
|
|
6089
|
+
locale: locale,
|
|
6024
6090
|
data: [...category_suggestions]
|
|
6025
6091
|
});
|
|
6026
6092
|
response.suggestions = transformed_category_suggestions;
|
|
6027
6093
|
return response;
|
|
6028
6094
|
}
|
|
6029
|
-
async function $e270e9f953fcbc58$var$_run_display_transformers_for_rest2(merchant, market, input_data) {
|
|
6095
|
+
async function $e270e9f953fcbc58$var$_run_display_transformers_for_rest2(merchant, market, locale, input_data) {
|
|
6030
6096
|
const {
|
|
6031
6097
|
display_transformers: display_transformers
|
|
6032
6098
|
} = this;
|
|
@@ -6042,25 +6108,24 @@ async function $e270e9f953fcbc58$var$_run_display_transformers_for_rest2(merchan
|
|
|
6042
6108
|
const transformed_displays = await product_transformer({
|
|
6043
6109
|
merchant: merchant,
|
|
6044
6110
|
market: market,
|
|
6111
|
+
locale: locale,
|
|
6045
6112
|
displays: [...displays]
|
|
6046
6113
|
});
|
|
6047
6114
|
input_data.displays = transformed_displays;
|
|
6048
6115
|
}
|
|
6049
|
-
if (category_transformer) for (const key of ["breadcrumbs", "quick_links"]) {
|
|
6050
|
-
const category_display_array = input_data[key];
|
|
6051
|
-
if (!category_display_array) continue;
|
|
6052
|
-
const transformed_category_displays = await category_transformer({
|
|
6053
|
-
merchant: merchant,
|
|
6054
|
-
market: market,
|
|
6055
|
-
data: [...category_display_array]
|
|
6056
|
-
});
|
|
6057
|
-
input_data[key] = transformed_category_displays;
|
|
6058
|
-
}
|
|
6059
6116
|
if (content_search_links !== null && content_search_links !== void 0 && content_search_links.length && content_result_transformer) input_data.content_search_links = await content_result_transformer({
|
|
6060
6117
|
merchant: merchant,
|
|
6061
6118
|
market: market,
|
|
6119
|
+
locale: locale,
|
|
6062
6120
|
data: [...content_search_links]
|
|
6063
6121
|
});
|
|
6122
|
+
if (input_data.ancestors) return await $097d688689209955$export$d9792230b7c0203e({
|
|
6123
|
+
input_data_: input_data,
|
|
6124
|
+
category_transformer_: category_transformer,
|
|
6125
|
+
merchant_: merchant,
|
|
6126
|
+
market_: market,
|
|
6127
|
+
locale_: locale
|
|
6128
|
+
});
|
|
6064
6129
|
return input_data;
|
|
6065
6130
|
}
|
|
6066
6131
|
async function $e270e9f953fcbc58$var$_cached_request2(_ref3) {
|
|
@@ -6099,7 +6164,7 @@ async function $e270e9f953fcbc58$var$_cached_request2(_ref3) {
|
|
|
6099
6164
|
let result;
|
|
6100
6165
|
try {
|
|
6101
6166
|
const unmodified_result = await api_response.json();
|
|
6102
|
-
result = await $e270e9f953fcbc58$var$_classPrivateMethodGet(this, $e270e9f953fcbc58$var$_run_display_transformers_for_rest, $e270e9f953fcbc58$var$_run_display_transformers_for_rest2).call(this, input_req_.merchant, input_req_.market, unmodified_result);
|
|
6167
|
+
result = await $e270e9f953fcbc58$var$_classPrivateMethodGet(this, $e270e9f953fcbc58$var$_run_display_transformers_for_rest, $e270e9f953fcbc58$var$_run_display_transformers_for_rest2).call(this, input_req_.merchant, input_req_.market, input_req_.locale, unmodified_result);
|
|
6103
6168
|
} catch (e) {
|
|
6104
6169
|
$52FdA$depictaiutilishared.dwarn("displayTransformer or json decoding failed", e);
|
|
6105
6170
|
break return_successfully;
|
|
@@ -8848,7 +8913,7 @@ function $ede6c70ecdca46fe$export$f7d2f673fc2f091d(_ref) {
|
|
|
8848
8913
|
var _plp_meta;
|
|
8849
8914
|
return (_plp_meta = plp_meta()) === null || _plp_meta === void 0 ? void 0 : _plp_meta.title;
|
|
8850
8915
|
});
|
|
8851
|
-
const crumb_data_ = $ede6c70ecdca46fe$var$add_us_to_crumbs(plp_meta
|
|
8916
|
+
const crumb_data_ = $ede6c70ecdca46fe$var$add_us_to_crumbs(plp_meta);
|
|
8852
8917
|
const quicklinks_data_ = $52FdA$solidjs.createMemo(() => {
|
|
8853
8918
|
var _plp_meta2;
|
|
8854
8919
|
return (_plp_meta2 = plp_meta()) === null || _plp_meta2 === void 0 ? void 0 : _plp_meta2.quick_links;
|
|
@@ -9138,32 +9203,17 @@ function $ede6c70ecdca46fe$export$f7d2f673fc2f091d(_ref) {
|
|
|
9138
9203
|
/**
|
|
9139
9204
|
* Adds the current page as last breadcrumb to the breadcrumb trail
|
|
9140
9205
|
*/
|
|
9141
|
-
function $ede6c70ecdca46fe$var$add_us_to_crumbs(plp_meta
|
|
9206
|
+
function $ede6c70ecdca46fe$var$add_us_to_crumbs(plp_meta) {
|
|
9142
9207
|
const href_accessor = $52FdA$depictaiutilisharedlatest.use_href_accessor();
|
|
9143
9208
|
return $52FdA$solidjs.createMemo(() => {
|
|
9144
9209
|
var _plp_meta3;
|
|
9145
9210
|
const api_value = (_plp_meta3 = plp_meta()) === null || _plp_meta3 === void 0 ? void 0 : _plp_meta3.breadcrumbs;
|
|
9146
9211
|
if (!api_value) return api_value;
|
|
9147
|
-
return [...api_value, {
|
|
9148
|
-
get listing_id() {
|
|
9149
|
-
return plp_meta().listing_id;
|
|
9150
|
-
},
|
|
9151
|
-
get title() {
|
|
9152
|
-
return title();
|
|
9153
|
-
},
|
|
9212
|
+
return [...api_value, $52FdA$solidjs.mergeProps(plp_meta(), {
|
|
9154
9213
|
get page_url() {
|
|
9155
9214
|
return href_accessor();
|
|
9156
|
-
},
|
|
9157
|
-
get slug() {
|
|
9158
|
-
return plp_meta().slug;
|
|
9159
|
-
},
|
|
9160
|
-
get listing_type() {
|
|
9161
|
-
return plp_meta().listing_type;
|
|
9162
|
-
},
|
|
9163
|
-
get external_id() {
|
|
9164
|
-
return plp_meta().external_id;
|
|
9165
9215
|
}
|
|
9166
|
-
}];
|
|
9216
|
+
})];
|
|
9167
9217
|
});
|
|
9168
9218
|
}
|
|
9169
9219
|
function $5dd9d0d3ea82e2dd$export$477caf01aecaeb2a(options) {
|
|
@@ -9854,7 +9904,7 @@ function $3001ad378baf39dc$export$d757d54550ebfb3d(_ref) {
|
|
|
9854
9904
|
} = _ref;
|
|
9855
9905
|
const parentTitle = $52FdA$solidjs.createMemo(() => {
|
|
9856
9906
|
var _category_suggestion_;
|
|
9857
|
-
return (_category_suggestion_ = category_suggestion_().
|
|
9907
|
+
return (_category_suggestion_ = category_suggestion_().ancestors.at(-1)) === null || _category_suggestion_ === void 0 ? void 0 : _category_suggestion_.title;
|
|
9858
9908
|
});
|
|
9859
9909
|
return (() => {
|
|
9860
9910
|
const _el$ = $52FdA$solidjsweb.getNextElement($3001ad378baf39dc$var$_tmpl$2),
|
|
@@ -10745,10 +10795,10 @@ function $0677d509ad208e22$export$e872e2339fb04a7f(_ref) {
|
|
|
10745
10795
|
return ((_read_selected_index_ = read_selected_index_()) === null || _read_selected_index_ === void 0 ? void 0 : _read_selected_index_[0]) === autocomplete_data_index && ((_read_selected_index_2 = read_selected_index_()) === null || _read_selected_index_2 === void 0 ? void 0 : _read_selected_index_2[1]) === index;
|
|
10746
10796
|
});
|
|
10747
10797
|
const parent_title_if_exists = $52FdA$solidjs.createMemo(() => {
|
|
10748
|
-
var _item$
|
|
10798
|
+
var _item$ancestors$at;
|
|
10749
10799
|
const item = input_obj();
|
|
10750
|
-
if (!("
|
|
10751
|
-
return (_item$
|
|
10800
|
+
if (!("ancestors" in item)) return;
|
|
10801
|
+
return (_item$ancestors$at = item.ancestors.at(-1)) === null || _item$ancestors$at === void 0 ? void 0 : _item$ancestors$at.title;
|
|
10752
10802
|
});
|
|
10753
10803
|
return (() => {
|
|
10754
10804
|
const _el$ = $52FdA$solidjsweb.getNextElement($0677d509ad208e22$var$_tmpl$);
|
package/ES10/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ColsAtSize, Display, ModernDisplay, Amazing_Slider, Node_Array, report,
|
|
|
2
2
|
import { JSX, Signal, Accessor, Setter } from "solid-js";
|
|
3
3
|
import { SearchFilter, SortModel, SearchRequestV3 } from "@depict-ai/types/api/SearchRequestV3";
|
|
4
4
|
import { ContentLink, SearchFilter as _SearchFilter1, SearchResponse } from "@depict-ai/types/api/SearchResponse";
|
|
5
|
-
import { ListingSuggestion, SearchSuggestionsResponseV3 } from "@depict-ai/types/api/SearchSuggestionsResponseV3";
|
|
5
|
+
import { Ancestors, ListingSuggestion, SearchSuggestionsResponseV3 } from "@depict-ai/types/api/SearchSuggestionsResponseV3";
|
|
6
6
|
import { ProductListing, GetListingResponse } from "@depict-ai/types/api/GetListingResponse";
|
|
7
7
|
import { ProductListingResponseV3 } from "@depict-ai/types/api/ProductListingResponseV3";
|
|
8
8
|
import { SearchSuggestionsRequestV3 } from "@depict-ai/types/api/SearchSuggestionsRequestV3";
|
|
@@ -10,7 +10,7 @@ import { ProductListingRequestV3 } from "@depict-ai/types/api/ProductListingRequ
|
|
|
10
10
|
import { GetListingRequest } from "@depict-ai/types/api/GetListingRequest";
|
|
11
11
|
import { BaseSearchRequestV3 } from "@depict-ai/types/api/BaseSearchRequestV3";
|
|
12
12
|
import { SearchFilter as _SearchFilter2 } from "@depict-ai/types/api/SearchRequestV2";
|
|
13
|
-
export const version = "3.0.
|
|
13
|
+
export const version = "3.0.7";
|
|
14
14
|
export type SDKColsAtSize = [number, number?][];
|
|
15
15
|
/**
|
|
16
16
|
* Transform SDK ColsAtSize into valid Layout ColsAtSize
|
|
@@ -40,11 +40,15 @@ type AddActualFieldToFilters<T extends SearchFilter[] | undefined> = T extends u
|
|
|
40
40
|
type DisplayTransformerAlwaysThereData = {
|
|
41
41
|
merchant: string;
|
|
42
42
|
market: string;
|
|
43
|
+
locale: string;
|
|
43
44
|
};
|
|
44
45
|
type CanBePromiseWrapped<T> = T | Promise<T>;
|
|
45
46
|
export type ModernDisplayWithPageUrl<T extends ModernDisplay> = { [K in keyof T]: K extends "variant_displays" ? (T[K][number] & {
|
|
46
47
|
page_url: string;
|
|
47
48
|
})[] : T[K] };
|
|
49
|
+
type ProductListingWithAncestors = ProductListing & {
|
|
50
|
+
ancestors: Ancestors;
|
|
51
|
+
};
|
|
48
52
|
/**
|
|
49
53
|
* DisplayTransformers supersede pageURLCreator
|
|
50
54
|
* 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.
|
|
@@ -53,7 +57,7 @@ export type DisplayTransformers<InputDisplay extends ModernDisplay, OutputDispla
|
|
|
53
57
|
products?: (options: DisplayTransformerAlwaysThereData & {
|
|
54
58
|
displays: InputDisplay[];
|
|
55
59
|
}) => CanBePromiseWrapped<OutputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<OutputDisplay>[] : never>;
|
|
56
|
-
categories?: <T extends
|
|
60
|
+
categories?: <T extends ProductListingWithAncestors | ListingSuggestion>(options: DisplayTransformerAlwaysThereData & {
|
|
57
61
|
data: T[];
|
|
58
62
|
}) => CanBePromiseWrapped<(T & {
|
|
59
63
|
page_url: string;
|
|
@@ -825,7 +829,11 @@ type _AddPageUrlToDisplay1<T extends any[]> = (T[number] & {
|
|
|
825
829
|
page_url: string;
|
|
826
830
|
})[];
|
|
827
831
|
type ProductListingResponseAfterDisplayTransformer = { [K in keyof ProductListingResponseV3]: K extends "displays" ? _AddPageUrlToDisplay1<ProductListingResponseV3[K]> : K extends "filters" ? AddActualFieldToFilters<ProductListingResponseV3[K]> : ProductListingResponseV3[K] };
|
|
828
|
-
type GetListingResponseAfterDisplayTransformer = { [K in keyof
|
|
832
|
+
type GetListingResponseAfterDisplayTransformer = { [K in keyof GetListingResponseWithQuicklinksAndBreadcrumbs]: K extends "breadcrumbs" ? ProductListingWithPageURL[] : K extends "quick_links" ? ProductListingWithPageURL[] : GetListingResponseWithQuicklinksAndBreadcrumbs[K] };
|
|
833
|
+
type GetListingResponseWithQuicklinksAndBreadcrumbs = Omit<GetListingResponse, "siblings" | "ancestors" | "children"> & {
|
|
834
|
+
quick_links: ProductListingWithAncestors[];
|
|
835
|
+
breadcrumbs: ProductListingWithAncestors[];
|
|
836
|
+
};
|
|
829
837
|
type DepictAPIConstructorOptions<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = {
|
|
830
838
|
get_metadata?: () => Promise<{
|
|
831
839
|
[k: string]: string;
|
package/ES10/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { createStore as $8tj43$createStore, reconcile as $8tj43$reconcile } from
|
|
|
10
10
|
/*! Depict.ai search and product listing SDK */
|
|
11
11
|
import { register_es_version } from "../multi_import_deduplicator.mjs";
|
|
12
12
|
register_es_version("ui", "ES10");
|
|
13
|
-
const $8db9a15135765c11$export$83d89fbfd8236492 = "3.0.
|
|
13
|
+
const $8db9a15135765c11$export$83d89fbfd8236492 = "3.0.7";
|
|
14
14
|
const $ca6ab5f08bd28bca$var$_tmpl$ = /*#__PURE__*/$8tj43$template(`<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>`);
|
|
15
15
|
function $ca6ab5f08bd28bca$export$8be2714ec7f169ee() {
|
|
16
16
|
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -5766,6 +5766,69 @@ function $ed0fefda39a0f15d$export$967e966fca9515e(api_response) {
|
|
|
5766
5766
|
// Why not use const enum? See https://gitlab.com/depict-ai/depict.ai/-/merge_requests/9223#note_1675965260
|
|
5767
5767
|
const $397620a4d7958ed1$export$74ee7529ce0f8a00 = "listingId";
|
|
5768
5768
|
const $397620a4d7958ed1$export$5aae649db1b959fc = "externalId";
|
|
5769
|
+
|
|
5770
|
+
/**
|
|
5771
|
+
* Converts a v3 API response into something that has quick_links and breadcrumbs that behave as in v2 instead of ancestors, children and siblings, but gives every quicklink and breadcrumb's transformer the ancestors of the listing they are for.
|
|
5772
|
+
*/
|
|
5773
|
+
async function $f454ce4c74ef4dc0$export$d9792230b7c0203e(_ref) {
|
|
5774
|
+
let {
|
|
5775
|
+
input_data_: {
|
|
5776
|
+
ancestors: ancestors,
|
|
5777
|
+
children: children,
|
|
5778
|
+
siblings: siblings,
|
|
5779
|
+
...clonedInputData
|
|
5780
|
+
},
|
|
5781
|
+
category_transformer_ = v => v.data,
|
|
5782
|
+
merchant_:
|
|
5783
|
+
// in case no display transformer just pass the data through, so we don't break
|
|
5784
|
+
merchant_,
|
|
5785
|
+
market_: market_,
|
|
5786
|
+
locale_: locale_
|
|
5787
|
+
} = _ref;
|
|
5788
|
+
const breadcrumbs = [];
|
|
5789
|
+
const clonedAncestors = [...ancestors];
|
|
5790
|
+
while (clonedAncestors.length) {
|
|
5791
|
+
const ancestor = clonedAncestors.pop();
|
|
5792
|
+
if (!ancestor.show_in_breadcrumbs) continue;
|
|
5793
|
+
breadcrumbs.push({
|
|
5794
|
+
...ancestor,
|
|
5795
|
+
ancestors: [...clonedAncestors]
|
|
5796
|
+
});
|
|
5797
|
+
}
|
|
5798
|
+
breadcrumbs.reverse();
|
|
5799
|
+
const quicklinksIsChildren = children.length;
|
|
5800
|
+
const quickLinks = (quicklinksIsChildren ? children : siblings).filter(_ref2 => {
|
|
5801
|
+
let {
|
|
5802
|
+
show_in_quicklinks: show_in_quicklinks
|
|
5803
|
+
} = _ref2;
|
|
5804
|
+
return show_in_quicklinks;
|
|
5805
|
+
}).map(productListing => {
|
|
5806
|
+
const ancestorsForUs = [...ancestors];
|
|
5807
|
+
if (quicklinksIsChildren) ancestorsForUs.push({
|
|
5808
|
+
...clonedInputData
|
|
5809
|
+
});
|
|
5810
|
+
return {
|
|
5811
|
+
...productListing,
|
|
5812
|
+
ancestors: ancestorsForUs
|
|
5813
|
+
};
|
|
5814
|
+
});
|
|
5815
|
+
const [transformedBreadcrumbs, transformedQuickLinks] = await Promise.all([category_transformer_({
|
|
5816
|
+
merchant: merchant_,
|
|
5817
|
+
market: market_,
|
|
5818
|
+
locale: locale_,
|
|
5819
|
+
data: breadcrumbs
|
|
5820
|
+
}), category_transformer_({
|
|
5821
|
+
merchant: merchant_,
|
|
5822
|
+
market: market_,
|
|
5823
|
+
locale: locale_,
|
|
5824
|
+
data: quickLinks
|
|
5825
|
+
})]);
|
|
5826
|
+
return {
|
|
5827
|
+
...clonedInputData,
|
|
5828
|
+
breadcrumbs: transformedBreadcrumbs,
|
|
5829
|
+
quick_links: transformedQuickLinks
|
|
5830
|
+
};
|
|
5831
|
+
}
|
|
5769
5832
|
function $284849364a6ef73a$var$_classPrivateMethodInitSpec(obj, privateSet) {
|
|
5770
5833
|
$284849364a6ef73a$var$_checkPrivateRedeclaration(obj, privateSet);
|
|
5771
5834
|
privateSet.add(obj);
|
|
@@ -5793,6 +5856,9 @@ var $284849364a6ef73a$var$_run_url_creator_for_suggest = /*#__PURE__*/new WeakSe
|
|
|
5793
5856
|
var $284849364a6ef73a$var$_run_display_transformers_for_rest = /*#__PURE__*/new WeakSet();
|
|
5794
5857
|
var $284849364a6ef73a$var$_cached_request = /*#__PURE__*/new WeakSet();
|
|
5795
5858
|
class $284849364a6ef73a$export$e015ed2f2950f2e3 {
|
|
5859
|
+
/**
|
|
5860
|
+
* rest = everything except query suggestions
|
|
5861
|
+
*/
|
|
5796
5862
|
constructor(options) {
|
|
5797
5863
|
$284849364a6ef73a$var$_classPrivateMethodInitSpec(this, $284849364a6ef73a$var$_cached_request);
|
|
5798
5864
|
$284849364a6ef73a$var$_classPrivateMethodInitSpec(this, $284849364a6ef73a$var$_run_display_transformers_for_rest);
|
|
@@ -5849,7 +5915,7 @@ class $284849364a6ef73a$export$e015ed2f2950f2e3 {
|
|
|
5849
5915
|
const decoded_json = await results.json();
|
|
5850
5916
|
if (!Array.isArray(decoded_json === null || decoded_json === void 0 ? void 0 : decoded_json.suggestions)) break attempt_to_return_api_response;
|
|
5851
5917
|
try {
|
|
5852
|
-
return await $284849364a6ef73a$var$_classPrivateMethodGet(this, $284849364a6ef73a$var$_run_url_creator_for_suggest, $284849364a6ef73a$var$_run_url_creator_for_suggest2).call(this, input_req.merchant, input_req.market, decoded_json);
|
|
5918
|
+
return await $284849364a6ef73a$var$_classPrivateMethodGet(this, $284849364a6ef73a$var$_run_url_creator_for_suggest, $284849364a6ef73a$var$_run_url_creator_for_suggest2).call(this, input_req.merchant, input_req.market, input_req.locale, decoded_json);
|
|
5853
5919
|
} catch (e) {
|
|
5854
5920
|
$8tj43$dwarn("displayTransformer failed", e);
|
|
5855
5921
|
}
|
|
@@ -5886,13 +5952,12 @@ class $284849364a6ef73a$export$e015ed2f2950f2e3 {
|
|
|
5886
5952
|
fallback_response_: () => ({
|
|
5887
5953
|
listing_id: "",
|
|
5888
5954
|
listing_type: "category",
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
"quick_links": [],
|
|
5955
|
+
title: "",
|
|
5956
|
+
slug: "",
|
|
5957
|
+
show_in_breadcrumbs: false,
|
|
5958
|
+
show_in_quicklinks: false,
|
|
5959
|
+
breadcrumbs: [],
|
|
5960
|
+
quick_links: [],
|
|
5896
5961
|
failed: true
|
|
5897
5962
|
}),
|
|
5898
5963
|
method_: "GET"
|
|
@@ -5939,7 +6004,7 @@ function $284849364a6ef73a$var$_get_cache_obj_for_endpoint2(endpoint) {
|
|
|
5939
6004
|
})) : undefined
|
|
5940
6005
|
});
|
|
5941
6006
|
}
|
|
5942
|
-
async function $284849364a6ef73a$var$_run_url_creator_for_suggest2(merchant, market, response) {
|
|
6007
|
+
async function $284849364a6ef73a$var$_run_url_creator_for_suggest2(merchant, market, locale, response) {
|
|
5943
6008
|
var _this$display_transfo;
|
|
5944
6009
|
const category_transformer = (_this$display_transfo = this.display_transformers) === null || _this$display_transfo === void 0 ? void 0 : _this$display_transfo.categories;
|
|
5945
6010
|
if (!category_transformer) return response;
|
|
@@ -5948,12 +6013,13 @@ async function $284849364a6ef73a$var$_run_url_creator_for_suggest2(merchant, mar
|
|
|
5948
6013
|
const transformed_category_suggestions = await category_transformer({
|
|
5949
6014
|
market: market,
|
|
5950
6015
|
merchant: merchant,
|
|
6016
|
+
locale: locale,
|
|
5951
6017
|
data: [...category_suggestions]
|
|
5952
6018
|
});
|
|
5953
6019
|
response.suggestions = transformed_category_suggestions;
|
|
5954
6020
|
return response;
|
|
5955
6021
|
}
|
|
5956
|
-
async function $284849364a6ef73a$var$_run_display_transformers_for_rest2(merchant, market, input_data) {
|
|
6022
|
+
async function $284849364a6ef73a$var$_run_display_transformers_for_rest2(merchant, market, locale, input_data) {
|
|
5957
6023
|
const {
|
|
5958
6024
|
display_transformers: display_transformers
|
|
5959
6025
|
} = this;
|
|
@@ -5969,25 +6035,24 @@ async function $284849364a6ef73a$var$_run_display_transformers_for_rest2(merchan
|
|
|
5969
6035
|
const transformed_displays = await product_transformer({
|
|
5970
6036
|
merchant: merchant,
|
|
5971
6037
|
market: market,
|
|
6038
|
+
locale: locale,
|
|
5972
6039
|
displays: [...displays]
|
|
5973
6040
|
});
|
|
5974
6041
|
input_data.displays = transformed_displays;
|
|
5975
6042
|
}
|
|
5976
|
-
if (category_transformer) for (const key of ["breadcrumbs", "quick_links"]) {
|
|
5977
|
-
const category_display_array = input_data[key];
|
|
5978
|
-
if (!category_display_array) continue;
|
|
5979
|
-
const transformed_category_displays = await category_transformer({
|
|
5980
|
-
merchant: merchant,
|
|
5981
|
-
market: market,
|
|
5982
|
-
data: [...category_display_array]
|
|
5983
|
-
});
|
|
5984
|
-
input_data[key] = transformed_category_displays;
|
|
5985
|
-
}
|
|
5986
6043
|
if (content_search_links !== null && content_search_links !== void 0 && content_search_links.length && content_result_transformer) input_data.content_search_links = await content_result_transformer({
|
|
5987
6044
|
merchant: merchant,
|
|
5988
6045
|
market: market,
|
|
6046
|
+
locale: locale,
|
|
5989
6047
|
data: [...content_search_links]
|
|
5990
6048
|
});
|
|
6049
|
+
if (input_data.ancestors) return await $f454ce4c74ef4dc0$export$d9792230b7c0203e({
|
|
6050
|
+
input_data_: input_data,
|
|
6051
|
+
category_transformer_: category_transformer,
|
|
6052
|
+
merchant_: merchant,
|
|
6053
|
+
market_: market,
|
|
6054
|
+
locale_: locale
|
|
6055
|
+
});
|
|
5991
6056
|
return input_data;
|
|
5992
6057
|
}
|
|
5993
6058
|
async function $284849364a6ef73a$var$_cached_request2(_ref3) {
|
|
@@ -6026,7 +6091,7 @@ async function $284849364a6ef73a$var$_cached_request2(_ref3) {
|
|
|
6026
6091
|
let result;
|
|
6027
6092
|
try {
|
|
6028
6093
|
const unmodified_result = await api_response.json();
|
|
6029
|
-
result = await $284849364a6ef73a$var$_classPrivateMethodGet(this, $284849364a6ef73a$var$_run_display_transformers_for_rest, $284849364a6ef73a$var$_run_display_transformers_for_rest2).call(this, input_req_.merchant, input_req_.market, unmodified_result);
|
|
6094
|
+
result = await $284849364a6ef73a$var$_classPrivateMethodGet(this, $284849364a6ef73a$var$_run_display_transformers_for_rest, $284849364a6ef73a$var$_run_display_transformers_for_rest2).call(this, input_req_.merchant, input_req_.market, input_req_.locale, unmodified_result);
|
|
6030
6095
|
} catch (e) {
|
|
6031
6096
|
$8tj43$dwarn("displayTransformer or json decoding failed", e);
|
|
6032
6097
|
break return_successfully;
|
|
@@ -8775,7 +8840,7 @@ function $4b4b262708b516ee$export$f7d2f673fc2f091d(_ref) {
|
|
|
8775
8840
|
var _plp_meta;
|
|
8776
8841
|
return (_plp_meta = plp_meta()) === null || _plp_meta === void 0 ? void 0 : _plp_meta.title;
|
|
8777
8842
|
});
|
|
8778
|
-
const crumb_data_ = $4b4b262708b516ee$var$add_us_to_crumbs(plp_meta
|
|
8843
|
+
const crumb_data_ = $4b4b262708b516ee$var$add_us_to_crumbs(plp_meta);
|
|
8779
8844
|
const quicklinks_data_ = $8tj43$createMemo(() => {
|
|
8780
8845
|
var _plp_meta2;
|
|
8781
8846
|
return (_plp_meta2 = plp_meta()) === null || _plp_meta2 === void 0 ? void 0 : _plp_meta2.quick_links;
|
|
@@ -9065,32 +9130,17 @@ function $4b4b262708b516ee$export$f7d2f673fc2f091d(_ref) {
|
|
|
9065
9130
|
/**
|
|
9066
9131
|
* Adds the current page as last breadcrumb to the breadcrumb trail
|
|
9067
9132
|
*/
|
|
9068
|
-
function $4b4b262708b516ee$var$add_us_to_crumbs(plp_meta
|
|
9133
|
+
function $4b4b262708b516ee$var$add_us_to_crumbs(plp_meta) {
|
|
9069
9134
|
const href_accessor = $8tj43$use_href_accessor();
|
|
9070
9135
|
return $8tj43$createMemo(() => {
|
|
9071
9136
|
var _plp_meta3;
|
|
9072
9137
|
const api_value = (_plp_meta3 = plp_meta()) === null || _plp_meta3 === void 0 ? void 0 : _plp_meta3.breadcrumbs;
|
|
9073
9138
|
if (!api_value) return api_value;
|
|
9074
|
-
return [...api_value, {
|
|
9075
|
-
get listing_id() {
|
|
9076
|
-
return plp_meta().listing_id;
|
|
9077
|
-
},
|
|
9078
|
-
get title() {
|
|
9079
|
-
return title();
|
|
9080
|
-
},
|
|
9139
|
+
return [...api_value, $8tj43$mergeProps1(plp_meta(), {
|
|
9081
9140
|
get page_url() {
|
|
9082
9141
|
return href_accessor();
|
|
9083
|
-
},
|
|
9084
|
-
get slug() {
|
|
9085
|
-
return plp_meta().slug;
|
|
9086
|
-
},
|
|
9087
|
-
get listing_type() {
|
|
9088
|
-
return plp_meta().listing_type;
|
|
9089
|
-
},
|
|
9090
|
-
get external_id() {
|
|
9091
|
-
return plp_meta().external_id;
|
|
9092
9142
|
}
|
|
9093
|
-
}];
|
|
9143
|
+
})];
|
|
9094
9144
|
});
|
|
9095
9145
|
}
|
|
9096
9146
|
function $9d3d794b62318ecc$export$477caf01aecaeb2a(options) {
|
|
@@ -9781,7 +9831,7 @@ function $dea31647b99a443b$export$d757d54550ebfb3d(_ref) {
|
|
|
9781
9831
|
} = _ref;
|
|
9782
9832
|
const parentTitle = $8tj43$createMemo(() => {
|
|
9783
9833
|
var _category_suggestion_;
|
|
9784
|
-
return (_category_suggestion_ = category_suggestion_().
|
|
9834
|
+
return (_category_suggestion_ = category_suggestion_().ancestors.at(-1)) === null || _category_suggestion_ === void 0 ? void 0 : _category_suggestion_.title;
|
|
9785
9835
|
});
|
|
9786
9836
|
return (() => {
|
|
9787
9837
|
const _el$ = $8tj43$getNextElement($dea31647b99a443b$var$_tmpl$2),
|
|
@@ -10672,10 +10722,10 @@ function $40dd3f46f55d62ba$export$e872e2339fb04a7f(_ref) {
|
|
|
10672
10722
|
return ((_read_selected_index_ = read_selected_index_()) === null || _read_selected_index_ === void 0 ? void 0 : _read_selected_index_[0]) === autocomplete_data_index && ((_read_selected_index_2 = read_selected_index_()) === null || _read_selected_index_2 === void 0 ? void 0 : _read_selected_index_2[1]) === index;
|
|
10673
10723
|
});
|
|
10674
10724
|
const parent_title_if_exists = $8tj43$createMemo(() => {
|
|
10675
|
-
var _item$
|
|
10725
|
+
var _item$ancestors$at;
|
|
10676
10726
|
const item = input_obj();
|
|
10677
|
-
if (!("
|
|
10678
|
-
return (_item$
|
|
10727
|
+
if (!("ancestors" in item)) return;
|
|
10728
|
+
return (_item$ancestors$at = item.ancestors.at(-1)) === null || _item$ancestors$at === void 0 ? void 0 : _item$ancestors$at.title;
|
|
10679
10729
|
});
|
|
10680
10730
|
return (() => {
|
|
10681
10731
|
const _el$ = $8tj43$getNextElement($40dd3f46f55d62ba$var$_tmpl$);
|