@brostark/solutions-client 1.1.1 → 1.1.5

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.
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Generates an API to manage search
3
+ * @param apiUrl - The API URL
4
+ * @param apiKey - The API key for authentication
5
+ * @returns An object containing methods to interact with the search API
6
+ */
7
+ export declare const generateLiveAPI: (apiUrl: string, apiKey: string) => {
8
+ /**
9
+ * Create a live stream
10
+ * @returns A promise with the created live stream
11
+ */
12
+ createLive: () => Promise<any>;
13
+ /**
14
+ * Get the active live stream
15
+ * @returns A promise with the active live stream
16
+ */
17
+ getActiveLive: () => Promise<any>;
18
+ };
19
+ //# sourceMappingURL=live.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../../../src/api/v1/live.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM;IAE1D;;;OAGG;;IAMH;;;OAGG;;CAMN,CAAA"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateLiveAPI = void 0;
4
+ const httpRequest_1 = require("../../lib/httpRequest");
5
+ /**
6
+ * Generates an API to manage search
7
+ * @param apiUrl - The API URL
8
+ * @param apiKey - The API key for authentication
9
+ * @returns An object containing methods to interact with the search API
10
+ */
11
+ const generateLiveAPI = (apiUrl, apiKey) => {
12
+ return {
13
+ /**
14
+ * Create a live stream
15
+ * @returns A promise with the created live stream
16
+ */
17
+ createLive: async () => {
18
+ const response = await (0, httpRequest_1.httpPostRequest)(`${apiUrl}/live`, apiKey, {});
19
+ return response.data;
20
+ },
21
+ /**
22
+ * Get the active live stream
23
+ * @returns A promise with the active live stream
24
+ */
25
+ getActiveLive: async () => {
26
+ const response = await (0, httpRequest_1.httpGetRequest)(`${apiUrl}/live`, apiKey);
27
+ return response.data;
28
+ },
29
+ };
30
+ };
31
+ exports.generateLiveAPI = generateLiveAPI;
@@ -30,7 +30,7 @@ export declare const generateSearchAPI: (apiUrl: string, apiKey: string) => {
30
30
  * @param document - The document to insert
31
31
  * @returns A promise with the inserted document
32
32
  */
33
- upsertDocument: (collectionName: string, document: Record<string, unknown>) => Promise<any>;
33
+ upsertDocuments: (collectionName: string, documents: Record<string, unknown>[]) => Promise<any>;
34
34
  /**
35
35
  * Deletes a document from a search collection
36
36
  * @param collectionName - The name of the collection to delete the document from
@@ -44,6 +44,6 @@ export declare const generateSearchAPI: (apiUrl: string, apiKey: string) => {
44
44
  * @param query - The query to search for
45
45
  * @returns A promise with the search results
46
46
  */
47
- search: (collectionName: string, query: BrostarkSolutions.Search.SearchQuery) => Promise<any>;
47
+ query: (collectionName: string, query: BrostarkSolutions.Search.SearchQuery) => Promise<any>;
48
48
  };
