jsgar 2.2.2 → 3.0.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.
Files changed (2) hide show
  1. package/dist/gar.umd.js +90 -41
  2. package/package.json +1 -1
package/dist/gar.umd.js CHANGED
@@ -589,58 +589,62 @@
589
589
  }
590
590
 
591
591
  /**
592
- * Send a subscription request using local IDs.
592
+ * Send an already-formatted subscription message
593
+ * @param {object} subscriptionMessageValue - json representation of the gar `subscribe` struct
594
+ */
595
+ subscribeFormatted(subscriptionMessageValue) {
596
+ const subMsg = {
597
+ message_type: 'Subscribe',
598
+ value: subscriptionMessageValue,
599
+ };
600
+ this.sendMessage(subMsg);
601
+ }
602
+
603
+ /**
604
+ * Send a subscription request
593
605
  * @param {string} name - Subscription name
594
606
  * @param {string} [subscriptionMode='Streaming'] - Subscription mode
595
- * @param {string} [mode] - Deprecated: use subscriptionMode instead
596
- * @param {string} [subscriptionSet] - Subscription set identifier
597
- * @param {string} [maxHistory] - Maximum history to include
598
- * @param {number} [snapshotSizeLimit=0] - Limit snapshot size
599
- * @param {number} [nagleInterval=0] - Nagle interval in milliseconds
600
- * @param {number} [subscriptionGroup=0] - Subscription group ID for isolating callbacks
601
- * @param {string} [density] - For performance tuning
602
- * @param {boolean} [includeReferencedKeys=false] - Add keys from key references in matched records
603
- * @param {boolean} [includeReferencingKeys=false] - Add keys that have one or more records referencing any matched keys
604
- * @param {boolean} [includeAllNamespace=false] - Include keys and topics from all namespaces
605
- * @param {number} [limit=0] - Limits records in initial snapshot (0 = all)
606
607
  * @param {string|Array<string>|null} [keyName=null] - Key name(s)
607
608
  * @param {string|Array<string>|null} [topicName=null] - Topic name(s)
608
609
  * @param {string|Array<string>|null} [className=null] - Class name(s)
609
610
  * @param {string|null} [keyFilter=null] - Key filter regex (cannot use with keyName)
610
- * @param {string|null} [excludeKeyFilter=null] - Exclude key filter regex (cannot use with keyName)
611
611
  * @param {string|null} [topicFilter=null] - Topic filter regex (cannot use with topicName)
612
+ * @param {string|null} [excludeKeyFilter=null] - Exclude key filter regex (cannot use with keyName)
612
613
  * @param {string|null} [excludeTopicFilter=null] - Exclude topic filter regex (cannot use with topicName)
613
- * @param {string} [workingNamespace] - Namespace for matching relative paths
614
+ * @param {string|null} [maxHistory] - Maximum history to include
615
+ * @param {boolean} [includeReferencedKeys=false] - Add keys from key references in matched records
616
+ * @param {boolean} [includeReferencingKeys=false] - Add keys that have one or more records referencing any matched keys
617
+ * @param {boolean} [includeAllNamespace=false] - Include keys and topics from all namespaces
618
+ * @param {string|null} [workingNamespace] - Namespace for matching relative paths
619
+ * @param {string|null} [density] - For performance tuning
620
+ * @param {number} [subscriptionGroup=0] - Subscription group ID for isolating callbacks
621
+ * @param {string|null} [subscriptionSet] - Subscription set identifier
622
+ * @param {number} [snapshotSizeLimit=0] - Limit snapshot size
623
+ * @param {number} [nagleInterval=0] - Nagle interval in milliseconds
624
+ * @param {number} [limit=0] - Limits records in initial snapshot (0 = all)
614
625
  */
