openkbs-pulse 1.0.10 → 1.0.12

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/package.json +1 -1
  2. package/pulse.js +1 -1
  3. package/server.js +8 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openkbs-pulse",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "Real-time WebSocket SDK for OpenKBS",
5
5
  "main": "pulse.js",
6
6
  "types": "pulse.d.ts",
package/pulse.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * OpenKBS Pulse v1.0.2 - Real-time WebSocket SDK
2
+ * OpenKBS Pulse v1.0.10 - Real-time WebSocket SDK
3
3
  *
4
4
  * Usage:
5
5
  * const pulse = new Pulse({ kbId: 'your-kb-id', token: 'user-token' });
package/server.js CHANGED
@@ -44,10 +44,11 @@ const pulse = {
44
44
  * @param {string} channel - Channel name
45
45
  * @param {string} event - Event type
46
46
  * @param {object} data - Event data
47
+ * @param {object} options - Optional { kbId, apiKey } overrides
47
48
  */
48
- async publish(channel, event, data) {
49
- const kbId = process.env.OPENKBS_KB_ID;
50
- const apiKey = process.env.OPENKBS_API_KEY;
49
+ async publish(channel, event, data, options = {}) {
50
+ const kbId = options.kbId || process.env.OPENKBS_KB_ID;
51
+ const apiKey = options.apiKey || process.env.OPENKBS_API_KEY;
51
52
 
52
53
  if (!kbId || !apiKey) {
53
54
  console.log('[Pulse] Not configured, skipping publish');
@@ -77,10 +78,11 @@ const pulse = {
77
78
  /**
78
79
  * Get presence info for a channel
79
80
  * @param {string} channel - Channel name
81
+ * @param {object} options - Optional { kbId, apiKey } overrides
80
82
  */
81
- async presence(channel) {
82
- const kbId = process.env.OPENKBS_KB_ID;
83
- const apiKey = process.env.OPENKBS_API_KEY;
83
+ async presence(channel, options = {}) {
84
+ const kbId = options.kbId || process.env.OPENKBS_KB_ID;
85
+ const apiKey = options.apiKey || process.env.OPENKBS_API_KEY;
84
86
 
85
87
  if (!kbId || !apiKey) {
86
88
  return { count: 0, members: [] };