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-10-29
version: v10.2.0
changes:
- type: feature
text: "Add a zero-based `offset` index parameter to be used together with `limit` for `here now` pagination."
- date: 2025-09-30
version: v10.1.0
changes:
Expand Down Expand Up @@ -1349,7 +1354,7 @@ supported-platforms:
- 'Ubuntu 14.04 and up'
- 'Windows 7 and up'
version: 'Pubnub Javascript for Node'
version: '10.1.0'
version: '10.2.0'
sdks:
- full-name: PubNub Javascript SDK
short-name: Javascript
Expand All @@ -1365,7 +1370,7 @@ sdks:
- distribution-type: source
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/archive/refs/tags/v10.1.0.zip
location: https://github.com/pubnub/javascript/archive/refs/tags/v10.2.0.zip
requires:
- name: 'agentkeepalive'
min-version: '3.5.2'
Expand Down Expand Up @@ -2036,7 +2041,7 @@ sdks:
- distribution-type: library
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/releases/download/v10.1.0/pubnub.10.1.0.js
location: https://github.com/pubnub/javascript/releases/download/v10.2.0/pubnub.10.2.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 @@
## v10.2.0
October 29 2025

#### Added
- Add a zero-based `offset` index parameter to be used together with `limit` for `here now` pagination.

## v10.1.0
September 30 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.10.1.0.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.10.1.0.min.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.10.2.0.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.10.2.0.min.js

2. Configure your keys:

Expand Down
21 changes: 9 additions & 12 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 '10.1.0';
return '10.2.0';
},
getVersion() {
return this.version;
Expand Down Expand Up @@ -11445,18 +11445,15 @@
*/
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);
if (this.parameters.limit)
this.parameters.limit = Math.min(this.parameters.limit, MAXIMUM_COUNT);
else
this.parameters.limit = MAXIMUM_COUNT;
(_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);
(_d = (_h = this.parameters).limit) !== null && _d !== void 0 ? _d : (_h.limit = MAXIMUM_COUNT);
}
operation() {
const { channels = [], channelGroups = [] } = this.parameters;
Expand Down Expand Up @@ -11517,8 +11514,8 @@
return path;
}
get queryParameters() {
const { channelGroups, includeUUIDs, includeState, limit, queryParameters } = this.parameters;
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (this.operation() === RequestOperation$1.PNHereNowOperation ? { limit } : {})), (!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 !== null && offset !== void 0 ? offset : 0 > 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
2 changes: 1 addition & 1 deletion 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 '10.1.0';
return '10.2.0';
},
getVersion() {
return this.version;
Expand Down
19 changes: 8 additions & 11 deletions lib/core/endpoints/presence/here_now.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,15 @@ const MAXIMUM_COUNT = 1000;
*/
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);
if (this.parameters.limit)
this.parameters.limit = Math.min(this.parameters.limit, MAXIMUM_COUNT);
else
this.parameters.limit = MAXIMUM_COUNT;
(_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);
(_d = (_h = this.parameters).limit) !== null && _d !== void 0 ? _d : (_h.limit = MAXIMUM_COUNT);
}
operation() {
const { channels = [], channelGroups = [] } = this.parameters;
Expand Down Expand Up @@ -117,8 +114,8 @@ class HereNowRequest extends request_1.AbstractRequest {
return path;
}
get queryParameters() {
const { channelGroups, includeUUIDs, includeState, limit, queryParameters } = this.parameters;
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (this.operation() === operations_1.default.PNHereNowOperation ? { limit } : {})), (!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 !== null && offset !== void 0 ? offset : 0 > 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: 4 additions & 2 deletions lib/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7185,11 +7185,13 @@ declare namespace PubNub {
/**
* Limit the number of results returned.
*
* **Important:** Maximum value is `1000` users per request.
*
* @default `1000`.
*/
limit?: number;
/**
* Zero-based starting index for pagination.
*/
offset?: number;
/**
* Additional query parameters.
*/
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": "10.1.0",
"version": "10.2.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 '10.1.0';
return '10.2.0';
},
getVersion(): string {
return this.version;
Expand Down
6 changes: 3 additions & 3 deletions src/core/endpoints/presence/here_now.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ 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.limit ??= MAXIMUM_COUNT;
}

operation(): RequestOperation {
Expand Down Expand Up @@ -212,10 +211,11 @@ export class HereNowRequest extends AbstractRequest<Presence.HereNowResponse, Se
}

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

return {
...(this.operation() === RequestOperation.PNHereNowOperation ? { limit } : {}),
...(this.operation() === RequestOperation.PNHereNowOperation && (offset ?? 0 > 0) ? { offset } : {}),
...(!includeUUIDs! ? { disable_uuids: '1' } : {}),
...((includeState ?? false) ? { state: '1' } : {}),
...(channelGroups && channelGroups.length > 0 ? { 'channel-group': channelGroups.join(',') } : {}),
Expand Down
7 changes: 5 additions & 2 deletions src/core/types/api/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,15 @@ export type HereNowParameters = {
/**
* Limit the number of results returned.
*
* **Important:** Maximum value is `1000` users per request.
*
* @default `1000`.
*/
limit?: number;

/**
* Zero-based starting index for pagination.
*/
offset?: number;

/**
* Additional query parameters.
*/
Expand Down
9 changes: 5 additions & 4 deletions test/integration/endpoints/presence.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,13 +444,13 @@ describe('presence endpoints', () => {
.query({
pnsdk: `PubNub-JS-Nodejs/${pubnub.getVersion()}`,
uuid: 'myUUID',
limit: 1000,
limit: 10000,
})
.reply(200, '{"status": 200, "message": "OK", "occupancy": 1, "service": "Presence"}', {
'content-type': 'text/javascript',
});

pubnub.hereNow({ channels: ['game1'] }, (status, response) => {
pubnub.hereNow({ channels: ['game1'], limit: 10000, offset: 0 }, (status, response) => {
try {
assert.equal(status.error, false);
assert(response !== null);
Expand All @@ -477,14 +477,15 @@ describe('presence endpoints', () => {
pnsdk: `PubNub-JS-Nodejs/${pubnub.getVersion()}`,
uuid: 'myUUID',
limit: 1000,
offset: 1,
})
.reply(
200,
'{"status": 200, "message": "OK", "payload": {"channels": {"game1": {"uuids": ["a3ffd012-a3b9-478c-8705-64089f24d71e"], "occupancy": 1}}, "total_channels": 1, "total_occupancy": 1}, "service": "Presence"}',
{ 'content-type': 'text/javascript' },
);

pubnub.hereNow({ channels: ['ch1', 'ch2'] }, (status, response) => {
pubnub.hereNow({ channels: ['ch1', 'ch2'], offset: 1 }, (status, response) => {
try {
assert.equal(status.error, false);
assert(response !== null);
Expand Down Expand Up @@ -560,7 +561,7 @@ describe('presence endpoints', () => {
.get('/v2/presence/sub-key/mySubscribeKey/channel/ch1,ch2')
.query({
pnsdk: `PubNub-JS-Nodejs/${pubnub.getVersion()}`,
limit: 1000,
limit: 10000,
uuid: 'myUUID',
})
.reply(
Expand Down
Loading