@brostark/solutions-client 1.1.15 → 1.1.17

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,15 @@
1
+ /**
2
+ * Generates an API to manage media
3
+ * @param apiUrl - The API URL
4
+ * @param apiKey - The API key for authentication
5
+ * @returns An object containing methods to interact with the media API
6
+ */
7
+ export declare const generateMediaAPI: (apiUrl: string, apiKey: string) => {
8
+ /**
9
+ * Uploads a new video
10
+ * @param file - The video file to upload
11
+ * @returns A promise with information about the uploaded video (URL and path)
12
+ */
13
+ upload: (file: File, filename: string) => Promise<any>;
14
+ };
15
+ //# sourceMappingURL=media.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../../src/api/v1/media.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM;IAE3D;;;;OAIG;mBACkB,IAAI,YAAY,MAAM;CAM9C,CAAA"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateMediaAPI = void 0;
4
+ const httpRequest_1 = require("../../lib/httpRequest");
5
+ /**
6
+ * Generates an API to manage media
7
+ * @param apiUrl - The API URL
8
+ * @param apiKey - The API key for authentication
9
+ * @returns An object containing methods to interact with the media API
10
+ */
11
+ const generateMediaAPI = (apiUrl, apiKey) => {
12
+ return {
13
+ /**
14
+ * Uploads a new video
15
+ * @param file - The video file to upload
16
+ * @returns A promise with information about the uploaded video (URL and path)
17
+ */
18
+ upload: async (file, filename) => {
19
+ const response = await (0, httpRequest_1.httpUploadRequest)(`${apiUrl}/media/${filename}`, apiKey, file);
20
+ return response.data;
21
+ },
22
+ };
23
+ };
24
+ exports.generateMediaAPI = generateMediaAPI;
package/dist/client.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { generateLiveAPI } from "./api/v1/live";
2
+ import { generateMediaAPI } from "./api/v1/media";
2
3
  import { generateSearchAPI } from "./api/v1/search";
3
4
  import { generateVideoAPI } from "./api/v1/video";
4
5
  import { ApiVersion } from "./constant";
@@ -14,6 +15,7 @@ export interface CreateClientOptions {
14
15
  export interface BrostarkSolutionsClient {
15
16
  live: ReturnType<typeof generateLiveAPI>;
16
17
  video: ReturnType<typeof generateVideoAPI>;
18
+ media: ReturnType<typeof generateMediaAPI>;
17
19
  search: ReturnType<typeof generateSearchAPI>;
18
20
  }
19
21
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,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,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;IACzC,KAAK,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;IAC3C,MAAM,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;CAC9C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,GAAG,uBAAuB,CAavG"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,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,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;IACzC,KAAK,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;IAC3C,KAAK,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;IAC3C,MAAM,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;CAC9C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,GAAG,uBAAuB,CAcvG"}
package/dist/client.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createClient = createClient;
4
4
  const live_1 = require("./api/v1/live");
5
+ const media_1 = require("./api/v1/media");
5
6
  const search_1 = require("./api/v1/search");
6
7
  const video_1 = require("./api/v1/video");
7
8
  const constant_1 = require("./constant");
