camstreamerlib 4.0.0-beta.29 → 4.0.0-beta.30

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.
Files changed (161) hide show
  1. package/README.md +6 -2
  2. package/cjs/CamOverlayAPI.d.ts +38 -615
  3. package/cjs/CamOverlayAPI.js +128 -104
  4. package/cjs/CamOverlayDrawingAPI.d.ts +2 -47
  5. package/cjs/CamOverlayPainter/Frame.d.ts +8 -37
  6. package/cjs/CamOverlayPainter/Frame.js +33 -0
  7. package/cjs/CamOverlayPainter/Painter.d.ts +5 -10
  8. package/cjs/CamOverlayPainter/Painter.js +2 -4
  9. package/cjs/CamOverlayPainter/ResourceManager.d.ts +3 -2
  10. package/cjs/CamOverlayPainter/ResourceManager.js +2 -1
  11. package/cjs/CamScripterAPI.d.ts +12 -12
  12. package/cjs/CamScripterAPI.js +33 -27
  13. package/cjs/CamStreamerAPI.d.ts +11 -9
  14. package/cjs/CamStreamerAPI.js +28 -22
  15. package/cjs/CamSwitcherAPI.d.ts +35 -34
  16. package/cjs/CamSwitcherAPI.js +94 -82
  17. package/cjs/PlaneTrackerAPI.d.ts +30 -36
  18. package/cjs/PlaneTrackerAPI.js +132 -71
  19. package/cjs/VapixAPI.d.ts +43 -40
  20. package/cjs/VapixAPI.js +205 -183
  21. package/cjs/events/AxisCameraStationEvents.d.ts +5 -5
  22. package/cjs/events/AxisCameraStationEvents.js +17 -12
  23. package/cjs/events/GenetecAgent.d.ts +2 -0
  24. package/cjs/events/GenetecAgent.js +15 -4
  25. package/cjs/index.d.ts +7 -1
  26. package/cjs/index.js +12 -2
  27. package/cjs/internal/ProxyClient.d.ts +7 -8
  28. package/cjs/internal/ProxyClient.js +25 -31
  29. package/cjs/internal/types.d.ts +16 -9
  30. package/cjs/internal/utils.d.ts +1 -2
  31. package/cjs/internal/utils.js +1 -5
  32. package/cjs/node/DefaultClient.d.ts +3 -5
  33. package/cjs/node/DefaultClient.js +10 -14
  34. package/cjs/node/HttpRequestSender.d.ts +1 -0
  35. package/cjs/node/HttpRequestSender.js +13 -3
  36. package/cjs/node/WsClient.d.ts +1 -0
  37. package/cjs/node/index.d.ts +2 -0
  38. package/cjs/node/index.js +18 -1
  39. package/cjs/{models/CamOverlayAPI/widgetsSchema.d.ts → types/CamOverlayAPI/CamOverlayAPI.d.ts} +625 -375
  40. package/cjs/{models/CamOverlayAPI/widgetCommonSchema.js → types/CamOverlayAPI/CamOverlayAPI.js} +65 -14
  41. package/cjs/{models → types}/CamOverlayAPI/accuweatherSchema.d.ts +40 -10
  42. package/cjs/{models → types}/CamOverlayAPI/accuweatherSchema.js +11 -9
  43. package/cjs/{models → types}/CamOverlayAPI/customGraphicsSchema.d.ts +89 -5
  44. package/cjs/{models → types}/CamOverlayAPI/customGraphicsSchema.js +9 -7
  45. package/{esm/models → cjs/types}/CamOverlayAPI/imagesSchema.d.ts +40 -13
  46. package/cjs/types/CamOverlayAPI/imagesSchema.js +12 -0
  47. package/cjs/{models → types}/CamOverlayAPI/index.d.ts +0 -4
  48. package/cjs/{models → types}/CamOverlayAPI/index.js +0 -4
  49. package/{esm/models → cjs/types}/CamOverlayAPI/infotickerSchema.d.ts +43 -9
  50. package/cjs/{models → types}/CamOverlayAPI/infotickerSchema.js +10 -8
  51. package/{esm/models → cjs/types}/CamOverlayAPI/pipSchema.d.ts +48 -7
  52. package/cjs/{models → types}/CamOverlayAPI/pipSchema.js +8 -6
  53. package/{esm/models → cjs/types}/CamOverlayAPI/ptzCompassSchema.d.ts +40 -7
  54. package/cjs/{models → types}/CamOverlayAPI/ptzCompassSchema.js +8 -6
  55. package/cjs/{models → types}/CamOverlayAPI/ptzSchema.d.ts +42 -14
  56. package/cjs/types/CamOverlayAPI/ptzSchema.js +15 -0
  57. package/{esm/models → cjs/types}/CamOverlayAPI/screenSharingSchema.d.ts +26 -5
  58. package/cjs/types/CamOverlayAPI/screenSharingSchema.js +11 -0
  59. package/cjs/{models → types}/CamOverlayAPI/webCameraSharingSchema.d.ts +26 -5
  60. package/cjs/types/CamOverlayAPI/webCameraSharingSchema.js +11 -0
  61. package/cjs/types/CamOverlayDrawingAPI.d.ts +58 -0
  62. package/cjs/types/CamOverlayDrawingAPI.js +2 -0
  63. package/cjs/types/CamOverlayPainter.d.ts +74 -0
  64. package/cjs/types/CamOverlayPainter.js +2 -0
  65. package/cjs/types/CamStreamerAPI.d.ts +4 -4
  66. package/cjs/types/PlaneTrackerAPI.d.ts +6 -0
  67. package/cjs/types/common.d.ts +12 -3
  68. package/cjs/web/DefaultClient.d.ts +4 -4
  69. package/cjs/web/DefaultClient.js +21 -11
  70. package/esm/CamOverlayAPI.d.ts +38 -615
  71. package/esm/CamOverlayAPI.js +127 -103
  72. package/esm/CamOverlayDrawingAPI.d.ts +2 -47
  73. package/esm/CamOverlayPainter/Frame.d.ts +8 -37
  74. package/esm/CamOverlayPainter/Frame.js +33 -0
  75. package/esm/CamOverlayPainter/Painter.d.ts +5 -10
  76. package/esm/CamOverlayPainter/Painter.js +1 -2
  77. package/esm/CamOverlayPainter/ResourceManager.d.ts +3 -2
  78. package/esm/CamOverlayPainter/ResourceManager.js +1 -1
  79. package/esm/CamScripterAPI.d.ts +12 -12
  80. package/esm/CamScripterAPI.js +32 -26
  81. package/esm/CamStreamerAPI.d.ts +11 -9
  82. package/esm/CamStreamerAPI.js +28 -22
  83. package/esm/CamSwitcherAPI.d.ts +35 -34
  84. package/esm/CamSwitcherAPI.js +95 -83
  85. package/esm/PlaneTrackerAPI.d.ts +30 -36
  86. package/esm/PlaneTrackerAPI.js +131 -70
  87. package/esm/VapixAPI.d.ts +43 -40
  88. package/esm/VapixAPI.js +204 -182
  89. package/esm/events/AxisCameraStationEvents.d.ts +5 -5
  90. package/esm/events/AxisCameraStationEvents.js +18 -13
  91. package/esm/events/GenetecAgent.d.ts +2 -0
  92. package/esm/events/GenetecAgent.js +15 -4
  93. package/esm/index.d.ts +7 -1
  94. package/esm/index.js +7 -1
  95. package/esm/internal/ProxyClient.d.ts +7 -8
  96. package/esm/internal/ProxyClient.js +25 -31
  97. package/esm/internal/types.d.ts +16 -9
  98. package/esm/internal/utils.d.ts +1 -2
  99. package/esm/internal/utils.js +0 -3
  100. package/esm/node/DefaultClient.d.ts +3 -5
  101. package/esm/node/DefaultClient.js +10 -14
  102. package/esm/node/HttpRequestSender.d.ts +1 -0
  103. package/esm/node/HttpRequestSender.js +13 -3
  104. package/esm/node/WsClient.d.ts +1 -0
  105. package/esm/node/index.d.ts +2 -0
  106. package/esm/node/index.js +2 -0
  107. package/esm/{models/CamOverlayAPI/widgetsSchema.d.ts → types/CamOverlayAPI/CamOverlayAPI.d.ts} +625 -375
  108. package/esm/{models/CamOverlayAPI/widgetCommonSchema.js → types/CamOverlayAPI/CamOverlayAPI.js} +64 -13
  109. package/esm/{models → types}/CamOverlayAPI/accuweatherSchema.d.ts +40 -10
  110. package/esm/{models → types}/CamOverlayAPI/accuweatherSchema.js +3 -2
  111. package/esm/{models → types}/CamOverlayAPI/customGraphicsSchema.d.ts +89 -5
  112. package/esm/{models → types}/CamOverlayAPI/customGraphicsSchema.js +3 -2
  113. package/{cjs/models → esm/types}/CamOverlayAPI/imagesSchema.d.ts +40 -13
  114. package/esm/types/CamOverlayAPI/imagesSchema.js +8 -0
  115. package/esm/{models → types}/CamOverlayAPI/index.d.ts +0 -4
  116. package/esm/{models → types}/CamOverlayAPI/index.js +0 -4
  117. package/{cjs/models → esm/types}/CamOverlayAPI/infotickerSchema.d.ts +43 -9
  118. package/esm/{models → types}/CamOverlayAPI/infotickerSchema.js +3 -2
  119. package/{cjs/models → esm/types}/CamOverlayAPI/pipSchema.d.ts +48 -7
  120. package/esm/{models → types}/CamOverlayAPI/pipSchema.js +3 -2
  121. package/{cjs/models → esm/types}/CamOverlayAPI/ptzCompassSchema.d.ts +40 -7
  122. package/esm/{models → types}/CamOverlayAPI/ptzCompassSchema.js +3 -2
  123. package/esm/{models → types}/CamOverlayAPI/ptzSchema.d.ts +42 -14
  124. package/esm/{models → types}/CamOverlayAPI/ptzSchema.js +3 -2
  125. package/{cjs/models → esm/types}/CamOverlayAPI/screenSharingSchema.d.ts +26 -5
  126. package/esm/types/CamOverlayAPI/screenSharingSchema.js +7 -0
  127. package/esm/{models → types}/CamOverlayAPI/webCameraSharingSchema.d.ts +26 -5
  128. package/esm/types/CamOverlayAPI/webCameraSharingSchema.js +7 -0
  129. package/esm/types/CamOverlayDrawingAPI.d.ts +58 -0
  130. package/esm/types/CamOverlayDrawingAPI.js +1 -0
  131. package/esm/types/CamOverlayPainter.d.ts +74 -0
  132. package/esm/types/CamOverlayPainter.js +1 -0
  133. package/esm/types/CamStreamerAPI.d.ts +4 -4
  134. package/esm/types/PlaneTrackerAPI.d.ts +6 -0
  135. package/esm/types/common.d.ts +12 -3
  136. package/esm/web/DefaultClient.d.ts +4 -4
  137. package/esm/web/DefaultClient.js +21 -11
  138. package/package.json +2 -2
  139. package/cjs/models/CamOverlayAPI/constants.d.ts +0 -11
  140. package/cjs/models/CamOverlayAPI/constants.js +0 -14
  141. package/cjs/models/CamOverlayAPI/fileSchema.d.ts +0 -28
  142. package/cjs/models/CamOverlayAPI/fileSchema.js +0 -17
  143. package/cjs/models/CamOverlayAPI/imagesSchema.js +0 -10
  144. package/cjs/models/CamOverlayAPI/ptzSchema.js +0 -13
  145. package/cjs/models/CamOverlayAPI/screenSharingSchema.js +0 -9
  146. package/cjs/models/CamOverlayAPI/webCameraSharingSchema.js +0 -9
  147. package/cjs/models/CamOverlayAPI/widgetCommonSchema.d.ts +0 -126
  148. package/cjs/models/CamOverlayAPI/widgetsSchema.js +0 -27
  149. package/cjs/types/CamOverlayAPI.d.ts +0 -328
  150. package/cjs/types/CamOverlayAPI.js +0 -26
  151. package/esm/models/CamOverlayAPI/constants.d.ts +0 -11
  152. package/esm/models/CamOverlayAPI/constants.js +0 -11
  153. package/esm/models/CamOverlayAPI/fileSchema.d.ts +0 -28
  154. package/esm/models/CamOverlayAPI/fileSchema.js +0 -14
  155. package/esm/models/CamOverlayAPI/imagesSchema.js +0 -7
  156. package/esm/models/CamOverlayAPI/screenSharingSchema.js +0 -6
  157. package/esm/models/CamOverlayAPI/webCameraSharingSchema.js +0 -6
  158. package/esm/models/CamOverlayAPI/widgetCommonSchema.d.ts +0 -126
  159. package/esm/models/CamOverlayAPI/widgetsSchema.js +0 -24
  160. package/esm/types/CamOverlayAPI.d.ts +0 -328
  161. package/esm/types/CamOverlayAPI.js +0 -14
