@soma-vertical-web/multi-lib 0.0.32 → 0.0.33

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.
Files changed (39) hide show
  1. package/data/api/fetchVtex.d.ts +2 -1
  2. package/data/api/search/autoCompleteSuggestions/index.d.ts +11 -0
  3. package/data/api/search/crosseling/index.d.ts +95 -0
  4. package/data/api/search/facets/index.d.ts +4 -0
  5. package/data/api/search/index.d.ts +6 -0
  6. package/data/api/search/product/index.d.ts +3 -0
  7. package/data/api/search/searchFetch.d.ts +3 -0
  8. package/data/api/search/suggestedTerms/index.d.ts +12 -0
  9. package/data/api/search/topSearch/index.d.ts +3 -0
  10. package/data/helpers/search/facets.d.ts +48 -0
  11. package/data/helpers/search/index.d.ts +12 -0
  12. package/data/helpers/search/product/index.d.ts +279 -0
  13. package/data/helpers/search/product/utils/canonical.d.ts +1 -0
  14. package/data/helpers/search/product/utils/enhanceSku.d.ts +9 -0
  15. package/data/helpers/search/product/utils/images.d.ts +7 -0
  16. package/data/helpers/search/product/utils/index.d.ts +8 -0
  17. package/data/helpers/search/product/utils/productStock.d.ts +7 -0
  18. package/data/helpers/search/product/utils/propertyValue.d.ts +20 -0
  19. package/data/helpers/search/product/utils/sanitizeHtml.d.ts +18 -0
  20. package/data/helpers/search/product/utils/sku.d.ts +5 -0
  21. package/data/helpers/search/product/utils/slugify.d.ts +1 -0
  22. package/data/helpers/search/root.d.ts +11 -0
  23. package/data/helpers/search/search.d.ts +7 -0
  24. package/index2.js +1 -1
  25. package/index2.mjs +984 -426
  26. package/package.json +1 -1
  27. package/server.d.ts +13 -0
  28. package/types/constants.d.ts +14 -0
  29. package/types/contexts/contexts/plp.d.ts +13 -0
  30. package/types/contexts/contexts/search.d.ts +2 -2
  31. package/types/data/api/index.d.ts +5 -2
  32. package/types/data/api/search/facets/index.d.ts +13 -13
  33. package/types/data/api/search/index.d.ts +25 -12
  34. package/types/data/api/search/product/index.d.ts +1 -8
  35. package/types/data/events/index.d.ts +0 -4
  36. package/types/data/helpers/index.d.ts +9 -1
  37. package/types/global/product/index.d.ts +5 -4
  38. package/types/data/api/search/autoCompleteSuggestions/index.d.ts +0 -7
  39. package/types/data/api/search/suggestedTerms/index.d.ts +0 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soma-vertical-web/multi-lib",
3
- "version": "0.0.32",
3
+ "version": "0.0.33",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
package/server.d.ts CHANGED
@@ -2,12 +2,25 @@ import * as checkout from './data/api/checkout';
2
2
  import * as catalog from './data/api/catalog';
3
3
  import * as catalogHelpers from './data/helpers/catalog';
4
4
  import * as cms from './data/api/cms';
5
+ import * as search from './data/api/search';
5
6
  declare const serverAPIs: {
6
7
  checkout: typeof checkout;
7
8
  catalog: typeof catalog;
8
9
  cms: typeof cms;
10
+ search: typeof search;
9
11
  };
10
12
  declare const serverHelpers: {
11
13
  catalog: typeof catalogHelpers;
14
+ search: {
15
+ parseSearchState: ({ pathname, searchParams }: URL, facets: string[]) => import('./types/data/api/search').State;
16
+ convertSearchParams: (searchParams: {
17
+ [key: string]: string | string[] | undefined;
18
+ }) => URLSearchParams;
19
+ filterNonRootFacets: (selectedFacets: import('./types/data/api/search/facets').SelectedFacet[], base?: string | null) => {
20
+ value: string;
21
+ key: string;
22
+ }[];
23
+ filterNonCategorySelected: (facets: import('./types/data/api/search/facets').Facet[], base?: string | null) => import('./types/data/api/search/facets').Facet<import('./types/data/api/search/facets').FacetValueBoolean | import('./types/data/api/search/facets').FacetValueRange>[];
24
+ };
12
25
  };
