camstreamerlib 4.0.0-beta.30 → 4.0.0-beta.31

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 (39) hide show
  1. package/cjs/CamOverlayAPI.d.ts +3 -2
  2. package/cjs/CamOverlayAPI.js +8 -8
  3. package/cjs/CamScripterAPI.d.ts +3 -2
  4. package/cjs/CamScripterAPI.js +5 -5
  5. package/cjs/CamStreamerAPI.d.ts +3 -2
  6. package/cjs/CamStreamerAPI.js +4 -4
  7. package/cjs/CamSwitcherAPI.d.ts +3 -2
  8. package/cjs/CamSwitcherAPI.js +7 -7
  9. package/cjs/PlaneTrackerAPI.d.ts +3 -2
  10. package/cjs/PlaneTrackerAPI.js +15 -15
  11. package/cjs/VapixAPI.d.ts +3 -2
  12. package/cjs/VapixAPI.js +13 -13
  13. package/cjs/events/AxisCameraStationEvents.d.ts +4 -2
  14. package/cjs/events/AxisCameraStationEvents.js +4 -4
  15. package/cjs/types/CamOverlayAPI/CamOverlayAPI.d.ts +0 -2
  16. package/cjs/types/CamSwitcherAPI.d.ts +0 -2
  17. package/cjs/types/VapixAPI.d.ts +0 -2
  18. package/esm/CamOverlayAPI.d.ts +3 -2
  19. package/esm/CamOverlayAPI.js +8 -8
  20. package/esm/CamScripterAPI.d.ts +3 -2
  21. package/esm/CamScripterAPI.js +5 -5
  22. package/esm/CamStreamerAPI.d.ts +3 -2
  23. package/esm/CamStreamerAPI.js +4 -4
  24. package/esm/CamSwitcherAPI.d.ts +3 -2
  25. package/esm/CamSwitcherAPI.js +7 -7
  26. package/esm/PlaneTrackerAPI.d.ts +3 -2
  27. package/esm/PlaneTrackerAPI.js +15 -15
  28. package/esm/VapixAPI.d.ts +3 -2
  29. package/esm/VapixAPI.js +13 -13
  30. package/esm/events/AxisCameraStationEvents.d.ts +4 -2
  31. package/esm/events/AxisCameraStationEvents.js +4 -4
  32. package/esm/types/CamOverlayAPI/CamOverlayAPI.d.ts +0 -2
  33. package/esm/types/CamSwitcherAPI.d.ts +0 -2
  34. package/esm/types/VapixAPI.d.ts +0 -2
  35. package/package.json +1 -1
  36. package/cjs/node/WsEventClient.d.ts +0 -13
  37. package/cjs/node/WsEventClient.js +0 -22
  38. package/esm/node/WsEventClient.d.ts +0 -13
  39. package/esm/node/WsEventClient.js +0 -18
@@ -1,7 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
3
  import { IClient, TBlobResponse, TResponse } from './internal/types';
4
- import { THttpRequestOptions, TNetworkCamera } from './types/common';
4
+ import { THttpRequestOptions, TProxyParams, TNetworkCamera } from './types/common';
5
+ import { ProxyClient } from './internal/ProxyClient';
5
6
  import { ImageType, TCoordinates, TFile, TFileList, TFileType, TStorage, TStorageDataList, TWidget } from './types/CamOverlayAPI/CamOverlayAPI';
6
7
  import { TField } from './types/CamOverlayAPI';
7
8
  export declare const allowedWidgetNames: {
@@ -21,6 +22,7 @@ export declare class CamOverlayAPI<Client extends IClient<TResponse> = IClient<T
21
22
  static getBasePath: () => string;
22
23
  static getProxyPath: () => string;
23
24
  static getFilePreviewPath: (path: string) => string;
25
+ getClient(proxyParams?: TProxyParams): Client | ProxyClient<Client>;
24
26
  checkCameraTime(options?: THttpRequestOptions): Promise<boolean>;
25
27
  getNetworkCameraList(options?: THttpRequestOptions): Promise<TNetworkCamera[]>;
26
28
  wsAuthorization(options?: THttpRequestOptions): Promise<string>;
@@ -48,5 +50,4 @@ export declare class CamOverlayAPI<Client extends IClient<TResponse> = IClient<T
48
50
  private parseBlobResponse;
49
51
  private _postUrlEncoded;
50
52
  private _postJsonEncoded;
51
- private getAgent;
52
53
  }
