jsgar 4.13.3 → 4.13.6

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 (3) hide show
  1. package/dist/gar.umd.js +46 -15
  2. package/gar.js +46 -15
  3. package/package.json +1 -1
package/dist/gar.umd.js CHANGED
@@ -1551,27 +1551,48 @@
1551
1551
  }
1552
1552
 
1553
1553
  /**
1554
- * Delete a key by name if it exists in the localKeyMap. Safe to call multiple times.
1554
+ * Remove a single class from a key by sending a KeyIntroduction with deleted_class set, if the
1555
+ * key exists in the localKeyMap. Safe to call multiple times. The key may still exist on the
1556
+ * server in other classes, so the localKeyMap entry is preserved. Careful: every record that
1557
+ * applied to className but to no remaining class is deleted.
1555
1558
  * @param {string} keyName - Key name
1556
- * @param {string|null} [className=null] - If set, removes the key from this class only via
1557
- * a KeyIntroduction with deleted_class set; the key may still exist on the server in
1558
- * other classes and the localKeyMap entry is preserved. If unset, sends DeleteKey to
1559
- * remove the key entirely and forgets the local id so a future
1560
- * getAndPossiblyIntroduceKeyId(keyName) re-introduces with a fresh id.
1559
+ * @param {string} className - Class to remove from the key
1560
+ * @param {string|Array<string>|null} [downgradeToClassList=null] - If set, populates
1561
+ * key_introduction::class_list in the same message the classes the key should apply to
1562
+ * alongside the removal. A single key_introduction may both add classes (class_list) and
1563
+ * remove one (deleted_class).
1561
1564
  */
