typesense-instantsearch-adapter 2.3.0 → 2.4.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/index.d.ts
CHANGED
|
@@ -1,43 +1,101 @@
|
|
|
1
|
-
type SearchClient =
|
|
1
|
+
type SearchClient = any;
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
port: string;
|
|
6
|
-
protocol: "https" | "http";
|
|
7
|
-
path?: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface TypesenseServer {
|
|
11
|
-
apiKey: string;
|
|
12
|
-
nodes: TypesenseNode[];
|
|
13
|
-
}
|
|
3
|
+
import type { ConfigurationOptions } from "typesense/lib/Typesense/Configuration";
|
|
4
|
+
import type { SearchParams } from "typesense/lib/Typesense/Documents";
|
|
14
5
|
|
|
15
|
-
interface BaseSearchParameters {
|
|
6
|
+
interface BaseSearchParameters extends Omit<SearchParams, "q" | "query_by" | "filter_by"> {
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Please use the snake_cased version of this parameter
|
|
9
|
+
*/
|
|
16
10
|
queryByWeights?: string;
|
|
17
|
-
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Please use the snake_cased version of this parameter
|
|
13
|
+
*/
|
|
18
14
|
sortBy?: string;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Please use the snake_cased version of this parameter
|
|
17
|
+
*/
|
|
19
18
|
maxFacetValues?: number;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Please use the snake_cased version of this parameter
|
|
21
|
+
*/
|
|
20
22
|
perPage?: number;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated Please use the snake_cased version of this parameter
|
|
25
|
+
*/
|
|
21
26
|
includeFields?: string;
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated Please use the snake_cased version of this parameter
|
|
29
|
+
*/
|
|
22
30
|
excludeFields?: string;
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated Please use the snake_cased version of this parameter
|
|
33
|
+
*/
|
|
23
34
|
highlightFields?: string;
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated Please use the snake_cased version of this parameter
|
|
37
|
+
*/
|
|
24
38
|
highlightFullFields?: string;
|
|
25
|
-
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated Please use the snake_cased version of this parameter
|
|
41
|
+
*/
|
|
42
|
+
numTypos?: string;
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated Please use the snake_cased version of this parameter
|
|
45
|
+
*/
|
|
26
46
|
typoTokensThreshold?: number;
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated Please use the snake_cased version of this parameter
|
|
49
|
+
*/
|
|
27
50
|
dropTokensThreshold?: number;
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated Please use the snake_cased version of this parameter
|
|
53
|
+
*/
|
|
28
54
|
pinnedHits?: string;
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated Please use the snake_cased version of this parameter
|
|
57
|
+
*/
|
|
29
58
|
hiddenHits?: string;
|
|
59
|
+
/**
|
|
60
|
+
* @deprecated Please use the snake_cased version of this parameter
|
|
61
|
+
*/
|
|
30
62
|
enableOverrides?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* @deprecated Please use the snake_cased version of this parameter
|
|
65
|
+
*/
|
|
31
66
|
preSegmentedQuery?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* @deprecated Please use the snake_cased version of this parameter
|
|
69
|
+
*/
|
|
32
70
|
limitHits?: number;
|
|
71
|
+
/**
|
|
72
|
+
* @deprecated Please use the snake_cased version of this parameter
|
|
73
|
+
*/
|
|
74
|
+
groupBy?: string;
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated Please use the snake_cased version of this parameter
|
|
77
|
+
*/
|
|
78
|
+
groupLimit?: number;
|
|
79
|
+
/**
|
|
80
|
+
* @deprecated Please use the snake_cased version of this parameter
|
|
81
|
+
*/
|
|
82
|
+
exhaustiveSearch?: boolean;
|
|
33
83
|
}
|
|
34
84
|
|
|
35
85
|
interface SearchParametersWithQueryBy extends BaseSearchParameters {
|
|
36
|
-
|
|
86
|
+
/**
|
|
87
|
+
* @deprecated Please use the snake_cased version of this parameter
|
|
88
|
+
*/
|
|
89
|
+
queryBy?: string;
|
|
90
|
+
query_by: string;
|
|
37
91
|
}
|
|
38
92
|
|
|
39
93
|
interface SearchParametersOptionalQueryBy extends BaseSearchParameters {
|
|
94
|
+
/**
|
|
95
|
+
* @deprecated Please use the snake_cased version of this parameter
|
|
96
|
+
*/
|
|
40
97
|
queryBy?: string;
|
|
98
|
+
query_by?: string;
|
|
41
99
|
}
|
|
42
100
|
|
|
43
101
|
interface CollectionSearchParametersWithQueryBy {
|
|
@@ -49,9 +107,8 @@ interface CollectionSearchParametersOptionalQueryBy {
|
|
|
49
107
|
}
|
|
50
108
|
|
|
51
109
|
interface BaseAdapterOptions {
|
|
52
|
-
server:
|
|
110
|
+
server: ConfigurationOptions;
|
|
53
111
|
geoLocationField?: string;
|
|
54
|
-
cacheSearchResultsForSeconds?: number;
|
|
55
112
|
}
|
|
56
113
|
|
|
57
114
|
interface AdditionalSearchParametersWithQueryBy extends BaseAdapterOptions {
|
package/lib/Configuration.js
CHANGED
|
@@ -27,33 +27,39 @@ var Configuration = /*#__PURE__*/function () {
|
|
|
27
27
|
};
|
|
28
28
|
this.server.cacheSearchResultsForSeconds = this.server.cacheSearchResultsForSeconds == null ? 2 * 60 : this.server.cacheSearchResultsForSeconds;
|
|
29
29
|
this.additionalSearchParameters = options.additionalSearchParameters || {};
|
|
30
|
-
this.additionalSearchParameters.
|
|
31
|
-
this.additionalSearchParameters.
|
|
32
|
-
this.additionalSearchParameters.highlightFullFields = this.additionalSearchParameters.highlightFullFields || this.additionalSearchParameters.
|
|
30
|
+
this.additionalSearchParameters.query_by = this.additionalSearchParameters.queryBy || this.additionalSearchParameters.query_by || "";
|
|
31
|
+
this.additionalSearchParameters.sort_by = this.additionalSearchParameters.sortBy || this.additionalSearchParameters.sort_by || "";
|
|
32
|
+
this.additionalSearchParameters.highlightFullFields = this.additionalSearchParameters.highlightFullFields || this.additionalSearchParameters.highlight_full_fields || this.additionalSearchParameters.query_by;
|
|
33
33
|
this.geoLocationField = options.geoLocationField || "_geoloc";
|
|
34
34
|
this.collectionSpecificSearchParameters = options.collectionSpecificSearchParameters || {};
|
|
35
35
|
Object.keys(this.collectionSpecificSearchParameters).forEach(function (collection) {
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
36
|
+
var params = _this.collectionSpecificSearchParameters[collection];
|
|
37
|
+
params.query_by = params.queryBy || params.query_by || "";
|
|
38
|
+
params.sort_by = params.sortBy || params.sort_by || "";
|
|
39
|
+
params.highlightFullFields = params.highlightFullFields || params.highlight_full_fields || params.query_by;
|
|
41
40
|
});
|
|
42
41
|
}
|
|
43
|
-
/*
|
|
44
|
-
* Either additionalSearchParameters.queryBy needs to be set, or
|
|
45
|
-
* All collectionSpecificSearchParameters need to have queryBy
|
|
46
|
-
*
|
|
47
|
-
* */
|
|
48
|
-
|
|
49
42
|
|
|
50
43
|
(0, _createClass2["default"])(Configuration, [{
|
|
51
44
|
key: "validate",
|
|
52
45
|
value: function validate() {
|
|
53
|
-
if
|
|
54
|
-
|
|
46
|
+
// Warn if camelCased parameters are used, suggest using snake_cased parameters instead
|
|
47
|
+
if (this.additionalSearchParameters.queryBy || Object.values(this.collectionSpecificSearchParameters).some(function (c) {
|
|
48
|
+
return c.queryBy;
|
|
55
49
|
})) {
|
|
56
|
-
|
|
50
|
+
console.warn("[typesense-instantsearch-adapter] Please use snake_cased versions of parameters in additionalSearchParameters instead of camelCased parameters. For example: Use query_by instead of queryBy. camelCased parameters will be deprecated in a future version." + " We're making this change so that parameter names are identical to the ones sent to Typesense (which are all snake_cased), and to also keep the types for these parameters in sync with the types defined in typesense-js.");
|
|
51
|
+
}
|
|
52
|
+
/*
|
|
53
|
+
* Either additionalSearchParameters.query_by needs to be set, or
|
|
54
|
+
* All collectionSpecificSearchParameters need to have query_by
|
|
55
|
+
*
|
|
56
|
+
* */
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
if (this.additionalSearchParameters.query_by.length === 0 && (Object.keys(this.collectionSpecificSearchParameters).length === 0 || Object.values(this.collectionSpecificSearchParameters).some(function (c) {
|
|
60
|
+
return (c.query_by || "").length === 0;
|
|
61
|
+
}))) {
|
|
62
|
+
throw new Error("[typesense-instantsearch-adapter] Missing parameter: Either additionalSearchParameters.query_by needs to be set, or all collectionSpecificSearchParameters need to have .query_by set");
|
|
57
63
|
}
|
|
58
64
|
}
|
|
59
65
|
}]);
|
package/lib/Configuration.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Configuration.js"],"names":["Configuration","options","server","nodes","host","port","path","protocol","cacheSearchResultsForSeconds","additionalSearchParameters","queryBy","sortBy","highlightFullFields","geoLocationField","collectionSpecificSearchParameters","Object","keys","forEach","collection","
|
|
1
|
+
{"version":3,"sources":["../src/Configuration.js"],"names":["Configuration","options","server","nodes","host","port","path","protocol","cacheSearchResultsForSeconds","additionalSearchParameters","query_by","queryBy","sort_by","sortBy","highlightFullFields","highlight_full_fields","geoLocationField","collectionSpecificSearchParameters","Object","keys","forEach","collection","params","values","some","c","console","warn","length","Error"],"mappings":"AAAA;;;;;;;;;;;;;IAEaA,a;AACX,2BAA0B;AAAA;;AAAA,QAAdC,OAAc,uEAAJ,EAAI;AAAA;AACxB,SAAKC,MAAL,GAAcD,OAAO,CAACC,MAAR,IAAkB;AAC9BC,MAAAA,KAAK,EAAE,CACL;AACEC,QAAAA,IAAI,EAAE,WADR;AAEEC,QAAAA,IAAI,EAAE,MAFR;AAGEC,QAAAA,IAAI,EAAE,EAHR;AAIEC,QAAAA,QAAQ,EAAE;AAJZ,OADK;AADuB,KAAhC;AAWA,SAAKL,MAAL,CAAYM,4BAAZ,GACE,KAAKN,MAAL,CAAYM,4BAAZ,IAA4C,IAA5C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kCAAnB,EAAuDO,IAAvD,CAA4D,UAACC,CAAD;AAAA,eAAOA,CAAC,CAACd,OAAT;AAAA,OAA5D,CAFF,EAGE;AACAe,QAAAA,OAAO,CAACC,IAAR,CACE,gQACE,4NAFJ;AAID;AAED;AACJ;AACA;AACA;AACA;;;AACI,UACE,KAAKlB,0BAAL,CAAgCC,QAAhC,CAAyCkB,MAAzC,KAAoD,CAApD,KACCV,MAAM,CAACC,IAAP,CAAY,KAAKF,kCAAjB,EAAqDW,MAArD,KAAgE,CAAhE,IACCV,MAAM,CAACK,MAAP,CAAc,KAAKN,kCAAnB,EAAuDO,IAAvD,CAA4D,UAACC,CAAD;AAAA,eAAO,CAACA,CAAC,CAACf,QAAF,IAAc,EAAf,EAAmBkB,MAAnB,KAA8B,CAArC;AAAA,OAA5D,CAFF,CADF,EAIE;AACA,cAAM,IAAIC,KAAJ,CACJ,uLADI,CAAN;AAGD;AACF","sourcesContent":["\"use strict\";\n\nexport class Configuration {\n constructor(options = {}) {\n this.server = options.server || {\n nodes: [\n {\n host: \"localhost\",\n port: \"8108\",\n path: \"\",\n protocol: \"http\",\n },\n ],\n };\n\n this.server.cacheSearchResultsForSeconds =\n this.server.cacheSearchResultsForSeconds == null ? 2 * 60 : this.server.cacheSearchResultsForSeconds;\n\n this.additionalSearchParameters = options.additionalSearchParameters || {};\n\n this.additionalSearchParameters.query_by =\n this.additionalSearchParameters.queryBy || this.additionalSearchParameters.query_by || \"\";\n\n this.additionalSearchParameters.sort_by =\n this.additionalSearchParameters.sortBy || this.additionalSearchParameters.sort_by || \"\";\n\n this.additionalSearchParameters.highlightFullFields =\n this.additionalSearchParameters.highlightFullFields ||\n this.additionalSearchParameters.highlight_full_fields ||\n this.additionalSearchParameters.query_by;\n\n this.geoLocationField = options.geoLocationField || \"_geoloc\";\n\n this.collectionSpecificSearchParameters = options.collectionSpecificSearchParameters || {};\n\n Object.keys(this.collectionSpecificSearchParameters).forEach((collection) => {\n const params = this.collectionSpecificSearchParameters[collection];\n params.query_by = params.queryBy || params.query_by || \"\";\n params.sort_by = params.sortBy || params.sort_by || \"\";\n params.highlightFullFields = params.highlightFullFields || params.highlight_full_fields || params.query_by;\n });\n }\n\n validate() {\n // Warn if camelCased parameters are used, suggest using snake_cased parameters instead\n if (\n this.additionalSearchParameters.queryBy ||\n Object.values(this.collectionSpecificSearchParameters).some((c) => c.queryBy)\n ) {\n console.warn(\n \"[typesense-instantsearch-adapter] Please use snake_cased versions of parameters in additionalSearchParameters instead of camelCased parameters. For example: Use query_by instead of queryBy. camelCased parameters will be deprecated in a future version.\" +\n \" We're making this change so that parameter names are identical to the ones sent to Typesense (which are all snake_cased), and to also keep the types for these parameters in sync with the types defined in typesense-js.\"\n );\n }\n\n /*\n * Either additionalSearchParameters.query_by needs to be set, or\n * All collectionSpecificSearchParameters need to have query_by\n *\n * */\n if (\n this.additionalSearchParameters.query_by.length === 0 &&\n (Object.keys(this.collectionSpecificSearchParameters).length === 0 ||\n Object.values(this.collectionSpecificSearchParameters).some((c) => (c.query_by || \"\").length === 0))\n ) {\n throw new Error(\n \"[typesense-instantsearch-adapter] Missing parameter: Either additionalSearchParameters.query_by needs to be set, or all collectionSpecificSearchParameters need to have .query_by set\"\n );\n }\n }\n}\n"],"file":"Configuration.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typesense-instantsearch-adapter",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Adapter to use InstantSearch UI widgets with Typesense Search",
|
|
5
5
|
"homepage": "https://github.com/typesense/typesense-instantsearch-adapter",
|
|
6
6
|
"main": "lib/TypesenseInstantsearchAdapter.js",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"typescript": "^4.2.4"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"typesense": "^
|
|
84
|
+
"typesense": "^1.2.1"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
87
|
"@babel/runtime": "^7.13.17"
|