camstreamerlib 4.0.0-beta.17 → 4.0.0-beta.19

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.
@@ -1,10 +1,17 @@
1
1
  import { IClient, TBlobResponse, TParameters, TResponse } from './internal/types';
2
2
  import { TExportDataType, TImportDataType } from './types/PlaneTrackerAPI';
3
+ export type TApiUser = {
4
+ userId: string;
5
+ userName: string;
6
+ userPriority: number;
7
+ };
3
8
  type ICAO = string;
4
9
  export declare const BASE_URL = "/local/planetracker";
5
10
  export declare class PlaneTrackerAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
6
11
  private client;
7
- constructor(client: Client);
12
+ private apiUser;
13
+ private _apiUserQuery;
14
+ constructor(client: Client, apiUser: TApiUser);
8
15
  static getProxyUrlPath: () => string;
9
16
  checkCameraTime(): Promise<boolean>;
10
17
  fetchCameraSettings: () => Promise<any>;
@@ -7,8 +7,12 @@ const errors_1 = require("./errors/errors");
7
7
  exports.BASE_URL = '/local/planetracker';
8
8
  class PlaneTrackerAPI {
9
9
  client;
10
- constructor(client) {
10
+ apiUser;
11
+ _apiUserQuery;
12
+ constructor(client, apiUser) {
11
13
  this.client = client;
14
+ this.apiUser = apiUser;
15
+ this._apiUserQuery = (0, utils_1.paramToUrl)(this.apiUser);
12
16
  }
13
17
  static getProxyUrlPath = () => `${exports.BASE_URL}/proxy.cgi`;
14
18
  async checkCameraTime() {
@@ -50,46 +54,51 @@ class PlaneTrackerAPI {
50
54
  return await this._getJson(`${exports.BASE_URL}/package/getMapInfo.cgi`);
51
55
  };
52
56
  fetchFlightInfo = async (icao) => {
53
- return await this._getJson(`${exports.BASE_URL}/package/flightInfo.cgi`, { icao });
57
+ return await this._getJson(`${exports.BASE_URL}/package/flightInfo.cgi`, { icao: encodeURIComponent(icao) });
54
58
  };
55
59
  getZones = async () => {
56
60
  return await this._getJson(`${exports.BASE_URL}/package/getZones.cgi`);
57
61
  };
58
62
  setZones = async (zonesJsonString) => {
59
- return await this._postJsonEncoded(`${exports.BASE_URL}/package/setZones.cgi`, zonesJsonString);
63
+ return await this._postJsonEncoded(`${exports.BASE_URL}/package/setZones.cgi?${this._apiUserQuery}`, zonesJsonString);
60
64
  };
61
65
  getPriorityList = async () => {
62
66
  return await this._getJson(`${exports.BASE_URL}/package/getPriorityList.cgi`);
63
67
  };
64
68
  setPriorityList = async (priorityListJsonString) => {
65
- return await this._postJsonEncoded(`${exports.BASE_URL}/package/setPriorityList.cgi`, priorityListJsonString);
69
+ return await this._postJsonEncoded(`${exports.BASE_URL}/package/setPriorityList.cgi?${this._apiUserQuery}`, priorityListJsonString);
66
70
  };
67
71
  getWhiteList = async () => {
68
72
  return await this._getJson(`${exports.BASE_URL}/package/getWhiteList.cgi`);
69
73
  };
70
74
  setWhiteList = async (whiteListJsonString) => {
71
- return await this._postJsonEncoded(`${exports.BASE_URL}/package/setWhiteList.cgi`, whiteListJsonString);
75
+ return await this._postJsonEncoded(`${exports.BASE_URL}/package/setWhiteList.cgi?${this._apiUserQuery}`, whiteListJsonString);
72
76
  };
73
77
  getBlackList = async () => {
74
78
  return await this._getJson(`${exports.BASE_URL}/package/getBlackList.cgi`);
75
79
  };
76
80
  setBlackList = async (blackListJsonString) => {
77
- return await this._postJsonEncoded(`${exports.BASE_URL}/package/setBlackList.cgi`, blackListJsonString);
81
+ return await this._postJsonEncoded(`${exports.BASE_URL}/package/setBlackList.cgi?${this._apiUserQuery}`, blackListJsonString);
78
82
  };
79
83
  getTrackingMode = async () => {
80
84
  return await this._getJson(`${exports.BASE_URL}/package/getTrackingMode.cgi`);
81
85
  };
82
86
  setTrackingMode = async (modeJsonString) => {
83
- return await this._postJsonEncoded(`${exports.BASE_URL}/package/setTrackingMode.cgi`, modeJsonString);
87
+ return await this._postJsonEncoded(`${exports.BASE_URL}/package/setTrackingMode.cgi?${this._apiUserQuery}`, modeJsonString);
84
88
  };
85
89
  startTrackingPlane = async (icao) => {
86
- return await this.client.get(`${exports.BASE_URL}/package/trackIcao.cgi`, { icao });
90
+ return await this.client.get(`${exports.BASE_URL}/package/trackIcao.cgi`, {
91
+ icao: encodeURIComponent(icao),
92
+ userId: encodeURIComponent(this.apiUser.userId),
93
+ userName: encodeURIComponent(this.apiUser.userName),
94
+ userPriority: this.apiUser.userPriority,
95
+ });
87
96
  };
88
97
  stopTrackingPlane = async () => {
89
- return await this.client.get(`${exports.BASE_URL}/package/resetIcao.cgi`);
98
+ return await this.client.get(`${exports.BASE_URL}/package/resetIcao.cgi?${this._apiUserQuery}`);
90
99
  };
91
100
  goToCoordinates = async (lat, lon, alt) => {
92
- const url = `${exports.BASE_URL}/package/goToCoordinates.cgi?lat=${lat}&lon=${lon}`;
101
+ const url = `${exports.BASE_URL}/package/goToCoordinates.cgi?lat=${lat}&lon=${lon}&${this._apiUserQuery}`;
93
102
  return await this.client.get(`${url}${alt !== undefined ? `&alt=${alt}` : ''}`);
94
103
  };
95
104
  exportAppSettings = async (dataType) => {
@@ -99,7 +108,11 @@ class PlaneTrackerAPI {
99
108
  return await this.client.post(`${exports.BASE_URL}/package_data.cgi`, formData, { action: 'IMPORT', dataType });
100
109
  };
101
110
  resetPtzCalibration = async () => {
102
- return await this.client.get(`${exports.BASE_URL}/package/resetPtzCalibration.cgi`);
111
+ return await this.client.get(`${exports.BASE_URL}/package/resetPtzCalibration.cgi`, {
112
+ userId: encodeURIComponent(this.apiUser.userId),
113
+ userName: encodeURIComponent(this.apiUser.userName),
114
+ userPriority: this.apiUser.userPriority,
115
+ });
103
116
  };
104
117
  checkGenetecConnection = async (params) => {
105
118
  return await this._postUrlEncoded(`${exports.BASE_URL}/package/checkGenetecConnection.cgi`, params);
@@ -148,14 +148,15 @@ export declare const cameraDetailsResponseSchema: z.ZodObject<{
148
148
  export type TCameraDetailsResponse = z.infer<typeof cameraDetailsResponseSchema>;
149
149
  export type TCameraDetail = z.infer<typeof cameraDetailSchema>;
150
150
  export type TParams = Array<'Guid' | 'Name' | 'EntityType'>;
151
+ export type TProtocol = 'http' | 'https' | 'https_insecure';
151
152
  export type GenetecAgentOptions = {
152
- protocol?: 'http' | 'https' | 'https_insecure';
153
+ protocol?: TProtocol;
153
154
  ip?: string;
154
155
  port?: number;
155
- base_uri?: string;
156
+ baseUri?: string;
156
157
  user?: string;
157
158
  pass?: string;
158
- app_id?: string;
159
+ appId?: string;
159
160
  };
160
161
  export declare class GenetecAgent {
161
162
  private settings;
@@ -37,13 +37,13 @@ class GenetecAgent {
37
37
  protocol: options.protocol ?? 'http',
38
38
  ip: options.ip ?? '127.0.0.1',
39
39
  port: options.port ?? 80,
40
- base_uri: options.base_uri ?? 'WebSdk',
40
+ baseUri: options.baseUri ?? 'WebSdk',
41
41
  user: options.user ?? 'root',
42
42
  pass: options.pass ?? '',
43
- app_id: options.app_id ?? '',
43
+ appId: options.appId ?? '',
44
44
  };
45
- this.baseUrl = `${this.settings.protocol}://${this.settings.ip}:${this.settings.port}/${this.settings.base_uri}`;
46
- this.credentials = btoa(`${this.settings.user};${this.settings.app_id}:${this.settings.pass}`);
45
+ this.baseUrl = `${this.settings.protocol}://${this.settings.ip}:${this.settings.port}/${this.settings.baseUri}`;
46
+ this.credentials = btoa(`${this.settings.user};${this.settings.appId}:${this.settings.pass}`);
47
47
  }
48
48
  async checkConnection() {
49
49
  const requestOptions = this.getRequestOptions('GET');
@@ -1,10 +1,17 @@
1
1
  import { IClient, TBlobResponse, TParameters, TResponse } from './internal/types';
2
2
  import { TExportDataType, TImportDataType } from './types/PlaneTrackerAPI';
3
+ export type TApiUser = {
4
+ userId: string;
5
+ userName: string;
6
+ userPriority: number;
7
+ };
3
8
  type ICAO = string;
4
9
  export declare const BASE_URL = "/local/planetracker";
5
10
  export declare class PlaneTrackerAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
6
11
  private client;
7
- constructor(client: Client);
12
+ private apiUser;
13
+ private _apiUserQuery;
14
+ constructor(client: Client, apiUser: TApiUser);
8
15
  static getProxyUrlPath: () => string;
9
16
  checkCameraTime(): Promise<boolean>;
10
17
  fetchCameraSettings: () => Promise<any>;
@@ -4,8 +4,12 @@ import { ParsingBlobError } from './errors/errors';
4
4
  export const BASE_URL = '/local/planetracker';
5
5
  export class PlaneTrackerAPI {
6
6
  client;
7
- constructor(client) {
7
+ apiUser;
8
+ _apiUserQuery;
9
+ constructor(client, apiUser) {
8
10
  this.client = client;
11
+ this.apiUser = apiUser;
12
+ this._apiUserQuery = paramToUrl(this.apiUser);
9
13
  }
10
14
  static getProxyUrlPath = () => `${BASE_URL}/proxy.cgi`;
11
15
  async checkCameraTime() {
@@ -47,46 +51,51 @@ export class PlaneTrackerAPI {
47
51
  return await this._getJson(`${BASE_URL}/package/getMapInfo.cgi`);
48
52
  };
49
53
  fetchFlightInfo = async (icao) => {
50
- return await this._getJson(`${BASE_URL}/package/flightInfo.cgi`, { icao });
54
+ return await this._getJson(`${BASE_URL}/package/flightInfo.cgi`, { icao: encodeURIComponent(icao) });
51
55
  };
52
56
  getZones = async () => {
53
57
  return await this._getJson(`${BASE_URL}/package/getZones.cgi`);
54
58
  };
55
59
  setZones = async (zonesJsonString) => {
56
- return await this._postJsonEncoded(`${BASE_URL}/package/setZones.cgi`, zonesJsonString);
60
+ return await this._postJsonEncoded(`${BASE_URL}/package/setZones.cgi?${this._apiUserQuery}`, zonesJsonString);
57
61
  };
58
62
  getPriorityList = async () => {
59
63
  return await this._getJson(`${BASE_URL}/package/getPriorityList.cgi`);
60
64
  };
61
65
  setPriorityList = async (priorityListJsonString) => {
62
- return await this._postJsonEncoded(`${BASE_URL}/package/setPriorityList.cgi`, priorityListJsonString);
66
+ return await this._postJsonEncoded(`${BASE_URL}/package/setPriorityList.cgi?${this._apiUserQuery}`, priorityListJsonString);
63
67
  };
64
68
  getWhiteList = async () => {
65
69
  return await this._getJson(`${BASE_URL}/package/getWhiteList.cgi`);
66
70
  };
67
71
  setWhiteList = async (whiteListJsonString) => {
68
- return await this._postJsonEncoded(`${BASE_URL}/package/setWhiteList.cgi`, whiteListJsonString);
72
+ return await this._postJsonEncoded(`${BASE_URL}/package/setWhiteList.cgi?${this._apiUserQuery}`, whiteListJsonString);
69
73
  };
70
74
  getBlackList = async () => {
71
75
  return await this._getJson(`${BASE_URL}/package/getBlackList.cgi`);
72
76
  };
73
77
  setBlackList = async (blackListJsonString) => {
74
- return await this._postJsonEncoded(`${BASE_URL}/package/setBlackList.cgi`, blackListJsonString);
78
+ return await this._postJsonEncoded(`${BASE_URL}/package/setBlackList.cgi?${this._apiUserQuery}`, blackListJsonString);
75
79
  };
76
80
  getTrackingMode = async () => {
77
81
  return await this._getJson(`${BASE_URL}/package/getTrackingMode.cgi`);
78
82
  };
79
83
  setTrackingMode = async (modeJsonString) => {
80
- return await this._postJsonEncoded(`${BASE_URL}/package/setTrackingMode.cgi`, modeJsonString);
84
+ return await this._postJsonEncoded(`${BASE_URL}/package/setTrackingMode.cgi?${this._apiUserQuery}`, modeJsonString);
81
85
  };
82
86
  startTrackingPlane = async (icao) => {
83
- return await this.client.get(`${BASE_URL}/package/trackIcao.cgi`, { icao });
87
+ return await this.client.get(`${BASE_URL}/package/trackIcao.cgi`, {
88
+ icao: encodeURIComponent(icao),
89
+ userId: encodeURIComponent(this.apiUser.userId),
90
+ userName: encodeURIComponent(this.apiUser.userName),
91
+ userPriority: this.apiUser.userPriority,
92
+ });
84
93
  };
85
94
  stopTrackingPlane = async () => {
86
- return await this.client.get(`${BASE_URL}/package/resetIcao.cgi`);
95
+ return await this.client.get(`${BASE_URL}/package/resetIcao.cgi?${this._apiUserQuery}`);
87
96
  };
88
97
  goToCoordinates = async (lat, lon, alt) => {
89
- const url = `${BASE_URL}/package/goToCoordinates.cgi?lat=${lat}&lon=${lon}`;
98
+ const url = `${BASE_URL}/package/goToCoordinates.cgi?lat=${lat}&lon=${lon}&${this._apiUserQuery}`;
90
99
  return await this.client.get(`${url}${alt !== undefined ? `&alt=${alt}` : ''}`);
91
100
  };
92
101
  exportAppSettings = async (dataType) => {
@@ -96,7 +105,11 @@ export class PlaneTrackerAPI {
96
105
  return await this.client.post(`${BASE_URL}/package_data.cgi`, formData, { action: 'IMPORT', dataType });
97
106
  };
98
107
  resetPtzCalibration = async () => {
99
- return await this.client.get(`${BASE_URL}/package/resetPtzCalibration.cgi`);
108
+ return await this.client.get(`${BASE_URL}/package/resetPtzCalibration.cgi`, {
109
+ userId: encodeURIComponent(this.apiUser.userId),
110
+ userName: encodeURIComponent(this.apiUser.userName),
111
+ userPriority: this.apiUser.userPriority,
112
+ });
100
113
  };
101
114
  checkGenetecConnection = async (params) => {
102
115
  return await this._postUrlEncoded(`${BASE_URL}/package/checkGenetecConnection.cgi`, params);
@@ -148,14 +148,15 @@ export declare const cameraDetailsResponseSchema: z.ZodObject<{
148
148
  export type TCameraDetailsResponse = z.infer<typeof cameraDetailsResponseSchema>;
149
149
  export type TCameraDetail = z.infer<typeof cameraDetailSchema>;
150
150
  export type TParams = Array<'Guid' | 'Name' | 'EntityType'>;
151
+ export type TProtocol = 'http' | 'https' | 'https_insecure';
151
152
  export type GenetecAgentOptions = {
152
- protocol?: 'http' | 'https' | 'https_insecure';
153
+ protocol?: TProtocol;
153
154
  ip?: string;
154
155
  port?: number;
155
- base_uri?: string;
156
+ baseUri?: string;
156
157
  user?: string;
157
158
  pass?: string;
158
- app_id?: string;
159
+ appId?: string;
159
160
  };
160
161
  export declare class GenetecAgent {
161
162
  private settings;
@@ -34,13 +34,13 @@ export class GenetecAgent {
34
34
  protocol: options.protocol ?? 'http',
35
35
  ip: options.ip ?? '127.0.0.1',
36
36
  port: options.port ?? 80,
37
- base_uri: options.base_uri ?? 'WebSdk',
37
+ baseUri: options.baseUri ?? 'WebSdk',
38
38
  user: options.user ?? 'root',
39
39
  pass: options.pass ?? '',
40
- app_id: options.app_id ?? '',
40
+ appId: options.appId ?? '',
41
41
  };
42
- this.baseUrl = `${this.settings.protocol}://${this.settings.ip}:${this.settings.port}/${this.settings.base_uri}`;
43
- this.credentials = btoa(`${this.settings.user};${this.settings.app_id}:${this.settings.pass}`);
42
+ this.baseUrl = `${this.settings.protocol}://${this.settings.ip}:${this.settings.port}/${this.settings.baseUri}`;
43
+ this.credentials = btoa(`${this.settings.user};${this.settings.appId}:${this.settings.pass}`);
44
44
  }
45
45
  async checkConnection() {
46
46
  const requestOptions = this.getRequestOptions('GET');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "camstreamerlib",
3
- "version": "4.0.0-beta.17",
3
+ "version": "4.0.0-beta.19",
4
4
  "description": "Helper library for CamStreamer ACAP applications.",
5
5
  "prettier": "@camstreamer/prettier-config",
6
6
  "dependencies": {