Skip to content

Commit 856ff28

Browse files
committed
fix(interface): add missing new retry policy as static field of PubNub
Add missing `NoneRetryPolicy` static field for `PubNub` class. refactor(retry-policy): change `None` retry policy to function `RetryPolicy.None` exported as a function to not affect tree-shaking and modules exclusion possibilities.
1 parent b283e9e commit 856ff28

File tree

8 files changed

+246
-13
lines changed

8 files changed

+246
-13
lines changed

dist/web/pubnub.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3777,38 +3777,96 @@
37773777
Endpoint["Unknown"] = "UnknownEndpoint";
37783778
/**
37793779
* The endpoints to send messages.
3780+
*
3781+
* This is related to the following functionality:
3782+
* - `publish`
3783+
* - `signal`
3784+
* - `publish file`
3785+
* - `fire`
37803786
*/
37813787
Endpoint["MessageSend"] = "MessageSendEndpoint";
37823788
/**
37833789
* The endpoint for real-time update retrieval.
3790+
*
3791+
* This is related to the following functionality:
3792+
* - `subscribe`
37843793
*/
37853794
Endpoint["Subscribe"] = "SubscribeEndpoint";
37863795
/**
37873796
* The endpoint to access and manage `user_id` presence and fetch channel presence information.
3797+
*
3798+
* This is related to the following functionality:
3799+
* - `get presence state`
3800+
* - `set presence state`
3801+
* - `here now`
3802+
* - `where now`
3803+
* - `heartbeat`
37883804
*/
37893805
Endpoint["Presence"] = "PresenceEndpoint";
37903806
/**
37913807
* The endpoint to access and manage files in channel-specific storage.
3808+
*
3809+
* This is related to the following functionality:
3810+
* - `send file`
3811+
* - `download file`
3812+
* - `list files`
3813+
* - `delete file`
37923814
*/
37933815
Endpoint["Files"] = "FilesEndpoint";
37943816
/**
37953817
* The endpoint to access and manage messages for a specific channel(s) in the persistent storage.
3818+
*
3819+
* This is related to the following functionality:
3820+
* - `fetch messages / message actions`
3821+
* - `delete messages`
3822+
* - `messages count`
37963823
*/
37973824
Endpoint["MessageStorage"] = "MessageStorageEndpoint";
37983825
/**
37993826
* The endpoint to access and manage channel groups.
3827+
*
3828+
* This is related to the following functionality:
3829+
* - `add channels to group`
3830+
* - `list channels in group`
3831+
* - `remove channels from group`
3832+
* - `list channel groups`
38003833
*/
38013834
Endpoint["ChannelGroups"] = "ChannelGroupsEndpoint";
38023835
/**
38033836
* The endpoint to access and manage device registration for channel push notifications.
3837+
*
3838+
* This is related to the following functionality:
3839+
* - `enable channels for push notifications`
3840+
* - `list push notification enabled channels`
3841+
* - `disable push notifications for channels`
3842+
* - `disable push notifications for all channels`
38043843
*/
38053844
Endpoint["DevicePushNotifications"] = "DevicePushNotificationsEndpoint";
38063845
/**
38073846
* The endpoint to access and manage App Context objects.
3847+
*
3848+
* This is related to the following functionality:
3849+
* - `set UUID metadata`
3850+
* - `get UUID metadata`
3851+
* - `remove UUID metadata`
3852+
* - `get all UUID metadata`
3853+
* - `set Channel metadata`
3854+
* - `get Channel metadata`
3855+
* - `remove Channel metadata`
3856+
* - `get all Channel metadata`
3857+
* - `manage members`
3858+
* - `list members`
3859+
* - `manage memberships`
3860+
* - `list memberships`
38083861
*/
38093862
Endpoint["AppContext"] = "AppContextEndpoint";
38103863
/**
38113864
* The endpoint to access and manage reactions for a specific message.
3865+
*
3866+
* This is related to the following functionality:
3867+
* - `add message action`
3868+
* - `get message actions`
3869+
* - `remove message action`
38123870
*/
38133871
Endpoint["MessageReactions"] = "MessageReactionsEndpoint";
38143872
})(Endpoint || (Endpoint = {}));
@@ -3817,6 +3875,19 @@
38173875
* Failed request retry policy.
38183876
*/
38193877
class RetryPolicy {
3878+
static None() {
3879+
return {
3880+
shouldRetry(_request, _response, _errorCategory, _attempt) {
3881+
return false;
3882+
},
3883+
getDelay(_attempt, _response) {
3884+
return -1;
3885+
},
3886+
validate() {
3887+
return true;
3888+
},
3889+
};
3890+
}
38203891
static LinearRetryPolicy(configuration) {
38213892
var _a;
38223893
return {
@@ -14656,6 +14727,13 @@
1465614727
* Linear retry policy constructor.
1465714728
*/
1465814729
PubNubCore.LinearRetryPolicy = RetryPolicy.LinearRetryPolicy;
14730+
/**
14731+
* Disabled / inactive retry policy.
14732+
*
14733+
* **Note:** By default `ExponentialRetryPolicy` is set for subscribe requests and this one can be used to disable
14734+
* retry policy for all requests (setting `undefined` for retry configuration will set default policy).
14735+
*/
14736+
PubNubCore.NoneRetryPolicy = RetryPolicy.None;
1465914737

1466014738
/**
1466114739
* Cbor decoder module.

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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const makeConfiguration = (base, setupCryptoModule) => {
3535
var _a, _b, _c;
3636
// Set default retry policy for subscribe (if new subscribe logic not used).
3737
if (!base.retryConfiguration && base.enableEventEngine) {
38+
const s = retryPolicy_1.RetryPolicy.None;
3839
base.retryConfiguration = retryPolicy_1.RetryPolicy.ExponentialRetryPolicy({
3940
minimumDelay: 2,
4041
maximumDelay: 150,

lib/core/components/retryPolicy.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,96 @@ var Endpoint;
2222
Endpoint["Unknown"] = "UnknownEndpoint";
2323
/**
2424
* The endpoints to send messages.
25+
*
26+
* This is related to the following functionality:
27+
* - `publish`
28+
* - `signal`
29+
* - `publish file`
30+
* - `fire`
2531
*/
2632
Endpoint["MessageSend"] = "MessageSendEndpoint";
2733
/**
2834
* The endpoint for real-time update retrieval.
35+
*
36+
* This is related to the following functionality:
37+
* - `subscribe`
2938
*/
3039
Endpoint["Subscribe"] = "SubscribeEndpoint";
3140
/**
3241
* The endpoint to access and manage `user_id` presence and fetch channel presence information.
42+
*
43+
* This is related to the following functionality:
44+
* - `get presence state`
45+
* - `set presence state`
46+
* - `here now`
47+
* - `where now`
48+
* - `heartbeat`
3349
*/
3450
Endpoint["Presence"] = "PresenceEndpoint";
3551
/**
3652
* The endpoint to access and manage files in channel-specific storage.
53+
*
54+
* This is related to the following functionality:
55+
* - `send file`
56+
* - `download file`
57+
* - `list files`
58+
* - `delete file`
3759
*/
3860
Endpoint["Files"] = "FilesEndpoint";
3961
/**
4062
* The endpoint to access and manage messages for a specific channel(s) in the persistent storage.
63+
*
64+
* This is related to the following functionality:
65+
* - `fetch messages / message actions`
66+
* - `delete messages`
67+
* - `messages count`
4168
*/
4269
Endpoint["MessageStorage"] = "MessageStorageEndpoint";
4370
/**
4471
* The endpoint to access and manage channel groups.
72+
*
73+
* This is related to the following functionality:
74+
* - `add channels to group`
75+
* - `list channels in group`
76+
* - `remove channels from group`
77+
* - `list channel groups`
4578
*/
4679
Endpoint["ChannelGroups"] = "ChannelGroupsEndpoint";
4780
/**
4881
* The endpoint to access and manage device registration for channel push notifications.
82+
*
83+
* This is related to the following functionality:
84+
* - `enable channels for push notifications`
85+
* - `list push notification enabled channels`
86+
* - `disable push notifications for channels`
87+
* - `disable push notifications for all channels`
4988
*/
5089
Endpoint["DevicePushNotifications"] = "DevicePushNotificationsEndpoint";
5190
/**
5291
* The endpoint to access and manage App Context objects.
92+
*
93+
* This is related to the following functionality:
94+
* - `set UUID metadata`
95+
* - `get UUID metadata`
96+
* - `remove UUID metadata`
97+
* - `get all UUID metadata`
98+
* - `set Channel metadata`
99+
* - `get Channel metadata`
100+
* - `remove Channel metadata`
101+
* - `get all Channel metadata`
102+
* - `manage members`
103+
* - `list members`
104+
* - `manage memberships`
105+
* - `list memberships`
53106
*/
54107
Endpoint["AppContext"] = "AppContextEndpoint";
55108
/**
56109
* The endpoint to access and manage reactions for a specific message.
110+
*
111+
* This is related to the following functionality:
112+
* - `add message action`
113+
* - `get message actions`
114+
* - `remove message action`
57115
*/
58116
Endpoint["MessageReactions"] = "MessageReactionsEndpoint";
59117
})(Endpoint || (exports.Endpoint = Endpoint = {}));
@@ -62,6 +120,19 @@ var Endpoint;
62120
* Failed request retry policy.
63121
*/
64122
class RetryPolicy {
123+
static None() {
124+
return {
125+
shouldRetry(_request, _response, _errorCategory, _attempt) {
126+
return false;
127+
},
128+
getDelay(_attempt, _response) {
129+
return -1;
130+
},
131+
validate() {
132+
return true;
133+
},
134+
};
135+
}
65136
static LinearRetryPolicy(configuration) {
66137
var _a;
67138
return {

lib/core/pubnub-common.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,3 +2224,10 @@ PubNubCore.ExponentialRetryPolicy = retryPolicy_1.RetryPolicy.ExponentialRetryPo
22242224
* Linear retry policy constructor.
22252225
*/
22262226
PubNubCore.LinearRetryPolicy = retryPolicy_1.RetryPolicy.LinearRetryPolicy;
2227+
/**
2228+
* Disabled / inactive retry policy.
2229+
*
2230+
* **Note:** By default `ExponentialRetryPolicy` is set for subscribe requests and this one can be used to disable
2231+
* retry policy for all requests (setting `undefined` for retry configuration will set default policy).
2232+
*/
2233+
PubNubCore.NoneRetryPolicy = retryPolicy_1.RetryPolicy.None;

lib/types/index.d.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ declare class PubNubCore<
6161
* Linear retry policy constructor.
6262
*/
6363
static LinearRetryPolicy: typeof PubNub.RetryPolicy.LinearRetryPolicy;
64+
/**
65+
* Disabled / inactive retry policy.
66+
*
67+
* **Note:** By default `ExponentialRetryPolicy` is set for subscribe requests and this one can be used to disable
68+
* retry policy for all requests (setting `undefined` for retry configuration will set default policy).
69+
*/
70+
static NoneRetryPolicy: typeof PubNub.RetryPolicy.None;
6471
/**
6572
* Construct notification payload which will trigger push notification.
6673
*
@@ -2722,38 +2729,96 @@ declare namespace PubNub {
27222729
export enum Endpoint {
27232730
/**
27242731
* The endpoints to send messages.
2732+
*
2733+
* This is related to the following functionality:
2734+
* - `publish`
2735+
* - `signal`
2736+
* - `publish file`
2737+
* - `fire`
27252738
*/
27262739
MessageSend = 'MessageSendEndpoint',
27272740
/**
27282741
* The endpoint for real-time update retrieval.
2742+
*
2743+
* This is related to the following functionality:
2744+
* - `subscribe`
27292745
*/
27302746
Subscribe = 'SubscribeEndpoint',
27312747
/**
27322748
* The endpoint to access and manage `user_id` presence and fetch channel presence information.
2749+
*
2750+
* This is related to the following functionality:
2751+
* - `get presence state`
2752+
* - `set presence state`
2753+
* - `here now`
2754+
* - `where now`
2755+
* - `heartbeat`
27332756
*/
27342757
Presence = 'PresenceEndpoint',
27352758
/**
27362759
* The endpoint to access and manage files in channel-specific storage.
2760+
*
2761+
* This is related to the following functionality:
2762+
* - `send file`
2763+
* - `download file`
2764+
* - `list files`
2765+
* - `delete file`
27372766
*/
27382767
Files = 'FilesEndpoint',
27392768
/**
27402769
* The endpoint to access and manage messages for a specific channel(s) in the persistent storage.
2770+
*
2771+
* This is related to the following functionality:
2772+
* - `fetch messages / message actions`
2773+
* - `delete messages`
2774+
* - `messages count`
27412775
*/
27422776
MessageStorage = 'MessageStorageEndpoint',
27432777
/**
27442778
* The endpoint to access and manage channel groups.
2779+
*
2780+
* This is related to the following functionality:
2781+
* - `add channels to group`
2782+
* - `list channels in group`
2783+
* - `remove channels from group`
2784+
* - `list channel groups`
27452785
*/
27462786
ChannelGroups = 'ChannelGroupsEndpoint',
27472787
/**
27482788
* The endpoint to access and manage device registration for channel push notifications.
2789+
*
2790+
* This is related to the following functionality:
2791+
* - `enable channels for push notifications`
2792+
* - `list push notification enabled channels`
2793+
* - `disable push notifications for channels`
2794+
* - `disable push notifications for all channels`
27492795
*/
27502796
DevicePushNotifications = 'DevicePushNotificationsEndpoint',
27512797
/**
27522798
* The endpoint to access and manage App Context objects.
2799+
*
2800+
* This is related to the following functionality:
2801+
* - `set UUID metadata`
2802+
* - `get UUID metadata`
2803+
* - `remove UUID metadata`
2804+
* - `get all UUID metadata`
2805+
* - `set Channel metadata`
2806+
* - `get Channel metadata`
2807+
* - `remove Channel metadata`
2808+
* - `get all Channel metadata`
2809+
* - `manage members`
2810+
* - `list members`
2811+
* - `manage memberships`
2812+
* - `list memberships`
27532813
*/
27542814
AppContext = 'AppContextEndpoint',
27552815
/**
27562816
* The endpoint to access and manage reactions for a specific message.
2817+
*
2818+
* This is related to the following functionality:
2819+
* - `add message action`
2820+
* - `get message actions`
2821+
* - `remove message action`
27572822
*/
27582823
MessageReactions = 'MessageReactionsEndpoint',
27592824
}
@@ -2842,6 +2907,7 @@ declare namespace PubNub {
28422907
* Failed request retry policy.
28432908
*/
28442909
export class RetryPolicy {
2910+
static None(): RequestRetryPolicy;
28452911
static LinearRetryPolicy(
28462912
configuration: LinearRetryPolicyConfiguration,
28472913
): RequestRetryPolicy & LinearRetryPolicyConfiguration;

0 commit comments

Comments
 (0)