Skip to content

Commit b60a6f8

Browse files
datasync updates (#559)
* update set* apis as per endpoint behaviour. set* PUT now upserts: optional class/classLevel (entityClass/entityClassLevel),relationship/membership participant IDs optional, ifNoneMatch (If-None-Match). * Treat 412 as non-retriable in retry policy. * test updates * lib updates * dist updates * remove default limit value query param from dataSync get operations. no validation on empty ids in get memberships,relationships,users/channels. to match behaviour across the sdks * updated tests * test code update with codacy recommandations * datasync: add ordered `operations` to update* JSON Patch * update the tests * lib updates * dist updates * lint and prettier * prettier * PubNub SDK v14.1.0 release. * fix live integration test failure * code snippet test: added assert for filter example --------- Co-authored-by: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com>
1 parent d7e1446 commit b60a6f8

64 files changed

Lines changed: 2942 additions & 682 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.pubnub.yml‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
---
22
changelog:
3+
- date: 2026-12-03
4+
version: v14.1.0
5+
changes:
6+
- type: feature
7+
text: "DataSync set operations are upserts now. added support for optional ttl parameter."
8+
- type: feature
9+
text: "Add optional `operations` to updateEntity/User/Channel/Membership/Relationship. Sent exactly as written, Reject `operations` mixed with grouped fields, and validate each operation."
10+
- type: bug
11+
text: "Treat 412 as non-retriable in retry policy."
312
- date: 2026-11-24
413
version: v14.0.1
514
changes:
@@ -1547,7 +1556,7 @@ supported-platforms:
15471556
- 'Ubuntu 14.04 and up'
15481557
- 'Windows 7 and up'
15491558
version: 'Pubnub Javascript for Node'
1550-
version: '14.0.1'
1559+
version: '14.1.0'
15511560
sdks:
15521561
- full-name: PubNub Javascript SDK
15531562
short-name: Javascript
@@ -1563,7 +1572,7 @@ sdks:
15631572
- distribution-type: source
15641573
distribution-repository: GitHub release
15651574
package-name: pubnub.js
1566-
location: https://github.com/pubnub/javascript/archive/refs/tags/v14.0.1.zip
1575+
location: https://github.com/pubnub/javascript/archive/refs/tags/v14.1.0.zip
15671576
requires:
15681577
- name: 'agentkeepalive'
15691578
min-version: '3.5.2'
@@ -2234,7 +2243,7 @@ sdks:
22342243
- distribution-type: library
22352244
distribution-repository: GitHub release
22362245
package-name: pubnub.js
2237-
location: https://github.com/pubnub/javascript/releases/download/v14.0.1/pubnub.14.0.1.js
2246+
location: https://github.com/pubnub/javascript/releases/download/v14.1.0/pubnub.14.1.0.js
22382247
requires:
22392248
- name: 'agentkeepalive'
22402249
min-version: '3.5.2'

‎CHANGELOG.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## v14.1.0
2+
December 03 2026
3+
4+
#### Added
5+
- DataSync set operations are upserts now. added support for optional ttl parameter.
6+
- Add optional `operations` to updateEntity/User/Channel/Membership/Relationship. Sent exactly as written, Reject `operations` mixed with grouped fields, and validate each operation.
7+
8+
#### Fixed
9+
- Treat 412 as non-retriable in retry policy.
10+
111
## v14.0.1
212
November 24 2026
313

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ npm install pubnub
2727

2828
Or download one of our builds from our CDN:
2929

30-
- https://cdn.pubnub.com/sdk/javascript/pubnub.14.0.1.js
31-
- https://cdn.pubnub.com/sdk/javascript/pubnub.14.0.1.min.js
30+
- https://cdn.pubnub.com/sdk/javascript/pubnub.14.1.0.js
31+
- https://cdn.pubnub.com/sdk/javascript/pubnub.14.1.0.min.js
3232

3333
For other installation methods, see [environment setup](https://www.pubnub.com/docs/sdks/javascript/environment-setup).
3434

‎dist/web/pubnub.js‎

Lines changed: 153 additions & 160 deletions
Large diffs are not rendered by default.

‎dist/web/pubnub.min.js‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/core/components/configuration.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ const makeConfiguration = (base, setupCryptoModule) => {
174174
return base.PubNubFile;
175175
},
176176
get version() {
177-
return '14.0.1';
177+
return '14.1.0';
178178
},
179179
getVersion() {
180180
return this.version;

‎lib/core/components/retry-policy.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ const categories_1 = __importDefault(require("../constants/categories"));
88
/**
99
* HTTP status codes which represent definitive client-side outcomes and shouldn't be retried.
1010
*
11+
* `412` is a failed `If-Match` / `If-None-Match` precondition: resending the same conditional
12+
* request can never succeed.
13+
*
1114
* @internal
1215
*/
13-
const NON_RETRIABLE_STATUS_CODES = [404, 409];
16+
const NON_RETRIABLE_STATUS_CODES = [404, 409, 412];
1417
// --------------------------------------------------------
1518
// ------------------------ Types -------------------------
1619
// --------------------------------------------------------

‎lib/core/endpoints/data_sync/channel/create.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ class CreateChannelRequest extends request_1.AbstractRequest {
5959
return `/v1/datasync/subkeys/${subscribeKey}/channels`;
6060
}
6161
get body() {
62-
const { id, class: entityClass, classLevel, data } = this.parameters;
62+
const { id, class: entityClass, classLevel, ttl, data } = this.parameters;
6363
return JSON.stringify({
64-
data: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (id !== undefined ? { id } : {})), (entityClass !== undefined ? { entityClass } : {})), { entityClassVersion: data.classVersion }), (classLevel !== undefined ? { entityClassLevel: classLevel } : {})), (data.status !== undefined ? { status: data.status } : {})), (data.payload !== undefined ? { payload: data.payload } : {})),
64+
data: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (id !== undefined ? { id } : {})), (entityClass !== undefined ? { entityClass } : {})), { entityClassVersion: data.classVersion }), (classLevel !== undefined ? { entityClassLevel: classLevel } : {})), (ttl !== undefined ? { entityTtlSec: ttl } : {})), (data.status !== undefined ? { status: data.status } : {})), (data.payload !== undefined ? { payload: data.payload } : {})),
6565
});
6666
}
6767
}

