@gotillit/tillit-node-red 1.1.13 → 1.1.14
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/nodes/node-api.d.ts +2 -0
- package/dist/nodes/node-api.js +123 -0
- package/dist/nodes/node-api.js.map +1 -0
- package/dist/nodes/node-broker.d.ts +2 -0
- package/dist/nodes/node-broker.js +85 -0
- package/dist/nodes/node-broker.js.map +1 -0
- package/dist/nodes/node-in.d.ts +2 -0
- package/dist/nodes/node-in.js +79 -0
- package/dist/nodes/node-in.js.map +1 -0
- package/dist/nodes/node-out.d.ts +2 -0
- package/dist/nodes/node-out.js +70 -0
- package/dist/nodes/node-out.js.map +1 -0
- package/dist/tillit-node.js +8 -330
- package/dist/tillit-node.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,123 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.buildApiFunction = void 0;
|
|
43
|
+
var utils_1 = require("../shared/utils");
|
|
44
|
+
var got_1 = __importDefault(require("got"));
|
|
45
|
+
var buildApiFunction = function (RED) { return (function apiCall(n) {
|
|
46
|
+
RED.nodes.createNode(this, n);
|
|
47
|
+
this.myDevice = n.device;
|
|
48
|
+
this.connection = RED.nodes.getNode(this.myDevice);
|
|
49
|
+
var _a = this.connection, environment = _a.environment, tenant = _a.tenant, username = _a.username, password = _a.password;
|
|
50
|
+
var self = this;
|
|
51
|
+
self.on("input", function (msg) {
|
|
52
|
+
var _a;
|
|
53
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
+
var endpoint, url, method, ops, response, error_1;
|
|
55
|
+
return __generator(this, function (_b) {
|
|
56
|
+
switch (_b.label) {
|
|
57
|
+
case 0:
|
|
58
|
+
endpoint = (_a = msg.endpoint) !== null && _a !== void 0 ? _a : n.endpoint;
|
|
59
|
+
url = (0, utils_1.hostname)(environment, tenant) + '/api/' + endpoint;
|
|
60
|
+
method = n.method;
|
|
61
|
+
self.status({
|
|
62
|
+
fill: "blue",
|
|
63
|
+
shape: "ring",
|
|
64
|
+
text: "loading..."
|
|
65
|
+
});
|
|
66
|
+
_b.label = 1;
|
|
67
|
+
case 1:
|
|
68
|
+
_b.trys.push([1, 3, , 4]);
|
|
69
|
+
ops = {
|
|
70
|
+
method: method,
|
|
71
|
+
username: username,
|
|
72
|
+
password: password
|
|
73
|
+
};
|
|
74
|
+
if (msg.payload) {
|
|
75
|
+
if (['POST', 'PUT'].includes(method)) {
|
|
76
|
+
ops['json'] = msg.payload;
|
|
77
|
+
}
|
|
78
|
+
else if (typeof msg.payload === 'object') {
|
|
79
|
+
ops['searchParams'] = msg.payload;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return [4 /*yield*/, (0, got_1.default)(url, ops)];
|
|
83
|
+
case 2:
|
|
84
|
+
response = _b.sent();
|
|
85
|
+
// const data = await response.json();
|
|
86
|
+
self.status({
|
|
87
|
+
fill: "green",
|
|
88
|
+
shape: "ring",
|
|
89
|
+
text: response.statusCode
|
|
90
|
+
});
|
|
91
|
+
try {
|
|
92
|
+
self.send([{
|
|
93
|
+
topic: msg.topic,
|
|
94
|
+
payload: response.body ? JSON.parse(response.body) : null
|
|
95
|
+
}, null]);
|
|
96
|
+
}
|
|
97
|
+
catch (e) {
|
|
98
|
+
self.send([null, {
|
|
99
|
+
topic: msg.topic,
|
|
100
|
+
payload: response.body
|
|
101
|
+
}]);
|
|
102
|
+
}
|
|
103
|
+
return [3 /*break*/, 4];
|
|
104
|
+
case 3:
|
|
105
|
+
error_1 = _b.sent();
|
|
106
|
+
self.status({
|
|
107
|
+
fill: "red",
|
|
108
|
+
shape: "ring",
|
|
109
|
+
text: error_1.message
|
|
110
|
+
});
|
|
111
|
+
self.send([null, {
|
|
112
|
+
topic: msg.topic,
|
|
113
|
+
payload: error_1.response.body ? JSON.parse(error_1.response.body) : { message: error_1.message }
|
|
114
|
+
}]);
|
|
115
|
+
return [3 /*break*/, 4];
|
|
116
|
+
case 4: return [2 /*return*/];
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
}); };
|
|
122
|
+
exports.buildApiFunction = buildApiFunction;
|
|
123
|
+
//# sourceMappingURL=node-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-api.js","sourceRoot":"","sources":["../../src/nodes/node-api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAAyC;AACzC,4CAAsB;AAEf,IAAM,gBAAgB,GAAG,UAAC,GAAQ,IAAK,OAAA,CAAC,SAAS,OAAO,CAAC,CAAiB;IAC7E,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC9B,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC;IACzB,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC7C,IAAA,KAA4C,IAAI,CAAC,UAAU,EAA1D,WAAW,iB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;oCACP,KAAK,EAAE,GAAG,CAAC,KAAK;oCAChB,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI;iCAC5D,EAAE,IAAI,CAAC,CAAC,CAAC;yBACb;wBAAC,OAAO,CAAC,EAAE;4BACR,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE;oCACb,KAAK,EAAE,GAAG,CAAC,KAAK;oCAChB,OAAO,EAAE,QAAQ,CAAC,IAAI;iCACzB,CAAC,CAAC,CAAC;yBACP;;;;wBAGD,IAAI,CAAC,MAAM,CAAC;4BACR,IAAI,EAAE,KAAK;4BACX,KAAK,EAAE,MAAM;4BACb,IAAI,EAAE,OAAK,CAAC,OAAO;yBACtB,CAAC,CAAC;wBACH,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE;gCACb,KAAK,EAAE,GAAG,CAAC,KAAK;gCAChB,OAAO,EAAE,OAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAC,OAAO,EAAE,OAAK,CAAC,OAAO,EAAC;6BAC5F,CAAC,CAAC,CAAC;;;;;;KAGX,CAAC,CAAC;AACP,CAAC,CAAC,EAhE4C,CAgE5C,CAAA;AAhEW,QAAA,gBAAgB,oBAgE3B"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildNodeBrokerFunction = void 0;
|
|
4
|
+
var utils_1 = require("../shared/utils");
|
|
5
|
+
var edge_from_s3_1 = require("../shared/edge-from-s3");
|
|
6
|
+
var aws_iot_device_sdk_v2_1 = require("aws-iot-device-sdk-v2");
|
|
7
|
+
var buildNodeBrokerFunction = function (RED) { return (function awsNodeBroker(n) {
|
|
8
|
+
var _this = this;
|
|
9
|
+
var _a;
|
|
10
|
+
var workingDir = RED.settings.userDir + '/';
|
|
11
|
+
RED.nodes.createNode(this, n);
|
|
12
|
+
this.clientId = process.env.CLIENT_ID || n.thingId;
|
|
13
|
+
this.environment = (_a = n.environment) !== null && _a !== void 0 ? _a : process.env.ENVIRONMENT;
|
|
14
|
+
this.endpoint = process.env.IOT_ENDPOINT || (0, utils_1.mqttEndpoint)(n.environment);
|
|
15
|
+
var username = n.username, tenant = n.tenant, password = n.password;
|
|
16
|
+
username = username !== null && username !== void 0 ? username : process.env.USERNAME;
|
|
17
|
+
this.password = password !== null && password !== void 0 ? password : process.env.PASSWORD;
|
|
18
|
+
this.tenant = tenant !== null && tenant !== void 0 ? tenant : process.env.TENANT;
|
|
19
|
+
this.username = "".concat(username, "@").concat(tenant, ".tillit.cloud");
|
|
20
|
+
if (process.env.EDGE_BUCKET && n.thingId) {
|
|
21
|
+
(0, edge_from_s3_1.downloadAndUnzipEdge)(workingDir, n.thingId);
|
|
22
|
+
}
|
|
23
|
+
var self = this;
|
|
24
|
+
this.connect = function (clientId, reconnect, callback) {
|
|
25
|
+
clientId = n.thingId.trim();
|
|
26
|
+
if (!self.device || reconnect) {
|
|
27
|
+
self.log("Attempt to connect to with " + clientId + " from: " + _this.endpoint);
|
|
28
|
+
var thingCert = process.env.THING_CERT || n.thingCert || (workingDir + n.thingId + '/tillitEdgeConfig/thingCert.crt');
|
|
29
|
+
var privKey = process.env.PRIV_KEY || n.privKey || (workingDir + n.thingId + '/tillitEdgeConfig/privKey.key');
|
|
30
|
+
var rootCa = process.env.ROOT_CA || n.rootCa || (workingDir + n.thingId + '/tillitEdgeConfig/rootCA.pem');
|
|
31
|
+
self.log("Using the certificates that are presented as follows:");
|
|
32
|
+
self.log(" - keyPath : " + privKey);
|
|
33
|
+
self.log(" - certPath : " + thingCert);
|
|
34
|
+
self.log(" - caPath : " + rootCa);
|
|
35
|
+
var configBuilder = aws_iot_device_sdk_v2_1.iot.AwsIotMqttConnectionConfigBuilder.new_mtls_builder_from_path(thingCert, privKey);
|
|
36
|
+
configBuilder.with_certificate_authority_from_path(undefined, rootCa);
|
|
37
|
+
configBuilder.with_clean_session(false);
|
|
38
|
+
configBuilder.with_client_id(clientId || "test-" + Math.floor(Math.random() * 100000000));
|
|
39
|
+
configBuilder.with_endpoint(self.endpoint);
|
|
40
|
+
configBuilder.with_keep_alive_seconds(20);
|
|
41
|
+
var config = configBuilder.build();
|
|
42
|
+
console.log(JSON.stringify(config));
|
|
43
|
+
var client = new aws_iot_device_sdk_v2_1.mqtt.MqttClient();
|
|
44
|
+
self.device = client.new_connection(config);
|
|
45
|
+
self.device.connect().catch(function (error) {
|
|
46
|
+
console.log("Connect error: " + error);
|
|
47
|
+
}).then(function (connected, err) {
|
|
48
|
+
console.log(err);
|
|
49
|
+
});
|
|
50
|
+
if (self.device) {
|
|
51
|
+
self.device.on('connect', function () {
|
|
52
|
+
callback('connected');
|
|
53
|
+
});
|
|
54
|
+
self.device.on('reconnect', function () {
|
|
55
|
+
callback('reconnected');
|
|
56
|
+
});
|
|
57
|
+
self.device.on('interrupt', function (error) {
|
|
58
|
+
callback('interrupt', error);
|
|
59
|
+
});
|
|
60
|
+
self.device.on('resume', function (error) {
|
|
61
|
+
callback('resume', error);
|
|
62
|
+
});
|
|
63
|
+
self.device.on('error', function (error) {
|
|
64
|
+
callback('error', error);
|
|
65
|
+
});
|
|
66
|
+
self.device.on('offline', function () {
|
|
67
|
+
callback('offline');
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
callback('created');
|
|
71
|
+
}
|
|
72
|
+
else if (self.device) {
|
|
73
|
+
callback('ready');
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
self.on('close', function () {
|
|
77
|
+
self.log("closed " + self.clientId + " ok");
|
|
78
|
+
if (self.device) {
|
|
79
|
+
self.device.disconnect();
|
|
80
|
+
}
|
|
81
|
+
self.device = null;
|
|
82
|
+
});
|
|
83
|
+
}); };
|
|
84
|
+
exports.buildNodeBrokerFunction = buildNodeBrokerFunction;
|
|
85
|
+
//# sourceMappingURL=node-broker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-broker.js","sourceRoot":"","sources":["../../src/nodes/node-broker.ts"],"names":[],"mappings":";;;AACA,yCAA6C;AAC7C,uDAA4D;AAC5D,+DAAgD;AAEzC,IAAM,uBAAuB,GAAG,UAAC,GAAQ,IAAK,OAAA,CACjD,SAAS,aAAa,CAAC,CAAmB;IAA1C,iBAiFC;;IAhFG,IAAM,UAAU,GAAG,GAAG,CAAC,QAAQ,CAAC,OAAO,GAAG,GAAG,CAAC;IAC9C,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC9B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,CAAC,OAAO,CAAC;IACnD,IAAI,CAAC,WAAW,GAAG,MAAA,CAAC,CAAC,WAAW,mCAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;IAC5D,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,IAAA,oBAAY,EAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IACnE,IAAA,QAAQ,GAAsB,CAAC,SAAvB,EAAE,MAAM,GAAc,CAAC,OAAf,EAAE,QAAQ,GAAI,CAAC,SAAL,CAAM;IACrC,QAAQ,GAAG,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;IAC5C,IAAI,CAAC,QAAQ,GAAG,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;IACjD,IAAI,CAAC,MAAM,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;IAC3C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 = require("aws-iot-device-sdk-v2");
|
|
5
|
+
var decoder = new TextDecoder('utf8');
|
|
6
|
+
var buildNodeInFunction = function (RED) { return (function awsMqttNodeIn(n) {
|
|
7
|
+
RED.nodes.createNode(this, n);
|
|
8
|
+
this.myDevice = n.device;
|
|
9
|
+
this.awsIot = RED.nodes.getNode(this.myDevice);
|
|
10
|
+
var self = this;
|
|
11
|
+
if (self.awsIot) {
|
|
12
|
+
self.status({
|
|
13
|
+
fill: "yellow",
|
|
14
|
+
shape: "ring",
|
|
15
|
+
text: "subscribing..."
|
|
16
|
+
});
|
|
17
|
+
self.awsIot.connect(null, null, function (event, error) {
|
|
18
|
+
if (event == "connected") {
|
|
19
|
+
var topic = self.awsIot.tenant + n.topic;
|
|
20
|
+
self.awsIot.device.unsubscribe(topic);
|
|
21
|
+
var onMessage = function (topic, payload, dup, qos, retain) {
|
|
22
|
+
var json = JSON.parse(decoder.decode(payload));
|
|
23
|
+
self.log("RECV< " + topic + JSON.stringify(json));
|
|
24
|
+
self.send({
|
|
25
|
+
topic: topic,
|
|
26
|
+
payload: json
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
try {
|
|
30
|
+
self.awsIot.device.subscribe(topic, aws_iot_device_sdk_v2_1.mqtt.QoS.AtLeastOnce, onMessage);
|
|
31
|
+
self.status({
|
|
32
|
+
fill: "green",
|
|
33
|
+
shape: "ring",
|
|
34
|
+
text: "subscribed"
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
self.status({
|
|
39
|
+
fill: "error",
|
|
40
|
+
shape: "ring",
|
|
41
|
+
text: error.message
|
|
42
|
+
});
|
|
43
|
+
self.awsIot.device.on('message');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else if (event == "error") {
|
|
47
|
+
self.status({
|
|
48
|
+
fill: "error",
|
|
49
|
+
shape: "ring",
|
|
50
|
+
text: error.message
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
else if (event == 'interrupt') {
|
|
54
|
+
self.status({
|
|
55
|
+
fill: "error",
|
|
56
|
+
shape: "ring",
|
|
57
|
+
text: 'Connection lost'
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else if (event == 'resume') {
|
|
61
|
+
self.status({
|
|
62
|
+
fill: "green",
|
|
63
|
+
shape: "ring",
|
|
64
|
+
text: "subscribed"
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
self.error("aws-mqtt in is not configured");
|
|
71
|
+
self.status({
|
|
72
|
+
fill: "red",
|
|
73
|
+
shape: "ring",
|
|
74
|
+
text: "not configured"
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}); };
|
|
78
|
+
exports.buildNodeInFunction = buildNodeInFunction;
|
|
79
|
+
//# sourceMappingURL=node-in.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-in.js","sourceRoot":"","sources":["../../src/nodes/node-in.ts"],"names":[],"mappings":";;;AACA,+DAA2C;AAE3C,IAAM,OAAO,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;AACjC,IAAM,mBAAmB,GAAG,UAAC,GAAQ,IAAK,OAAA,CAC7C,SAAS,aAAa,CAAC,CAAW;IAC9B,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC9B,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC;IACzB,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/C,IAAM,IAAI,GAAG,IAAI,CAAC;IAClB,IAAI,IAAI,CAAC,MAAM,EAAE;QACb,IAAI,CAAC,MAAM,CAAC;YACR,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,MAAM;YACb,IAAI,EAAE,gBAAgB;SACzB,CAAC,CAAC;QACH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AAE;gBACzB,IAAI,CAAC,MAAM,CAAC;oBACR,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,MAAM;oBACb,IAAI,EAAE,KAAK,CAAC,OAAO;iBACtB,CAAC,CAAC;aACN;iBAAM,IAAI,KAAK,IAAI,WAAW,EAAE;gBAC7B,IAAI,CAAC,MAAM,CAAC;oBACR,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,MAAM;oBACb,IAAI,EAAE,iBAAiB;iBAC1B,CAAC,CAAC;aACN;iBAAM,IAAI,KAAK,IAAI,QAAQ,EAAE;gBAC1B,IAAI,CAAC,MAAM,CAAC;oBACR,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,MAAM;oBACb,IAAI,EAAE,YAAY;iBACrB,CAAC,CAAC;aACN;QAEL,CAAC,CAAC,CAAC;KACN;SAAM;QACH,IAAI,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,CAAC;YACR,IAAI,EAAE,KAAK;YACX,KAAK,EAAE,MAAM;YACb,IAAI,EAAE,gBAAgB;SACzB,CAAC,CAAC;KACN;AACL,CAAC,CAAC,EAtE2C,CAsE3C,CAAA;AAtEO,QAAA,mBAAmB,uBAsE1B"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildNodeOutFunction = void 0;
|
|
4
|
+
var buildNodeOutFunction = function (RED) { return (function awsMqttNodeOut(n) {
|
|
5
|
+
RED.nodes.createNode(this, n);
|
|
6
|
+
this.myDevice = n.device;
|
|
7
|
+
this.awsIot = RED.nodes.getNode(this.myDevice);
|
|
8
|
+
var self = this;
|
|
9
|
+
var options = {
|
|
10
|
+
qos: parseInt(n.qos) || 0
|
|
11
|
+
};
|
|
12
|
+
self.on("input", function (msg) {
|
|
13
|
+
if (self.awsIot) {
|
|
14
|
+
self.awsIot.connect(msg.clientId, msg.reconnect, function (event, error) {
|
|
15
|
+
if ((event == "ready" || event == "created")) {
|
|
16
|
+
self.log("SEND> " + (msg.topic || n.topic) + " " + JSON.stringify(msg.payload));
|
|
17
|
+
if (!Buffer.isBuffer(msg.payload)) {
|
|
18
|
+
if (typeof msg.payload === "object") {
|
|
19
|
+
msg.payload = JSON.stringify(msg.payload);
|
|
20
|
+
}
|
|
21
|
+
else if (typeof msg.payload !== "string") {
|
|
22
|
+
msg.payload = msg.payload.toString();
|
|
23
|
+
}
|
|
24
|
+
msg.payload = new Buffer(msg.payload, "utf-8");
|
|
25
|
+
}
|
|
26
|
+
self.status({
|
|
27
|
+
fill: "blue",
|
|
28
|
+
shape: "ring",
|
|
29
|
+
text: "sending..."
|
|
30
|
+
});
|
|
31
|
+
try {
|
|
32
|
+
self.awsIot.device.publish(msg.topic || n.topic, msg.payload, options.qos, false).then(function (result, error) {
|
|
33
|
+
if (error) {
|
|
34
|
+
self.status({
|
|
35
|
+
fill: "red",
|
|
36
|
+
shape: "ring",
|
|
37
|
+
text: error.message
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
self.status({
|
|
42
|
+
fill: "green",
|
|
43
|
+
shape: "ring",
|
|
44
|
+
text: "done"
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
self.status({
|
|
51
|
+
fill: "red",
|
|
52
|
+
shape: "ring",
|
|
53
|
+
text: e.message
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
self.error("aws-mqtt out is not configured");
|
|
61
|
+
self.status({
|
|
62
|
+
fill: "red",
|
|
63
|
+
shape: "ring",
|
|
64
|
+
text: "not configured"
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}); };
|
|
69
|
+
exports.buildNodeOutFunction = buildNodeOutFunction;
|
|
70
|
+
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AI,EAAE,KAAK;gBACX,KAAK,EAAE,MAAM;gBACb,IAAI,EAAE,gBAAgB;aACzB,CAAC,CAAC;SACN;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,EA7D4C,CA6D5C,CAAA;AA7DO,QAAA,oBAAoB,wBA6D3B"}
|
package/dist/tillit-node.js
CHANGED
|
@@ -1,335 +1,13 @@
|
|
|
1
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
var decoder = new TextDecoder('utf8');
|
|
3
|
+
var node_api_1 = require("./nodes/node-api");
|
|
4
|
+
var node_out_1 = require("./nodes/node-out");
|
|
5
|
+
var node_in_1 = require("./nodes/node-in");
|
|
6
|
+
var node_broker_1 = require("./nodes/node-broker");
|
|
47
7
|
module.exports = function (RED) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
RED.nodes.createNode(this, n);
|
|
53
|
-
this.clientId = process.env.CLIENT_ID || n.thingId;
|
|
54
|
-
this.environment = (_a = n.environment) !== null && _a !== void 0 ? _a : process.env.ENVIRONMENT;
|
|
55
|
-
this.endpoint = process.env.IOT_ENDPOINT || (0, utils_1.mqttEndpoint)(n.environment);
|
|
56
|
-
var username = n.username, tenant = n.tenant, password = n.password;
|
|
57
|
-
username = username !== null && username !== void 0 ? username : process.env.USERNAME;
|
|
58
|
-
this.password = password !== null && password !== void 0 ? password : process.env.PASSWORD;
|
|
59
|
-
this.tenant = tenant !== null && tenant !== void 0 ? tenant : process.env.TENANT;
|
|
60
|
-
this.username = "".concat(username, "@").concat(tenant, ".tillit.cloud");
|
|
61
|
-
if (process.env.EDGE_BUCKET && n.thingId) {
|
|
62
|
-
(0, edge_from_s3_1.downloadAndUnzipEdge)(workingDir, n.thingId);
|
|
63
|
-
}
|
|
64
|
-
var self = this;
|
|
65
|
-
this.connect = function (clientId, reconnect, callback) {
|
|
66
|
-
clientId = n.thingId.trim();
|
|
67
|
-
if (!self.device || reconnect) {
|
|
68
|
-
self.log("Attempt to connect to with " + clientId + " from: " + _this.endpoint);
|
|
69
|
-
var thingCert = process.env.THING_CERT || n.thingCert || (workingDir + n.thingId + '/tillitEdgeConfig/thingCert.crt');
|
|
70
|
-
var privKey = process.env.PRIV_KEY || n.privKey || (workingDir + n.thingId + '/tillitEdgeConfig/privKey.key');
|
|
71
|
-
var rootCa = process.env.ROOT_CA || n.rootCa || (workingDir + n.thingId + '/tillitEdgeConfig/rootCA.pem');
|
|
72
|
-
self.log("Using the certificates that are presented as follows:");
|
|
73
|
-
self.log(" - keyPath : " + privKey);
|
|
74
|
-
self.log(" - certPath : " + thingCert);
|
|
75
|
-
self.log(" - caPath : " + rootCa);
|
|
76
|
-
var configBuilder = aws_iot_device_sdk_v2_1.iot.AwsIotMqttConnectionConfigBuilder.new_mtls_builder_from_path(thingCert, privKey);
|
|
77
|
-
configBuilder.with_certificate_authority_from_path(undefined, rootCa);
|
|
78
|
-
configBuilder.with_clean_session(false);
|
|
79
|
-
configBuilder.with_client_id(clientId || "test-" + Math.floor(Math.random() * 100000000));
|
|
80
|
-
configBuilder.with_endpoint(self.endpoint);
|
|
81
|
-
configBuilder.with_keep_alive_seconds(20);
|
|
82
|
-
var config = configBuilder.build();
|
|
83
|
-
console.log(JSON.stringify(config));
|
|
84
|
-
var client = new aws_iot_device_sdk_v2_1.mqtt.MqttClient();
|
|
85
|
-
self.device = client.new_connection(config);
|
|
86
|
-
self.device.connect().catch(function (error) {
|
|
87
|
-
console.log("Connect error: " + error);
|
|
88
|
-
}).then(function (connected, err) {
|
|
89
|
-
console.log(err);
|
|
90
|
-
});
|
|
91
|
-
if (self.device) {
|
|
92
|
-
self.device.on('connect', function () {
|
|
93
|
-
callback('connected');
|
|
94
|
-
});
|
|
95
|
-
self.device.on('reconnect', function () {
|
|
96
|
-
callback('reconnected');
|
|
97
|
-
});
|
|
98
|
-
self.device.on('interrupt', function (error) {
|
|
99
|
-
callback('interrupt', error);
|
|
100
|
-
});
|
|
101
|
-
self.device.on('resume', function (error) {
|
|
102
|
-
callback('resume', error);
|
|
103
|
-
});
|
|
104
|
-
self.device.on('error', function (error) {
|
|
105
|
-
callback('error', error);
|
|
106
|
-
});
|
|
107
|
-
self.device.on('offline', function () {
|
|
108
|
-
callback('offline');
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
callback('created');
|
|
112
|
-
}
|
|
113
|
-
else if (self.device) {
|
|
114
|
-
callback('ready');
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
self.on('close', function () {
|
|
118
|
-
self.log("closed " + self.clientId + " ok");
|
|
119
|
-
if (self.device) {
|
|
120
|
-
self.device.disconnect();
|
|
121
|
-
}
|
|
122
|
-
self.device = null;
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
function awsMqttNodeIn(n) {
|
|
126
|
-
RED.nodes.createNode(this, n);
|
|
127
|
-
this.myDevice = n.device;
|
|
128
|
-
this.awsIot = RED.nodes.getNode(this.myDevice);
|
|
129
|
-
var self = this;
|
|
130
|
-
if (self.awsIot) {
|
|
131
|
-
self.status({
|
|
132
|
-
fill: "yellow",
|
|
133
|
-
shape: "ring",
|
|
134
|
-
text: "subscribing..."
|
|
135
|
-
});
|
|
136
|
-
self.awsIot.connect(null, null, function (event, error) {
|
|
137
|
-
if (event == "connected") {
|
|
138
|
-
var topic = self.awsIot.tenant + n.topic;
|
|
139
|
-
self.awsIot.device.unsubscribe(topic);
|
|
140
|
-
var onMessage = function (topic, payload, dup, qos, retain) {
|
|
141
|
-
var json = JSON.parse(decoder.decode(payload));
|
|
142
|
-
self.log("RECV< " + topic + JSON.stringify(json));
|
|
143
|
-
self.send({
|
|
144
|
-
topic: topic,
|
|
145
|
-
payload: json
|
|
146
|
-
});
|
|
147
|
-
};
|
|
148
|
-
try {
|
|
149
|
-
self.awsIot.device.subscribe(topic, aws_iot_device_sdk_v2_1.mqtt.QoS.AtLeastOnce, onMessage);
|
|
150
|
-
self.status({
|
|
151
|
-
fill: "green",
|
|
152
|
-
shape: "ring",
|
|
153
|
-
text: "subscribed"
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
catch (error) {
|
|
157
|
-
self.status({
|
|
158
|
-
fill: "error",
|
|
159
|
-
shape: "ring",
|
|
160
|
-
text: error.message
|
|
161
|
-
});
|
|
162
|
-
self.awsIot.device.on('message');
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
else if (event == "error") {
|
|
166
|
-
self.status({
|
|
167
|
-
fill: "error",
|
|
168
|
-
shape: "ring",
|
|
169
|
-
text: error.message
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
else if (event == 'interrupt') {
|
|
173
|
-
self.status({
|
|
174
|
-
fill: "error",
|
|
175
|
-
shape: "ring",
|
|
176
|
-
text: 'Connection lost'
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
else if (event == 'resume') {
|
|
180
|
-
self.status({
|
|
181
|
-
fill: "green",
|
|
182
|
-
shape: "ring",
|
|
183
|
-
text: "subscribed"
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
self.error("aws-mqtt in is not configured");
|
|
190
|
-
self.status({
|
|
191
|
-
fill: "red",
|
|
192
|
-
shape: "ring",
|
|
193
|
-
text: "not configured"
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
function awsMqttNodeOut(n) {
|
|
198
|
-
RED.nodes.createNode(this, n);
|
|
199
|
-
this.myDevice = n.device;
|
|
200
|
-
this.awsIot = RED.nodes.getNode(this.myDevice);
|
|
201
|
-
var self = this;
|
|
202
|
-
var options = {
|
|
203
|
-
qos: parseInt(n.qos) || 0
|
|
204
|
-
};
|
|
205
|
-
self.on("input", function (msg) {
|
|
206
|
-
if (self.awsIot) {
|
|
207
|
-
self.awsIot.connect(msg.clientId, msg.reconnect, function (event, error) {
|
|
208
|
-
if ((event == "ready" || event == "created")) {
|
|
209
|
-
if (!Buffer.isBuffer(msg.payload)) {
|
|
210
|
-
if (typeof msg.payload === "object") {
|
|
211
|
-
msg.payload = JSON.stringify(msg.payload);
|
|
212
|
-
}
|
|
213
|
-
else if (typeof msg.payload !== "string") {
|
|
214
|
-
msg.payload = msg.payload.toString();
|
|
215
|
-
}
|
|
216
|
-
msg.payload = new Buffer(msg.payload, "utf-8");
|
|
217
|
-
}
|
|
218
|
-
self.status({
|
|
219
|
-
fill: "blue",
|
|
220
|
-
shape: "ring",
|
|
221
|
-
text: "sending..."
|
|
222
|
-
});
|
|
223
|
-
self.log("SEND> " + msg.topic || n.topic + " " + msg.payload);
|
|
224
|
-
self.awsIot.device.publish(msg.topic || n.topic, msg.payload, options.qos, false).then(function (result, error) {
|
|
225
|
-
if (error) {
|
|
226
|
-
self.status({
|
|
227
|
-
fill: "red",
|
|
228
|
-
shape: "ring",
|
|
229
|
-
text: error.message
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
self.status({
|
|
234
|
-
fill: "green",
|
|
235
|
-
shape: "ring",
|
|
236
|
-
text: "done"
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
else {
|
|
244
|
-
self.error("aws-mqtt out is not configured");
|
|
245
|
-
self.status({
|
|
246
|
-
fill: "red",
|
|
247
|
-
shape: "ring",
|
|
248
|
-
text: "not configured"
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
function apiCall(n) {
|
|
254
|
-
RED.nodes.createNode(this, n);
|
|
255
|
-
this.myDevice = n.device;
|
|
256
|
-
this.connection = RED.nodes.getNode(this.myDevice);
|
|
257
|
-
var _a = this.connection, environment = _a.environment, tenant = _a.tenant, username = _a.username, password = _a.password;
|
|
258
|
-
var self = this;
|
|
259
|
-
self.on("input", function (msg) {
|
|
260
|
-
var _a;
|
|
261
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
262
|
-
var endpoint, url, method, ops, response, error_1;
|
|
263
|
-
return __generator(this, function (_b) {
|
|
264
|
-
switch (_b.label) {
|
|
265
|
-
case 0:
|
|
266
|
-
endpoint = (_a = msg.endpoint) !== null && _a !== void 0 ? _a : n.endpoint;
|
|
267
|
-
url = (0, utils_1.hostname)(environment, tenant) + '/api/' + endpoint;
|
|
268
|
-
method = n.method;
|
|
269
|
-
self.status({
|
|
270
|
-
fill: "blue",
|
|
271
|
-
shape: "ring",
|
|
272
|
-
text: "loading..."
|
|
273
|
-
});
|
|
274
|
-
_b.label = 1;
|
|
275
|
-
case 1:
|
|
276
|
-
_b.trys.push([1, 3, , 4]);
|
|
277
|
-
ops = {
|
|
278
|
-
method: method,
|
|
279
|
-
username: username,
|
|
280
|
-
password: password
|
|
281
|
-
};
|
|
282
|
-
if (msg.payload) {
|
|
283
|
-
if (['POST', 'PUT'].includes(method)) {
|
|
284
|
-
ops['json'] = msg.payload;
|
|
285
|
-
}
|
|
286
|
-
else if (typeof msg.payload === 'object') {
|
|
287
|
-
ops['searchParams'] = msg.payload;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
return [4 /*yield*/, (0, got_1.default)(url, ops)];
|
|
291
|
-
case 2:
|
|
292
|
-
response = _b.sent();
|
|
293
|
-
// const data = await response.json();
|
|
294
|
-
self.status({
|
|
295
|
-
fill: "green",
|
|
296
|
-
shape: "ring",
|
|
297
|
-
text: response.statusCode
|
|
298
|
-
});
|
|
299
|
-
try {
|
|
300
|
-
self.send([{
|
|
301
|
-
topic: msg.topic,
|
|
302
|
-
payload: response.body ? JSON.parse(response.body) : null
|
|
303
|
-
}, null]);
|
|
304
|
-
}
|
|
305
|
-
catch (e) {
|
|
306
|
-
self.send([null, {
|
|
307
|
-
topic: msg.topic,
|
|
308
|
-
payload: response.body
|
|
309
|
-
}]);
|
|
310
|
-
}
|
|
311
|
-
return [3 /*break*/, 4];
|
|
312
|
-
case 3:
|
|
313
|
-
error_1 = _b.sent();
|
|
314
|
-
self.status({
|
|
315
|
-
fill: "red",
|
|
316
|
-
shape: "ring",
|
|
317
|
-
text: error_1.message
|
|
318
|
-
});
|
|
319
|
-
self.send([null, {
|
|
320
|
-
topic: msg.topic,
|
|
321
|
-
payload: error_1.response.body ? JSON.parse(error_1.response.body) : { message: error_1.message }
|
|
322
|
-
}]);
|
|
323
|
-
return [3 /*break*/, 4];
|
|
324
|
-
case 4: return [2 /*return*/];
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
});
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
RED.nodes.registerType("tillit-api", apiCall);
|
|
331
|
-
RED.nodes.registerType("tillit-out", awsMqttNodeOut);
|
|
332
|
-
RED.nodes.registerType("tillit-in", awsMqttNodeIn);
|
|
333
|
-
RED.nodes.registerType("tillit-node-connection", awsNodeBroker);
|
|
8
|
+
RED.nodes.registerType("tillit-api", (0, node_api_1.buildApiFunction)(RED));
|
|
9
|
+
RED.nodes.registerType("tillit-out", (0, node_out_1.buildNodeOutFunction)(RED));
|
|
10
|
+
RED.nodes.registerType("tillit-in", (0, node_in_1.buildNodeInFunction)(RED));
|
|
11
|
+
RED.nodes.registerType("tillit-node-connection", (0, node_broker_1.buildNodeBrokerFunction)(RED));
|
|
334
12
|
};
|
|
335
13
|
//# sourceMappingURL=tillit-node.js.map
|
package/dist/tillit-node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tillit-node.js","sourceRoot":"","sources":["../src/tillit-node.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+DAAgD;AAChD,wCAAsD;AACtD,4CAAsB;AACtB,sDAA2D;AAC3D,IAAM,OAAO,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;AACxC,MAAM,CAAC,OAAO,GAAG,UAAU,GAAQ;IAE/B,IAAM,UAAU,GAAG,uBAAuB,CAAC;IAE3C,SAAS,aAAa,CAAC,CAAmB;QAA1C,iBA+EC;;QA9EG,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAC9B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,CAAC,OAAO,CAAC;QACnD,IAAI,CAAC,WAAW,GAAG,MAAA,CAAC,CAAC,WAAW,mCAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;QAC5D,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,IAAA,oBAAY,EAAC,CAAC,CAAC,WAAW,CAAC,CAAC;QACnE,IAAA,QAAQ,GAAsB,CAAC,SAAvB,EAAE,MAAM,GAAc,CAAC,OAAf,EAAE,QAAQ,GAAI,CAAC,SAAL,CAAM;QACrC,QAAQ,GAAG,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;QAC5C,IAAI,CAAC,QAAQ,GAAG,QAAQ,aAAR,QAA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