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

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 (53) hide show
  1. package/__vite-browser-external-CpdIDx9o.mjs +79 -0
  2. package/__vite-browser-external-DDWPeg5L.js +1 -0
  3. package/constants.d.ts +32 -0
  4. package/contexts/contexts/search/Facets.d.ts +5 -0
  5. package/contexts/contexts/search/Products.d.ts +5 -0
  6. package/contexts/contexts/search/Root.d.ts +5 -0
  7. package/contexts/contexts/search/Search.d.ts +5 -0
  8. package/contexts/contexts/search/SuggestedTerms.d.ts +5 -0
  9. package/contexts/contexts/search/TopSearches.d.ts +6 -0
  10. package/contexts/index.d.ts +24 -0
  11. package/data/api/fetchVtex.d.ts +2 -1
  12. package/data/api/search/autoCompleteSuggestions/index.d.ts +11 -0
  13. package/data/api/search/crosseling/index.d.ts +91 -0
  14. package/data/api/search/facets/index.d.ts +4 -0
  15. package/data/api/search/index.d.ts +6 -0
  16. package/data/api/search/product/index.d.ts +3 -0
  17. package/data/api/search/searchFetch.d.ts +3 -0
  18. package/data/api/search/suggestedTerms/index.d.ts +12 -0
  19. package/data/api/search/topSearch/index.d.ts +3 -0
  20. package/data/helpers/search/facets.d.ts +48 -0
  21. package/data/helpers/search/index.d.ts +12 -0
  22. package/data/helpers/search/product/index.d.ts +279 -0
  23. package/data/helpers/search/product/utils/canonical.d.ts +1 -0
  24. package/data/helpers/search/product/utils/enhanceSku.d.ts +9 -0
  25. package/data/helpers/search/product/utils/images.d.ts +7 -0
  26. package/data/helpers/search/product/utils/index.d.ts +8 -0
  27. package/data/helpers/search/product/utils/productStock.d.ts +7 -0
  28. package/data/helpers/search/product/utils/propertyValue.d.ts +20 -0
  29. package/data/helpers/search/product/utils/sanitizeHtml.d.ts +18 -0
  30. package/data/helpers/search/product/utils/sku.d.ts +5 -0
  31. package/data/helpers/search/product/utils/slugify.d.ts +1 -0
  32. package/data/helpers/search/root.d.ts +11 -0
  33. package/data/helpers/search/search.d.ts +7 -0
  34. package/index.js +19 -19
  35. package/index.mjs +4336 -3979
  36. package/index2.js +1 -1
  37. package/index2.mjs +891 -400
  38. package/package.json +1 -1
  39. package/server.d.ts +13 -0
  40. package/types/constants.d.ts +9 -15
  41. package/types/contexts/contexts/plp.d.ts +13 -0
  42. package/types/contexts/contexts/search.d.ts +10 -4
  43. package/types/data/api/index.d.ts +5 -2
  44. package/types/data/api/search/facets/index.d.ts +13 -13
  45. package/types/data/api/search/index.d.ts +25 -12
  46. package/types/data/api/search/product/index.d.ts +1 -8
  47. package/types/data/events/index.d.ts +0 -4
  48. package/types/data/helpers/index.d.ts +9 -1
  49. package/types/global/product/index.d.ts +5 -4
  50. package/types/layout/team-components/AddToCart/index.d.ts +2 -2
  51. package/types/layout/team-components/Sort/index.d.ts +2 -3
  52. package/types/data/api/search/autoCompleteSuggestions/index.d.ts +0 -7
  53. 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.34",
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 };
@@ -1,22 +1,12 @@
1
1
  import { Size } from '@soma-vertical-web/core-components/src/lib/TextField/interfaces';
2
2
  import { EditorState } from 'draft-js';
3
3
  import { CSSProperties } from 'react';
4
+ import { FACET_CROSS_SELLING_MAP, ObjectFitsDefault, PLP_FILTERS_SORT } from '../constants';
4
5
 
5
- export declare const PDPShelfType: readonly ["whosawalsosaw", "whosawalsobought", "whoboughtalsobought", "accessories", "similars", "showtogether", "suggestions"];
6
- export declare const PLP_FILTERS_SORT: {
7
- placeholder: string;
8
- options: {
9
- score_desc: string;
10
- orders_desc: string;
11
- price_desc: string;
12
- price_asc: string;
13
- release_desc: string;
14
- discount_desc: string;
15
- name_asc: string;
16
- };
17
- default_option: string;
18
- };
19
- export declare const ObjectFitsDefault: readonly ["contain", "cover", "fill", "none"];
6
+ export interface CrossSellingFacet {
7
+ key: keyof typeof FACET_CROSS_SELLING_MAP;
8
+ value: string;
9
+ }
20
10
  /**
21
11
  * TODO: remove 'textarea-size' from InputSizes in core-compoennts
22
12
  */
@@ -40,6 +30,7 @@ export type COMPONENT_LISTType = Record<string, string>;
40
30
  export type CREATE_CONTENTType = (jsonData: string) => EditorState;
41
31
  export type EXTENDED_BLOCK_RENDER_MAPType = Immutable.Map<any, any>;
42
32
  export type ICONSType = Record<string, string>;