@@ -27,6 +27,9 @@ class CamOverlayAPI {
27
27
  static getBasePath = () => BASE_PATH;
28
28
  static getProxyPath = () => `${BASE_PATH}/proxy.cgi`;
29
29
  static getFilePreviewPath = (path) => `${BASE_PATH}/image.cgi?path=${encodeURIComponent(path)}`;
30
+ getClient(proxyParams) {
31
+ return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
32
+ }
30
33
  async checkCameraTime(options) {
31
34
  const response = await this._get({ path: `${BASE_PATH}/camera_time.cgi` }, options);
32
35
  return zod_1.z.boolean().parse(response.state);
@@ -92,7 +95,7 @@ class CamOverlayAPI {
92
95
  await this._post({ path: `${BASE_PATH}/enabled.cgi?id_${serviceId}=${enabled ? 1 : 0}`, data: '' }, options);
93
96
  }
94
97
  async isEnabled(serviceId, options) {
95
- const agent = this.getAgent(options?.proxyParams);
98
+ const agent = this.getClient(options?.proxyParams);
96
99
  const res = await agent.get({ path: `${BASE_PATH}/services.cgi?action=get`, timeout: options?.timeout });
97
100
  if (res.ok) {
98
101
  const data = JSON.parse(await res.text());
@@ -189,7 +192,7 @@ class CamOverlayAPI {
189
192
  if (contentType !== undefined && data) {
190
193
  headers = { 'Content-Type': contentType };
191
194
  }
192
- const agent = this.getAgent(options?.proxyParams);
195
+ const agent = this.getClient(options?.proxyParams);
193
196
  const res = await agent.post({
194
197
  path,
195
198
  data: data ?? '',
@@ -206,7 +209,7 @@ class CamOverlayAPI {
206
209
  }
207
210
  }
208
211
  async _get(params, options) {
209
- const agent = this.getAgent(options?.proxyParams);
212
+ const agent = this.getClient(options?.proxyParams);
210
213
  const res = await agent.get({ ...params, timeout: options?.timeout });
211
214
  if (res.ok) {
212
215
  return (await res.json());
@@ -216,7 +219,7 @@ class CamOverlayAPI {
216
219
  }
217
220
  }
218
221
  async _post(params, options) {
219
- const agent = this.getAgent(options?.proxyParams);
222
+ const agent = this.getClient(options?.proxyParams);
220
223
  const res = await agent.post({ ...params, timeout: options?.timeout });
221
224
  if (res.ok) {
222
225
  return (await res.json());
@@ -226,7 +229,7 @@ class CamOverlayAPI {
226
229
  }
227
230
  }
228
231
  async _getBlob(params, options) {
229
- const agent = this.getAgent(options?.proxyParams);
232
+ const agent = this.getClient(options?.proxyParams);
230
233
  const res = await agent.get({ ...params, timeout: options?.timeout });
231
234
  if (res.ok) {
232
235
  return await this.parseBlobResponse(res);
@@ -252,8 +255,5 @@ class CamOverlayAPI {
252
255
  const baseHeaders = { 'Accept': 'application/json', 'Content-Type': 'application/json' };
253
256
  return this._post({ path, data, parameters, headers: { ...baseHeaders, ...headers } }, options);
254
257
  }
255
- getAgent(proxyParams) {
256
- return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
257
- }
258
258
  }
259
259
  exports.CamOverlayAPI = CamOverlayAPI;
@@ -1,10 +1,12 @@
1
+ import { ProxyClient } from './internal/ProxyClient';
1
2
  import { IClient, TResponse } from './internal/types';
2
3
  import { TNodeState, TPackageInfoList, TStorage, TStorageType } from './types/CamScripterAPI';
3
- import { THttpRequestOptions, TNetworkCamera } from './types/common';
4
+ import { THttpRequestOptions, TNetworkCamera, TProxyParams } from './types/common';
4
5
  export declare class CamScripterAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
5
6
  client: Client;
6
7
  constructor(client: Client);
7
8
  static getProxyUrlPath: () => string;
9
+ getClient(proxyParams?: TProxyParams): Client | ProxyClient<Client>;
8
10
  checkCameraTime(options?: THttpRequestOptions): Promise<boolean>;
9
11
  getNetworkCameraList(options?: THttpRequestOptions): Promise<TNetworkCamera[]>;
10
12
  getStorageInfo(options?: THttpRequestOptions): Promise<TStorage>;
@@ -32,5 +34,4 @@ export declare class CamScripterAPI<Client extends IClient<TResponse> = IClient<
32
34
  }>;
33
35
  private get;
34
36
  private post;
35
- private getAgent;
36
37
  }
@@ -12,6 +12,9 @@ class CamScripterAPI {
12
12
  this.client = client;
13
13
  }
14
14
  static getProxyUrlPath = () => `${BASE_PATH}/proxy.cgi`;
15
+ getClient(proxyParams) {
16
+ return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
17
+ }
15
18
  async checkCameraTime(options) {
16
19
  const data = await this.get(`${BASE_PATH}/camera_time.cgi`, undefined, options);
17
20
  return CamScripterAPI_1.cameraTimeResponseSchema.parse(data).state;
@@ -53,7 +56,7 @@ class CamScripterAPI {
53
56
  return CamScripterAPI_1.camscripterApiResponseSchema.parse(data);
54
57
  }
55
58
  async get(path, parameters, options) {
56
- const agent = this.getAgent(options?.proxyParams);
59
+ const agent = this.getClient(options?.proxyParams);
57
60
  const res = await agent.get({ path, parameters, timeout: options?.timeout });
58
61
  if (res.ok) {
59
62
  return await res.json();
@@ -63,7 +66,7 @@ class CamScripterAPI {
63
66
  }
64
67
  }
65
68
  async post(path, data, parameters, options) {
66
- const agent = this.getAgent(options?.proxyParams);
69
+ const agent = this.getClient(options?.proxyParams);
67
70
  const res = await agent.post({ path, data, parameters, timeout: options?.timeout });
68
71
  if (res.ok) {
69
72
  return await res.json();
@@ -72,8 +75,5 @@ class CamScripterAPI {
72
75
  throw new Error(await (0, utils_1.responseStringify)(res));
73
76
  }
74
77
  }
75
- getAgent(proxyParams) {
76
- return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
77
- }
78
78
  }
79
79
  exports.CamScripterAPI = CamScripterAPI;
@@ -1,9 +1,11 @@
1
+ import { ProxyClient } from './internal/ProxyClient';
1
2
  import { IClient, TResponse } from './internal/types';
2
3
  import { TStreamAttributes, TStreamList } from './types/CamStreamerAPI';
3
- import { THttpRequestOptions } from './types/common';
4
+ import { THttpRequestOptions, TProxyParams } from './types/common';
4
5
  export declare class CamStreamerAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
5
6
  client: Client;
6
7
  constructor(client: Client);
8
+ getClient(proxyParams?: TProxyParams): Client | ProxyClient<Client>;
7
9
  getStreamList(options?: THttpRequestOptions): Promise<TStreamList>;
8
10
  getStream(streamId: string, options?: THttpRequestOptions): Promise<TStreamAttributes>;
9
11
  getStreamParameter(streamId: string, paramName: string, options?: THttpRequestOptions): Promise<string>;
@@ -14,5 +16,4 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse> = IClient<
14
16
  wsAuthorization(options?: THttpRequestOptions): Promise<string>;
15
17
  getUtcTime(options?: THttpRequestOptions): Promise<number>;
16
18
  private get;
17
- private getAgent;
18
19
  }
@@ -10,6 +10,9 @@ class CamStreamerAPI {
10
10
  constructor(client) {
11
11
  this.client = client;
12
12
  }
13
+ getClient(proxyParams) {
14
+ return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
15
+ }
13
16
  async getStreamList(options) {
14
17
  const streamListRes = await this.get(`${BASE_PATH}/stream/list.cgi`, undefined, options);
15
18
  return CamStreamerAPI_1.streamListSchema.parse(streamListRes.data);
@@ -49,7 +52,7 @@ class CamStreamerAPI {
49
52
  return await this.get(`${BASE_PATH}/get_utc_time.cgi`, undefined, options);
50
53
  }
51
54
  async get(path, parameters, options) {
52
- const agent = this.getAgent(options?.proxyParams);
55
+ const agent = this.getClient(options?.proxyParams);
53
56
  const res = await agent.get({ path, parameters, timeout: options?.timeout });
54
57
  if (res.ok) {
55
58
  return await res.json();
@@ -58,8 +61,5 @@ class CamStreamerAPI {
58
61
  throw new Error(await (0, utils_1.responseStringify)(res));
59
62
  }
60
63
  }
61
- getAgent(proxyParams) {
62
- return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
63
- }
64
64
  }
65
65
  exports.CamStreamerAPI = CamStreamerAPI;
@@ -1,6 +1,7 @@
1
1
  import { IClient, TResponse } from './internal/types';
2
2
  import { TAudioPushInfo, TOutputInfo, TStorageInfo, TStreamSaveList, TClipList, TStreamSaveLoadList, TClipSaveLoadList, TPlaylistSaveLoadList, TTrackerSaveList, TrackerSaveLoadList, TClipSaveList, TPlaylistSaveList, TCameraOptions, TGlobalAudioSettings, TSecondaryAudioSettings } from './types/CamSwitcherAPI';
3
- import { TAudioChannel, THttpRequestOptions, TNetworkCamera, TStorageType } from './types/common';
3
+ import { TAudioChannel, THttpRequestOptions, TNetworkCamera, TProxyParams, TStorageType } from './types/common';
4
+ import { ProxyClient } from './internal/ProxyClient';
4
5
  export declare class CamSwitcherAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
5
6
  client: Client;
6
7
  private CustomFormData;
@@ -12,6 +13,7 @@ export declare class CamSwitcherAPI<Client extends IClient<TResponse> = IClient<
12
13
  static getProxyUrlPath: () => string;
13
14
  static getWsEventsUrlPath: () => string;
14
15
  static getClipPreviewUrlPath: (id: string, storage: TStorageType) => string;
16
+ getClient(proxyParams?: TProxyParams): Client | ProxyClient<Client>;
15
17
  generateSilence(sampleRate: number, channels: TAudioChannel, options?: THttpRequestOptions): Promise<void>;
16
18
  checkCameraTime(options?: THttpRequestOptions): Promise<boolean>;
17
19
  getNetworkCameraList(options?: THttpRequestOptions): Promise<TNetworkCamera[]>;
@@ -49,5 +51,4 @@ export declare class CamSwitcherAPI<Client extends IClient<TResponse> = IClient<
49
51
  private set;
50
52
  private setParamFromCameraJSON;
51
53
  private getParamFromCameraAndJSONParse;
52
- private getAgent;
53
54
  }
@@ -23,8 +23,11 @@ class CamSwitcherAPI {
23
23
  static getProxyUrlPath = () => `${BASE_PATH}/proxy.cgi`;
24
24
  static getWsEventsUrlPath = () => `/local/camswitcher/events`;
25
25
  static getClipPreviewUrlPath = (id, storage) => `${BASE_PATH}/clip_preview.cgi?clip_name=${id}&storage=${storage}`;
26
+ getClient(proxyParams) {
27
+ return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
28
+ }
26
29
  async generateSilence(sampleRate, channels, options) {
27
- const agent = this.getAgent(options?.proxyParams);
30
+ const agent = this.getClient(options?.proxyParams);
28
31
  await agent.get({
29
32
  path: `${BASE_PATH}/generate_silence.cgi`,
30
33
  parameters: {
@@ -114,7 +117,7 @@ class CamSwitcherAPI {
114
117
  formData.append('clip_name', id);
115
118
  formData.append('clip_type', clipType);
116
119
  formData.append('file', file, fileName);
117
- const agent = this.getAgent(options?.proxyParams);
120
+ const agent = this.getClient(options?.proxyParams);
118
121
  const res = await agent.post({ path, data: formData, timeout: options?.timeout });
119
122
  const output = (await res.json());
120
123
  if (output.status !== 200) {
@@ -247,7 +250,7 @@ class CamSwitcherAPI {
247
250
  return res[paramName] ?? '';
248
251
  }
249
252
  async get(path, parameters, options) {
250
- const agent = this.getAgent(options?.proxyParams);
253
+ const agent = this.getClient(options?.proxyParams);
251
254
  const res = await agent.get({ path, parameters, timeout: options?.timeout });
252
255
  if (res.ok) {
253
256
  const d = (await res.json());
@@ -258,7 +261,7 @@ class CamSwitcherAPI {
258
261
  }
259
262
  }
260
263
  async set(path, data, parameters, options) {
261
- const agent = this.getAgent(options?.proxyParams);
264
+ const agent = this.getClient(options?.proxyParams);
262
265
  const res = await agent.post({ path, data: JSON.stringify(data), parameters, timeout: options?.timeout });
263
266
  if (res.ok) {
264
267
  const parsed = await res.json();
@@ -290,9 +293,6 @@ class CamSwitcherAPI {
290
293
  }
291
294
  throw new Error("Error: no parametr '" + paramName + "' was found");
292
295
  }
293
- getAgent(proxyParams) {
294
- return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
295
- }
296
296
  }
297
297
  exports.CamSwitcherAPI = CamSwitcherAPI;
298
298
  const CSW_PARAM_NAMES = {
@@ -1,11 +1,13 @@
1
1
  import { IClient, TBlobResponse, TParameters, TResponse } from './internal/types';
2
2
  import { ICAO, TApiUser, TExportDataType, TImportDataType } from './types/PlaneTrackerAPI';
3
- import { THttpRequestOptions } from './types/common';
3
+ import { THttpRequestOptions, TProxyParams } from './types/common';
4
+ import { ProxyClient } from './internal/ProxyClient';
4
5
  export declare class PlaneTrackerAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
5
6
  private client;
6
7
  private apiUser;
7
8
  constructor(client: Client, apiUser: TApiUser);
8
9
  static getProxyUrlPath: () => string;
10
+ getClient(proxyParams?: TProxyParams): Client | ProxyClient<Client>;
9
11
  checkCameraTime(options?: THttpRequestOptions): Promise<boolean>;
10
12
  resetPtzCalibration: (options?: THttpRequestOptions) => Promise<TResponse>;
11
13
  resetFocusCalibration: (options?: THttpRequestOptions) => Promise<TResponse>;
@@ -38,5 +40,4 @@ export declare class PlaneTrackerAPI<Client extends IClient<TResponse> = IClient
38
40
  private parseBlobResponse;
39
41
  private _postJsonEncoded;
40
42
  private _postUrlEncoded;
41
- private getAgent;
42
43
  }
@@ -14,12 +14,15 @@ class PlaneTrackerAPI {
14
14
  this.apiUser = apiUser;
15
15
  }
16
16
  static getProxyUrlPath = () => `${BASE_PATH}/proxy.cgi`;
17
+ getClient(proxyParams) {
18
+ return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
19
+ }
17
20
  async checkCameraTime(options) {
18
21
  const response = await this._getJson(`${BASE_PATH}/camera_time.cgi`, undefined, options);
19
22
  return zod_1.z.boolean().parse(response.state);
20
23
  }
21
24
  resetPtzCalibration = async (options) => {
22
- const agent = this.getAgent(options?.proxyParams);
25
+ const agent = this.getClient(options?.proxyParams);
23
26
  return await agent.get({
24
27
  path: `${BASE_PATH}/package/resetPtzCalibration.cgi`,
25
28
  parameters: this.apiUser,
@@ -27,7 +30,7 @@ class PlaneTrackerAPI {
27
30
  });
28
31
  };
29
32
  resetFocusCalibration = async (options) => {
30
- const agent = this.getAgent(options?.proxyParams);
33
+ const agent = this.getClient(options?.proxyParams);
31
34
  return await agent.get({
32
35
  path: `${BASE_PATH}/package/resetFocusCalibration.cgi`,
33
36
  parameters: this.apiUser,
@@ -35,11 +38,11 @@ class PlaneTrackerAPI {
35
38
  });
36
39
  };
37
40
  serverRunCheck = async (options) => {
38
- const agent = this.getAgent(options?.proxyParams);
41
+ const agent = this.getClient(options?.proxyParams);
39
42
  return await agent.get({ path: `${BASE_PATH}/package/serverRunCheck.cgi`, timeout: options?.timeout });
40
43
  };
41
44
  getLiveViewAlias = async (rtspUrl, options) => {
42
- const agent = this.getAgent(options?.proxyParams);
45
+ const agent = this.getClient(options?.proxyParams);
43
46
  return await agent.get({
44
47
  path: `${BASE_PATH}/getLiveViewAlias.cgi`,
45
48
  parameters: { rtsp_url: rtspUrl },
@@ -61,7 +64,7 @@ class PlaneTrackerAPI {
61
64
  return await this._getBlob(`${BASE_PATH}/package_data.cgi`, { action: 'EXPORT', dataType }, options);
62
65
  };
63
66
  importAppSettings = async (dataType, formData, options) => {
64
- const agent = this.getAgent(options?.proxyParams);
67
+ const agent = this.getClient(options?.proxyParams);
65
68
  return await agent.post({
66
69
  path: `${BASE_PATH}/package_data.cgi`,
67
70
  data: formData,
@@ -79,7 +82,7 @@ class PlaneTrackerAPI {
79
82
  return await this._postJsonEncoded(`${BASE_PATH}/package/setTrackingMode.cgi`, modeJsonString, this.apiUser, options);
80
83
  };
81
84
  startTrackingPlane = async (icao, options) => {
82
- const agent = this.getAgent(options?.proxyParams);
85
+ const agent = this.getClient(options?.proxyParams);
83
86
  return await agent.get({
84
87
  path: `${BASE_PATH}/package/trackIcao.cgi`,
85
88
  parameters: { icao, ...this.apiUser },
@@ -87,7 +90,7 @@ class PlaneTrackerAPI {
87
90
  });
88
91
  };
89
92
  stopTrackingPlane = async (options) => {
90
- const agent = this.getAgent(options?.proxyParams);
93
+ const agent = this.getClient(options?.proxyParams);
91
94
  return await agent.get({
92
95
  path: `${BASE_PATH}/package/resetIcao.cgi`,
93
96
  parameters: this.apiUser,
@@ -122,7 +125,7 @@ class PlaneTrackerAPI {
122
125
  return await this._postJsonEncoded(`${BASE_PATH}/package/setZones.cgi`, zonesJsonString, this.apiUser, options);
123
126
  };
124
127
  goToCoordinates = async (lat, lon, alt, options) => {
125
- const agent = this.getAgent(options?.proxyParams);
128
+ const agent = this.getClient(options?.proxyParams);
126
129
  return await agent.get({
127
130
  path: `${BASE_PATH}/package/goToCoordinates.cgi`,
128
131
  parameters: { lat, lon, alt, ...this.apiUser },
@@ -137,7 +140,7 @@ class PlaneTrackerAPI {
137
140
  return await res.json();
138
141
  };
139
142
  async _getJson(path, parameters, options) {
140
- const agent = this.getAgent(options?.proxyParams);
143
+ const agent = this.getClient(options?.proxyParams);
141
144
  const res = await agent.get({
142
145
  path,
143
146
  parameters,
@@ -151,7 +154,7 @@ class PlaneTrackerAPI {
151
154
  }
152
155
  }
153
156
  async _getBlob(path, parameters, options) {
154
- const agent = this.getAgent(options?.proxyParams);
157
+ const agent = this.getClient(options?.proxyParams);
155
158
  const res = await agent.get({
156
159
  path,
157
160
  parameters,
@@ -173,7 +176,7 @@ class PlaneTrackerAPI {
173
176
  }
174
177
  }
175
178
  async _postJsonEncoded(path, data, parameters, options) {
176
- const agent = this.getAgent(options?.proxyParams);
179
+ const agent = this.getClient(options?.proxyParams);
177
180
  const res = await agent.post({
178
181
  path,
179
182
  data,
@@ -190,7 +193,7 @@ class PlaneTrackerAPI {
190
193
  }
191
194
  async _postUrlEncoded(path, params, options) {
192
195
  const data = (0, utils_1.paramToUrl)(params);
193
- const agent = this.getAgent(options?.proxyParams);
196
+ const agent = this.getClient(options?.proxyParams);
194
197
  const res = await agent.post({
195
198
  path,
196
199
  data,
@@ -204,8 +207,5 @@ class PlaneTrackerAPI {
204
207
  throw new Error(await (0, utils_1.responseStringify)(res));
205
208
  }
206
209
  }
207
- getAgent(proxyParams) {
208
- return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
209
- }
210
210
  }
211
211
  exports.PlaneTrackerAPI = PlaneTrackerAPI;
package/cjs/VapixAPI.d.ts CHANGED
@@ -1,9 +1,11 @@
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 { TCameraImageConfig, THttpRequestOptions } from './types/common';
3
+ import { ProxyClient } from './internal/ProxyClient';
4
+ import { TCameraImageConfig, THttpRequestOptions, TProxyParams } from './types/common';
4
5
  export declare class VapixAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
5
6
  private client;
6
7
  constructor(client: Client);
8
+ getClient(proxyParams?: TProxyParams): Client | ProxyClient<Client>;
7
9
  postUrlEncoded(path: string, parameters?: TParameters, headers?: Record<string, string>, options?: THttpRequestOptions): Promise<TResponse>;
8
10
  postJson(path: string, jsonData: Record<string, any>, headers?: Record<string, string>, options?: THttpRequestOptions): Promise<TResponse>;
9
11
  getCameraImage(parameters: TCameraImageConfig, options?: THttpRequestOptions): Promise<TResponse>;
@@ -75,5 +77,4 @@ export declare class VapixAPI<Client extends IClient<TResponse> = IClient<TRespo
75
77
  private static parseParameters;
76
78
  private static parseCameraPtzResponse;
77
79
  private static parsePtz;
78
- private getAgent;
79
80
  }
package/cjs/VapixAPI.js CHANGED
@@ -13,10 +13,13 @@ class VapixAPI {
13
13
  constructor(client) {
14
14
  this.client = client;
15
15
  }
16
+ getClient(proxyParams) {
17
+ return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
18
+ }
16
19
  async postUrlEncoded(path, parameters, headers, options) {
17
20
  const data = (0, utils_1.paramToUrl)(parameters);
18
21
  const head = { ...headers, 'Content-Type': 'application/x-www-form-urlencoded' };
19
- const agent = this.getAgent(options?.proxyParams);
22
+ const agent = this.getClient(options?.proxyParams);
20
23
  const res = await agent.post({ path, data, headers: head, timeout: options?.timeout });
21
24
  if (!res.ok) {
22
25
  throw new Error(await (0, utils_1.responseStringify)(res));
@@ -26,7 +29,7 @@ class VapixAPI {
26
29
  async postJson(path, jsonData, headers, options) {
27
30
  const data = JSON.stringify(jsonData);
28
31
  const head = { ...headers, 'Content-Type': 'application/json' };
29
- const agent = this.getAgent(options?.proxyParams);
32
+ const agent = this.getClient(options?.proxyParams);
30
33
  const res = await agent.post({ path, data, headers: head, timeout: options?.timeout });
31
34
  if (!res.ok) {
32
35
  throw new Error(await (0, utils_1.responseStringify)(res));
@@ -34,7 +37,7 @@ class VapixAPI {
34
37
  return res;
35
38
  }
36
39
  async getCameraImage(parameters, options) {
37
- const agent = this.getAgent(options?.proxyParams);
40
+ const agent = this.getClient(options?.proxyParams);
38
41
  return await agent.get({ path: '/axis-cgi/jpg/image.cgi', parameters, timeout: options?.timeout });
39
42
  }
40
43
  async getEventDeclarations(options) {
@@ -44,7 +47,7 @@ class VapixAPI {
44
47
  '<GetEventInstances xmlns="http://www.axis.com/vapix/ws/event1"/>' +
45
48
  '</s:Body>' +
46
49
  '</s:Envelope>';
47
- const agent = this.getAgent(options?.proxyParams);
50
+ const agent = this.getClient(options?.proxyParams);
48
51
  const res = await agent.post({
49
52
  path: '/vapix/services',
50
53
  data,
@@ -180,7 +183,7 @@ class VapixAPI {
180
183
  }
181
184
  async getTimezone(options) {
182
185
  try {
183
- const agent = this.getAgent(options?.proxyParams);
186
+ const agent = this.getClient(options?.proxyParams);
184
187
  const resV2 = await agent.get({ path: '/config/rest/time/v2/timeZone', timeout: options?.timeout });
185
188
  if (!resV2.ok) {
186
189
  throw new Error(await (0, utils_1.responseStringify)(resV2));
@@ -389,7 +392,7 @@ class VapixAPI {
389
392
  }, undefined, options);
390
393
  }
391
394
  async getApplicationList(options) {
392
- const agent = this.getAgent(options?.proxyParams);
395
+ const agent = this.getClient(options?.proxyParams);
393
396
  const res = await agent.get({ path: '/axis-cgi/applications/list.cgi', timeout: options?.timeout });
394
397
  const xml = await res.text();
395
398
  const parser = new fast_xml_parser_1.XMLParser({
@@ -410,7 +413,7 @@ class VapixAPI {
410
413
  });
411
414
  }
412
415
  async startApplication(applicationID, options) {
413
- const agent = this.getAgent(options?.proxyParams);
416
+ const agent = this.getClient(options?.proxyParams);
414
417
  const res = await agent.get({
415
418
  path: '/axis-cgi/applications/control.cgi',
416
419
  parameters: {
@@ -425,7 +428,7 @@ class VapixAPI {
425
428
  }
426
429
  }
427
430
  async restartApplication(applicationID, options) {
428
- const agent = this.getAgent(options?.proxyParams);
431
+ const agent = this.getClient(options?.proxyParams);
429
432
  const res = await agent.get({
430
433
  path: '/axis-cgi/applications/control.cgi',
431
434
  parameters: {
@@ -440,7 +443,7 @@ class VapixAPI {
440
443
  }
441
444
  }
442
445
  async stopApplication(applicationID, options) {
443
- const agent = this.getAgent(options?.proxyParams);
446
+ const agent = this.getClient(options?.proxyParams);
444
447
  const res = await agent.get({
445
448
  path: '/axis-cgi/applications/control.cgi',
446
449
  parameters: {
@@ -457,7 +460,7 @@ class VapixAPI {
457
460
  async installApplication(data, fileName, options) {
458
461
  const formData = new FormData();
459
462
  formData.append('packfil', data, fileName);
460
- const agent = this.getAgent(options?.proxyParams);
463
+ const agent = this.getClient(options?.proxyParams);
461
464
  const res = await agent.post({
462
465
  path: '/axis-cgi/applications/upload.cgi',
463
466
  data: formData,
@@ -540,8 +543,5 @@ class VapixAPI {
540
543
  });
541
544
  return res;
542
545
  };
543
- getAgent(proxyParams) {
544
- return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
545
- }
546
546
  }
547
547
  exports.VapixAPI = VapixAPI;
@@ -1,10 +1,12 @@
1
1
  import { HttpOptions } from '../internal/types';
2
- import { THttpRequestOptions } from '../types/common';
2
+ import { THttpRequestOptions, TProxyParams } from '../types/common';
3
+ import { ProxyClient } from '../internal/ProxyClient';
4
+ import { DefaultClient } from '../node';
3
5
  export declare class AxisCameraStationEvents {
4
6
  private sourceKey;
5
7
  private client;
6
8
  constructor(clientOptions: HttpOptions, sourceKey: string);
9
+ getClient(proxyParams?: TProxyParams): DefaultClient | ProxyClient<DefaultClient>;
7
10
  sendEvent(data: Record<string, string>, eventType: string, options?: THttpRequestOptions): Promise<void>;
8
11
  private getDate;
9
- private getAgent;
10
12
  }
@@ -11,6 +11,9 @@ class AxisCameraStationEvents {
11
11
  this.sourceKey = sourceKey;
12
12
  this.client = new node_1.DefaultClient(clientOptions);
13
13
  }
14
+ getClient(proxyParams) {
15
+ return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
16
+ }
14
17
  async sendEvent(data, eventType, options) {
15
18
  const dateString = this.getDate();
16
19
  const event = {
@@ -22,7 +25,7 @@ class AxisCameraStationEvents {
22
25
  },
23
26
  };
24
27
  const eventData = JSON.stringify(event);
25
- const agent = this.getAgent(options?.proxyParams);
28
+ const agent = this.getClient(options?.proxyParams);
26
29
  const res = await agent.post({
27
30
  path: '/Acs/Api/ExternalDataFacade/AddExternalData',
28
31
  data: eventData,
@@ -46,8 +49,5 @@ class AxisCameraStationEvents {
46
49
  const seconds = (0, utils_1.pad)(date.getUTCSeconds(), 2);
47
50
  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
48
51
  }
49
- getAgent(proxyParams) {
50
- return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
51
- }
52
52
  }
53
53
  exports.AxisCameraStationEvents = AxisCameraStationEvents;
@@ -1,6 +1,4 @@
1
- import { HttpOptions } from '../../internal/types';
2
1
  import { z } from 'zod';
3
- export type CamOverlayOptions = HttpOptions;
4
2
  export declare const WSResponseSchema: z.ZodObject<{
5
3
  status: z.ZodNumber;
6
4
  message: z.ZodString;
@@ -1,7 +1,5 @@
1
- import { HttpOptions } from '../internal/types';
2
1
  import { z } from 'zod';
3
2
  import { TH264Profile, TAudioChannelCount, TKeyboardShortcut } from './common';
4
- export type CamSwitcherAPIOptions = HttpOptions;
5
3
  declare const channelTypeSchema: z.ZodUnion<[z.ZodLiteral<"audio">, z.ZodLiteral<"video">, z.ZodLiteral<"av">]>;
6
4
  export type TChannelType = z.infer<typeof channelTypeSchema>;
7
5
  declare const playlistPlayTypeSchema: z.ZodUnion<[z.ZodLiteral<"PLAY_ALL">, z.ZodLiteral<"PLAY_ALL_LOOP">, z.ZodLiteral<"PLAY_ALL_SHUFFLED">, z.ZodLiteral<"PLAY_ALL_LOOP_SHUFFLED">, z.ZodLiteral<"PLAY_ONE_RANDOM">]>;
@@ -1,6 +1,4 @@
1
- import { HttpOptions } from '../internal/types';
2
1
  import { z } from 'zod';
3
- export type CameraVapixOptions = HttpOptions;
4
2
  export declare const applicationSchema: z.ZodObject<{
5
3
  Name: z.ZodString;
6
4
  NiceName: z.ZodString;
@@ -1,7 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
3
  import { IClient, TBlobResponse, TResponse } from './internal/types';
4
- import { THttpRequestOptions, TNetworkCamera } from './types/common';
4
+ import { THttpRequestOptions, TProxyParams, TNetworkCamera } from './types/common';
5
+ import { ProxyClient } from './internal/ProxyClient';
5
6
  import { ImageType, TCoordinates, TFile, TFileList, TFileType, TStorage, TStorageDataList, TWidget } from './types/CamOverlayAPI/CamOverlayAPI';
6
7
  import { TField } from './types/CamOverlayAPI';
7
8
  export declare const allowedWidgetNames: {
@@ -21,6 +22,7 @@ export declare class CamOverlayAPI<Client extends IClient<TResponse> = IClient<T
21
22
  static getBasePath: () => string;
22
23
  static getProxyPath: () => string;
23
24
  static getFilePreviewPath: (path: string) => string;
25
+ getClient(proxyParams?: TProxyParams): Client | ProxyClient<Client>;
24
26
  checkCameraTime(options?: THttpRequestOptions): Promise<boolean>;
25
27
  getNetworkCameraList(options?: THttpRequestOptions): Promise<TNetworkCamera[]>;
26
28
  wsAuthorization(options?: THttpRequestOptions): Promise<string>;
@@ -48,5 +50,4 @@ export declare class CamOverlayAPI<Client extends IClient<TResponse> = IClient<T
48
50
  private parseBlobResponse;
49
51
  private _postUrlEncoded;
50
52
  private _postJsonEncoded;
51
- private getAgent;
52
53
  }