‎lib/core/endpoints/data_sync/channel/get-all.js‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,6 @@ exports.GetChannelsRequest = void 0;
5454
const request_1 = require("../../../components/request");
5555
const operations_1 = __importDefault(require("../../../constants/operations"));
5656
const DataSync = __importStar(require("../../../types/api/data-sync"));
57-
// --------------------------------------------------------
58-
// ----------------------- Defaults -----------------------
59-
// --------------------------------------------------------
60-
// region Defaults
61-
/**
62-
* Default number of items per page.
63-
*/
64-
const DEFAULT_LIMIT = 20;
6557
// endregion
6658
/**
6759
* Get Channels request.
@@ -70,11 +62,8 @@ const DEFAULT_LIMIT = 20;
7062
*/
7163
class GetChannelsRequest extends request_1.AbstractRequest {
7264
constructor(parameters) {
73-
var _a;
7465
super();
7566
this.parameters = parameters;
76-
// Apply defaults.
77-
(_a = parameters.limit) !== null && _a !== void 0 ? _a : (parameters.limit = DEFAULT_LIMIT);
7867
}
7968
operation() {
8069
return operations_1.default.PNGetDataSyncChannelsOperation;
@@ -93,7 +82,7 @@ class GetChannelsRequest extends request_1.AbstractRequest {
9382
get queryParameters() {
9483
const { class: entityClass, classVersion, classLevel, cursor, limit, filter, filterFast, sort } = this.parameters;
9584
const sorting = DataSync.serializeDataSyncSort(sort);
96-
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (entityClass ? { entity_class: entityClass } : {})), (classVersion !== undefined ? { entity_class_version: `${classVersion}` } : {})), (classLevel ? { entity_class_level: classLevel } : {})), (cursor ? { cursor } : {})), (limit ? { limit: `${limit}` } : {})), (filter ? { filter } : {})), (filterFast ? { filter_fast: filterFast } : {})), (sorting.length ? { sort: sorting } : {}));
85+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (entityClass !== undefined ? { entity_class: entityClass } : {})), (classVersion !== undefined ? { entity_class_version: `${classVersion}` } : {})), (classLevel ? { entity_class_level: classLevel } : {})), (cursor ? { cursor } : {})), (limit !== undefined ? { limit: `${limit}` } : {})), (filter ? { filter } : {})), (filterFast ? { filter_fast: filterFast } : {})), (sorting.length ? { sort: sorting } : {}));
9786
}
9887
}
9988
exports.GetChannelsRequest = GetChannelsRequest;

‎lib/core/endpoints/data_sync/channel/set.js‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
/**
33
* Set Channel REST API module.
44
*
5-
* Full resource replacement via PUT.
5+
* Create or replace (upsert) via PUT: creates the channel when no live record exists at the path ID
6+
* (HTTP 201), otherwise replaces it (HTTP 200). An omitted class creates a Global `Channel`.
67
*
78
* @internal
89
*/
@@ -59,16 +60,18 @@ class SetChannelRequest extends request_1.AbstractRequest {
5960
let headers = (_a = super.headers) !== null && _a !== void 0 ? _a : {};
6061
if (this.parameters.ifMatchesEtag)
6162
headers = Object.assign(Object.assign({}, headers), { 'If-Match': this.parameters.ifMatchesEtag });
63+
if (this.parameters.ifNoneMatch)
64+
headers = Object.assign(Object.assign({}, headers), { 'If-None-Match': this.parameters.ifNoneMatch });
6265
return Object.assign(Object.assign({}, headers), { 'Content-Type': 'application/vnd.pubnub.objects.channel+json;version=1' });
6366
}
6467
get path() {
6568
const { keySet: { subscribeKey }, id, } = this.parameters;
6669
return `/v1/datasync/subkeys/${subscribeKey}/channels/${(0, utils_1.encodeString)(id)}`;
6770
}
6871
get body() {
69-
const { data } = this.parameters;
72+
const { class: entityClass, classLevel, ttl, data } = this.parameters;
7073
return JSON.stringify({
71-
data: Object.assign(Object.assign({ entityClassVersion: data.classVersion }, (data.status !== undefined ? { status: data.status } : {})), (data.payload !== undefined ? { payload: data.payload } : {})),
74+
data: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (entityClass !== undefined ? { entityClass } : {})), { entityClassVersion: data.classVersion }), (classLevel !== undefined ? { entityClassLevel: classLevel } : {})), (ttl !== undefined ? { entityTtlSec: ttl } : {})), (data.status !== undefined ? { status: data.status } : {})), (data.payload !== undefined ? { payload: data.payload } : {})),
7275
});
7376
}
7477
}

0 commit comments

Comments
 (0)