jsgar 2.0.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 +125 -31
- 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,80 @@
|
|
|
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
|
+
|
|
658
|
+
// Convert className to array
|
|
659
|
+
let classList = null;
|
|
660
|
+
if (typeof className === 'string') {
|
|
661
|
+
classList = className.split(/\s+/).filter(Boolean);
|
|
662
|
+
} else if (Array.isArray(className)) {
|
|
663
|
+
classList = className;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
let singleClass = Array.isArray(classList) && classList.length === 1 ? classList[0] : null;
|
|
667
|
+
|
|
616
668
|
// Convert keyName to array
|
|
617
669
|
let keyNames = [];
|
|
618
670
|
if (typeof keyName === 'string') {
|
|
@@ -620,7 +672,7 @@
|
|
|
620
672
|
} else if (Array.isArray(keyName)) {
|
|
621
673
|
keyNames = keyName;
|
|
622
674
|
}
|
|
623
|
-
const keyIdList = keyNames.map(x => this.getAndPossiblyIntroduceKeyId(x));
|
|
675
|
+
const keyIdList = keyNames.map(x => this.getAndPossiblyIntroduceKeyId(x, singleClass));
|
|
624
676
|
|
|
625
677
|
// Convert topicName to array
|
|
626
678
|
let topicNames = [];
|
|
@@ -631,29 +683,71 @@
|
|
|
631
683
|
}
|
|
632
684
|
const topicIdList = topicNames.map(x => this.getAndPossiblyIntroduceTopicId(x));
|
|
633
685
|
|
|
634
|
-
//
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
}
|
|
639
|
-
|
|
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;
|
|
640
746
|
}
|
|
641
747
|
|
|
642
748
|
const subMsg = {
|
|
643
749
|
message_type: 'Subscribe',
|
|
644
|
-
value:
|
|
645
|
-
subscription_mode: mode,
|
|
646
|
-
all_matching_keys: allMatchingKeys,
|
|
647
|
-
snapshot_size_limit: snapshotSizeLimit,
|
|
648
|
-
nagle_interval: 0,
|
|
649
|
-
name,
|
|
650
|
-
key_id_list: keyIdList,
|
|
651
|
-
topic_id_list: topicIdList,
|
|
652
|
-
class_list: classList,
|
|
653
|
-
key_filter: keyFilter,
|
|
654
|
-
topic_filter: topicFilter,
|
|
655
|
-
subscription_group: subscriptionGroup
|
|
656
|
-
}
|
|
750
|
+
value: valueDict,
|
|
657
751
|
};
|
|
658
752
|
this.sendMessage(subMsg);
|
|
659
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
|
}
|