@dnax/core 0.60.6 → 0.62.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/driver/mongo/rest.ts +9 -0
- package/lib/socket/instance.ts +11 -2
- package/package.json +1 -1
- package/types/index.ts +2 -1
package/driver/mongo/rest.ts
CHANGED
|
@@ -376,6 +376,7 @@ class useRest {
|
|
|
376
376
|
|
|
377
377
|
if (col?.customApi?.insertOne && useCustomApi) {
|
|
378
378
|
let result = await col?.customApi?.insertOne({
|
|
379
|
+
error: fn.error,
|
|
379
380
|
io: Cfg.io,
|
|
380
381
|
session: sessionStorage(),
|
|
381
382
|
data: toJson(data),
|
|
@@ -527,6 +528,7 @@ class useRest {
|
|
|
527
528
|
|
|
528
529
|
if (col?.customApi?.insertMany && useCustomApi) {
|
|
529
530
|
let result = await col?.customApi?.insertMany({
|
|
531
|
+
error: fn.error,
|
|
530
532
|
io: Cfg.io,
|
|
531
533
|
session: sessionStorage(),
|
|
532
534
|
data: toJson(data),
|
|
@@ -728,6 +730,7 @@ class useRest {
|
|
|
728
730
|
if (col?.customApi?.find && useCustomApi) {
|
|
729
731
|
let result = (await col?.customApi?.find({
|
|
730
732
|
io: Cfg.io,
|
|
733
|
+
error: fn.error,
|
|
731
734
|
session: sessionStorage(),
|
|
732
735
|
params: params,
|
|
733
736
|
rest: new useRest({
|
|
@@ -864,6 +867,7 @@ class useRest {
|
|
|
864
867
|
if (col?.customApi?.count && useCustomApi) {
|
|
865
868
|
let result = (await col?.customApi?.count({
|
|
866
869
|
io: Cfg.io,
|
|
870
|
+
error: fn.error,
|
|
867
871
|
session: sessionStorage(),
|
|
868
872
|
params: params,
|
|
869
873
|
rest: new useRest({
|
|
@@ -984,6 +988,7 @@ class useRest {
|
|
|
984
988
|
if (col?.customApi?.findOne && useCustomApi) {
|
|
985
989
|
let result = await col?.customApi?.findOne({
|
|
986
990
|
io: Cfg.io,
|
|
991
|
+
error: fn.error,
|
|
987
992
|
session: sessionStorage(),
|
|
988
993
|
id: id,
|
|
989
994
|
params: params,
|
|
@@ -1114,6 +1119,7 @@ class useRest {
|
|
|
1114
1119
|
if (col?.customApi?.updateOne && useCustomApi) {
|
|
1115
1120
|
let result = await col?.customApi?.updateOne({
|
|
1116
1121
|
io: Cfg.io,
|
|
1122
|
+
error: fn.error,
|
|
1117
1123
|
session: sessionStorage(),
|
|
1118
1124
|
update: update,
|
|
1119
1125
|
id: id,
|
|
@@ -1542,6 +1548,7 @@ class useRest {
|
|
|
1542
1548
|
if (col?.customApi?.updateMany && useCustomApi) {
|
|
1543
1549
|
let result = await col?.customApi?.updateMany({
|
|
1544
1550
|
io: Cfg.io,
|
|
1551
|
+
error: fn.error,
|
|
1545
1552
|
session: sessionStorage(),
|
|
1546
1553
|
update: update,
|
|
1547
1554
|
ids: ids,
|
|
@@ -1731,6 +1738,7 @@ class useRest {
|
|
|
1731
1738
|
if (col?.customApi?.deleteOne && useCustomApi) {
|
|
1732
1739
|
let result = await col?.customApi?.deleteOne({
|
|
1733
1740
|
io: Cfg.io,
|
|
1741
|
+
error: fn.error,
|
|
1734
1742
|
session: sessionStorage(),
|
|
1735
1743
|
id: id,
|
|
1736
1744
|
rest: new useRest({
|
|
@@ -1869,6 +1877,7 @@ class useRest {
|
|
|
1869
1877
|
if (col?.customApi?.deleteMany && useCustomApi) {
|
|
1870
1878
|
let result = await col?.customApi?.deleteMany({
|
|
1871
1879
|
io: Cfg.io,
|
|
1880
|
+
error: fn.error,
|
|
1872
1881
|
session: sessionStorage(),
|
|
1873
1882
|
ids: ids,
|
|
1874
1883
|
rest: new useRest({
|
package/lib/socket/instance.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { ServerWebSocket, WebSocketHandler, Server } from "bun";
|
|
|
2
2
|
import { EventEmitter } from "events";
|
|
3
3
|
import { Cfg } from "../../config";
|
|
4
4
|
import { v4 } from "uuid";
|
|
5
|
+
import { uuid } from "../../utils";
|
|
5
6
|
const wsClients = new Map<string, ServerWebSocket>();
|
|
6
7
|
const wsEvents: optionsIo[] = [];
|
|
7
8
|
|
|
@@ -36,7 +37,7 @@ class Io {
|
|
|
36
37
|
}
|
|
37
38
|
emit(event: string, data: any) {
|
|
38
39
|
if (!this?.id || this.id == null) {
|
|
39
|
-
console.error("No id found");
|
|
40
|
+
console.error("ws:: No id found");
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
if (this.id) {
|
|
@@ -133,6 +134,7 @@ function webSocketServer(server: Server): WebSocketHandler {
|
|
|
133
134
|
let clb_ = null;
|
|
134
135
|
if (options?.uuid) {
|
|
135
136
|
clb_ = (data: any) => {
|
|
137
|
+
//console.log("MMM", data);
|
|
136
138
|
ws.send(
|
|
137
139
|
JSON.stringify({ type: "emit", event: options?.uuid, data })
|
|
138
140
|
);
|
|
@@ -150,7 +152,14 @@ function webSocketServer(server: Server): WebSocketHandler {
|
|
|
150
152
|
broadcast: (event: string, data: any) => {
|
|
151
153
|
// send to all clients
|
|
152
154
|
wsClients.forEach((client) => {
|
|
153
|
-
client.send(
|
|
155
|
+
client.send(
|
|
156
|
+
JSON.stringify({
|
|
157
|
+
type: "emit",
|
|
158
|
+
event,
|
|
159
|
+
data,
|
|
160
|
+
uuid: options?.uuid,
|
|
161
|
+
})
|
|
162
|
+
);
|
|
154
163
|
});
|
|
155
164
|
},
|
|
156
165
|
emit: (event: string, data: any) =>
|
package/package.json
CHANGED
package/types/index.ts
CHANGED
|
@@ -261,10 +261,11 @@ export type ctxApi = {
|
|
|
261
261
|
rest: useRest;
|
|
262
262
|
data?: any;
|
|
263
263
|
session?: sessionCtx;
|
|
264
|
-
io
|
|
264
|
+
io: socketIoType;
|
|
265
265
|
params?: findParam;
|
|
266
266
|
id?: string;
|
|
267
267
|
ids?: string[];
|
|
268
|
+
error: typeof fn.error;
|
|
268
269
|
update?: updateParams;
|
|
269
270
|
};
|
|
270
271
|
|