camstreamerlib 4.0.0-beta.41 → 4.0.0-beta.42
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.
- package/cjs/PlaneTrackerAPI.js +11 -9
- package/esm/PlaneTrackerAPI.js +12 -10
- package/package.json +1 -1
package/cjs/PlaneTrackerAPI.js
CHANGED
|
@@ -95,7 +95,7 @@ class PlaneTrackerAPI {
|
|
|
95
95
|
return PlaneTrackerAPI_1.trackingModeSchema.parse(res);
|
|
96
96
|
}
|
|
97
97
|
async setTrackingMode(mode, options) {
|
|
98
|
-
await this._postJsonEncoded(`${BASE_PATH}/package/setTrackingMode.cgi`,
|
|
98
|
+
await this._postJsonEncoded(`${BASE_PATH}/package/setTrackingMode.cgi`, mode, this.apiUser, options);
|
|
99
99
|
}
|
|
100
100
|
async startTrackingPlane(icao, options) {
|
|
101
101
|
const agent = this.getClient(options?.proxyParams);
|
|
@@ -125,14 +125,14 @@ class PlaneTrackerAPI {
|
|
|
125
125
|
return PlaneTrackerAPI_1.whiteListSchema.parse(res);
|
|
126
126
|
}
|
|
127
127
|
async setWhiteList(whiteList, options) {
|
|
128
|
-
return await this._postJsonEncoded(`${BASE_PATH}/package/setWhiteList.cgi`,
|
|
128
|
+
return await this._postJsonEncoded(`${BASE_PATH}/package/setWhiteList.cgi`, whiteList, this.apiUser, options);
|
|
129
129
|
}
|
|
130
130
|
async getBlackList(options) {
|
|
131
131
|
const res = await this._getJson(`${BASE_PATH}/package/getBlackList.cgi`, undefined, options);
|
|
132
132
|
return PlaneTrackerAPI_1.blackListSchema.parse(res);
|
|
133
133
|
}
|
|
134
134
|
async setBlackList(blackList, options) {
|
|
135
|
-
return await this._postJsonEncoded(`${BASE_PATH}/package/setBlackList.cgi`,
|
|
135
|
+
return await this._postJsonEncoded(`${BASE_PATH}/package/setBlackList.cgi`, blackList, this.apiUser, options);
|
|
136
136
|
}
|
|
137
137
|
async fetchMapInfo(options) {
|
|
138
138
|
const res = await this._getJson(`${BASE_PATH}/package/getMapInfo.cgi`, undefined, options);
|
|
@@ -143,7 +143,7 @@ class PlaneTrackerAPI {
|
|
|
143
143
|
return PlaneTrackerAPI_1.zonesSchema.parse(res);
|
|
144
144
|
}
|
|
145
145
|
async setZones(zones, options) {
|
|
146
|
-
await this._postJsonEncoded(`${BASE_PATH}/package/setZones.cgi`,
|
|
146
|
+
await this._postJsonEncoded(`${BASE_PATH}/package/setZones.cgi`, zones, this.apiUser, options);
|
|
147
147
|
}
|
|
148
148
|
async goToCoordinates(lat, lon, alt, options) {
|
|
149
149
|
const agent = this.getClient(options?.proxyParams);
|
|
@@ -154,10 +154,10 @@ class PlaneTrackerAPI {
|
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
156
|
async checkGenetecConnection(params, options) {
|
|
157
|
-
return await this._postUrlEncoded(`${BASE_PATH}/package/checkGenetecConnection.cgi`,
|
|
157
|
+
return await this._postUrlEncoded(`${BASE_PATH}/package/checkGenetecConnection.cgi`, params, options);
|
|
158
158
|
}
|
|
159
159
|
async getGenetecCameraList(params, options) {
|
|
160
|
-
const res = await this._postUrlEncoded(`${BASE_PATH}/package/getGenetecCameraList.cgi`,
|
|
160
|
+
const res = await this._postUrlEncoded(`${BASE_PATH}/package/getGenetecCameraList.cgi`, params, options);
|
|
161
161
|
return GenetecAgent_1.cameraListSchema.parse(res);
|
|
162
162
|
}
|
|
163
163
|
async _getJson(path, parameters, options, headers) {
|
|
@@ -198,13 +198,15 @@ class PlaneTrackerAPI {
|
|
|
198
198
|
throw new errors_1.ParsingBlobError(err);
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
-
async _postUrlEncoded(path,
|
|
201
|
+
async _postUrlEncoded(path, parameters, options, headers) {
|
|
202
202
|
const baseHeaders = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
203
|
-
|
|
203
|
+
const data = (0, utils_1.paramToUrl)(parameters);
|
|
204
|
+
return this._post(path, data, {}, options, { ...baseHeaders, ...headers });
|
|
204
205
|
}
|
|
205
206
|
async _postJsonEncoded(path, data, parameters, options, headers) {
|
|
206
207
|
const baseHeaders = { 'Accept': 'application/json', 'Content-Type': 'application/json' };
|
|
207
|
-
|
|
208
|
+
const jsonData = JSON.stringify(data);
|
|
209
|
+
return this._post(path, jsonData, parameters, options, { ...baseHeaders, ...headers });
|
|
208
210
|
}
|
|
209
211
|
}
|
|
210
212
|
exports.PlaneTrackerAPI = PlaneTrackerAPI;
|
package/esm/PlaneTrackerAPI.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { responseStringify } from './internal/utils';
|
|
2
|
+
import { paramToUrl, responseStringify } from './internal/utils';
|
|
3
3
|
import { blackListSchema, cameraSettingsSchema, flightInfoSchema, mapInfoSchema, priorityListSchema, serverSettingsSchema, trackingModeSchema, whiteListSchema, wsAliasResponseSchema, zonesSchema, } from './types/PlaneTrackerAPI';
|
|
4
4
|
import { ImportSettingsError, ParsingBlobError, ResetCalibrationError } from './errors/errors';
|
|
5
5
|
import { ProxyClient } from './internal/ProxyClient';
|
|
@@ -92,7 +92,7 @@ export class PlaneTrackerAPI {
|
|
|
92
92
|
return trackingModeSchema.parse(res);
|
|
93
93
|
}
|
|
94
94
|
async setTrackingMode(mode, options) {
|
|
95
|
-
await this._postJsonEncoded(`${BASE_PATH}/package/setTrackingMode.cgi`,
|
|
95
|
+
await this._postJsonEncoded(`${BASE_PATH}/package/setTrackingMode.cgi`, mode, this.apiUser, options);
|
|
96
96
|
}
|
|
97
97
|
async startTrackingPlane(icao, options) {
|
|
98
98
|
const agent = this.getClient(options?.proxyParams);
|
|
@@ -122,14 +122,14 @@ export class PlaneTrackerAPI {
|
|
|
122
122
|
return whiteListSchema.parse(res);
|
|
123
123
|
}
|
|
124
124
|
async setWhiteList(whiteList, options) {
|
|
125
|
-
return await this._postJsonEncoded(`${BASE_PATH}/package/setWhiteList.cgi`,
|
|
125
|
+
return await this._postJsonEncoded(`${BASE_PATH}/package/setWhiteList.cgi`, whiteList, this.apiUser, options);
|
|
126
126
|
}
|
|
127
127
|
async getBlackList(options) {
|
|
128
128
|
const res = await this._getJson(`${BASE_PATH}/package/getBlackList.cgi`, undefined, options);
|
|
129
129
|
return blackListSchema.parse(res);
|
|
130
130
|
}
|
|
131
131
|
async setBlackList(blackList, options) {
|
|
132
|
-
return await this._postJsonEncoded(`${BASE_PATH}/package/setBlackList.cgi`,
|
|
132
|
+
return await this._postJsonEncoded(`${BASE_PATH}/package/setBlackList.cgi`, blackList, this.apiUser, options);
|
|
133
133
|
}
|
|
134
134
|
async fetchMapInfo(options) {
|
|
135
135
|
const res = await this._getJson(`${BASE_PATH}/package/getMapInfo.cgi`, undefined, options);
|
|
@@ -140,7 +140,7 @@ export class PlaneTrackerAPI {
|
|
|
140
140
|
return zonesSchema.parse(res);
|
|
141
141
|
}
|
|
142
142
|
async setZones(zones, options) {
|
|
143
|
-
await this._postJsonEncoded(`${BASE_PATH}/package/setZones.cgi`,
|
|
143
|
+
await this._postJsonEncoded(`${BASE_PATH}/package/setZones.cgi`, zones, this.apiUser, options);
|
|
144
144
|
}
|
|
145
145
|
async goToCoordinates(lat, lon, alt, options) {
|
|
146
146
|
const agent = this.getClient(options?.proxyParams);
|
|
@@ -151,10 +151,10 @@ export class PlaneTrackerAPI {
|
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
153
|
async checkGenetecConnection(params, options) {
|
|
154
|
-
return await this._postUrlEncoded(`${BASE_PATH}/package/checkGenetecConnection.cgi`,
|
|
154
|
+
return await this._postUrlEncoded(`${BASE_PATH}/package/checkGenetecConnection.cgi`, params, options);
|
|
155
155
|
}
|
|
156
156
|
async getGenetecCameraList(params, options) {
|
|
157
|
-
const res = await this._postUrlEncoded(`${BASE_PATH}/package/getGenetecCameraList.cgi`,
|
|
157
|
+
const res = await this._postUrlEncoded(`${BASE_PATH}/package/getGenetecCameraList.cgi`, params, options);
|
|
158
158
|
return cameraListSchema.parse(res);
|
|
159
159
|
}
|
|
160
160
|
async _getJson(path, parameters, options, headers) {
|
|
@@ -195,12 +195,14 @@ export class PlaneTrackerAPI {
|
|
|
195
195
|
throw new ParsingBlobError(err);
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
async _postUrlEncoded(path,
|
|
198
|
+
async _postUrlEncoded(path, parameters, options, headers) {
|
|
199
199
|
const baseHeaders = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
200
|
-
|
|
200
|
+
const data = paramToUrl(parameters);
|
|
201
|
+
return this._post(path, data, {}, options, { ...baseHeaders, ...headers });
|
|
201
202
|
}
|
|
202
203
|
async _postJsonEncoded(path, data, parameters, options, headers) {
|
|
203
204
|
const baseHeaders = { 'Accept': 'application/json', 'Content-Type': 'application/json' };
|
|
204
|
-
|
|
205
|
+
const jsonData = JSON.stringify(data);
|
|
206
|
+
return this._post(path, jsonData, parameters, options, { ...baseHeaders, ...headers });
|
|
205
207
|
}
|
|
206
208
|
}
|