@usereactify/search 5.32.0 → 6.0.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [6.0.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.32.0...release-v6.0.0) (2023-09-12)
6
+
7
+
8
+ ### Features
9
+
10
+ * use endpoint from config ([f41806d](https://bitbucket.org/usereactify/reactify-search-ui/commit/f41806ded0ce06e09e0f856aa038ce32bf509948))
11
+
5
12
  ## [5.32.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.31.0...release-v5.32.0) (2023-09-07)
6
13
 
7
14
 
package/dist/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": "5.32.0",
4
+ "version": "6.0.0",
5
5
  "license": "MIT",
6
6
  "main": "dist/src/index.js",
7
7
  "types": "dist/src/index.d.ts",
@@ -19,9 +19,6 @@
19
19
  "build": "tsc",
20
20
  "prettier": "prettier --write .",
21
21
  "start": "start-storybook -p 6006",
22
- "sentry:release:new": "sentry-cli releases new $npm_package_version",
23
- "sentry:release:upload": "sentry-cli releases files $npm_package_version upload-sourcemaps dist",
24
- "sentry:release:finalize": "sentry-cli releases finalize $npm_package_version",
25
22
  "prepare": "husky install"
26
23
  },
27
24
  "commitlint": {
@@ -93,13 +93,13 @@ const ReactifySearchInner = (props) => {
93
93
  }
94
94
  }, [searchSortFromURL]);
