Skip to content

Commit f09df2b

Browse files
mohitpubnubClient Engineering Bot
and
Client Engineering Bot
authored
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 [email protected]>
1 parent 26d6baf commit f09df2b

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,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ var endpoint = {
4141
prepareParams: function (_modules, params) {
4242
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
4343
var queryParams = {};
44+
queryParams.include = ['uuid.status', 'uuid.type', 'type'];
4445
if (params === null || params === void 0 ? void 0 : params.include) {
45-
queryParams.include = [];
4646
if ((_a = params.include) === null || _a === void 0 ? void 0 : _a.customFields) {
4747
queryParams.include.push('custom');
4848
}
@@ -52,8 +52,8 @@ var endpoint = {
5252
if ((_d = (_c = params.include) === null || _c === void 0 ? void 0 : _c.UUIDFields) !== null && _d !== void 0 ? _d : true) {
5353
queryParams.include.push('uuid');
5454
}
55-
queryParams.include = queryParams.include.join(',');
5655
}
56+
queryParams.include = queryParams.include.join(',');
5757
if ((_e = params === null || params === void 0 ? void 0 : params.include) === null || _e === void 0 ? void 0 : _e.totalCount) {
5858
queryParams.count = (_f = params.include) === null || _f === void 0 ? void 0 : _f.totalCount;
5959
}

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

Lines changed: 5 additions & 5 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;
@@ -41,7 +40,7 @@ var endpoint = {
4140
var _a;
4241
return (_a = {
4342
set: [],
44-
remove: []
43+
delete: []
4544
},
4645
_a[params.type] = params.uuids.map(function (uuid) {
4746
if (typeof uuid === 'string') {
@@ -54,6 +53,7 @@ var endpoint = {
5453
return {
5554
uuid: { id: uuid.id },
5655
custom: uuid.custom,
56+
status: uuid.status,
5757
};
5858
}),
5959
_a);
@@ -66,8 +66,8 @@ var endpoint = {
6666
prepareParams: function (_modules, params) {
6767
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
6868
var queryParams = {};
69+
queryParams.include = ['uuid.status', 'uuid.type', 'type'];
6970
if (params === null || params === void 0 ? void 0 : params.include) {
70-
queryParams.include = [];
7171
if ((_a = params.include) === null || _a === void 0 ? void 0 : _a.customFields) {
7272
queryParams.include.push('custom');
7373
}
@@ -77,8 +77,8 @@ var endpoint = {
7777
if ((_c = params.include) === null || _c === void 0 ? void 0 : _c.UUIDFields) {
7878
queryParams.include.push('uuid');
7979
}
80-
queryParams.include = queryParams.include.join(',');
8180
}
81+
queryParams.include = queryParams.include.join(',');
8282
if ((_d = params === null || params === void 0 ? void 0 : params.include) === null || _d === void 0 ? void 0 : _d.totalCount) {
8383
queryParams.count = true;
8484
}
@@ -91,7 +91,7 @@ var endpoint = {
9191
if (params === null || params === void 0 ? void 0 : params.filter) {
9292
queryParams.filter = params.filter;
9393
}
94-
if (params === null || params === void 0 ? void 0 : params.limit) {
94+
if (params.limit != null) {
9595
queryParams.limit = params.limit;
9696
}
9797
if (params === null || params === void 0 ? void 0 : params.sort) {

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

Lines changed: 2 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;
@@ -40,8 +39,8 @@ var endpoint = {
4039
prepareParams: function (_modules, params) {
4140
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
4241
var queryParams = {};
42+
queryParams.include = ['channel.status', 'channel.type', 'status'];
4343
if (params === null || params === void 0 ? void 0 : params.include) {
44-
queryParams.include = [];
4544
if ((_a = params.include) === null || _a === void 0 ? void 0 : _a.customFields) {
4645
queryParams.include.push('custom');
4746
}
@@ -51,8 +50,8 @@ var endpoint = {
5150
if ((_c = params.include) === null || _c === void 0 ? void 0 : _c.channelFields) {
5251
queryParams.include.push('channel');
5352
}
54-
queryParams.include = queryParams.include.join(',');
5553
}
54+
queryParams.include = queryParams.include.join(',');
5655
if ((_d = params === null || params === void 0 ? void 0 : params.include) === null || _d === void 0 ? void 0 : _d.totalCount) {
5756
queryParams.count = (_e = params.include) === null || _e === void 0 ? void 0 : _e.totalCount;
5857
}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var endpoint = {
3939
var _a;
4040
return (_a = {
4141
set: [],
42-
remove: []
42+
delete: []
4343
},
4444
_a[params.type] = params.channels.map(function (channel) {
4545
if (typeof channel === 'string') {
@@ -52,6 +52,7 @@ var endpoint = {
5252
return {
5353
channel: { id: channel.id },
5454
custom: channel.custom,
55+
status: channel.status,
5556
};
5657
}),
5758
_a);
@@ -64,8 +65,8 @@ var endpoint = {
6465
prepareParams: function (_modules, params) {
6566
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
6667
var queryParams = {};
68+
queryParams.include = ['channel.status', 'channel.type', 'status'];
6769
if (params === null || params === void 0 ? void 0 : params.include) {
68-
queryParams.include = [];
6970
if ((_a = params.include) === null || _a === void 0 ? void 0 : _a.customFields) {
7071
queryParams.include.push('custom');
7172
}
@@ -75,8 +76,8 @@ var endpoint = {
7576
if ((_c = params.include) === null || _c === void 0 ? void 0 : _c.channelFields) {
7677
queryParams.include.push('channel');
7778
}
78-
queryParams.include = queryParams.include.join(',');
7979
}
80+
queryParams.include = queryParams.include.join(',');
8081
if ((_d = params === null || params === void 0 ? void 0 : params.include) === null || _d === void 0 ? void 0 : _d.totalCount) {
8182
queryParams.count = true;
8283
}
@@ -89,7 +90,7 @@ var endpoint = {
8990
if (params === null || params === void 0 ? void 0 : params.filter) {
9091
queryParams.filter = params.filter;
9192
}
92-
if (params === null || params === void 0 ? void 0 : params.limit) {
93+
if (params.limit != null) {
9394
queryParams.limit = params.limit;
9495
}
9596
if (params === null || params === void 0 ? void 0 : params.sort) {

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,18 @@ var endpoint = {
2222
},
2323
isAuthSupported: function () { return true; },
2424
prepareParams: function (_a, params) {
25-
var _b, _c, _d;
25+
var _b, _c;
2626
var config = _a.config;
27-
return ({
28-
uuid: (_b = params === null || params === void 0 ? void 0 : params.uuid) !== null && _b !== void 0 ? _b : config.getUUID(),
29-
include: ((_d = (_c = params === null || params === void 0 ? void 0 : params.include) === null || _c === void 0 ? void 0 : _c.customFields) !== null && _d !== void 0 ? _d : true) && 'custom',
30-
});
27+
var queryParams = {};
28+
queryParams.uuid = (_b = params === null || params === void 0 ? void 0 : params.uuid) !== null && _b !== void 0 ? _b : config.getUUID();
29+
queryParams.include = ['status', 'type', 'custom'];
30+
if (params === null || params === void 0 ? void 0 : params.include) {
31+
if (((_c = params.include) === null || _c === void 0 ? void 0 : _c.customFields) === false) {
32+
queryParams.include.pop();
33+
}
34+
}
35+
queryParams.include = queryParams.include.join(',');
36+
return queryParams;
3137
},
3238
handleResponse: function (_, response) { return ({
3339
status: response.status,

0 commit comments

Comments
 (0)