13
26
  export { serverAPIs, serverHelpers };
@@ -3,6 +3,18 @@ import { EditorState } from 'draft-js';
3
3
  import { CSSProperties } from 'react';
4
4
 
5
5
  export declare const PDPShelfType: readonly ["whosawalsosaw", "whosawalsobought", "whoboughtalsobought", "accessories", "similars", "showtogether", "suggestions"];
6
+ export declare const FACET_CROSS_SELLING_MAP: {
7
+ readonly buy: "whoboughtalsobought";
8
+ readonly view: "whosawalsosaw";
9
+ readonly similars: "similars";
10
+ readonly viewAndBought: "whosawalsobought";
11
+ readonly accessories: "accessories";
12
+ readonly suggestions: "suggestions";
13
+ };
14
+ export interface CrossSellingFacet {
15
+ key: keyof typeof FACET_CROSS_SELLING_MAP;
16
+ value: string;
17
+ }
6
18
  export declare const PLP_FILTERS_SORT: {
7
19
  placeholder: string;
8
20
  options: {
@@ -16,6 +28,7 @@ export declare const PLP_FILTERS_SORT: {
16
28
  };
17
29
  default_option: string;
18
30
  };
31
+ export declare const SORT_OPTIONS: string[];
19
32
  export declare const ObjectFitsDefault: readonly ["contain", "cover", "fill", "none"];
20
33
  /**
21
34
  * TODO: remove 'textarea-size' from InputSizes in core-compoennts
@@ -40,6 +53,7 @@ export type COMPONENT_LISTType = Record<string, string>;
40
53
  export type CREATE_CONTENTType = (jsonData: string) => EditorState;
41
54
  export type EXTENDED_BLOCK_RENDER_MAPType = Immutable.Map<any, any>;
42
55
  export type ICONSType = Record<string, string>;
56
+ export type ITEMS_PER_PAGEType = number;
43
57
  export type FREIGHT_CALCULATIONType = {
44
58
  messages: {
45
59
  [key: string]: string;
@@ -0,0 +1,13 @@
1
+ export interface Page {
2
+ page: number;
3
+ loading: boolean;
4
+ products: any[];
5
+ pagination: {
6
+ nextPage?: boolean;
7
+ previousPage?: boolean;
8
+ startCursor: string;
9
+ endCursor: string;
10
+ count: number;
11
+ total: number;
12
+ };
13
+ }
@@ -1,7 +1,7 @@
1
1
  import { Dispatch, PropsWithChildren, SetStateAction } from 'react';
2
- import { ProductSearchResultPage, Suggestion } from '../../data/api/search/product';
2
+ import { ProductSearchResultPage } from '../../data/api/search/product';
3
3
  import { BreadCrumbItemLinkProps } from '../../layout/team-components/PDCNavigation/intex';
4
- import { State } from '../../data/api/search';
4
+ import { State, Suggestion } from '../../data/api/search';
5
5
  import { Facet, SelectedFacet } from '../../data/api/search/facets';
6
6
  import { PLPFilterOption } from '../../layout/team-components/Sort';
7
7
 
@@ -4,10 +4,13 @@ export interface FetchOptions {
4
4
  headers?: Record<string, string>;
5
5
  skipSanitize?: boolean;
6
6
  priority?: 'low' | 'auto' | 'high';
7
+ cache?: 'no-store' | 'default' | 'force-cache' | 'only-if-cached';
8
+ abort?: boolean;
9
+ signal?: AbortSignal;
7
10
  }
8
- export interface FetchFunctionsProps<T> {
11
+ export interface FetchFunctionsProps<T, U = any> {
9
12
  apiUrl: string;
10
13
  fetchOptions?: FetchOptions;
11
- extraData?: any;
14
+ extraData?: U;
12
15
  body?: T;
13
16
  }
@@ -1,7 +1,14 @@
1
1
  type FilterType = 'PRICERANGE' | 'TEXT' | 'NUMBER' | 'CATEGORYTREE';
2
- export interface FacetSearchResult {
3
- facets: Facet[];
4
- breadcrumb: Breadcrumb[];
2
+ interface Breadcrumb {
3
+ href: string;
4
+ name: string;
5
+ }
6
+ export interface FacetValueBoolean {
7
+ quantity: number;
8
+ name: string;
9
+ key: string;
10
+ value: string;
11
+ selected: boolean;
5
12
  }
6
13
  type FacetTypeName<T> = T extends FacetValueBoolean ? 'FacetBoolean' : 'FacetRange';
7
14
  export interface Facet<T = FacetValueBoolean | FacetValueRange> {
@@ -13,12 +20,9 @@ export interface Facet<T = FacetValueBoolean | FacetValueRange> {
13
20
  quantity?: number;
14
21
  key: string;
15
22
  }
16
- export interface FacetValueBoolean {
17
- quantity: number;
18
- name: string;
19
- key: string;
20
- value: string;
21
- selected: boolean;
23
+ export interface FacetSearchResult {
24
+ facets: Facet[];
25
+ breadcrumb: Breadcrumb[];
22
26
  }
23
27
  export interface FacetValueRange {
24
28
  quantity: number;
@@ -28,10 +32,6 @@ export interface FacetValueRange {
28
32
  to: number;
29
33
  };
30
34
  }
31
- interface Breadcrumb {
32
- href: string;
33
- name: string;
34
- }
35
35
  export interface SelectedFacet {
36
36
  key: string;
37
37
  value: string;
@@ -1,5 +1,13 @@
1
+ import { FetchFunctionsProps } from '..';
1
2
  import { SelectedFacet } from './facets';
2
3
 
4
+ export interface Search {
5
+ term: string;
6
+ count: number;
7
+ }
8
+ export interface Suggestion {
9
+ searches: Search[];
10
+ }
3
11
  export interface Channel {
4
12
  seller?: string;
5
13
  regionId?: string;
@@ -34,26 +42,25 @@ export type StoreSelectedFacet = {
34
42
  };
35
43
  export type Sort = 'price:desc' | 'price:asc' | 'orders:desc' | 'name:desc' | 'name:asc' | 'release:desc' | 'discount:desc' | '';
36
44
  export declare type SearchSort = 'price_desc' | 'price_asc' | 'orders_desc' | 'name_desc' | 'name_asc' | 'release_desc' | 'discount_desc' | 'score_desc' | '';
37
- export interface SearchArgs {
38
- query?: string;
39
- page: number;
40
- count: number;
41
- type: 'product_search' | 'facets';
42
- sort?: Sort;
43
- facets?: SelectedFacet[];
44
- fuzzy?: '0' | '1' | 'auto';
45
- hideUnavailableItems?: boolean;
46
- forceUpdate?: boolean;
47
- }
48
45
  export interface State {
49
46
  sort: SearchSort;
50
47
  facets: SelectedFacet[];
51
- term: string | null;
48
+ term?: string | null;
52
49
  base: string;
53
50
  page: number;
54
51
  count?: number;
55
52
  query?: string;
56
53
  }
54
+ export interface SearchArgs extends Omit<State, 'sort'> {
55
+ type: 'product_search' | 'facets';
56
+ sort?: Sort;
57
+ fuzzy?: '0' | '1' | 'auto';
58
+ hideUnavailableItems?: boolean;
59
+ }
60
+ export interface SearchAPIBody extends SearchArgs {
61
+ locale?: string;
62
+ }
63
+ export type SearchAPIProps = FetchFunctionsProps<SearchAPIBody>;
57
64
  /**
58
65
  * TODO: Juntar com ProductType_PDC
59
66
  */
@@ -134,3 +141,9 @@ export interface SearchProduct {
134
141
  };
135
142
  };
