@usereactify/search 2.1.0-beta.6 → 3.0.0-beta.0

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 (49) hide show
  1. package/README.md +0 -3
  2. package/dist/filter/Filter.d.ts +1 -1
  3. package/dist/filter/FilterStack.d.ts +1 -1
  4. package/dist/hooks/index.d.ts +0 -2
  5. package/dist/hooks/index.js +0 -2
  6. package/dist/hooks/reactivesearch/useReactiveBaseProps.d.ts +1 -1
  7. package/dist/hooks/reactivesearch/useReactiveDataSearchProps.js +0 -8
  8. package/dist/hooks/reactivesearch/useReactiveFilterListProps.d.ts +1 -1
  9. package/dist/hooks/reactivesearch/useReactiveResultListProps.d.ts +0 -1
  10. package/dist/hooks/reactivesearch/useReactiveResultListProps.js +3 -3
  11. package/dist/hooks/useCollection.d.ts +1 -1
  12. package/dist/hooks/useFilterCollapsedState.d.ts +1 -1
  13. package/dist/hooks/useFilterListProps.d.ts +2 -1
  14. package/dist/hooks/useFilters.d.ts +1 -1
  15. package/dist/hooks/usePages.d.ts +1 -1
  16. package/dist/hooks/usePages.js +2 -7
  17. package/dist/hooks/useProductPrice.d.ts +2 -2
  18. package/dist/index.d.ts +3 -1
  19. package/dist/index.js +3 -1
  20. package/dist/provider.d.ts +34 -7
  21. package/dist/provider.js +1 -3
  22. package/dist/result/ResultCard.d.ts +2 -2
  23. package/dist/result/ResultCard.js +3 -16
  24. package/dist/result/ResultCardCallout.d.ts +2 -2
  25. package/dist/result/ResultCardCallout.js +2 -2
  26. package/dist/result/ResultList.d.ts +4 -7
  27. package/dist/result/ResultList.js +9 -20
  28. package/dist/result/ResultLoadMoreButton.d.ts +1 -1
  29. package/dist/result/ResultPagination.d.ts +1 -1
  30. package/dist/result/ResultPaginationNextPrev.d.ts +1 -1
  31. package/dist/result/ResultStateProvider.d.ts +1 -1
  32. package/dist/types/config.d.ts +17 -122
  33. package/dist/types/elastic.d.ts +209 -0
  34. package/dist/types/elastic.js +18 -0
  35. package/dist/types/firestore.d.ts +276 -0
  36. package/dist/types/firestore.js +18 -0
  37. package/dist/types/graphql.d.ts +26545 -0
  38. package/dist/types/graphql.js +4687 -0
  39. package/dist/types/{index.d.ts → reactivesearch.d.ts} +5 -11
  40. package/dist/types/{results.js → reactivesearch.js} +0 -0
  41. package/dist/types/shopify.d.ts +21 -0
  42. package/dist/types/shopify.js +27 -0
  43. package/package.json +1 -3
  44. package/dist/hooks/useAnalytics.d.ts +0 -28
  45. package/dist/hooks/useAnalytics.js +0 -45
  46. package/dist/hooks/useCombinedResults.d.ts +0 -7
  47. package/dist/hooks/useCombinedResults.js +0 -25
  48. package/dist/types/index.js +0 -14
  49. package/dist/types/results.d.ts +0 -48
