dbm-graph-api 1.1.32 → 1.1.34

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbm-graph-api",
3
- "version": "1.1.32",
3
+ "version": "1.1.34",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -13,7 +13,7 @@
13
13
  "dependencies": {
14
14
  "@aws-sdk/client-s3": "^3.741.0",
15
15
  "@aws-sdk/s3-request-presigner": "^3.741.0",
16
- "dbm": "^1.2.2",
16
+ "dbm": "^1.2.3",
17
17
  "mime": "^4.0.6",
18
18
  "sharp": "^0.33.5",
19
19
  "ws": "^8.18.0"
@@ -114,7 +114,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
114
114
  console.error(theError);
115
115
  }
116
116
 
117
- this._webSocket.send(JSON.stringify({"type": "range/response", "ids": ids, "requestId": data["requestId"], "logs": logs}));
117
+ this._sendData({"type": "range/response", "ids": ids, "requestId": data["requestId"], "logs": logs});
118
118
  break;
119
119
  case "data":
120
120
  {
@@ -128,7 +128,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
128
128
  returnData = await dataFunctionItem.controller.getData(data['data'], encodeSession);
129
129
  }
130
130
 
131
- this._webSocket.send(JSON.stringify({"type": "data/response", "data": returnData, "requestId": data["requestId"]}));
131
+ this._sendData({"type": "data/response", "data": returnData, "requestId": data["requestId"]});
132
132
  }
133
133
  break;
134
134
  case "action":
@@ -151,7 +151,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
151
151
  console.error(theError);
152
152
  }
153
153
 
154
- this._webSocket.send(JSON.stringify({"type": "data/response", "data": returnData, "requestId": data["requestId"], "logs": logs}));
154
+ this._sendData({"type": "data/response", "data": returnData, "requestId": data["requestId"], "logs": logs});
155
155
  }
156
156
  break;
157
157
  case "item":
@@ -174,7 +174,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
174
174
 
175
175
  encodeSession.destroy();
176
176
 
177
- this._webSocket.send(JSON.stringify({"type": "item/response", "id": id, "requestId": data["requestId"], "logs": logs}));
177
+ this._sendData({"type": "item/response", "id": id, "requestId": data["requestId"], "logs": logs});
178
178
  }
179
179
  break;
180
180
  case "url":
@@ -196,10 +196,10 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
196
196
 
197
197
  await encodeSession.encodeSingleWithTypes(urlObject.id, ["urlRequest"]);
198
198
  encodeSession.destroy();
199
- this._webSocket.send(JSON.stringify({"type": "url/response", "id": urlObject.id, "requestId": data["requestId"]}));
199
+ this._sendData({"type": "url/response", "id": urlObject.id, "requestId": data["requestId"]});
200
200
  }
201
201
  else {
202
- this._webSocket.send(JSON.stringify({"type": "url/response", "id": 0, "requestId": data["requestId"]}));
202
+ this._sendData({"type": "url/response", "id": 0, "requestId": data["requestId"]});
203
203
  }
204
204
  }
205
205
  break;
@@ -238,7 +238,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
238
238
  }
239
239
 
240
240
 
241
- this._webSocket.send(JSON.stringify({"type": "item/response", "id": returnId, "requestId": data["requestId"]}));
241
+ this._sendData({"type": "item/response", "id": returnId, "requestId": data["requestId"]});
242
242
  }
243
243
  break;
244
244
  case "admin/editObject":
@@ -268,7 +268,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
268
268
  }
269
269
 
270
270
 
271
- this._webSocket.send(JSON.stringify({"type": "item/response", "id": theObject.id, "requestId": data["requestId"]}));
271
+ this._sendData({"type": "item/response", "id": theObject.id, "requestId": data["requestId"]});
272
272
  }
273
273
  break;
274
274
  case "user/signInWithToken":
@@ -287,19 +287,29 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
287
287
  this.item.setValue("user", user);
288
288
  }
289
289
 
290
- this._webSocket.send(JSON.stringify({"type": "currentUser/response", "id": userId, "requestId": data["requestId"]}));
291
-
290
+ this._sendData({"type": "currentUser/response", "id": userId, "requestId": data["requestId"]});
292
291
  }
293
292
  break;
294
293
  case "heartbeat":
