mavenagi 1.2.10 → 1.2.12
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/Client.d.ts +6 -0
- package/Client.js +32 -22
- package/api/resources/auth/client/Client.d.ts +33 -0
- package/api/resources/auth/client/Client.js +171 -0
- package/api/resources/auth/client/index.d.ts +1 -0
- package/api/resources/auth/client/index.js +2 -0
- package/api/resources/auth/index.d.ts +2 -0
- package/api/resources/auth/index.js +18 -0
- package/api/resources/auth/types/SessionTokenRequest.d.ts +3 -0
- package/api/resources/auth/types/SessionTokenRequest.js +3 -0
- package/api/resources/auth/types/SessionTokenResponse.d.ts +6 -0
- package/api/resources/auth/types/SessionTokenResponse.js +3 -0
- package/api/resources/auth/types/index.d.ts +2 -0
- package/api/resources/auth/types/index.js +18 -0
- package/api/resources/commons/types/ActionBase.d.ts +1 -11
- package/api/resources/commons/types/ActionParameterType.d.ts +3 -0
- package/api/resources/commons/types/ActionParameterType.js +3 -0
- package/api/resources/commons/types/ActionProperties.d.ts +13 -0
- package/api/resources/commons/types/ActionProperties.js +3 -0
- package/api/resources/commons/types/ActionUser.d.ts +46 -0
- package/api/resources/commons/types/ActionUser.js +3 -0
- package/api/resources/commons/types/EntityType.d.ts +1 -0
- package/api/resources/commons/types/EntityType.js +1 -0
- package/api/resources/commons/types/EventField.d.ts +1 -0
- package/api/resources/commons/types/EventField.js +1 -0
- package/api/resources/commons/types/MetadataPrecondition.d.ts +3 -1
- package/api/resources/commons/types/PreconditionOperator.d.ts +20 -0
- package/api/resources/commons/types/PreconditionOperator.js +20 -0
- package/api/resources/commons/types/UserEvent.d.ts +2 -0
- package/api/resources/commons/types/index.d.ts +3 -0
- package/api/resources/commons/types/index.js +3 -0
- package/api/resources/index.d.ts +4 -0
- package/api/resources/index.js +5 -1
- package/api/resources/knowledge/types/KnowledgeBaseResponse.d.ts +2 -0
- package/api/resources/knowledge/types/KnowledgeDocumentRequest.d.ts +1 -1
- package/api/resources/segments/types/SegmentResponse.d.ts +6 -0
- package/api/resources/triggers/types/index.d.ts +0 -1
- package/api/resources/triggers/types/index.js +0 -1
- package/api/resources/websockets/client/Client.d.ts +22 -0
- package/api/resources/websockets/client/Client.js +89 -0
- package/api/resources/websockets/client/Socket.d.ts +48 -0
- package/api/resources/websockets/client/Socket.js +172 -0
- package/api/resources/websockets/client/index.d.ts +1 -0
- package/api/resources/websockets/client/index.js +2 -0
- package/api/resources/websockets/index.d.ts +2 -0
- package/api/resources/websockets/index.js +18 -0
- package/api/resources/websockets/types/AgentAudioChunk.d.ts +9 -0
- package/api/resources/websockets/types/AgentAudioChunk.js +3 -0
- package/api/resources/websockets/types/AgentTranscript.d.ts +9 -0
- package/api/resources/websockets/types/AgentTranscript.js +3 -0
- package/api/resources/websockets/types/AudioFormat.d.ts +7 -0
- package/api/resources/websockets/types/AudioFormat.js +10 -0
- package/api/resources/websockets/types/Config.d.ts +15 -0
- package/api/resources/websockets/types/Config.js +3 -0
- package/api/resources/websockets/types/ConversationEnded.d.ts +7 -0
- package/api/resources/websockets/types/ConversationEnded.js +3 -0
- package/api/resources/websockets/types/ConversationReady.d.ts +6 -0
- package/api/resources/websockets/types/ConversationReady.js +3 -0
- package/api/resources/websockets/types/Error_.d.ts +9 -0
- package/api/resources/websockets/types/Error_.js +3 -0
- package/api/resources/websockets/types/ServerEventBase.d.ts +6 -0
- package/api/resources/websockets/types/ServerEventBase.js +3 -0
- package/api/resources/websockets/types/UserAudioChunk.d.ts +8 -0
- package/api/resources/websockets/types/UserAudioChunk.js +3 -0
- package/api/resources/websockets/types/UserFinishedSpeaking.d.ts +7 -0
- package/api/resources/websockets/types/UserFinishedSpeaking.js +3 -0
- package/api/resources/websockets/types/UserStartedSpeaking.d.ts +7 -0
- package/api/resources/websockets/types/UserStartedSpeaking.js +3 -0
- package/api/resources/websockets/types/UserTranscript.d.ts +9 -0
- package/api/resources/websockets/types/UserTranscript.js +3 -0
- package/api/resources/websockets/types/index.d.ts +12 -0
- package/api/resources/websockets/types/index.js +28 -0
- package/core/index.d.ts +1 -0
- package/core/index.js +1 -0
- package/core/websocket/events.d.ts +36 -0
- package/core/websocket/events.js +27 -0
- package/core/websocket/index.d.ts +1 -0
- package/core/websocket/index.js +17 -0
- package/core/websocket/ws.d.ts +147 -0
- package/core/websocket/ws.js +444 -0
- package/dist/Client.d.ts +6 -0
- package/dist/Client.js +32 -22
- package/dist/api/resources/auth/client/Client.d.ts +33 -0
- package/dist/api/resources/auth/client/Client.js +171 -0
- package/dist/api/resources/auth/client/index.d.ts +1 -0
- package/dist/api/resources/auth/client/index.js +2 -0
- package/dist/api/resources/auth/index.d.ts +2 -0
- package/dist/api/resources/auth/index.js +18 -0
- package/dist/api/resources/auth/types/SessionTokenRequest.d.ts +3 -0
- package/dist/api/resources/auth/types/SessionTokenRequest.js +3 -0
- package/dist/api/resources/auth/types/SessionTokenResponse.d.ts +6 -0
- package/dist/api/resources/auth/types/SessionTokenResponse.js +3 -0
- package/dist/api/resources/auth/types/index.d.ts +2 -0
- package/dist/api/resources/auth/types/index.js +18 -0
- package/dist/api/resources/commons/types/ActionBase.d.ts +1 -11
- package/dist/api/resources/commons/types/ActionParameterType.d.ts +3 -0
- package/dist/api/resources/commons/types/ActionParameterType.js +3 -0
- package/dist/api/resources/commons/types/ActionProperties.d.ts +13 -0
- package/dist/api/resources/commons/types/ActionProperties.js +3 -0
- package/dist/api/resources/commons/types/ActionUser.d.ts +46 -0
- package/dist/api/resources/commons/types/ActionUser.js +3 -0
- package/dist/api/resources/commons/types/EntityType.d.ts +1 -0
- package/dist/api/resources/commons/types/EntityType.js +1 -0
- package/dist/api/resources/commons/types/EventField.d.ts +1 -0
- package/dist/api/resources/commons/types/EventField.js +1 -0
- package/dist/api/resources/commons/types/MetadataPrecondition.d.ts +3 -1
- package/dist/api/resources/commons/types/PreconditionOperator.d.ts +20 -0
- package/dist/api/resources/commons/types/PreconditionOperator.js +20 -0
- package/dist/api/resources/commons/types/UserEvent.d.ts +2 -0
- package/dist/api/resources/commons/types/index.d.ts +3 -0
- package/dist/api/resources/commons/types/index.js +3 -0
- package/dist/api/resources/index.d.ts +4 -0
- package/dist/api/resources/index.js +5 -1
- package/dist/api/resources/knowledge/types/KnowledgeBaseResponse.d.ts +2 -0
- package/dist/api/resources/knowledge/types/KnowledgeDocumentRequest.d.ts +1 -1
- package/dist/api/resources/segments/types/SegmentResponse.d.ts +6 -0
- package/dist/api/resources/triggers/types/index.d.ts +0 -1
- package/dist/api/resources/triggers/types/index.js +0 -1
- package/dist/api/resources/websockets/client/Client.d.ts +22 -0
- package/dist/api/resources/websockets/client/Client.js +89 -0
- package/dist/api/resources/websockets/client/Socket.d.ts +48 -0
- package/dist/api/resources/websockets/client/Socket.js +172 -0
- package/dist/api/resources/websockets/client/index.d.ts +1 -0
- package/dist/api/resources/websockets/client/index.js +2 -0
- package/dist/api/resources/websockets/index.d.ts +2 -0
- package/dist/api/resources/websockets/index.js +18 -0
- package/dist/api/resources/websockets/types/AgentAudioChunk.d.ts +9 -0
- package/dist/api/resources/websockets/types/AgentAudioChunk.js +3 -0
- package/dist/api/resources/websockets/types/AgentTranscript.d.ts +9 -0
- package/dist/api/resources/websockets/types/AgentTranscript.js +3 -0
- package/dist/api/resources/websockets/types/AudioFormat.d.ts +7 -0
- package/dist/api/resources/websockets/types/AudioFormat.js +10 -0
- package/dist/api/resources/websockets/types/Config.d.ts +15 -0
- package/dist/api/resources/websockets/types/Config.js +3 -0
- package/dist/api/resources/websockets/types/ConversationEnded.d.ts +7 -0
- package/dist/api/resources/websockets/types/ConversationEnded.js +3 -0
- package/dist/api/resources/websockets/types/ConversationReady.d.ts +6 -0
- package/dist/api/resources/websockets/types/ConversationReady.js +3 -0
- package/dist/api/resources/websockets/types/Error_.d.ts +9 -0
- package/dist/api/resources/websockets/types/Error_.js +3 -0
- package/dist/api/resources/websockets/types/ServerEventBase.d.ts +6 -0
- package/dist/api/resources/websockets/types/ServerEventBase.js +3 -0
- package/dist/api/resources/websockets/types/UserAudioChunk.d.ts +8 -0
- package/dist/api/resources/websockets/types/UserAudioChunk.js +3 -0
- package/dist/api/resources/websockets/types/UserFinishedSpeaking.d.ts +7 -0
- package/dist/api/resources/websockets/types/UserFinishedSpeaking.js +3 -0
- package/dist/api/resources/websockets/types/UserStartedSpeaking.d.ts +7 -0
- package/dist/api/resources/websockets/types/UserStartedSpeaking.js +3 -0
- package/dist/api/resources/websockets/types/UserTranscript.d.ts +9 -0
- package/dist/api/resources/websockets/types/UserTranscript.js +3 -0
- package/dist/api/resources/websockets/types/index.d.ts +12 -0
- package/dist/api/resources/websockets/types/index.js +28 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/websocket/events.d.ts +36 -0
- package/dist/core/websocket/events.js +27 -0
- package/dist/core/websocket/index.d.ts +1 -0
- package/dist/core/websocket/index.js +17 -0
- package/dist/core/websocket/ws.d.ts +147 -0
- package/dist/core/websocket/ws.js +444 -0
- package/dist/serialization/resources/auth/index.d.ts +1 -0
- package/dist/serialization/resources/auth/index.js +17 -0
- package/dist/serialization/resources/auth/types/SessionTokenRequest.d.ts +9 -0
- package/dist/serialization/resources/auth/types/SessionTokenRequest.js +41 -0
- package/dist/serialization/resources/auth/types/SessionTokenResponse.d.ts +10 -0
- package/dist/serialization/resources/auth/types/SessionTokenResponse.js +42 -0
- package/dist/serialization/resources/auth/types/index.d.ts +2 -0
- package/dist/serialization/resources/auth/types/index.js +18 -0
- package/dist/serialization/resources/commons/types/ActionBase.d.ts +3 -8
- package/dist/serialization/resources/commons/types/ActionBase.js +5 -9
- package/dist/serialization/resources/commons/types/ActionParameterType.d.ts +1 -1
- package/dist/serialization/resources/commons/types/ActionParameterType.js +1 -0
- package/dist/serialization/resources/commons/types/ActionProperties.d.ts +14 -0
- package/dist/serialization/resources/commons/types/ActionProperties.js +47 -0
- package/dist/serialization/resources/commons/types/ActionUser.d.ts +17 -0
- package/dist/serialization/resources/commons/types/ActionUser.js +49 -0
- package/dist/serialization/resources/commons/types/EntityType.d.ts +1 -1
- package/dist/serialization/resources/commons/types/EntityType.js +1 -0
- package/dist/serialization/resources/commons/types/EventField.d.ts +1 -1
- package/dist/serialization/resources/commons/types/EventField.js +1 -0
- package/dist/serialization/resources/commons/types/MetadataPrecondition.d.ts +1 -0
- package/dist/serialization/resources/commons/types/MetadataPrecondition.js +1 -0
- package/dist/serialization/resources/commons/types/PreconditionOperator.d.ts +1 -1
- package/dist/serialization/resources/commons/types/PreconditionOperator.js +9 -1
- package/dist/serialization/resources/commons/types/UserEvent.d.ts +1 -0
- package/dist/serialization/resources/commons/types/UserEvent.js +1 -0
- package/dist/serialization/resources/commons/types/index.d.ts +3 -0
- package/dist/serialization/resources/commons/types/index.js +3 -0
- package/dist/serialization/resources/index.d.ts +5 -0
- package/dist/serialization/resources/index.js +6 -1
- package/dist/serialization/resources/knowledge/types/KnowledgeBaseResponse.d.ts +1 -0
- package/dist/serialization/resources/knowledge/types/KnowledgeBaseResponse.js +1 -0
- package/dist/serialization/resources/knowledge/types/KnowledgeDocumentRequest.d.ts +1 -1
- package/dist/serialization/resources/knowledge/types/KnowledgeDocumentRequest.js +1 -1
- package/dist/serialization/resources/segments/types/SegmentResponse.d.ts +2 -0
- package/dist/serialization/resources/segments/types/SegmentResponse.js +2 -0
- package/dist/serialization/resources/triggers/types/EventTriggerBase.d.ts +1 -1
- package/dist/serialization/resources/triggers/types/EventTriggerBase.js +1 -1
- package/dist/serialization/resources/triggers/types/index.d.ts +0 -1
- package/dist/serialization/resources/triggers/types/index.js +0 -1
- package/dist/serialization/resources/websockets/client/index.d.ts +1 -0
- package/dist/serialization/resources/websockets/client/index.js +17 -0
- package/dist/serialization/resources/websockets/client/socket/WebsocketsSocketResponse.d.ts +15 -0
- package/dist/serialization/resources/websockets/client/socket/WebsocketsSocketResponse.js +56 -0
- package/dist/serialization/resources/websockets/client/socket/index.d.ts +1 -0
- package/dist/serialization/resources/websockets/client/socket/index.js +5 -0
- package/dist/serialization/resources/websockets/index.d.ts +2 -0
- package/dist/serialization/resources/websockets/index.js +18 -0
- package/dist/serialization/resources/websockets/types/AgentAudioChunk.d.ts +11 -0
- package/dist/serialization/resources/websockets/types/AgentAudioChunk.js +45 -0
- package/dist/serialization/resources/websockets/types/AgentTranscript.d.ts +11 -0
- package/dist/serialization/resources/websockets/types/AgentTranscript.js +45 -0
- package/dist/serialization/resources/websockets/types/AudioFormat.d.ts +7 -0
- package/dist/serialization/resources/websockets/types/AudioFormat.js +39 -0
- package/dist/serialization/resources/websockets/types/Config.d.ts +14 -0
- package/dist/serialization/resources/websockets/types/Config.js +46 -0
- package/dist/serialization/resources/websockets/types/ConversationEnded.d.ts +10 -0
- package/dist/serialization/resources/websockets/types/ConversationEnded.js +44 -0
- package/dist/serialization/resources/websockets/types/ConversationReady.d.ts +9 -0
- package/dist/serialization/resources/websockets/types/ConversationReady.js +41 -0
- package/dist/serialization/resources/websockets/types/Error_.d.ts +12 -0
- package/dist/serialization/resources/websockets/types/Error_.js +46 -0
- package/dist/serialization/resources/websockets/types/ServerEventBase.d.ts +9 -0
- package/dist/serialization/resources/websockets/types/ServerEventBase.js +41 -0
- package/dist/serialization/resources/websockets/types/UserAudioChunk.d.ts +10 -0
- package/dist/serialization/resources/websockets/types/UserAudioChunk.js +42 -0
- package/dist/serialization/resources/websockets/types/UserFinishedSpeaking.d.ts +10 -0
- package/dist/serialization/resources/websockets/types/UserFinishedSpeaking.js +44 -0
- package/dist/serialization/resources/websockets/types/UserStartedSpeaking.d.ts +10 -0
- package/dist/serialization/resources/websockets/types/UserStartedSpeaking.js +44 -0
- package/dist/serialization/resources/websockets/types/UserTranscript.d.ts +11 -0
- package/dist/serialization/resources/websockets/types/UserTranscript.js +45 -0
- package/dist/serialization/resources/websockets/types/index.d.ts +12 -0
- package/dist/serialization/resources/websockets/types/index.js +28 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -1
- package/reference.md +73 -5
- package/serialization/resources/auth/index.d.ts +1 -0
- package/serialization/resources/auth/index.js +17 -0
- package/serialization/resources/auth/types/SessionTokenRequest.d.ts +9 -0
- package/serialization/resources/auth/types/SessionTokenRequest.js +41 -0
- package/serialization/resources/auth/types/SessionTokenResponse.d.ts +10 -0
- package/serialization/resources/auth/types/SessionTokenResponse.js +42 -0
- package/serialization/resources/auth/types/index.d.ts +2 -0
- package/serialization/resources/auth/types/index.js +18 -0
- package/serialization/resources/commons/types/ActionBase.d.ts +3 -8
- package/serialization/resources/commons/types/ActionBase.js +5 -9
- package/serialization/resources/commons/types/ActionParameterType.d.ts +1 -1
- package/serialization/resources/commons/types/ActionParameterType.js +1 -0
- package/serialization/resources/commons/types/ActionProperties.d.ts +14 -0
- package/serialization/resources/commons/types/ActionProperties.js +47 -0
- package/serialization/resources/commons/types/ActionUser.d.ts +17 -0
- package/serialization/resources/commons/types/ActionUser.js +49 -0
- package/serialization/resources/commons/types/EntityType.d.ts +1 -1
- package/serialization/resources/commons/types/EntityType.js +1 -0
- package/serialization/resources/commons/types/EventField.d.ts +1 -1
- package/serialization/resources/commons/types/EventField.js +1 -0
- package/serialization/resources/commons/types/MetadataPrecondition.d.ts +1 -0
- package/serialization/resources/commons/types/MetadataPrecondition.js +1 -0
- package/serialization/resources/commons/types/PreconditionOperator.d.ts +1 -1
- package/serialization/resources/commons/types/PreconditionOperator.js +9 -1
- package/serialization/resources/commons/types/UserEvent.d.ts +1 -0
- package/serialization/resources/commons/types/UserEvent.js +1 -0
- package/serialization/resources/commons/types/index.d.ts +3 -0
- package/serialization/resources/commons/types/index.js +3 -0
- package/serialization/resources/index.d.ts +5 -0
- package/serialization/resources/index.js +6 -1
- package/serialization/resources/knowledge/types/KnowledgeBaseResponse.d.ts +1 -0
- package/serialization/resources/knowledge/types/KnowledgeBaseResponse.js +1 -0
- package/serialization/resources/knowledge/types/KnowledgeDocumentRequest.d.ts +1 -1
- package/serialization/resources/knowledge/types/KnowledgeDocumentRequest.js +1 -1
- package/serialization/resources/segments/types/SegmentResponse.d.ts +2 -0
- package/serialization/resources/segments/types/SegmentResponse.js +2 -0
- package/serialization/resources/triggers/types/EventTriggerBase.d.ts +1 -1
- package/serialization/resources/triggers/types/EventTriggerBase.js +1 -1
- package/serialization/resources/triggers/types/index.d.ts +0 -1
- package/serialization/resources/triggers/types/index.js +0 -1
- package/serialization/resources/websockets/client/index.d.ts +1 -0
- package/serialization/resources/websockets/client/index.js +17 -0
- package/serialization/resources/websockets/client/socket/WebsocketsSocketResponse.d.ts +15 -0
- package/serialization/resources/websockets/client/socket/WebsocketsSocketResponse.js +56 -0
- package/serialization/resources/websockets/client/socket/index.d.ts +1 -0
- package/serialization/resources/websockets/client/socket/index.js +5 -0
- package/serialization/resources/websockets/index.d.ts +2 -0
- package/serialization/resources/websockets/index.js +18 -0
- package/serialization/resources/websockets/types/AgentAudioChunk.d.ts +11 -0
- package/serialization/resources/websockets/types/AgentAudioChunk.js +45 -0
- package/serialization/resources/websockets/types/AgentTranscript.d.ts +11 -0
- package/serialization/resources/websockets/types/AgentTranscript.js +45 -0
- package/serialization/resources/websockets/types/AudioFormat.d.ts +7 -0
- package/serialization/resources/websockets/types/AudioFormat.js +39 -0
- package/serialization/resources/websockets/types/Config.d.ts +14 -0
- package/serialization/resources/websockets/types/Config.js +46 -0
- package/serialization/resources/websockets/types/ConversationEnded.d.ts +10 -0
- package/serialization/resources/websockets/types/ConversationEnded.js +44 -0
- package/serialization/resources/websockets/types/ConversationReady.d.ts +9 -0
- package/serialization/resources/websockets/types/ConversationReady.js +41 -0
- package/serialization/resources/websockets/types/Error_.d.ts +12 -0
- package/serialization/resources/websockets/types/Error_.js +46 -0
- package/serialization/resources/websockets/types/ServerEventBase.d.ts +9 -0
- package/serialization/resources/websockets/types/ServerEventBase.js +41 -0
- package/serialization/resources/websockets/types/UserAudioChunk.d.ts +10 -0
- package/serialization/resources/websockets/types/UserAudioChunk.js +42 -0
- package/serialization/resources/websockets/types/UserFinishedSpeaking.d.ts +10 -0
- package/serialization/resources/websockets/types/UserFinishedSpeaking.js +44 -0
- package/serialization/resources/websockets/types/UserStartedSpeaking.d.ts +10 -0
- package/serialization/resources/websockets/types/UserStartedSpeaking.js +44 -0
- package/serialization/resources/websockets/types/UserTranscript.d.ts +11 -0
- package/serialization/resources/websockets/types/UserTranscript.js +45 -0
- package/serialization/resources/websockets/types/index.d.ts +12 -0
- package/serialization/resources/websockets/types/index.js +28 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
- /package/api/resources/{triggers → commons}/types/EventTriggerType.d.ts +0 -0
- /package/api/resources/{triggers → commons}/types/EventTriggerType.js +0 -0
- /package/dist/api/resources/{triggers → commons}/types/EventTriggerType.d.ts +0 -0
- /package/dist/api/resources/{triggers → commons}/types/EventTriggerType.js +0 -0
- /package/dist/serialization/resources/{triggers → commons}/types/EventTriggerType.d.ts +0 -0
- /package/dist/serialization/resources/{triggers → commons}/types/EventTriggerType.js +0 -0
- /package/serialization/resources/{triggers → commons}/types/EventTriggerType.d.ts +0 -0
- /package/serialization/resources/{triggers → commons}/types/EventTriggerType.js +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ws"), exports);
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import * as Events from "./events";
|
|
2
|
+
export type Event = Events.Event;
|
|
3
|
+
export type ErrorEvent = Events.ErrorEvent;
|
|
4
|
+
export type CloseEvent = Events.CloseEvent;
|
|
5
|
+
export declare namespace ReconnectingWebSocket {
|
|
6
|
+
interface Args {
|
|
7
|
+
url: string;
|
|
8
|
+
protocols?: string | string[];
|
|
9
|
+
options?: ReconnectingWebSocket.Options;
|
|
10
|
+
headers?: Record<string, unknown>;
|
|
11
|
+
queryParameters?: Record<string, string | string[] | object | object[] | null | undefined>;
|
|
12
|
+
}
|
|
13
|
+
type Options = {
|
|
14
|
+
WebSocket?: any;
|
|
15
|
+
maxReconnectionDelay?: number;
|
|
16
|
+
minReconnectionDelay?: number;
|
|
17
|
+
reconnectionDelayGrowFactor?: number;
|
|
18
|
+
minUptime?: number;
|
|
19
|
+
connectionTimeout?: number;
|
|
20
|
+
maxRetries?: number;
|
|
21
|
+
maxEnqueuedMessages?: number;
|
|
22
|
+
startClosed?: boolean;
|
|
23
|
+
debug?: boolean;
|
|
24
|
+
};
|
|
25
|
+
type UrlProvider = string | (() => string) | (() => Promise<string>);
|
|
26
|
+
type Message = string | ArrayBuffer | Blob | ArrayBufferView;
|
|
27
|
+
type ListenersMap = {
|
|
28
|
+
error: Array<Events.WebSocketEventListenerMap["error"]>;
|
|
29
|
+
message: Array<Events.WebSocketEventListenerMap["message"]>;
|
|
30
|
+
open: Array<Events.WebSocketEventListenerMap["open"]>;
|
|
31
|
+
close: Array<Events.WebSocketEventListenerMap["close"]>;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export declare class ReconnectingWebSocket {
|
|
35
|
+
private _ws?;
|
|
36
|
+
private _listeners;
|
|
37
|
+
private _retryCount;
|
|
38
|
+
private _uptimeTimeout;
|
|
39
|
+
private _connectTimeout;
|
|
40
|
+
private _shouldReconnect;
|
|
41
|
+
private _connectLock;
|
|
42
|
+
private _binaryType;
|
|
43
|
+
private _closeCalled;
|
|
44
|
+
private _messageQueue;
|
|
45
|
+
private readonly _url;
|
|
46
|
+
private readonly _protocols?;
|
|
47
|
+
private readonly _options;
|
|
48
|
+
private readonly _headers?;
|
|
49
|
+
private readonly _queryParameters?;
|
|
50
|
+
constructor({ url, protocols, options, headers, queryParameters }: ReconnectingWebSocket.Args);
|
|
51
|
+
static readonly CONNECTING = 0;
|
|
52
|
+
static readonly OPEN = 1;
|
|
53
|
+
static readonly CLOSING = 2;
|
|
54
|
+
static readonly CLOSED = 3;
|
|
55
|
+
readonly CONNECTING: typeof ReconnectingWebSocket.CONNECTING;
|
|
56
|
+
readonly OPEN: typeof ReconnectingWebSocket.OPEN;
|
|
57
|
+
readonly CLOSING: typeof ReconnectingWebSocket.CLOSING;
|
|
58
|
+
readonly CLOSED: typeof ReconnectingWebSocket.CLOSED;
|
|
59
|
+
get binaryType(): BinaryType;
|
|
60
|
+
set binaryType(value: BinaryType);
|
|
61
|
+
/**
|
|
62
|
+
* Returns the number or connection retries
|
|
63
|
+
*/
|
|
64
|
+
get retryCount(): number;
|
|
65
|
+
/**
|
|
66
|
+
* The number of bytes of data that have been queued using calls to send() but not yet
|
|
67
|
+
* transmitted to the network. This value resets to zero once all queued data has been sent.
|
|
68
|
+
* This value does not reset to zero when the connection is closed; if you keep calling send(),
|
|
69
|
+
* this will continue to climb. Read only
|
|
70
|
+
*/
|
|
71
|
+
get bufferedAmount(): number;
|
|
72
|
+
/**
|
|
73
|
+
* The extensions selected by the server. This is currently only the empty string or a list of
|
|
74
|
+
* extensions as negotiated by the connection
|
|
75
|
+
*/
|
|
76
|
+
get extensions(): string;
|
|
77
|
+
/**
|
|
78
|
+
* A string indicating the name of the sub-protocol the server selected;
|
|
79
|
+
* this will be one of the strings specified in the protocols parameter when creating the
|
|
80
|
+
* WebSocket object
|
|
81
|
+
*/
|
|
82
|
+
get protocol(): string;
|
|
83
|
+
/**
|
|
84
|
+
* The current state of the connection; this is one of the Ready state constants
|
|
85
|
+
*/
|
|
86
|
+
get readyState(): number;
|
|
87
|
+
/**
|
|
88
|
+
* The URL as resolved by the constructor
|
|
89
|
+
*/
|
|
90
|
+
get url(): string;
|
|
91
|
+
/**
|
|
92
|
+
* An event listener to be called when the WebSocket connection's readyState changes to CLOSED
|
|
93
|
+
*/
|
|
94
|
+
onclose: ((event: Events.CloseEvent) => void) | null;
|
|
95
|
+
/**
|
|
96
|
+
* An event listener to be called when an error occurs
|
|
97
|
+
*/
|
|
98
|
+
onerror: ((event: Events.ErrorEvent) => void) | null;
|
|
99
|
+
/**
|
|
100
|
+
* An event listener to be called when a message is received from the server
|
|
101
|
+
*/
|
|
102
|
+
onmessage: ((event: MessageEvent) => void) | null;
|
|
103
|
+
/**
|
|
104
|
+
* An event listener to be called when the WebSocket connection's readyState changes to OPEN;
|
|
105
|
+
* this indicates that the connection is ready to send and receive data
|
|
106
|
+
*/
|
|
107
|
+
onopen: ((event: Event) => void) | null;
|
|
108
|
+
/**
|
|
109
|
+
* Closes the WebSocket connection or connection attempt, if any. If the connection is already
|
|
110
|
+
* CLOSED, this method does nothing
|
|
111
|
+
*/
|
|
112
|
+
close(code?: number, reason?: string): void;
|
|
113
|
+
/**
|
|
114
|
+
* Closes the WebSocket connection or connection attempt and connects again.
|
|
115
|
+
* Resets retry counter;
|
|
116
|
+
*/
|
|
117
|
+
reconnect(code?: number, reason?: string): void;
|
|
118
|
+
/**
|
|
119
|
+
* Enqueue specified data to be transmitted to the server over the WebSocket connection
|
|
120
|
+
*/
|
|
121
|
+
send(data: ReconnectingWebSocket.Message): void;
|
|
122
|
+
/**
|
|
123
|
+
* Register an event handler of a specific event type
|
|
124
|
+
*/
|
|
125
|
+
addEventListener<T extends keyof Events.WebSocketEventListenerMap>(type: T, listener: Events.WebSocketEventListenerMap[T]): void;
|
|
126
|
+
dispatchEvent(event: Event): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Removes an event listener
|
|
129
|
+
*/
|
|
130
|
+
removeEventListener<T extends keyof Events.WebSocketEventListenerMap>(type: T, listener: Events.WebSocketEventListenerMap[T]): void;
|
|
131
|
+
private _debug;
|
|
132
|
+
private _getNextDelay;
|
|
133
|
+
private _wait;
|
|
134
|
+
private _getNextUrl;
|
|
135
|
+
private _connect;
|
|
136
|
+
private _handleTimeout;
|
|
137
|
+
private _disconnect;
|
|
138
|
+
private _acceptOpen;
|
|
139
|
+
private _callEventListener;
|
|
140
|
+
private _handleOpen;
|
|
141
|
+
private _handleMessage;
|
|
142
|
+
private _handleError;
|
|
143
|
+
private _handleClose;
|
|
144
|
+
private _removeListeners;
|
|
145
|
+
private _addListeners;
|
|
146
|
+
private _clearTimeouts;
|
|
147
|
+
}
|
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ReconnectingWebSocket = void 0;
|
|
37
|
+
const ws_1 = require("ws");
|
|
38
|
+
const runtime_1 = require("../runtime");
|
|
39
|
+
const qs_1 = require("../url/qs");
|
|
40
|
+
const Events = __importStar(require("./events"));
|
|
41
|
+
const getGlobalWebSocket = () => {
|
|
42
|
+
if (typeof WebSocket !== "undefined") {
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
return WebSocket;
|
|
45
|
+
}
|
|
46
|
+
else if (runtime_1.RUNTIME.type === "node") {
|
|
47
|
+
return ws_1.WebSocket;
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Returns true if given argument looks like a WebSocket class
|
|
53
|
+
*/
|
|
54
|
+
const isWebSocket = (w) => typeof w !== "undefined" && !!w && w.CLOSING === 2;
|
|
55
|
+
const DEFAULT_OPTIONS = {
|
|
56
|
+
maxReconnectionDelay: 10000,
|
|
57
|
+
minReconnectionDelay: 1000 + Math.random() * 4000,
|
|
58
|
+
minUptime: 5000,
|
|
59
|
+
reconnectionDelayGrowFactor: 1.3,
|
|
60
|
+
connectionTimeout: 4000,
|
|
61
|
+
maxRetries: Infinity,
|
|
62
|
+
maxEnqueuedMessages: Infinity,
|
|
63
|
+
startClosed: false,
|
|
64
|
+
debug: false,
|
|
65
|
+
};
|
|
66
|
+
class ReconnectingWebSocket {
|
|
67
|
+
constructor({ url, protocols, options, headers, queryParameters }) {
|
|
68
|
+
this._listeners = {
|
|
69
|
+
error: [],
|
|
70
|
+
message: [],
|
|
71
|
+
open: [],
|
|
72
|
+
close: [],
|
|
73
|
+
};
|
|
74
|
+
this._retryCount = -1;
|
|
75
|
+
this._shouldReconnect = true;
|
|
76
|
+
this._connectLock = false;
|
|
77
|
+
this._binaryType = "blob";
|
|
78
|
+
this._closeCalled = false;
|
|
79
|
+
this._messageQueue = [];
|
|
80
|
+
this.CONNECTING = ReconnectingWebSocket.CONNECTING;
|
|
81
|
+
this.OPEN = ReconnectingWebSocket.OPEN;
|
|
82
|
+
this.CLOSING = ReconnectingWebSocket.CLOSING;
|
|
83
|
+
this.CLOSED = ReconnectingWebSocket.CLOSED;
|
|
84
|
+
/**
|
|
85
|
+
* An event listener to be called when the WebSocket connection's readyState changes to CLOSED
|
|
86
|
+
*/
|
|
87
|
+
this.onclose = null;
|
|
88
|
+
/**
|
|
89
|
+
* An event listener to be called when an error occurs
|
|
90
|
+
*/
|
|
91
|
+
this.onerror = null;
|
|
92
|
+
/**
|
|
93
|
+
* An event listener to be called when a message is received from the server
|
|
94
|
+
*/
|
|
95
|
+
this.onmessage = null;
|
|
96
|
+
/**
|
|
97
|
+
* An event listener to be called when the WebSocket connection's readyState changes to OPEN;
|
|
98
|
+
* this indicates that the connection is ready to send and receive data
|
|
99
|
+
*/
|
|
100
|
+
this.onopen = null;
|
|
101
|
+
this._handleOpen = (event) => {
|
|
102
|
+
this._debug("open event");
|
|
103
|
+
const { minUptime = DEFAULT_OPTIONS.minUptime } = this._options;
|
|
104
|
+
clearTimeout(this._connectTimeout);
|
|
105
|
+
this._uptimeTimeout = setTimeout(() => this._acceptOpen(), minUptime);
|
|
106
|
+
this._ws.binaryType = this._binaryType;
|
|
107
|
+
// send enqueued messages (messages sent before websocket open event)
|
|
108
|
+
this._messageQueue.forEach((message) => { var _a; return (_a = this._ws) === null || _a === void 0 ? void 0 : _a.send(message); });
|
|
109
|
+
this._messageQueue = [];
|
|
110
|
+
if (this.onopen) {
|
|
111
|
+
this.onopen(event);
|
|
112
|
+
}
|
|
113
|
+
this._listeners.open.forEach((listener) => this._callEventListener(event, listener));
|
|
114
|
+
};
|
|
115
|
+
this._handleMessage = (event) => {
|
|
116
|
+
this._debug("message event");
|
|
117
|
+
if (this.onmessage) {
|
|
118
|
+
this.onmessage(event);
|
|
119
|
+
}
|
|
120
|
+
this._listeners.message.forEach((listener) => this._callEventListener(event, listener));
|
|
121
|
+
};
|
|
122
|
+
this._handleError = (event) => {
|
|
123
|
+
this._debug("error event", event.message);
|
|
124
|
+
this._disconnect(undefined, event.message === "TIMEOUT" ? "timeout" : undefined);
|
|
125
|
+
if (this.onerror) {
|
|
126
|
+
this.onerror(event);
|
|
127
|
+
}
|
|
128
|
+
this._debug("exec error listeners");
|
|
129
|
+
this._listeners.error.forEach((listener) => this._callEventListener(event, listener));
|
|
130
|
+
this._connect();
|
|
131
|
+
};
|
|
132
|
+
this._handleClose = (event) => {
|
|
133
|
+
this._debug("close event");
|
|
134
|
+
this._clearTimeouts();
|
|
135
|
+
if (event.code === 1000) {
|
|
136
|
+
this._shouldReconnect = false;
|
|
137
|
+
}
|
|
138
|
+
if (this._shouldReconnect) {
|
|
139
|
+
this._connect();
|
|
140
|
+
}
|
|
141
|
+
if (this.onclose) {
|
|
142
|
+
this.onclose(event);
|
|
143
|
+
}
|
|
144
|
+
this._listeners.close.forEach((listener) => this._callEventListener(event, listener));
|
|
145
|
+
};
|
|
146
|
+
this._url = url;
|
|
147
|
+
this._protocols = protocols;
|
|
148
|
+
this._options = options !== null && options !== void 0 ? options : DEFAULT_OPTIONS;
|
|
149
|
+
this._headers = headers;
|
|
150
|
+
this._queryParameters = queryParameters;
|
|
151
|
+
if (this._options.startClosed) {
|
|
152
|
+
this._shouldReconnect = false;
|
|
153
|
+
}
|
|
154
|
+
this._connect();
|
|
155
|
+
}
|
|
156
|
+
get binaryType() {
|
|
157
|
+
return this._ws ? this._ws.binaryType : this._binaryType;
|
|
158
|
+
}
|
|
159
|
+
set binaryType(value) {
|
|
160
|
+
this._binaryType = value;
|
|
161
|
+
if (this._ws) {
|
|
162
|
+
this._ws.binaryType = value;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Returns the number or connection retries
|
|
167
|
+
*/
|
|
168
|
+
get retryCount() {
|
|
169
|
+
return Math.max(this._retryCount, 0);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The number of bytes of data that have been queued using calls to send() but not yet
|
|
173
|
+
* transmitted to the network. This value resets to zero once all queued data has been sent.
|
|
174
|
+
* This value does not reset to zero when the connection is closed; if you keep calling send(),
|
|
175
|
+
* this will continue to climb. Read only
|
|
176
|
+
*/
|
|
177
|
+
get bufferedAmount() {
|
|
178
|
+
const bytes = this._messageQueue.reduce((acc, message) => {
|
|
179
|
+
if (typeof message === "string") {
|
|
180
|
+
acc += message.length; // not byte size
|
|
181
|
+
}
|
|
182
|
+
else if (message instanceof Blob) {
|
|
183
|
+
acc += message.size;
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
acc += message.byteLength;
|
|
187
|
+
}
|
|
188
|
+
return acc;
|
|
189
|
+
}, 0);
|
|
190
|
+
return bytes + (this._ws ? this._ws.bufferedAmount : 0);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* The extensions selected by the server. This is currently only the empty string or a list of
|
|
194
|
+
* extensions as negotiated by the connection
|
|
195
|
+
*/
|
|
196
|
+
get extensions() {
|
|
197
|
+
return this._ws ? this._ws.extensions : "";
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* A string indicating the name of the sub-protocol the server selected;
|
|
201
|
+
* this will be one of the strings specified in the protocols parameter when creating the
|
|
202
|
+
* WebSocket object
|
|
203
|
+
*/
|
|
204
|
+
get protocol() {
|
|
205
|
+
return this._ws ? this._ws.protocol : "";
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* The current state of the connection; this is one of the Ready state constants
|
|
209
|
+
*/
|
|
210
|
+
get readyState() {
|
|
211
|
+
if (this._ws) {
|
|
212
|
+
return this._ws.readyState;
|
|
213
|
+
}
|
|
214
|
+
return this._options.startClosed ? ReconnectingWebSocket.CLOSED : ReconnectingWebSocket.CONNECTING;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* The URL as resolved by the constructor
|
|
218
|
+
*/
|
|
219
|
+
get url() {
|
|
220
|
+
return this._ws ? this._ws.url : "";
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Closes the WebSocket connection or connection attempt, if any. If the connection is already
|
|
224
|
+
* CLOSED, this method does nothing
|
|
225
|
+
*/
|
|
226
|
+
close(code = 1000, reason) {
|
|
227
|
+
this._closeCalled = true;
|
|
228
|
+
this._shouldReconnect = false;
|
|
229
|
+
this._clearTimeouts();
|
|
230
|
+
if (!this._ws) {
|
|
231
|
+
this._debug("close enqueued: no ws instance");
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
if (this._ws.readyState === this.CLOSED) {
|
|
235
|
+
this._debug("close: already closed");
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
this._ws.close(code, reason);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Closes the WebSocket connection or connection attempt and connects again.
|
|
242
|
+
* Resets retry counter;
|
|
243
|
+
*/
|
|
244
|
+
reconnect(code, reason) {
|
|
245
|
+
this._shouldReconnect = true;
|
|
246
|
+
this._closeCalled = false;
|
|
247
|
+
this._retryCount = -1;
|
|
248
|
+
if (!this._ws || this._ws.readyState === this.CLOSED) {
|
|
249
|
+
this._connect();
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
this._disconnect(code, reason);
|
|
253
|
+
this._connect();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Enqueue specified data to be transmitted to the server over the WebSocket connection
|
|
258
|
+
*/
|
|
259
|
+
send(data) {
|
|
260
|
+
if (this._ws && this._ws.readyState === this.OPEN) {
|
|
261
|
+
this._debug("send", data);
|
|
262
|
+
this._ws.send(data);
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
const { maxEnqueuedMessages = DEFAULT_OPTIONS.maxEnqueuedMessages } = this._options;
|
|
266
|
+
if (this._messageQueue.length < maxEnqueuedMessages) {
|
|
267
|
+
this._debug("enqueue", data);
|
|
268
|
+
this._messageQueue.push(data);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Register an event handler of a specific event type
|
|
274
|
+
*/
|
|
275
|
+
addEventListener(type, listener) {
|
|
276
|
+
if (this._listeners[type]) {
|
|
277
|
+
// @ts-ignore
|
|
278
|
+
this._listeners[type].push(listener);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
dispatchEvent(event) {
|
|
282
|
+
const listeners = this._listeners[event.type];
|
|
283
|
+
if (listeners) {
|
|
284
|
+
for (const listener of listeners) {
|
|
285
|
+
this._callEventListener(event, listener);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Removes an event listener
|
|
292
|
+
*/
|
|
293
|
+
removeEventListener(type, listener) {
|
|
294
|
+
if (this._listeners[type]) {
|
|
295
|
+
// @ts-ignore
|
|
296
|
+
this._listeners[type] = this._listeners[type].filter(
|
|
297
|
+
// @ts-ignore
|
|
298
|
+
(l) => l !== listener);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
_debug(...args) {
|
|
302
|
+
if (this._options.debug) {
|
|
303
|
+
// not using spread because compiled version uses Symbols
|
|
304
|
+
// tslint:disable-next-line
|
|
305
|
+
// biome-ignore lint/suspicious/noConsole: allow console
|
|
306
|
+
console.log.apply(console, ["RWS>", ...args]);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
_getNextDelay() {
|
|
310
|
+
const { reconnectionDelayGrowFactor = DEFAULT_OPTIONS.reconnectionDelayGrowFactor, minReconnectionDelay = DEFAULT_OPTIONS.minReconnectionDelay, maxReconnectionDelay = DEFAULT_OPTIONS.maxReconnectionDelay, } = this._options;
|
|
311
|
+
let delay = 0;
|
|
312
|
+
if (this._retryCount > 0) {
|
|
313
|
+
delay = minReconnectionDelay * Math.pow(reconnectionDelayGrowFactor, (this._retryCount - 1));
|
|
314
|
+
if (delay > maxReconnectionDelay) {
|
|
315
|
+
delay = maxReconnectionDelay;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
this._debug("next delay", delay);
|
|
319
|
+
return delay;
|
|
320
|
+
}
|
|
321
|
+
_wait() {
|
|
322
|
+
return new Promise((resolve) => {
|
|
323
|
+
setTimeout(resolve, this._getNextDelay());
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
_getNextUrl(urlProvider) {
|
|
327
|
+
if (typeof urlProvider === "string") {
|
|
328
|
+
return Promise.resolve(urlProvider);
|
|
329
|
+
}
|
|
330
|
+
if (typeof urlProvider === "function") {
|
|
331
|
+
const url = urlProvider();
|
|
332
|
+
if (typeof url === "string") {
|
|
333
|
+
return Promise.resolve(url);
|
|
334
|
+
}
|
|
335
|
+
// @ts-ignore redundant check
|
|
336
|
+
if (url.then) {
|
|
337
|
+
return url;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
throw Error("Invalid URL");
|
|
341
|
+
}
|
|
342
|
+
_connect() {
|
|
343
|
+
if (this._connectLock || !this._shouldReconnect) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
this._connectLock = true;
|
|
347
|
+
const { maxRetries = DEFAULT_OPTIONS.maxRetries, connectionTimeout = DEFAULT_OPTIONS.connectionTimeout, WebSocket = getGlobalWebSocket(), } = this._options;
|
|
348
|
+
if (this._retryCount >= maxRetries) {
|
|
349
|
+
this._debug("max retries reached", this._retryCount, ">=", maxRetries);
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
this._retryCount++;
|
|
353
|
+
this._debug("connect", this._retryCount);
|
|
354
|
+
this._removeListeners();
|
|
355
|
+
if (!isWebSocket(WebSocket)) {
|
|
356
|
+
throw Error("No valid WebSocket class provided");
|
|
357
|
+
}
|
|
358
|
+
this._wait()
|
|
359
|
+
.then(() => this._getNextUrl(this._url))
|
|
360
|
+
.then((url) => {
|
|
361
|
+
if (this._closeCalled) {
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
const options = {};
|
|
365
|
+
if (this._headers) {
|
|
366
|
+
options.headers = this._headers;
|
|
367
|
+
}
|
|
368
|
+
if (this._queryParameters && Object.keys(this._queryParameters).length > 0) {
|
|
369
|
+
const queryString = (0, qs_1.toQueryString)(this._queryParameters, { arrayFormat: "repeat" });
|
|
370
|
+
if (queryString) {
|
|
371
|
+
url = `${url}?${queryString}`;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
this._ws = new WebSocket(url, this._protocols, options);
|
|
375
|
+
this._ws.binaryType = this._binaryType;
|
|
376
|
+
this._connectLock = false;
|
|
377
|
+
this._addListeners();
|
|
378
|
+
this._connectTimeout = setTimeout(() => this._handleTimeout(), connectionTimeout);
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
_handleTimeout() {
|
|
382
|
+
this._debug("timeout event");
|
|
383
|
+
this._handleError(new Events.ErrorEvent(Error("TIMEOUT"), this));
|
|
384
|
+
}
|
|
385
|
+
_disconnect(code = 1000, reason) {
|
|
386
|
+
this._clearTimeouts();
|
|
387
|
+
if (!this._ws) {
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
this._removeListeners();
|
|
391
|
+
try {
|
|
392
|
+
this._ws.close(code, reason);
|
|
393
|
+
this._handleClose(new Events.CloseEvent(code, reason, this));
|
|
394
|
+
}
|
|
395
|
+
catch (_error) {
|
|
396
|
+
// ignore
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
_acceptOpen() {
|
|
400
|
+
this._debug("accept open");
|
|
401
|
+
this._retryCount = 0;
|
|
402
|
+
}
|
|
403
|
+
_callEventListener(event, listener) {
|
|
404
|
+
if ("handleEvent" in listener) {
|
|
405
|
+
// @ts-ignore
|
|
406
|
+
listener.handleEvent(event);
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
// @ts-ignore
|
|
410
|
+
listener(event);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
_removeListeners() {
|
|
414
|
+
if (!this._ws) {
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
this._debug("removeListeners");
|
|
418
|
+
this._ws.removeEventListener("open", this._handleOpen);
|
|
419
|
+
this._ws.removeEventListener("close", this._handleClose);
|
|
420
|
+
this._ws.removeEventListener("message", this._handleMessage);
|
|
421
|
+
// @ts-ignore
|
|
422
|
+
this._ws.removeEventListener("error", this._handleError);
|
|
423
|
+
}
|
|
424
|
+
_addListeners() {
|
|
425
|
+
if (!this._ws) {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
this._debug("addListeners");
|
|
429
|
+
this._ws.addEventListener("open", this._handleOpen);
|
|
430
|
+
this._ws.addEventListener("close", this._handleClose);
|
|
431
|
+
this._ws.addEventListener("message", this._handleMessage);
|
|
432
|
+
// @ts-ignore
|
|
433
|
+
this._ws.addEventListener("error", this._handleError);
|
|
434
|
+
}
|
|
435
|
+
_clearTimeouts() {
|
|
436
|
+
clearTimeout(this._connectTimeout);
|
|
437
|
+
clearTimeout(this._uptimeTimeout);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
exports.ReconnectingWebSocket = ReconnectingWebSocket;
|
|
441
|
+
ReconnectingWebSocket.CONNECTING = 0;
|
|
442
|
+
ReconnectingWebSocket.OPEN = 1;
|
|
443
|
+
ReconnectingWebSocket.CLOSING = 2;
|
|
444
|
+
ReconnectingWebSocket.CLOSED = 3;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./types";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as MavenAGI from "../../../../api/index";
|
|
2
|
+
import * as core from "../../../../core";
|
|
3
|
+
import type * as serializers from "../../../index";
|
|
4
|
+
export declare const SessionTokenRequest: core.serialization.ObjectSchema<serializers.SessionTokenRequest.Raw, MavenAGI.SessionTokenRequest>;
|
|
5
|
+
export declare namespace SessionTokenRequest {
|
|
6
|
+
interface Raw {
|
|
7
|
+
ttlSeconds: number;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.SessionTokenRequest = void 0;
|
|
38
|
+
const core = __importStar(require("../../../../core"));
|
|
39
|
+
exports.SessionTokenRequest = core.serialization.object({
|
|
40
|
+
ttlSeconds: core.serialization.number(),
|
|
41
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type * as MavenAGI from "../../../../api/index";
|
|
2
|
+
import * as core from "../../../../core";
|
|
3
|
+
import type * as serializers from "../../../index";
|
|
4
|
+
export declare const SessionTokenResponse: core.serialization.ObjectSchema<serializers.SessionTokenResponse.Raw, MavenAGI.SessionTokenResponse>;
|
|
5
|
+
export declare namespace SessionTokenResponse {
|
|
6
|
+
interface Raw {
|
|
7
|
+
sessionToken: string;
|
|
8
|
+
expiresAt: string;
|
|
9
|
+
}
|
|
10
|
+
}
|