@@ -1,48 +1,42 @@
1
1
  import { IClient, TBlobResponse, TParameters, TResponse } from './internal/types';
2
- import { TExportDataType, TImportDataType } from './types/PlaneTrackerAPI';
3
- export type TApiUser = {
4
- userId: string;
5
- userName: string;
6
- userPriority: number;
7
- };
8
- type ICAO = string;
9
- export declare const BASE_URL = "/local/planetracker";
2
+ import { ICAO, TApiUser, TExportDataType, TImportDataType } from './types/PlaneTrackerAPI';
3
+ import { THttpRequestOptions } from './types/common';
10
4
  export declare class PlaneTrackerAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
11
5
  private client;
12
6
  private apiUser;
13
- private _apiUserQuery;
14
7
  constructor(client: Client, apiUser: TApiUser);
15
8
  static getProxyUrlPath: () => string;
16
- checkCameraTime(): Promise<boolean>;
17
- fetchCameraSettings: () => Promise<any>;
18
- setCameraSettings: (settingsJsonString: string) => Promise<TResponse>;
19
- fetchServerSettings: () => Promise<any>;
20
- fetchMapInfo: () => Promise<any>;
21
- fetchFlightInfo: (icao: ICAO) => Promise<any>;
22
- getZones: () => Promise<any>;
23
- setZones: (zonesJsonString: string) => Promise<TResponse>;
24
- getPriorityList: () => Promise<any>;
25
- setPriorityList: (priorityListJsonString: string) => Promise<TResponse>;
26
- getWhiteList: () => Promise<any>;
27
- setWhiteList: (whiteListJsonString: string) => Promise<TResponse>;
28
- getBlackList: () => Promise<any>;
29
- setBlackList: (blackListJsonString: string) => Promise<TResponse>;
30
- getTrackingMode: () => Promise<any>;
31
- setTrackingMode: (modeJsonString: string) => Promise<TResponse>;
32
- startTrackingPlane: (icao: ICAO) => Promise<TResponse>;
33
- stopTrackingPlane: () => Promise<TResponse>;
34
- goToCoordinates: (lat: number, lon: number, alt?: number) => Promise<TResponse>;
35
- exportAppSettings: (dataType: TExportDataType) => Promise<TBlobResponse<Client>>;
36
- importAppSettings: (dataType: TImportDataType, formData: FormData) => Promise<TResponse>;
37
- resetPtzCalibration: () => Promise<TResponse>;
38
- resetFocusCalibration: () => Promise<TResponse>;
39
- checkGenetecConnection: (params: TParameters) => Promise<TResponse>;
40
- getGenetecCameraList: (params: TParameters) => Promise<any>;
41
- serverRunCheck: () => Promise<TResponse>;
9
+ checkCameraTime(options?: THttpRequestOptions): Promise<boolean>;
10
+ resetPtzCalibration: (options?: THttpRequestOptions) => Promise<TResponse>;
11
+ resetFocusCalibration: (options?: THttpRequestOptions) => Promise<TResponse>;
12
+ serverRunCheck: (options?: THttpRequestOptions) => Promise<TResponse>;
13
+ getLiveViewAlias: (rtspUrl: string, options?: THttpRequestOptions) => Promise<TResponse>;
14
+ fetchCameraSettings: (options?: THttpRequestOptions) => Promise<any>;
15
+ setCameraSettings: (settingsJsonString: string, options?: THttpRequestOptions) => Promise<TResponse>;
16
+ fetchServerSettings: (options?: THttpRequestOptions) => Promise<any>;
17
+ exportAppSettings: (dataType: TExportDataType, options?: THttpRequestOptions) => Promise<TBlobResponse<Client>>;
18
+ importAppSettings: (dataType: TImportDataType, formData: FormData, options?: THttpRequestOptions) => Promise<TResponse>;
19
+ fetchFlightInfo: (icao: ICAO, options?: THttpRequestOptions) => Promise<any>;
20
+ getTrackingMode: (options?: THttpRequestOptions) => Promise<any>;
21
+ setTrackingMode: (modeJsonString: string, options?: THttpRequestOptions) => Promise<TResponse>;
22
+ startTrackingPlane: (icao: ICAO, options?: THttpRequestOptions) => Promise<TResponse>;
23
+ stopTrackingPlane: (options?: THttpRequestOptions) => Promise<TResponse>;
24
+ getPriorityList: (options?: THttpRequestOptions) => Promise<any>;
25
+ setPriorityList: (priorityListJsonString: string, options?: THttpRequestOptions) => Promise<TResponse>;
26
+ getWhiteList: (options?: THttpRequestOptions) => Promise<any>;
27
+ setWhiteList: (whiteListJsonString: string, options?: THttpRequestOptions) => Promise<TResponse>;
28
+ getBlackList: (options?: THttpRequestOptions) => Promise<any>;
29
+ setBlackList: (blackListJsonString: string, options?: THttpRequestOptions) => Promise<TResponse>;
30
+ fetchMapInfo: (options?: THttpRequestOptions) => Promise<any>;
31
+ getZones: (options?: THttpRequestOptions) => Promise<any>;
32
+ setZones: (zonesJsonString: string, options?: THttpRequestOptions) => Promise<TResponse>;
33
+ goToCoordinates: (lat: number, lon: number, alt?: number, options?: THttpRequestOptions) => Promise<TResponse>;
34
+ checkGenetecConnection: (params: TParameters, options?: THttpRequestOptions) => Promise<TResponse>;
35
+ getGenetecCameraList: (params: TParameters, options?: THttpRequestOptions) => Promise<any>;
42
36
  private _getJson;
