@cutos/core 4.0.9 → 4.2.0
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/README.md +2 -1
- package/dist/cutos.cjs.js +6 -39
- package/dist/cutos.esm.js +6 -39
- package/package.json +1 -1
- package/types/index.d.ts +1 -9
package/README.md
CHANGED
|
@@ -25,7 +25,8 @@ Hardware Device/Driver APIs remain available as the compatibility layer, but new
|
|
|
25
25
|
### Database
|
|
26
26
|
|
|
27
27
|
- `CoreClass.Database` provides Promise-first access to the CUTOS local database.
|
|
28
|
-
- `Database.Table` supports table creation, insert, update, delete, query
|
|
28
|
+
- `Database.Table` supports local table creation, insert, update, delete, query and synchronization metadata.
|
|
29
|
+
- Gateway data replication is provided by the separate `@cutos/mirror` package. Core has no Gateway connection or automatic forwarding hooks.
|
|
29
30
|
|
|
30
31
|
### Notification
|
|
31
32
|
|
package/dist/cutos.cjs.js
CHANGED
|
@@ -398,7 +398,7 @@ const cutosAPI$2 = {
|
|
|
398
398
|
var cutosApi = cutosAPI$2;
|
|
399
399
|
|
|
400
400
|
var name = "@cutos/core";
|
|
401
|
-
var version = "4.0
|
|
401
|
+
var version = "4.2.0";
|
|
402
402
|
var description = "The CUTOS (CUT Operating System) Core API is a JavaScript library that provides essential functionalities for LWA (Local Web Application) edge computing and communication in the CUTOS ecosystem. ";
|
|
403
403
|
var main = "dist/cutos.cjs.js";
|
|
404
404
|
var module$1 = "dist/cutos.esm.js";
|
|
@@ -658,9 +658,6 @@ let Database$1 = class Database {
|
|
|
658
658
|
return maybePromise(callback, cb => publishRequest(cutosAPI$1.CORE.DATABASE, cb, body));
|
|
659
659
|
}
|
|
660
660
|
|
|
661
|
-
setupMirror(gwIPC, lwaName, confirm = false) {
|
|
662
|
-
this.mirror = {gwIPC, lwaName, confirm};
|
|
663
|
-
}
|
|
664
661
|
};
|
|
665
662
|
|
|
666
663
|
Database$1.Table = class {
|
|
@@ -707,7 +704,7 @@ Database$1.Table = class {
|
|
|
707
704
|
keyName: opts.keyName
|
|
708
705
|
};
|
|
709
706
|
|
|
710
|
-
return maybePromise(callback, cb =>
|
|
707
|
+
return maybePromise(callback, cb => publishRequest(cutosAPI$1.CORE.DATABASE, cb, body));
|
|
711
708
|
}
|
|
712
709
|
|
|
713
710
|
/**
|
|
@@ -725,7 +722,7 @@ Database$1.Table = class {
|
|
|
725
722
|
let body = {
|
|
726
723
|
db: this.db, cmd: "db.table.insert", name: this.name, value: value, tid: opts?.tid
|
|
727
724
|
};
|
|
728
|
-
return maybePromise(callback, cb =>
|
|
725
|
+
return maybePromise(callback, cb => publishRequest(cutosAPI$1.CORE.DATABASE, cb, body));
|
|
729
726
|
}
|
|
730
727
|
|
|
731
728
|
insertById(id, value, opts, callback) {
|
|
@@ -737,7 +734,7 @@ Database$1.Table = class {
|
|
|
737
734
|
let body = {
|
|
738
735
|
db: this.db, cmd: "db.table.insertById", name: this.name, id: id, value: value, tid: opts?.tid
|
|
739
736
|
};
|
|
740
|
-
return maybePromise(callback, cb =>
|
|
737
|
+
return maybePromise(callback, cb => publishRequest(cutosAPI$1.CORE.DATABASE, cb, body));
|
|
741
738
|
}
|
|
742
739
|
|
|
743
740
|
/**
|
|
@@ -756,7 +753,7 @@ Database$1.Table = class {
|
|
|
756
753
|
let body = {
|
|
757
754
|
db: this.db, cmd: "db.table.insertByKey", name: this.name, key: key, value: value, tid: opts?.tid
|
|
758
755
|
};
|
|
759
|
-
return maybePromise(callback, cb =>
|
|
756
|
+
return maybePromise(callback, cb => publishRequest(cutosAPI$1.CORE.DATABASE, cb, body));
|
|
760
757
|
}
|
|
761
758
|
|
|
762
759
|
/**
|
|
@@ -838,7 +835,7 @@ Database$1.Table = class {
|
|
|
838
835
|
opts = {limit: 100};
|
|
839
836
|
}
|
|
840
837
|
if (!opts) opts = {};
|
|
841
|
-
if (opts.limit <= 0) opts.limit = 100;
|
|
838
|
+
if (!Number.isFinite(opts.limit) || opts.limit <= 0) opts.limit = 100;
|
|
842
839
|
|
|
843
840
|
let body = {
|
|
844
841
|
db: this.db, cmd: "db.table.queryUnsynced", name: this.name, limit: opts.limit
|
|
@@ -869,36 +866,6 @@ Database$1.Table = class {
|
|
|
869
866
|
return maybePromise(callback, cb => publishRequest(cutosAPI$1.CORE.DATABASE, cb, body));
|
|
870
867
|
}
|
|
871
868
|
|
|
872
|
-
publishRequestMirror(topic, callback, body) {
|
|
873
|
-
let mirror = this.database.mirror;
|
|
874
|
-
let cb = callback;
|
|
875
|
-
if (mirror && mirror.gwIPC) { // mirror enabled
|
|
876
|
-
cb = (dbResult) => {
|
|
877
|
-
let confirmCallback = !mirror.confirm ? null : (gwResult) => {
|
|
878
|
-
if (gwResult.status === "success") {
|
|
879
|
-
this.sync(dbResult.row);
|
|
880
|
-
}
|
|
881
|
-
};
|
|
882
|
-
if (dbResult.status === true) {
|
|
883
|
-
switch (body.cmd) {
|
|
884
|
-
case "db.table.create":
|
|
885
|
-
break;
|
|
886
|
-
case "db.table.insert":
|
|
887
|
-
body.id = dbResult.msg.row;
|
|
888
|
-
body.timestamp = dbResult.msg.timestamp;
|
|
889
|
-
break;
|
|
890
|
-
case "db.table.insertById":
|
|
891
|
-
case "db.table.insertByKey":
|
|
892
|
-
body.timestamp = dbResult.msg.timestamp;
|
|
893
|
-
break;
|
|
894
|
-
}
|
|
895
|
-
mirror.gwIPC.mirror(body, confirmCallback, {lwaName: mirror.lwaName});
|
|
896
|
-
}
|
|
897
|
-
callback && callback(dbResult);
|
|
898
|
-
};
|
|
899
|
-
}
|
|
900
|
-
return publishRequest(topic, cb, body);
|
|
901
|
-
}
|
|
902
869
|
};
|
|
903
870
|
|
|
904
871
|
class Logger {
|
package/dist/cutos.esm.js
CHANGED
|
@@ -690,7 +690,7 @@ const cutosAPI$2 = {
|
|
|
690
690
|
var cutosApi = cutosAPI$2;
|
|
691
691
|
|
|
692
692
|
var name = "@cutos/core";
|
|
693
|
-
var version = "4.0
|
|
693
|
+
var version = "4.2.0";
|
|
694
694
|
var description = "The CUTOS (CUT Operating System) Core API is a JavaScript library that provides essential functionalities for LWA (Local Web Application) edge computing and communication in the CUTOS ecosystem. ";
|
|
695
695
|
var main = "dist/cutos.cjs.js";
|
|
696
696
|
var module = "dist/cutos.esm.js";
|
|
@@ -950,9 +950,6 @@ let Database$1 = class Database {
|
|
|
950
950
|
return maybePromise(callback, cb => publishRequest(cutosAPI$1.CORE.DATABASE, cb, body));
|
|
951
951
|
}
|
|
952
952
|
|
|
953
|
-
setupMirror(gwIPC, lwaName, confirm = false) {
|
|
954
|
-
this.mirror = {gwIPC, lwaName, confirm};
|
|
955
|
-
}
|
|
956
953
|
};
|
|
957
954
|
|
|
958
955
|
Database$1.Table = class {
|
|
@@ -999,7 +996,7 @@ Database$1.Table = class {
|
|
|
999
996
|
keyName: opts.keyName
|
|
1000
997
|
};
|
|
1001
998
|
|
|
1002
|
-
return maybePromise(callback, cb =>
|
|
999
|
+
return maybePromise(callback, cb => publishRequest(cutosAPI$1.CORE.DATABASE, cb, body));
|
|
1003
1000
|
}
|
|
1004
1001
|
|
|
1005
1002
|
/**
|
|
@@ -1017,7 +1014,7 @@ Database$1.Table = class {
|
|
|
1017
1014
|
let body = {
|
|
1018
1015
|
db: this.db, cmd: "db.table.insert", name: this.name, value: value, tid: opts?.tid
|
|
1019
1016
|
};
|
|
1020
|
-
return maybePromise(callback, cb =>
|
|
1017
|
+
return maybePromise(callback, cb => publishRequest(cutosAPI$1.CORE.DATABASE, cb, body));
|
|
1021
1018
|
}
|
|
1022
1019
|
|
|
1023
1020
|
insertById(id, value, opts, callback) {
|
|
@@ -1029,7 +1026,7 @@ Database$1.Table = class {
|
|
|
1029
1026
|
let body = {
|
|
1030
1027
|
db: this.db, cmd: "db.table.insertById", name: this.name, id: id, value: value, tid: opts?.tid
|
|
1031
1028
|
};
|
|
1032
|
-
return maybePromise(callback, cb =>
|
|
1029
|
+
return maybePromise(callback, cb => publishRequest(cutosAPI$1.CORE.DATABASE, cb, body));
|
|
1033
1030
|
}
|
|
1034
1031
|
|
|
1035
1032
|
/**
|
|
@@ -1048,7 +1045,7 @@ Database$1.Table = class {
|
|
|
1048
1045
|
let body = {
|
|
1049
1046
|
db: this.db, cmd: "db.table.insertByKey", name: this.name, key: key, value: value, tid: opts?.tid
|
|
1050
1047
|
};
|
|
1051
|
-
return maybePromise(callback, cb =>
|
|
1048
|
+
return maybePromise(callback, cb => publishRequest(cutosAPI$1.CORE.DATABASE, cb, body));
|
|
1052
1049
|
}
|
|
1053
1050
|
|
|
1054
1051
|
/**
|
|
@@ -1130,7 +1127,7 @@ Database$1.Table = class {
|
|
|
1130
1127
|
opts = {limit: 100};
|
|
1131
1128
|
}
|
|
1132
1129
|
if (!opts) opts = {};
|
|
1133
|
-
if (opts.limit <= 0) opts.limit = 100;
|
|
1130
|
+
if (!Number.isFinite(opts.limit) || opts.limit <= 0) opts.limit = 100;
|
|
1134
1131
|
|
|
1135
1132
|
let body = {
|
|
1136
1133
|
db: this.db, cmd: "db.table.queryUnsynced", name: this.name, limit: opts.limit
|
|
@@ -1161,36 +1158,6 @@ Database$1.Table = class {
|
|
|
1161
1158
|
return maybePromise(callback, cb => publishRequest(cutosAPI$1.CORE.DATABASE, cb, body));
|
|
1162
1159
|
}
|
|
1163
1160
|
|
|
1164
|
-
publishRequestMirror(topic, callback, body) {
|
|
1165
|
-
let mirror = this.database.mirror;
|
|
1166
|
-
let cb = callback;
|
|
1167
|
-
if (mirror && mirror.gwIPC) { // mirror enabled
|
|
1168
|
-
cb = (dbResult) => {
|
|
1169
|
-
let confirmCallback = !mirror.confirm ? null : (gwResult) => {
|
|
1170
|
-
if (gwResult.status === "success") {
|
|
1171
|
-
this.sync(dbResult.row);
|
|
1172
|
-
}
|
|
1173
|
-
};
|
|
1174
|
-
if (dbResult.status === true) {
|
|
1175
|
-
switch (body.cmd) {
|
|
1176
|
-
case "db.table.create":
|
|
1177
|
-
break;
|
|
1178
|
-
case "db.table.insert":
|
|
1179
|
-
body.id = dbResult.msg.row;
|
|
1180
|
-
body.timestamp = dbResult.msg.timestamp;
|
|
1181
|
-
break;
|
|
1182
|
-
case "db.table.insertById":
|
|
1183
|
-
case "db.table.insertByKey":
|
|
1184
|
-
body.timestamp = dbResult.msg.timestamp;
|
|
1185
|
-
break;
|
|
1186
|
-
}
|
|
1187
|
-
mirror.gwIPC.mirror(body, confirmCallback, {lwaName: mirror.lwaName});
|
|
1188
|
-
}
|
|
1189
|
-
callback && callback(dbResult);
|
|
1190
|
-
};
|
|
1191
|
-
}
|
|
1192
|
-
return publishRequest(topic, cb, body);
|
|
1193
|
-
}
|
|
1194
1161
|
};
|
|
1195
1162
|
|
|
1196
1163
|
class Logger {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cutos/core",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "The CUTOS (CUT Operating System) Core API is a JavaScript library that provides essential functionalities for LWA (Local Web Application) edge computing and communication in the CUTOS ecosystem. ",
|
|
5
5
|
"main": "dist/cutos.cjs.js",
|
|
6
6
|
"module": "dist/cutos.esm.js",
|
package/types/index.d.ts
CHANGED
|
@@ -77,11 +77,6 @@ export interface DatabaseTableOptions {
|
|
|
77
77
|
[key: string]: unknown;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
export interface MirrorOptions {
|
|
81
|
-
lwaName?: string;
|
|
82
|
-
[key: string]: unknown;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
80
|
export class IPC {
|
|
86
81
|
constructor(destAddress?: string);
|
|
87
82
|
sendTo<TArgs = unknown, TResult = unknown>(
|
|
@@ -91,7 +86,7 @@ export class IPC {
|
|
|
91
86
|
): boolean;
|
|
92
87
|
call<TArgs = unknown, TResult = unknown>(
|
|
93
88
|
channel: string,
|
|
94
|
-
args
|
|
89
|
+
args: TArgs | undefined,
|
|
95
90
|
callback: CutosCallback<TResult>
|
|
96
91
|
): boolean;
|
|
97
92
|
call<TArgs = unknown, TResult = unknown>(channel: string, args?: TArgs): Promise<TResult>;
|
|
@@ -283,7 +278,6 @@ export class Database {
|
|
|
283
278
|
connect<TResult = unknown>(): Promise<TResult>;
|
|
284
279
|
run<TResult = unknown>(sql: string, callback: CutosCallback<TResult>): boolean;
|
|
285
280
|
run<TResult = unknown>(sql: string): Promise<TResult>;
|
|
286
|
-
setupMirror(gwIPC: unknown, lwaName: string, confirm?: boolean): void;
|
|
287
281
|
static Table: typeof DatabaseTable;
|
|
288
282
|
}
|
|
289
283
|
|
|
@@ -410,5 +404,3 @@ export const CoreSimulator: CoreSimulator;
|
|
|
410
404
|
export const CutosMock: CutosMock;
|
|
411
405
|
export function installCutosMock(options?: CutosMockOptions): CutosMock;
|
|
412
406
|
export function uninstallCutosMock(): void;
|
|
413
|
-
export { CutosError };
|
|
414
|
-
export { DeviceCapabilityBase, DeviceProviderBase };
|