@brostark/solutions-client 1.0.1 → 1.1.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/dist/api/v1/search.d.ts +27 -0
- package/dist/api/v1/search.d.ts.map +1 -1
- package/dist/api/v1/search.js +45 -0
- package/dist/client.d.ts +4 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/lib/types.d.ts +9 -0
- package/dist/lib/types.d.ts.map +1 -1
- package/package.json +7 -2
- package/src/api/v1/search.ts +56 -1
- package/src/lib/types.ts +11 -0
package/dist/api/v1/search.d.ts
CHANGED
|
@@ -18,5 +18,32 @@ export declare const generateSearchAPI: (apiUrl: string, apiKey: string) => {
|
|
|
18
18
|
* @returns A promise with the created search collection
|
|
19
19
|
*/
|
|
20
20
|
createCollection: (params: BrostarkSolutions.Search.CreateCollectionParams) => Promise<any>;
|
|
21
|
+
/**
|
|
22
|
+
* Deletes a search collection
|
|
23
|
+
* @param name - The name of the collection to delete
|
|
24
|
+
* @returns A promise with the deleted collection
|
|
25
|
+
*/
|
|
26
|
+
deleteCollection: (name: string) => Promise<any>;
|
|
27
|
+
/**
|
|
28
|
+
* Inserts a document into a search collection
|
|
29
|
+
* @param collectionName - The name of the collection to insert the document into
|
|
30
|
+
* @param document - The document to insert
|
|
31
|
+
* @returns A promise with the inserted document
|
|
32
|
+
*/
|
|
33
|
+
upsertDocument: (collectionName: string, document: Record<string, unknown>) => Promise<any>;
|
|
34
|
+
/**
|
|
35
|
+
* Deletes a document from a search collection
|
|
36
|
+
* @param collectionName - The name of the collection to delete the document from
|
|
37
|
+
* @param documentId - The ID of the document to delete
|
|
38
|
+
* @returns A promise with the deleted document
|
|
39
|
+
*/
|
|
40
|
+
deleteDocument: (collectionName: string, documentId: string) => Promise<any>;
|
|
41
|
+
/**
|
|
42
|
+
* Searches for documents in a search collection
|
|
43
|
+
* @param collectionName - The name of the collection to search in
|
|
44
|
+
* @param query - The query to search for
|
|
45
|
+
* @returns A promise with the search results
|
|
46
|
+
*/
|
|
47
|
+
search: (collectionName: string, query: BrostarkSolutions.Search.SearchQuery) => Promise<any>;
|
|
21
48
|
};
|
|
22
49
|
//# sourceMappingURL=search.d.ts.map
|
|
@@ -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;AAIjE;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM;IAE5D;;;;OAIG;gCAC8B,WAAW;IAK5C;;;;OAIG;+BAC8B,iBAAiB,CAAC,MAAM,CAAC,sBAAsB;
|
|
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;AAIjE;;;;;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;qCACoC,MAAM,YAAY,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAMhF;;;;;OAKG;qCACoC,MAAM,cAAc,MAAM;IAMjE;;;;;OAKG;6BAC4B,MAAM,SAAS,iBAAiB,CAAC,MAAM,CAAC,WAAW;CAcrF,CAAA"}
|
package/dist/api/v1/search.js
CHANGED
|
@@ -28,6 +28,51 @@ const generateSearchAPI = (apiUrl, apiKey) => {
|
|
|
28
28
|
const response = await (0, httpRequest_1.httpPostRequest)(`${apiUrl}/search/collections`, apiKey, params);
|
|
29
29
|
return response.data;
|
|
30
30
|
},
|
|
31
|
+
/**
|
|
32
|
+
* Deletes a search collection
|
|
33
|
+
* @param name - The name of the collection to delete
|
|
34
|
+
* @returns A promise with the deleted collection
|
|
35
|
+
*/
|
|
36
|
+
deleteCollection: async (name) => {
|
|
37
|
+
const response = await (0, httpRequest_1.httpDeleteRequest)(`${apiUrl}/search/collections/${name}`, apiKey);
|
|
38
|
+
return response.data;
|
|
39
|
+
},
|
|
40
|
+
/**
|
|
41
|
+
* Inserts a document into a search collection
|
|
42
|
+
* @param collectionName - The name of the collection to insert the document into
|
|
43
|
+
* @param document - The document to insert
|
|
44
|
+
* @returns A promise with the inserted document
|
|
45
|
+
*/
|
|
46
|
+
upsertDocument: async (collectionName, document) => {
|
|
47
|
+
const response = await (0, httpRequest_1.httpPostRequest)(`${apiUrl}/search/collections/${collectionName}/documents`, apiKey, document);
|
|
48
|
+
return response.data;
|
|
49
|
+
},
|
|
50
|
+
/**
|
|
51
|
+
* Deletes a document from a search collection
|
|
52
|
+
* @param collectionName - The name of the collection to delete the document from
|
|
53
|
+
* @param documentId - The ID of the document to delete
|
|
54
|
+
* @returns A promise with the deleted document
|
|
55
|
+
*/
|
|
56
|
+
deleteDocument: async (collectionName, documentId) => {
|
|
57
|
+
const response = await (0, httpRequest_1.httpDeleteRequest)(`${apiUrl}/search/collections/${collectionName}/documents/${documentId}`, apiKey);
|
|
58
|
+
return response.data;
|
|
59
|
+
},
|
|
60
|
+
/**
|
|
61
|
+
* Searches for documents in a search collection
|
|
62
|
+
* @param collectionName - The name of the collection to search in
|
|
63
|
+
* @param query - The query to search for
|
|
64
|
+
* @returns A promise with the search results
|
|
65
|
+
*/
|
|
66
|
+
search: async (collectionName, query) => {
|
|
67
|
+
const urlQuery = new URLSearchParams();
|
|
68
|
+
Object.entries(query).forEach(([key, value]) => {
|
|
69
|
+
if (value !== undefined && value !== null) {
|
|
70
|
+
urlQuery.set(key, String(value));
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
const response = await (0, httpRequest_1.httpGetRequest)(`${apiUrl}/search/collections/${collectionName}/search?${urlQuery.toString()}`, apiKey);
|
|
74
|
+
return response.data;
|
|
75
|
+
},
|
|
31
76
|
};
|
|
32
77
|
};
|
|
33
78
|
exports.generateSearchAPI = generateSearchAPI;
|
package/dist/client.d.ts
CHANGED
|
@@ -25,6 +25,10 @@ export declare function createClient(apiKey: string, options?: CreateClientOptio
|
|
|
25
25
|
search: {
|
|
26
26
|
listCollections: (options?: import("./lib/types").ListOptions) => Promise<any>;
|
|
27
27
|
createCollection: (params: import("./lib/types").BrostarkSolutions.Search.CreateCollectionParams) => Promise<any>;
|
|
28
|
+
deleteCollection: (name: string) => Promise<any>;
|
|
29
|
+
upsertDocument: (collectionName: string, document: Record<string, unknown>) => Promise<any>;
|
|
30
|
+
deleteDocument: (collectionName: string, documentId: string) => Promise<any>;
|
|
31
|
+
search: (collectionName: string, query: import("./lib/types").BrostarkSolutions.Search.SearchQuery) => Promise<any>;
|
|
28
32
|
};
|
|
29
33
|
};
|
|
30
34
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAyC,MAAM,YAAY,CAAC;AAE/E;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,+CAA+C;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,OAAO,CAAC,EAAE,UAAU,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAyC,MAAM,YAAY,CAAC;AAE/E;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,+CAA+C;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,OAAO,CAAC,EAAE,UAAU,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB;;;;;;;;;;;;;;;;EAY7E"}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -26,6 +26,15 @@ export declare namespace BrostarkSolutions {
|
|
|
26
26
|
defaultSortingField?: string;
|
|
27
27
|
metadata?: Record<string, unknown>;
|
|
28
28
|
}
|
|
29
|
+
interface SearchQuery {
|
|
30
|
+
query: string;
|
|
31
|
+
by?: string;
|
|
32
|
+
sortBy?: string;
|
|
33
|
+
filterBy?: string;
|
|
34
|
+
}
|
|
35
|
+
type Document = {
|
|
36
|
+
id: string;
|
|
37
|
+
} & Record<string, unknown>;
|
|
29
38
|
}
|
|
30
39
|
}
|
|
31
40
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,yBAAiB,iBAAiB,CAAC;IACjC,UAAiB,MAAM,CAAC;QACtB,KAAY,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,YAAY,GAAG,YAAY,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;QACtO,UAAiB,eAAe;YAC9B,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,EAAE,SAAS,CAAC;YAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;YACnB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,CAAC;YAChB,IAAI,CAAC,EAAE,OAAO,CAAC;YACf,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,KAAK,CAAC,EAAE,OAAO,CAAC;YAChB,IAAI,CAAC,EAAE,OAAO,CAAC;YACf,OAAO,CAAC,EAAE,MAAM,CAAC;YACjB,KAAK,CAAC,EAAE,OAAO,CAAC;YAChB,WAAW,CAAC,EAAE,OAAO,CAAC;YACtB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;SACtB;QAED,UAAiB,sBAAsB;YACrC,IAAI,EAAE,MAAM,CAAC;YACb,MAAM,EAAE,eAAe,EAAE,CAAC;YAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;YAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;SACpC;QAED,UAAiB,WAAW;YAC1B,KAAK,EAAE,MAAM,CAAC;YACd,EAAE,CAAC,EAAE,MAAM,CAAC;YACZ,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;SACnB;QAED,KAAY,QAAQ,GAAG;YACrB,EAAE,EAAE,MAAM,CAAC;SACZ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC7B;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brostark/solutions-client",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -14,7 +14,12 @@
|
|
|
14
14
|
"author": "Brostark Solutions",
|
|
15
15
|
"license": "ISC",
|
|
16
16
|
"description": "Brostark Solutions Client",
|
|
17
|
-
"keywords": [
|
|
17
|
+
"keywords": [
|
|
18
|
+
"brostark",
|
|
19
|
+
"solutions",
|
|
20
|
+
"client",
|
|
21
|
+
"api"
|
|
22
|
+
],
|
|
18
23
|
"devDependencies": {
|
|
19
24
|
"eslint": "^8.57.1",
|
|
20
25
|
"eslint-config-incredibilis": "^1.1.30",
|
package/src/api/v1/search.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BrostarkSolutions, ListOptions } from "../../lib/types";
|
|
2
|
-
import { httpListRequest, httpPostRequest } from "../../lib/httpRequest";
|
|
2
|
+
import { httpDeleteRequest, httpGetRequest, httpListRequest, httpPostRequest } from "../../lib/httpRequest";
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -30,5 +30,60 @@ export const generateSearchAPI = (apiUrl: string, apiKey: string) => {
|
|
|
30
30
|
|
|
31
31
|
return response.data;
|
|
32
32
|
},
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Deletes a search collection
|
|
36
|
+
* @param name - The name of the collection to delete
|
|
37
|
+
* @returns A promise with the deleted collection
|
|
38
|
+
*/
|
|
39
|
+
deleteCollection: async (name: string) => {
|
|
40
|
+
const response = await httpDeleteRequest(`${apiUrl}/search/collections/${name}`, apiKey);
|
|
41
|
+
|
|
42
|
+
return response.data;
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Inserts a document into a search collection
|
|
47
|
+
* @param collectionName - The name of the collection to insert the document into
|
|
48
|
+
* @param document - The document to insert
|
|
49
|
+
* @returns A promise with the inserted document
|
|
50
|
+
*/
|
|
51
|
+
upsertDocument: async (collectionName: string, document: Record<string, unknown>) => {
|
|
52
|
+
const response = await httpPostRequest(`${apiUrl}/search/collections/${collectionName}/documents`, apiKey, document);
|
|
53
|
+
|
|
54
|
+
return response.data;
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Deletes a document from a search collection
|
|
59
|
+
* @param collectionName - The name of the collection to delete the document from
|
|
60
|
+
* @param documentId - The ID of the document to delete
|
|
61
|
+
* @returns A promise with the deleted document
|
|
62
|
+
*/
|
|
63
|
+
deleteDocument: async (collectionName: string, documentId: string) => {
|
|
64
|
+
const response = await httpDeleteRequest(`${apiUrl}/search/collections/${collectionName}/documents/${documentId}`, apiKey);
|
|
65
|
+
|
|
66
|
+
return response.data;
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Searches for documents in a search collection
|
|
71
|
+
* @param collectionName - The name of the collection to search in
|
|
72
|
+
* @param query - The query to search for
|
|
73
|
+
* @returns A promise with the search results
|
|
74
|
+
*/
|
|
75
|
+
search: async (collectionName: string, query: BrostarkSolutions.Search.SearchQuery) => {
|
|
76
|
+
const urlQuery = new URLSearchParams();
|
|
77
|
+
|
|
78
|
+
Object.entries(query).forEach(([key, value]) => {
|
|
79
|
+
if (value !== undefined && value !== null) {
|
|
80
|
+
urlQuery.set(key, String(value));
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const response = await httpGetRequest(`${apiUrl}/search/collections/${collectionName}/search?${urlQuery.toString()}`, apiKey);
|
|
85
|
+
|
|
86
|
+
return response.data;
|
|
87
|
+
},
|
|
33
88
|
}
|
|
34
89
|
}
|
package/src/lib/types.ts
CHANGED
|
@@ -29,5 +29,16 @@ export namespace BrostarkSolutions {
|
|
|
29
29
|
defaultSortingField?: string;
|
|
30
30
|
metadata?: Record<string, unknown>;
|
|
31
31
|
}
|
|
32
|
+
|
|
33
|
+
export interface SearchQuery {
|
|
34
|
+
query: string;
|
|
35
|
+
by?: string;
|
|
36
|
+
sortBy?: string;
|
|
37
|
+
filterBy?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type Document = {
|
|
41
|
+
id: string;
|
|
42
|
+
} & Record<string, unknown>;
|
|
32
43
|
}
|
|
33
44
|
}
|