@usereactify/search 5.28.0 → 5.29.1

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,15 @@
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
+ ### [5.29.1](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.29.0...release-v5.29.1) (2023-08-17)
6
+
7
+ ## [5.29.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.28.0...release-v5.29.0) (2023-08-16)
8
+
9
+
10
+ ### Features
11
+
12
+ * add loading field to useResults ([3441e12](https://bitbucket.org/usereactify/reactify-search-ui/commit/3441e128198720b0eb27ca332b5e3b98af21d2fb))
13
+
5
14
  ## [5.28.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.27.1...release-v5.28.0) (2023-08-16)
6
15
 
7
16
 
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.28.0",
4
+ "version": "5.29.1",
5
5
  "license": "MIT",
6
6
  "main": "dist/src/index.js",
7
7
  "types": "dist/src/index.d.ts",
@@ -32,7 +32,11 @@ 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://${config.endpoint}/_cat/indices?format=json`).then((response) => response.json());
35
+ const response = yield fetch(`https://api.search.reactify.app/_cat/indices?format=json`, {
36
+ headers: {
37
+ "x-reactify-index": config.index,
38
+ },
39
+ }).then((response) => response.json());
36
40
  const regexp = new RegExp(`${shopName}-[0-9]`);
37
41
  setIndices(response
38
42
  .map((item) => item.index)
@@ -1 +1 @@
1
- {"version":3,"file":"useIndices.js","sourceRoot":"","sources":["../../../src/hooks/useIndices.ts"],"names":[],"mappings":";;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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;AA1CW,QAAA,UAAU,cA0CrB","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://${config.endpoint}/_cat/indices?format=json`\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","sour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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;AA/CW,QAAA,UAAU,cA+CrB","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 },\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"]}
@@ -2,6 +2,8 @@ import React from "react";
2
2
  import { ReactivesearchResultProps } from "../types";
3
3
  /** This hook must never be used to render results */
4
4
  export declare const useResults: () => {
5
+ /** Equals true until first load has completed */
6
+ loading: boolean;
5
7
  /** All of the current results */
6
8
  results: ReactivesearchResultProps["data"];
7
9
  /** Function for setting the current results */
@@ -1,14 +1,24 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.useResults = void 0;
7
+ const react_1 = __importDefault(require("react"));
4
8
  const hooks_1 = require("../hooks");
5
9
  const utility_1 = require("../utility");
6
10
  /** This hook must never be used to render results */
7
11
  const useResults = () => {
12
+ var _a;
8
13
  const { results } = (0, hooks_1.useReactifySearchContext)();
14
+ const loading = react_1.default.useMemo(() => {
15
+ var _a;
16
+ return typeof ((_a = results.resultStats) === null || _a === void 0 ? void 0 : _a.numberOfResults) === "undefined";
17
+ }, [(_a = results.resultStats) === null || _a === void 0 ? void 0 : _a.numberOfResults]);
9
18
  utility_1.debug.hook("useResults", "results", results.results);
10
19
  utility_1.debug.hook("useResults", "resultStats", results.resultStats);
11
20
  return {
21
+ loading: loading,
12
22
  results: results.results,
13
23
  setResults: results.setResults,
14
24
  resultStats: results.resultStats,
@@ -1 +1 @@
1
- {"version":3,"file":"useResults.js","sourceRoot":"","sources":["../../../src/hooks/useResults.ts"],"names":[],"mappings":";;;AAGA,oCAAoD;AACpD,wCAAmC;AAEnC,qDAAqD;AAC9C,MAAM,UAAU,GAAG,GAaxB,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAE/C,eAAK,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACrD,eAAK,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAE7D,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,cAAc,EAAE,OAAO,CAAC,cAAc;KACvC,CAAC;AACJ,CAAC,CAAC;AAzBW,QAAA,UAAU,cAyBrB","sourcesContent":["import React from \"react\";\n\nimport { ReactivesearchResultProps } from \"../types\";\nimport { useReactifySearchContext } from \"../hooks\";\nimport { debug } from \"../utility\";\n\n/** This hook must never be used to render results */\nexport const useResults = (): {\n /** All of the current results */\n results: ReactivesearchResultProps[\"data\"];\n /** Function for setting the current results */\n setResults: React.Dispatch<\n React.SetStateAction<ReactivesearchResultProps[\"data\"]>\n >;\n /** All of the current result stats */\n resultStats?: ReactivesearchResultProps[\"resultStats\"];\n /** Function for setting the current result stats */\n setResultStats: React.Dispatch<\n React.SetStateAction<ReactivesearchResultProps[\"resultStats\"] | undefined>\n >;\n} => {\n const { results } = useReactifySearchContext();\n\n debug.hook(\"useResults\", \"results\", results.results);\n debug.hook(\"useResults\", \"resultStats\", results.resultStats);\n\n return {\n results: results.results,\n setResults: results.setResults,\n resultStats: results.resultStats,\n setResultStats: results.setResultStats,\n };\n};\n"]}
1
+ {"version":3,"file":"useResults.js","sourceRoot":"","sources":["../../../src/hooks/useResults.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,oCAAoD;AACpD,wCAAmC;AAEnC,qDAAqD;AAC9C,MAAM,UAAU,GAAG,GAexB,EAAE;;IACF,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAE/C,MAAM,OAAO,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;;QACjC,OAAO,OAAO,CAAA,MAAA,OAAO,CAAC,WAAW,0CAAE,eAAe,CAAA,KAAK,WAAW,CAAC;IACrE,CAAC,EAAE,CAAC,MAAA,OAAO,CAAC,WAAW,0CAAE,eAAe,CAAC,CAAC,CAAC;IAE3C,eAAK,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACrD,eAAK,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAE7D,OAAO;QACL,OAAO,EAAE,OAAO;QAChB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,cAAc,EAAE,OAAO,CAAC,cAAc;KACvC,CAAC;AACJ,CAAC,CAAC;AAhCW,QAAA,UAAU,cAgCrB","sourcesContent":["import React from \"react\";\n\nimport { ReactivesearchResultProps } from \"../types\";\nimport { useReactifySearchContext } from \"../hooks\";\nimport { debug } from \"../utility\";\n\n/** This hook must never be used to render results */\nexport const useResults = (): {\n /** Equals true until first load has completed */\n loading: boolean;\n /** All of the current results */\n results: ReactivesearchResultProps[\"data\"];\n /** Function for setting the current results */\n setResults: React.Dispatch<\n React.SetStateAction<ReactivesearchResultProps[\"data\"]>\n >;\n /** All of the current result stats */\n resultStats?: ReactivesearchResultProps[\"resultStats\"];\n /** Function for setting the current result stats */\n setResultStats: React.Dispatch<\n React.SetStateAction<ReactivesearchResultProps[\"resultStats\"] | undefined>\n >;\n} => {\n const { results } = useReactifySearchContext();\n\n const loading = React.useMemo(() => {\n return typeof results.resultStats?.numberOfResults === \"undefined\";\n }, [results.resultStats?.numberOfResults]);\n\n debug.hook(\"useResults\", \"results\", results.results);\n debug.hook(\"useResults\", \"resultStats\", results.resultStats);\n\n return {\n loading: loading,\n results: results.results,\n setResults: results.setResults,\n resultStats: results.resultStats,\n setResultStats: results.setResultStats,\n };\n};\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.28.0",
4
+ "version": "5.29.1",
5
5
  "license": "MIT",
6
6
  "main": "dist/src/index.js",
7
7
  "types": "dist/src/index.d.ts",