Skip to content

Commit f5f9670

Browse files
wkal-pubnubMohit Tejani
andauthored
Preliminary If-Match ETag support for User and Channel (#432)
Preliminary If-Match ETag support for User and Channel --------- Co-authored-by: Mohit Tejani <[email protected]>
1 parent 875e44b commit f5f9670

File tree

14 files changed

+91
-10
lines changed

14 files changed

+91
-10
lines changed

.pubnub.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
---
22
changelog:
3+
- date: 2025-01-21
4+
version: v8.6.0
5+
changes:
6+
- type: feature
7+
text: "A new optional parameter `ifMatchesEtag` is added to `setUUIDMetadata` and `setChannelMetadata`. When provided, the server compares the argument value with the ETag on the server and if they don't match a HTTP 412 error is returned."
38
- date: 2025-01-15
49
version: v8.5.0
510
changes:
@@ -1106,7 +1111,7 @@ supported-platforms:
11061111
- 'Ubuntu 14.04 and up'
11071112
- 'Windows 7 and up'
11081113
version: 'Pubnub Javascript for Node'
1109-
version: '8.5.0'
1114+
version: '8.6.0'
11101115
sdks:
11111116
- full-name: PubNub Javascript SDK
11121117
short-name: Javascript
@@ -1122,7 +1127,7 @@ sdks:
11221127
- distribution-type: source
11231128
distribution-repository: GitHub release
11241129
package-name: pubnub.js
1125-
location: https://github.com/pubnub/javascript/archive/refs/tags/v8.5.0.zip
1130+
location: https://github.com/pubnub/javascript/archive/refs/tags/v8.6.0.zip
11261131
requires:
11271132
- name: 'agentkeepalive'
11281133
min-version: '3.5.2'
@@ -1793,7 +1798,7 @@ sdks:
17931798
- distribution-type: library
17941799
distribution-repository: GitHub release
17951800
package-name: pubnub.js
1796-
location: https://github.com/pubnub/javascript/releases/download/v8.5.0/pubnub.8.5.0.js
1801+
location: https://github.com/pubnub/javascript/releases/download/v8.6.0/pubnub.8.6.0.js
17971802
requires:
17981803
- name: 'agentkeepalive'
17991804
min-version: '3.5.2'

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## v8.6.0
2+
January 21 2025
3+
4+
#### Added
5+
- A new optional parameter `ifMatchesEtag` is added to `setUUIDMetadata` and `setChannelMetadata`. When provided, the server compares the argument value with the ETag on the server and if they don't match a HTTP 412 error is returned.
6+
17
## v8.5.0
28
January 15 2025
39

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ Watch [Getting Started with PubNub JS SDK](https://app.dashcam.io/replay/64ee0d2
2828
npm install pubnub
2929
```
3030
* or download one of our builds from our CDN:
31-
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.5.0.js
32-
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.5.0.min.js
31+
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.6.0.js
32+
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.6.0.min.js
3333
3434
2. Configure your keys:
3535

dist/web/pubnub.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3974,7 +3974,7 @@
39743974
return base.PubNubFile;
39753975
},
39763976
get version() {
3977-
return '8.5.0';
3977+
return '8.6.0';
39783978
},
39793979
getVersion() {
39803980
return this.version;
@@ -11553,6 +11553,14 @@
1155311553
if (!this.parameters.data)
1155411554
return 'Data cannot be empty';
1155511555
}
11556+
get headers() {
11557+
if (this.parameters.ifMatchesEtag) {
11558+
return { 'If-Match': this.parameters.ifMatchesEtag };
11559+
}
11560+
else {
11561+
return undefined;
11562+
}
11563+
}
1155611564
parse(response) {
1155711565
return __awaiter(this, void 0, void 0, function* () {
1155811566
const serviceResponse = this.deserializeResponse(response);
@@ -11972,6 +11980,14 @@
1197211980
if (!this.parameters.data)
1197311981
return 'Data cannot be empty';
1197411982
}
11983+
get headers() {
11984+
if (this.parameters.ifMatchesEtag) {
11985+
return { 'If-Match': this.parameters.ifMatchesEtag };
11986+
}
11987+
else {
11988+
return undefined;
11989+
}
11990+
}
1197511991
parse(response) {
1197611992
return __awaiter(this, void 0, void 0, function* () {
1197711993
const serviceResponse = this.deserializeResponse(response);

dist/web/pubnub.min.js

Lines changed: 1 addition & 1 deletion
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
@@ -120,7 +120,7 @@ const makeConfiguration = (base, setupCryptoModule) => {
120120
return base.PubNubFile;
121121
},
122122
get version() {
123-
return '8.5.0';
123+
return '8.6.0';
124124
},
125125
getVersion() {
126126
return this.version;

lib/core/endpoints/objects/channel/set.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ class SetChannelMetadataRequest extends request_1.AbstractRequest {
5757
if (!this.parameters.data)
5858
return 'Data cannot be empty';
5959
}
60+
get headers() {
61+
if (this.parameters.ifMatchesEtag) {
62+
return { 'If-Match': this.parameters.ifMatchesEtag };
63+
}
64+
else {
65+
return undefined;
66+
}
67+
}
6068
parse(response) {
6169
return __awaiter(this, void 0, void 0, function* () {
6270
const serviceResponse = this.deserializeResponse(response);

lib/core/endpoints/objects/uuid/set.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ class SetUUIDMetadataRequest extends request_1.AbstractRequest {
6060
if (!this.parameters.data)
6161
return 'Data cannot be empty';
6262
}
63+
get headers() {
64+
if (this.parameters.ifMatchesEtag) {
65+
return { 'If-Match': this.parameters.ifMatchesEtag };
66+
}
67+
else {
68+
return undefined;
69+
}
70+
}
6371
parse(response) {
6472
return __awaiter(this, void 0, void 0, function* () {
6573
const serviceResponse = this.deserializeResponse(response);

lib/types/index.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5627,6 +5627,11 @@ declare namespace PubNub {
56275627
* Fields which can be additionally included into response.
56285628
*/
56295629
include?: Omit<IncludeOptions, 'totalCount'>;
5630+
/**
5631+
* Optional entity tag from a previously received `PNUUIDMetadata`. The request
5632+
* will fail if this parameter is specified and the ETag value on the server doesn't match.
5633+
*/
5634+
ifMatchesEtag?: string;
56305635
};
56315636

56325637
/**
@@ -5752,6 +5757,11 @@ declare namespace PubNub {
57525757
* Fields which can be additionally included into response.
57535758
*/
57545759
include?: Omit<IncludeOptions, 'totalCount'>;
5760+
/**
5761+
* Optional entity tag from a previously received `PNUUIDMetadata`. The request
5762+
* will fail if this parameter is specified and the ETag value on the server doesn't match.
5763+
*/
5764+
ifMatchesEtag?: string;
57555765
};
57565766

57575767
/**

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pubnub",
3-
"version": "8.5.0",
3+
"version": "8.6.0",
44
"author": "PubNub <[email protected]>",
55
"description": "Publish & Subscribe Real-time Messaging with PubNub",
66
"scripts": {

src/core/components/configuration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export const makeConfiguration = (
178178
return base.PubNubFile;
179179
},
180180
get version(): string {
181-
return '8.5.0';
181+
return '8.6.0';
182182
},
183183
getVersion(): string {
184184
return this.version;

src/core/endpoints/objects/channel/set.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ export class SetChannelMetadataRequest<
6767
if (!this.parameters.data) return 'Data cannot be empty';
6868
}
6969

70+
protected get headers(): Record<string, string> | undefined {
71+
if (this.parameters.ifMatchesEtag) {
72+
return { 'If-Match': this.parameters.ifMatchesEtag };
73+
} else {
74+
return undefined;
75+
}
76+
}
77+
7078
async parse(response: TransportResponse): Promise<Response> {
7179
const serviceResponse = this.deserializeResponse<Response>(response);
7280

src/core/endpoints/objects/uuid/set.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ export class SetUUIDMetadataRequest<
7070
if (!this.parameters.data) return 'Data cannot be empty';
7171
}
7272

73+
protected get headers(): Record<string, string> | undefined {
74+
if (this.parameters.ifMatchesEtag) {
75+
return { 'If-Match': this.parameters.ifMatchesEtag };
76+
} else {
77+
return undefined;
78+
}
79+
}
80+
7381
async parse(response: TransportResponse): Promise<Response> {
7482
const serviceResponse = this.deserializeResponse<Response>(response);
7583

src/core/types/api/app-context.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,12 @@ export type SetUUIDMetadataParameters<Custom extends CustomData> = {
689689
* Fields which can be additionally included into response.
690690
*/
691691
include?: Omit<IncludeOptions, 'totalCount'>;
692+
693+
/**
694+
* Optional entity tag from a previously received `PNUUIDMetadata`. The request
695+
* will fail if this parameter is specified and the ETag value on the server doesn't match.
696+
*/
697+
ifMatchesEtag?: string;
692698
};
693699

694700
/**
@@ -827,6 +833,12 @@ export type SetChannelMetadataParameters<Custom extends CustomData> = {
827833
* Fields which can be additionally included into response.
828834
*/
829835
include?: Omit<IncludeOptions, 'totalCount'>;
836+
837+
/**
838+
* Optional entity tag from a previously received `PNUUIDMetadata`. The request
839+
* will fail if this parameter is specified and the ETag value on the server doesn't match.
840+
*/
841+
ifMatchesEtag?: string;
830842
};
831843

832844
/**

0 commit comments

Comments
 (0)