@@ -16,6 +17,7 @@ function createClient(apiKey, options = {}) {
16
17
  const apiUrl = `${host}/${version}`;
17
18
  return {
18
19
  live: (0, live_1.generateLiveAPI)(apiUrl, apiKey),
20
+ media: (0, media_1.generateMediaAPI)(apiUrl, apiKey),
19
21
  video: (0, video_1.generateVideoAPI)(apiUrl, apiKey),
20
22
  search: (0, search_1.generateSearchAPI)(apiUrl, apiKey),
21
23
  };
@@ -2,7 +2,6 @@ import { ListOptions } from "./types";
2
2
  type RequestOptions = Omit<RequestInit, "body"> & {
3
3
  params?: Record<string, unknown>;
4
4
  data?: unknown;
5
- timeout?: number;
6
5
  };
7
6
  /**
8
7
  * Base function to make an HTTP request
@@ -1 +1 @@
1
- {"version":3,"file":"httpRequest.d.ts","sourceRoot":"","sources":["../../src/lib/httpRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAItC,KAAK,cAAc,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAGF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAU,QAAQ,MAAM,EAAE,QAAQ,MAAM,EAAE,SAAS,cAAc,iBAkDxF,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,EAAE,SAAS,WAAW,iBAOnF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,iBAI5D,CAAA;AAGD;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,EAAE,MAAM,OAAO,iBAK5E,CAAA;AAGD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,iBAI/D,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,EAAE,MAAM,IAAI,iBAQ3E,CAAA"}
1
+ {"version":3,"file":"httpRequest.d.ts","sourceRoot":"","sources":["../../src/lib/httpRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAItC,KAAK,cAAc,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAGF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAU,QAAQ,MAAM,EAAE,QAAQ,MAAM,EAAE,SAAS,cAAc,iBA2CxF,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,EAAE,SAAS,WAAW,iBAOnF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,iBAI5D,CAAA;AAGD;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,EAAE,MAAM,OAAO,iBAK5E,CAAA;AAGD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,iBAI/D,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,EAAE,MAAM,IAAI,iBAQ3E,CAAA"}
@@ -11,15 +11,12 @@ const constant_1 = require("../constant");
11
11
  * @returns A promise with the request response
12
12
  */
13
13
  const httpRequest = async (apiUrl, apiKey, options) => {
14
- const { headers, params, data, timeout: timeoutValue, ...rest } = options;
14
+ const { headers, params, data, ...rest } = options;
15
15
  const url = (0, helper_1.buildUrlWithParams)(apiUrl, params);
16
- const controller = typeof timeoutValue === "number" ? new AbortController() : undefined;
17
- const timeoutId = typeof timeoutValue === "number" ? setTimeout(() => controller.abort(), timeoutValue) : undefined;
18
16
  const config = (0, helper_1.removeUndefinedValues)({
19
17
  mode: "cors",
20
18
  method: "GET",
21
19
  ...rest,
22
- signal: controller?.signal,
23
20
  });
24
21
  const finalHeaders = {
25
22
  "x-api-key": apiKey,
@@ -50,11 +47,6 @@ const httpRequest = async (apiUrl, apiKey, options) => {
50
47
  catch (e) {
51
48
  return responseText;
52
49
  }
53
- finally {
54
- if (timeoutId !== undefined) {
55
- clearTimeout(timeoutId);
56
- }
57
- }
58
50
  };
59
51
  exports.httpRequest = httpRequest;
60
52
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brostark/solutions-client",
3
- "version": "1.1.15",
3
+ "version": "1.1.17",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -0,0 +1,23 @@
1
+ import { httpUploadRequest } from "../../lib/httpRequest";
2
+
3
+
4
+ /**
5
+ * Generates an API to manage media
6
+ * @param apiUrl - The API URL
7
+ * @param apiKey - The API key for authentication
8
+ * @returns An object containing methods to interact with the media API
9
+ */
10
+ export const generateMediaAPI = (apiUrl: string, apiKey: string) => {
11
+ return {
12
+ /**
13
+ * Uploads a new video
14
+ * @param file - The video file to upload
15
+ * @returns A promise with information about the uploaded video (URL and path)
16
+ */
17
+ upload: async (file: File, filename: string) => {
18
+ const response = await httpUploadRequest(`${apiUrl}/media/${filename}`, apiKey, file);
19
+
20
+ return response.data;
21
+ },
22
+ }
23
+ }
package/src/client.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { generateLiveAPI } from "./api/v1/live";
2
+ import { generateMediaAPI } from "./api/v1/media";
2
3
  import { generateSearchAPI } from "./api/v1/search";
3
4
  import { generateVideoAPI } from "./api/v1/video";
4
5
  import { ApiVersion, DEFAULT_API_HOST, DEFAULT_API_VERSION } from "./constant";
@@ -16,6 +17,7 @@ export interface CreateClientOptions {
16
17
  export interface BrostarkSolutionsClient {
17
18
  live: ReturnType<typeof generateLiveAPI>;
18
19
  video: ReturnType<typeof generateVideoAPI>;
20
+ media: ReturnType<typeof generateMediaAPI>;
19
21
  search: ReturnType<typeof generateSearchAPI>;
20
22
  }
21
23
 
@@ -35,6 +37,7 @@ export function createClient(apiKey: string, options: CreateClientOptions = {}):
35
37
 
36
38
  return {
37
39
  live: generateLiveAPI(apiUrl, apiKey),
40
+ media: generateMediaAPI(apiUrl, apiKey),
38
41
  video: generateVideoAPI(apiUrl, apiKey),
39
42
  search: generateSearchAPI(apiUrl, apiKey),
40
43
  }
@@ -5,7 +5,6 @@ import { MAX_LIMIT } from "../constant";
5
5
  type RequestOptions = Omit<RequestInit, "body"> & {
6
6
  params?: Record<string, unknown>;
7
7
  data?: unknown;
8
- timeout?: number;
9
8
  };
10
9
 
11
10
 
@@ -17,17 +16,14 @@ type RequestOptions = Omit<RequestInit, "body"> & {
17
16
  * @returns A promise with the request response
18
17
  */
19
18
  export const httpRequest = async (apiUrl: string, apiKey: string, options: RequestOptions) => {
20
- const { headers, params, data, timeout: timeoutValue,...rest } = options;
19
+ const { headers, params, data, ...rest } = options;
21
20
 
22
21
  const url = buildUrlWithParams(apiUrl, params);
23
- const controller = typeof timeoutValue === "number" ? new AbortController() : undefined;
24
- const timeoutId = typeof timeoutValue === "number" ? setTimeout(() => controller!.abort(), timeoutValue) : undefined;
25
22
 
26
23
  const config: RequestInit = removeUndefinedValues({
27
24
  mode: "cors",
28
25
  method: "GET",
29
26
  ...rest,
30
- signal: controller?.signal,
31
27
  });
32
28
 
33
29
  const finalHeaders: Record<string, string> = {
@@ -61,10 +57,6 @@ export const httpRequest = async (apiUrl: string, apiKey: string, options: Reque
61
57
  return JSON.parse(responseText);
62
58
  } catch (e) {
63
59
  return responseText;
64
- } finally {
65
- if (timeoutId !== undefined) {
66
- clearTimeout(timeoutId);
67
- }
68
60
  }
69
61
  }
70
62