Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
---
changelog:
- date: 2025-09-18
version: v9.11.0
changes:
- type: feature
text: "Add 'limit' and 'offset' parameters for 'HereNowRequest' for pagination support."
- date: 2025-09-09
version: v9.10.0
changes:
Expand Down Expand Up @@ -1335,7 +1340,7 @@ supported-platforms:
- 'Ubuntu 14.04 and up'
- 'Windows 7 and up'
version: 'Pubnub Javascript for Node'
version: '9.10.0'
version: '9.11.0'
sdks:
- full-name: PubNub Javascript SDK
short-name: Javascript
Expand All @@ -1351,7 +1356,7 @@ sdks:
- distribution-type: source
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/archive/refs/tags/v9.10.0.zip
location: https://github.com/pubnub/javascript/archive/refs/tags/v9.11.0.zip
requires:
- name: 'agentkeepalive'
min-version: '3.5.2'
Expand Down Expand Up @@ -2022,7 +2027,7 @@ sdks:
- distribution-type: library
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/releases/download/v9.10.0/pubnub.9.10.0.js
location: https://github.com/pubnub/javascript/releases/download/v9.11.0/pubnub.9.11.0.js
requires:
- name: 'agentkeepalive'
min-version: '3.5.2'
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v9.11.0
September 18 2025

#### Added
- Add 'limit' and 'offset' parameters for 'HereNowRequest' for pagination support.

