jsgar 3.8.0 → 3.8.2

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.
Files changed (2) hide show
  1. package/dist/gar.umd.js +30 -2
  2. package/package.json +1 -1
package/dist/gar.umd.js CHANGED
@@ -38,8 +38,9 @@
38
38
  * @param {number} [heartbeatTimeoutInterval=4000] - Heartbeat interval in milliseconds
39
39
  * @param {boolean} [allowSelfSignedCertificate=false] - Allow self-signed certificates
40
40
  * @param {string} [logLevel='INFO'] - Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
41
+ * @param {boolean} [uniqueKeyAndRecordUpdates=false] - Only one update per key/record
41
42
  */
42
- constructor(wsEndpoint, user, working_namespace = null, heartbeatTimeoutInterval = 4000, allowSelfSignedCertificate = false, logLevel = 'INFO') {
43
+ constructor(wsEndpoint, user, working_namespace = null, heartbeatTimeoutInterval = 4000, allowSelfSignedCertificate = false, logLevel = 'INFO', uniqueKeyAndRecordUpdates = false) {
43
44
  this.wsEndpoint = wsEndpoint;
44
45
  this.websocket = null;
45
46
  this.messageQueue = [];
@@ -52,6 +53,7 @@
52
53
  if (this.timeoutScale !== 1.0) {
53
54
  this.scaledHeartbeatTimeoutInterval *= this.timeoutScale;
54
55
  }
56
+ this.unique_key_and_record_updates = uniqueKeyAndRecordUpdates;
55
57
  this.version = 650707;
56
58
 
57
59
  if (typeof window !== 'undefined' && window.location) {
@@ -423,6 +425,20 @@
423
425
  }, subscriptionGroup);
424
426
  }
425
427
 
428
+ /**
429
+ * Register handler for EchoResponse message.
430
+ * @param {Function} handler - Callback with (msgRef)
431
+ */
432
+ registerEchoResponseHandler(handler) {
433
+ this.registerHandler('EchoResponse', (msg) => {
434
+ handler(msg.value.msg_ref);
435
+ });
436
+ }
437
+
438
+ clearEchoResponseHandler() {
439
+ this.messageHandlers.delete('EchoResponse');
440
+ }
441
+
426
442
  /**
427
443
  * Register a callback to handle heartbeat timeout events.
428
444
  * @param {Function} handler - Callback with no arguments
@@ -491,6 +507,7 @@
491
507
  value: {
492
508
  version: this.version,
493
509
  heartbeat_timeout_interval: Math.floor(this.scaledHeartbeatTimeoutInterval),
510
+ unique_key_and_record_updates: this.unique_key_and_record_updates,
494
511
  user: this.user,
495
512
  working_namespace: this.working_namespace
496
513
  }
@@ -608,6 +625,17 @@
608
625
  this.sendMessage(msg);
609
626
  }
610
627
 
628
+ /**
629
+ * Send an EchoRequest message.
630
+ * @param {number} msgRef - Message reference ID
631
+ */
632
+ sendEchoRequest(msgRef) {
633
+ this.sendMessage({
634
+ message_type: 'EchoRequest',
635
+ value: { msg_ref: msgRef }
636
+ });
637
+ }
638
+
611
639
  /**
612
640
  * Send periodic heartbeat messages.
613
641
  */
@@ -925,7 +953,7 @@
925
953
  // Convert keyName to array
926
954
  let keyNames = [];
927
955
  if (typeof keyName === 'string') {
928
- keyNames = keyName.split(/\s+/).filter(Boolean);
956
+ keyNames = [keyName];
929
957
  } else if (Array.isArray(keyName)) {
930
958
  keyNames = keyName;
931
959
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsgar",
3
- "version": "3.8.0",
3
+ "version": "3.8.2",
4
4
  "description": "A Javascript client for the GAR protocol",
5
5
  "type": "module",
6
6
  "main": "dist/gar.umd.js",