1562
- deleteKey(keyName, className = null) {
1565
+ deleteClass(keyName, className, downgradeToClassList = null) {
1563
1566
  const keyId = this.localKeyMap.get(keyName);
1564
1567
  if (keyId === undefined) return;
1568
+ const value = { key_id: keyId, name: keyName, deleted_class: className };
1569
+ if (downgradeToClassList) {
1570
+ value.class_list = typeof downgradeToClassList === 'string'
1571
+ ? downgradeToClassList.split(/\s+/).filter(Boolean)
1572
+ : downgradeToClassList;
1573
+ }
1574
+ this.sendMessage({ message_type: 'KeyIntroduction', value });
1575
+ }
1576
+
1577
+ /**
1578
+ * Delete a key by name if it exists in the localKeyMap. Safe to call multiple times.
1579
+ * @param {string} keyName - Key name
1580
+ * @param {string|null} [className=null] - If set, delegates to deleteClass (KeyIntroduction
1581
+ * with deleted_class set); the key may still exist on the server in other classes and the
1582
+ * localKeyMap entry is preserved. If unset, sends DeleteKey to remove the key entirely and
1583
+ * forgets the local id so a future getAndPossiblyIntroduceKeyId(keyName) re-introduces with
1584
+ * a fresh id.
1585
+ */
1586
+ deleteKey(keyName, className = null) {
1565
1587
  if (className) {
1566
- this.sendMessage({
1567
- message_type: 'KeyIntroduction',
1568
- value: { key_id: keyId, name: keyName, deleted_class: className },
1569
- });
1570
- } else {
1571
- this.publishDeleteKey(keyId);
1572
- // Forget the local id so future re-introduction allocates a new one.
1573
- this.localKeyMap.delete(keyName);
1588
+ this.deleteClass(keyName, className);
1589
+ return;
1574
1590
  }
1591
+ const keyId = this.localKeyMap.get(keyName);
1592
+ if (keyId === undefined) return;
1593
+ this.publishDeleteKey(keyId);
1594
+ // Forget the local id so future re-introduction allocates a new one.
1595
+ this.localKeyMap.delete(keyName);
1575
1596
  }
1576
1597
 
1577
1598
  /**
@@ -1673,6 +1694,16 @@
1673
1694
  this.compareExchangeRecordWithIds(keyId, topicId, test, value);
1674
1695
  }
1675
1696
 
1697
+ /**
1698
+ * Declare the subscription group for subsequent operations whose results the server tags by group —
1699
+ * notably compare-exchange. Send this BEFORE a compareExchangeRecord and register the result handler
1700
+ * on the same group, so the result routes to it (the server reflects this group ahead of the result).
1701
+ * @param {number} subscriptionGroup - The group to attribute following results to.
1702
+ */
1703
+ sendActiveSubscriptionGroup(subscriptionGroup) {
1704
+ this.sendMessage({ message_type: 'ActiveSubscription', value: { subscription_group: subscriptionGroup } });
1705
+ }
1706
+
1676
1707
  /**
1677
1708
  * Query GAR deployment routing to find servers with matching publications.
1678
1709
  * Mirrors the Python client's route_query implementation.
package/gar.js CHANGED
@@ -1544,27 +1544,48 @@ class GARClient {
1544
1544
  }
1545
1545
 
1546
1546
  /**
1547
- * Delete a key by name if it exists in the localKeyMap. Safe to call multiple times.
1547
+ * Remove a single class from a key by sending a KeyIntroduction with deleted_class set, if the
1548
+ * key exists in the localKeyMap. Safe to call multiple times. The key may still exist on the
1549
+ * server in other classes, so the localKeyMap entry is preserved. Careful: every record that
1550
+ * applied to className but to no remaining class is deleted.
1548
1551
  * @param {string} keyName - Key name
1549
- * @param {string|null} [className=null] - If set, removes the key from this class only via
1550
- * a KeyIntroduction with deleted_class set; the key may still exist on the server in
1551
- * other classes and the localKeyMap entry is preserved. If unset, sends DeleteKey to
1552
- * remove the key entirely and forgets the local id so a future
1553
- * getAndPossiblyIntroduceKeyId(keyName) re-introduces with a fresh id.
1552
+ * @param {string} className - Class to remove from the key
1553
+ * @param {string|Array<string>|null} [downgradeToClassList=null] - If set, populates
1554
+ * key_introduction::class_list in the same message the classes the key should apply to
1555
+ * alongside the removal. A single key_introduction may both add classes (class_list) and
1556
+ * remove one (deleted_class).
1554
1557
  */
1555
- deleteKey(keyName, className = null) {
1558
+ deleteClass(keyName, className, downgradeToClassList = null) {
1556
1559
  const keyId = this.localKeyMap.get(keyName);
1557
1560
  if (keyId === undefined) return;
1561
+ const value = { key_id: keyId, name: keyName, deleted_class: className };
1562
+ if (downgradeToClassList) {
1563
+ value.class_list = typeof downgradeToClassList === 'string'
1564
+ ? downgradeToClassList.split(/\s+/).filter(Boolean)
1565
+ : downgradeToClassList;
1566
+ }
1567
+ this.sendMessage({ message_type: 'KeyIntroduction', value });
1568
+ }
1569
+
1570
+ /**
1571
+ * Delete a key by name if it exists in the localKeyMap. Safe to call multiple times.
1572
+ * @param {string} keyName - Key name
1573
+ * @param {string|null} [className=null] - If set, delegates to deleteClass (KeyIntroduction
1574
+ * with deleted_class set); the key may still exist on the server in other classes and the
1575
+ * localKeyMap entry is preserved. If unset, sends DeleteKey to remove the key entirely and
1576
+ * forgets the local id so a future getAndPossiblyIntroduceKeyId(keyName) re-introduces with
1577
+ * a fresh id.
1578
+ */
1579
+ deleteKey(keyName, className = null) {
1558
1580
  if (className) {
1559
- this.sendMessage({
1560
- message_type: 'KeyIntroduction',
1561
- value: { key_id: keyId, name: keyName, deleted_class: className },
1562
- });
1563
- } else {
1564
- this.publishDeleteKey(keyId);
1565
- // Forget the local id so future re-introduction allocates a new one.
1566
- this.localKeyMap.delete(keyName);
1581
+ this.deleteClass(keyName, className);
1582
+ return;
1567
1583
  }
1584
+ const keyId = this.localKeyMap.get(keyName);
1585
+ if (keyId === undefined) return;
1586
+ this.publishDeleteKey(keyId);
1587
+ // Forget the local id so future re-introduction allocates a new one.
1588
+ this.localKeyMap.delete(keyName);
1568
1589
  }
1569
1590
 
1570
1591
  /**
@@ -1666,6 +1687,16 @@ class GARClient {
1666
1687
  this.compareExchangeRecordWithIds(keyId, topicId, test, value);
1667
1688
  }
1668
1689
 
1690
+ /**
1691
+ * Declare the subscription group for subsequent operations whose results the server tags by group —
1692
+ * notably compare-exchange. Send this BEFORE a compareExchangeRecord and register the result handler
1693
+ * on the same group, so the result routes to it (the server reflects this group ahead of the result).
1694
+ * @param {number} subscriptionGroup - The group to attribute following results to.
1695
+ */
1696
+ sendActiveSubscriptionGroup(subscriptionGroup) {
1697
+ this.sendMessage({ message_type: 'ActiveSubscription', value: { subscription_group: subscriptionGroup } });
1698
+ }
1699
+
1669
1700
  /**
1670
1701
  * Query GAR deployment routing to find servers with matching publications.
1671
1702
  * Mirrors the Python client's route_query implementation.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsgar",
3
- "version": "4.13.3",
3
+ "version": "4.13.6",
4
4
  "description": "A Javascript client for the GAR protocol",
5
5
  "type": "module",
6
6
  "main": "dist/gar.umd.js",