@brostark/solutions-client 1.1.11 → 1.1.13
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/api/v1/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/api/v1/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAKjE;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM;IAE5D;;;;OAIG;gCAC8B,WAAW;IAK5C;;;;OAIG;+BAC8B,iBAAiB,CAAC,MAAM,CAAC,sBAAsB;IAMhF;;;;OAIG;6BAC4B,MAAM;IAMrC;;;;;OAKG;sCACqC,MAAM,aAAa,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;IAMpF;;;;;OAKG;qCACoC,MAAM,cAAc,MAAM;IAMjE;;;;;OAKG;sCACqC,MAAM,cAAc,MAAM;IAMlE;;;;;OAKG;4BAC2B,MAAM,SAAS,iBAAiB,CAAC,MAAM,CAAC,WAAW,KAAG,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,YAAY,CAAC;CAcrI,CAAA"}
|
package/dist/api/v1/search.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateSearchAPI = void 0;
|
|
4
4
|
const httpRequest_1 = require("../../lib/httpRequest");
|
|
5
|
+
const helper_1 = require("../../helper");
|
|
5
6
|
/**
|
|
6
7
|
* Generates an API to manage search
|
|
7
8
|
* @param apiUrl - The API URL
|
|
@@ -65,7 +66,7 @@ const generateSearchAPI = (apiUrl, apiKey) => {
|
|
|
65
66
|
*/
|
|
66
67
|
getDocumentById: async (collectionName, documentId) => {
|
|
67
68
|
const response = await (0, httpRequest_1.httpGetRequest)(`${apiUrl}/search/collections/${collectionName}/documents/${documentId}`, apiKey);
|
|
68
|
-
return response
|
|
69
|
+
return response;
|
|
69
70
|
},
|
|
70
71
|
/**
|
|
71
72
|
* Searches for documents in a search collection
|
|
@@ -74,13 +75,13 @@ const generateSearchAPI = (apiUrl, apiKey) => {
|
|
|
74
75
|
* @returns A promise with the search results
|
|
75
76
|
*/
|
|
76
77
|
query: async (collectionName, query) => {
|
|
77
|
-
const urlQuery =
|
|
78
|
+
const urlQuery = {};
|
|
78
79
|
Object.entries(query).forEach(([key, value]) => {
|
|
79
80
|
if (value !== undefined && value !== null) {
|
|
80
|
-
urlQuery
|
|
81
|
+
urlQuery[key] = String(value);
|
|
81
82
|
}
|
|
82
83
|
});
|
|
83
|
-
const response = await (0, httpRequest_1.httpGetRequest)(`${apiUrl}/search/collections/${collectionName}/query
|
|
84
|
+
const response = await (0, httpRequest_1.httpGetRequest)((0, helper_1.buildUrlWithParams)(`${apiUrl}/search/collections/${collectionName}/query`, urlQuery), apiKey);
|
|
84
85
|
return response;
|
|
85
86
|
},
|
|
86
87
|
};
|
package/package.json
CHANGED
package/src/api/v1/search.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BrostarkSolutions, ListOptions } from "../../lib/types";
|
|
2
2
|
import { httpDeleteRequest, httpGetRequest, httpListRequest, httpPostRequest } from "../../lib/httpRequest";
|
|
3
|
+
import { buildUrlWithParams } from "../../helper";
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -75,7 +76,7 @@ export const generateSearchAPI = (apiUrl: string, apiKey: string) => {
|
|
|
75
76
|
getDocumentById: async (collectionName: string, documentId: string) => {
|
|
76
77
|
const response = await httpGetRequest(`${apiUrl}/search/collections/${collectionName}/documents/${documentId}`, apiKey);
|
|
77
78
|
|
|
78
|
-
return response
|
|
79
|
+
return response;
|
|
79
80
|
},
|
|
80
81
|
|
|
81
82
|
/**
|
|
@@ -85,15 +86,15 @@ export const generateSearchAPI = (apiUrl: string, apiKey: string) => {
|
|
|
85
86
|
* @returns A promise with the search results
|
|
86
87
|
*/
|
|
87
88
|
query: async (collectionName: string, query: BrostarkSolutions.Search.SearchQuery): Promise<BrostarkSolutions.Search.SearchResult> => {
|
|
88
|
-
const urlQuery =
|
|
89
|
+
const urlQuery: Record<string, string> = {}
|
|
89
90
|
|
|
90
91
|
Object.entries(query).forEach(([key, value]) => {
|
|
91
92
|
if (value !== undefined && value !== null) {
|
|
92
|
-
urlQuery
|
|
93
|
+
urlQuery[key] = String(value);
|
|
93
94
|
}
|
|
94
95
|
});
|
|
95
96
|
|
|
96
|
-
const response = await httpGetRequest(`${apiUrl}/search/collections/${collectionName}/query
|
|
97
|
+
const response = await httpGetRequest(buildUrlWithParams(`${apiUrl}/search/collections/${collectionName}/query`, urlQuery), apiKey);
|
|
97
98
|
|
|
98
99
|
return response;
|
|
99
100
|
},
|