@@ -1,6 +1,4 @@
1
- export * from "./config";
2
- export * from "./results";
3
- import { Hit, Product } from "./results";
1
+ import { ElasticDocument, ElasticHit } from "./elastic";
4
2
  export interface ReactivesearchFilterProps {
5
3
  loading: boolean;
6
4
  error: Error | null;
@@ -20,10 +18,10 @@ export interface ReactivesearchPaginationProps {
20
18
  currentPage: number;
21
19
  setPage: (page: number) => void;
22
20
  }
23
- export interface ReactivesearchResultProps<T = Product> {
21
+ export interface ReactivesearchResultProps {
24
22
  error?: ReactivesearchError;
25
23
  loading: boolean;
26
- data: (Hit & T)[];
24
+ data: (Omit<ElasticHit, "_source"> & ElasticDocument)[];
27
25
  loadMore: () => void;
28
26
  customData: unknown;
29
27
  promotedData: unknown;
@@ -38,9 +36,7 @@ export interface ReactivesearchResultProps<T = Product> {
38
36
  took: number;
39
37
  status: number;
40
38
  timed_out: boolean;
41
- hits: Hit & {
42
- _source: T;
43
- };
39
+ hits: ElasticHit[];
44
40
  };
45
41
  resultStats: {
46
42
  time: number;
@@ -61,9 +57,7 @@ export interface ReactivesearchSearchStatePage {
61
57
  hidden: number;
62
58
  time: number;
63
59
  total: number;
64
- hits: Hit & {
65
- _source: Product;
66
- };
60
+ hits: ElasticHit[];
67
61
  };
68
62
  resultStats: {
69
63
  hidden: number;
File without changes
@@ -0,0 +1,21 @@
1
+ import { ProductQuery, BulkQueryProductsQuery } from "./graphql";
2
+ export declare type ShopifyProduct = NonNullable<ProductQuery["product"]>;
3
+ export declare type ShopifyVariant = ShopifyProduct["variants"]["edges"][0]["node"];
4
+ export declare type BulkShopifyProduct = BulkQueryProductsQuery["products"]["edges"][0]["node"];
5
+ export declare type BulkShopifyVariant = BulkShopifyProduct["variants"]["edges"][0]["node"];
6
+ export declare type ShopifyExportProduct = Omit<BulkShopifyProduct, "variants" | "images" | "media" | "metafields">;
7
+ export declare type ShopifyExportProductVariant = Omit<BulkShopifyVariant, "presentmentPrices">;
8
+ export declare type ShopifyExportPresentmentPrice = BulkShopifyVariant["presentmentPrices"]["edges"][0]["node"];
9
+ export declare type ShopifyExportImage = BulkShopifyProduct["images"]["edges"][0]["node"];
10
+ export declare type ShopifyExportMedia = BulkShopifyProduct["media"]["edges"][0]["node"];
11
+ export declare type ShopifyExportMetafield = BulkShopifyProduct["metafields"]["edges"][0]["node"];
12
+ export interface ShopifyExportLine {
13
+ __parentId?: string;
14
+ __typename: string;
15
+ }
16
+ export declare function isProduct(exportLine: ShopifyExportLine): exportLine is ShopifyExportProduct;
17
+ export declare function isProductVariant(exportLine: ShopifyExportLine): exportLine is ShopifyExportProductVariant;
18
+ export declare function isPresentmentPrice(exportLine: ShopifyExportLine): exportLine is ShopifyExportPresentmentPrice;
19
+ export declare function isImage(exportLine: ShopifyExportLine): exportLine is ShopifyExportImage;
20
+ export declare function isMedia(exportLine: ShopifyExportLine): exportLine is ShopifyExportMedia;
21
+ export declare function isMetafield(exportLine: ShopifyExportLine): exportLine is ShopifyExportMetafield;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isMetafield = exports.isMedia = exports.isImage = exports.isPresentmentPrice = exports.isProductVariant = exports.isProduct = void 0;
4
+ function isProduct(exportLine) {
5
+ return "Product" === exportLine.__typename;
6
+ }
7
+ exports.isProduct = isProduct;
8
+ function isProductVariant(exportLine) {
9
+ return "ProductVariant" === exportLine.__typename;
10
+ }
11
+ exports.isProductVariant = isProductVariant;
12
+ function isPresentmentPrice(exportLine) {
13
+ return "ProductVariantPricePair" === exportLine.__typename;
14
+ }
15
+ exports.isPresentmentPrice = isPresentmentPrice;
16
+ function isImage(exportLine) {
17
+ return "Image" === exportLine.__typename;
18
+ }
19
+ exports.isImage = isImage;
20
+ function isMedia(exportLine) {
21
+ return ["Video", "Model3d", "MediaImage", "ExternalVideo"].includes(exportLine.__typename);
22
+ }
23
+ exports.isMedia = isMedia;
24
+ function isMetafield(exportLine) {
25
+ return "Metafield" === exportLine.__typename;
26
+ }
27
+ exports.isMetafield = isMetafield;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@usereactify/search",
3
3
  "description": "React UI library for Reactify Search",
4
- "version": "2.1.0-beta.6",
4
+ "version": "3.0.0-beta.0",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -30,7 +30,6 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "ahooks": "2.10.11",
33
- "axios": "0.25.0",
34
33
  "currency.js": "2.0.4",
35
34
  "debug": "4.3.2"
36
35
  },
@@ -46,7 +45,6 @@
46
45
  "@storybook/addon-essentials": "6.3.10",
47
46
  "@storybook/addon-links": "6.3.10",
48
47
  "@storybook/react": "6.3.10",
49
- "@types/axios": "0.14.0",
50
48
  "@types/debug": "4.1.7",
51
49
  "@types/react": "17.0.27",
52
50
  "babel-loader": "8.2.2",
@@ -1,28 +0,0 @@
1
- export declare const useAnalytics: () => {
2
- track: (event: TrackEvent) => Promise<void>;
3
- };
4
- export declare type TrackEvent = TrackEvent.SearchEvent | TrackEvent.ClickProductEvent;
5
- export declare namespace TrackEvent {
6
- interface SearchEvent {
7
- eventName: "search";
8
- payload: SearchEvent.Payload;
9
- }
10
- namespace SearchEvent {
11
- interface Payload {
12
- searchTerm: string;
13
- }
14
- }
15
- interface ClickProductEvent {
16
- eventName: "clickProduct";
17
- payload: ClickProductEvent.Payload;
18
- }
19
- namespace ClickProductEvent {
20
- interface Payload {
21
- elasticProduct: ElasticProduct;
22
- }
23
- }
24
- interface ElasticProduct {
25
- id: number;
26
- title: string;
27
- }
28
- }
@@ -1,45 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.useAnalytics = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
- const provider_1 = require("../provider");
9
- const useAnalytics = () => {
10
- const { shopName } = (0, provider_1.useContext)();
11
- const url = "https://analytics.search.reactify.app/record/";
12
- const track = (event) => {
13
- const events = getTrackEvents(event);
14
- return axios_1.default
15
- .post(url, { events }, { headers: { "X-Reactify-Tenant": shopName || "test shop name" } })
16
- .then((response) => {
17
- console.log(response);
18
- });
19
- };
20
- return { track };
21
- };
22
- exports.useAnalytics = useAnalytics;
23
- function getTrackEvents(event) {
24
- const { eventName } = event;
25
- let events = [];
26
- switch (eventName) {
27
- case "search":
28
- events = [
29
- {
30
- eventName,
31
- payload: event.payload,
32
- },
33
- ];
34
- break;
35
- case "clickProduct":
36
- events = [
37
- {
38
- eventName,
39
- payload: event.payload,
40
- },
41
- ];
42
- break;
43
- }
44
- return events;
45
- }
@@ -1,7 +0,0 @@
1
- import { ConfigCallout, ResultCombined, ReactivesearchResultProps } from "../types";
2
- interface Props {
3
- callouts: ConfigCallout[];
4
- products: ReactivesearchResultProps["data"];
5
- }
6
- export declare const useCombinedResults: ({ callouts, products }: Props) => ResultCombined[];
7
- export {};
@@ -1,25 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.useCombinedResults = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const useCombinedResults = ({ callouts, products }) => react_1.default.useMemo(() => {
9
- const combinedResults = [];
10
- let n = 0;
11
- for (const product of products) {
12
- // search for a callout in this position
13
- const callout = callouts.find((callout) => n === callout.position);
14
- if (callout)
15
- combinedResults.push({ type: "callout", data: callout });
16
- combinedResults.push({ type: "product", data: product });
17
- n++;
18
- }
19
- // add a trailing callout if available
20
- const callout = callouts.find((callout) => n === callout.position);
21
- if (callout)
22
- combinedResults.push({ type: "callout", data: callout });
23
- return combinedResults;
24
- }, [callouts, products]);
25
- exports.useCombinedResults = useCombinedResults;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./config"), exports);
14
- __exportStar(require("./results"), exports);
@@ -1,48 +0,0 @@
1
- import { ConfigCallout } from "./config";
2
- export interface Collection {
3
- id: number;
4
- handle: string;
5
- title: string;
6
- }
7
- export interface Product {
8
- id: number;
9
- title: string;
10
- handle: string;
11
- vendor: string;
12
- tags: string[];
13
- image: string;
14
- variants: Variant[];
15
- images: ProductImage[];
16
- }
17
- export interface ProductImage {
18
- id: number;
19
- alt: string;
20
- src: string;
21
- }
22
- export interface Variant {
23
- sku: string;
24
- title: string;
25
- available: boolean;
26
- presentment_prices: {
27
- price: Price;
28
- compare_at_price?: Price;
29
- }[];
30
- }
31
- export interface Price {
32
- amount: number;
33
- currency_code: string;
34
- }
35
- export interface Hit {
36
- _id: string;
37
- _index: string;
38
- _score: number;
39
- }
40
- export interface ResultCallout {
41
- type: "callout";
42
- data: ConfigCallout;
43
- }
44
- export interface ResultProduct {
45
- type: "product";
46
- data: Hit & Product;
47
- }
48
- export declare type ResultCombined = ResultCallout | ResultProduct;