33
+ export type ITEMS_PER_PAGEType = number;
43
34
  export type FREIGHT_CALCULATIONType = {
44
35
  messages: {
45
36
  [key: string]: string;
@@ -58,6 +49,7 @@ export type MENU_MOB_BTN_SIDEType = 'left' | 'right';
58
49
  export type MENU_INFOType = Record<string, Record<string, string>>;
59
50
  export type MENU_NAVIGATION_BAR_ALLOWEDType = boolean;
60
51
  export type NAME_SPLIT_SYMBOLType = string;
52
+ export type OBJECT_FITS_DEFAULTType = (typeof ObjectFitsDefault)[number];
61
53
  export type PAYMENT_FLAGS_DICTIONARYType = Record<string, string>;
62
54
  export type PAYMENT_FLAGSType = any;
63
55
  export type PDP_INFOType = Record<string, Record<string, string>>;
@@ -67,6 +59,8 @@ export type PLP_FILTERSType = {
67
59
  eventLabel: string;
68
60
  order: number;
69
61
  }[];
62
+ export type PLP_FILTERS_SORTType = typeof PLP_FILTERS_SORT;
63
+ export type PLP_FILTERS_SORT_OPTIONtype = keyof typeof PLP_FILTERS_SORT.options;
70
64
  export type PLP_GRID_SCROLL_BACKType = Record<string, string>;
71
65
  export type PLP_SHOW_VIDEO_ON_PRODUCT_CARDType = boolean;
72
66
  export type PRODUCT_CARD_IMAGE_ASPECT_RATIOType = 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,9 +1,9 @@
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
- import { PLPFilterOption } from '../../layout/team-components/Sort';
6
+ import { ITEMS_PER_PAGEType, PLP_FILTERS_SORT_OPTIONtype } from '../../constants';
7
7
 
8
8
  export interface FacetsContextProps {
9
9
  breadcrumb: BreadCrumbItemLinkProps[];
@@ -13,13 +13,16 @@ export interface FacetsContextProps {
13
13
  selectedFacets: SelectedFacet[];
14
14
  searchParams: FacetsProviderProps['searchParams'];
15
15
  onToggleFacet(value: SelectedFacet): void;
16
- onSort(sort: PLPFilterOption): void;
16
+ onSort(sort: PLP_FILTERS_SORT_OPTIONtype): void;
17
17
  }
18
18
  export interface FacetsProviderProps extends PropsWithChildren, Pick<ProductsProviderProps, 'state' | 'forceUpdate'> {
19
19
  searchParams: {
20
20
  [key: string]: string | string[] | undefined;
21
21
  };
22
22
  }
23
+ export interface FacetsProviderContentProps extends FacetsProviderProps {
24
+ selectedFacets: SelectedFacet[];
25
+ }
23
26
  export interface ProductsContextProps extends ProductSearchResultPage {
24
27
  isLoading: boolean;
25
28
  total: number;
@@ -47,6 +50,9 @@ export interface SearchProviderProps extends PropsWithChildren {
47
50
  state: State;
48
51
  collectionId?: number | null;
49
52
  count?: number;
53
+ CONSTANTS: {
54
+ ITEMS_PER_PAGE: ITEMS_PER_PAGEType;
55
+ };
50
56
  }
51
57
  export interface SearchItem {
52
58
  term: string;
@@ -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,4 +1,4 @@
1
- import { ADD_TO_CARTType, ObjectFitsDefault, TEXTURE_IMAGEType, TOGGLE_STYLE_MODIFIERType, Z_INDEX_WARType, NAME_SPLIT_SYMBOLType } from '../../../constants';
1
+ import { ADD_TO_CARTType, TEXTURE_IMAGEType, TOGGLE_STYLE_MODIFIERType, Z_INDEX_WARType, NAME_SPLIT_SYMBOLType, OBJECT_FITS_DEFAULTType } from '../../../constants';
2
2
  import { CartItemStore } from '../../../contexts/store/cart';
3
3
  import { Dispatch, HTMLAttributes, MutableRefObject, ReactNode, SetStateAction, VideoHTMLAttributes } from 'react';
4
4
 
@@ -76,7 +76,7 @@ export interface TooltipProps extends HTMLAttributes<HTMLDivElement> {
76
76
  Z_INDEX_WAR: Z_INDEX_WARType;
77
77
  }
78
78
  interface MediaObjectFit {
79
- objectFit?: (typeof ObjectFitsDefault)[number];
79
+ objectFit?: OBJECT_FITS_DEFAULTType;
80
80
  }
81
81
  export interface CustomImageProps extends MediaObjectFit, HTMLImageElement {
82
82
  ImgComp: React.ComponentType<any>;
@@ -1,8 +1,7 @@
1
1
  import { ButtonProps } from '@soma-vertical-web/core-components/src/lib/Button/interfaces';
2
- import { PLP_FILTERS_SORT } from '../../../constants';
3
2
  import { Dispatch, HTMLAttributes, ReactNode, SetStateAction } from 'react';
3
+ import { PLP_FILTERS_SORT_OPTIONtype } from '../../../constants';
4
4
 
5
- export type PLPFilterOption = keyof typeof PLP_FILTERS_SORT.options;
6
5
  export type RootProps = HTMLAttributes<HTMLDivElement>;
7
6
  export interface SortButtonProps extends Omit<ButtonProps, 'adornment' | 'iconNameStart' | 'iconNameEnd'> {
8
7
  btnAdornment?: {
@@ -12,7 +11,7 @@ export interface SortButtonProps extends Omit<ButtonProps, 'adornment' | 'iconNa
12
11
  sortListOpen: boolean;
13
12
  }
14
13
  export interface SortProps extends RootProps {
15
- handleSelectValue?: (value?: PLPFilterOption) => void;
14
+ handleSelectValue?: (value?: PLP_FILTERS_SORT_OPTIONtype) => void;
16
15
  sortListOpen: boolean;
17
16
  setSortListOpen: Dispatch<SetStateAction<boolean>>;
18
17
  }
@@ -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
- }