@brostark/solutions-client 1.1.12 → 1.1.14
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/dist/api/v1/search.d.ts +7 -0
- package/dist/api/v1/search.d.ts.map +1 -1
- package/dist/api/v1/search.js +14 -3
- package/package.json +1 -1
- package/src/api/v1/search.ts +16 -3
package/dist/api/v1/search.d.ts
CHANGED
|
@@ -38,6 +38,13 @@ export declare const generateSearchAPI: (apiUrl: string, apiKey: string) => {
|
|
|
38
38
|
* @returns A promise with the deleted document
|
|
39
39
|
*/
|
|
40
40
|
deleteDocument: (collectionName: string, documentId: string) => Promise<any>;
|
|
41
|
+
/**
|
|
42
|
+
* Deletes multiple documents from a search collection
|
|
43
|
+
* @param collectionName - The name of the collection to delete the documents from
|
|
44
|
+
* @param documentIds - The IDs of the documents to delete
|
|
45
|
+
* @returns A promise with the deleted documents
|
|
46
|
+
*/
|
|
47
|
+
deleteMultipleDocuments: (collectionName: string, documentIds: string[]) => Promise<any>;
|
|
41
48
|
/**
|
|
42
49
|
* Gets a document from a search collection by its ID
|
|
43
50
|
* @param collectionName - The name of the collection to get the document from
|
|
@@ -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;8CAC6C,MAAM,eAAe,MAAM,EAAE;IAM7E;;;;;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
|
|
@@ -57,6 +58,16 @@ const generateSearchAPI = (apiUrl, apiKey) => {
|
|
|
57
58
|
const response = await (0, httpRequest_1.httpDeleteRequest)(`${apiUrl}/search/collections/${collectionName}/documents/${documentId}`, apiKey);
|
|
58
59
|
return response.data;
|
|
59
60
|
},
|
|
61
|
+
/**
|
|
62
|
+
* Deletes multiple documents from a search collection
|
|
63
|
+
* @param collectionName - The name of the collection to delete the documents from
|
|
64
|
+
* @param documentIds - The IDs of the documents to delete
|
|
65
|
+
* @returns A promise with the deleted documents
|
|
66
|
+
*/
|
|
67
|
+
deleteMultipleDocuments: async (collectionName, documentIds) => {
|
|
68
|
+
const response = await (0, httpRequest_1.httpPostRequest)(`${apiUrl}/search/collections/${collectionName}/documents/delete`, apiKey, { documentIds });
|
|
69
|
+
return response.data;
|
|
70
|
+
},
|
|
60
71
|
/**
|
|
61
72
|
* Gets a document from a search collection by its ID
|
|
62
73
|
* @param collectionName - The name of the collection to get the document from
|
|
@@ -74,13 +85,13 @@ const generateSearchAPI = (apiUrl, apiKey) => {
|
|
|
74
85
|
* @returns A promise with the search results
|
|
75
86
|
*/
|
|
76
87
|
query: async (collectionName, query) => {
|
|
77
|
-
const urlQuery =
|
|
88
|
+
const urlQuery = {};
|
|
78
89
|
Object.entries(query).forEach(([key, value]) => {
|
|
79
90
|
if (value !== undefined && value !== null) {
|
|
80
|
-
urlQuery
|
|
91
|
+
urlQuery[key] = String(value);
|
|
81
92
|
}
|
|
82
93
|
});
|
|
83
|
-
const response = await (0, httpRequest_1.httpGetRequest)(`${apiUrl}/search/collections/${collectionName}/query
|
|
94
|
+
const response = await (0, httpRequest_1.httpGetRequest)((0, helper_1.buildUrlWithParams)(`${apiUrl}/search/collections/${collectionName}/query`, urlQuery), apiKey);
|
|
84
95
|
return response;
|
|
85
96
|
},
|
|
86
97
|
};
|
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
|
/**
|
|
@@ -66,6 +67,18 @@ export const generateSearchAPI = (apiUrl: string, apiKey: string) => {
|
|
|
66
67
|
return response.data;
|
|
67
68
|
},
|
|
68
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Deletes multiple documents from a search collection
|
|
72
|
+
* @param collectionName - The name of the collection to delete the documents from
|
|
73
|
+
* @param documentIds - The IDs of the documents to delete
|
|
74
|
+
* @returns A promise with the deleted documents
|
|
75
|
+
*/
|
|
76
|
+
deleteMultipleDocuments: async (collectionName: string, documentIds: string[]) => {
|
|
77
|
+
const response = await httpPostRequest(`${apiUrl}/search/collections/${collectionName}/documents/delete`, apiKey, { documentIds });
|
|
78
|
+
|
|
79
|
+
return response.data;
|
|
80
|
+
},
|
|
81
|
+
|
|
69
82
|
/**
|
|
70
83
|
* Gets a document from a search collection by its ID
|
|
71
84
|
* @param collectionName - The name of the collection to get the document from
|
|
@@ -85,15 +98,15 @@ export const generateSearchAPI = (apiUrl: string, apiKey: string) => {
|
|
|
85
98
|
* @returns A promise with the search results
|
|
86
99
|
*/
|
|
87
100
|
query: async (collectionName: string, query: BrostarkSolutions.Search.SearchQuery): Promise<BrostarkSolutions.Search.SearchResult> => {
|
|
88
|
-
const urlQuery =
|
|
101
|
+
const urlQuery: Record<string, string> = {}
|
|
89
102
|
|
|
90
103
|
Object.entries(query).forEach(([key, value]) => {
|
|
91
104
|
if (value !== undefined && value !== null) {
|
|
92
|
-
urlQuery
|
|
105
|
+
urlQuery[key] = String(value);
|
|
93
106
|
}
|
|
94
107
|
});
|
|
95
108
|
|
|
96
|
-
const response = await httpGetRequest(`${apiUrl}/search/collections/${collectionName}/query
|
|
109
|
+
const response = await httpGetRequest(buildUrlWithParams(`${apiUrl}/search/collections/${collectionName}/query`, urlQuery), apiKey);
|
|
97
110
|
|
|
98
111
|
return response;
|
|
99
112
|
},
|