@selfcommunity/api-services 0.1.6-alpha.2 → 0.1.6-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/utils/apiRequest.js +1 -1
- package/lib/esm/utils/apiRequest.js +1 -1
- package/lib/{esm/api-services/src → types}/client/index.d.ts +0 -0
- package/lib/types/client/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/constants/Endpoints.d.ts +0 -0
- package/lib/types/constants/Endpoints.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/index.d.ts +0 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/category/index.d.ts +0 -0
- package/lib/types/services/category/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/comment/index.d.ts +0 -0
- package/lib/types/services/comment/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/custom_adv/index.d.ts +0 -0
- package/lib/types/services/custom_adv/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/custom_page/index.d.ts +0 -0
- package/lib/types/services/custom_page/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/data_portability/index.d.ts +0 -0
- package/lib/types/services/data_portability/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/embed/index.d.ts +0 -0
- package/lib/types/services/embed/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/feature/index.d.ts +0 -0
- package/lib/types/services/feature/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/feed/index.d.ts +0 -0
- package/lib/types/services/feed/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/feed_object/index.d.ts +0 -0
- package/lib/types/services/feed_object/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/incubator/index.d.ts +0 -0
- package/lib/types/services/incubator/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/insight/index.d.ts +0 -0
- package/lib/types/services/insight/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/legal_page/index.d.ts +0 -0
- package/lib/types/services/legal_page/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/locality/index.d.ts +0 -0
- package/lib/types/services/locality/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/loyalty/index.d.ts +0 -0
- package/lib/types/services/loyalty/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/media/index.d.ts +0 -0
- package/lib/types/services/media/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/moderation/index.d.ts +0 -0
- package/lib/types/services/moderation/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/notification/index.d.ts +0 -0
- package/lib/types/services/notification/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/preference/index.d.ts +0 -0
- package/lib/types/services/preference/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/private_message/index.d.ts +0 -0
- package/lib/types/services/private_message/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/score/index.d.ts +0 -0
- package/lib/types/services/score/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/sso/index.d.ts +0 -0
- package/lib/types/services/sso/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/suggestion/index.d.ts +0 -0
- package/lib/types/services/suggestion/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/tag/index.d.ts +0 -0
- package/lib/types/services/tag/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/user/index.d.ts +0 -0
- package/lib/types/services/user/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/services/webhook/index.d.ts +0 -0
- package/lib/types/services/webhook/index.d.ts.map +1 -0
- package/lib/types/tsconfig.build.tsbuildinfo +1 -0
- package/lib/{esm/api-services/src → types}/types/index.d.ts +0 -0
- package/lib/types/types/index.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/types/paginatedResponse.d.ts +0 -0
- package/lib/types/types/paginatedResponse.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/types/webhook.d.ts +0 -0
- package/lib/types/types/webhook.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/utils/apiRequest.d.ts +0 -0
- package/lib/types/utils/apiRequest.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/utils/http.d.ts +0 -0
- package/lib/types/utils/http.d.ts.map +1 -0
- package/lib/{esm/api-services/src → types}/utils/token.d.ts +0 -0
- package/lib/types/utils/token.d.ts.map +1 -0
- package/lib/umd/api-services.js +1 -1
- package/lib/umd/api-services.js.map +1 -1
- package/package.json +6 -5
- package/lib/esm/api-services/src/client/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/constants/Endpoints.d.ts.map +0 -1
- package/lib/esm/api-services/src/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/category/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/comment/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/custom_adv/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/custom_page/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/data_portability/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/embed/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/feature/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/feed/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/feed_object/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/incubator/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/insight/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/legal_page/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/locality/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/loyalty/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/media/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/moderation/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/notification/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/preference/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/private_message/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/score/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/sso/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/suggestion/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/tag/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/user/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/services/webhook/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/types/index.d.ts.map +0 -1
- package/lib/esm/api-services/src/types/paginatedResponse.d.ts.map +0 -1
- package/lib/esm/api-services/src/types/webhook.d.ts.map +0 -1
- package/lib/esm/api-services/src/utils/apiRequest.d.ts.map +0 -1
- package/lib/esm/api-services/src/utils/http.d.ts.map +0 -1
- package/lib/esm/api-services/src/utils/token.d.ts.map +0 -1
- package/lib/esm/types/src/index.d.ts +0 -9
- package/lib/esm/types/src/index.d.ts.map +0 -1
- package/lib/esm/types/src/types/auth.d.ts +0 -26
- package/lib/esm/types/src/types/auth.d.ts.map +0 -1
- package/lib/esm/types/src/types/broadcastMessage.d.ts +0 -73
- package/lib/esm/types/src/types/broadcastMessage.d.ts.map +0 -1
- package/lib/esm/types/src/types/category.d.ts +0 -100
- package/lib/esm/types/src/types/category.d.ts.map +0 -1
- package/lib/esm/types/src/types/comment.d.ts +0 -97
- package/lib/esm/types/src/types/comment.d.ts.map +0 -1
- package/lib/esm/types/src/types/customAdv.d.ts +0 -53
- package/lib/esm/types/src/types/customAdv.d.ts.map +0 -1
- package/lib/esm/types/src/types/customNotification.d.ts +0 -28
- package/lib/esm/types/src/types/customNotification.d.ts.map +0 -1
- package/lib/esm/types/src/types/embed.d.ts +0 -33
- package/lib/esm/types/src/types/embed.d.ts.map +0 -1
- package/lib/esm/types/src/types/feed.d.ts +0 -208
- package/lib/esm/types/src/types/feed.d.ts.map +0 -1
- package/lib/esm/types/src/types/incubator.d.ts +0 -53
- package/lib/esm/types/src/types/incubator.d.ts.map +0 -1
- package/lib/esm/types/src/types/index.d.ts +0 -23
- package/lib/esm/types/src/types/index.d.ts.map +0 -1
- package/lib/esm/types/src/types/location.d.ts +0 -61
- package/lib/esm/types/src/types/location.d.ts.map +0 -1
- package/lib/esm/types/src/types/media.d.ts +0 -52
- package/lib/esm/types/src/types/media.d.ts.map +0 -1
- package/lib/esm/types/src/types/notification.d.ts +0 -416
- package/lib/esm/types/src/types/notification.d.ts.map +0 -1
- package/lib/esm/types/src/types/poll.d.ts +0 -77
- package/lib/esm/types/src/types/poll.d.ts.map +0 -1
- package/lib/esm/types/src/types/privateMessage.d.ts +0 -109
- package/lib/esm/types/src/types/privateMessage.d.ts.map +0 -1
- package/lib/esm/types/src/types/prize.d.ts +0 -48
- package/lib/esm/types/src/types/prize.d.ts.map +0 -1
- package/lib/esm/types/src/types/tag.d.ts +0 -47
- package/lib/esm/types/src/types/tag.d.ts.map +0 -1
- package/lib/esm/types/src/types/user.d.ts +0 -231
- package/lib/esm/types/src/types/user.d.ts.map +0 -1
- package/lib/esm/types/src/types/webhook.d.ts +0 -91
- package/lib/esm/types/src/types/webhook.d.ts.map +0 -1
- package/lib/esm/utils/src/index.d.ts +0 -12
- package/lib/esm/utils/src/index.d.ts.map +0 -1
- package/lib/esm/utils/src/utils/browser.d.ts +0 -9
- package/lib/esm/utils/src/utils/browser.d.ts.map +0 -1
- package/lib/esm/utils/src/utils/logger.d.ts +0 -11
- package/lib/esm/utils/src/utils/logger.d.ts.map +0 -1
- package/lib/esm/utils/src/utils/object.d.ts +0 -13
- package/lib/esm/utils/src/utils/object.d.ts.map +0 -1
- package/lib/esm/utils/src/utils/string.d.ts +0 -43
- package/lib/esm/utils/src/utils/string.d.ts.map +0 -1
- package/lib/esm/utils/src/utils/url.d.ts +0 -33
- package/lib/esm/utils/src/utils/url.d.ts.map +0 -1
- package/lib/esm/utils/src/utils/websocket.d.ts +0 -177
- package/lib/esm/utils/src/utils/websocket.d.ts.map +0 -1
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WSClientPropTypes interface
|
|
3
|
-
*/
|
|
4
|
-
export interface WSClientPropTypes {
|
|
5
|
-
/**
|
|
6
|
-
* The Websocket URI
|
|
7
|
-
*/
|
|
8
|
-
uri: string;
|
|
9
|
-
/**
|
|
10
|
-
* The Websocket Protocols
|
|
11
|
-
*/
|
|
12
|
-
protocols: string | string[];
|
|
13
|
-
/**
|
|
14
|
-
* String to identify the heartbeat message.
|
|
15
|
-
*/
|
|
16
|
-
heartbeatMsg?: string;
|
|
17
|
-
/**
|
|
18
|
-
* Reconnect the websocket if close
|
|
19
|
-
*/
|
|
20
|
-
mustReconnect?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Callback called after the websocket is connected.
|
|
23
|
-
*/
|
|
24
|
-
connected?: () => any;
|
|
25
|
-
/**
|
|
26
|
-
* Callback called when the websocket is connecting.
|
|
27
|
-
*/
|
|
28
|
-
connecting?: () => any;
|
|
29
|
-
/**
|
|
30
|
-
* Callback called after the websocket is disconnected.
|
|
31
|
-
*/
|
|
32
|
-
disconnected?: (evt: any) => any;
|
|
33
|
-
/**
|
|
34
|
-
* Callback called when a message is received from the websocket.
|
|
35
|
-
*/
|
|
36
|
-
receiveMessage?: (data: any) => any;
|
|
37
|
-
/**
|
|
38
|
-
* Enable/disable debug
|
|
39
|
-
*/
|
|
40
|
-
debug?: boolean;
|
|
41
|
-
}
|
|
42
|
-
export interface WSClientType {
|
|
43
|
-
/**
|
|
44
|
-
* Send message
|
|
45
|
-
* @param message
|
|
46
|
-
*/
|
|
47
|
-
sendMessage: (message: any) => void;
|
|
48
|
-
/**
|
|
49
|
-
* Get current state
|
|
50
|
-
*/
|
|
51
|
-
getState: () => string;
|
|
52
|
-
/**
|
|
53
|
-
* Get current connection state
|
|
54
|
-
*/
|
|
55
|
-
isConnecting: () => boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Check if ws is connected
|
|
58
|
-
*/
|
|
59
|
-
isConnected: () => boolean;
|
|
60
|
-
/**
|
|
61
|
-
* Check if ws is closing connection
|
|
62
|
-
*/
|
|
63
|
-
isClosing: () => boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Return if ws is closed
|
|
66
|
-
*/
|
|
67
|
-
isClosed: () => boolean;
|
|
68
|
-
/**
|
|
69
|
-
* Close the connection
|
|
70
|
-
*/
|
|
71
|
-
close: () => void;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* WSClient: manage socket connection
|
|
75
|
-
* @param options
|
|
76
|
-
* @constructor
|
|
77
|
-
*/
|
|
78
|
-
export default class WSClient implements WSClientType {
|
|
79
|
-
private static _instance;
|
|
80
|
-
private _cfg;
|
|
81
|
-
private _ws;
|
|
82
|
-
private _timer;
|
|
83
|
-
private _attempts;
|
|
84
|
-
private _heartbeatInterval;
|
|
85
|
-
private _missedHeartbeats;
|
|
86
|
-
/**
|
|
87
|
-
* Constructor
|
|
88
|
-
* @param cfg
|
|
89
|
-
*/
|
|
90
|
-
constructor(cfg: WSClientPropTypes);
|
|
91
|
-
/**
|
|
92
|
-
* Get instance
|
|
93
|
-
*/
|
|
94
|
-
static getInstance(cfg: any): WSClient;
|
|
95
|
-
/**
|
|
96
|
-
* Connect
|
|
97
|
-
*/
|
|
98
|
-
connect(): void;
|
|
99
|
-
/**
|
|
100
|
-
* Validate options
|
|
101
|
-
* @param cfg
|
|
102
|
-
*/
|
|
103
|
-
isValidOptions(cfg: WSClientPropTypes): boolean;
|
|
104
|
-
/**
|
|
105
|
-
* Try to reconnect if previous connection failed
|
|
106
|
-
* Generate an interval, after that try to reconnect
|
|
107
|
-
*/
|
|
108
|
-
tryToReconnect(): void;
|
|
109
|
-
/**
|
|
110
|
-
* Reestablish the connection
|
|
111
|
-
* Increase the number of attempts
|
|
112
|
-
*/
|
|
113
|
-
reconnect(): void;
|
|
114
|
-
/**
|
|
115
|
-
* Send heartbeat every 5 seconds
|
|
116
|
-
* If missing more than 3 heartbeats close connection
|
|
117
|
-
*/
|
|
118
|
-
sendHeartbeat(): void;
|
|
119
|
-
/**
|
|
120
|
-
* Established the new connection
|
|
121
|
-
* Reset this._attempts counter
|
|
122
|
-
*/
|
|
123
|
-
onOpen(): void;
|
|
124
|
-
/**
|
|
125
|
-
* Connection closed. Try to reconnect.
|
|
126
|
-
* @param evt
|
|
127
|
-
*/
|
|
128
|
-
onClose(evt: any): void;
|
|
129
|
-
/**
|
|
130
|
-
* An error occured
|
|
131
|
-
* @param evt
|
|
132
|
-
*/
|
|
133
|
-
onError(evt: any): void;
|
|
134
|
-
/**
|
|
135
|
-
* A message has arrived.
|
|
136
|
-
* If it is the heartbeat -> reset this._missedHeartbeats
|
|
137
|
-
* If it is data pass data to the callback
|
|
138
|
-
* @param evt
|
|
139
|
-
*/
|
|
140
|
-
onMessage(evt: any): any;
|
|
141
|
-
/**
|
|
142
|
-
* Generate an interval that is randomly between 0 and 2^k - 1, where k is
|
|
143
|
-
* the number of connection attmpts, with a maximum interval of 30 seconds,
|
|
144
|
-
* so it starts at 0 - 1 seconds and maxes out at 0 - 30 seconds
|
|
145
|
-
*/
|
|
146
|
-
generateInteval(k: any): number;
|
|
147
|
-
/**
|
|
148
|
-
* Send message
|
|
149
|
-
* @param message
|
|
150
|
-
*/
|
|
151
|
-
sendMessage(message: any): void;
|
|
152
|
-
/**
|
|
153
|
-
* Get the ws state
|
|
154
|
-
*/
|
|
155
|
-
getState(): any;
|
|
156
|
-
/**
|
|
157
|
-
* Check if ws is in connecting state
|
|
158
|
-
*/
|
|
159
|
-
isConnecting(): boolean;
|
|
160
|
-
/**
|
|
161
|
-
* Check if ws is connected
|
|
162
|
-
*/
|
|
163
|
-
isConnected(): boolean;
|
|
164
|
-
/**
|
|
165
|
-
* Check if ws is in closing state
|
|
166
|
-
*/
|
|
167
|
-
isClosing(): boolean;
|
|
168
|
-
/**
|
|
169
|
-
* Check if ws is closed
|
|
170
|
-
*/
|
|
171
|
-
isClosed(): boolean;
|
|
172
|
-
/**
|
|
173
|
-
* Close the connection
|
|
174
|
-
*/
|
|
175
|
-
close(): void;
|
|
176
|
-
}
|
|
177
|
-
//# sourceMappingURL=websocket.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"websocket.d.ts","sourceRoot":"","sources":["../../../../../../utils/src/utils/websocket.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE7B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC;IAEtB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,CAAC;IAEvB;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,GAAG,KAAA,KAAK,GAAG,CAAC;IAE5B;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,IAAI,KAAA,KAAK,GAAG,CAAC;IAE/B;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,WAAW,EAAE,CAAC,OAAO,KAAA,KAAK,IAAI,CAAC;IAE/B;;OAEG;IACH,QAAQ,EAAE,MAAM,MAAM,CAAC;IAEvB;;OAEG;IACH,YAAY,EAAE,MAAM,OAAO,CAAC;IAE5B;;OAEG;IACH,WAAW,EAAE,MAAM,OAAO,CAAC;IAE3B;;OAEG;IACH,SAAS,EAAE,MAAM,OAAO,CAAC;IAEzB;;OAEG;IACH,QAAQ,EAAE,MAAM,OAAO,CAAC;IAExB;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,QAAS,YAAW,YAAY;IACnD,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC;IACzB,OAAO,CAAC,IAAI,CAAC;IACb,OAAO,CAAC,GAAG,CAAC;IACZ,OAAO,CAAC,MAAM,CAAC;IACf,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,kBAAkB,CAAQ;IAClC,OAAO,CAAC,iBAAiB,CAAK;IAE9B;;;OAGG;gBACS,GAAG,EAAE,iBAAiB;IAQlC;;OAEG;WACW,WAAW,CAAC,GAAG,KAAA,GAAG,QAAQ;IAKxC;;OAEG;IACH,OAAO;IAyBP;;;OAGG;IACH,cAAc,CAAC,GAAG,EAAE,iBAAiB;IAqCrC;;;OAGG;IACH,cAAc;IAQd;;;OAGG;IACH,SAAS;IAKT;;;OAGG;IACH,aAAa;IAeb;;;OAGG;IACH,MAAM;IAUN;;;OAGG;IACH,OAAO,CAAC,GAAG,KAAA;IAMX;;;OAGG;IACH,OAAO,CAAC,GAAG,KAAA;IAKX;;;;;OAKG;IACH,SAAS,CAAC,GAAG,KAAA;IASb;;;;OAIG;IACH,eAAe,CAAC,CAAC,KAAA;IAUjB;;;OAGG;IACI,WAAW,CAAC,OAAO,KAAA;IAI1B;;OAEG;IACI,QAAQ;IAIf;;OAEG;IACI,YAAY;IAInB;;OAEG;IACI,WAAW;IAIlB;;OAEG;IACI,SAAS;IAIhB;;OAEG;IACI,QAAQ;IAIf;;OAEG;IACI,KAAK;CAQb"}
|