@cutos/core 0.0.13 → 0.0.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/cutos.cjs.js +13 -27
- package/dist/cutos.esm.js +13 -27
- package/package.json +1 -1
package/dist/cutos.cjs.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var crypto = require('crypto');
|
|
6
6
|
var require$$1 = require('mqtt');
|
|
7
|
-
|
|
7
|
+
require('lodash');
|
|
8
8
|
var require$$0$1 = require('qs');
|
|
9
9
|
|
|
10
10
|
function getAugmentedNamespace(n) {
|
|
@@ -411,7 +411,7 @@ if(typeof window !== 'undefined') {
|
|
|
411
411
|
var utils = config$1;
|
|
412
412
|
|
|
413
413
|
var name = "@cutos/core";
|
|
414
|
-
var version = "0.0.
|
|
414
|
+
var version = "0.0.14";
|
|
415
415
|
var description = "";
|
|
416
416
|
var main = "dist/cutos.cjs.js";
|
|
417
417
|
var module$1 = "dist/cutos.esm.js";
|
|
@@ -461,7 +461,6 @@ var require$$5 = {
|
|
|
461
461
|
|
|
462
462
|
const {v4: uuidv4} = require$$0;
|
|
463
463
|
const mqtt = require$$1;
|
|
464
|
-
const _ = require$$2;
|
|
465
464
|
const cutosAPI = cutosApi;
|
|
466
465
|
const config = utils;
|
|
467
466
|
const callbackMap = new Map();
|
|
@@ -492,14 +491,7 @@ class Database {
|
|
|
492
491
|
KEY_TYPE_TEXT = "TEXT";
|
|
493
492
|
KEY_TYPE_INTEGER = "INTEGER";
|
|
494
493
|
|
|
495
|
-
constructor(db, callback
|
|
496
|
-
retentionTime: 48,
|
|
497
|
-
mirror: {
|
|
498
|
-
gwIPC: null,
|
|
499
|
-
lwaName: "lwa-default",
|
|
500
|
-
confirm: false
|
|
501
|
-
}
|
|
502
|
-
}) {
|
|
494
|
+
constructor(db, callback) {
|
|
503
495
|
// sub class
|
|
504
496
|
let database = this;
|
|
505
497
|
this.Table = class {
|
|
@@ -610,7 +602,7 @@ class Database {
|
|
|
610
602
|
publishRequestMirror(topic, callback, body) {
|
|
611
603
|
let mirror = database.mirror;
|
|
612
604
|
let cb = callback;
|
|
613
|
-
if (mirror.gwIPC) { // mirror enabled
|
|
605
|
+
if (mirror && mirror.gwIPC) { // mirror enabled
|
|
614
606
|
cb = (dbResult) => {
|
|
615
607
|
let confirmCallback = !mirror.confirm ? null : (gwResult) => {
|
|
616
608
|
if (gwResult.status === "success") {
|
|
@@ -639,8 +631,6 @@ class Database {
|
|
|
639
631
|
}
|
|
640
632
|
};
|
|
641
633
|
this.db = db;
|
|
642
|
-
this.retentionTime = opts.retentionTime ? opts.retentionTime : 48;// default 48 hours
|
|
643
|
-
this.mirror = opts.mirror;
|
|
644
634
|
let body = {
|
|
645
635
|
cmd: "db.connect", db: this.db
|
|
646
636
|
};
|
|
@@ -657,6 +647,10 @@ class Database {
|
|
|
657
647
|
createTable(name, callback, retentionTime, keyType = 'INTEGER', keyName = 'id') {
|
|
658
648
|
return new this.Table(null, name, callback, retentionTime, keyType, keyName);
|
|
659
649
|
}
|
|
650
|
+
|
|
651
|
+
setupMirror(gwIPC, lwaName, confirm = false) {
|
|
652
|
+
this.mirror = {gwIPC, lwaName, confirm};
|
|
653
|
+
}
|
|
660
654
|
}
|
|
661
655
|
|
|
662
656
|
class Logger {
|
|
@@ -974,6 +968,10 @@ const CoreAPI = {
|
|
|
974
968
|
return publishRequest(cutosAPI.CORE.SIGN_INFO, callback);
|
|
975
969
|
},
|
|
976
970
|
|
|
971
|
+
getDeviceInfo(callback) {
|
|
972
|
+
return publishRequest(cutosAPI.CORE.DEVICE_INFO, callback);
|
|
973
|
+
},
|
|
974
|
+
|
|
977
975
|
getSignGroupInfo(callback) {
|
|
978
976
|
return publishRequest(cutosAPI.CORE.SIGN_GROUP_INFO, callback);
|
|
979
977
|
},
|
|
@@ -995,19 +993,7 @@ const CoreAPI = {
|
|
|
995
993
|
},
|
|
996
994
|
|
|
997
995
|
getDatabase(db, callback) {
|
|
998
|
-
|
|
999
|
-
retentionTime: 48,
|
|
1000
|
-
mirror: {
|
|
1001
|
-
gwIPC: null,
|
|
1002
|
-
lwaName: "lwa-default",
|
|
1003
|
-
confirm: false
|
|
1004
|
-
}
|
|
1005
|
-
};
|
|
1006
|
-
if (typeof db === 'object') {
|
|
1007
|
-
_.merge(opts, db);
|
|
1008
|
-
db = opts.db;
|
|
1009
|
-
}
|
|
1010
|
-
return new Database(db, callback, opts);
|
|
996
|
+
return new Database(db, callback);
|
|
1011
997
|
},
|
|
1012
998
|
|
|
1013
999
|
getVolume(callback) {
|
package/dist/cutos.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import require$$1 from 'mqtt/dist/mqtt';
|
|
2
|
-
import
|
|
2
|
+
import 'lodash';
|
|
3
3
|
import require$$0$1 from 'qs';
|
|
4
4
|
|
|
5
5
|
function getAugmentedNamespace(n) {
|
|
@@ -703,7 +703,7 @@ if(typeof window !== 'undefined') {
|
|
|
703
703
|
var utils = config$1;
|
|
704
704
|
|
|
705
705
|
var name = "@cutos/core";
|
|
706
|
-
var version = "0.0.
|
|
706
|
+
var version = "0.0.14";
|
|
707
707
|
var description = "";
|
|
708
708
|
var main = "dist/cutos.cjs.js";
|
|
709
709
|
var module = "dist/cutos.esm.js";
|
|
@@ -753,7 +753,6 @@ var require$$5 = {
|
|
|
753
753
|
|
|
754
754
|
const {v4: uuidv4} = require$$0;
|
|
755
755
|
const mqtt = require$$1;
|
|
756
|
-
const _ = require$$2;
|
|
757
756
|
const cutosAPI = cutosApi;
|
|
758
757
|
const config = utils;
|
|
759
758
|
const callbackMap = new Map();
|
|
@@ -784,14 +783,7 @@ class Database {
|
|
|
784
783
|
KEY_TYPE_TEXT = "TEXT";
|
|
785
784
|
KEY_TYPE_INTEGER = "INTEGER";
|
|
786
785
|
|
|
787
|
-
constructor(db, callback
|
|
788
|
-
retentionTime: 48,
|
|
789
|
-
mirror: {
|
|
790
|
-
gwIPC: null,
|
|
791
|
-
lwaName: "lwa-default",
|
|
792
|
-
confirm: false
|
|
793
|
-
}
|
|
794
|
-
}) {
|
|
786
|
+
constructor(db, callback) {
|
|
795
787
|
// sub class
|
|
796
788
|
let database = this;
|
|
797
789
|
this.Table = class {
|
|
@@ -902,7 +894,7 @@ class Database {
|
|
|
902
894
|
publishRequestMirror(topic, callback, body) {
|
|
903
895
|
let mirror = database.mirror;
|
|
904
896
|
let cb = callback;
|
|
905
|
-
if (mirror.gwIPC) { // mirror enabled
|
|
897
|
+
if (mirror && mirror.gwIPC) { // mirror enabled
|
|
906
898
|
cb = (dbResult) => {
|
|
907
899
|
let confirmCallback = !mirror.confirm ? null : (gwResult) => {
|
|
908
900
|
if (gwResult.status === "success") {
|
|
@@ -931,8 +923,6 @@ class Database {
|
|
|
931
923
|
}
|
|
932
924
|
};
|
|
933
925
|
this.db = db;
|
|
934
|
-
this.retentionTime = opts.retentionTime ? opts.retentionTime : 48;// default 48 hours
|
|
935
|
-
this.mirror = opts.mirror;
|
|
936
926
|
let body = {
|
|
937
927
|
cmd: "db.connect", db: this.db
|
|
938
928
|
};
|
|
@@ -949,6 +939,10 @@ class Database {
|
|
|
949
939
|
createTable(name, callback, retentionTime, keyType = 'INTEGER', keyName = 'id') {
|
|
950
940
|
return new this.Table(null, name, callback, retentionTime, keyType, keyName);
|
|
951
941
|
}
|
|
942
|
+
|
|
943
|
+
setupMirror(gwIPC, lwaName, confirm = false) {
|
|
944
|
+
this.mirror = {gwIPC, lwaName, confirm};
|
|
945
|
+
}
|
|
952
946
|
}
|
|
953
947
|
|
|
954
948
|
class Logger {
|
|
@@ -1266,6 +1260,10 @@ const CoreAPI = {
|
|
|
1266
1260
|
return publishRequest(cutosAPI.CORE.SIGN_INFO, callback);
|
|
1267
1261
|
},
|
|
1268
1262
|
|
|
1263
|
+
getDeviceInfo(callback) {
|
|
1264
|
+
return publishRequest(cutosAPI.CORE.DEVICE_INFO, callback);
|
|
1265
|
+
},
|
|
1266
|
+
|
|
1269
1267
|
getSignGroupInfo(callback) {
|
|
1270
1268
|
return publishRequest(cutosAPI.CORE.SIGN_GROUP_INFO, callback);
|
|
1271
1269
|
},
|
|
@@ -1287,19 +1285,7 @@ const CoreAPI = {
|
|
|
1287
1285
|
},
|
|
1288
1286
|
|
|
1289
1287
|
getDatabase(db, callback) {
|
|
1290
|
-
|
|
1291
|
-
retentionTime: 48,
|
|
1292
|
-
mirror: {
|
|
1293
|
-
gwIPC: null,
|
|
1294
|
-
lwaName: "lwa-default",
|
|
1295
|
-
confirm: false
|
|
1296
|
-
}
|
|
1297
|
-
};
|
|
1298
|
-
if (typeof db === 'object') {
|
|
1299
|
-
_.merge(opts, db);
|
|
1300
|
-
db = opts.db;
|
|
1301
|
-
}
|
|
1302
|
-
return new Database(db, callback, opts);
|
|
1288
|
+
return new Database(db, callback);
|
|
1303
1289
|
},
|
|
1304
1290
|
|
|
1305
1291
|
getVolume(callback) {
|