camstreamerlib 4.0.0-beta.119 → 4.0.0-beta.120

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 (75) hide show
  1. package/cjs/CamOverlayAPI.d.ts +83 -91
  2. package/cjs/CamOverlayAPI.js +10 -62
  3. package/cjs/CamScripterAPI.d.ts +4 -8
  4. package/cjs/CamScripterAPI.js +4 -29
  5. package/cjs/CamStreamerAPI.d.ts +1427 -1596
  6. package/cjs/CamStreamerAPI.js +7 -76
  7. package/cjs/CamSwitcherAPI.d.ts +18 -21
  8. package/cjs/CamSwitcherAPI.js +5 -26
  9. package/cjs/PlaneTrackerAPI.d.ts +9 -15
  10. package/cjs/PlaneTrackerAPI.js +6 -69
  11. package/cjs/internal/BasicAPI.d.ts +15 -0
  12. package/cjs/internal/BasicAPI.js +97 -0
  13. package/cjs/internal/versionCompare.d.ts +2 -2
  14. package/cjs/types/CamOverlayAPI/CamOverlayAPI.d.ts +296 -296
  15. package/cjs/types/CamOverlayAPI/accuweatherSchema.d.ts +6 -6
  16. package/cjs/types/CamOverlayAPI/customGraphicsSchema.d.ts +26 -26
  17. package/cjs/types/CamOverlayAPI/imagesSchema.d.ts +8 -8
  18. package/cjs/types/CamOverlayAPI/infotickerSchema.d.ts +6 -6
  19. package/cjs/types/CamOverlayAPI/pipSchema.d.ts +6 -6
  20. package/cjs/types/CamOverlayAPI/ptzCompassSchema.d.ts +6 -6
  21. package/cjs/types/CamOverlayAPI/ptzSchema.d.ts +11 -11
  22. package/cjs/types/CamOverlayAPI/scoreBoardSchema.d.ts +18 -18
  23. package/cjs/types/CamOverlayAPI/screenSharingSchema.d.ts +6 -6
  24. package/cjs/types/CamOverlayAPI/serviceCommonTypes.d.ts +12 -12
  25. package/cjs/types/CamOverlayAPI/webCameraSharingSchema.d.ts +6 -6
  26. package/cjs/types/CamStreamerAPI/CamStreamerAPI.d.ts +7796 -9156
  27. package/cjs/types/CamStreamerAPI/facebookSchema.d.ts +146 -174
  28. package/cjs/types/CamStreamerAPI/oldStreamSchema.d.ts +22 -22
  29. package/cjs/types/CamStreamerAPI/streamCommonTypes.d.ts +140 -168
  30. package/cjs/types/CamStreamerAPI/streamCommonTypes.js +22 -32
  31. package/cjs/types/CamStreamerAPI/streamsSchema.d.ts +2513 -3017
  32. package/cjs/types/CamStreamerAPI/windySchema.d.ts +138 -166
  33. package/cjs/types/CamStreamerAPI/youtubeSchema.d.ts +148 -176
  34. package/cjs/types/CamSwitcherAPI.d.ts +66 -66
  35. package/cjs/types/PlaneTrackerAPI.d.ts +12 -12
  36. package/cjs/types/ws/CamStreamerEvents.d.ts +8 -8
  37. package/cjs/types/ws/CamSwitcherEvents.d.ts +8 -8
  38. package/esm/CamOverlayAPI.js +11 -63
  39. package/esm/CamScripterAPI.js +4 -29
  40. package/esm/CamStreamerAPI.js +8 -77
  41. package/esm/CamSwitcherAPI.js +6 -27
  42. package/esm/PlaneTrackerAPI.js +7 -70
  43. package/esm/internal/BasicAPI.js +93 -0
  44. package/esm/types/CamStreamerAPI/streamCommonTypes.js +22 -32
  45. package/package.json +1 -1
  46. package/types/CamOverlayAPI.d.ts +83 -91
  47. package/types/CamScripterAPI.d.ts +4 -8
  48. package/types/CamStreamerAPI.d.ts +1427 -1596
  49. package/types/CamSwitcherAPI.d.ts +18 -21
  50. package/types/PlaneTrackerAPI.d.ts +9 -15
  51. package/types/internal/BasicAPI.d.ts +15 -0
  52. package/types/internal/versionCompare.d.ts +2 -2
  53. package/types/types/CamOverlayAPI/CamOverlayAPI.d.ts +296 -296
  54. package/types/types/CamOverlayAPI/accuweatherSchema.d.ts +6 -6
  55. package/types/types/CamOverlayAPI/customGraphicsSchema.d.ts +26 -26
  56. package/types/types/CamOverlayAPI/imagesSchema.d.ts +8 -8
  57. package/types/types/CamOverlayAPI/infotickerSchema.d.ts +6 -6
  58. package/types/types/CamOverlayAPI/pipSchema.d.ts +6 -6
  59. package/types/types/CamOverlayAPI/ptzCompassSchema.d.ts +6 -6
  60. package/types/types/CamOverlayAPI/ptzSchema.d.ts +11 -11
  61. package/types/types/CamOverlayAPI/scoreBoardSchema.d.ts +18 -18
  62. package/types/types/CamOverlayAPI/screenSharingSchema.d.ts +6 -6
  63. package/types/types/CamOverlayAPI/serviceCommonTypes.d.ts +12 -12
  64. package/types/types/CamOverlayAPI/webCameraSharingSchema.d.ts +6 -6
  65. package/types/types/CamStreamerAPI/CamStreamerAPI.d.ts +7796 -9156
  66. package/types/types/CamStreamerAPI/facebookSchema.d.ts +146 -174
  67. package/types/types/CamStreamerAPI/oldStreamSchema.d.ts +22 -22
  68. package/types/types/CamStreamerAPI/streamCommonTypes.d.ts +140 -168
  69. package/types/types/CamStreamerAPI/streamsSchema.d.ts +2513 -3017
  70. package/types/types/CamStreamerAPI/windySchema.d.ts +138 -166
  71. package/types/types/CamStreamerAPI/youtubeSchema.d.ts +148 -176
  72. package/types/types/CamSwitcherAPI.d.ts +66 -66
  73. package/types/types/PlaneTrackerAPI.d.ts +12 -12
  74. package/types/types/ws/CamStreamerEvents.d.ts +8 -8
  75. package/types/types/ws/CamSwitcherEvents.d.ts +8 -8