136
143
  }
144
+ export type GetSearchFacetsResponse = Promise<{
145
+ data: {
146
+ facets: any[];
147
+ [key: string]: any;
148
+ };
149
+ } | undefined>;
@@ -35,13 +35,6 @@ interface Page {
35
35
  export interface First {
36
36
  index: number;
37
37
  }
38
- export interface Suggestion {
39
- searches: Search[];
40
- }
41
- export interface Search {
42
- term: string;
43
- count: number;
44
- }
45
38
  export interface Attachment {
46
39
  name: string;
47
40
  content: Record<string, string>;
@@ -72,6 +65,6 @@ export interface ProductSearchResultPage {
72
65
  products: {
73
66
  cursor: string;
74
67
  node: ProductType_PDC;
75
- }[] | null;
68
+ }[];
76
69
  }
77
70
  export {};
@@ -106,8 +106,4 @@ export type HandleSelectPromotionEventType = {
106
106
  promotion: PromotionType;
107
107
  index?: number;
108
108
  };
109
- export interface SelectedFacet {
110
- key: string;
111
- value: string;
112
- }
113
109
  export {};
@@ -1,5 +1,5 @@
1
1
  import { ItemType_PDP } from '../../global/product';
2
- import { MAIN_IMAGEType, NAME_SPLIT_SYMBOLType, SECOND_IMAGEType } from '../../constants';
2
+ import { MAIN_IMAGEType, NAME_SPLIT_SYMBOLType, SECOND_IMAGEType, TEXTURE_IMAGEType } from '../../constants';
3
3
  import { ProductCardProps } from '../../layout/team-components/ProductCard';
4
4
 
5
5
  export type GetSkuInfosProps = {
@@ -18,3 +18,11 @@ export interface GetFirstImagesProps {
18
18
  second: SECOND_IMAGEType;
19
19
  };
20
20
  }
21
+ export interface SearchCreateProduct {
22
+ MAIN_IMAGE: MAIN_IMAGEType;
23
+ TEXTURE_IMAGE: TEXTURE_IMAGEType;
24
+ }
25
+ export interface SearchCreatePages extends SearchCreateProduct {
26
+ page: number;
27
+ count: number;
28
+ }
@@ -81,6 +81,7 @@ export type CommertialOfferType = {
81
81
  ItemMetadataAttachment: any[];
82
82
  Price: number;
83
83
  ListPrice: number;
84
+ spotPrice: number;
84
85
  PriceWithoutDiscount: number;
85
86
  FullSellingPrice: number;
86
87
  RewardValue: number;
@@ -156,10 +157,7 @@ interface CommonItemType {
156
157
  nameComplete: string;
157
158
  complementName: string;
158
159
  ean: string;
159
- referenceId: Array<{
160
- Key: string;
161
- Value: string;
162
- }>;
160
+ referenceId: ReferenceIdType[];
163
161
  measurementUnit: string;
164
162
  unitMultiplier: number;
165
163
  modalType: any | null;
@@ -408,6 +406,9 @@ export interface ProductType_APISearch extends CommonProductType_PDP_APISearch {
408
406
  value: string;
409
407
  }>;
410
408
  }
409
+ export type ProductType_APISearchNode = {
410
+ node: ProductType_APISearch;
411
+ };
411
412
  export type EnhancedSku_APISearch = ItemType_APISearch & {
412
413
  isVariantOf: ProductType_APISearch;
413
414
  };
@@ -1,7 +0,0 @@
1
- export interface Suggestion {
2
- searches: Search[];
3
- }
4
- export interface Search {
5
- term: string;
6
- count: number;
7
- }
@@ -1,7 +0,0 @@
1
- export interface Suggestion {
2
- searches: Search[];
3
- }
4
- export interface Search {
5
- term: string;
6
- count: number;
7
- }