elero-usb-transmitter-client 1.0.5 → 1.1.1
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/.github/workflows/nodejs.yml +27 -0
- package/README.md +58 -1
- package/dist/UsbTransmitterClient.d.ts +18 -0
- package/dist/UsbTransmitterClient.js +284 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +277 -0
- package/dist/domain/constants.d.ts +32 -0
- package/dist/domain/constants.js +44 -0
- package/dist/domain/enums.d.ts +34 -0
- package/dist/domain/enums.js +40 -0
- package/dist/domain/types.d.ts +3 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +18 -0
- package/dist/model/Response.d.ts +10 -0
- package/dist/model/Response.js +2 -0
- package/dist/src/UsbTransmitterClient.d.ts +2 -2
- package/dist/src/UsbTransmitterClient.js +5 -4
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +277 -0
- package/jest.json +1 -1
- package/package.json +6 -3
- package/src/UsbTransmitterClient.ts +52 -44
- package/src/cli.ts +167 -0
- package/test/UsbTransmitterClient.test.ts +39 -0
- package/test/UsbTransmitterClientMock.test.ts +182 -0
- package/__test__/UsbTransmitterClient.test.ts +0 -31
- package/dist/src/ComfortCloudClient.d.ts +0 -21
- package/dist/src/ComfortCloudClient.js +0 -215
- package/dist/src/model/Device.d.ts +0 -182
- package/dist/src/model/Device.js +0 -374
- package/dist/src/model/Group.d.ts +0 -10
- package/dist/src/model/Group.js +0 -32
- package/dist/src/model/LoginData.d.ts +0 -6
- package/dist/src/model/LoginData.js +0 -11
- package/dist/src/model/Parameters.d.ts +0 -12
- package/dist/src/model/ServiceError.d.ts +0 -7
- package/dist/src/model/ServiceError.js +0 -41
- package/dist/src/model/TokenExpiredError.d.ts +0 -4
- package/dist/src/model/TokenExpiredError.js +0 -24
- /package/dist/{src/model/Parameters.js → domain/types.js} +0 -0
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
var axios_1 = require("axios");
|
|
40
|
-
var https = require("https");
|
|
41
|
-
var _ = require("lodash");
|
|
42
|
-
var LoginData_1 = require("./model/LoginData");
|
|
43
|
-
var ServiceError_1 = require("./model/ServiceError");
|
|
44
|
-
var Device_1 = require("./model/Device");
|
|
45
|
-
var Group_1 = require("./model/Group");
|
|
46
|
-
var TokenExpiredError_1 = require("./model/TokenExpiredError");
|
|
47
|
-
var ComfortCloudClient = /** @class */ (function () {
|
|
48
|
-
function ComfortCloudClient() {
|
|
49
|
-
this.baseUrl = 'https://accsmart.panasonic.com';
|
|
50
|
-
this.urlPartLogin = '/auth/login/';
|
|
51
|
-
this.urlPartGroup = '/device/group/';
|
|
52
|
-
this.urlPartDevice = '/deviceStatus/';
|
|
53
|
-
this.urlPartDeviceControl = '/deviceStatus/control';
|
|
54
|
-
this.appVersion = '2.0.0';
|
|
55
|
-
this._token = '';
|
|
56
|
-
this.axiosInstance = axios_1.default.create({
|
|
57
|
-
baseURL: this.baseUrl,
|
|
58
|
-
});
|
|
59
|
-
var agent = new https.Agent({
|
|
60
|
-
rejectUnauthorized: false,
|
|
61
|
-
});
|
|
62
|
-
this.axiosInstance.defaults.httpsAgent = agent;
|
|
63
|
-
this.axiosInstance.defaults.headers.common['Accept'] =
|
|
64
|
-
'application/json; charset=UTF-8';
|
|
65
|
-
this.axiosInstance.defaults.headers.common['Content-Type'] =
|
|
66
|
-
'application/json';
|
|
67
|
-
this.axiosInstance.defaults.headers.common['X-APP-TYPE'] = 0;
|
|
68
|
-
this.axiosInstance.defaults.headers.common['X-APP-VERSION'] = this.appVersion;
|
|
69
|
-
}
|
|
70
|
-
Object.defineProperty(ComfortCloudClient.prototype, "token", {
|
|
71
|
-
set: function (value) {
|
|
72
|
-
this._token = value;
|
|
73
|
-
},
|
|
74
|
-
enumerable: true,
|
|
75
|
-
configurable: true
|
|
76
|
-
});
|
|
77
|
-
ComfortCloudClient.prototype.login = function (username, password, language) {
|
|
78
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
-
var loginData, response, newToken, error_1;
|
|
80
|
-
return __generator(this, function (_a) {
|
|
81
|
-
switch (_a.label) {
|
|
82
|
-
case 0:
|
|
83
|
-
loginData = new LoginData_1.LoginData(username, password, language);
|
|
84
|
-
_a.label = 1;
|
|
85
|
-
case 1:
|
|
86
|
-
_a.trys.push([1, 3, , 4]);
|
|
87
|
-
return [4 /*yield*/, this.axiosInstance.post(this.urlPartLogin, loginData)];
|
|
88
|
-
case 2:
|
|
89
|
-
response = _a.sent();
|
|
90
|
-
if (response.status == 200) {
|
|
91
|
-
newToken = response.data.uToken;
|
|
92
|
-
this._token = newToken;
|
|
93
|
-
return [2 /*return*/, newToken];
|
|
94
|
-
}
|
|
95
|
-
throw new ServiceError_1.ServiceError(response.data.message, 0, response.status);
|
|
96
|
-
case 3:
|
|
97
|
-
error_1 = _a.sent();
|
|
98
|
-
this.handleError(error_1);
|
|
99
|
-
return [3 /*break*/, 4];
|
|
100
|
-
case 4: return [2 /*return*/, ''];
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
ComfortCloudClient.prototype.getGroups = function () {
|
|
106
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
107
|
-
var response, groupsResponse, groups, error_2;
|
|
108
|
-
return __generator(this, function (_a) {
|
|
109
|
-
switch (_a.label) {
|
|
110
|
-
case 0:
|
|
111
|
-
_a.trys.push([0, 2, , 3]);
|
|
112
|
-
return [4 /*yield*/, this.axiosInstance.get(this.urlPartGroup, {
|
|
113
|
-
headers: { 'X-User-Authorization': this._token },
|
|
114
|
-
})];
|
|
115
|
-
case 1:
|
|
116
|
-
response = _a.sent();
|
|
117
|
-
if (response.status == 200) {
|
|
118
|
-
groupsResponse = response.data.groupList;
|
|
119
|
-
groups = _.map(groupsResponse, function (element) {
|
|
120
|
-
var devices = _.map(element.deviceIdList, function (device) {
|
|
121
|
-
var retDevice = device.parameters;
|
|
122
|
-
retDevice.guid = device.deviceGuid;
|
|
123
|
-
retDevice.name = device.deviceName;
|
|
124
|
-
return retDevice;
|
|
125
|
-
});
|
|
126
|
-
return new Group_1.Group(element.groupId, element.groupName, devices);
|
|
127
|
-
});
|
|
128
|
-
return [2 /*return*/, groups];
|
|
129
|
-
}
|
|
130
|
-
return [3 /*break*/, 3];
|
|
131
|
-
case 2:
|
|
132
|
-
error_2 = _a.sent();
|
|
133
|
-
this.handleError(error_2);
|
|
134
|
-
return [3 /*break*/, 3];
|
|
135
|
-
case 3: return [2 /*return*/, []];
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
};
|
|
140
|
-
ComfortCloudClient.prototype.getDevice = function (id) {
|
|
141
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
142
|
-
var response, responseData, retDevice, error_3;
|
|
143
|
-
return __generator(this, function (_a) {
|
|
144
|
-
switch (_a.label) {
|
|
145
|
-
case 0:
|
|
146
|
-
_a.trys.push([0, 2, , 3]);
|
|
147
|
-
return [4 /*yield*/, this.axiosInstance.get(this.urlPartDevice + '/' + id, {
|
|
148
|
-
headers: { 'X-User-Authorization': this._token },
|
|
149
|
-
})];
|
|
150
|
-
case 1:
|
|
151
|
-
response = _a.sent();
|
|
152
|
-
if (response.status == 200) {
|
|
153
|
-
responseData = response.data;
|
|
154
|
-
retDevice = new Device_1.Device('', '');
|
|
155
|
-
_.assign(retDevice, responseData.parameters);
|
|
156
|
-
retDevice.guid = responseData.deviceGuid;
|
|
157
|
-
retDevice.name = responseData.deviceName;
|
|
158
|
-
return [2 /*return*/, retDevice];
|
|
159
|
-
}
|
|
160
|
-
return [3 /*break*/, 3];
|
|
161
|
-
case 2:
|
|
162
|
-
error_3 = _a.sent();
|
|
163
|
-
this.handleError(error_3);
|
|
164
|
-
return [3 /*break*/, 3];
|
|
165
|
-
case 3: return [2 /*return*/, null];
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
};
|
|
170
|
-
ComfortCloudClient.prototype.handleError = function (error) {
|
|
171
|
-
var errorResponse = error.response;
|
|
172
|
-
var responseData = errorResponse.data;
|
|
173
|
-
if (responseData.code === '4100') {
|
|
174
|
-
throw new TokenExpiredError_1.TokenExpiredError(responseData.message, responseData.code, errorResponse.status);
|
|
175
|
-
}
|
|
176
|
-
throw new ServiceError_1.ServiceError(responseData.message, responseData.code, errorResponse.status);
|
|
177
|
-
};
|
|
178
|
-
ComfortCloudClient.prototype.setDevice = function (device) {
|
|
179
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
180
|
-
return __generator(this, function (_a) {
|
|
181
|
-
return [2 /*return*/, this.setParameters(device.guid, device.parameters)];
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
};
|
|
185
|
-
ComfortCloudClient.prototype.setParameters = function (guid, parameters) {
|
|
186
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
187
|
-
var body, response, error_4;
|
|
188
|
-
return __generator(this, function (_a) {
|
|
189
|
-
switch (_a.label) {
|
|
190
|
-
case 0:
|
|
191
|
-
body = {
|
|
192
|
-
deviceGuid: guid,
|
|
193
|
-
parameters: parameters,
|
|
194
|
-
};
|
|
195
|
-
_a.label = 1;
|
|
196
|
-
case 1:
|
|
197
|
-
_a.trys.push([1, 3, , 4]);
|
|
198
|
-
return [4 /*yield*/, this.axiosInstance.post(this.urlPartDeviceControl, body, {
|
|
199
|
-
headers: { 'X-User-Authorization': this._token },
|
|
200
|
-
})];
|
|
201
|
-
case 2:
|
|
202
|
-
response = _a.sent();
|
|
203
|
-
return [2 /*return*/, response];
|
|
204
|
-
case 3:
|
|
205
|
-
error_4 = _a.sent();
|
|
206
|
-
this.handleError(error_4);
|
|
207
|
-
return [3 /*break*/, 4];
|
|
208
|
-
case 4: return [2 /*return*/, null];
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
};
|
|
213
|
-
return ComfortCloudClient;
|
|
214
|
-
}());
|
|
215
|
-
exports.ComfortCloudClient = ComfortCloudClient;
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { Power, OperationMode, FanSpeed, AirSwingLR, AirSwingUD, EcoMode, FanAutoMode } from '../domain/enums';
|
|
2
|
-
import { Parameters } from './Parameters';
|
|
3
|
-
export declare class Device {
|
|
4
|
-
private _guid;
|
|
5
|
-
private _name;
|
|
6
|
-
private _operate;
|
|
7
|
-
private _operationMode;
|
|
8
|
-
private _temperatureSet;
|
|
9
|
-
private _fanSpeed;
|
|
10
|
-
private _fanAutoMode;
|
|
11
|
-
private _airSwingLR;
|
|
12
|
-
private _airSwingUD;
|
|
13
|
-
private _ecoMode;
|
|
14
|
-
private _ecoNavi;
|
|
15
|
-
private _nanoe;
|
|
16
|
-
private _iAuto;
|
|
17
|
-
private _actualNanoe;
|
|
18
|
-
private _airDirection;
|
|
19
|
-
private _ecoFunctionData;
|
|
20
|
-
constructor(guid: string, name: string);
|
|
21
|
-
get parameters(): Parameters;
|
|
22
|
-
/**
|
|
23
|
-
* Getter operate
|
|
24
|
-
* @return {Power}
|
|
25
|
-
*/
|
|
26
|
-
get operate(): Power;
|
|
27
|
-
/**
|
|
28
|
-
* Getter operationMode
|
|
29
|
-
* @return {OperationMode}
|
|
30
|
-
*/
|
|
31
|
-
get operationMode(): OperationMode;
|
|
32
|
-
/**
|
|
33
|
-
* Getter temperatureSet
|
|
34
|
-
* @return {number}
|
|
35
|
-
*/
|
|
36
|
-
get temperatureSet(): number;
|
|
37
|
-
/**
|
|
38
|
-
* Getter fanSpeed
|
|
39
|
-
* @return {FanSpeed}
|
|
40
|
-
*/
|
|
41
|
-
get fanSpeed(): FanSpeed;
|
|
42
|
-
/**
|
|
43
|
-
* Getter fanAutoMode
|
|
44
|
-
* @return {FanAutoMode}
|
|
45
|
-
*/
|
|
46
|
-
get fanAutoMode(): FanAutoMode;
|
|
47
|
-
/**
|
|
48
|
-
* Getter airSwingLR
|
|
49
|
-
* @return {AirSwingLR}
|
|
50
|
-
*/
|
|
51
|
-
get airSwingLR(): AirSwingLR;
|
|
52
|
-
/**
|
|
53
|
-
* Getter airSwingUD
|
|
54
|
-
* @return {AirSwingUD}
|
|
55
|
-
*/
|
|
56
|
-
get airSwingUD(): AirSwingUD;
|
|
57
|
-
/**
|
|
58
|
-
* Getter ecoMode
|
|
59
|
-
* @return {EcoMode}
|
|
60
|
-
*/
|
|
61
|
-
get ecoMode(): EcoMode;
|
|
62
|
-
/**
|
|
63
|
-
* Getter ecoNavi
|
|
64
|
-
* @return {number}
|
|
65
|
-
*/
|
|
66
|
-
get ecoNavi(): number;
|
|
67
|
-
/**
|
|
68
|
-
* Getter nanoe
|
|
69
|
-
* @return {number}
|
|
70
|
-
*/
|
|
71
|
-
get nanoe(): number;
|
|
72
|
-
/**
|
|
73
|
-
* Getter iAuto
|
|
74
|
-
* @return {number}
|
|
75
|
-
*/
|
|
76
|
-
get iAuto(): number;
|
|
77
|
-
/**
|
|
78
|
-
* Getter actualNanoe
|
|
79
|
-
* @return {number}
|
|
80
|
-
*/
|
|
81
|
-
get actualNanoe(): number;
|
|
82
|
-
/**
|
|
83
|
-
* Getter airDirection
|
|
84
|
-
* @return {number}
|
|
85
|
-
*/
|
|
86
|
-
get airDirection(): number;
|
|
87
|
-
/**
|
|
88
|
-
* Getter ecoFunctionData
|
|
89
|
-
* @return {number}
|
|
90
|
-
*/
|
|
91
|
-
get ecoFunctionData(): number;
|
|
92
|
-
/**
|
|
93
|
-
* Setter operate
|
|
94
|
-
* @param {Power} value
|
|
95
|
-
*/
|
|
96
|
-
set operate(value: Power);
|
|
97
|
-
/**
|
|
98
|
-
* Setter operationMode
|
|
99
|
-
* @param {OperationMode} value
|
|
100
|
-
*/
|
|
101
|
-
set operationMode(value: OperationMode);
|
|
102
|
-
/**
|
|
103
|
-
* Setter temperatureSet
|
|
104
|
-
* @param {number} value
|
|
105
|
-
*/
|
|
106
|
-
set temperatureSet(value: number);
|
|
107
|
-
/**
|
|
108
|
-
* Setter fanSpeed
|
|
109
|
-
* @param {FanSpeed} value
|
|
110
|
-
*/
|
|
111
|
-
set fanSpeed(value: FanSpeed);
|
|
112
|
-
/**
|
|
113
|
-
* Setter fanAutoMode
|
|
114
|
-
* @param {FanAutoMode} value
|
|
115
|
-
*/
|
|
116
|
-
set fanAutoMode(value: FanAutoMode);
|
|
117
|
-
/**
|
|
118
|
-
* Setter airSwingLR
|
|
119
|
-
* @param {AirSwingLR} value
|
|
120
|
-
*/
|
|
121
|
-
set airSwingLR(value: AirSwingLR);
|
|
122
|
-
/**
|
|
123
|
-
* Setter airSwingUD
|
|
124
|
-
* @param {AirSwingUD} value
|
|
125
|
-
*/
|
|
126
|
-
set airSwingUD(value: AirSwingUD);
|
|
127
|
-
/**
|
|
128
|
-
* Setter ecoMode
|
|
129
|
-
* @param {EcoMode} value
|
|
130
|
-
*/
|
|
131
|
-
set ecoMode(value: EcoMode);
|
|
132
|
-
/**
|
|
133
|
-
* Setter ecoNavi
|
|
134
|
-
* @param {number} value
|
|
135
|
-
*/
|
|
136
|
-
set ecoNavi(value: number);
|
|
137
|
-
/**
|
|
138
|
-
* Setter nanoe
|
|
139
|
-
* @param {number} value
|
|
140
|
-
*/
|
|
141
|
-
set nanoe(value: number);
|
|
142
|
-
/**
|
|
143
|
-
* Setter iAuto
|
|
144
|
-
* @param {number} value
|
|
145
|
-
*/
|
|
146
|
-
set iAuto(value: number);
|
|
147
|
-
/**
|
|
148
|
-
* Setter actualNanoe
|
|
149
|
-
* @param {number} value
|
|
150
|
-
*/
|
|
151
|
-
set actualNanoe(value: number);
|
|
152
|
-
/**
|
|
153
|
-
* Setter airDirection
|
|
154
|
-
* @param {number} value
|
|
155
|
-
*/
|
|
156
|
-
set airDirection(value: number);
|
|
157
|
-
/**
|
|
158
|
-
* Setter ecoFunctionData
|
|
159
|
-
* @param {number} value
|
|
160
|
-
*/
|
|
161
|
-
set ecoFunctionData(value: number);
|
|
162
|
-
/**
|
|
163
|
-
* Getter name
|
|
164
|
-
* @return {string}
|
|
165
|
-
*/
|
|
166
|
-
get name(): string;
|
|
167
|
-
/**
|
|
168
|
-
* setter name
|
|
169
|
-
* @param {string} value
|
|
170
|
-
*/
|
|
171
|
-
set name(value: string);
|
|
172
|
-
/**
|
|
173
|
-
* Getter guid
|
|
174
|
-
* @return {string}
|
|
175
|
-
*/
|
|
176
|
-
get guid(): string;
|
|
177
|
-
/**
|
|
178
|
-
* Setter guid
|
|
179
|
-
* @param {string} value
|
|
180
|
-
*/
|
|
181
|
-
set guid(value: string);
|
|
182
|
-
}
|