## v9.10.0
September 09 2025

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ Watch [Getting Started with PubNub JS SDK](https://app.dashcam.io/replay/64ee0d2
npm install pubnub
```
* or download one of our builds from our CDN:
* https://cdn.pubnub.com/sdk/javascript/pubnub.9.10.0.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.9.10.0.min.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.9.11.0.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.9.11.0.min.js

2. Configure your keys:

Expand Down
32 changes: 24 additions & 8 deletions dist/web/pubnub.js
Original file line number Diff line number Diff line change
Expand Up @@ -5436,7 +5436,7 @@
return base.PubNubFile;
},
get version() {
return '9.10.0';
return '9.11.0';
},
getVersion() {
return this.version;
Expand Down Expand Up @@ -11420,6 +11420,10 @@
* Whether state associated with `uuid` should be included in response or not.
*/
const INCLUDE_STATE = false;
/**
* Maximum number of participants which can be returned with single response.
*/
const MAXIMUM_COUNT = 1000;
// endregion
/**
* Channel presence request.
Expand All @@ -11428,14 +11432,19 @@
*/
class HereNowRequest extends AbstractRequest {
constructor(parameters) {
var _a, _b, _c;
var _d, _e, _f;
var _a, _b, _c, _d;
var _e, _f, _g, _h;
super();
this.parameters = parameters;
// Apply defaults.
(_a = (_d = this.parameters).queryParameters) !== null && _a !== void 0 ? _a : (_d.queryParameters = {});
(_b = (_e = this.parameters).includeUUIDs) !== null && _b !== void 0 ? _b : (_e.includeUUIDs = INCLUDE_UUID$1);
(_c = (_f = this.parameters).includeState) !== null && _c !== void 0 ? _c : (_f.includeState = INCLUDE_STATE);
(_a = (_e = this.parameters).queryParameters) !== null && _a !== void 0 ? _a : (_e.queryParameters = {});
(_b = (_f = this.parameters).includeUUIDs) !== null && _b !== void 0 ? _b : (_f.includeUUIDs = INCLUDE_UUID$1);
(_c = (_g = this.parameters).includeState) !== null && _c !== void 0 ? _c : (_g.includeState = INCLUDE_STATE);
if (this.parameters.limit)
this.parameters.limit = Math.min(this.parameters.limit, MAXIMUM_COUNT);
else
this.parameters.limit = MAXIMUM_COUNT;
(_d = (_h = this.parameters).offset) !== null && _d !== void 0 ? _d : (_h.offset = 0);
}
operation() {
const { channels = [], channelGroups = [] } = this.parameters;
Expand Down Expand Up @@ -11480,6 +11489,7 @@
return {
totalChannels,
totalOccupancy,
next: 0,
channels: channelsPresence,
};
});
Expand All @@ -11492,8 +11502,8 @@
return path;
}
get queryParameters() {
const { channelGroups, includeUUIDs, includeState, queryParameters } = this.parameters;
return Object.assign(Object.assign(Object.assign(Object.assign({}, (!includeUUIDs ? { disable_uuids: '1' } : {})), ((includeState !== null && includeState !== void 0 ? includeState : false) ? { state: '1' } : {})), (channelGroups && channelGroups.length > 0 ? { 'channel-group': channelGroups.join(',') } : {})), queryParameters);
const { channelGroups, includeUUIDs, includeState, limit, offset, queryParameters } = this.parameters;
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (this.operation() === RequestOperation$1.PNHereNowOperation ? { limit } : {})), (this.operation() === RequestOperation$1.PNHereNowOperation && offset > 0 ? { offset } : {})), (!includeUUIDs ? { disable_uuids: '1' } : {})), ((includeState !== null && includeState !== void 0 ? includeState : false) ? { state: '1' } : {})), (channelGroups && channelGroups.length > 0 ? { 'channel-group': channelGroups.join(',') } : {})), queryParameters);
}
}

Expand Down Expand Up @@ -16768,10 +16778,16 @@
};
if (callback)
return this.sendRequest(request, (status, response) => {
var _a;
if (response && response.totalOccupancy === parameters.limit)
response.next = ((_a = parameters.offset) !== null && _a !== void 0 ? _a : 0) + 1;
logResponse(response);
callback(status, response);
});
return this.sendRequest(request).then((response) => {
var _a;
if (response && response.totalOccupancy === parameters.limit)
response.next = ((_a = parameters.offset) !== null && _a !== void 0 ? _a : 0) + 1;
logResponse(response);
return response;
});
Expand Down
4 changes: 2 additions & 2 deletions dist/web/pubnub.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/core/components/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const makeConfiguration = (base, setupCryptoModule) => {
return base.PubNubFile;
},
get version() {
return '9.10.0';
return '9.11.0';
},
getVersion() {
return this.version;
Expand Down
24 changes: 17 additions & 7 deletions lib/core/endpoints/presence/here_now.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ const INCLUDE_UUID = true;
* Whether state associated with `uuid` should be included in response or not.
*/
const INCLUDE_STATE = false;
/**
* Maximum number of participants which can be returned with single response.
*/
const MAXIMUM_COUNT = 1000;
// endregion
/**
* Channel presence request.
Expand All @@ -41,14 +45,19 @@ const INCLUDE_STATE = false;
*/
class HereNowRequest extends request_1.AbstractRequest {
constructor(parameters) {
var _a, _b, _c;
var _d, _e, _f;
var _a, _b, _c, _d;
var _e, _f, _g, _h;
super();
this.parameters = parameters;
// Apply defaults.
(_a = (_d = this.parameters).queryParameters) !== null && _a !== void 0 ? _a : (_d.queryParameters = {});
(_b = (_e = this.parameters).includeUUIDs) !== null && _b !== void 0 ? _b : (_e.includeUUIDs = INCLUDE_UUID);
(_c = (_f = this.parameters).includeState) !== null && _c !== void 0 ? _c : (_f.includeState = INCLUDE_STATE);
(_a = (_e = this.parameters).queryParameters) !== null && _a !== void 0 ? _a : (_e.queryParameters = {});
(_b = (_f = this.parameters).includeUUIDs) !== null && _b !== void 0 ? _b : (_f.includeUUIDs = INCLUDE_UUID);
(_c = (_g = this.parameters).includeState) !== null && _c !== void 0 ? _c : (_g.includeState = INCLUDE_STATE);
if (this.parameters.limit)
this.parameters.limit = Math.min(this.parameters.limit, MAXIMUM_COUNT);
else
this.parameters.limit = MAXIMUM_COUNT;
(_d = (_h = this.parameters).offset) !== null && _d !== void 0 ? _d : (_h.offset = 0);
}
operation() {
const { channels = [], channelGroups = [] } = this.parameters;
Expand Down Expand Up @@ -93,6 +102,7 @@ class HereNowRequest extends request_1.AbstractRequest {
return {
totalChannels,
totalOccupancy,
next: 0,
channels: channelsPresence,
};
});
Expand All @@ -105,8 +115,8 @@ class HereNowRequest extends request_1.AbstractRequest {
return path;
}
get queryParameters() {
const { channelGroups, includeUUIDs, includeState, queryParameters } = this.parameters;
return Object.assign(Object.assign(Object.assign(Object.assign({}, (!includeUUIDs ? { disable_uuids: '1' } : {})), ((includeState !== null && includeState !== void 0 ? includeState : false) ? { state: '1' } : {})), (channelGroups && channelGroups.length > 0 ? { 'channel-group': channelGroups.join(',') } : {})), queryParameters);
const { channelGroups, includeUUIDs, includeState, limit, offset, queryParameters } = this.parameters;
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (this.operation() === operations_1.default.PNHereNowOperation ? { limit } : {})), (this.operation() === operations_1.default.PNHereNowOperation && offset > 0 ? { offset } : {})), (!includeUUIDs ? { disable_uuids: '1' } : {})), ((includeState !== null && includeState !== void 0 ? includeState : false) ? { state: '1' } : {})), (channelGroups && channelGroups.length > 0 ? { 'channel-group': channelGroups.join(',') } : {})), queryParameters);
}
}
exports.HereNowRequest = HereNowRequest;
6 changes: 6 additions & 0 deletions lib/core/pubnub-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1701,10 +1701,16 @@ class PubNubCore {
};
if (callback)
return this.sendRequest(request, (status, response) => {
var _a;
if (response && response.totalOccupancy === parameters.limit)
response.next = ((_a = parameters.offset) !== null && _a !== void 0 ? _a : 0) + 1;
logResponse(response);
callback(status, response);
});
return this.sendRequest(request).then((response) => {
var _a;
if (response && response.totalOccupancy === parameters.limit)
response.next = ((_a = parameters.offset) !== null && _a !== void 0 ? _a : 0) + 1;
logResponse(response);
return response;
});
Expand Down
22 changes: 22 additions & 0 deletions lib/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7182,6 +7182,20 @@ declare namespace PubNub {
* @default `false`.
*/
includeState?: boolean;
/**
* Limit the number of results returned.
*
* **Important:** Maximum value is `1000` users per request.
*
* @default `1000`.
*/
limit?: number;
/**
* Starting position of results to return, used for pagination.
*
* @default `0`.
*/
offset?: number;
/**
* Additional query parameters.
*/
Expand All @@ -7200,6 +7214,14 @@ declare namespace PubNub {
* Total occupancy for all retrieved channels.
*/
totalOccupancy: number;
/**
* Next page offset value.
*
* Value that could be passed as {@link HereNowParameters.offset|offset} to fetch the next participants list page.
*
* **Note:** There are no more pages if the value is set to `0`.
*/
next: number;
/**
* List of channels to which `uuid` currently subscribed.
*/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pubnub",
"version": "9.10.0",
"version": "9.11.0",
"author": "PubNub <support@pubnub.com>",
"description": "Publish & Subscribe Real-time Messaging with PubNub",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export const makeConfiguration = (
return base.PubNubFile;
},
get version(): string {
return '9.10.0';
return '9.11.0';
},
getVersion(): string {
return this.version;
Expand Down
13 changes: 12 additions & 1 deletion src/core/endpoints/presence/here_now.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ const INCLUDE_UUID = true;
* Whether state associated with `uuid` should be included in response or not.
*/
const INCLUDE_STATE = false;

/**
* Maximum number of participants which can be returned with single response.
*/
const MAXIMUM_COUNT = 1000;
// endregion

// --------------------------------------------------------
Expand Down Expand Up @@ -137,6 +142,9 @@ export class HereNowRequest extends AbstractRequest<Presence.HereNowResponse, Se
this.parameters.queryParameters ??= {};
this.parameters.includeUUIDs ??= INCLUDE_UUID;
this.parameters.includeState ??= INCLUDE_STATE;
if (this.parameters.limit) this.parameters.limit = Math.min(this.parameters.limit, MAXIMUM_COUNT);
else this.parameters.limit = MAXIMUM_COUNT;
this.parameters.offset ??= 0;
}

operation(): RequestOperation {
Expand Down Expand Up @@ -182,6 +190,7 @@ export class HereNowRequest extends AbstractRequest<Presence.HereNowResponse, Se
return {
totalChannels,
totalOccupancy,
next: 0,
channels: channelsPresence,
};
}
Expand All @@ -201,9 +210,11 @@ export class HereNowRequest extends AbstractRequest<Presence.HereNowResponse, Se
}

protected get queryParameters(): Query {
const { channelGroups, includeUUIDs, includeState, queryParameters } = this.parameters;
const { channelGroups, includeUUIDs, includeState, limit, offset, queryParameters } = this.parameters;

return {
...(this.operation() === RequestOperation.PNHereNowOperation ? { limit } : {}),
...(this.operation() === RequestOperation.PNHereNowOperation && offset! > 0 ? { offset } : {}),
...(!includeUUIDs! ? { disable_uuids: '1' } : {}),
...((includeState ?? false) ? { state: '1' } : {}),
...(channelGroups && channelGroups.length > 0 ? { 'channel-group': channelGroups.join(',') } : {}),
Expand Down
4 changes: 4 additions & 0 deletions src/core/pubnub-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2428,11 +2428,15 @@ export class PubNubCore<

if (callback)
return this.sendRequest(request, (status, response) => {
if (response && response.totalOccupancy === parameters.limit) response.next = (parameters.offset ?? 0) + 1;

logResponse(response);
callback(status, response);
});

return this.sendRequest(request).then((response) => {
if (response && response.totalOccupancy === parameters.limit) response.next = (parameters.offset ?? 0) + 1;

logResponse(response);
return response;
});
Expand Down
25 changes: 25 additions & 0 deletions src/core/types/api/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,22 @@ export type HereNowParameters = {
*/
includeState?: boolean;

/**
* Limit the number of results returned.
*
* **Important:** Maximum value is `1000` users per request.
*
* @default `1000`.
*/
limit?: number;

/**
* Starting position of results to return, used for pagination.
*
* @default `0`.
*/
offset?: number;

/**
* Additional query parameters.
*/
Expand All @@ -212,6 +228,15 @@ export type HereNowResponse = {
*/
totalOccupancy: number;

/**
* Next page offset value.
*
* Value that could be passed as {@link HereNowParameters.offset|offset} to fetch the next participants list page.
*
* **Note:** There are no more pages if the value is set to `0`.
*/
next: number;

/**
* List of channels to which `uuid` currently subscribed.
*/
Expand Down
Loading
Loading