43
37
  private _getBlob;
44
38
  private parseBlobResponse;
45
39
  private _postJsonEncoded;
46
40
  private _postUrlEncoded;
41
+ private getAgent;
47
42
  }
48
- export {};
@@ -1,102 +1,145 @@
1
1
  import { z } from 'zod';
2
2
  import { paramToUrl, responseStringify } from './internal/utils';
3
3
  import { ParsingBlobError } from './errors/errors';
4
- export const BASE_URL = '/local/planetracker';
4
+ import { ProxyClient } from './internal/ProxyClient';
5
+ const BASE_PATH = '/local/planetracker';
5
6
  export class PlaneTrackerAPI {
6
7
  client;
7
8
  apiUser;
8
- _apiUserQuery;
9
9
  constructor(client, apiUser) {
10
10
  this.client = client;
11
11
  this.apiUser = apiUser;
12
- this._apiUserQuery = paramToUrl(this.apiUser);
13
12
  }
14
- static getProxyUrlPath = () => `${BASE_URL}/proxy.cgi`;
15
- async checkCameraTime() {
16
- const response = await this._getJson(`${BASE_URL}/camera_time.cgi`);
13
+ static getProxyUrlPath = () => `${BASE_PATH}/proxy.cgi`;
14
+ async checkCameraTime(options) {
15
+ const response = await this._getJson(`${BASE_PATH}/camera_time.cgi`, undefined, options);
17
16
  return z.boolean().parse(response.state);
18
17
  }
19
- fetchCameraSettings = async () => {
20
- return await this._getJson(`${BASE_URL}/package_camera_settings.cgi`, { action: 'get' });
18
+ resetPtzCalibration = async (options) => {
19
+ const agent = this.getAgent(options?.proxyParams);
20
+ return await agent.get({
21
+ path: `${BASE_PATH}/package/resetPtzCalibration.cgi`,
22
+ parameters: this.apiUser,
23
+ timeout: options?.timeout,
24
+ });
21
25
  };
22
- setCameraSettings = async (settingsJsonString) => {
23
- return await this._postJsonEncoded(`${BASE_URL}/package_camera_settings.cgi`, settingsJsonString, {
24
- action: 'set',
26
+ resetFocusCalibration = async (options) => {
27
+ const agent = this.getAgent(options?.proxyParams);
28
+ return await agent.get({
29
+ path: `${BASE_PATH}/package/resetFocusCalibration.cgi`,
30
+ parameters: this.apiUser,
31
+ timeout: options?.timeout,
25
32
  });
26
33
  };
27
- fetchServerSettings = async () => {
28
- return await this._getJson(`${BASE_URL}/package_server_settings.cgi`, { action: 'get' });
34
+ serverRunCheck = async (options) => {
35
+ const agent = this.getAgent(options?.proxyParams);
36
+ return await agent.get({ path: `${BASE_PATH}/package/serverRunCheck.cgi`, timeout: options?.timeout });
29
37
  };
30
- fetchMapInfo = async () => {
31
- return await this._getJson(`${BASE_URL}/package/getMapInfo.cgi`);
38
+ getLiveViewAlias = async (rtspUrl, options) => {
39
+ const agent = this.getAgent(options?.proxyParams);
40
+ return await agent.get({
41
+ path: `${BASE_PATH}/getLiveViewAlias.cgi`,
42
+ parameters: { rtsp_url: rtspUrl },
43
+ timeout: options?.timeout,
44
+ });
32
45
  };
33
- fetchFlightInfo = async (icao) => {
34
- return await this._getJson(`${BASE_URL}/package/flightInfo.cgi`, { icao: encodeURIComponent(icao) });
46
+ fetchCameraSettings = async (options) => {
47
+ return await this._getJson(`${BASE_PATH}/package_camera_settings.cgi`, { action: 'get' }, options);
35
48
  };
36
- getZones = async () => {
37
- return await this._getJson(`${BASE_URL}/package/getZones.cgi`);
49
+ setCameraSettings = async (settingsJsonString, options) => {
50
+ return await this._postJsonEncoded(`${BASE_PATH}/package_camera_settings.cgi`, settingsJsonString, {
51
+ action: 'set',
52
+ }, options);
38
53
  };
39
- setZones = async (zonesJsonString) => {
40
- return await this._postJsonEncoded(`${BASE_URL}/package/setZones.cgi?${this._apiUserQuery}`, zonesJsonString);
54
+ fetchServerSettings = async (options) => {
55
+ return await this._getJson(`${BASE_PATH}/package_server_settings.cgi`, { action: 'get' }, options);
41
56
  };
42
- getPriorityList = async () => {
43
- return await this._getJson(`${BASE_URL}/package/getPriorityList.cgi`);
57
+ exportAppSettings = async (dataType, options) => {
58
+ return await this._getBlob(`${BASE_PATH}/package_data.cgi`, { action: 'EXPORT', dataType }, options);
44
59
  };
45
- setPriorityList = async (priorityListJsonString) => {
46
- return await this._postJsonEncoded(`${BASE_URL}/package/setPriorityList.cgi?${this._apiUserQuery}`, priorityListJsonString);
60
+ importAppSettings = async (dataType, formData, options) => {
61
+ const agent = this.getAgent(options?.proxyParams);
62
+ return await agent.post({
63
+ path: `${BASE_PATH}/package_data.cgi`,
64
+ data: formData,
65
+ parameters: { action: 'IMPORT', dataType },
66
+ timeout: options?.timeout,
67
+ });
47
68
  };
48
- getWhiteList = async () => {
49
- return await this._getJson(`${BASE_URL}/package/getWhiteList.cgi`);
69
+ fetchFlightInfo = async (icao, options) => {
70
+ return await this._getJson(`${BASE_PATH}/package/flightInfo.cgi`, { icao: encodeURIComponent(icao) }, options);
50
71
  };
51
- setWhiteList = async (whiteListJsonString) => {
52
- return await this._postJsonEncoded(`${BASE_URL}/package/setWhiteList.cgi?${this._apiUserQuery}`, whiteListJsonString);
72
+ getTrackingMode = async (options) => {
73
+ return await this._getJson(`${BASE_PATH}/package/getTrackingMode.cgi`, undefined, options);
53
74
  };
54
- getBlackList = async () => {
55
- return await this._getJson(`${BASE_URL}/package/getBlackList.cgi`);
75
+ setTrackingMode = async (modeJsonString, options) => {
76
+ return await this._postJsonEncoded(`${BASE_PATH}/package/setTrackingMode.cgi`, modeJsonString, this.apiUser, options);
56
77
  };
57
- setBlackList = async (blackListJsonString) => {
58
- return await this._postJsonEncoded(`${BASE_URL}/package/setBlackList.cgi?${this._apiUserQuery}`, blackListJsonString);
78
+ startTrackingPlane = async (icao, options) => {
79
+ const agent = this.getAgent(options?.proxyParams);
80
+ return await agent.get({
81
+ path: `${BASE_PATH}/package/trackIcao.cgi`,
82
+ parameters: { icao, ...this.apiUser },
83
+ timeout: options?.timeout,
84
+ });
59
85
  };
60
- getTrackingMode = async () => {
61
- return await this._getJson(`${BASE_URL}/package/getTrackingMode.cgi`);
86
+ stopTrackingPlane = async (options) => {
87
+ const agent = this.getAgent(options?.proxyParams);
88
+ return await agent.get({
89
+ path: `${BASE_PATH}/package/resetIcao.cgi`,
90
+ parameters: this.apiUser,
91
+ timeout: options?.timeout,
92
+ });
62
93
  };
63
- setTrackingMode = async (modeJsonString) => {
64
- return await this._postJsonEncoded(`${BASE_URL}/package/setTrackingMode.cgi?${this._apiUserQuery}`, modeJsonString);
94
+ getPriorityList = async (options) => {
95
+ return await this._getJson(`${BASE_PATH}/package/getPriorityList.cgi`, undefined, options);
65
96
  };
66
- startTrackingPlane = async (icao) => {
67
- return await this.client.get(`${BASE_URL}/package/trackIcao.cgi?icao=${encodeURIComponent(icao)}&${this._apiUserQuery}`);
97
+ setPriorityList = async (priorityListJsonString, options) => {
98
+ return await this._postJsonEncoded(`${BASE_PATH}/package/setPriorityList.cgi`, priorityListJsonString, this.apiUser, options);
68
99
  };
69
- stopTrackingPlane = async () => {
70
- return await this.client.get(`${BASE_URL}/package/resetIcao.cgi?${this._apiUserQuery}`);
100
+ getWhiteList = async (options) => {
101
+ return await this._getJson(`${BASE_PATH}/package/getWhiteList.cgi`, undefined, options);
71
102
  };
72
- goToCoordinates = async (lat, lon, alt) => {
73
- const url = `${BASE_URL}/package/goToCoordinates.cgi?lat=${lat}&lon=${lon}&${this._apiUserQuery}`;
74
- return await this.client.get(`${url}${alt !== undefined ? `&alt=${alt}` : ''}`);
103
+ setWhiteList = async (whiteListJsonString, options) => {
104
+ return await this._postJsonEncoded(`${BASE_PATH}/package/setWhiteList.cgi`, whiteListJsonString, this.apiUser, options);
75
105
  };
76
- exportAppSettings = async (dataType) => {
77
- return await this._getBlob(`${BASE_URL}/package_data.cgi`, { action: 'EXPORT', dataType });
106
+ getBlackList = async (options) => {
107
+ return await this._getJson(`${BASE_PATH}/package/getBlackList.cgi`, undefined, options);
78
108
  };
79
- importAppSettings = async (dataType, formData) => {
80
- return await this.client.post(`${BASE_URL}/package_data.cgi`, formData, { action: 'IMPORT', dataType });
109
+ setBlackList = async (blackListJsonString, options) => {
110
+ return await this._postJsonEncoded(`${BASE_PATH}/package/setBlackList.cgi`, blackListJsonString, this.apiUser, options);
81
111
  };
82
- resetPtzCalibration = async () => {
83
- return await this.client.get(`${BASE_URL}/package/resetPtzCalibration.cgi?${this._apiUserQuery}`);
112
+ fetchMapInfo = async (options) => {
113
+ return await this._getJson(`${BASE_PATH}/package/getMapInfo.cgi`, undefined, options);
84
114
  };
85
- resetFocusCalibration = async () => {
86
- return await this.client.get(`${BASE_URL}/package/resetFocusCalibration.cgi?${this._apiUserQuery}`);
115
+ getZones = async (options) => {
116
+ return await this._getJson(`${BASE_PATH}/package/getZones.cgi`, undefined, options);
87
117
  };
88
- checkGenetecConnection = async (params) => {
89
- return await this._postUrlEncoded(`${BASE_URL}/package/checkGenetecConnection.cgi`, params);
118
+ setZones = async (zonesJsonString, options) => {
119
+ return await this._postJsonEncoded(`${BASE_PATH}/package/setZones.cgi`, zonesJsonString, this.apiUser, options);
90
120
  };
91
- getGenetecCameraList = async (params) => {
92
- const res = await this._postUrlEncoded(`${BASE_URL}/package/getGenetecCameraList.cgi`, params);
93
- return await res.json();
121
+ goToCoordinates = async (lat, lon, alt, options) => {
122
+ const agent = this.getAgent(options?.proxyParams);
123
+ return await agent.get({
124
+ path: `${BASE_PATH}/package/goToCoordinates.cgi`,
125
+ parameters: { lat, lon, alt, ...this.apiUser },
126
+ timeout: options?.timeout,
127
+ });
128
+ };
129
+ checkGenetecConnection = async (params, options) => {
130
+ return await this._postUrlEncoded(`${BASE_PATH}/package/checkGenetecConnection.cgi`, params, options);
94
131
  };
95
- serverRunCheck = async () => {
96
- return await this.client.get(`${BASE_URL}/package/serverRunCheck.cgi`);
132
+ getGenetecCameraList = async (params, options) => {
133
+ const res = await this._postUrlEncoded(`${BASE_PATH}/package/getGenetecCameraList.cgi`, params, options);
134
+ return await res.json();
97
135
  };
98
- async _getJson(...args) {
99
- const res = await this.client.get(...args);
136
+ async _getJson(path, parameters, options) {
137
+ const agent = this.getAgent(options?.proxyParams);
138
+ const res = await agent.get({
139
+ path,
140
+ parameters,
141
+ timeout: options?.timeout,
142
+ });
100
143
  if (res.ok) {
101
144
  return await res.json();
102
145
  }
@@ -104,8 +147,13 @@ export class PlaneTrackerAPI {
104
147
  throw new Error(await responseStringify(res));
105
148
  }
106
149
  }
107
- async _getBlob(...args) {
108
- const res = await this.client.get(...args);
150
+ async _getBlob(path, parameters, options) {
151
+ const agent = this.getAgent(options?.proxyParams);
152
+ const res = await agent.get({
153
+ path,
154
+ parameters,
155
+ timeout: options?.timeout,
156
+ });
109
157
  if (res.ok) {
110
158
  return await this.parseBlobResponse(res);
111
159
  }
@@ -121,10 +169,15 @@ export class PlaneTrackerAPI {
121
169
  throw new ParsingBlobError(err);
122
170
  }
123
171
  }
124
- async _postJsonEncoded(...args) {
125
- const [path, data, params, headers] = args;
126
- const baseHeaders = { 'Accept': 'application/json', 'Content-Type': 'application/json' };
127
- const res = await this.client.post(path, data, params, { ...baseHeaders, ...headers });
172
+ async _postJsonEncoded(path, data, parameters, options) {
173
+ const agent = this.getAgent(options?.proxyParams);
174
+ const res = await agent.post({
175
+ path,
176
+ data,
177
+ parameters,
178
+ headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' },
179
+ timeout: options?.timeout,
180
+ });
128
181
  if (res.ok) {
129
182
  return res;
130
183
  }
@@ -132,10 +185,15 @@ export class PlaneTrackerAPI {
132
185
  throw new Error(await responseStringify(res));
133
186
  }
134
187
  }
135
- async _postUrlEncoded(path, params, headers) {
188
+ async _postUrlEncoded(path, params, options) {
136
189
  const data = paramToUrl(params);
137
- const baseHeaders = { 'Content-Type': 'application/x-www-form-urlencoded' };
138
- const res = await this.client.post(path, data, {}, { ...baseHeaders, ...headers });
190
+ const agent = this.getAgent(options?.proxyParams);
191
+ const res = await agent.post({
192
+ path,
193
+ data,
194
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
195
+ timeout: options?.timeout,
196
+ });
139
197
  if (res.ok) {
140
198
  return res;
141
199
  }
@@ -143,4 +201,7 @@ export class PlaneTrackerAPI {
143
201
  throw new Error(await responseStringify(res));
144
202
  }
145
203
  }
204
+ getAgent(proxyParams) {
205
+ return proxyParams ? new ProxyClient(this.client, proxyParams) : this.client;
206
+ }
146
207
  }
package/esm/VapixAPI.d.ts CHANGED
@@ -1,26 +1,25 @@
1
1
  import { IClient, TParameters, TResponse } from './internal/types';
2
2
  import { TAudioSampleRates, TSDCardInfo, TPtzOverview, TCameraPTZItem, TCameraPTZItemData, TAudioDevice, TPortSetSchema, TPortSequenceStateSchema } from './types/VapixAPI';
3
- import { ProxyClient } from './internal/ProxyClient';
4
- import { TCameraImageConfig, TProxyParam } from './types/common';
3
+ import { TCameraImageConfig, THttpRequestOptions } from './types/common';
5
4
  export declare class VapixAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
6
- client: ProxyClient<Client>;
7
- constructor(client: Client, getProxyUrl: () => string);
8
- getUrlEncoded(proxy: TProxyParam, path: string, parameters?: TParameters, headers?: Record<string, string>): Promise<TResponse>;
9
- postJson(proxy: TProxyParam, path: string, jsonData: Record<string, any>, headers?: Record<string, string>): Promise<TResponse>;
10
- getCameraImage(params: TCameraImageConfig, proxy?: TProxyParam): Promise<TResponse>;
11
- getEventDeclarations(proxy?: TProxyParam): Promise<string>;
12
- getSupportedAudioSampleRate(proxy?: TProxyParam): Promise<TAudioSampleRates[]>;
13
- performAutofocus(proxy?: TProxyParam): Promise<void>;
14
- checkSDCard(proxy?: TProxyParam): Promise<TSDCardInfo>;
15
- mountSDCard(proxy?: TProxyParam): Promise<number>;
16
- unmountSDCard(proxy?: TProxyParam): Promise<number>;
5
+ private client;
6
+ constructor(client: Client);
7
+ postUrlEncoded(path: string, parameters?: TParameters, headers?: Record<string, string>, options?: THttpRequestOptions): Promise<TResponse>;
8
+ postJson(path: string, jsonData: Record<string, any>, headers?: Record<string, string>, options?: THttpRequestOptions): Promise<TResponse>;
9
+ getCameraImage(parameters: TCameraImageConfig, options?: THttpRequestOptions): Promise<TResponse>;
10
+ getEventDeclarations(options?: THttpRequestOptions): Promise<string>;
11
+ getSupportedAudioSampleRate(options?: THttpRequestOptions): Promise<TAudioSampleRates[]>;
12
+ performAutofocus(options?: THttpRequestOptions): Promise<void>;
13
+ checkSDCard(options?: THttpRequestOptions): Promise<TSDCardInfo>;
14
+ mountSDCard(options?: THttpRequestOptions): Promise<number>;
15
+ unmountSDCard(options?: THttpRequestOptions): Promise<number>;
17
16
  private _doSDCardMountAction;
18
- fetchSDCardJobProgress(jobId: number, proxy?: TProxyParam): Promise<number>;
19
- downloadCameraReport(proxy?: TProxyParam): Promise<TResponse>;
20
- getSystemLog(proxy?: TProxyParam): Promise<TResponse>;
21
- getMaxFps(channel: number, proxy?: TProxyParam): Promise<number>;
22
- getTimezone(proxy?: TProxyParam): Promise<string>;
23
- getDateTimeInfo(proxy?: TProxyParam): Promise<{
17
+ fetchSDCardJobProgress(jobId: number, options?: THttpRequestOptions): Promise<number>;
18
+ downloadCameraReport(options?: THttpRequestOptions): Promise<TResponse>;
19
+ getSystemLog(options?: THttpRequestOptions): Promise<TResponse>;
20
+ getMaxFps(channel: number, options?: THttpRequestOptions): Promise<number>;
21
+ getTimezone(options?: THttpRequestOptions): Promise<string>;
22
+ getDateTimeInfo(options?: THttpRequestOptions): Promise<{
24
23
  data: {
25
24
  dateTime: string;
26
25
  dstEnabled: boolean;
@@ -29,13 +28,13 @@ export declare class VapixAPI<Client extends IClient<TResponse> = IClient<TRespo
29
28
  timeZone?: string | undefined;
30
29
  };
31
30
  }>;
32
- getDevicesSettings(proxy?: TProxyParam): Promise<TAudioDevice[]>;
33
- fetchRemoteDeviceInfo<T extends Record<string, any>>(payload: T, proxy?: TProxyParam): Promise<any>;
34
- getHeaders(proxy?: TProxyParam): Promise<Record<string, string>>;
35
- setHeaders(headers: Record<string, string>, proxy?: TProxyParam): Promise<TResponse>;
36
- getParameter(paramNames: string | string[], proxy?: TProxyParam): Promise<Record<string, string>>;
37
- setParameter(params: Record<string, string | number | boolean>, proxy?: TProxyParam): Promise<boolean>;
38
- getGuardTourList(proxy?: TProxyParam): Promise<{
31
+ getDevicesSettings(options?: THttpRequestOptions): Promise<TAudioDevice[]>;
32
+ fetchRemoteDeviceInfo<T extends Record<string, any>>(payload: T, options?: THttpRequestOptions): Promise<any>;
33
+ getHeaders(options?: THttpRequestOptions): Promise<Record<string, string>>;
34
+ setHeaders(headers: Record<string, string>, options?: THttpRequestOptions): Promise<TResponse>;
35
+ getParameter(paramNames: string | string[], options?: THttpRequestOptions): Promise<Record<string, string>>;
36
+ setParameter(params: Record<string, string | number | boolean>, options?: THttpRequestOptions): Promise<boolean>;
37
+ getGuardTourList(options?: THttpRequestOptions): Promise<{
39
38
  name: string;
40
39
  id: string;
41
40
  running: string;
@@ -50,13 +49,13 @@ export declare class VapixAPI<Client extends IClient<TResponse> = IClient<TRespo
50
49
  randomEnabled?: unknown;
51
50
  timeBetweenSequences?: unknown;
52
51
  }[]>;
53
- setGuardTourEnabled(guardTourID: string, enable: boolean, proxy?: TProxyParam): Promise<boolean>;
54
- getPTZPresetList(channel: number, proxy?: TProxyParam): Promise<string[]>;
55
- listPTZ(camera: number, proxy?: TProxyParam): Promise<TCameraPTZItem[]>;
56
- listPtzVideoSourceOverview(proxy?: TProxyParam): Promise<TPtzOverview>;
57
- goToPreset(channel: number, presetName: string, proxy?: TProxyParam): Promise<TResponse>;
58
- getPtzPosition(camera: number, proxy?: TProxyParam): Promise<TCameraPTZItemData>;
59
- getPorts(proxy?: TProxyParam): Promise<{
52
+ setGuardTourEnabled(guardTourID: string, enable: boolean, options?: THttpRequestOptions): Promise<boolean>;
53
+ getPTZPresetList(channel: number, options?: THttpRequestOptions): Promise<string[]>;
54
+ listPTZ(camera: number, options?: THttpRequestOptions): Promise<TCameraPTZItem[]>;
55
+ listPtzVideoSourceOverview(options?: THttpRequestOptions): Promise<TPtzOverview>;
56
+ goToPreset(channel: number, presetName: string, options?: THttpRequestOptions): Promise<TResponse>;
57
+ getPtzPosition(camera: number, options?: THttpRequestOptions): Promise<TCameraPTZItemData>;
58
+ getPorts(options?: THttpRequestOptions): Promise<{
60
59
  name: string;
61
60
  port: string;
62
61
  state: "open" | "closed";
@@ -66,11 +65,15 @@ export declare class VapixAPI<Client extends IClient<TResponse> = IClient<TRespo
66
65
  normalState: "open" | "closed";
67
66
  readonly?: boolean | undefined;
68
67
  }[]>;
69
- setPorts(ports: TPortSetSchema[], proxy?: TProxyParam): Promise<void>;
70
- setPortStateSequence(port: number, sequence: TPortSequenceStateSchema[], proxy?: TProxyParam): Promise<void>;
71
- getApplicationList(proxy?: TProxyParam): Promise<any>;
72
- startApplication(applicationID: string, proxy?: TProxyParam): Promise<void>;
73
- restartApplication(applicationID: string, proxy?: TProxyParam): Promise<void>;
74
- stopApplication(applicationID: string, proxy?: TProxyParam): Promise<void>;
75
- installApplication(data: Blob, fileName: string): Promise<void>;
68
+ setPorts(ports: TPortSetSchema[], options?: THttpRequestOptions): Promise<void>;
69
+ setPortStateSequence(port: number, sequence: TPortSequenceStateSchema[], options?: THttpRequestOptions): Promise<void>;
70
+ getApplicationList(options?: THttpRequestOptions): Promise<any>;
71
+ startApplication(applicationID: string, options?: THttpRequestOptions): Promise<void>;
72
+ restartApplication(applicationID: string, options?: THttpRequestOptions): Promise<void>;
73
+ stopApplication(applicationID: string, options?: THttpRequestOptions): Promise<void>;
74
+ installApplication(data: Blob, fileName: string, options?: THttpRequestOptions): Promise<void>;
75
+ private static parseParameters;
76
+ private static parseCameraPtzResponse;
77
+ private static parsePtz;
78
+ private getAgent;
76
79
  }