camstreamerlib
Version:
Helper library for CamStreamer ACAP applications.
59 lines (58 loc) • 2.64 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CamScripterAPI = void 0;
const BasicAPI_1 = require("./internal/BasicAPI");
const CamScripterAPI_1 = require("./types/CamScripterAPI");
const common_1 = require("./types/common");
const BASE_PATH = '/local/camscripter';
class CamScripterAPI extends BasicAPI_1.BasicAPI {
static getProxyPath = () => `${BASE_PATH}/proxy.cgi`;
async checkAPIAvailable(options) {
await this._getJson(`${BASE_PATH}/api_check.cgi`, undefined, options);
}
async checkCameraTime(options) {
const res = await this._getJson(`${BASE_PATH}/camera_time.cgi`, undefined, options);
return CamScripterAPI_1.cameraTimeResponseSchema.parse(res).state;
}
async getNetworkCameraList(options) {
const res = await this._getJson(`${BASE_PATH}/network_camera_list.cgi`, undefined, options);
return common_1.networkCameraListSchema.parse(res.camera_list);
}
async getStorageInfo(options) {
const res = await this._getJson(`${BASE_PATH}/package/get_storage.cgi`, undefined, options);
return CamScripterAPI_1.cameraStorageSchema.parse(res);
}
async getPackageList(options) {
const res = await this._getJson(`${BASE_PATH}/package/list.cgi`, undefined, options);
return CamScripterAPI_1.packageInfoListSchema.parse(res);
}
async installPackages(formData, storage, options) {
await this._post(`${BASE_PATH}/package/install.cgi`, formData, { storage: storage }, options);
}
async uninstallPackage(packageId, options) {
await this._getJson(`${BASE_PATH}/package/remove.cgi`, { package_name: packageId }, options);
}
async importSettings(packageId, formData, options) {
await this._post(`${BASE_PATH}/package/data.cgi`, formData, {
action: 'IMPORT',
package_name: packageId,
}, options);
}
async exportSettings(packageId, formData, options) {
await this._post(`${BASE_PATH}/package/data.cgi`, formData, {
action: 'EXPORT',
package_name: packageId,
}, options);
}
async getNodejsStatus(options) {
const res = await this._getJson(`${BASE_PATH}/diagnostics.cgi`, undefined, options);
return CamScripterAPI_1.nodeStateSchema.parse(res);
}
async installNodejs(storage, options) {
await this._getJson(`${BASE_PATH}/node_update.cgi`, { storage: storage }, options);
}
downloadReport(options) {
return this._getText(`${BASE_PATH}/report.cgi`, undefined, options);
}
}
exports.CamScripterAPI = CamScripterAPI;