jsgar 2.1.0 → 2.2.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.
- package/dist/gar.umd.js +116 -24
- package/package.json +2 -2
package/dist/gar.umd.js
CHANGED
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
this.user = user;
|
|
51
51
|
this.working_namespace = working_namespace;
|
|
52
52
|
this.heartbeatTimeoutInterval = heartbeatTimeoutInterval;
|
|
53
|
-
this.version =
|
|
53
|
+
this.version = 650705;
|
|
54
54
|
|
|
55
55
|
if (typeof window !== 'undefined' && window.location) {
|
|
56
56
|
this.application = window.location.href;
|
|
@@ -591,28 +591,70 @@
|
|
|
591
591
|
/**
|
|
592
592
|
* Send a subscription request using local IDs.
|
|
593
593
|
* @param {string} name - Subscription name
|
|
594
|
-
* @param {string} [
|
|
594
|
+
* @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)
|
|
595
606
|
* @param {string|Array<string>|null} [keyName=null] - Key name(s)
|
|
596
607
|
* @param {string|Array<string>|null} [topicName=null] - Topic name(s)
|
|
597
608
|
* @param {string|Array<string>|null} [className=null] - Class name(s)
|
|
598
|
-
* @param {string|null} [keyFilter=null] - Key filter regex
|
|
599
|
-
* @param {string|null} [
|
|
600
|
-
* @param {
|
|
601
|
-
* @param
|
|
602
|
-
* @param {
|
|
609
|
+
* @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
|
+
* @param {string|null} [topicFilter=null] - Topic filter regex (cannot use with topicName)
|
|
612
|
+
* @param {string|null} [excludeTopicFilter=null] - Exclude topic filter regex (cannot use with topicName)
|
|
613
|
+
* @param {string} [workingNamespace] - Namespace for matching relative paths
|
|
603
614
|
*/
|
|
604
615
|
subscribe(
|
|
605
616
|
name,
|
|
606
|
-
|
|
617
|
+
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,
|
|
607
629
|
keyName = null,
|
|
608
630
|
topicName = null,
|
|
609
631
|
className = null,
|
|
610
632
|
keyFilter = null,
|
|
633
|
+
excludeKeyFilter = null,
|
|
611
634
|
topicFilter = null,
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
snapshotSizeLimit = 0
|
|
635
|
+
excludeTopicFilter = null,
|
|
636
|
+
workingNamespace = null
|
|
615
637
|
) {
|
|
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
|
+
// Validate mutually exclusive parameters
|
|
645
|
+
if (keyName && (keyFilter || excludeKeyFilter)) {
|
|
646
|
+
throw new Error('keyName cannot be used with keyFilter or excludeKeyFilter');
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
if (topicName && (topicFilter || excludeTopicFilter)) {
|
|
650
|
+
throw new Error('topicName cannot be used with topicFilter or excludeTopicFilter');
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
// Validate limit parameter usage
|
|
654
|
+
if (limit > 0 && subscriptionMode === 'Streaming') {
|
|
655
|
+
throw new Error('limit cannot be used with streaming subscriptions');
|
|
656
|
+
}
|
|
657
|
+
|
|
616
658
|
// Convert className to array
|
|
617
659
|
let classList = null;
|
|
618
660
|
if (typeof className === 'string') {
|
|
@@ -641,21 +683,71 @@
|
|
|
641
683
|
}
|
|
642
684
|
const topicIdList = topicNames.map(x => this.getAndPossiblyIntroduceTopicId(x));
|
|
643
685
|
|
|
686
|
+
// Build subscription message, filtering out null/undefined values
|
|
687
|
+
const valueDict = {
|
|
688
|
+
subscription_mode: subscriptionMode,
|
|
689
|
+
name,
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
// Add optional fields only if they have values
|
|
693
|
+
if (subscriptionSet !== null) {
|
|
694
|
+
valueDict.subscription_set = subscriptionSet;
|
|
695
|
+
}
|
|
696
|
+
if (maxHistory !== null) {
|
|
697
|
+
valueDict.max_history = maxHistory;
|
|
698
|
+
}
|
|
699
|
+
if (snapshotSizeLimit > 0) {
|
|
700
|
+
valueDict.snapshot_size_limit = snapshotSizeLimit;
|
|
701
|
+
}
|
|
702
|
+
if (nagleInterval > 0) {
|
|
703
|
+
valueDict.nagle_interval = nagleInterval;
|
|
704
|
+
}
|
|
705
|
+
if (subscriptionGroup > 0) {
|
|
706
|
+
valueDict.subscription_group = subscriptionGroup;
|
|
707
|
+
}
|
|
708
|
+
if (density !== null) {
|
|
709
|
+
valueDict.density = density;
|
|
710
|
+
}
|
|
711
|
+
if (includeReferencedKeys) {
|
|
712
|
+
valueDict.include_referenced_keys = includeReferencedKeys;
|
|
713
|
+
}
|
|
714
|
+
if (includeReferencingKeys) {
|
|
715
|
+
valueDict.include_referencing_keys = includeReferencingKeys;
|
|
716
|
+
}
|
|
717
|
+
if (includeAllNamespace) {
|
|
718
|
+
valueDict.include_all_namespace = includeAllNamespace;
|
|
719
|
+
}
|
|
720
|
+
if (limit > 0) {
|
|
721
|
+
valueDict.limit = limit;
|
|
722
|
+
}
|
|
723
|
+
if (keyIdList.length > 0) {
|
|
724
|
+
valueDict.key_id_list = keyIdList;
|
|
725
|
+
}
|
|
726
|
+
if (topicIdList.length > 0) {
|
|
727
|
+
valueDict.topic_id_list = topicIdList;
|
|
728
|
+
}
|
|
729
|
+
if (classList) {
|
|
730
|
+
valueDict.class_list = classList;
|
|
731
|
+
}
|
|
732
|
+
if (keyFilter) {
|
|
733
|
+
valueDict.key_filter = keyFilter;
|
|
734
|
+
}
|
|
735
|
+
if (excludeKeyFilter) {
|
|
736
|
+
valueDict.exclude_key_filter = excludeKeyFilter;
|
|
737
|
+
}
|
|
738
|
+
if (topicFilter) {
|
|
739
|
+
valueDict.topic_filter = topicFilter;
|
|
740
|
+
}
|
|
741
|
+
if (excludeTopicFilter) {
|
|
742
|
+
valueDict.exclude_topic_filter = excludeTopicFilter;
|
|
743
|
+
}
|
|
744
|
+
if (workingNamespace) {
|
|
745
|
+
valueDict.working_namespace = workingNamespace;
|
|
746
|
+
}
|
|
747
|
+
|
|
644
748
|
const subMsg = {
|
|
645
749
|
message_type: 'Subscribe',
|
|
646
|
-
value:
|
|
647
|
-
subscription_mode: mode,
|
|
648
|
-
all_matching_keys: allMatchingKeys,
|
|
649
|
-
snapshot_size_limit: snapshotSizeLimit,
|
|
650
|
-
nagle_interval: 0,
|
|
651
|
-
name,
|
|
652
|
-
key_id_list: keyIdList,
|
|
653
|
-
topic_id_list: topicIdList,
|
|
654
|
-
class_list: classList,
|
|
655
|
-
key_filter: keyFilter,
|
|
656
|
-
topic_filter: topicFilter,
|
|
657
|
-
subscription_group: subscriptionGroup
|
|
658
|
-
}
|
|
750
|
+
value: valueDict,
|
|
659
751
|
};
|
|
660
752
|
this.sendMessage(subMsg);
|
|
661
753
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsgar",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"description": "A Javascript client for the GAR protocol",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/gar.umd.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@eslint/json": "^0.12.0",
|
|
28
28
|
"@rollup/plugin-commonjs": "^24.0.0",
|
|
29
29
|
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
30
|
-
"eslint": "^9.
|
|
30
|
+
"eslint": "^9.33.0",
|
|
31
31
|
"globals": "^16.0.0",
|
|
32
32
|
"rollup": "^3.0.0"
|
|
33
33
|
}
|