@fast-simon/dashboard-utilities 1.0.98 → 1.0.100

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.
@@ -0,0 +1,28 @@
1
+ import type { SortBy } from "../@types/sortBy";
2
+ import type { Narrow } from "@fast-simon/utilities";
3
+ import { ServerFacet } from "@fast-simon/utilities";
4
+ import { EditorProduct } from "../@types/editorProduct";
5
+ interface LandingPageResponse {
6
+ items: EditorProduct[];
7
+ facets_completed: boolean;
8
+ narrow?: Narrow[];
9
+ p: number;
10
+ total_p: number;
11
+ isp_quick_view_mode: number;
12
+ related_results: boolean;
13
+ total_results: number;
14
+ lp_slug: string;
15
+ title: string;
16
+ facets: ServerFacet[];
17
+ sort_by: SortBy;
18
+ avoid_tag_prefixes?: string;
19
+ }
20
+ export declare const LandingPage: {
21
+ landingPage: ({ uuid, storeID, landingPage, page, sortBy, facets, narrow, productsPerPage, withProductAttributes, searchWithinResultsQuery, type, visualMerchandising, merchandisingRules, idsOnly, }: any) => Promise<{
22
+ data: LandingPageResponse;
23
+ getFacets: () => Promise<import("@fast-simon/utilities").Facet[]>;
24
+ }>;
25
+ landingPageFacetsOnly: ({ uuid, storeID, landingPage, page, narrow, type, productsPerPage, searchWithinResultsQuery, withProductAttributes, visualMerchandising, merchandisingRules }: any) => Promise<import("@fast-simon/utilities").Facet[]>;
26
+ };
27
+ export declare const transformFacetsOnlyData: (r: ServerFacet[], avoidTagPrefixes?: string) => import("@fast-simon/utilities").Facet[];
28
+ export {};
@@ -0,0 +1,86 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { fastSimonGet } from "./API";
11
+ import { FacetsParser } from "@fast-simon/utilities";
12
+ //Todo: change the url back to- import.meta.env.VITE_SERVING_BASE_URL ?? "https://internal-v3joil6oqa-uc.a.run.app/search";
13
+ const BASE_URL = "https://ys1testlpmerch---internal-v3joil6oqa-uc.a.run.app/search";
14
+ export const LandingPage = {
15
+ landingPage: ({ uuid, storeID, landingPage, page = 1, sortBy = "relevency", facets = true, narrow, productsPerPage, withProductAttributes = undefined, searchWithinResultsQuery, type, visualMerchandising, merchandisingRules, idsOnly, }) => __awaiter(void 0, void 0, void 0, function* () {
16
+ const params = {
17
+ UUID: uuid,
18
+ store_id: storeID,
19
+ facets_required: facets ? 1 : 0,
20
+ products_per_page: productsPerPage,
21
+ narrow: JSON.stringify(narrow),
22
+ lp: landingPage,
23
+ page_num: page,
24
+ type: type,
25
+ with_product_attributes: withProductAttributes,
26
+ search_within_search: searchWithinResultsQuery
27
+ ? searchWithinResultsQuery
28
+ : undefined,
29
+ visual_merchandising: type == 0
30
+ ? JSON.stringify(visualMerchandising)
31
+ .replaceAll('"[', "[")
32
+ .replaceAll(']"', "]")
33
+ : undefined,
34
+ m: 1,
35
+ merchandising_rules: type == 1 ? JSON.stringify(merchandisingRules) : undefined,
36
+ ids_only: idsOnly ? 1 : undefined,
37
+ };
38
+ const res = yield fastSimonGet(BASE_URL, "landing_page_editor", params);
39
+ return {
40
+ data: res,
41
+ getFacets: () => __awaiter(void 0, void 0, void 0, function* () {
42
+ return (res === null || res === void 0 ? void 0 : res.facets_completed)
43
+ ? transformFacetsOnlyData(res.facets, res.avoid_tag_prefixes)
44
+ : yield LandingPage.landingPageFacetsOnly({
45
+ uuid,
46
+ storeID,
47
+ landingPage,
48
+ page,
49
+ narrow,
50
+ type,
51
+ productsPerPage,
52
+ searchWithinResultsQuery,
53
+ withProductAttributes,
54
+ visualMerchandising,
55
+ merchandisingRules,
56
+ });
57
+ }),
58
+ };
59
+ }),
60
+ landingPageFacetsOnly: ({ uuid, storeID, landingPage, page = 1, narrow, type, productsPerPage, searchWithinResultsQuery, withProductAttributes = false, visualMerchandising, merchandisingRules }) => __awaiter(void 0, void 0, void 0, function* () {
61
+ const data = yield fastSimonGet(BASE_URL, "landing_page_editor", {
62
+ UUID: uuid,
63
+ store_id: storeID,
64
+ facets_required: 2,
65
+ products_per_page: productsPerPage,
66
+ narrow: JSON.stringify(narrow),
67
+ type: type,
68
+ lp: landingPage,
69
+ page_num: page !== null && page !== void 0 ? page : 1,
70
+ with_product_attributes: withProductAttributes,
71
+ search_within_search: searchWithinResultsQuery
72
+ ? searchWithinResultsQuery
73
+ : undefined,
74
+ visual_merchandising: JSON.stringify(visualMerchandising)
75
+ .replaceAll('"[', "[")
76
+ .replaceAll(']"', "]"),
77
+ merchandising_rules: merchandisingRules
78
+ ? JSON.stringify(merchandisingRules)
79
+ : undefined,
80
+ m: 1,
81
+ });
82
+ return transformFacetsOnlyData(data.facets, data.avoid_tag_prefixes);
83
+ }),
84
+ };
85
+ export const transformFacetsOnlyData = (r, avoidTagPrefixes) => new FacetsParser().parseFacets(r, avoidTagPrefixes ? avoidTagPrefixes.split(",") : []);
86
+ //# sourceMappingURL=landingPageTest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"landingPageTest.js","sourceRoot":"","sources":["../../src/services/landingPageTest.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAM,YAAY,EAAC,MAAM,OAAO,CAAC;AACxC,OAAO,EAAC,YAAY,EAAc,MAAM,uBAAuB,CAAA;AAmD/D,2HAA2H;AAC3H,MAAM,QAAQ,GAAE,kEAAkE,CAAC;AAkBnF,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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E,CAAC;SACP,CACJ,CAAC;QACF,OAAO,uBAAuB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACzE,CAAC,CAAA;CACJ,CAAC;AAEF,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\";\nimport type {Narrow, ServerNarrow} from \"@fast-simon/utilities\";\nimport {API, fastSimonGet} from \"./API\";\nimport {FacetsParser, ServerFacet} from \"@fast-simon/utilities\"\nimport {AncestorCategory} from \"../@types/categories\";\nimport {EditorProduct} from \"../@types/editorProduct\";\ninterface LandingPageRequest {\n uuid: string;\n storeID: string;\n landingPage: string\n type: number\n page?: number\n sortBy?: SortBy\n facets?: boolean\n narrow?: Narrow\n productsPerPage?: number\n withProductAttributes?: boolean\n searchWithinResultsQuery?: string\n idsOnly?: boolean\n}\n\ninterface LandingPageFacetsOnly extends Omit<LandingPageRequest, \"facets\"> {\n avoid_tag_prefixes?: string\n}\n\ninterface LandingPageServerResponseFacetsOnly {\n total_results: number\n term: string\n narrow?: ServerNarrow\n facets_completed: true\n facets: ServerFacet[],\n}\n\ninterface LandingPageServerResponseAll {\n items: EditorProduct[]\n alternatives?: string[]\n facets_completed: boolean\n narrow?: ServerNarrow[]\n p: number\n total_p: number\n total_results: number\n term: string\n lp_slug: string\n title: string\n index_page: number\n banner_html: string\n banner_html_mobile: string\n facets: ServerFacet[]\n sort_by: SortBy\n avoid_tag_prefixes?: string\n cms_number_found?: number\n within_search_results_for?: string,\n ancestor_categories?: AncestorCategory[]\n}\n//Todo: change the url back to- import.meta.env.VITE_SERVING_BASE_URL ?? \"https://internal-v3joil6oqa-uc.a.run.app/search\";\nconst BASE_URL =\"https://ys1testlpmerch---internal-v3joil6oqa-uc.a.run.app/search\";\n\ninterface LandingPageResponse {\n items: EditorProduct[]\n facets_completed: boolean\n narrow?: Narrow[]\n p: number\n total_p: number\n isp_quick_view_mode: number\n related_results: boolean\n total_results: number\n lp_slug: string\n title: string\n facets: ServerFacet[]\n sort_by: SortBy\n avoid_tag_prefixes?: string\n}\n\nexport const LandingPage = {\n landingPage: async ({\n uuid,\n storeID,\n landingPage,\n page = 1,\n sortBy = \"relevency\",\n facets = true,\n narrow,\n productsPerPage,\n withProductAttributes = undefined,\n searchWithinResultsQuery,\n type,\n visualMerchandising,\n merchandisingRules,\n idsOnly,\n }: any) => {\n const params: Record<string, any> = {\n UUID: uuid,\n store_id: storeID,\n facets_required: facets ? 1 : 0,\n products_per_page: productsPerPage,\n narrow: JSON.stringify(narrow),\n lp: landingPage,\n page_num: page,\n type: type,\n with_product_attributes: withProductAttributes,\n search_within_search: searchWithinResultsQuery\n ? searchWithinResultsQuery\n : undefined,\n visual_merchandising:\n type == 0\n ? JSON.stringify(visualMerchandising)\n .replaceAll('\"[', \"[\")\n .replaceAll(']\"', \"]\")\n : undefined,\n m: 1,\n merchandising_rules:\n type == 1 ? JSON.stringify(merchandisingRules) : undefined,\n ids_only: idsOnly ? 1 : undefined,\n };\n const res = await fastSimonGet<LandingPageResponse>(\n BASE_URL,\n \"landing_page_editor\",\n params\n );\n return {\n data: res,\n getFacets: async () =>\n res?.facets_completed\n ? transformFacetsOnlyData(\n res.facets,\n res.avoid_tag_prefixes\n )\n : await LandingPage.landingPageFacetsOnly({\n uuid,\n storeID,\n landingPage,\n page,\n narrow,\n type,\n productsPerPage,\n searchWithinResultsQuery,\n withProductAttributes,\n visualMerchandising,\n merchandisingRules,\n }),\n };\n },\n\n landingPageFacetsOnly: async ({\n uuid,\n storeID,\n landingPage,\n page = 1,\n narrow,\n type,\n productsPerPage,\n searchWithinResultsQuery,\n withProductAttributes = false,\n visualMerchandising,\n merchandisingRules\n }: any) => {\n const data = await fastSimonGet<LandingPageServerResponseAll>(\n BASE_URL,\n \"landing_page_editor\",\n {\n UUID: uuid,\n store_id: storeID,\n facets_required: 2,\n products_per_page: productsPerPage,\n narrow: JSON.stringify(narrow),\n type: type,\n lp: landingPage,\n page_num: page ?? 1,\n with_product_attributes: withProductAttributes,\n search_within_search: searchWithinResultsQuery\n ? searchWithinResultsQuery\n : undefined,\n visual_merchandising:\n JSON.stringify(visualMerchandising)\n .replaceAll('\"[', \"[\")\n .replaceAll(']\"', \"]\"),\n merchandising_rules: merchandisingRules\n ? JSON.stringify(merchandisingRules)\n : undefined,\n m: 1,\n }\n );\n return transformFacetsOnlyData(data.facets, data.avoid_tag_prefixes);\n },\n};\n\nexport const transformFacetsOnlyData = (r: ServerFacet[], avoidTagPrefixes?: string) => new FacetsParser().parseFacets(r, avoidTagPrefixes ? avoidTagPrefixes.split(\",\") : []);"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fast-simon/dashboard-utilities",
3
- "version": "1.0.98",
3
+ "version": "1.0.100",
4
4
  "scripts": {
5
5
  "dev": "vite",
6
6
  "preview": "vite preview",