@@ -1,21 +1,13 @@
1
- import { paramToUrl } from './internal/utils';
2
- import { ParsingBlobError, ErrorWithResponse, ServiceNotFoundError, StorageDataFetchError } from './errors/errors';
1
+ import { ErrorWithResponse, ServiceNotFoundError, StorageDataFetchError } from './errors/errors';
3
2
  import { networkCameraListSchema } from './types/common';
4
3
  import { z } from 'zod';
5
- import { ProxyClient } from './internal/ProxyClient';
6
4
  import { ImageType, serviceListSchema, servicesSchema, wsResponseSchema, getStorageDataListSchema, getFileListSchema, } from './types/CamOverlayAPI';
5
+ import { BasicAPI } from './internal/BasicAPI';
7
6
  const BASE_PATH = '/local/camoverlay/api';
8
- export class CamOverlayAPI {
9
- client;
10
- constructor(client) {
11
- this.client = client;
12
- }
7
+ export class CamOverlayAPI extends BasicAPI {
13
8
  static getBasePath = () => BASE_PATH;
14
9
  static getProxyPath = () => `${BASE_PATH}/proxy.cgi`;
15
10
  static getFilePreviewPath = (path) => `${BASE_PATH}/image.cgi?path=${encodeURIComponent(path)}`;
16
- getClient(proxyParams) {
17
- return proxyParams ? new ProxyClient(this.client, proxyParams) : this.client;
18
- }
19
11
  async checkAPIAvailable(options) {
20
12
  await this._getJson(`${BASE_PATH}/api_check.cgi`, undefined, options);
21
13
  }
@@ -48,7 +40,7 @@ export class CamOverlayAPI {
48
40
  await this._postUrlEncoded(`${BASE_PATH}/upload_${fileType}.cgi`, {
49
41
  action: 'remove',
50
42
  ...fileParams,
51
- }, options, undefined);
43
+ }, options);
52
44
  }