49
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;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"}
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;sCACqC,MAAM,aAAa,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;IAMpF;;;;;OAKG;qCACoC,MAAM,cAAc,MAAM;IAMjE;;;;;OAKG;4BAC2B,MAAM,SAAS,iBAAiB,CAAC,MAAM,CAAC,WAAW;CAcpF,CAAA"}
@@ -43,8 +43,8 @@ const generateSearchAPI = (apiUrl, apiKey) => {
43
43
  * @param document - The document to insert
44
44
  * @returns A promise with the inserted document
45
45
  */
46
- upsertDocument: async (collectionName, document) => {
47
- const response = await (0, httpRequest_1.httpPostRequest)(`${apiUrl}/search/collections/${collectionName}/documents`, apiKey, document);
46
+ upsertDocuments: async (collectionName, documents) => {
47
+ const response = await (0, httpRequest_1.httpPostRequest)(`${apiUrl}/search/collections/${collectionName}/documents`, apiKey, documents);
48
48
  return response.data;
49
49
  },
50
50
  /**
@@ -63,14 +63,14 @@ const generateSearchAPI = (apiUrl, apiKey) => {
63
63
  * @param query - The query to search for
64
64
  * @returns A promise with the search results
65
65
  */
66
- search: async (collectionName, query) => {
66
+ query: async (collectionName, query) => {
67
67
  const urlQuery = new URLSearchParams();
68
68
  Object.entries(query).forEach(([key, value]) => {
69
69
  if (value !== undefined && value !== null) {
70
70
  urlQuery.set(key, String(value));
71
71
  }
72
72
  });
73
- const response = await (0, httpRequest_1.httpGetRequest)(`${apiUrl}/search/collections/${collectionName}/search?${urlQuery.toString()}`, apiKey);
73
+ const response = await (0, httpRequest_1.httpGetRequest)(`${apiUrl}/search/collections/${collectionName}/query?${urlQuery.toString()}`, apiKey);
74
74
  return response.data;
75
75
  },
76
76
  };
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/api/v1/stream.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ "use strict";
package/dist/client.d.ts CHANGED
@@ -15,6 +15,10 @@ export interface CreateClientOptions {
15
15
  * @returns An object containing the different APIs available
16
16
  */
17
17
  export declare function createClient(apiKey: string, options?: CreateClientOptions): {
18
+ live: {
19
+ createLive: () => Promise<any>;
20
+ getActiveLive: () => Promise<any>;
21
+ };
18
22
  video: {
19
23
  list: (options?: import("./lib/types").ListOptions) => Promise<any>;
20
24
  upload: (file: File) => Promise<any>;
@@ -26,9 +30,9 @@ export declare function createClient(apiKey: string, options?: CreateClientOptio
26
30
  listCollections: (options?: import("./lib/types").ListOptions) => Promise<any>;
27
31
  createCollection: (params: import("./lib/types").BrostarkSolutions.Search.CreateCollectionParams) => Promise<any>;
28
32
  deleteCollection: (name: string) => Promise<any>;
29
- upsertDocument: (collectionName: string, document: Record<string, unknown>) => Promise<any>;
33
+ upsertDocuments: (collectionName: string, documents: Record<string, unknown>[]) => Promise<any>;
30
34
  deleteDocument: (collectionName: string, documentId: string) => Promise<any>;
31
- search: (collectionName: string, query: import("./lib/types").BrostarkSolutions.Search.SearchQuery) => Promise<any>;
35
+ query: (collectionName: string, query: import("./lib/types").BrostarkSolutions.Search.SearchQuery) => Promise<any>;
32
36
  };
33
37
  };
34
38
  //# sourceMappingURL=client.d.ts.map
@@ -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;;;;;;;;;;;;;;;;EAY7E"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAGA,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;;;;;;;;;;;;;;;;;;;;EAa7E"}
package/dist/client.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createClient = createClient;
4
+ const live_1 = require("./api/v1/live");
4
5
  const search_1 = require("./api/v1/search");
5
6
  const video_1 = require("./api/v1/video");
6
7
  const constant_1 = require("./constant");
@@ -14,6 +15,7 @@ function createClient(apiKey, options = {}) {
14
15
  const { host = constant_1.DEFAULT_API_HOST, version = constant_1.DEFAULT_API_VERSION, } = options;
15
16
  const apiUrl = `${host}/${version}`;
16
17
  return {
18
+ live: (0, live_1.generateLiveAPI)(apiUrl, apiKey),
17
19
  video: (0, video_1.generateVideoAPI)(apiUrl, apiKey),
18
20
  search: (0, search_1.generateSearchAPI)(apiUrl, apiKey),
19
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brostark/solutions-client",
3
- "version": "1.1.1",
3
+ "version": "1.1.5",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -0,0 +1,30 @@
1
+ import { httpGetRequest, httpPostRequest } from "../../lib/httpRequest";
2
+
3
+
4
+ /**
5
+ * Generates an API to manage search
6
+ * @param apiUrl - The API URL
7
+ * @param apiKey - The API key for authentication
8
+ * @returns An object containing methods to interact with the search API
9
+ */
10
+ export const generateLiveAPI = (apiUrl: string, apiKey: string) => {
11
+ return {
12
+ /**
13
+ * Create a live stream
14
+ * @returns A promise with the created live stream
15
+ */
16
+ createLive: async () => {
17
+ const response = await httpPostRequest(`${apiUrl}/live`, apiKey, {});
18
+ return response.data;
19
+ },
20
+
21
+ /**
22
+ * Get the active live stream
23
+ * @returns A promise with the active live stream
24
+ */
25
+ getActiveLive: async () => {
26
+ const response = await httpGetRequest(`${apiUrl}/live`, apiKey);
27
+ return response.data;
28
+ },
29
+ }
30
+ }
@@ -48,8 +48,8 @@ export const generateSearchAPI = (apiUrl: string, apiKey: string) => {
48
48
  * @param document - The document to insert
49
49
  * @returns A promise with the inserted document
50
50
  */
51
- upsertDocument: async (collectionName: string, document: Record<string, unknown>) => {
52
- const response = await httpPostRequest(`${apiUrl}/search/collections/${collectionName}/documents`, apiKey, document);
51
+ upsertDocuments: async (collectionName: string, documents: Record<string, unknown>[]) => {
52
+ const response = await httpPostRequest(`${apiUrl}/search/collections/${collectionName}/documents`, apiKey, documents);
53
53
 
54
54
  return response.data;
55
55
  },
@@ -72,7 +72,7 @@ export const generateSearchAPI = (apiUrl: string, apiKey: string) => {
72
72
  * @param query - The query to search for
73
73
  * @returns A promise with the search results
74
74
  */
75
- search: async (collectionName: string, query: BrostarkSolutions.Search.SearchQuery) => {
75
+ query: async (collectionName: string, query: BrostarkSolutions.Search.SearchQuery) => {
76
76
  const urlQuery = new URLSearchParams();
77
77
 
78
78
  Object.entries(query).forEach(([key, value]) => {
@@ -81,7 +81,7 @@ export const generateSearchAPI = (apiUrl: string, apiKey: string) => {
81
81
  }
82
82
  });
83
83
 
84
- const response = await httpGetRequest(`${apiUrl}/search/collections/${collectionName}/search?${urlQuery.toString()}`, apiKey);
84
+ const response = await httpGetRequest(`${apiUrl}/search/collections/${collectionName}/query?${urlQuery.toString()}`, apiKey);
85
85
 
86
86
  return response.data;
87
87
  },
package/src/client.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { generateLiveAPI } from "./api/v1/live";
1
2
  import { generateSearchAPI } from "./api/v1/search";
2
3
  import { generateVideoAPI } from "./api/v1/video";
3
4
  import { ApiVersion, DEFAULT_API_HOST, DEFAULT_API_VERSION } from "./constant";
@@ -27,6 +28,7 @@ export function createClient(apiKey: string, options: CreateClientOptions = {})
27
28
  const apiUrl = `${host}/${version}`;
28
29
 
29
30
  return {
31
+ live: generateLiveAPI(apiUrl, apiKey),
30
32
  video: generateVideoAPI(apiUrl, apiKey),
31
33
  search: generateSearchAPI(apiUrl, apiKey),
32
34
  }