ironflock 0.0.6 → 0.0.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/crossbar/index.js +6 -4
- package/dist/ironflock.d.ts +1 -0
- package/dist/ironflock.js +14 -1
- package/package.json +6 -5
- package/src/crossbar/index.ts +6 -4
- package/src/ironflock.ts +19 -1
package/dist/crossbar/index.js
CHANGED
|
@@ -59,12 +59,14 @@ var autobahn_1 = __importDefault(require("autobahn"));
|
|
|
59
59
|
var stream_1 = require("stream");
|
|
60
60
|
// import { MsgpackSerializer } from "./serializer";
|
|
61
61
|
var RESWARM_URL = process.env.RESWARM_URL;
|
|
62
|
-
var DATAPODS_WS_URI = "
|
|
63
|
-
var STUDIO_WS_URI = "
|
|
64
|
-
var
|
|
62
|
+
var DATAPODS_WS_URI = "wss://cbw.datapods.io/ws-ua-usr";
|
|
63
|
+
var STUDIO_WS_URI = "wss://cbw.ironflock.com/ws-ua-usr";
|
|
64
|
+
var STUDIO_WS_URI_OLD = "wss://cbw.record-evolution.com/ws-ua-usr";
|
|
65
|
+
var LOCALHOST_WS_URI = "ws://localhost:8080/ws-ua-usr";
|
|
65
66
|
var socketURIMap = {
|
|
66
67
|
"https://studio.datapods.io": DATAPODS_WS_URI,
|
|
67
|
-
"https://studio.
|
|
68
|
+
"https://studio.ironflock.com": STUDIO_WS_URI,
|
|
69
|
+
"https://studio.record-evolution.com": STUDIO_WS_URI_OLD,
|
|
68
70
|
"http://localhost:8085": LOCALHOST_WS_URI
|
|
69
71
|
};
|
|
70
72
|
var CrossbarConnection = /** @class */ (function (_super) {
|
package/dist/ironflock.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare class IronFlock {
|
|
|
12
12
|
private queue;
|
|
13
13
|
private _publish;
|
|
14
14
|
publish(topic: string, data: any): Promise<any>;
|
|
15
|
+
publishToTable(tablename: string, data: any): Promise<any>;
|
|
15
16
|
onConnect(cb: Function): void;
|
|
16
17
|
onDisconnect(cb: Function): void;
|
|
17
18
|
}
|
package/dist/ironflock.js
CHANGED
|
@@ -49,7 +49,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
50
|
exports.IronFlock = void 0;
|
|
51
51
|
var crossbar_1 = require("./crossbar");
|
|
52
|
-
var _a = process.env, DEVICE_SERIAL_NUMBER = _a.DEVICE_SERIAL_NUMBER, DEVICE_NAME = _a.DEVICE_NAME;
|
|
52
|
+
var _a = process.env, DEVICE_SERIAL_NUMBER = _a.DEVICE_SERIAL_NUMBER, DEVICE_NAME = _a.DEVICE_NAME, SWARM_KEY = _a.SWARM_KEY, APP_KEY = _a.APP_KEY;
|
|
53
53
|
var IronFlock = /** @class */ (function () {
|
|
54
54
|
function IronFlock(options) {
|
|
55
55
|
this.onConnectTasks = [];
|
|
@@ -142,6 +142,19 @@ var IronFlock = /** @class */ (function () {
|
|
|
142
142
|
var _this = this;
|
|
143
143
|
return this.queue(function () { return _this._publish.apply(_this, [topic, data]); });
|
|
144
144
|
};
|
|
145
|
+
IronFlock.prototype.publishToTable = function (tablename, data) {
|
|
146
|
+
if (data == null) {
|
|
147
|
+
throw new Error("null or undefined cannot be published as payload");
|
|
148
|
+
}
|
|
149
|
+
if (!SWARM_KEY) {
|
|
150
|
+
throw new Error("SWARM_KEY is not set as environment variable");
|
|
151
|
+
}
|
|
152
|
+
if (!APP_KEY) {
|
|
153
|
+
throw new Error("APP_KEY is not set as environment variable");
|
|
154
|
+
}
|
|
155
|
+
var topic = "".concat(SWARM_KEY, ".").concat(APP_KEY, ".").concat(tablename);
|
|
156
|
+
return this.publish(topic, data);
|
|
157
|
+
};
|
|
145
158
|
IronFlock.prototype.onConnect = function (cb) {
|
|
146
159
|
this.crossbarSession.on("connected", function () { return cb(); });
|
|
147
160
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ironflock",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Collect data in the IronFlock Storage architecture",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
18
|
"prepublish": "rm -rf dist && tsc",
|
|
19
|
-
"release": "npm version patch --tag-version-prefix='' && git push && git push --tag"
|
|
19
|
+
"release": "npm version patch --tag-version-prefix='' && git push && git push --tag",
|
|
20
|
+
"publish": "npm publish"
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|
|
22
23
|
"@types/autobahn": "^20.9.4",
|
|
@@ -25,14 +26,14 @@
|
|
|
25
26
|
},
|
|
26
27
|
"repository": {
|
|
27
28
|
"type": "git",
|
|
28
|
-
"url": "git+https://github.com/RecordEvolution/
|
|
29
|
+
"url": "git+https://github.com/RecordEvolution/ironflock-js.git"
|
|
29
30
|
},
|
|
30
31
|
"keywords": [
|
|
31
32
|
"ironflock",
|
|
32
33
|
"messaging"
|
|
33
34
|
],
|
|
34
35
|
"bugs": {
|
|
35
|
-
"url": "https://github.com/RecordEvolution/
|
|
36
|
+
"url": "https://github.com/RecordEvolution/ironflock-js/issues"
|
|
36
37
|
},
|
|
37
|
-
"homepage": "https://github.com/RecordEvolution/
|
|
38
|
+
"homepage": "https://github.com/RecordEvolution/ironflock-js#readme"
|
|
38
39
|
}
|
package/src/crossbar/index.ts
CHANGED
|
@@ -15,13 +15,15 @@ export type AuthPayload = {
|
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
const DATAPODS_WS_URI = "
|
|
19
|
-
const STUDIO_WS_URI = "
|
|
20
|
-
const
|
|
18
|
+
const DATAPODS_WS_URI = "wss://cbw.datapods.io/ws-ua-usr";
|
|
19
|
+
const STUDIO_WS_URI = "wss://cbw.ironflock.com/ws-ua-usr";
|
|
20
|
+
const STUDIO_WS_URI_OLD = "wss://cbw.record-evolution.com/ws-ua-usr";
|
|
21
|
+
const LOCALHOST_WS_URI = "ws://localhost:8080/ws-ua-usr";
|
|
21
22
|
|
|
22
23
|
const socketURIMap: Record<string, string> = {
|
|
23
24
|
"https://studio.datapods.io": DATAPODS_WS_URI,
|
|
24
|
-
"https://studio.
|
|
25
|
+
"https://studio.ironflock.com": STUDIO_WS_URI,
|
|
26
|
+
"https://studio.record-evolution.com": STUDIO_WS_URI_OLD,
|
|
25
27
|
"http://localhost:8085": LOCALHOST_WS_URI
|
|
26
28
|
};
|
|
27
29
|
|
package/src/ironflock.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CrossbarConnection } from "./crossbar";
|
|
2
2
|
|
|
3
|
-
const { DEVICE_SERIAL_NUMBER, DEVICE_NAME } = process.env;
|
|
3
|
+
const { DEVICE_SERIAL_NUMBER, DEVICE_NAME, SWARM_KEY, APP_KEY } = process.env;
|
|
4
4
|
|
|
5
5
|
type TOptions = {
|
|
6
6
|
quiet?: boolean;
|
|
@@ -81,6 +81,24 @@ export class IronFlock {
|
|
|
81
81
|
return this.queue(() => this._publish.apply(this, [topic, data]));
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
publishToTable(tablename: string, data: any) {
|
|
85
|
+
if (data == null) {
|
|
86
|
+
throw new Error("null or undefined cannot be published as payload");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (!SWARM_KEY) {
|
|
90
|
+
throw new Error("SWARM_KEY is not set as environment variable");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (!APP_KEY) {
|
|
94
|
+
throw new Error("APP_KEY is not set as environment variable");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const topic = `${SWARM_KEY}.${APP_KEY}.${tablename}`;
|
|
98
|
+
|
|
99
|
+
return this.publish(topic, data);
|
|
100
|
+
}
|
|
101
|
+
|
|
84
102
|
onConnect(cb: Function) {
|
|
85
103
|
this.crossbarSession.on("connected", () => cb());
|
|
86
104
|
}
|