95
95
  const contextValue = react_1.default.useMemo(() => {
96
- var _a, _b, _c, _d;
96
+ var _a, _b, _c;
97
97
  if (!config) {
98
98
  return;
99
99
  }
100
100
  return {
101
101
  config: config,
102
- options: Object.assign(Object.assign({}, props), { clientId: (_a = props.clientId) !== null && _a !== void 0 ? _a : "theme", index: (_c = (_b = props.index) !== null && _b !== void 0 ? _b : indexFromURL) !== null && _c !== void 0 ? _c : config.index, filtersHandle: props.filtersHandle, credentials: props.credentials, endpoint: (_d = props.endpoint) !== null && _d !== void 0 ? _d : "https://api.search.reactify.app", theme: theme }),
102
+ options: Object.assign(Object.assign({}, props), { clientId: (_a = props.clientId) !== null && _a !== void 0 ? _a : "theme", index: (_c = (_b = props.index) !== null && _b !== void 0 ? _b : indexFromURL) !== null && _c !== void 0 ? _c : config.index, filtersHandle: props.filtersHandle, credentials: props.credentials, theme: theme }),
103
103
  search: {
104
104
  searchTerm: searchTerm,
105
105
  setSearchTerm: setSearchTerm,
@@ -1 +1 @@
1
- {"version":3,"file":"ReactifySearchProvider.js","sourceRoot":"","sources":["../../../../src/components/ReactifySearchProvider/ReactifySearchProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,iCAAiC;AACjC,gDAAkC;AAElC,yEAAwC;AAExC,uCAA+D;AAC/D,iDAAoE;AACpE,2CAAsC;AAkD/B,MAAM,sBAAsB,GAA0C,CAC3E,KAAK,EACL,EAAE;IACF,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,eAAK,CAAC,GAAG,CAAC,wBAAwB,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAEpD,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE;YAC7B,aAAa,EAAE,KAAK;YACpB,eAAe,EAAE;gBACf,IAAI,EAAE,KAAK,CAAC,sBAAsB;gBAClC,OAAO,EAAE,sBAAG,CAAC,OAAO;aACrB;SACF,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,8BAAC,mBAAmB,oBAAK,KAAK,EAAI,CAAC;AAC5C,CAAC,CAAC;AAhBW,QAAA,sBAAsB,0BAgBjC;AAEF,MAAM,mBAAmB,GAA0C,CAAC,KAAK,EAAE,EAAE;;IAC3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tag\";\n\nimport pkg from \"../../../package.json\";\n\nimport { ReactifySearchContext, useConfig } from \"../../hooks\";\nimport { UtilityAuthenticatedReactiveBase } from \"../../components\";\nimport { debug } from \"../../utility\";\nimport { ReactivesearchResultProps } from \"../../types\";\n\nexport type ReactifySearchProviderProps = {\n /** Standard react children */\n children?: React.ReactNode | undefined;\n /** The search area the provider will be used in */\n mode: \"search\" | \"collection\" | \"instant-search\";\n /** Shopify store domain used to resolve the site configuration */\n shopifyPermanentDomain: string;\n /** Callback function for redirects, suitable for headless sites to avoid full page refresh */\n onRedirect?: (type: \"redirect\" | \"search\", url: string) => void;\n /** Render method to display a component when the config is loading */\n renderBooting?: () => JSX.Element | null;\n /** Advanced usage: Override the default Reactify Search id (for telemetry) */\n clientId?: string;\n /** Advanced usage: Override the default Filters selection logic */\n filtersHandle?: string;\n /** Advanced usage: Array of additional component IDs managed outside of Reactify Search */\n additionalComponentIds?: Array<string>;\n /** Advanced usage: Override the default Elasticsearch index */\n index?: string;\n /** Advanced usage: Override the default Reactify Search config (for multi-instance stores) */\n configId?: string;\n /** Advanced usage: Override the default Elasticsearch credentials */\n credentials?: string;\n /** Advanced usage: Override the default Elasticsearch endpoint */\n endpoint?: string;\n /** Advanced usage: Override the default ReactiveBase theme */\n theme?: Record<string, unknown>;\n /** Advanced usage: Fields to include in the Elasticsearch response e.g. [\"title\"] */\n includeFields?: Array<string>;\n /** Advanced usage: Fields to exclude from the Elasticsearch response e.g. [\"variant_skus\", \"*price*\"] */\n excludeFields?: Array<string>;\n /** Advanced usage: Flags are used to enable or disable specific features within Reactify Search */\n flags?: Record<string, boolean>;\n} & (\n | {\n mode: \"search\";\n }\n | {\n mode: \"collection\";\n /** Collection object that includes the handle, used to find curations */\n collectionHandle: string;\n }\n | {\n mode: \"instant-search\";\n }\n);\n\nexport const ReactifySearchProvider: React.FC<ReactifySearchProviderProps> = (\n props\n) => {\n React.useEffect(() => {\n debug.log(\"ReactifySearchProvider\", \"props\", props);\n\n GaGtag.install(\"G-DV00Z0X5VP\", {\n cookie_prefix: \"_rs\",\n user_properties: {\n shop: props.shopifyPermanentDomain,\n version: pkg.version,\n },\n });\n }, [props]);\n\n return <ReactifySearchInner {...props} />;\n};\n\nconst ReactifySearchInner: React.FC<ReactifySearchProviderProps> = (props) => {\n const { config } = useConfig(props.shopifyPermanentDomain, props.configId);\n\n const theme = props.theme ?? {\n typography: {\n fontFamily: \"inherit\",\n fontSize: \"inherit\",\n },\n };\n\n const searchTermFromURL = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"q\") ?? undefined;\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n const searchSortFromURL = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"sort\") ?? undefined;\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n const indexFromURL = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"index\") ?? undefined;\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n const [searchTerm, setSearchTerm] = React.useState<string>(\n searchTermFromURL ?? \"\"\n );\n const [showInstantSearchResults, setShowInstantSearchResults] =\n React.useState<boolean>(false);\n const [sortOption, setSortOption] = React.useState<string>(\n searchSortFromURL ?? \"\"\n );\n\n const [results, setResults] = React.useState<\n ReactivesearchResultProps[\"data\"]\n >([]);\n const [resultStats, setResultStats] =\n React.useState<ReactivesearchResultProps[\"resultStats\"]>();\n\n React.useEffect(() => {\n if (searchTermFromURL && searchTerm !== searchTermFromURL) {\n setSearchTerm(searchTermFromURL);\n }\n }, [searchTermFromURL]);\n\n React.useEffect(() => {\n if (searchSortFromURL && sortOption !== searchSortFromURL) {\n setSortOption(searchSortFromURL);\n }\n }, [searchSortFromURL]);\n\n const contextValue = React.useMemo(() => {\n if (!config) {\n return;\n }\n\n return {\n config: config,\n options: {\n ...props,\n clientId: props.clientId ?? \"theme\",\n index: props.index ?? indexFromURL ?? config.index,\n filtersHandle: props.filtersHandle,\n credentials: props.credentials,\n endpoint: props.endpoint ?? \"https://api.search.reactify.app\",\n theme: theme,\n },\n search: {\n searchTerm: searchTerm,\n setSearchTerm: setSearchTerm,\n showInstantSearchResults: showInstantSearchResults,\n setShowInstantSearchResults: setShowInstantSearchResults,\n },\n sortby: {\n sortOption: sortOption,\n setSortOption: setSortOption,\n },\n results: {\n results: results,\n setResults: setResults,\n resultStats: resultStats,\n setResultStats: setResultStats,\n },\n };\n }, [\n config,\n props,\n searchTerm,\n showInstantSearchResults,\n sortOption,\n results,\n resultStats,\n ]);\n\n debug.hook(\"ReactifySearchProvider\", \"context\", contextValue);\n\n if (!contextValue) {\n if (props.renderBooting) {\n return props.renderBooting();\n }\n return null;\n }\n\n return (\n <ReactifySearchContext.Provider value={contextValue}>\n <UtilityAuthenticatedReactiveBase>\n {props.children}\n </UtilityAuthenticatedReactiveBase>\n </ReactifySearchContext.Provider>\n );\n};\n"]}
1
+ {"version":3,"file":"ReactifySearchProvider.js","sourceRoot":"","sources":["../../../../src/components/ReactifySearchProvider/ReactifySearchProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,iCAAiC;AACjC,gDAAkC;AAElC,yEAAwC;AAExC,uCAA+D;AAC/D,iDAAoE;AACpE,2CAAsC;AAkD/B,MAAM,sBAAsB,GAA0C,CAC3E,KAAK,EACL,EAAE;IACF,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,eAAK,CAAC,GAAG,CAAC,wBAAwB,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAEpD,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE;YAC7B,aAAa,EAAE,KAAK;YACpB,eAAe,EAAE;gBACf,IAAI,EAAE,KAAK,CAAC,sBAAsB;gBAClC,OAAO,EAAE,sBAAG,CAAC,OAAO;a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AC,KAAK,EAAE,YAAY;QACjD,8BAAC,6CAAgC,QAC9B,KAAK,CAAC,QAAQ,CACkB,CACJ,CAClC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\n// @ts-expect-error missing types\nimport * as GaGtag from \"ga-gtag\";\n\nimport pkg from \"../../../package.json\";\n\nimport { ReactifySearchContext, useConfig } from \"../../hooks\";\nimport { UtilityAuthenticatedReactiveBase } from \"../../components\";\nimport { debug } from \"../../utility\";\nimport { ReactivesearchResultProps } from \"../../types\";\n\nexport type ReactifySearchProviderProps = {\n /** Standard react children */\n children?: React.ReactNode | undefined;\n /** The search area the provider will be used in */\n mode: \"search\" | \"collection\" | \"instant-search\";\n /** Shopify store domain used to resolve the site configuration */\n shopifyPermanentDomain: string;\n /** Callback function for redirects, suitable for headless sites to avoid full page refresh */\n onRedirect?: (type: \"redirect\" | \"search\", url: string) => void;\n /** Render method to display a component when the config is loading */\n renderBooting?: () => JSX.Element | null;\n /** Advanced usage: Override the default Reactify Search id (for telemetry) */\n clientId?: string;\n /** Advanced usage: Override the default Filters selection logic */\n filtersHandle?: string;\n /** Advanced usage: Array of additional component IDs managed outside of Reactify Search */\n additionalComponentIds?: Array<string>;\n /** Advanced usage: Override the default Elasticsearch index */\n index?: string;\n /** Advanced usage: Override the default Reactify Search config (for multi-instance stores) */\n configId?: string;\n /** Advanced usage: Override the default Elasticsearch credentials */\n credentials?: string;\n /** Advanced usage: Override the default Elasticsearch endpoint */\n endpoint?: string;\n /** Advanced usage: Override the default ReactiveBase theme */\n theme?: Record<string, unknown>;\n /** Advanced usage: Fields to include in the Elasticsearch response e.g. [\"title\"] */\n includeFields?: Array<string>;\n /** Advanced usage: Fields to exclude from the Elasticsearch response e.g. [\"variant_skus\", \"*price*\"] */\n excludeFields?: Array<string>;\n /** Advanced usage: Flags are used to enable or disable specific features within Reactify Search */\n flags?: Record<string, boolean>;\n} & (\n | {\n mode: \"search\";\n }\n | {\n mode: \"collection\";\n /** Collection object that includes the handle, used to find curations */\n collectionHandle: string;\n }\n | {\n mode: \"instant-search\";\n }\n);\n\nexport const ReactifySearchProvider: React.FC<ReactifySearchProviderProps> = (\n props\n) => {\n React.useEffect(() => {\n debug.log(\"ReactifySearchProvider\", \"props\", props);\n\n GaGtag.install(\"G-DV00Z0X5VP\", {\n cookie_prefix: \"_rs\",\n user_properties: {\n shop: props.shopifyPermanentDomain,\n version: pkg.version,\n },\n });\n }, [props]);\n\n return <ReactifySearchInner {...props} />;\n};\n\nconst ReactifySearchInner: React.FC<ReactifySearchProviderProps> = (props) => {\n const { config } = useConfig(props.shopifyPermanentDomain, props.configId);\n\n const theme = props.theme ?? {\n typography: {\n fontFamily: \"inherit\",\n fontSize: \"inherit\",\n },\n };\n\n const searchTermFromURL = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"q\") ?? undefined;\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n const searchSortFromURL = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"sort\") ?? undefined;\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n const indexFromURL = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"index\") ?? undefined;\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n const [searchTerm, setSearchTerm] = React.useState<string>(\n searchTermFromURL ?? \"\"\n );\n const [showInstantSearchResults, setShowInstantSearchResults] =\n React.useState<boolean>(false);\n const [sortOption, setSortOption] = React.useState<string>(\n searchSortFromURL ?? \"\"\n );\n\n const [results, setResults] = React.useState<\n ReactivesearchResultProps[\"data\"]\n >([]);\n const [resultStats, setResultStats] =\n React.useState<ReactivesearchResultProps[\"resultStats\"]>();\n\n React.useEffect(() => {\n if (searchTermFromURL && searchTerm !== searchTermFromURL) {\n setSearchTerm(searchTermFromURL);\n }\n }, [searchTermFromURL]);\n\n React.useEffect(() => {\n if (searchSortFromURL && sortOption !== searchSortFromURL) {\n setSortOption(searchSortFromURL);\n }\n }, [searchSortFromURL]);\n\n const contextValue = React.useMemo(() => {\n if (!config) {\n return;\n }\n\n return {\n config: config,\n options: {\n ...props,\n clientId: props.clientId ?? \"theme\",\n index: props.index ?? indexFromURL ?? config.index,\n filtersHandle: props.filtersHandle,\n credentials: props.credentials,\n theme: theme,\n },\n search: {\n searchTerm: searchTerm,\n setSearchTerm: setSearchTerm,\n showInstantSearchResults: showInstantSearchResults,\n setShowInstantSearchResults: setShowInstantSearchResults,\n },\n sortby: {\n sortOption: sortOption,\n setSortOption: setSortOption,\n },\n results: {\n results: results,\n setResults: setResults,\n resultStats: resultStats,\n setResultStats: setResultStats,\n },\n };\n }, [\n config,\n props,\n searchTerm,\n showInstantSearchResults,\n sortOption,\n results,\n resultStats,\n ]);\n\n debug.hook(\"ReactifySearchProvider\", \"context\", contextValue);\n\n if (!contextValue) {\n if (props.renderBooting) {\n return props.renderBooting();\n }\n return null;\n }\n\n return (\n <ReactifySearchContext.Provider value={contextValue}>\n <UtilityAuthenticatedReactiveBase>\n {props.children}\n </UtilityAuthenticatedReactiveBase>\n </ReactifySearchContext.Provider>\n );\n};\n"]}
@@ -31,10 +31,10 @@ const replaceDocCountWithParent = (response) => {
31
31
  return response;
32
32
  };
33
33
  const useReactiveBaseProps = () => {
34
- const { options } = (0, hooks_1.useReactifySearchContext)();
34
+ const { config, options } = (0, hooks_1.useReactifySearchContext)();
35
35
  const reactiveBaseProps = react_1.default.useMemo(() => ({
36
36
  app: options.index,
37
- url: options.endpoint,
37
+ url: config.endpoint,
38
38
  credentials: options.credentials,
39
39
  theme: options.theme,
40
40
  transformResponse: (response) => __awaiter(void 0, void 0, void 0, function* () {
@@ -59,7 +59,7 @@ const useReactiveBaseProps = () => {
59
59
  "x-reactify-client-id": options.clientId,
60
60
  "x-reactify-client-version": package_json_1.default.version,
61
61
  },
62
- }), [options.index, options.endpoint, options.credentials, options.theme]);
62
+ }), [options.index, config.endpoint, options.credentials, options.theme]);
63
63
  return reactiveBaseProps;
64
64
  };
65
65
  exports.useReactiveBaseProps = useReactiveBaseProps;
@@ -1 +1 @@
1
- {"version":3,"file":"useReactiveBaseProps.js","sourceRoot":"","sources":["../../../../src/hooks/reactivesearch/useReactiveBaseProps.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAG1B,uCAAuD;AAEvD,yEAAwC;AAExC,MAAM,yBAAyB,GAAG,CAAC,QAAa,EAAE,EAAE;IAClD,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;SACrB,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,WAAW,CAAC;SACtC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAgB,EAAE,EAAE;;QACvC,MAAA,KAAK,CAAC,OAAO,0CAAE,OAAO,CAAC,CAAC,MAAW,EAAE,EAAE;YACrC,IAAI,MAAM,CAAC,WAAW,EAAE;gBACtB,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC;gBAChD,OAAO,MAAM,CAAC,WAAW,CAAC;aAC3B;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEL,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEK,MAAM,oBAAoB,GAAG,GAAsB,EAAE;IAC1D,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAE/C,MAAM,iBAAiB,GAAG,eAAK,CAAC,OAAO,CACrC,GAAG,EAAE,CAAC,CAAC;QACL,GAAG,EAAE,OAAO,CAAC,KAAK;QAClB,GAAG,EAAE,OAAO,CAAC,QAAQ;QACrB,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,iBAAiB,EAAE,CAAO,QAAa,EAAE,EAAE;;YACzC,+EAA+E;YAC/E,uDAAuD;YACvD,EAAE;YACF,qFAAqF;YACrF,qFAAqF;YACrF,kEAAkE;YAClE,EAAE;YACF,0DAA0D;YAC1D,IACE,MAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,YAAY,0CAAE,qBAAqB,0CAAE,qBAAqB,EACpE;gBACA,QAAQ,CAAC,YAAY,CAAC,qBAAqB;oBACzC,yBAAyB,CACvB,MAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,YAAY,0CAAE,qBAAqB,0CACzC,qBAAqB,CAC1B,CAAC;aACL;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC,CAAA;QACD,OAAO,EAAE;YACP,iBAAiB,EAAE,OAAO,CAAC,sBAAsB;YACjD,iBAAiB,EAAE,OAAO,CAAC,IAAI;YAC/B,sBAAsB,EAAE,OAAO,CAAC,QAAQ;YACxC,2BAA2B,EAAE,sBAAG,CAAC,OAAO;SACzC;KACF,CAAC,EACF,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,CACtE,CAAC;IAEF,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AAzCW,QAAA,oBAAoB,wBAyC/B","sourcesContent":["import React from \"react\";\nimport { ReactiveBaseProps } from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveBase\";\n\nimport { useReactifySearchContext } from \"../../hooks\";\n\nimport pkg from \"../../../package.json\";\n\nconst replaceDocCountWithParent = (response: any) => {\n Object.entries(response)\n .filter(([key]) => key !== \"doc_count\")\n .forEach(([key, value]: [string, any]) => {\n value.buckets?.forEach((bucket: any) => {\n if (bucket.parent_docs) {\n bucket.doc_count = bucket.parent_docs.doc_count;\n delete bucket.parent_docs;\n }\n });\n });\n\n return response;\n};\n\nexport const useReactiveBaseProps = (): ReactiveBaseProps => {\n const { options } = useReactifySearchContext();\n\n const reactiveBaseProps = React.useMemo<ReactiveBaseProps>(\n () => ({\n app: options.index,\n url: options.endpoint,\n credentials: options.credentials,\n theme: options.theme,\n transformResponse: async (response: any) => {\n // support filtering inside nested aggregations by moving the inner aggregation\n // up one level such that reactivesearch understands it\n //\n // see useReactiveFilterListProps > defaultQuery to see how a filter is being applied\n // to variant aggregations to ensure that only in stock sizes are displayed as filter\n // options, this involves a nested filter, which requires this fix\n //\n // https://github.com/appbaseio/reactivesearch/issues/1530\n if (\n response?.aggregations?.reactivesearch_nested?.reactify_nested_outer\n ) {\n response.aggregations.reactivesearch_nested =\n replaceDocCountWithParent(\n response?.aggregations?.reactivesearch_nested\n ?.reactify_nested_outer\n );\n }\n\n return response;\n },\n headers: {\n \"x-reactify-shop\": options.shopifyPermanentDomain,\n \"x-reactify-mode\": options.mode,\n \"x-reactify-client-id\": options.clientId,\n \"x-reactify-client-version\": pkg.version,\n },\n }),\n [options.index, options.endpoint, options.credentials, options.theme]\n );\n\n return reactiveBaseProps;\n};\n"]}
1
+ {"version":3,"file":"useReactiveBaseProps.js","sourceRoot":"","sources":["../../../../src/hooks/reactivesearch/useReactiveBaseProps.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAG1B,uCAAuD;AAEvD,yEAAwC;AAExC,MAAM,yBAAyB,GAAG,CAAC,QAAa,EAAE,EAAE;IAClD,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;SACrB,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,WAAW,CAAC;SACtC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAgB,EAAE,EAAE;;QACvC,MAAA,KAAK,CAAC,OAAO,0CAAE,OAAO,CAAC,CAAC,MAAW,EAAE,EAAE;YACrC,IAAI,MAAM,CAAC,WAAW,EAAE;gBACtB,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC;gBAChD,OAAO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,CACrE,CAAC;IAEF,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AAzCW,QAAA,oBAAoB,wBAyC/B","sourcesContent":["import React from \"react\";\nimport { ReactiveBaseProps } from \"@appbaseio/reactivesearch/lib/components/basic/ReactiveBase\";\n\nimport { useReactifySearchContext } from \"../../hooks\";\n\nimport pkg from \"../../../package.json\";\n\nconst replaceDocCountWithParent = (response: any) => {\n Object.entries(response)\n .filter(([key]) => key !== \"doc_count\")\n .forEach(([key, value]: [string, any]) => {\n value.buckets?.forEach((bucket: any) => {\n if (bucket.parent_docs) {\n bucket.doc_count = bucket.parent_docs.doc_count;\n delete bucket.parent_docs;\n }\n });\n });\n\n return response;\n};\n\nexport const useReactiveBaseProps = (): ReactiveBaseProps => {\n const { config, options } = useReactifySearchContext();\n\n const reactiveBaseProps = React.useMemo<ReactiveBaseProps>(\n () => ({\n app: options.index,\n url: config.endpoint,\n credentials: options.credentials,\n theme: options.theme,\n transformResponse: async (response: any) => {\n // support filtering inside nested aggregations by moving the inner aggregation\n // up one level such that reactivesearch understands it\n //\n // see useReactiveFilterListProps > defaultQuery to see how a filter is being applied\n // to variant aggregations to ensure that only in stock sizes are displayed as filter\n // options, this involves a nested filter, which requires this fix\n //\n // https://github.com/appbaseio/reactivesearch/issues/1530\n if (\n response?.aggregations?.reactivesearch_nested?.reactify_nested_outer\n ) {\n response.aggregations.reactivesearch_nested =\n replaceDocCountWithParent(\n response?.aggregations?.reactivesearch_nested\n ?.reactify_nested_outer\n );\n }\n\n return response;\n },\n headers: {\n \"x-reactify-shop\": options.shopifyPermanentDomain,\n \"x-reactify-mode\": options.mode,\n \"x-reactify-client-id\": options.clientId,\n \"x-reactify-client-version\": pkg.version,\n },\n }),\n [options.index, config.endpoint, options.credentials, options.theme]\n );\n\n return reactiveBaseProps;\n};\n"]}
@@ -4,6 +4,6 @@ export declare const useFilters: () => {
4
4
  filterStack?: ConfigFilter | undefined;
5
5
  /** All of the available filters within the filter stack */
6
6
  filters?: ConfigFilterOption[] | undefined;
7
- /** Clear filter by handle */
7
+ /** Set filter value by handle */
8
8
  setFilterValue: (handle: string, value: string | Array<string> | [number, number]) => void;
9
9
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useFilters.js","sourceRoot":"","sources":["../../../src/hooks/useFilters.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,iCAAiC;AACjC,+DAAwE;AACxE,iCAAiC;AACjC,iEAA+D;AAG/D,oCAAoD;AACpD,wCAAmC;AAE5B,MAAM,UAAU,GAAG,GAUxB,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IACvD,MAAM,qBAAqB,GAAG,eAAK,CAAC,UAAU,CAAM,yBAAiB,CAAC,CAAC;IAEvE,MAAM,WAAW,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACrC,yBAAyB;QACzB,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAC5C,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,CACzC,CAAC;QAEF,4CAA4C;QAC5C,IAAI,OAAO,CAAC,aAAa,EAAE;YACzB,MAAM,eAAe,GAAG,gBAAgB,CAAC,IAAI,CAC3C,CAAC,WAAW,EAAE,EAAE,CAAC,OAAO,CAAC,aAAa,KAAK,WAAW,CAAC,MAAM,CAC9D,CAAC;YACF,IAAI,eAAe,EAAE;gBACnB,OAAO,eAAe,CAAC;aACxB;SACF;QAED,gDAAgD;QAChD,IAAI,OAAO,CAAC,IAAI,KAAK,YAAY,IAAI,OAAO,CAAC,gBAAgB,EAAE;YAC7D,MAAM,eAAe,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,WAC5D,OAAA,MAAA,WAAW,CAAC,WAAW,0CAAE,QAAQ,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA,EAAA,CAC5D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;QACvE,qBAAqB,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAA,kBAAQ,EAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IAChE,CAAC,EACD,CAAC,qBAAqB,CAAC,CACxB,CAAC;IAEF,eAAK,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;IACrD,eAAK,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAE7C,OAAO;QACL,WAAW,EAAE,WAAW;QACxB,OAAO,EAAE,OAAO;QAChB,cAAc,EAAE,cAAc;KAC/B,CAAC;AACJ,CAAC,CAAC;AA5FW,QAAA,UAAU,cA4FrB","sourcesContent":["import React from \"react\";\n// @ts-expect-error missing types\nimport { ReactReduxContext } from \"@appbaseio/reactivesearch/lib/utils\";\n// @ts-expect-error missing types\nimport { setValue } from \"@appbaseio/reactivecore/lib/actions\";\n\nimport { ConfigFilter, ConfigFilterOption } from \"../types\";\nimport { useReactifySearchContext } from \"../hooks\";\nimport { debug } from \"../utility\";\n\nexport const useFilters = (): {\n /** The currently selected filter stack, based on mode, curation and more */\n filterStack?: ConfigFilter;\n /** All of the available filters within the filter stack */\n filters?: Array<ConfigFilterOption>;\n /** Clear filter by handle */\n setFilterValue: (\n handle: string,\n value: string | Array<string> | [number, number]\n ) => void;\n} => {\n const { options, config } = useReactifySearchContext();\n const reactivesearchContext = React.useContext<any>(ReactReduxContext);\n\n const filterStack = React.useMemo(() => {\n // select filters by type\n const matchingFilterss = config.filters.filter(\n (filter) => filter.type === options.mode\n );\n\n // select filter stack by handle if provided\n if (options.filtersHandle) {\n const matchingFilters = matchingFilterss.find(\n (filterStack) => options.filtersHandle === filterStack.handle\n );\n if (matchingFilters) {\n return matchingFilters;\n }\n }\n\n // select filter stack by collection if provided\n if (options.mode === \"collection\" && options.collectionHandle) {\n const matchingFilters = matchingFilterss.find((filterStack) =>\n filterStack.collections?.includes(options.collectionHandle)\n );\n if (matchingFilters) {\n return matchingFilters;\n }\n }\n\n // select filter with \"default\" handle\n let matchingFilters = matchingFilterss.find(\n (filterStack) => filterStack.handle === \"default\"\n );\n if (matchingFilters) {\n return matchingFilters;\n }\n\n // select any filter with \"default\" handle\n matchingFilters = config.filters.find(\n (filterStack) => filterStack.handle === \"default\"\n );\n if (matchingFilters) {\n return matchingFilters;\n }\n\n // select any available filter as a last resort\n matchingFilters = config.filters[0];\n\n return matchingFilters;\n }, [\n config,\n options.mode === \"collection\" ? options.collectionHandle : undefined,\n ]);\n\n const filters = React.useMemo(() => {\n const sortedFilters = filterStack?.options.sort((a, b) =>\n a.position > b.position ? 1 : -1\n );\n\n return sortedFilters;\n }, [filterStack]);\n\n const setFilterValue = React.useCallback(\n (\n handle: string,\n value: string | Array<string> | [number, number]\n ): void => {\n debug.log(\"useFilters\", \"setFilterValue[handle,value]\", handle, value);\n reactivesearchContext.store.dispatch(setValue(handle, value));\n },\n [reactivesearchContext]\n );\n\n debug.hook(\"useFilters\", \"filterStack\", filterStack);\n debug.hook(\"useFilters\", \"filters\", filters);\n\n return {\n filterStack: filterStack,\n filters: filters,\n setFilterValue: setFilterValue,\n };\n};\n"]}
1
+ {"version":3,"file":"useFilters.js","sourceRoot":"","sources":["../../../src/hooks/useFilters.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,iCAAiC;AACjC,+DAAwE;AACxE,iCAAiC;AACjC,iEAA+D;AAG/D,oCAAoD;AACpD,wCAAmC;AAE5B,MAAM,UAAU,GAAG,GAUxB,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IACvD,MAAM,qBAAqB,GAAG,eAAK,CAAC,UAAU,CAAM,yBAAiB,CAAC,CAAC;IAEvE,MAAM,WAAW,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACrC,yBAAyB;QACzB,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM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AAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS;KACrE,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACjC,MAAM,aAAa,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACvD,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACjC,CAAC;QAEF,OAAO,aAAa,CAAC;IACvB,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,MAAM,cAAc,GAAG,eAAK,CAAC,WAAW,CACtC,CACE,MAAc,EACd,KAAgD,EAC1C,EAAE;QACR,eAAK,CAAC,GAAG,CAAC,YAAY,EAAE,8BAA8B,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QACvE,qBAAqB,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAA,kBAAQ,EAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IAChE,CAAC,EACD,CAAC,qBAAqB,CAAC,CACxB,CAAC;IAEF,eAAK,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;IACrD,eAAK,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAE7C,OAAO;QACL,WAAW,EAAE,WAAW;QACxB,OAAO,EAAE,OAAO;QAChB,cAAc,EAAE,cAAc;KAC/B,CAAC;AACJ,CAAC,CAAC;AA5FW,QAAA,UAAU,cA4FrB","sourcesContent":["import React from \"react\";\n// @ts-expect-error missing types\nimport { ReactReduxContext } from \"@appbaseio/reactivesearch/lib/utils\";\n// @ts-expect-error missing types\nimport { setValue } from \"@appbaseio/reactivecore/lib/actions\";\n\nimport { ConfigFilter, ConfigFilterOption } from \"../types\";\nimport { useReactifySearchContext } from \"../hooks\";\nimport { debug } from \"../utility\";\n\nexport const useFilters = (): {\n /** The currently selected filter stack, based on mode, curation and more */\n filterStack?: ConfigFilter;\n /** All of the available filters within the filter stack */\n filters?: Array<ConfigFilterOption>;\n /** Set filter value by handle */\n setFilterValue: (\n handle: string,\n value: string | Array<string> | [number, number]\n ) => void;\n} => {\n const { options, config } = useReactifySearchContext();\n const reactivesearchContext = React.useContext<any>(ReactReduxContext);\n\n const filterStack = React.useMemo(() => {\n // select filters by type\n const matchingFilterss = config.filters.filter(\n (filter) => filter.type === options.mode\n );\n\n // select filter stack by handle if provided\n if (options.filtersHandle) {\n const matchingFilters = matchingFilterss.find(\n (filterStack) => options.filtersHandle === filterStack.handle\n );\n if (matchingFilters) {\n return matchingFilters;\n }\n }\n\n // select filter stack by collection if provided\n if (options.mode === \"collection\" && options.collectionHandle) {\n const matchingFilters = matchingFilterss.find((filterStack) =>\n filterStack.collections?.includes(options.collectionHandle)\n );\n if (matchingFilters) {\n return matchingFilters;\n }\n }\n\n // select filter with \"default\" handle\n let matchingFilters = matchingFilterss.find(\n (filterStack) => filterStack.handle === \"default\"\n );\n if (matchingFilters) {\n return matchingFilters;\n }\n\n // select any filter with \"default\" handle\n matchingFilters = config.filters.find(\n (filterStack) => filterStack.handle === \"default\"\n );\n if (matchingFilters) {\n return matchingFilters;\n }\n\n // select any available filter as a last resort\n matchingFilters = config.filters[0];\n\n return matchingFilters;\n }, [\n config,\n options.mode === \"collection\" ? options.collectionHandle : undefined,\n ]);\n\n const filters = React.useMemo(() => {\n const sortedFilters = filterStack?.options.sort((a, b) =>\n a.position > b.position ? 1 : -1\n );\n\n return sortedFilters;\n }, [filterStack]);\n\n const setFilterValue = React.useCallback(\n (\n handle: string,\n value: string | Array<string> | [number, number]\n ): void => {\n debug.log(\"useFilters\", \"setFilterValue[handle,value]\", handle, value);\n reactivesearchContext.store.dispatch(setValue(handle, value));\n },\n [reactivesearchContext]\n );\n\n debug.hook(\"useFilters\", \"filterStack\", filterStack);\n debug.hook(\"useFilters\", \"filters\", filters);\n\n return {\n filterStack: filterStack,\n filters: filters,\n setFilterValue: setFilterValue,\n };\n};\n"]}
@@ -32,9 +32,9 @@ const useIndices = () => {
32
32
  };
33
33
  react_1.default.useEffect(() => {
34
34
  (() => __awaiter(void 0, void 0, void 0, function* () {
35
- const response = yield fetch(`https://api.search.reactify.app/_cat/indices?format=json`, {
35
+ const response = yield fetch(`${config.endpoint}/_cat/indices?format=json`, {
36
36
  headers: {
37
- "x-reactify-index": config.index,
37
+ "x-reactify-shop": options.shopifyPermanentDomain,
38
38
  "x-reactify-skip-cache": "true",
39
39
  },
40
40
  }).then((response) => response.json());
@@ -1 +1 @@
1
- {"version":3,"file":"useIndices.js","sourceRoot":"","sources":["../../../src/hooks/useIndices.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,yEAAsE;AAO/D,MAAM,UAAU,GAAG,GAAe,EAAE;IACzC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,mDAAwB,GAAE,CAAC;IACvD,MAAM,QAAQ,GAAG,OAAO,CAAC,sBAAsB,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;IAE9E,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAwB,EAAE,CAAC,CAAC;IAExE,MAAM,eAAe,GAAkC,CAAC,SAAS,EAAE,EAAE;QACnE,IAAI,kBAAkB,GAAG,SAAS,CAAC;QACnC,IAAI;YACF,MAAM,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YAErD,kBAAkB,GAAG,GAAG,QAAQ,IAAI,IAAI,IAAI,CAC1C,QAAQ,CAAC,SAAS,CAAC,CACpB,CAAC,cAAc,EAAE,KAAK,SAAS,GAAG,CAAC;SACrC;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SACtB;QAED,OAAO,kBAAkB,CAAC;IAC5B,CAAC,CAAC;IAEF,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,CAAC,GAAS,EAAE;YACV,MAAM,QAAQ,GAA6B,MAAM,KAAK,CACpD,0DAA0D,EAC1D;gBACE,OAAO,EAAE;oBACP,kBAAkB,EAAE,MAAM,CAAC,KAAK;oBAChC,uBAAuB,EAAE,MAAM;iBAChC;aACF,CACF,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;YAEtC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,GAAG,QAAQ,QAAQ,CAAC,CAAC;YAE/C,UAAU,CACR,QAAQ;iBACL,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;iBACzB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBACnC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACpC,CAAC;QACJ,CAAC,CAAA,CAAC,EAAE,CAAC;IACP,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEtB,OAAO;QACL,OAAO,EAAE,OAAO;QAChB,eAAe,EAAE,eAAe;KACjC,CAAC;AACJ,CAAC,CAAC;AAhDW,QAAA,UAAU,cAgDrB","sourcesContent":["import React from \"react\";\nimport { useReactifySearchContext } from \"./useReactifySearchContext\";\n\nexport type UseIndices = {\n indices: Array<string>;\n indexNameFormat: (indexName: string) => string;\n};\n\nexport const useIndices = (): UseIndices => {\n const { config, options } = useReactifySearchContext();\n const shopName = options.shopifyPermanentDomain.replace(\".myshopify.com\", \"\");\n\n const [indices, setIndices] = React.useState<UseIndices[\"indices\"]>([]);\n\n const indexNameFormat: UseIndices[\"indexNameFormat\"] = (indexName) => {\n let indexNameFormatted = indexName;\n try {\n const indexDate = indexName.split(`${shopName}-`)[1];\n\n indexNameFormatted = `${shopName} ${new Date(\n parseInt(indexDate)\n ).toLocaleString()} (${indexDate})`;\n } catch (error) {\n console.error(error);\n }\n\n return indexNameFormatted;\n };\n\n React.useEffect(() => {\n (async () => {\n const response: Array<{ index: string }> = await fetch(\n `https://api.search.reactify.app/_cat/indices?format=json`,\n {\n headers: {\n \"x-reactify-index\": config.index,\n \"x-reactify-skip-cache\": \"true\",\n },\n }\n ).then((response) => response.json());\n\n const regexp = new RegExp(`${shopName}-[0-9]`);\n\n setIndices(\n response\n .map((item) => item.index)\n .filter((item) => regexp.test(item))\n .sort((a, b) => (a > b ? -1 : 1))\n );\n })();\n }, [config.endpoint]);\n\n return {\n indices: indices,\n indexNameFormat: indexNameFormat,\n };\n};\n"]}
1
+ {"version":3,"file":"useIndices.js","sourceRoot":"","sources":["../../../src/hooks/useIndices.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,yEAAsE;AAO/D,MAAM,UAAU,GAAG,GAAe,EAAE;IACzC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,mDAAwB,GAAE,CAAC;IACvD,MAAM,QAAQ,GAAG,OAAO,CAAC,sBAAsB,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;IAE9E,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAwB,EAAE,CAAC,CAAC;IAExE,MAAM,eAAe,GAAkC,CAAC,SAAS,EAAE,EAAE;QACnE,IAAI,kBAAkB,GAAG,SAAS,CAAC;QACnC,IAAI;YACF,MAAM,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,QAAQ,GAAG,CAAC,CAAC,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;AAhDW,QAAA,UAAU,cAgDrB","sourcesContent":["import React from \"react\";\nimport { useReactifySearchContext } from \"./useReactifySearchContext\";\n\nexport type UseIndices = {\n indices: Array<string>;\n indexNameFormat: (indexName: string) => string;\n};\n\nexport const useIndices = (): UseIndices => {\n const { config, options } = useReactifySearchContext();\n const shopName = options.shopifyPermanentDomain.replace(\".myshopify.com\", \"\");\n\n const [indices, setIndices] = React.useState<UseIndices[\"indices\"]>([]);\n\n const indexNameFormat: UseIndices[\"indexNameFormat\"] = (indexName) => {\n let indexNameFormatted = indexName;\n try {\n const indexDate = indexName.split(`${shopName}-`)[1];\n\n indexNameFormatted = `${shopName} ${new Date(\n parseInt(indexDate)\n ).toLocaleString()} (${indexDate})`;\n } catch (error) {\n console.error(error);\n }\n\n return indexNameFormatted;\n };\n\n React.useEffect(() => {\n (async () => {\n const response: Array<{ index: string }> = await fetch(\n `${config.endpoint}/_cat/indices?format=json`,\n {\n headers: {\n \"x-reactify-shop\": options.shopifyPermanentDomain,\n \"x-reactify-skip-cache\": \"true\",\n },\n }\n ).then((response) => response.json());\n\n const regexp = new RegExp(`${shopName}-[0-9]`);\n\n setIndices(\n response\n .map((item) => item.index)\n .filter((item) => regexp.test(item))\n .sort((a, b) => (a > b ? -1 : 1))\n );\n })();\n }, [config.endpoint]);\n\n return {\n indices: indices,\n indexNameFormat: indexNameFormat,\n };\n};\n"]}
@@ -11,7 +11,6 @@ export declare const ReactifySearchContext: React.Context<{
11
11
  shopifyPermanentDomain: string;
12
12
  filtersHandle?: string | undefined;
13
13
  credentials?: string | undefined;
14
- endpoint: string;
15
14
  onRedirect?: ((type: "redirect" | "search", url: string) => void) | undefined;
16
15
  theme: Record<string, unknown>;
17
16
  additionalComponentIds?: string[] | undefined;
@@ -52,7 +51,6 @@ export declare const useReactifySearchContext: () => {
52
51
  shopifyPermanentDomain: string;
53
52
  filtersHandle?: string | undefined;
54
53
  credentials?: string | undefined;
55
- endpoint: string;
56
54
  onRedirect?: ((type: "redirect" | "search", url: string) => void) | undefined;
57
55
  theme: Record<string, unknown>;
58
56
  additionalComponentIds?: string[] | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"useReactifySearchContext.js","sourceRoot":"","sources":["../../../src/hooks/useReactifySearchContext.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAOb,QAAA,qBAAqB,GAAG,eAAK,CAAC,aAAa,CAuDtD,SAAS,CAAC,CAAC;AAEN,MAAM,wBAAwB,GAAG,GAAG,EAAE,CAC3C,eAAK,CAAC,UAAU,CAAC,6BAAqB,CAAE,CAAC;AAD9B,QAAA,wBAAwB,4BACM","sourcesContent":["import React from \"react\";\n\nimport { Config, ReactivesearchResultProps } from \"../types\";\nimport { Flags } from \"./useFlags\";\n\nexport type ReactifySearchMode = \"search\" | \"collection\" | \"instant-search\";\n\nexport const ReactifySearchContext = React.createContext<\n | {\n config: Config;\n options: {\n clientId: string;\n mode: ReactifySearchMode;\n index: string;\n shopifyPermanentDomain: string;\n filtersHandle?: string;\n credentials?: string;\n endpoint: string;\n onRedirect?: (type: \"redirect\" | \"search\", url: string) => void;\n theme: Record<string, unknown>;\n additionalComponentIds?: Array<string>;\n includeFields?: Array<string>;\n excludeFields?: Array<string>;\n flags?: Record<Flags, boolean>;\n } & (\n | {\n mode: \"search\";\n }\n | {\n mode: \"collection\";\n collectionHandle: string;\n }\n | {\n mode: \"instant-search\";\n }\n );\n search: {\n searchTerm: string;\n setSearchTerm: React.Dispatch<React.SetStateAction<string>>;\n showInstantSearchResults: boolean;\n setShowInstantSearchResults: React.Dispatch<\n React.SetStateAction<boolean>\n >;\n };\n sortby: {\n sortOption: string;\n setSortOption: React.Dispatch<React.SetStateAction<string>>;\n };\n results: {\n results: ReactivesearchResultProps[\"data\"];\n setResults: React.Dispatch<\n React.SetStateAction<ReactivesearchResultProps[\"data\"]>\n >;\n resultStats?: ReactivesearchResultProps[\"resultStats\"];\n setResultStats: React.Dispatch<\n React.SetStateAction<\n ReactivesearchResultProps[\"resultStats\"] | undefined\n >\n >;\n };\n }\n | undefined\n>(undefined);\n\nexport const useReactifySearchContext = () =>\n React.useContext(ReactifySearchContext)!;\n"]}
1
+ {"version":3,"file":"useReactifySearchContext.js","sourceRoot":"","sources":["../../../src/hooks/useReactifySearchContext.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAOb,QAAA,qBAAqB,GAAG,eAAK,CAAC,aAAa,CAsDtD,SAAS,CAAC,CAAC;AAEN,MAAM,wBAAwB,GAAG,GAAG,EAAE,CAC3C,eAAK,CAAC,UAAU,CAAC,6BAAqB,CAAE,CAAC;AAD9B,QAAA,wBAAwB,4BACM","sourcesContent":["import React from \"react\";\n\nimport { Config, ReactivesearchResultProps } from \"../types\";\nimport { Flags } from \"./useFlags\";\n\nexport type ReactifySearchMode = \"search\" | \"collection\" | \"instant-search\";\n\nexport const ReactifySearchContext = React.createContext<\n | {\n config: Config;\n options: {\n clientId: string;\n mode: ReactifySearchMode;\n index: string;\n shopifyPermanentDomain: string;\n filtersHandle?: string;\n credentials?: string;\n onRedirect?: (type: \"redirect\" | \"search\", url: string) => void;\n theme: Record<string, unknown>;\n additionalComponentIds?: Array<string>;\n includeFields?: Array<string>;\n excludeFields?: Array<string>;\n flags?: Record<Flags, boolean>;\n } & (\n | {\n mode: \"search\";\n }\n | {\n mode: \"collection\";\n collectionHandle: string;\n }\n | {\n mode: \"instant-search\";\n }\n );\n search: {\n searchTerm: string;\n setSearchTerm: React.Dispatch<React.SetStateAction<string>>;\n showInstantSearchResults: boolean;\n setShowInstantSearchResults: React.Dispatch<\n React.SetStateAction<boolean>\n >;\n };\n sortby: {\n sortOption: string;\n setSortOption: React.Dispatch<React.SetStateAction<string>>;\n };\n results: {\n results: ReactivesearchResultProps[\"data\"];\n setResults: React.Dispatch<\n React.SetStateAction<ReactivesearchResultProps[\"data\"]>\n >;\n resultStats?: ReactivesearchResultProps[\"resultStats\"];\n setResultStats: React.Dispatch<\n React.SetStateAction<\n ReactivesearchResultProps[\"resultStats\"] | undefined\n >\n >;\n };\n }\n | undefined\n>(undefined);\n\nexport const useReactifySearchContext = () =>\n React.useContext(ReactifySearchContext)!;\n"]}
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": "5.32.0",
4
+ "version": "6.0.0",
5
5
  "license": "MIT",
6
6
  "main": "dist/src/index.js",
7
7
  "types": "dist/src/index.d.ts",
@@ -19,9 +19,6 @@
19
19
  "build": "tsc",
20
20
  "prettier": "prettier --write .",
21
21
  "start": "start-storybook -p 6006",
22
- "sentry:release:new": "sentry-cli releases new $npm_package_version",
23
- "sentry:release:upload": "sentry-cli releases files $npm_package_version upload-sourcemaps dist",
24
- "sentry:release:finalize": "sentry-cli releases finalize $npm_package_version",
25
22
  "prepare": "husky install"
26
23
  },
27
24
  "commitlint": {