53
45
  async getFileStorage(fileType, options) {
54
46
  const res = await this._getJson(`${BASE_PATH}/upload_${fileType}.cgi`, { action: 'get_storage' }, options);
@@ -99,15 +91,15 @@ export class CamOverlayAPI {
99
91
  return services;
100
92
  }
101
93
  async updateSingleService(service, options) {
102
- await this._postJsonEncoded(`${BASE_PATH}/services.cgi`, JSON.stringify(service), {
94
+ await this._postJsonEncoded(`${BASE_PATH}/services.cgi`, service, {
103
95
  action: 'set',
104
96
  service_id: service.id,
105
- }, options, undefined);
97
+ }, options);
106
98
  }
107
99
  async updateServices(services, options) {
108
- await this._postJsonEncoded(`${BASE_PATH}/services.cgi`, JSON.stringify({ services: services }), {
100
+ await this._postJsonEncoded(`${BASE_PATH}/services.cgi`, { services: services }, {
109
101
  action: 'set',
110
- }, options, undefined);
102
+ }, options);
111
103
  }
112
104
  updateCGText(serviceId, fields, options) {
113
105
  const params = {};
@@ -146,6 +138,9 @@ export class CamOverlayAPI {
146
138
  };
147
139
  return this.promiseCGUpdate(serviceId, 'update_image', params, contentType, imageData, options);
148
140
  }
141
+ downloadReport(options) {
142
+ return this._getText(`${BASE_PATH}/report.cgi`, undefined, options);
143
+ }
149
144
  async promiseCGUpdate(serviceId, action, params = {}, contentType, data, options) {
150
145
  const path = `${BASE_PATH}/customGraphics.cgi`;
151
146
  let headers = {};
@@ -168,51 +163,4 @@ export class CamOverlayAPI {
168
163
  throw new ErrorWithResponse(res);
169
164
  }
170
165
  }
171
- async _getJson(path, parameters, options) {
172
- const agent = this.getClient(options?.proxyParams);
173
- const res = await agent.get({ path, parameters, timeout: options?.timeout });
174
- if (res.ok) {
175
- return await res.json();
176
- }
177
- else {
178
- throw new ErrorWithResponse(res);
179
- }
180
- }
181
- async _post(path, data, parameters, options, headers) {
182
- const agent = this.getClient(options?.proxyParams);
183
- const res = await agent.post({ path, data, parameters, headers, timeout: options?.timeout });
184
- if (res.ok) {
185
- return await res.json();
186
- }
187
- else {
188
- throw new ErrorWithResponse(res);
189
- }
190
- }
191
- async _getBlob(path, parameters, options) {
192
- const agent = this.getClient(options?.proxyParams);
193
- const res = await agent.get({ path, parameters, timeout: options?.timeout });
194
- if (res.ok) {
195
- return await this.parseBlobResponse(res);
196
- }
197
- else {
198
- throw new ErrorWithResponse(res);
199
- }
200
- }
201
- async parseBlobResponse(response) {
202
- try {
203
- return (await response.blob());
204
- }
205
- catch (err) {
206
- throw new ParsingBlobError(err);
207
- }
208
- }
209
- async _postUrlEncoded(path, parameters, options, headers) {
210
- const data = paramToUrl(parameters);
211
- const baseHeaders = { 'Content-Type': 'application/x-www-form-urlencoded' };
212
- return this._post(path, data, undefined, options, { ...baseHeaders, ...headers });
213
- }
214
- async _postJsonEncoded(path, data, parameters, options, headers) {
215
- const baseHeaders = { 'Accept': 'application/json', 'Content-Type': 'application/json' };
216
- return this._post(path, data, parameters, options, { ...baseHeaders, ...headers });
217
- }
218
166
  }
@@ -1,17 +1,9 @@
1
- import { ErrorWithResponse } from './errors/errors';
2
- import { ProxyClient } from './internal/ProxyClient';
1
+ import { BasicAPI } from './internal/BasicAPI';
3
2
  import { cameraTimeResponseSchema, nodeStateSchema, packageInfoListSchema, cameraStorageSchema, } from './types/CamScripterAPI';
4
3
  import { networkCameraListSchema } from './types/common';
5
4
  const BASE_PATH = '/local/camscripter';
