@fast-simon/dashboard-utilities 1.0.23 → 1.0.24
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.
|
@@ -22,7 +22,7 @@ export declare const LandingPage: {
|
|
|
22
22
|
data: LandingPageResponse;
|
|
23
23
|
getFacets: () => Promise<import("@fast-simon/utilities").Facet[]>;
|
|
24
24
|
}>;
|
|
25
|
-
landingPageFacetsOnly: ({ uuid, storeID, landingPage, page, narrow, type, productsPerPage, searchWithinResultsQuery, withProductAttributes, visualMerchandising, merchandisingRules
|
|
25
|
+
landingPageFacetsOnly: ({ uuid, storeID, landingPage, page, narrow, type, productsPerPage, searchWithinResultsQuery, withProductAttributes, visualMerchandising, merchandisingRules }: any) => Promise<import("@fast-simon/utilities").Facet[]>;
|
|
26
26
|
};
|
|
27
27
|
export declare const transformFacetsOnlyData: (r: ServerFacet[], avoidTagPrefixes?: string) => import("@fast-simon/utilities").Facet[];
|
|
28
28
|
export {};
|
|
@@ -12,29 +12,7 @@ import { FacetsParser } from "@fast-simon/utilities";
|
|
|
12
12
|
// const BASE_URL = import.meta.env.VITE_SERVING_BASE_URL ?? "https://internal-v3joil6oqa-uc.a.run.app/search";
|
|
13
13
|
const BASE_URL = "https://yslp---internal-v3joil6oqa-uc.a.run.app/search";
|
|
14
14
|
export const LandingPage = {
|
|
15
|
-
landingPage: ({ uuid, storeID, landingPage, page = 1, sortBy = "relevency", facets = true, narrow, productsPerPage, withProductAttributes = undefined, searchWithinResultsQuery, type,
|
|
16
|
-
// const narrowParm = narrow ? new NarrowParser().toServerNarrow(narrow) : undefined;
|
|
17
|
-
//
|
|
18
|
-
// const data = await fastSimonGet<LandingPageServerResponseAll>(BASE_URL, 'landing_page_editor', {
|
|
19
|
-
// UUID: uuid,
|
|
20
|
-
// store_id: storeID,
|
|
21
|
-
// facets_required: facets ? 1 : 0,
|
|
22
|
-
// products_per_page: productsPerPage,
|
|
23
|
-
// narrow: JSON.stringify(narrow),
|
|
24
|
-
// lp: landingPage,
|
|
25
|
-
// page_num: page,
|
|
26
|
-
// type: type,
|
|
27
|
-
// // sort_by: sortBy,
|
|
28
|
-
// // with_product_attributes: withProductAttributes || get(ispOptions)?.with_product_attributes,
|
|
29
|
-
// with_product_attributes: withProductAttributes,
|
|
30
|
-
// search_within_search: searchWithinResultsQuery ? searchWithinResultsQuery : undefined,
|
|
31
|
-
// visual_merchandising: !searchWithinResultsQuery && !narrow.length ? JSON.stringify(visualMerchandising).replaceAll('"[', '[').replaceAll(']"', ']') : undefined,
|
|
32
|
-
// // merchandising_editor: 1,
|
|
33
|
-
// // disable_merchandising: 1,
|
|
34
|
-
// // related_search: 1
|
|
35
|
-
// m: 1
|
|
36
|
-
// });
|
|
37
|
-
visualMerchandising, merchandisingRules, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
landingPage: ({ uuid, storeID, landingPage, page = 1, sortBy = "relevency", facets = true, narrow, productsPerPage, withProductAttributes = undefined, searchWithinResultsQuery, type, visualMerchandising, merchandisingRules, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
16
|
const params = {
|
|
39
17
|
UUID: uuid,
|
|
40
18
|
store_id: storeID,
|
|
@@ -44,8 +22,6 @@ export const LandingPage = {
|
|
|
44
22
|
lp: landingPage,
|
|
45
23
|
page_num: page,
|
|
46
24
|
type: type,
|
|
47
|
-
// sort_by: sortBy,
|
|
48
|
-
// with_product_attributes: withProductAttributes || get(ispOptions)?.with_product_attributes,
|
|
49
25
|
with_product_attributes: withProductAttributes,
|
|
50
26
|
search_within_search: searchWithinResultsQuery
|
|
51
27
|
? searchWithinResultsQuery
|
|
@@ -55,18 +31,10 @@ export const LandingPage = {
|
|
|
55
31
|
.replaceAll('"[', "[")
|
|
56
32
|
.replaceAll(']"', "]")
|
|
57
33
|
: undefined,
|
|
58
|
-
// merchandising_editor: 1,
|
|
59
|
-
// disable_merchandising: 1,
|
|
60
|
-
// related_search: 1
|
|
61
34
|
m: 1,
|
|
62
|
-
// merchandising_rules: merchandising_rules ? JSON.stringify(merchandising_rules).replaceAll('"[', '[').replaceAll(']"', ']') : undefined
|
|
63
35
|
merchandising_rules: type == 1 ? JSON.stringify(merchandisingRules) : undefined,
|
|
64
36
|
};
|
|
65
|
-
|
|
66
|
-
// params['last_product'] = lastProduct
|
|
67
|
-
// }
|
|
68
|
-
const res = yield yield fastSimonGet(BASE_URL, "landing_page_editor", params);
|
|
69
|
-
// const res = await API.post<LandingPageResponse>({url: BASE_URL+'/landing_page_editor', data: params, config: {headers: {'content-type': 'text/plain'}}});
|
|
37
|
+
const res = yield fastSimonGet(BASE_URL, "landing_page_editor", params);
|
|
70
38
|
return {
|
|
71
39
|
data: res,
|
|
72
40
|
getFacets: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -87,21 +55,8 @@ export const LandingPage = {
|
|
|
87
55
|
});
|
|
88
56
|
}),
|
|
89
57
|
};
|
|
90
|
-
// return {
|
|
91
|
-
// data: data,
|
|
92
|
-
// getFacets: async () => (data?.facets_completed ? transformFacetsOnlyData(data.facets, data.avoid_tag_prefixes) : await LandingPage.landingPageFacetsOnly({uuid,
|
|
93
|
-
// storeID,
|
|
94
|
-
// landingPage,
|
|
95
|
-
// narrow,
|
|
96
|
-
// type,
|
|
97
|
-
// page,
|
|
98
|
-
// productsPerPage,
|
|
99
|
-
// searchWithinResultsQuery})
|
|
100
|
-
// )
|
|
101
|
-
// }
|
|
102
58
|
}),
|
|
103
|
-
landingPageFacetsOnly: ({ uuid, storeID, landingPage, page = 1, narrow, type, productsPerPage, searchWithinResultsQuery, withProductAttributes = false, visualMerchandising, merchandisingRules
|
|
104
|
-
// }: LandingPageFacetsOnly): Promise<Facet[]> => {
|
|
59
|
+
landingPageFacetsOnly: ({ uuid, storeID, landingPage, page = 1, narrow, type, productsPerPage, searchWithinResultsQuery, withProductAttributes = false, visualMerchandising, merchandisingRules }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
105
60
|
const data = yield fastSimonGet(BASE_URL, "landing_page_editor", {
|
|
106
61
|
UUID: uuid,
|
|
107
62
|
store_id: storeID,
|
|
@@ -111,8 +66,6 @@ export const LandingPage = {
|
|
|
111
66
|
type: type,
|
|
112
67
|
lp: landingPage,
|
|
113
68
|
page_num: page !== null && page !== void 0 ? page : 1,
|
|
114
|
-
// sort_by: sortBy,
|
|
115
|
-
// with_product_attributes: withProductAttributes || get(ispOptions)?.with_product_attributes,
|
|
116
69
|
with_product_attributes: withProductAttributes,
|
|
117
70
|
search_within_search: searchWithinResultsQuery
|
|
118
71
|
? searchWithinResultsQuery
|
|
@@ -130,24 +83,5 @@ export const LandingPage = {
|
|
|
130
83
|
return transformFacetsOnlyData(data.facets, data.avoid_tag_prefixes);
|
|
131
84
|
}),
|
|
132
85
|
};
|
|
133
|
-
// const transformData = (r: LandingPageServerResponseAll): LandingPageResults => ({
|
|
134
|
-
// narrow: r.narrow ? new NarrowParser().toNarrow(r.narrow) : {},
|
|
135
|
-
// sortBy: r.sort_by,
|
|
136
|
-
// totalResults: r.total_results,
|
|
137
|
-
// page: r.p,
|
|
138
|
-
// totalPages: r.total_p,
|
|
139
|
-
// lpSlug: r.lp_slug,
|
|
140
|
-
// // products: ProductParser.parseProducts(r.items),
|
|
141
|
-
// products: r.items,
|
|
142
|
-
// productIDS: r.items.map(product => String(product.id)),
|
|
143
|
-
// facets: new FacetsParser().parseFacets(r.facets, r.avoid_tag_prefixes ? r.avoid_tag_prefixes.split(",") : []),
|
|
144
|
-
// avoidTagPrefixes: r.avoid_tag_prefixes ? r.avoid_tag_prefixes.split(",") : [],
|
|
145
|
-
// bannerHTML: r?.banner_html ?? "",
|
|
146
|
-
// bannerHTMLMobile: r?.banner_html_mobile ?? "",
|
|
147
|
-
// indexPage: r.index_page,
|
|
148
|
-
// title: r.title,
|
|
149
|
-
// sort: r.sort_by,
|
|
150
|
-
// ancestors: new FacetsParser().parseAncestors(r?.ancestor_categories)
|
|
151
|
-
// });
|
|
152
86
|
export const transformFacetsOnlyData = (r, avoidTagPrefixes) => new FacetsParser().parseFacets(r, avoidTagPrefixes ? avoidTagPrefixes.split(",") : []);
|
|
153
87
|
//# sourceMappingURL=landingPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"landingPage.js","sourceRoot":"","sources":["../../src/services/landingPage.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAAC,YAAY,EAAc,MAAM,uBAAuB,CAAA;AAmD/D,+GAA+G;AAC/G,MAAM,QAAQ,GAAG,wDAAwD,CAAA;AAoBzE,MAAM,CAAC,MAAM,WAAW,GAAG;IACvB,WAAW,EAAE,CAAO,EAChB,IAAI,EACJ,OAAO,EACP,WAAW,EACX,IAAI,GAAG,CAAC,EACR,MAAM,GAAG,WAAW,EACpB,MAAM,GAAG,IAAI,EACb,MAAM,EACN,eAAe,EACf,qBAAqB,GAAG,SAAS,EACjC,wBAAwB,EACxB,IAAI,EAAE,4DAA4D;IAClE,qFAAqF;IACrF,EAAE;IACF,mGAAmG;IACnG,kBAAkB;IAClB,yBAAyB;IACzB,uCAAuC;IACvC,0CAA0C;IAC1C,sCAAsC;IACtC,uBAAuB;IACvB,sBAAsB;IACtB,kBAAkB;IAClB,0BAA0B;IAC1B,qGAAqG;IACrG,sDAAsD;IACtD,6FAA6F;IAC7F,uKAAuK;IACvK,kCAAkC;IAClC,mCAAmC;IACnC,2BAA2B;IAC3B,WAAW;IACX,MAAM;IACN,mBAAmB,EACnB,kBAAkB,GAChB,EAAE,EAAE;QACN,MAAM,MAAM,GAAwB;YAChC,IAAI,EAAE,IAAI;YACV,QAAQ,EAAE,OAAO;YACjB,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC/B,iBAAiB,EAAE,eAAe;YAClC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;YAC9B,EAAE,EAAE,WA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AAuB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACzE,CAAC,CAAA;CACJ,CAAC;AAEF,oFAAoF;AAChF,iEAAiE;AACjE,qBAAqB;AACrB,iCAAiC;AACjC,aAAa;AACb,yBAAyB;AACzB,qBAAqB;AACrB,qDAAqD;AACrD,qBAAqB;AACrB,0DAA0D;AAC1D,iHAAiH;AACjH,iFAAiF;AACjF,oCAAoC;AACpC,iDAAiD;AACjD,2BAA2B;AAC3B,kBAAkB;AAClB,mBAAmB;AACnB,uEAAuE;AAC3E,MAAM;AAEN,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAgB,EAAE,gBAAyB,EAAE,EAAE,CAAC,IAAI,YAAY,EAAE,CAAC,WAAW,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC","sourcesContent":["import type {SortBy} from \"../@types/sortBy\";\r\nimport type {Narrow, ServerNarrow} from \"@fast-simon/utilities\";\r\nimport { fastSimonGet } from \"./API\";\r\nimport {FacetsParser, ServerFacet} from \"@fast-simon/utilities\"\r\nimport {AncestorCategory} from \"../@types/categories\";\r\nimport {EditorProduct} from \"../@types/editorProduct\";\r\ninterface LandingPageRequest {\r\n uuid: string;\r\n storeID: string;\r\n landingPage: string\r\n type: number\r\n page?: number\r\n sortBy?: SortBy\r\n facets?: boolean\r\n narrow?: Narrow\r\n productsPerPage?: number\r\n withProductAttributes?: boolean\r\n searchWithinResultsQuery?: string\r\n}\r\n\r\ninterface LandingPageFacetsOnly extends Omit<LandingPageRequest, \"facets\"> {\r\n avoid_tag_prefixes?: string\r\n}\r\n\r\ninterface LandingPageServerResponseFacetsOnly {\r\n total_results: number\r\n term: string\r\n narrow?: ServerNarrow\r\n facets_completed: true\r\n facets: ServerFacet[],\r\n}\r\n\r\ninterface LandingPageServerResponseAll {\r\n items: EditorProduct[]\r\n alternatives?: string[]\r\n facets_completed: boolean\r\n narrow?: ServerNarrow[]\r\n p: number\r\n total_p: number\r\n total_results: number\r\n term: string\r\n lp_slug: string\r\n title: string\r\n index_page: number\r\n banner_html: string\r\n banner_html_mobile: string\r\n facets: ServerFacet[]\r\n sort_by: SortBy\r\n avoid_tag_prefixes?: string\r\n cms_number_found?: number\r\n within_search_results_for?: string,\r\n ancestor_categories?: AncestorCategory[]\r\n}\r\n\r\n// const BASE_URL = import.meta.env.VITE_SERVING_BASE_URL ?? \"https://internal-v3joil6oqa-uc.a.run.app/search\";\r\nconst BASE_URL = \"https://yslp---internal-v3joil6oqa-uc.a.run.app/search\"\r\n\r\ninterface LandingPageResponse {\r\n items: EditorProduct[]\r\n facets_completed: boolean\r\n narrow?: Narrow[]\r\n p: number\r\n total_p: number\r\n isp_quick_view_mode: number\r\n related_results: boolean\r\n total_results: number\r\n lp_slug: string\r\n title: string\r\n facets: ServerFacet[]\r\n sort_by: SortBy\r\n avoid_tag_prefixes?: string\r\n // data: LandingPageResults,\r\n // getFacetsOnly?: () => Promise<Facet[]>\r\n}\r\n\r\nexport const LandingPage = {\r\n landingPage: async ({\r\n uuid,\r\n storeID,\r\n landingPage,\r\n page = 1,\r\n sortBy = \"relevency\",\r\n facets = true,\r\n narrow,\r\n productsPerPage,\r\n withProductAttributes = undefined,\r\n searchWithinResultsQuery,\r\n type, // }: LandingPageRequest): Promise<LandingPageResponse> => {\r\n // const narrowParm = narrow ? new NarrowParser().toServerNarrow(narrow) : undefined;\r\n //\r\n // const data = await fastSimonGet<LandingPageServerResponseAll>(BASE_URL, 'landing_page_editor', {\r\n // UUID: uuid,\r\n // store_id: storeID,\r\n // facets_required: facets ? 1 : 0,\r\n // products_per_page: productsPerPage,\r\n // narrow: JSON.stringify(narrow),\r\n // lp: landingPage,\r\n // page_num: page,\r\n // type: type,\r\n // // sort_by: sortBy,\r\n // // with_product_attributes: withProductAttributes || get(ispOptions)?.with_product_attributes,\r\n // with_product_attributes: withProductAttributes,\r\n // search_within_search: searchWithinResultsQuery ? searchWithinResultsQuery : undefined,\r\n // visual_merchandising: !searchWithinResultsQuery && !narrow.length ? JSON.stringify(visualMerchandising).replaceAll('\"[', '[').replaceAll(']\"', ']') : undefined,\r\n // // merchandising_editor: 1,\r\n // // disable_merchandising: 1,\r\n // // related_search: 1\r\n // m: 1\r\n // });\r\n visualMerchandising,\r\n merchandisingRules,\r\n }: any) => {\r\n const params: Record<string, any> = {\r\n UUID: uuid,\r\n store_id: storeID,\r\n facets_required: facets ? 1 : 0,\r\n products_per_page: productsPerPage,\r\n narrow: JSON.stringify(narrow),\r\n lp: landingPage,\r\n page_num: page,\r\n type: type,\r\n // sort_by: sortBy,\r\n // with_product_attributes: withProductAttributes || get(ispOptions)?.with_product_attributes,\r\n with_product_attributes: withProductAttributes,\r\n search_within_search: searchWithinResultsQuery\r\n ? searchWithinResultsQuery\r\n : undefined,\r\n visual_merchandising:\r\n type == 0\r\n ? JSON.stringify(visualMerchandising)\r\n .replaceAll('\"[', \"[\")\r\n .replaceAll(']\"', \"]\")\r\n : undefined,\r\n // merchandising_editor: 1,\r\n // disable_merchandising: 1,\r\n // related_search: 1\r\n m: 1,\r\n // merchandising_rules: merchandising_rules ? JSON.stringify(merchandising_rules).replaceAll('\"[', '[').replaceAll(']\"', ']') : undefined\r\n merchandising_rules:\r\n type == 1 ? JSON.stringify(merchandisingRules) : undefined,\r\n };\r\n // if(lastProduct) {\r\n // params['last_product'] = lastProduct\r\n // }\r\n const res = await await fastSimonGet<LandingPageResponse>(\r\n BASE_URL,\r\n \"landing_page_editor\",\r\n params\r\n );\r\n // const res = await API.post<LandingPageResponse>({url: BASE_URL+'/landing_page_editor', data: params, config: {headers: {'content-type': 'text/plain'}}});\r\n return {\r\n data: res,\r\n getFacets: async () =>\r\n res?.facets_completed\r\n ? transformFacetsOnlyData(\r\n res.facets,\r\n res.avoid_tag_prefixes\r\n )\r\n : await LandingPage.landingPageFacetsOnly({\r\n uuid,\r\n storeID,\r\n landingPage,\r\n page,\r\n narrow,\r\n type,\r\n productsPerPage,\r\n searchWithinResultsQuery,\r\n withProductAttributes,\r\n visualMerchandising,\r\n merchandisingRules,\r\n }),\r\n };\r\n // return {\r\n // data: data,\r\n // getFacets: async () => (data?.facets_completed ? transformFacetsOnlyData(data.facets, data.avoid_tag_prefixes) : await LandingPage.landingPageFacetsOnly({uuid,\r\n // storeID,\r\n // landingPage,\r\n // narrow,\r\n // type,\r\n // page,\r\n // productsPerPage,\r\n // searchWithinResultsQuery})\r\n // )\r\n // }\r\n },\r\n\r\n landingPageFacetsOnly: async ({\r\n uuid,\r\n storeID,\r\n landingPage,\r\n page = 1,\r\n narrow,\r\n type,\r\n productsPerPage,\r\n searchWithinResultsQuery,\r\n withProductAttributes = false,\r\n visualMerchandising,\r\n merchandisingRules,\r\n }: any) => {\r\n // }: LandingPageFacetsOnly): Promise<Facet[]> => {\r\n\r\n const data = await fastSimonGet<LandingPageServerResponseAll>(\r\n BASE_URL,\r\n \"landing_page_editor\",\r\n {\r\n UUID: uuid,\r\n store_id: storeID,\r\n facets_required: 2,\r\n products_per_page: productsPerPage,\r\n narrow: JSON.stringify(narrow),\r\n type: type,\r\n lp: landingPage,\r\n page_num: page ?? 1,\r\n // sort_by: sortBy,\r\n // with_product_attributes: withProductAttributes || get(ispOptions)?.with_product_attributes,\r\n with_product_attributes: withProductAttributes,\r\n search_within_search: searchWithinResultsQuery\r\n ? searchWithinResultsQuery\r\n : undefined,\r\n visual_merchandising:\r\n type == 0\r\n ? JSON.stringify(visualMerchandising)\r\n .replaceAll('\"[', \"[\")\r\n .replaceAll(']\"', \"]\")\r\n : undefined,\r\n merchandising_rules: merchandisingRules\r\n ? JSON.stringify(merchandisingRules)\r\n : undefined,\r\n m: 1,\r\n }\r\n );\r\n\r\n return transformFacetsOnlyData(data.facets, data.avoid_tag_prefixes);\r\n },\r\n};\r\n\r\n// const transformData = (r: LandingPageServerResponseAll): LandingPageResults => ({\r\n // narrow: r.narrow ? new NarrowParser().toNarrow(r.narrow) : {},\r\n // sortBy: r.sort_by,\r\n // totalResults: r.total_results,\r\n // page: r.p,\r\n // totalPages: r.total_p,\r\n // lpSlug: r.lp_slug,\r\n // // products: ProductParser.parseProducts(r.items),\r\n // products: r.items,\r\n // productIDS: r.items.map(product => String(product.id)),\r\n // facets: new FacetsParser().parseFacets(r.facets, r.avoid_tag_prefixes ? r.avoid_tag_prefixes.split(\",\") : []),\r\n // avoidTagPrefixes: r.avoid_tag_prefixes ? r.avoid_tag_prefixes.split(\",\") : [],\r\n // bannerHTML: r?.banner_html ?? \"\",\r\n // bannerHTMLMobile: r?.banner_html_mobile ?? \"\",\r\n // indexPage: r.index_page,\r\n // title: r.title,\r\n // sort: r.sort_by,\r\n // ancestors: new FacetsParser().parseAncestors(r?.ancestor_categories)\r\n// });\r\n\r\nexport const transformFacetsOnlyData = (r: ServerFacet[], avoidTagPrefixes?: string) => new FacetsParser().parseFacets(r, avoidTagPrefixes ? avoidTagPrefixes.split(\",\") : []);"]}
|
|
1
|
+
{"version":3,"file":"landingPage.js","sourceRoot":"","sources":["../../src/services/landingPage.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAM,YAAY,EAAC,MAAM,OAAO,CAAC;AACxC,OAAO,EAAC,YAAY,EAAc,MAAM,uBAAuB,CAAA;AAmD/D,+GAA+G;AAC/G,MAAM,QAAQ,GAAG,wDAAwD,CAAA;AAkBzE,MAAM,CAAC,MAAM,WAAW,GAAG;IACvB,WAAW,EAAE,CAAO,EAChB,IAAI,EACJ,OAAO,EACP,WAAW,EACX,IAAI,GAAG,CAAC,EACR,MAAM,GAAG,WAAW,EACpB,MAAM,GAAG,IAAI,EACb,MAAM,EACN,eAAe,EACf,qBAAqB,GAAG,SAAS,EACjC,wBAAwB,EACxB,IAAI,EACJ,mBAAmB,EACnB,kBAAkB,GAChB,EAAE,EAAE;QACN,MAAM,MAAM,GAAwB;YAChC,IAAI,EAAE,IAAI;YACV,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,EAAE,CAAC,IAAI,YAAY,EAAE,CAAC,WAAW,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC","sourcesContent":["import type {SortBy} from \"../@types/sortBy\";\r\nimport type {Narrow, ServerNarrow} from \"@fast-simon/utilities\";\r\nimport {API, fastSimonGet} from \"./API\";\r\nimport {FacetsParser, ServerFacet} from \"@fast-simon/utilities\"\r\nimport {AncestorCategory} from \"../@types/categories\";\r\nimport {EditorProduct} from \"../@types/editorProduct\";\r\ninterface LandingPageRequest {\r\n uuid: string;\r\n storeID: string;\r\n landingPage: string\r\n type: number\r\n page?: number\r\n sortBy?: SortBy\r\n facets?: boolean\r\n narrow?: Narrow\r\n productsPerPage?: number\r\n withProductAttributes?: boolean\r\n searchWithinResultsQuery?: string\r\n}\r\n\r\ninterface LandingPageFacetsOnly extends Omit<LandingPageRequest, \"facets\"> {\r\n avoid_tag_prefixes?: string\r\n}\r\n\r\ninterface LandingPageServerResponseFacetsOnly {\r\n total_results: number\r\n term: string\r\n narrow?: ServerNarrow\r\n facets_completed: true\r\n facets: ServerFacet[],\r\n}\r\n\r\ninterface LandingPageServerResponseAll {\r\n items: EditorProduct[]\r\n alternatives?: string[]\r\n facets_completed: boolean\r\n narrow?: ServerNarrow[]\r\n p: number\r\n total_p: number\r\n total_results: number\r\n term: string\r\n lp_slug: string\r\n title: string\r\n index_page: number\r\n banner_html: string\r\n banner_html_mobile: string\r\n facets: ServerFacet[]\r\n sort_by: SortBy\r\n avoid_tag_prefixes?: string\r\n cms_number_found?: number\r\n within_search_results_for?: string,\r\n ancestor_categories?: AncestorCategory[]\r\n}\r\n\r\n// const BASE_URL = import.meta.env.VITE_SERVING_BASE_URL ?? \"https://internal-v3joil6oqa-uc.a.run.app/search\";\r\nconst BASE_URL = \"https://yslp---internal-v3joil6oqa-uc.a.run.app/search\"\r\n\r\ninterface LandingPageResponse {\r\n items: EditorProduct[]\r\n facets_completed: boolean\r\n narrow?: Narrow[]\r\n p: number\r\n total_p: number\r\n isp_quick_view_mode: number\r\n related_results: boolean\r\n total_results: number\r\n lp_slug: string\r\n title: string\r\n facets: ServerFacet[]\r\n sort_by: SortBy\r\n avoid_tag_prefixes?: string\r\n}\r\n\r\nexport const LandingPage = {\r\n landingPage: async ({\r\n uuid,\r\n storeID,\r\n landingPage,\r\n page = 1,\r\n sortBy = \"relevency\",\r\n facets = true,\r\n narrow,\r\n productsPerPage,\r\n withProductAttributes = undefined,\r\n searchWithinResultsQuery,\r\n type,\r\n visualMerchandising,\r\n merchandisingRules,\r\n }: any) => {\r\n const params: Record<string, any> = {\r\n UUID: uuid,\r\n store_id: storeID,\r\n facets_required: facets ? 1 : 0,\r\n products_per_page: productsPerPage,\r\n narrow: JSON.stringify(narrow),\r\n lp: landingPage,\r\n page_num: page,\r\n type: type,\r\n with_product_attributes: withProductAttributes,\r\n search_within_search: searchWithinResultsQuery\r\n ? searchWithinResultsQuery\r\n : undefined,\r\n visual_merchandising:\r\n type == 0\r\n ? JSON.stringify(visualMerchandising)\r\n .replaceAll('\"[', \"[\")\r\n .replaceAll(']\"', \"]\")\r\n : undefined,\r\n m: 1,\r\n merchandising_rules:\r\n type == 1 ? JSON.stringify(merchandisingRules) : undefined,\r\n };\r\n const res = await fastSimonGet<LandingPageResponse>(\r\n BASE_URL,\r\n \"landing_page_editor\",\r\n params\r\n );\r\n return {\r\n data: res,\r\n getFacets: async () =>\r\n res?.facets_completed\r\n ? transformFacetsOnlyData(\r\n res.facets,\r\n res.avoid_tag_prefixes\r\n )\r\n : await LandingPage.landingPageFacetsOnly({\r\n uuid,\r\n storeID,\r\n landingPage,\r\n page,\r\n narrow,\r\n type,\r\n productsPerPage,\r\n searchWithinResultsQuery,\r\n withProductAttributes,\r\n visualMerchandising,\r\n merchandisingRules,\r\n }),\r\n };\r\n },\r\n\r\n landingPageFacetsOnly: async ({\r\n uuid,\r\n storeID,\r\n landingPage,\r\n page = 1,\r\n narrow,\r\n type,\r\n productsPerPage,\r\n searchWithinResultsQuery,\r\n withProductAttributes = false,\r\n visualMerchandising,\r\n merchandisingRules\r\n }: any) => {\r\n const data = await fastSimonGet<LandingPageServerResponseAll>(\r\n BASE_URL,\r\n \"landing_page_editor\",\r\n {\r\n UUID: uuid,\r\n store_id: storeID,\r\n facets_required: 2,\r\n products_per_page: productsPerPage,\r\n narrow: JSON.stringify(narrow),\r\n type: type,\r\n lp: landingPage,\r\n page_num: page ?? 1,\r\n with_product_attributes: withProductAttributes,\r\n search_within_search: searchWithinResultsQuery\r\n ? searchWithinResultsQuery\r\n : undefined,\r\n visual_merchandising:\r\n type == 0\r\n ? JSON.stringify(visualMerchandising)\r\n .replaceAll('\"[', \"[\")\r\n .replaceAll(']\"', \"]\")\r\n : undefined,\r\n merchandising_rules: merchandisingRules\r\n ? JSON.stringify(merchandisingRules)\r\n : undefined,\r\n m: 1,\r\n }\r\n );\r\n return transformFacetsOnlyData(data.facets, data.avoid_tag_prefixes);\r\n },\r\n};\r\n\r\nexport const transformFacetsOnlyData = (r: ServerFacet[], avoidTagPrefixes?: string) => new FacetsParser().parseFacets(r, avoidTagPrefixes ? avoidTagPrefixes.split(\",\") : []);"]}
|