295
294
  {
296
- this._webSocket.send(JSON.stringify({"type": "heartbeat/response"}));
297
-
295
+ this._sendData({"type": "heartbeat/response"});
298
296
  }
299
297
  break;
300
298
  }
301
299
  }
302
300
 
301
+ _sendData(aData) {
302
+ if(this._webSocket) {
303
+ let encodedData = JSON.stringify(aData);
304
+ try {
305
+ this._webSocket.send(encodedData);
306
+ }
307
+ catch(theError) {
308
+ console.error();
309
+ }
310
+ }
311
+ }
312
+
303
313
  _callback_error(aMessage) {
304
314
  console.log("_callback_error");
305
315
  console.error(aMessage);
@@ -336,7 +346,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
336
346
  outputEncodedData(aId, aData, aEncoding) {
337
347
  //console.log("WebSocketConnection::outputEncodedData");
338
348
 
339
- this._webSocket.send(JSON.stringify({"type": "updateEncodedObject", "id": aId, "data": aData, "encoding": aEncoding}));
349
+ this._sendData({"type": "updateEncodedObject", "id": aId, "data": aData, "encoding": aEncoding});
340
350
 
341
351
  }
342
352
 
@@ -352,7 +362,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
352
362
  this.item.setValue("user", null);
353
363
  }
354
364
 
355
- this._webSocket.send(JSON.stringify({"type": "connectionReady", "user": aId}));
365
+ this._sendData({"type": "connectionReady", "user": aId});
356
366
  }
357
367
 
358
368
  async getUser() {
@@ -0,0 +1,12 @@
1
+ import Dbm from "dbm";
2
+ import EditBaseObject from "./EditBaseObject.js";
3
+
4
+ export default class Trash extends EditBaseObject {
5
+ _construct() {
6
+ super._construct();
7
+ }
8
+
9
+ async performChange(aObject, aData, aRequest) {
10
+ await aObject.trash();
11
+ }
12
+ }
@@ -16,6 +16,7 @@ export {default as AddObjectType} from "./AddObjectType.js";
16
16
  export {default as RemoveObjectType} from "./RemoveObjectType.js";
17
17
  export {default as AddAction} from "./AddAction.js";
18
18
  export {default as SetFieldTranslation} from "./SetFieldTranslation.js";
19
+ export {default as Trash} from "./Trash.js";
19
20
 
20
21
 
21
22
  export const fullSetup = function() {
@@ -109,4 +110,10 @@ export const fullSetup = function() {
109
110
  let currentSelect = new DbmGraphApi.admin.edit.SetFieldTranslation();
110
111
  currentSelect.item.register(prefix + name);
111
112
  }
113
+
114
+ {
115
+ let name = "trash";
116
+ let currentSelect = new DbmGraphApi.admin.edit.Trash();
117
+ currentSelect.item.register(prefix + name);
118
+ }
112
119
  }
@@ -1,6 +1,8 @@
1
1
  import Dbm from "dbm";
2
2
  import DbmGraphApi from "../../../index.js";
3
3
 
4
+ import { performance } from 'node:perf_hooks';
5
+
4
6
  export default class ExternalTaskRunner extends Dbm.core.BaseObject {
5
7
 
6
8
  _construct() {
@@ -43,10 +45,13 @@ export default class ExternalTaskRunner extends Dbm.core.BaseObject {
43
45
  requestData["body"] = this.item.body;
44
46
  }
45
47
 
48
+ let startTime = performance.now();
46
49
  let response = await fetch(this.item.url, requestData);
47
50
 
48
51
  let responseText = await response.text();
49
52
 
53
+ let endTime = performance.now();
54
+
50
55
  let data = null;
51
56
  try {
52
57
  data = JSON.parse(responseText);
@@ -58,7 +63,8 @@ export default class ExternalTaskRunner extends Dbm.core.BaseObject {
58
63
 
59
64
  if(data) {
60
65
  let continueData = Dbm.objectPath(data, this.item.continueField);
61
- console.log(this.item.name + " " + continueData);
66
+ let callTime = ((endTime-startTime)/1000).toFixed(3);
67
+ console.log(this.item.name + ` (time: ${callTime} continue: ${continueData})`);
62
68
 
63
69
  if(continueData > 0) {
64
70
  runDirect = true;