6
- export class CamScripterAPI {
7
- client;
8
- constructor(client) {
9
- this.client = client;
10
- }
5
+ export class CamScripterAPI extends BasicAPI {
11
6
  static getProxyPath = () => `${BASE_PATH}/proxy.cgi`;
12
- getClient(proxyParams) {
13
- return proxyParams ? new ProxyClient(this.client, proxyParams) : this.client;
14
- }
15
7
  async checkAPIAvailable(options) {
16
8
  await this._getJson(`${BASE_PATH}/api_check.cgi`, undefined, options);
17
9
  }
@@ -56,24 +48,7 @@ export class CamScripterAPI {
56
48
  async installNodejs(storage, options) {
57
49
  await this._getJson(`${BASE_PATH}/node_update.cgi`, { storage: storage }, options);
58
50
  }
59
- async _getJson(path, parameters, options) {
60
- const agent = this.getClient(options?.proxyParams);
61
- const res = await agent.get({ path, parameters, timeout: options?.timeout });
62
- if (res.ok) {
63
- return await res.json();
64
- }
65
- else {
66
- throw new ErrorWithResponse(res);
67
- }
68
- }
69
- async _post(path, data, parameters, options, headers) {
70
- const agent = this.getClient(options?.proxyParams);
71
- const res = await agent.post({ path, data, parameters, headers, timeout: options?.timeout });
72
- if (res.ok) {
73
- return await res.json();
74
- }
75
- else {
76
- throw new ErrorWithResponse(res);
77
- }
51
+ downloadReport(options) {
52
+ return this._getText(`${BASE_PATH}/report.cgi`, undefined, options);
78
53
  }
79
54
  }
@@ -1,20 +1,12 @@
1
1
  import { z } from 'zod';
2
- import { ProxyClient } from './internal/ProxyClient';
3
2
  import { audioFileListSchema, storageListSchema, streamSchema, } from './types/CamStreamerAPI/CamStreamerAPI';
4
- import { ErrorWithResponse, UtcTimeFetchError, WsAuthorizationError, MigrationError, ParsingBlobError, } from './errors/errors';
3
+ import { UtcTimeFetchError, WsAuthorizationError, MigrationError } from './errors/errors';
5
4
  import { oldStringStreamSchema, oldStringStreamSchemaWithId, } from './types/CamStreamerAPI/oldStreamSchema';
6
- import { paramToUrl } from './internal/utils';
5
+ import { BasicAPI } from './internal/BasicAPI';
7
6
  const BASE_PATH = '/local/camstreamer';
8
- export class CamStreamerAPI {
9
- client;
10
- constructor(client) {
11
- this.client = client;
12
- }
7
+ export class CamStreamerAPI extends BasicAPI {
13
8
  static getProxyPath = () => `${BASE_PATH}/proxy.cgi`;
14
9
  static getWsEventsPath = () => `${BASE_PATH}/events`;
15
- getClient(proxyParams) {
16
- return proxyParams ? new ProxyClient(this.client, proxyParams) : this.client;
17
- }
18
10
  async checkAPIAvailable(options) {
19
11
  await this._getJson(`${BASE_PATH}/api_check.cgi`, undefined, options);
20
12
  }
@@ -77,7 +69,7 @@ export class CamStreamerAPI {
77
69
  return newStreamData;
78
70
  }
79
71
  async setStreamList(streamList, options) {
80
- await this._postJsonEncoded(`${BASE_PATH}/stream_list.cgi`, JSON.stringify({ streamList }), {
72
+ await this._postJsonEncoded(`${BASE_PATH}/stream_list.cgi`, { streamList }, {
81
73
  action: 'set',
82
74
  }, options);
83
75
  }
@@ -91,7 +83,7 @@ export class CamStreamerAPI {
91
83
  throw new MigrationError([], [{ streamId, ...parseCameraStreamResponse(oldStream) }]);
92
84
  }
93
85
  async setStream(streamId, streamData, options) {
94
- await this._postJsonEncoded(`${BASE_PATH}/stream_list.cgi`, JSON.stringify(streamData), {
86
+ await this._postJsonEncoded(`${BASE_PATH}/stream_list.cgi`, streamData, {
95
87
  action: 'set',
96
88
  stream_id: streamId,
97
89
  }, options);
@@ -117,7 +109,7 @@ export class CamStreamerAPI {
117
109
  }, options);
118
110
  }
119
111
  async removeFile(fileParams, options) {
120
- await this._postUrlEncoded(`${BASE_PATH}/upload_audio.cgi`, { action: 'remove', ...fileParams }, options, undefined);
112
+ await this._postUrlEncoded(`${BASE_PATH}/upload_audio.cgi`, { action: 'remove', ...fileParams }, options);
121
113
  }
122
114
  async getFileStorage(options) {
123
115
  const res = await this._getJson(`${BASE_PATH}/upload_audio.cgi`, { action: 'get_storage' }, options);
@@ -126,69 +118,8 @@ export class CamStreamerAPI {
126
118
  async getFileFromCamera(path, options) {
127
119
  return await this._getBlob(`${BASE_PATH}/audio.cgi`, { path }, options);
128
120
  }
129
- async _getJson(path, parameters, options) {
130
- const agent = this.getClient(options?.proxyParams);
131
- const res = await agent.get({ path, parameters, timeout: options?.timeout });
132
- if (res.ok) {
133
- return await res.json();
134
- }
135
- else {
136
- throw new ErrorWithResponse(res);
137
- }
138
- }
139
- async _getText(path, parameters, options) {
140
- const agent = this.getClient(options?.proxyParams);
141
- const res = await agent.get({ path, parameters, timeout: options?.timeout });
142
- if (res.ok) {
143
- return await res.text();
144
- }
145
- else {
146
- throw new ErrorWithResponse(res);
147
- }
148
- }
149
- async _getBlob(path, parameters, options) {
150
- const agent = this.getClient(options?.proxyParams);
151
- const res = await agent.get({ path, parameters, timeout: options?.timeout });
152
- if (res.ok) {
153
- return await this.parseBlobResponse(res);
154
- }
155
- else {
156
- throw new ErrorWithResponse(res);
157
- }
158
- }
159
- async parseBlobResponse(response) {
160
- try {
161
- return (await response.blob());
162
- }
163
- catch (err) {
164
- throw new ParsingBlobError(err);
165
- }
166
- }
167
- async _postUrlEncoded(path, parameters, options, headers) {
168
- const data = paramToUrl(parameters);
169
- const baseHeaders = { 'Content-Type': 'application/x-www-form-urlencoded' };
170
- return this._post(path, data, undefined, options, { ...baseHeaders, ...headers });
171
- }
172
- async _postJsonEncoded(path, data, parameters, options, headers) {
173
- const agent = this.getClient(options?.proxyParams);
174
- const baseHeaders = { 'Accept': 'application/json', 'Content-Type': 'application/json' };
175
- return agent.post({
176
- path,
177
- data,
178
- parameters,
179
- timeout: options?.timeout,
180
- headers: { ...baseHeaders, ...headers },
181
- });
182
- }
183
- async _post(path, data, parameters, options, headers) {
184
- const agent = this.getClient(options?.proxyParams);
185
- const res = await agent.post({ path, data, parameters, headers, timeout: options?.timeout });
186
- if (res.ok) {
187
- return await res.json();
188
- }
189
- else {
190
- throw new ErrorWithResponse(res);
191
- }
121
+ downloadReport(options) {
122
+ return this._getText(`${BASE_PATH}/report.cgi`, undefined, options);
192
123
  }
193
124
  }
194
125
  export const parseCameraStreamResponse = (cameraStreamData) => {
@@ -1,27 +1,23 @@
1
1
  import { z } from 'zod';
2
- import { AddNewClipError, JsonParseError, ParameterNotFoundError, ErrorWithResponse } from './errors/errors';
2
+ import { AddNewClipError, JsonParseError, ParameterNotFoundError } from './errors/errors';
3
3
  import { parseBitrateOptionsToVapixParams, parseVapixParamsToBitrateOptions } from './internal/convertors';
4
4
  import { isClip, isNullish } from './internal/utils';
5
5
  import { storageInfoListSchema, outputInfoSchema, audioPushInfoSchema, clipListSchema, playlistQueueSchema, streamSaveLoadSchema, clipSaveLoadSchema, playlistSaveLoadSchema, trackerSaveLoadSchema, secondaryAudioSettingsSchema, globalAudioSettingsSchema, } from './types/CamSwitcherAPI';
6
6
  import { networkCameraListSchema, } from './types/common';
7
7
  import { VapixAPI } from './VapixAPI';
8
- import { ProxyClient } from './internal/ProxyClient';
8
+ import { BasicAPI } from './internal/BasicAPI';
9
9
  const BASE_PATH = '/local/camswitcher/api';
10
- export class CamSwitcherAPI {
11
- client;
10
+ export class CamSwitcherAPI extends BasicAPI {
12
11
  CustomFormData;
13
12
  vapixAgent;
14
13
  constructor(client, CustomFormData = FormData) {
15
- this.client = client;
14
+ super(client);
16
15
  this.CustomFormData = CustomFormData;
17
16
  this.vapixAgent = new VapixAPI(client);
18
17
  }
19
18
  static getProxyPath = () => `${BASE_PATH}/proxy.cgi`;
20
19
  static getWsEventsPath = () => `/local/camswitcher/events`;
21
20
  static getClipPreviewPath = (clipId, storage) => `${BASE_PATH}/clip_preview.cgi?clip_name=${clipId}&storage=${storage}`;
22
- getClient(proxyParams) {
23
- return proxyParams ? new ProxyClient(this.client, proxyParams) : this.client;
24
- }
25
21
  async checkAPIAvailable(options) {
26
22
  await this._getJson(`${BASE_PATH}/api_check.cgi`, undefined, options);
27
23
  }
@@ -261,25 +257,8 @@ export class CamSwitcherAPI {
261
257
  const res = await this.vapixAgent.getParameter([paramName], options);
262
258
  return z.string().parse(res[paramName] ?? '');
263
259
  }
264
- async _getJson(path, parameters, options) {
265
- const agent = this.getClient(options?.proxyParams);
266
- const res = await agent.get({ path, parameters, timeout: options?.timeout });
267
- if (res.ok) {
268
- return await res.json();
269
- }
270
- else {
271
- throw new ErrorWithResponse(res);
272
- }
273
- }
274
- async _post(path, data, parameters, options, headers) {
275
- const agent = this.getClient(options?.proxyParams);
276
- const res = await agent.post({ path, data, parameters, timeout: options?.timeout, headers });
277
- if (res.ok) {
278
- return await res.json();
279
- }
280
- else {
281
- throw new ErrorWithResponse(res);
282
- }
260
+ downloadReport(options) {
261
+ return this._getText(`${BASE_PATH}/report.cgi`, undefined, options);
283
262
  }
284
263
  setParamFromCameraJSON(paramName, data, options) {
285
264
  const params = {};
@@ -1,22 +1,17 @@
1
1
  import { z } from 'zod';
2
- import { paramToUrl } from './internal/utils';
3
2
  import { blackListSchema, cameraSettingsSchema, flightInfoSchema, getIcaoSchema, mapInfoSchema, priorityListSchema, serverSettingsSchema, trackingModeSchema, typePriorityListSchema, whiteListSchema, wsAliasResponseSchema, zonesSchema, } from './types/PlaneTrackerAPI';
4
- import { CannotSetCoordsInAutoModeError, ImportSettingsError, InvalidAltitudeError, InvalidLatLngError, ParsingBlobError, ResetCalibrationError, ServerError, BadRequestError, ErrorWithResponse, } from './errors/errors';
5
- import { ProxyClient } from './internal/ProxyClient';
3
+ import { CannotSetCoordsInAutoModeError, ImportSettingsError, InvalidAltitudeError, InvalidLatLngError, ResetCalibrationError, ServerError, BadRequestError, } from './errors/errors';
6
4
  import { cameraListSchema } from './types/GenetecAgent';
5
+ import { BasicAPI } from './internal/BasicAPI';
7
6
  const BASE_PATH = '/local/planetracker';
8
- export class PlaneTrackerAPI {
9
- client;
7
+ export class PlaneTrackerAPI extends BasicAPI {
10
8
  apiUser;
11
9
  constructor(client, apiUser) {
12
- this.client = client;
10
+ super(client);
13
11
  this.apiUser = apiUser;
14
12
  }
15
13
  static getProxyPath = () => `${BASE_PATH}/proxy.cgi`;
16
14
  static getWsEventsPath = () => `${BASE_PATH}/package/ws`;
17
- getClient(proxyParams) {
18
- return proxyParams ? new ProxyClient(this.client, proxyParams) : this.client;
19
- }
20
15
  async checkAPIAvailable(options) {
21
16
  await this._getJson(`${BASE_PATH}/api_check.cgi`, undefined, options);
22
17
  }
@@ -182,6 +177,9 @@ export class PlaneTrackerAPI {
182
177
  }
183
178
  }
184
179
  }
180
+ downloadReport(options) {
181
+ return this._getText(`${BASE_PATH}/report.cgi`, undefined, options);
182
+ }
185
183
  async checkGenetecConnection(params, options) {
186
184
  return await this._postUrlEncoded(`${BASE_PATH}/package/checkGenetecConnection.cgi`, params, options);
187
185
  }
@@ -189,65 +187,4 @@ export class PlaneTrackerAPI {
189
187
  const res = await this._postUrlEncoded(`${BASE_PATH}/package/getGenetecCameraList.cgi`, params, options);
190
188
  return cameraListSchema.parse(await res.json());
191
189
  }
192
- async _getJson(path, parameters, options, headers) {
193
- const agent = this.getClient(options?.proxyParams);
194
- const res = await agent.get({ path, parameters, timeout: options?.timeout, headers });
195
- if (res.ok) {
196
- return await res.json();
197
- }
198
- else {
199
- throw new ErrorWithResponse(res);
200
- }
201
- }
202
- async _getBlob(path, parameters, options) {
203
- const agent = this.getClient(options?.proxyParams);
204
- const res = await agent.get({ path, parameters, timeout: options?.timeout });
205
- if (res.ok) {
206
- return await this.parseBlobResponse(res);
207
- }
208
- else {
209
- throw new ErrorWithResponse(res);
210
- }
211
- }
212
- async parseBlobResponse(response) {
213
- try {
214
- return (await response.blob());
215
- }
216
- catch (err) {
217
- throw new ParsingBlobError(err);
218
- }
219
- }
220
- async _postJsonEncoded(path, data, parameters, options) {
221
- const agent = this.getClient(options?.proxyParams);
222
- const jsonData = JSON.stringify(data);
223
- const res = await agent.post({
224
- path,
225
- data: jsonData,
226
- parameters,
227
- headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' },
228
- timeout: options?.timeout,
229
- });
230
- if (res.ok) {
231
- return res;
232
- }
233
- else {
234
- throw new ErrorWithResponse(res);
235
- }
236
- }
237
- async _postUrlEncoded(path, params, options) {
238
- const data = paramToUrl(params);
239
- const agent = this.getClient(options?.proxyParams);
240
- const res = await agent.post({
241
- path,
242
- data,
243
- headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
244
- timeout: options?.timeout,
245
- });
246
- if (res.ok) {
247
- return res;
248
- }
249
- else {
250
- throw new ErrorWithResponse(res);
251
- }
252
- }
253
190
  }
@@ -0,0 +1,93 @@
1
+ import { ErrorWithResponse, ParsingBlobError } from '../errors/errors';
2
+ import { ProxyClient } from './ProxyClient';
3
+ import { paramToUrl } from './utils';
4
+ export class BasicAPI {
5
+ client;
6
+ constructor(client) {
7
+ this.client = client;
8
+ }
9
+ getClient(proxyParams) {
10
+ return proxyParams ? new ProxyClient(this.client, proxyParams) : this.client;
11
+ }
12
+ async _getJson(path, parameters, options) {
13
+ const agent = this.getClient(options?.proxyParams);
14
+ const res = await agent.get({ path, parameters, timeout: options?.timeout });
15
+ if (res.ok) {
16
+ return await res.json();
17
+ }
18
+ else {
19
+ throw new ErrorWithResponse(res);
20
+ }
21
+ }
22
+ async _getText(path, parameters, options) {
23
+ const agent = this.getClient(options?.proxyParams);
24
+ const res = await agent.get({ path, parameters, timeout: options?.timeout });
25
+ if (res.ok) {
26
+ return await res.text();
27
+ }
28
+ else {
29
+ throw new ErrorWithResponse(res);
30
+ }
31
+ }
32
+ async _getBlob(path, parameters, options) {
33
+ const agent = this.getClient(options?.proxyParams);
34
+ const res = await agent.get({ path, parameters, timeout: options?.timeout });
35
+ if (res.ok) {
36
+ return await this.parseBlobResponse(res);
37
+ }
38
+ else {
39
+ throw new ErrorWithResponse(res);
40
+ }
41
+ }
42
+ async parseBlobResponse(response) {
43
+ try {
44
+ return (await response.blob());
45
+ }
46
+ catch (err) {
47
+ throw new ParsingBlobError(err);
48
+ }
49
+ }
50
+ async _post(path, data, parameters, options, headers) {
51
+ const agent = this.getClient(options?.proxyParams);
52
+ const res = await agent.post({ path, data, parameters, headers, timeout: options?.timeout });
53
+ if (res.ok) {
54
+ return await res.json();
55
+ }
56
+ else {
57
+ throw new ErrorWithResponse(res);
58
+ }
59
+ }
60
+ async _postJsonEncoded(path, data, parameters, options) {
61
+ const agent = this.getClient(options?.proxyParams);
62
+ const jsonData = JSON.stringify(data);
63
+ const res = await agent.post({
64
+ path,
65
+ data: jsonData,
66
+ parameters,
67
+ headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' },
68
+ timeout: options?.timeout,
69
+ });
70
+ if (res.ok) {
71
+ return res;
72
+ }
73
+ else {
74
+ throw new ErrorWithResponse(res);
75
+ }
76
+ }
77
+ async _postUrlEncoded(path, data, options) {
78
+ const encodedData = paramToUrl(data);
79
+ const agent = this.getClient(options?.proxyParams);
80
+ const res = await agent.post({
81
+ path,
82
+ data: encodedData,
83
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
84
+ timeout: options?.timeout,
85
+ });
86
+ if (res.ok) {
87
+ return res;
88
+ }
89
+ else {
90
+ throw new ErrorWithResponse(res);
91
+ }
92
+ }
93
+ }
@@ -8,12 +8,13 @@ export const streamCommonSchema = z.object({
8
8
  trigger: z.discriminatedUnion('type', [
9
9
  z.object({
10
10
  type: z.literal('manual'),
11
- ioPort: z.number().nullable(),
11
+ port: z.number().optional(),
12
12
  }),
13
13
  z.object({
14
14
  type: z.literal('onetime'),
15
15
  startTime: z.number(),
16
16
  stopTime: z.number(),
17
+ prepareAheadS: z.number().int().optional(),
17
18
  }),
18
19
  z.object({
19
20
  type: z.literal('recurrent'),
@@ -28,22 +29,15 @@ export const streamCommonSchema = z.object({
28
29
  }),
29
30
  isActive: z.boolean(),
30
31
  })),
32
+ prepareAheadS: z.number().int().optional(),
31
33
  }),
32
34
  ]),
33
35
  video: z.object({
34
- output: z.discriminatedUnion('callApi', [
35
- z.object({
36
- type: z.union([z.literal('video'), z.literal('images')]),
37
- callApi: z.literal(false),
38
- url: z.string(),
39
- }),
40
- z.object({
41
- type: z.literal('video'),
42
- callApi: z.literal(true),
43
- prepareAheadS: z.number(),
44
- }),
45
- ]),
46
- outputParameters: z.string(),
36
+ output: z.object({
37
+ type: z.union([z.literal('video'), z.literal('images')]),
38
+ url: z.string().nullable(),
39
+ parameters: z.string(),
40
+ }),
47
41
  input: z.discriminatedUnion('type', [
48
42
  z.object({
49
43
  type: z.literal('RTSP_URL'),
@@ -54,20 +48,17 @@ export const streamCommonSchema = z.object({
54
48
  }),
55
49
  z.object({
56
50
  type: z.literal('CRS'),
51
+ streamingProtocol: z.union([z.literal('RTMP'), z.literal('RTMPS'), z.literal('HLS_PUSH')]),
52
+ internalVapixParameters: z.string(),
53
+ userVapixParameters: z.string(),
57
54
  }),
58
55
  ]),
59
- streamingProtocol: z.union([z.literal('RTMP'), z.literal('RTMPS'), z.literal('HLS_PUSH')]),
60
- internalVapixParameters: z.string(),
61
- userVapixParameters: z.string(),
62
- streamDelay: z
63
- .object({
64
- value: z.number().int(),
65
- unit: z.union([z.literal('seconds'), z.literal('minutes'), z.literal('hours')]),
66
- })
67
- .optional(),
56
+ delayS: z.number().int().nonnegative().optional(),
68
57
  }),
69
- audio: z
70
- .discriminatedUnion('source', [
58
+ audio: z.discriminatedUnion('source', [
59
+ z.object({
60
+ source: z.literal('none'),
61
+ }),
71
62
  z.object({
72
63
  source: z.literal('microphone'),
73
64
  audioChannelNbr: z.union([z.literal(1), z.literal(2)]),
@@ -75,22 +66,21 @@ export const streamCommonSchema = z.object({
75
66
  }),
76
67
  z.object({
77
68
  source: z.literal('file'),
78
- fileName: z.string(),
79
- filePath: z.string(),
69
+ name: z.string(),
70
+ path: z.string(),
80
71
  forceStereo: z.boolean(),
81
72
  }),
82
73
  z.object({
83
74
  source: z.literal('url'),
84
- fileName: z.string(),
85
- fileUrl: z.string(),
75
+ name: z.string(),
76
+ url: z.string(),
86
77
  avSyncMsec: z.number().int().nonnegative(),
87
78
  forceStereo: z.boolean(),
88
79
  }),
89
- ])
90
- .nullable(),
80
+ ]),
91
81
  status: z.object({
92
82
  led: z.boolean(),
93
- port: z.number().nullable(),
83
+ port: z.number().optional(),
94
84
  }),
95
85
  });
96
86
  export const internalVapixParametersSchema = bitrateVapixParamsSchema.extend({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "camstreamerlib",
3
- "version": "4.0.0-beta.119",
3
+ "version": "4.0.0-beta.120",
4
4
  "description": "Helper library for CamStreamer ACAP applications.",
5
5
  "prettier": "@camstreamer/prettier-config",
6
6
  "engine": {