Skip to content

Commit f09df2b

Browse files
mohitpubnubClient Engineering Bot
andauthored
ref/memberships (#277)
* added `addMemberships`, `removeMemberships`, `updateMemberships` * lib files updates * added `fetchMemberships` * build files * refactor: update fetchMemberships response * membership apis: `include` params updates as per new api naming convention * dist and lib files * added `status` field for membership apis payload. Not required for user and space as it can be part of `data` param * dist and lib files * `sort` param compatibility with new convention for membership apis * lib and dist files * handled `null` value of `userId` scanerio with `fetchMemberships` call * handled `null` value of `userId` for `removeMembership` calls * * `include` query param changes for status and type fields. * removed empty file for channel and uuid * `include` param changes for new apis * lib files * fix: Default include: custom for set<entity> and get<entity> methods. * fix: typo in condition * * default include status and type fields in get,set,getAll. * Fixed tests * Minor indentation changes in changed files. * build files * * event listener for `user`, `space` and `membership` event types. * refactored dead listeners which were not emitting any events for user and space type. * PubNub SDK v7.1.1 release. Co-authored-by: Client Engineering Bot <60980775+Client Engineering Bot@users.noreply.github.com>
1 parent 26d6baf commit f09df2b

File tree

39 files changed

+743
-183
lines changed

39 files changed

+743
-183
lines changed

.pubnub.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
---
22
changelog:
3+
- date: 2022-06-14
4+
version: v7.1.1
5+
changes:
6+
- type: feature
7+
text: "Added user and space memberships related methods."
8+
- type: feature
9+
text: "Added `type` and `status` fields in `User` and `Space`. `status` field in memberships."
310
- date: 2022-05-24
411
version: v7.0.1
512
changes:
6-
13+
- type: bug
14+
text: "Fixes export issue for Node and update config for es module compatibility."
715
- date: 2022-05-24
816
version: v7.0.0
917
changes:
@@ -1116,7 +1124,7 @@ supported-platforms:
11161124
- "Ubuntu 14.04 and up"
11171125
- "Windows 7 and up"
11181126
version: "Pubnub Javascript for Node"
1119-
version: "7.0.1"
1127+
version: "7.1.1"
11201128
sdks:
11211129
-
11221130
full-name: PubNub Javascript SDK
@@ -1135,7 +1143,7 @@ sdks:
11351143
distribution-type: source
11361144
distribution-repository: GitHub release
11371145
package-name: pubnub.js
1138-
location: https://github.com/pubnub/javascript/archive/refs/tags/v7.0.1.zip
1146+
location: https://github.com/pubnub/javascript/archive/refs/tags/v7.1.1.zip
11391147
requires:
11401148
-
11411149
name: "agentkeepalive"
@@ -1899,7 +1907,7 @@ sdks:
18991907
distribution-type: library
19001908
distribution-repository: GitHub release
19011909
package-name: pubnub.js
1902-
location: https://github.com/pubnub/javascript/releases/download/v7.0.1/pubnub.7.0.1.js
1910+
location: https://github.com/pubnub/javascript/releases/download/v7.1.1/pubnub.7.1.1.js
19031911
requires:
19041912
-
19051913
name: "agentkeepalive"

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## v7.1.1
2+
June 14 2022
3+
4+
#### Added
5+
- Added user and space memberships related methods.
6+
- Added `type` and `status` fields in `User` and `Space`. `status` field in memberships.
7+
18
## v7.0.1
29
May 24 2022
310

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ You will need the publish and subscribe keys to authenticate your app. Get your
2222
npm install pubnub
2323
```
2424
* or download one of our builds from our CDN:
25-
* https://cdn.pubnub.com/sdk/javascript/pubnub.7.0.1.js
26-
* https://cdn.pubnub.com/sdk/javascript/pubnub.7.0.1.min.js
25+
* https://cdn.pubnub.com/sdk/javascript/pubnub.7.1.1.js
26+
* https://cdn.pubnub.com/sdk/javascript/pubnub.7.1.1.min.js
2727
2828
2. Configure your keys:
2929

dist/web/pubnub.js

Lines changed: 209 additions & 45 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/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ var default_1 = /** @class */ (function () {
148148
return this;
149149
};
150150
default_1.prototype.getVersion = function () {
151-
return '7.0.1';
151+
return '7.1.1';
152152
};
153153
default_1.prototype._addPnsdkSuffix = function (name, suffix) {
154154
this._PNSDKSuffix[name] = suffix;

lib/core/components/subscription_manager.js

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
11
"use strict";
2+
var __assign = (this && this.__assign) || function () {
3+
__assign = Object.assign || function(t) {
4+
for (var s, i = 1, n = arguments.length; i < n; i++) {
5+
s = arguments[i];
6+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7+
t[p] = s[p];
8+
}
9+
return t;
10+
};
11+
return __assign.apply(this, arguments);
12+
};
13+
var __rest = (this && this.__rest) || function (s, e) {
14+
var t = {};
15+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16+
t[p] = s[p];
17+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
18+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20+
t[p[i]] = s[p[i]];
21+
}
22+
return t;
23+
};
224
var __importDefault = (this && this.__importDefault) || function (mod) {
325
return (mod && mod.__esModule) ? mod : { "default": mod };
426
};
@@ -453,14 +475,20 @@ var default_1 = /** @class */ (function () {
453475
data: message.payload.data,
454476
};
455477
_this._listenerManager.announceObjects(announce);
456-
if (message.payload.type === 'user') {
457-
_this._listenerManager.announceUser(announce);
478+
if (message.payload.type === 'uuid') {
479+
var eventData = _this._renameChannelField(announce);
480+
_this._listenerManager.announceUser(__assign(__assign({}, eventData), { message: __assign(__assign({}, eventData.message), { event: _this._renameEvent(eventData.message.event), type: 'user' }) }));
458481
}
459-
else if (message.payload.type === 'space') {
460-
_this._listenerManager.announceSpace(announce);
482+
else if (message.payload.type === 'channel') {
483+
var eventData = _this._renameChannelField(announce);
484+
_this._listenerManager.announceSpace(__assign(__assign({}, eventData), { message: __assign(__assign({}, eventData.message), { event: _this._renameEvent(eventData.message.event), type: 'space' }) }));
461485
}
462486
else if (message.payload.type === 'membership') {
463-
_this._listenerManager.announceMembership(announce);
487+
var eventData = _this._renameChannelField(announce);
488+
var _a = eventData.message.data, user = _a.uuid, space = _a.channel, membershipData = __rest(_a, ["uuid", "channel"]);
489+
membershipData.user = user;
490+
membershipData.space = space;
491+
_this._listenerManager.announceMembership(__assign(__assign({}, eventData), { message: __assign(__assign({}, eventData.message), { event: _this._renameEvent(eventData.message.event), data: membershipData }) }));
464492
}
465493
}
466494
else if (message.messageType === 3) {
@@ -544,6 +572,14 @@ var default_1 = /** @class */ (function () {
544572
this._subscribeCall = null;
545573
}
546574
};
575+
default_1.prototype._renameEvent = function (e) {
576+
return e === 'set' ? 'updated' : 'removed';
577+
};
578+
default_1.prototype._renameChannelField = function (announce) {
579+
var channel = announce.channel, eventData = __rest(announce, ["channel"]);
580+
eventData.spaceId = channel;
581+
return eventData;
582+
};
547583
return default_1;
548584
}());
549585
exports.default = default_1;

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"use strict";
2-
/** */
32
var __importDefault = (this && this.__importDefault) || function (mod) {
43
return (mod && mod.__esModule) ? mod : { "default": mod };
54
};
@@ -23,10 +22,16 @@ var endpoint = {
2322
},
2423
isAuthSupported: function () { return true; },
2524
prepareParams: function (_, params) {
26-
var _a, _b;
27-
return ({
28-
include: ((_b = (_a = params === null || params === void 0 ? void 0 : params.include) === null || _a === void 0 ? void 0 : _a.customFields) !== null && _b !== void 0 ? _b : true) && 'custom',
29-
});
25+
var _a;
26+
var queryParams = {};
27+
queryParams.include = ['status', 'type', 'custom'];
28+
if (params === null || params === void 0 ? void 0 : params.include) {
29+
if (((_a = params.include) === null || _a === void 0 ? void 0 : _a.customFields) === false) {
30+
queryParams.include.pop();
31+
}
32+
}
33+
queryParams.include = queryParams.include.join(',');
34+
return queryParams;
3035
},
3136
handleResponse: function (_, response) { return ({
3237
status: response.status,

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"use strict";
2-
/** */
32
var __read = (this && this.__read) || function (o, n) {
43
var m = typeof Symbol === "function" && o[Symbol.iterator];
54
if (!m) return o;
@@ -38,9 +37,13 @@ var endpoint = {
3837
prepareParams: function (_modules, params) {
3938
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
4039
var queryParams = {};
41-
if ((_a = params === null || params === void 0 ? void 0 : params.include) === null || _a === void 0 ? void 0 : _a.customFields) {
42-
queryParams.include = 'custom';
40+
queryParams.include = ['status', 'type'];
41+
if (params === null || params === void 0 ? void 0 : params.include) {
42+
if ((_a = params.include) === null || _a === void 0 ? void 0 : _a.customFields) {
43+
queryParams.include.push('custom');
44+
}
4345
}
46+
queryParams.include = queryParams.include.join(',');
4447
if ((_b = params === null || params === void 0 ? void 0 : params.include) === null || _b === void 0 ? void 0 : _b.totalCount) {
4548
queryParams.count = (_c = params.include) === null || _c === void 0 ? void 0 : _c.totalCount;
4649
}

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,16 @@ var endpoint = {
2828
},
2929
isAuthSupported: function () { return true; },
3030
prepareParams: function (_, params) {
31-
var _a, _b;
32-
return ({
33-
include: ((_b = (_a = params === null || params === void 0 ? void 0 : params.include) === null || _a === void 0 ? void 0 : _a.customFields) !== null && _b !== void 0 ? _b : true) && 'custom',
34-
});
31+
var _a;
32+
var queryParams = {};
33+
queryParams.include = ['status', 'type', 'custom'];
34+
if (params === null || params === void 0 ? void 0 : params.include) {
35+
if (((_a = params.include) === null || _a === void 0 ? void 0 : _a.customFields) === false) {
36+
queryParams.include.pop();
37+
}
38+
}
39+
queryParams.include = queryParams.include.join(',');
40+
return queryParams;
3541
},
3642
handleResponse: function (_, response) { return ({
3743
status: response.status,

0 commit comments

Comments
 (0)