615
626
  subscribe(
616
627
  name,
617
628
  subscriptionMode = 'Streaming',
618
- mode = null,
619
- subscriptionSet = null,
620
- maxHistory = null,
621
- snapshotSizeLimit = 0,
622
- nagleInterval = 0,
623
- subscriptionGroup = 0,
624
- density = null,
625
- includeReferencedKeys = false,
626
- includeReferencingKeys = false,
627
- includeAllNamespace = false,
628
- limit = 0,
629
629
  keyName = null,
630
630
  topicName = null,
631
631
  className = null,
632
632
  keyFilter = null,
633
- excludeKeyFilter = null,
634
633
  topicFilter = null,
634
+ excludeKeyFilter = null,
635
635
  excludeTopicFilter = null,
636
- workingNamespace = null
636
+ maxHistory = null,
637
+ includeReferencedKeys = false,
638
+ includeReferencingKeys = false,
639
+ includeAllNamespace = false,
640
+ workingNamespace = null,
641
+ density = null,
642
+ subscriptionGroup = 0,
643
+ subscriptionSet = null,
644
+ snapshotSizeLimit = 0,
645
+ nagleInterval = 0,
646
+ limit = 0
637
647
  ) {
638
- // Handle deprecated mode parameter
639
- if (mode !== null) {
640
- console.warn('The "mode" parameter is deprecated. Use "subscriptionMode" instead.');
641
- subscriptionMode = mode;
642
- }
643
-
644
648
  // Validate mutually exclusive parameters
645
649
  if (keyName && (keyFilter || excludeKeyFilter)) {
646
650
  throw new Error('keyName cannot be used with keyFilter or excludeKeyFilter');
@@ -690,10 +694,10 @@
690
694
  };
691
695
 
692
696
  // Add optional fields only if they have values
693
- if (subscriptionSet !== null) {
697
+ if (subscriptionSet) {
694
698
  valueDict.subscription_set = subscriptionSet;
695
699
  }
696
- if (maxHistory !== null) {
700
+ if (maxHistory) {
697
701
  valueDict.max_history = maxHistory;
698
702
  }
699
703
  if (snapshotSizeLimit > 0) {
@@ -705,7 +709,7 @@
705
709
  if (subscriptionGroup > 0) {
706
710
  valueDict.subscription_group = subscriptionGroup;
707
711
  }
708
- if (density !== null) {
712
+ if (density) {
709
713
  valueDict.density = density;
710
714
  }
711
715
  if (includeReferencedKeys) {
@@ -745,11 +749,56 @@
745
749
  valueDict.working_namespace = workingNamespace;
746
750
  }
747
751
 
748
- const subMsg = {
749
- message_type: 'Subscribe',
750
- value: valueDict,
751
- };
752
- this.sendMessage(subMsg);
752
+ this.subscribeFormatted(valueDict);
753
+ }
754
+
755
+ /**
756
+ * Wrapper to `subscribe` with a smaller set of arguments.
757
+ * @param {string} name - Subscription name
758
+ * @param {string} [subscriptionMode='Streaming'] - Subscription mode
759
+ * @param {number} [subscriptionGroup=0] - Subscription group ID for isolating callbacks
760
+ * @param {number} [snapshotSizeLimit=0] - Limit snapshot size
761
+ * @param {string|Array<string>|null} [keyName=null] - Key name(s)
762
+ * @param {string|Array<string>|null} [topicName=null] - Topic name(s)
763
+ * @param {string|Array<string>|null} [className=null] - Class name(s)
764
+ * @param {string|null} [keyFilter=null] - Key filter regex (cannot use with keyName)
765
+ * @param {string|null} [topicFilter=null] - Topic filter regex (cannot use with topicName)
766
+ * @param {string|null} [excludeKeyFilter=null] - Exclude key filter regex (cannot use with keyName)
767
+ * @param {string|null} [excludeTopicFilter=null] - Exclude topic filter regex (cannot use with topicName)
768
+ */
769
+ subscribeCommon(
770
+ name,
771
+ subscriptionMode = 'Streaming',
772
+ subscriptionGroup = 0,
773
+ snapshotSizeLimit = 0,
774
+ keyName = null,
775
+ topicName = null,
776
+ className = null,
777
+ keyFilter = null,
778
+ topicFilter = null,
779
+ excludeKeyFilter = null,
780
+ excludeTopicFilter = null,
781
+ ) {
782
+ this.subscribe(
783
+ name,
784
+ subscriptionMode,
785
+ keyName,
786
+ topicName,
787
+ className,
788
+ keyFilter,
789
+ topicFilter,
790
+ excludeKeyFilter,
791
+ excludeTopicFilter,
792
+ null,
793
+ false,
794
+ false,
795
+ false,
796
+ null,
797
+ null,
798
+ subscriptionGroup,
799
+ null,
800
+ snapshotSizeLimit
801
+ );
753
802
  }
754
803
 
755
804
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsgar",
3
- "version": "2.2.2",
3
+ "version": "3.0.0",
4
4
  "description": "A Javascript client for the GAR protocol",
5
5
  "type": "module",
6
6
  "main": "dist/gar.umd.js",