@wiotp/sdk 0.7.6-pre.monitoring-dashboard-updates → 0.7.8
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/dist/BaseClient.js +23 -9
- package/dist/BaseConfig.js +1 -3
- package/dist/api/ApiClient.js +8 -8
- package/dist/api/ApiErrors.js +24 -22
- package/dist/api/DscClient.js +2 -4
- package/dist/api/LecClient.js +1 -3
- package/dist/api/MgmtClient.js +1 -3
- package/dist/api/RegistryClient.js +1 -3
- package/dist/api/RulesClient.js +1 -3
- package/dist/api/StateClient.js +1 -3
- package/dist/application/ApplicationClient.js +15 -11
- package/dist/application/ApplicationConfig.js +14 -10
- package/dist/bundled/wiotp-bundle.js +34834 -30156
- package/dist/bundled/wiotp-bundle.min.js +6 -6
- package/dist/device/DeviceClient.js +15 -11
- package/dist/device/DeviceConfig.js +18 -10
- package/dist/gateway/GatewayClient.js +15 -11
- package/dist/gateway/GatewayConfig.js +13 -9
- package/dist/index.js +56 -0
- package/package.json +9 -5
- package/src/BaseClient.js +9 -0
- package/src/api/ApiClient.js +4 -2
- package/src/application/ApplicationConfig.js +1 -1
- package/src/device/DeviceConfig.js +7 -1
- package/src/index.js +8 -1
|
@@ -13,7 +13,7 @@ var _DeviceConfig = _interopRequireDefault(require("./DeviceConfig"));
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
15
|
|
|
16
|
-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
16
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
17
17
|
|
|
18
18
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
19
19
|
|
|
@@ -21,30 +21,34 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
21
21
|
|
|
22
22
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
23
23
|
|
|
24
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
25
|
-
|
|
26
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
27
|
-
|
|
28
24
|
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
|
|
29
25
|
|
|
30
26
|
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
31
27
|
|
|
32
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
33
|
-
|
|
34
28
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
35
29
|
|
|
36
30
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
37
31
|
|
|
32
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
33
|
+
|
|
34
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
35
|
+
|
|
36
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
37
|
+
|
|
38
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
39
|
+
|
|
40
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
41
|
+
|
|
38
42
|
var WILDCARD_TOPIC = 'iot-2/cmd/+/fmt/+';
|
|
39
43
|
var CMD_RE = /^iot-2\/cmd\/(.+)\/fmt\/(.+)$/;
|
|
40
44
|
|
|
41
45
|
var util = require('util');
|
|
42
46
|
|
|
43
|
-
var DeviceClient =
|
|
44
|
-
/*#__PURE__*/
|
|
45
|
-
function (_BaseClient) {
|
|
47
|
+
var DeviceClient = /*#__PURE__*/function (_BaseClient) {
|
|
46
48
|
_inherits(DeviceClient, _BaseClient);
|
|
47
49
|
|
|
50
|
+
var _super = _createSuper(DeviceClient);
|
|
51
|
+
|
|
48
52
|
function DeviceClient(config) {
|
|
49
53
|
var _this;
|
|
50
54
|
|
|
@@ -54,7 +58,7 @@ function (_BaseClient) {
|
|
|
54
58
|
throw new Error("Config must be an instance of DeviceConfig");
|
|
55
59
|
}
|
|
56
60
|
|
|
57
|
-
_this =
|
|
61
|
+
_this = _super.call(this, config);
|
|
58
62
|
|
|
59
63
|
_this.log.debug("[DeviceClient:constructor] DeviceClient initialized for " + config.getClientId());
|
|
60
64
|
|
|
@@ -11,7 +11,7 @@ var _loglevel = _interopRequireDefault(require("loglevel"));
|
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
13
|
|
|
14
|
-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
14
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
15
15
|
|
|
16
16
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
17
|
|
|
@@ -19,31 +19,35 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
19
19
|
|
|
20
20
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
21
21
|
|
|
22
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
23
|
+
|
|
24
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
25
|
+
|
|
26
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
27
|
+
|
|
22
28
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
23
29
|
|
|
24
30
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
25
31
|
|
|
26
|
-
function
|
|
32
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
27
33
|
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
34
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
31
35
|
|
|
32
36
|
var YAML = require('yaml');
|
|
33
37
|
|
|
34
38
|
var fs = require('fs');
|
|
35
39
|
|
|
36
|
-
var DeviceConfig =
|
|
37
|
-
/*#__PURE__*/
|
|
38
|
-
function (_BaseConfig) {
|
|
40
|
+
var DeviceConfig = /*#__PURE__*/function (_BaseConfig) {
|
|
39
41
|
_inherits(DeviceConfig, _BaseConfig);
|
|
40
42
|
|
|
43
|
+
var _super = _createSuper(DeviceConfig);
|
|
44
|
+
|
|
41
45
|
function DeviceConfig(identity, auth, options) {
|
|
42
46
|
var _this;
|
|
43
47
|
|
|
44
48
|
_classCallCheck(this, DeviceConfig);
|
|
45
49
|
|
|
46
|
-
_this =
|
|
50
|
+
_this = _super.call(this, identity, auth, options); //Validate the arguments
|
|
47
51
|
|
|
48
52
|
if (_this.identity == null) {
|
|
49
53
|
throw new Error("Missing identity from configuration");
|
|
@@ -97,7 +101,11 @@ function (_BaseConfig) {
|
|
|
97
101
|
}, {
|
|
98
102
|
key: "getMqttPassword",
|
|
99
103
|
value: function getMqttPassword() {
|
|
100
|
-
|
|
104
|
+
if (this.identity.orgId != "quickstart") {
|
|
105
|
+
return this.auth.token;
|
|
106
|
+
} else {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
101
109
|
}
|
|
102
110
|
}], [{
|
|
103
111
|
key: "parseEnvVars",
|
|
@@ -11,7 +11,7 @@ var _GatewayConfig = _interopRequireDefault(require("./GatewayConfig"));
|
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
13
|
|
|
14
|
-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
14
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
15
15
|
|
|
16
16
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
17
|
|
|
@@ -19,29 +19,33 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
19
19
|
|
|
20
20
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
21
21
|
|
|
22
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
23
|
-
|
|
24
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
25
|
-
|
|
26
22
|
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
|
|
27
23
|
|
|
28
24
|
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
29
25
|
|
|
30
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
31
|
-
|
|
32
26
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
33
27
|
|
|
34
28
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
35
29
|
|
|
30
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
31
|
+
|
|
32
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
33
|
+
|
|
34
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
35
|
+
|
|
36
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
37
|
+
|
|
38
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
39
|
+
|
|
36
40
|
var CMD_RE = /^iot-2\/type\/(.+)\/id\/(.+)\/cmd\/(.+)\/fmt\/(.+)$/;
|
|
37
41
|
|
|
38
42
|
var util = require('util');
|
|
39
43
|
|
|
40
|
-
var GatewayClient =
|
|
41
|
-
/*#__PURE__*/
|
|
42
|
-
function (_BaseClient) {
|
|
44
|
+
var GatewayClient = /*#__PURE__*/function (_BaseClient) {
|
|
43
45
|
_inherits(GatewayClient, _BaseClient);
|
|
44
46
|
|
|
47
|
+
var _super = _createSuper(GatewayClient);
|
|
48
|
+
|
|
45
49
|
function GatewayClient(config) {
|
|
46
50
|
var _this;
|
|
47
51
|
|
|
@@ -55,7 +59,7 @@ function (_BaseClient) {
|
|
|
55
59
|
throw new Error('[GatewayClient:constructor] Quickstart not supported in Gateways');
|
|
56
60
|
}
|
|
57
61
|
|
|
58
|
-
_this =
|
|
62
|
+
_this = _super.call(this, config);
|
|
59
63
|
|
|
60
64
|
_this.log.debug("[GatewayClient:constructor] GatewayClient initialized for " + config.getClientId());
|
|
61
65
|
|
|
@@ -9,7 +9,7 @@ var _DeviceConfig2 = _interopRequireDefault(require("../device/DeviceConfig"));
|
|
|
9
9
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
11
|
|
|
12
|
-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
12
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
13
13
|
|
|
14
14
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
15
|
|
|
@@ -17,25 +17,29 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
17
17
|
|
|
18
18
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
19
19
|
|
|
20
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
21
|
+
|
|
22
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
23
|
+
|
|
24
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
25
|
+
|
|
20
26
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
21
27
|
|
|
22
28
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
23
29
|
|
|
24
|
-
function
|
|
30
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
25
31
|
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
32
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
29
33
|
|
|
30
|
-
var GatewayConfig =
|
|
31
|
-
/*#__PURE__*/
|
|
32
|
-
function (_DeviceConfig) {
|
|
34
|
+
var GatewayConfig = /*#__PURE__*/function (_DeviceConfig) {
|
|
33
35
|
_inherits(GatewayConfig, _DeviceConfig);
|
|
34
36
|
|
|
37
|
+
var _super = _createSuper(GatewayConfig);
|
|
38
|
+
|
|
35
39
|
function GatewayConfig(identity, auth, options) {
|
|
36
40
|
_classCallCheck(this, GatewayConfig);
|
|
37
41
|
|
|
38
|
-
return
|
|
42
|
+
return _super.call(this, identity, auth, options);
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
_createClass(GatewayConfig, [{
|
package/dist/index.js
CHANGED
|
@@ -33,12 +33,54 @@ Object.defineProperty(exports, "DeviceConfig", {
|
|
|
33
33
|
return _DeviceConfig["default"];
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
+
Object.defineProperty(exports, "ApiClient", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _ApiClient["default"];
|
|
40
|
+
}
|
|
41
|
+
});
|
|
36
42
|
Object.defineProperty(exports, "ApiErrors", {
|
|
37
43
|
enumerable: true,
|
|
38
44
|
get: function get() {
|
|
39
45
|
return _ApiErrors["default"];
|
|
40
46
|
}
|
|
41
47
|
});
|
|
48
|
+
Object.defineProperty(exports, "DscClient", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function get() {
|
|
51
|
+
return _DscClient["default"];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "LecClient", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function get() {
|
|
57
|
+
return _LecClient["default"];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "MgmtClient", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function get() {
|
|
63
|
+
return _MgmtClient["default"];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "RegistryClient", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function get() {
|
|
69
|
+
return _RegistryClient["default"];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "RulesClient", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function get() {
|
|
75
|
+
return _RulesClient["default"];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "StateClient", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function get() {
|
|
81
|
+
return _StateClient["default"];
|
|
82
|
+
}
|
|
83
|
+
});
|
|
42
84
|
|
|
43
85
|
var _ApplicationClient = _interopRequireDefault(require("./application/ApplicationClient"));
|
|
44
86
|
|
|
@@ -50,6 +92,20 @@ var _ApplicationConfig = _interopRequireDefault(require("./application/Applicati
|
|
|
50
92
|
|
|
51
93
|
var _DeviceConfig = _interopRequireDefault(require("./device/DeviceConfig"));
|
|
52
94
|
|
|
95
|
+
var _ApiClient = _interopRequireDefault(require("./api/ApiClient"));
|
|
96
|
+
|
|
53
97
|
var _ApiErrors = _interopRequireDefault(require("./api/ApiErrors"));
|
|
54
98
|
|
|
99
|
+
var _DscClient = _interopRequireDefault(require("./api/DscClient"));
|
|
100
|
+
|
|
101
|
+
var _LecClient = _interopRequireDefault(require("./api/LecClient"));
|
|
102
|
+
|
|
103
|
+
var _MgmtClient = _interopRequireDefault(require("./api/MgmtClient"));
|
|
104
|
+
|
|
105
|
+
var _RegistryClient = _interopRequireDefault(require("./api/RegistryClient"));
|
|
106
|
+
|
|
107
|
+
var _RulesClient = _interopRequireDefault(require("./api/RulesClient"));
|
|
108
|
+
|
|
109
|
+
var _StateClient = _interopRequireDefault(require("./api/StateClient"));
|
|
110
|
+
|
|
55
111
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wiotp/sdk",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.8",
|
|
4
4
|
"description": "SDK for developing device, gateway, and application clients for IBM Watson IoT Platform",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -16,17 +16,19 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"axios": "^0.19.0",
|
|
18
18
|
"bluebird": "^3.5.4",
|
|
19
|
-
"browserify": "^16.5.0",
|
|
20
19
|
"btoa": "^1.2.1",
|
|
21
20
|
"concat-stream": "^2.0.0",
|
|
21
|
+
"esm": "^3.2.25",
|
|
22
22
|
"events": "^3.0.0",
|
|
23
23
|
"form-data": "^2.3.3",
|
|
24
24
|
"format": "^0.2.2",
|
|
25
25
|
"loglevel": "^1.6.1",
|
|
26
26
|
"mqtt": "^3.0.0",
|
|
27
|
+
"systeminformation": "^4.22.3",
|
|
27
28
|
"tinycache": "^1.1.2",
|
|
28
|
-
"uuid": "^3.
|
|
29
|
-
"yaml": "^1.7.2"
|
|
29
|
+
"uuid": "^3.4.0",
|
|
30
|
+
"yaml": "^1.7.2",
|
|
31
|
+
"yargs": "^15.1.0"
|
|
30
32
|
},
|
|
31
33
|
"devDependencies": {
|
|
32
34
|
"@babel/cli": "7.7.7",
|
|
@@ -36,6 +38,8 @@
|
|
|
36
38
|
"@cloudant/cloudant": "^2.1.0",
|
|
37
39
|
"@istanbuljs/nyc-config-babel": "^3.0.0",
|
|
38
40
|
"babel-plugin-istanbul": "^6.0.0",
|
|
41
|
+
"babelify": "^10.0.0",
|
|
42
|
+
"browserify": "^16.5.1",
|
|
39
43
|
"chai": "^4.2.0",
|
|
40
44
|
"chai-as-promised": "^7.1.1",
|
|
41
45
|
"coveralls": "3.0.9",
|
|
@@ -49,7 +53,7 @@
|
|
|
49
53
|
"clean": "rimraf dist/*",
|
|
50
54
|
"build": "npm run clean && npm run build:commonjs && npm run build:bundle && npm run build:min",
|
|
51
55
|
"build:commonjs": "babel src --out-dir dist",
|
|
52
|
-
"build:bundle": "browserify
|
|
56
|
+
"build:bundle": "browserify -t [ babelify --presets [ @babel/preset-env ] --global ] src --outfile dist/bundled/wiotp-bundle.js",
|
|
53
57
|
"build:min": "terser dist/bundled/wiotp-bundle.js -o dist/bundled/wiotp-bundle.min.js",
|
|
54
58
|
"test": "mocha --require @babel/register --require mocha-steps",
|
|
55
59
|
"test-cov": "nyc --reporter=lcov --reporter=text-summary mocha --require mocha-steps",
|
package/src/BaseClient.js
CHANGED
|
@@ -202,6 +202,15 @@ export default class BaseClient extends events.EventEmitter {
|
|
|
202
202
|
_publish(topic, msg, QoS, callback) {
|
|
203
203
|
QoS = QoS || 0;
|
|
204
204
|
|
|
205
|
+
if (this.mqtt == null) {
|
|
206
|
+
this.emit('error', "[BaseClient:_unsubscribe] MQTT Client is not initialized - call connect() first");
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (!this.mqtt.connected) {
|
|
210
|
+
this.emit('error', "[BaseClient:_unsubscribe] MQTT Client is not connected - call connect() first");
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
|
|
205
214
|
if ((typeof msg === 'object' || typeof msg === 'boolean' || typeof msg === 'number') && !Buffer.isBuffer(msg)) {
|
|
206
215
|
// mqtt library does not support sending JSON/Boolean/Number data. So stringifying it.
|
|
207
216
|
// All JSON object, array will be encoded.
|
package/src/api/ApiClient.js
CHANGED
|
@@ -344,7 +344,8 @@ export default class ApiClient {
|
|
|
344
344
|
if(xhrConfig.method == "POST") {
|
|
345
345
|
if(data.schemaFile) {
|
|
346
346
|
var blob = new Blob([data.schemaFile], { type: "application/json" })
|
|
347
|
-
|
|
347
|
+
var schemaFileName = `${data.name || 'schema'}.json`;
|
|
348
|
+
formData.append('schemaFile', blob, schemaFileName);
|
|
348
349
|
}
|
|
349
350
|
|
|
350
351
|
if(data.name) {
|
|
@@ -360,7 +361,8 @@ export default class ApiClient {
|
|
|
360
361
|
} else if(xhrConfig.method == "PUT") {
|
|
361
362
|
if(data.schemaFile) {
|
|
362
363
|
var blob = new Blob([data.schemaFile], { type: "application/json", name: data.name })
|
|
363
|
-
|
|
364
|
+
var schemaFileName = `${data.name || 'schema'}.json`;
|
|
365
|
+
formData.append('schemaFile', blob, schemaFileName);
|
|
364
366
|
}
|
|
365
367
|
}
|
|
366
368
|
|
|
@@ -66,7 +66,7 @@ export default class ApplicationConfig extends BaseConfig{
|
|
|
66
66
|
|
|
67
67
|
getClientId() {
|
|
68
68
|
let clientIdPrefix = "a";
|
|
69
|
-
if (this.sharedSubscription == true) {
|
|
69
|
+
if (this.options.mqtt.sharedSubscription == true) {
|
|
70
70
|
clientIdPrefix = "A";
|
|
71
71
|
}
|
|
72
72
|
return clientIdPrefix + ":" + this.getOrgId() + ":" + this.identity.appId;
|
|
@@ -60,7 +60,13 @@ export default class DeviceConfig extends BaseConfig{
|
|
|
60
60
|
return "use-token-auth";
|
|
61
61
|
}
|
|
62
62
|
getMqttPassword() {
|
|
63
|
-
|
|
63
|
+
if (this.identity.orgId != "quickstart")
|
|
64
|
+
{
|
|
65
|
+
return this.auth.token;
|
|
66
|
+
}
|
|
67
|
+
else{
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
64
70
|
}
|
|
65
71
|
|
|
66
72
|
static parseEnvVars() {
|
package/src/index.js
CHANGED
|
@@ -16,4 +16,11 @@ export { default as GatewayClient } from './gateway/GatewayClient';
|
|
|
16
16
|
export { default as ApplicationConfig } from './application/ApplicationConfig';
|
|
17
17
|
export { default as DeviceConfig } from './device/DeviceConfig';
|
|
18
18
|
|
|
19
|
-
export {default as
|
|
19
|
+
export { default as ApiClient} from './api/ApiClient';
|
|
20
|
+
export { default as ApiErrors} from './api/ApiErrors';
|
|
21
|
+
export { default as DscClient} from './api/DscClient';
|
|
22
|
+
export { default as LecClient} from './api/LecClient';
|
|
23
|
+
export { default as MgmtClient} from './api/MgmtClient';
|
|
24
|
+
export { default as RegistryClient} from './api/RegistryClient';
|
|
25
|
+
export { default as RulesClient} from './api/RulesClient';
|
|
26
|
+
export { default as StateClient} from './api/StateClient';
|