mavenagi 1.2.64 → 1.2.66
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/BaseClient.d.ts +4 -2
- package/BaseClient.js +8 -3
- package/README.md +2 -2
- package/api/resources/actions/client/Client.js +3 -3
- package/api/resources/agents/client/Client.js +5 -5
- package/api/resources/agents/client/requests/AgentPatchRequest.d.ts +10 -2
- package/api/resources/agents/types/Agent.d.ts +3 -1
- package/api/resources/agents/types/AgentPrompting.d.ts +12 -2
- package/api/resources/analytics/client/Client.d.ts +0 -38
- package/api/resources/analytics/client/Client.js +0 -120
- package/api/resources/analytics/types/AgentUserGroupBy.d.ts +15 -0
- package/api/resources/analytics/types/AgentUserRowIdentifier.d.ts +2 -0
- package/api/resources/analytics/types/AgentUserTableRequest.d.ts +7 -0
- package/api/resources/analytics/types/AgentUserTableResponse.d.ts +4 -1
- package/api/resources/analytics/types/index.d.ts +1 -10
- package/api/resources/analytics/types/index.js +1 -10
- package/api/resources/appDirectory/client/Client.js +5 -5
- package/api/resources/assets/client/Client.js +1 -1
- package/api/resources/capabilities/client/Client.d.ts +33 -0
- package/api/resources/capabilities/client/Client.js +126 -3
- package/api/resources/capabilities/client/requests/CapabilitiesSearchRequest.d.ts +0 -4
- package/api/resources/capabilities/client/requests/CapabilityExecutionsSearchRequest.d.ts +5 -0
- package/api/resources/capabilities/client/requests/SimulateCapabilityByTypeRequest.d.ts +14 -0
- package/api/resources/capabilities/client/requests/index.d.ts +1 -0
- package/api/resources/capabilities/types/ActionSimulationInput.d.ts +5 -0
- package/api/resources/capabilities/types/CapabilityExecutionBase.d.ts +5 -0
- package/api/resources/capabilities/types/CapabilityExecutionsSearchResponse.d.ts +3 -1
- package/api/resources/capabilities/types/CapabilitySimulationInput.d.ts +11 -0
- package/api/resources/capabilities/types/CapabilitySimulationResult.d.ts +10 -0
- package/api/resources/capabilities/types/ConversationContextSimulationInput.d.ts +14 -0
- package/api/resources/capabilities/types/SimulatedUser.d.ts +9 -0
- package/api/resources/capabilities/types/SimulatedUserData.d.ts +6 -0
- package/api/resources/capabilities/types/index.d.ts +6 -0
- package/api/resources/capabilities/types/index.js +6 -0
- package/api/resources/charters/client/Client.js +4 -4
- package/api/resources/charters/types/CharterBase.d.ts +5 -1
- package/api/resources/charters/types/CharterChildrenExclusionPolicy.d.ts +2 -0
- package/api/resources/charters/types/CharterChildrenExclusionPolicy.js +2 -0
- package/api/resources/charters/types/CharterContent.d.ts +2 -0
- package/api/resources/charters/types/CharterPatchReferences.d.ts +2 -0
- package/api/resources/charters/types/CharterReferences.d.ts +2 -0
- package/api/resources/charters/types/CharterResponse.d.ts +5 -1
- package/api/resources/charters/types/CharterStatus.d.ts +4 -0
- package/api/resources/charters/types/CharterStatus.js +4 -0
- package/api/resources/charters/types/CharterSummary.d.ts +5 -1
- package/api/resources/charters/types/index.d.ts +0 -1
- package/api/resources/charters/types/index.js +0 -1
- package/api/resources/commons/types/ActionExecutionStatus.d.ts +6 -0
- package/api/resources/commons/types/ActionExecutionStatus.js +9 -0
- package/api/resources/commons/types/ActionProperties.d.ts +1 -1
- package/api/resources/commons/types/AdditionalDataKey.d.ts +84 -3
- package/api/resources/commons/types/AdditionalDataKey.js +84 -3
- package/api/resources/commons/types/AppUserRequest.d.ts +11 -0
- package/api/resources/commons/types/BaseConversationResponse.d.ts +6 -0
- package/api/resources/commons/types/BotLogicCharterDetail.d.ts +2 -0
- package/api/resources/commons/types/BotMessage.d.ts +6 -1
- package/api/resources/commons/types/BotMessageStatusReason.d.ts +13 -0
- package/api/resources/commons/types/BotMessageStatusReason.js +16 -0
- package/api/resources/commons/types/Capability.d.ts +4 -0
- package/api/resources/commons/types/Capability.js +4 -0
- package/api/resources/commons/types/CapabilityStatus.d.ts +2 -2
- package/api/resources/commons/types/CapabilityStatus.js +2 -2
- package/api/resources/commons/types/ConversationAnalysis.d.ts +1 -1
- package/api/resources/commons/types/ConversationMetadataValueSource.d.ts +7 -0
- package/api/resources/commons/types/ConversationResponse.d.ts +1 -0
- package/api/resources/commons/types/ConversationSummary.d.ts +5 -3
- package/api/resources/commons/types/ConversationValueSource.d.ts +13 -0
- package/api/resources/commons/types/EntityType.d.ts +5 -0
- package/api/resources/commons/types/EntityType.js +5 -0
- package/api/resources/commons/types/ErrorReason.d.ts +5 -2
- package/api/resources/commons/types/ErrorReason.js +5 -2
- package/api/resources/commons/types/EventBaseNoId.d.ts +6 -0
- package/api/resources/commons/types/EventFilter.d.ts +3 -0
- package/api/resources/commons/types/EventTriggerType.d.ts +7 -0
- package/api/resources/commons/types/EventTriggerType.js +7 -0
- package/api/resources/commons/types/ExecuteActionResponse.d.ts +14 -0
- package/api/resources/commons/types/ExecutionMode.d.ts +10 -0
- package/api/resources/commons/types/ExecutionMode.js +13 -0
- package/api/resources/commons/types/FunctionVersionBinding.d.ts +11 -0
- package/api/resources/commons/types/FunctionVersionBinding.js +3 -0
- package/api/resources/commons/types/InboxItemDuplicateDocuments.d.ts +1 -1
- package/api/resources/commons/types/InboxItemStatus.d.ts +1 -1
- package/api/resources/commons/types/InboxItemStatus.js +1 -1
- package/api/resources/commons/types/InitializeConversationResponse.d.ts +40 -0
- package/api/resources/commons/types/LlmInclusionStatus.d.ts +3 -0
- package/api/resources/commons/types/LlmInclusionStatus.js +3 -0
- package/api/resources/commons/types/MetadataConversationValueFilter.d.ts +15 -0
- package/api/resources/commons/types/MetadataConversationValueFilter.js +3 -0
- package/api/resources/commons/types/MetadataFilter.d.ts +33 -6
- package/api/resources/commons/types/Quality.d.ts +2 -0
- package/api/resources/commons/types/Quality.js +2 -0
- package/api/resources/commons/types/QualityReason.d.ts +4 -0
- package/api/resources/commons/types/QualityReason.js +4 -0
- package/api/resources/commons/types/RelationshipType.d.ts +2 -2
- package/api/resources/commons/types/RelationshipType.js +2 -2
- package/api/resources/commons/types/ResolutionStatus.d.ts +2 -0
- package/api/resources/commons/types/ResolutionStatus.js +2 -0
- package/api/resources/commons/types/ResponseConfig.d.ts +2 -0
- package/api/resources/commons/types/SimulationActionBehavior.d.ts +19 -0
- package/api/resources/commons/types/SimulationActionBehavior.js +3 -0
- package/api/resources/commons/types/SimulationActionCallApp.d.ts +1 -0
- package/api/resources/commons/types/SimulationActionCallApp.js +3 -0
- package/api/resources/commons/types/SimulationActionMock.d.ts +7 -0
- package/api/resources/commons/types/SimulationActionMock.js +3 -0
- package/api/resources/commons/types/SimulationContext.d.ts +19 -0
- package/api/resources/commons/types/SystemEventName.d.ts +5 -2
- package/api/resources/commons/types/SystemEventName.js +5 -2
- package/api/resources/commons/types/UserDataValueSource.d.ts +8 -0
- package/api/resources/commons/types/UserDataValueSource.js +3 -0
- package/api/resources/commons/types/UserEvent.d.ts +1 -1
- package/api/resources/commons/types/UserEventName.d.ts +80 -5
- package/api/resources/commons/types/UserEventName.js +80 -5
- package/api/resources/commons/types/index.d.ts +14 -0
- package/api/resources/commons/types/index.js +14 -0
- package/api/resources/conversation/client/Client.d.ts +53 -29
- package/api/resources/conversation/client/Client.js +65 -40
- package/api/resources/conversation/client/requests/ConversationDeleteRequest.d.ts +1 -1
- package/api/resources/conversation/client/requests/ConversationGetRequest.d.ts +2 -0
- package/api/resources/conversation/types/BillableFilterField.d.ts +3 -3
- package/api/resources/conversation/types/BillableFilterField.js +3 -3
- package/api/resources/conversation/types/ConversationField.d.ts +8 -0
- package/api/resources/conversation/types/ConversationField.js +8 -0
- package/api/resources/conversation/types/ConversationFilter.d.ts +7 -1
- package/api/resources/conversation/types/ConversationPatchRequest.d.ts +1 -1
- package/api/resources/conversation/types/ConversationRequest.d.ts +45 -0
- package/api/resources/conversation/types/DeliverConversationMessageRequest.d.ts +1 -1
- package/api/resources/conversation/types/index.d.ts +0 -3
- package/api/resources/conversation/types/index.js +0 -3
- package/api/resources/customers/client/Client.js +2 -2
- package/api/resources/customers/types/CustomerFilter.d.ts +2 -0
- package/api/resources/customers/types/CustomerResponse.d.ts +2 -2
- package/api/resources/developersCommons/types/BaseDetailApp.d.ts +13 -4
- package/api/resources/developersCommons/types/Link.d.ts +1 -1
- package/api/resources/developersCommons/types/MarketplaceAppDetail.d.ts +2 -1
- package/api/resources/events/client/Client.js +1 -1
- package/api/resources/inbox/client/Client.js +6 -6
- package/api/resources/integrations/client/Client.js +1 -1
- package/api/resources/intelligentFields/client/Client.d.ts +3 -2
- package/api/resources/intelligentFields/client/Client.js +6 -5
- package/api/resources/intelligentFields/client/requests/IntelligentFieldPatchRequest.d.ts +0 -2
- package/api/resources/intelligentFields/types/EnumOption.d.ts +1 -1
- package/api/resources/intelligentFields/types/IntelligentFieldBase.d.ts +1 -1
- package/api/resources/intelligentFields/types/IntelligentFieldCore.d.ts +5 -1
- package/api/resources/intelligentFields/types/IntelligentFieldType.d.ts +1 -1
- package/api/resources/intelligentFields/types/IntelligentFieldType.js +1 -1
- package/api/resources/knowledge/client/Client.js +13 -13
- package/api/resources/knowledge/types/KnowledgeBaseFunctionBindings.d.ts +12 -0
- package/api/resources/knowledge/types/KnowledgeBaseFunctionBindings.js +3 -0
- package/api/resources/knowledge/types/KnowledgeBaseIndexingStatus.d.ts +1 -1
- package/api/resources/knowledge/types/KnowledgeBaseIndexingStatus.js +1 -1
- package/api/resources/knowledge/types/KnowledgeBaseResponse.d.ts +3 -1
- package/api/resources/knowledge/types/KnowledgeBaseType.d.ts +2 -0
- package/api/resources/knowledge/types/KnowledgeBaseType.js +2 -0
- package/api/resources/knowledge/types/KnowledgeBaseVersion.d.ts +2 -0
- package/api/resources/knowledge/types/KnowledgeBaseVersionStatus.d.ts +4 -0
- package/api/resources/knowledge/types/KnowledgeBaseVersionStatus.js +4 -0
- package/api/resources/knowledge/types/KnowledgeDocumentResponse.d.ts +1 -1
- package/api/resources/knowledge/types/index.d.ts +1 -0
- package/api/resources/knowledge/types/index.js +1 -0
- package/api/resources/organizations/client/Client.d.ts +13 -15
- package/api/resources/organizations/client/Client.js +17 -19
- package/api/resources/segments/client/Client.d.ts +1 -1
- package/api/resources/segments/client/Client.js +4 -4
- package/api/resources/segments/types/SegmentStatus.d.ts +4 -0
- package/api/resources/segments/types/SegmentStatus.js +4 -0
- package/api/resources/triggers/client/Client.js +3 -3
- package/api/resources/triggers/types/EventTriggerBase.d.ts +2 -0
- package/api/resources/users/client/Client.d.ts +42 -1
- package/api/resources/users/client/Client.js +116 -4
- package/api/resources/users/types/AgentUser.d.ts +3 -0
- package/api/resources/users/types/AgentUserField.d.ts +8 -0
- package/api/resources/users/types/AgentUserField.js +8 -0
- package/api/resources/users/types/AgentUserFilter.d.ts +4 -0
- package/api/resources/users/types/AgentUserSearchRequest.d.ts +4 -0
- package/api/resources/voiceConversations/client/Client.d.ts +1 -1
- package/api/resources/voiceConversations/client/Socket.d.ts +2 -2
- package/api/resources/voiceConversations/client/Socket.js +16 -17
- package/auth/AnyAuthProvider.d.ts +23 -0
- package/auth/AnyAuthProvider.js +46 -0
- package/auth/BearerAuthProvider.d.ts +20 -0
- package/auth/BearerAuthProvider.js +82 -0
- package/auth/index.d.ts +2 -0
- package/auth/index.js +5 -1
- package/core/fetcher/Fetcher.js +33 -3
- package/core/fetcher/getErrorResponseBody.js +20 -7
- package/core/fetcher/getResponseBody.d.ts +16 -0
- package/core/fetcher/getResponseBody.js +27 -22
- package/core/fetcher/makePassthroughRequest.js +20 -4
- package/core/fetcher/makeRequest.d.ts +6 -1
- package/core/fetcher/makeRequest.js +38 -5
- package/core/fetcher/requestWithRetries.d.ts +1 -1
- package/core/fetcher/requestWithRetries.js +23 -2
- package/core/fetcher/signals.d.ts +1 -0
- package/core/fetcher/signals.js +3 -2
- package/core/stream/Stream.d.ts +3 -0
- package/core/stream/Stream.js +5 -0
- package/core/url/encodePathParam.d.ts +3 -1
- package/core/url/encodePathParam.js +8 -2
- package/core/websocket/ws.d.ts +16 -2
- package/core/websocket/ws.js +110 -20
- package/errors/MavenAGIError.js +16 -2
- package/package.json +1 -1
- package/reference.md +207 -128
- package/serialization/resources/analytics/types/AgentUserGroupBy.d.ts +15 -0
- package/serialization/resources/analytics/types/{FeedbackTableResponse.js → AgentUserGroupBy.js} +10 -6
- package/serialization/resources/analytics/types/AgentUserRowIdentifier.d.ts +2 -0
- package/serialization/resources/analytics/types/AgentUserRowIdentifier.js +2 -0
- package/serialization/resources/analytics/types/AgentUserTableRequest.d.ts +2 -0
- package/serialization/resources/analytics/types/AgentUserTableRequest.js +2 -0
- package/serialization/resources/analytics/types/index.d.ts +1 -10
- package/serialization/resources/analytics/types/index.js +1 -10
- package/serialization/resources/capabilities/client/requests/CapabilitiesSearchRequest.d.ts +0 -2
- package/serialization/resources/capabilities/client/requests/CapabilitiesSearchRequest.js +0 -2
- package/serialization/resources/capabilities/client/requests/CapabilityExecutionsSearchRequest.d.ts +2 -0
- package/serialization/resources/capabilities/client/requests/CapabilityExecutionsSearchRequest.js +2 -0
- package/serialization/resources/capabilities/types/ActionSimulationInput.d.ts +10 -0
- package/serialization/resources/{analytics/types/FeedbackRowIdentifier.js → capabilities/types/ActionSimulationInput.js} +5 -6
- package/serialization/resources/capabilities/types/CapabilityExecutionBase.d.ts +2 -0
- package/serialization/resources/capabilities/types/CapabilityExecutionBase.js +2 -0
- package/serialization/resources/capabilities/types/CapabilitySimulationInput.d.ts +11 -0
- package/serialization/resources/{analytics/types/FeedbackMetric.js → capabilities/types/CapabilitySimulationInput.js} +5 -7
- package/serialization/resources/capabilities/types/CapabilitySimulationResult.d.ts +11 -0
- package/serialization/resources/{analytics/types/FeedbackGroupBy.js → capabilities/types/CapabilitySimulationResult.js} +9 -7
- package/serialization/resources/capabilities/types/ConversationContextSimulationInput.d.ts +12 -0
- package/serialization/resources/capabilities/types/ConversationContextSimulationInput.js +46 -0
- package/serialization/resources/capabilities/types/SimulatedUser.d.ts +10 -0
- package/serialization/resources/{analytics/types/FeedbackAnalyticsRequest.js → capabilities/types/SimulatedUser.js} +6 -5
- package/serialization/resources/capabilities/types/SimulatedUserData.d.ts +10 -0
- package/serialization/resources/capabilities/types/SimulatedUserData.js +42 -0
- package/serialization/resources/capabilities/types/index.d.ts +6 -0
- package/serialization/resources/capabilities/types/index.js +6 -0
- package/serialization/resources/charters/types/CharterContent.d.ts +1 -1
- package/serialization/resources/charters/types/CharterContent.js +1 -1
- package/serialization/resources/charters/types/CharterResponse.d.ts +1 -1
- package/serialization/resources/charters/types/CharterResponse.js +1 -1
- package/serialization/resources/charters/types/CharterSummary.d.ts +1 -1
- package/serialization/resources/charters/types/CharterSummary.js +1 -1
- package/serialization/resources/charters/types/index.d.ts +0 -1
- package/serialization/resources/charters/types/index.js +0 -1
- package/serialization/resources/commons/types/ActionExecutionStatus.d.ts +7 -0
- package/serialization/resources/{conversation/types/FeedbackField.js → commons/types/ActionExecutionStatus.js} +2 -2
- package/serialization/resources/commons/types/AdditionalDataKey.d.ts +1 -1
- package/serialization/resources/commons/types/AdditionalDataKey.js +27 -0
- package/serialization/resources/commons/types/AppUserRequest.d.ts +2 -0
- package/serialization/resources/commons/types/AppUserRequest.js +2 -0
- package/serialization/resources/commons/types/BaseConversationResponse.d.ts +2 -0
- package/serialization/resources/commons/types/BaseConversationResponse.js +2 -0
- package/serialization/resources/commons/types/BotLogicCharterDetail.d.ts +2 -0
- package/serialization/resources/commons/types/BotLogicCharterDetail.js +2 -0
- package/serialization/resources/commons/types/BotMessage.d.ts +2 -0
- package/serialization/resources/commons/types/BotMessage.js +2 -0
- package/serialization/resources/commons/types/BotMessageStatusReason.d.ts +7 -0
- package/serialization/resources/commons/types/BotMessageStatusReason.js +43 -0
- package/serialization/resources/commons/types/ConversationMetadataValueSource.d.ts +9 -0
- package/serialization/resources/commons/types/ConversationMetadataValueSource.js +41 -0
- package/serialization/resources/commons/types/ConversationValueSource.d.ts +15 -0
- package/serialization/resources/commons/types/ConversationValueSource.js +49 -0
- package/serialization/resources/commons/types/EntityType.d.ts +1 -1
- package/serialization/resources/commons/types/EntityType.js +5 -0
- package/serialization/resources/commons/types/ErrorReason.d.ts +1 -1
- package/serialization/resources/commons/types/ErrorReason.js +1 -0
- package/serialization/resources/commons/types/EventBaseNoId.d.ts +2 -0
- package/serialization/resources/commons/types/EventBaseNoId.js +2 -0
- package/serialization/resources/commons/types/EventFilter.d.ts +2 -0
- package/serialization/resources/commons/types/EventFilter.js +2 -0
- package/serialization/resources/commons/types/ExecuteActionResponse.d.ts +13 -0
- package/serialization/resources/commons/types/ExecuteActionResponse.js +45 -0
- package/serialization/resources/commons/types/ExecutionMode.d.ts +7 -0
- package/serialization/resources/commons/types/ExecutionMode.js +39 -0
- package/serialization/resources/commons/types/FunctionVersionBinding.d.ts +11 -0
- package/serialization/resources/{analytics/types/FeedbackDistinctCount.js → commons/types/FunctionVersionBinding.js} +5 -4
- package/serialization/resources/commons/types/MetadataConversationValueFilter.d.ts +11 -0
- package/serialization/resources/commons/types/MetadataConversationValueFilter.js +43 -0
- package/serialization/resources/commons/types/MetadataFilter.d.ts +5 -1
- package/serialization/resources/commons/types/MetadataFilter.js +2 -0
- package/serialization/resources/commons/types/SimulationActionBehavior.d.ts +15 -0
- package/serialization/resources/commons/types/SimulationActionBehavior.js +49 -0
- package/serialization/resources/commons/types/SimulationActionCallApp.d.ts +7 -0
- package/serialization/resources/{analytics/types/FeedbackCount.js → commons/types/SimulationActionCallApp.js} +2 -2
- package/serialization/resources/commons/types/SimulationActionMock.d.ts +12 -0
- package/serialization/resources/{analytics/types/FeedbackColumnDefinition.js → commons/types/SimulationActionMock.js} +7 -8
- package/serialization/resources/commons/types/SimulationContext.d.ts +4 -0
- package/serialization/resources/commons/types/SimulationContext.js +4 -0
- package/serialization/resources/commons/types/SystemEventName.d.ts +1 -1
- package/serialization/resources/commons/types/SystemEventName.js +1 -0
- package/serialization/resources/commons/types/UserDataValueSource.d.ts +9 -0
- package/serialization/resources/commons/types/UserDataValueSource.js +41 -0
- package/serialization/resources/commons/types/UserEventName.d.ts +1 -1
- package/serialization/resources/commons/types/UserEventName.js +25 -0
- package/serialization/resources/commons/types/index.d.ts +14 -0
- package/serialization/resources/commons/types/index.js +14 -0
- package/serialization/resources/conversation/types/ConversationFilter.d.ts +1 -1
- package/serialization/resources/conversation/types/ConversationFilter.js +1 -1
- package/serialization/resources/conversation/types/index.d.ts +0 -3
- package/serialization/resources/conversation/types/index.js +0 -3
- package/serialization/resources/intelligentFields/client/requests/IntelligentFieldPatchRequest.d.ts +0 -1
- package/serialization/resources/intelligentFields/client/requests/IntelligentFieldPatchRequest.js +0 -1
- package/serialization/resources/knowledge/types/KnowledgeBaseFunctionBindings.d.ts +12 -0
- package/serialization/resources/knowledge/types/KnowledgeBaseFunctionBindings.js +44 -0
- package/serialization/resources/knowledge/types/index.d.ts +1 -0
- package/serialization/resources/knowledge/types/index.js +1 -0
- package/serialization/resources/users/types/AgentUser.d.ts +2 -0
- package/serialization/resources/users/types/AgentUser.js +2 -0
- package/serialization/resources/users/types/AgentUserField.d.ts +1 -1
- package/serialization/resources/users/types/AgentUserField.js +1 -1
- package/serialization/resources/users/types/AgentUserFilter.d.ts +2 -0
- package/serialization/resources/users/types/AgentUserFilter.js +2 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/api/resources/analytics/types/FeedbackAnalyticsRequest.d.ts +0 -11
- package/api/resources/analytics/types/FeedbackColumnDefinition.d.ts +0 -5
- package/api/resources/analytics/types/FeedbackCount.d.ts +0 -4
- package/api/resources/analytics/types/FeedbackDistinctCount.d.ts +0 -9
- package/api/resources/analytics/types/FeedbackGroupBy.d.ts +0 -5
- package/api/resources/analytics/types/FeedbackMetric.d.ts +0 -13
- package/api/resources/analytics/types/FeedbackRow.d.ts +0 -11
- package/api/resources/analytics/types/FeedbackRowIdentifier.d.ts +0 -5
- package/api/resources/analytics/types/FeedbackTableRequest.d.ts +0 -38
- package/api/resources/analytics/types/FeedbackTableResponse.d.ts +0 -56
- package/api/resources/conversation/types/FeedbackField.d.ts +0 -7
- package/api/resources/conversation/types/FeedbackField.js +0 -10
- package/api/resources/conversation/types/FeedbackFilter.d.ts +0 -9
- package/serialization/resources/analytics/types/FeedbackAnalyticsRequest.d.ts +0 -11
- package/serialization/resources/analytics/types/FeedbackColumnDefinition.d.ts +0 -11
- package/serialization/resources/analytics/types/FeedbackCount.d.ts +0 -7
- package/serialization/resources/analytics/types/FeedbackDistinctCount.d.ts +0 -10
- package/serialization/resources/analytics/types/FeedbackGroupBy.d.ts +0 -11
- package/serialization/resources/analytics/types/FeedbackMetric.d.ts +0 -15
- package/serialization/resources/analytics/types/FeedbackRow.d.ts +0 -14
- package/serialization/resources/analytics/types/FeedbackRow.js +0 -48
- package/serialization/resources/analytics/types/FeedbackRowIdentifier.d.ts +0 -11
- package/serialization/resources/analytics/types/FeedbackTableRequest.d.ts +0 -15
- package/serialization/resources/analytics/types/FeedbackTableRequest.js +0 -49
- package/serialization/resources/analytics/types/FeedbackTableResponse.d.ts +0 -11
- package/serialization/resources/conversation/types/FeedbackField.d.ts +0 -7
- package/serialization/resources/conversation/types/FeedbackFilter.d.ts +0 -15
- package/serialization/resources/conversation/types/FeedbackFilter.js +0 -47
- /package/api/resources/analytics/types/{FeedbackAnalyticsRequest.js → AgentUserGroupBy.js} +0 -0
- /package/api/resources/{analytics/types/FeedbackColumnDefinition.js → capabilities/client/requests/SimulateCapabilityByTypeRequest.js} +0 -0
- /package/api/resources/{analytics/types/FeedbackCount.js → capabilities/types/ActionSimulationInput.js} +0 -0
- /package/api/resources/{analytics/types/FeedbackDistinctCount.js → capabilities/types/CapabilitySimulationInput.js} +0 -0
- /package/api/resources/{analytics/types/FeedbackGroupBy.js → capabilities/types/CapabilitySimulationResult.js} +0 -0
- /package/api/resources/{analytics/types/FeedbackMetric.js → capabilities/types/ConversationContextSimulationInput.js} +0 -0
- /package/api/resources/{analytics/types/FeedbackRow.js → capabilities/types/SimulatedUser.js} +0 -0
- /package/api/resources/{analytics/types/FeedbackRowIdentifier.js → capabilities/types/SimulatedUserData.js} +0 -0
- /package/api/resources/{charters → commons}/types/CharterType.d.ts +0 -0
- /package/api/resources/{charters → commons}/types/CharterType.js +0 -0
- /package/api/resources/{analytics/types/FeedbackTableRequest.js → commons/types/ConversationMetadataValueSource.js} +0 -0
- /package/api/resources/{analytics/types/FeedbackTableResponse.js → commons/types/ConversationValueSource.js} +0 -0
- /package/api/resources/{conversation/types/FeedbackFilter.js → commons/types/ExecuteActionResponse.js} +0 -0
- /package/api/resources/{conversation → commons}/types/SimulationFilter.d.ts +0 -0
- /package/api/resources/{conversation → commons}/types/SimulationFilter.js +0 -0
- /package/serialization/resources/{charters → commons}/types/CharterType.d.ts +0 -0
- /package/serialization/resources/{charters → commons}/types/CharterType.js +0 -0
- /package/serialization/resources/{conversation → commons}/types/SimulationFilter.d.ts +0 -0
- /package/serialization/resources/{conversation → commons}/types/SimulationFilter.js +0 -0
|
@@ -1 +1,17 @@
|
|
|
1
|
+
export type ResponseBodyError = {
|
|
2
|
+
ok: false;
|
|
3
|
+
error: {
|
|
4
|
+
reason: "non-json";
|
|
5
|
+
statusCode: number;
|
|
6
|
+
rawBody: string;
|
|
7
|
+
} | {
|
|
8
|
+
reason: "body-is-null";
|
|
9
|
+
statusCode: number;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Returns true when `value` is a failure record created by `getResponseBody` (for example malformed JSON),
|
|
14
|
+
* as opposed to a parsed JSON body that happens to have the same shape.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isResponseBodyError(value: unknown): value is ResponseBodyError;
|
|
1
17
|
export declare function getResponseBody(response: Response, responseType?: string): Promise<unknown>;
|
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.isResponseBodyError = isResponseBodyError;
|
|
12
13
|
exports.getResponseBody = getResponseBody;
|
|
13
14
|
const json_1 = require("../json");
|
|
14
15
|
const BinaryResponse_1 = require("./BinaryResponse");
|
|
@@ -21,6 +22,19 @@ function retainResponse(target, response) {
|
|
|
21
22
|
writable: false,
|
|
22
23
|
});
|
|
23
24
|
}
|
|
25
|
+
const responseBodyErrors = new WeakSet();
|
|
26
|
+
function responseBodyError(error) {
|
|
27
|
+
const record = { ok: false, error };
|
|
28
|
+
responseBodyErrors.add(record);
|
|
29
|
+
return record;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns true when `value` is a failure record created by `getResponseBody` (for example malformed JSON),
|
|
33
|
+
* as opposed to a parsed JSON body that happens to have the same shape.
|
|
34
|
+
*/
|
|
35
|
+
function isResponseBodyError(value) {
|
|
36
|
+
return typeof value === "object" && value != null && responseBodyErrors.has(value);
|
|
37
|
+
}
|
|
24
38
|
function getResponseBody(response, responseType) {
|
|
25
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
40
|
switch (responseType) {
|
|
@@ -32,25 +46,19 @@ function getResponseBody(response, responseType) {
|
|
|
32
46
|
return yield response.arrayBuffer();
|
|
33
47
|
case "sse":
|
|
34
48
|
if (response.body == null) {
|
|
35
|
-
return {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
statusCode: response.status,
|
|
40
|
-
},
|
|
41
|
-
};
|
|
49
|
+
return responseBodyError({
|
|
50
|
+
reason: "body-is-null",
|
|
51
|
+
statusCode: response.status,
|
|
52
|
+
});
|
|
42
53
|
}
|
|
43
54
|
retainResponse(response.body, response);
|
|
44
55
|
return response.body;
|
|
45
56
|
case "streaming":
|
|
46
57
|
if (response.body == null) {
|
|
47
|
-
return {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
statusCode: response.status,
|
|
52
|
-
},
|
|
53
|
-
};
|
|
58
|
+
return responseBodyError({
|
|
59
|
+
reason: "body-is-null",
|
|
60
|
+
statusCode: response.status,
|
|
61
|
+
});
|
|
54
62
|
}
|
|
55
63
|
retainResponse(response.body, response);
|
|
56
64
|
return response.body;
|
|
@@ -65,14 +73,11 @@ function getResponseBody(response, responseType) {
|
|
|
65
73
|
return responseBody;
|
|
66
74
|
}
|
|
67
75
|
catch (_err) {
|
|
68
|
-
return {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
rawBody: text,
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
+
return responseBodyError({
|
|
77
|
+
reason: "non-json",
|
|
78
|
+
statusCode: response.status,
|
|
79
|
+
rawBody: text,
|
|
80
|
+
});
|
|
76
81
|
}
|
|
77
82
|
}
|
|
78
83
|
return undefined;
|
|
@@ -18,6 +18,7 @@ const makeRequest_1 = require("./makeRequest");
|
|
|
18
18
|
const redactUrl_1 = require("./redactUrl");
|
|
19
19
|
const requestWithRetries_1 = require("./requestWithRetries");
|
|
20
20
|
const Supplier_1 = require("./Supplier");
|
|
21
|
+
const signals_1 = require("./signals");
|
|
21
22
|
/**
|
|
22
23
|
* Makes a passthrough HTTP request using the SDK's configuration (auth, retry, logging, etc.)
|
|
23
24
|
* while mimicking the standard `fetch` API.
|
|
@@ -122,10 +123,20 @@ function makePassthroughRequest(input, init, clientOptions, requestOptions) {
|
|
|
122
123
|
hasBody: body != null,
|
|
123
124
|
});
|
|
124
125
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
let response;
|
|
127
|
+
try {
|
|
128
|
+
response = yield (0, requestWithRetries_1.requestWithRetries)(() => __awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
return (0, makeRequest_1.makeRequest)(fetchFn, fullUrl, method, mergedHeaders, body !== null && body !== void 0 ? body : undefined, timeoutMs, abortSignal, (effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.credentials) === "include", undefined, // duplex
|
|
130
|
+
false);
|
|
131
|
+
}), maxRetries, abortSignal);
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
// Match `fetch`: a timeout rejects with an Error named "TimeoutError", not the bare abort reason.
|
|
135
|
+
if (error === signals_1.TIMEOUT) {
|
|
136
|
+
throw createTimeoutError();
|
|
137
|
+
}
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
129
140
|
if (logger.isDebug()) {
|
|
130
141
|
logger.debug("Passthrough HTTP request completed", {
|
|
131
142
|
method,
|
|
@@ -136,6 +147,11 @@ function makePassthroughRequest(input, init, clientOptions, requestOptions) {
|
|
|
136
147
|
return response;
|
|
137
148
|
});
|
|
138
149
|
}
|
|
150
|
+
function createTimeoutError() {
|
|
151
|
+
const error = new Error("The request timed out.");
|
|
152
|
+
error.name = "TimeoutError";
|
|
153
|
+
return error;
|
|
154
|
+
}
|
|
139
155
|
/**
|
|
140
156
|
* Returns true when the resolved request URL points at the same origin as the
|
|
141
157
|
* configured base URL. Relative paths are always joined onto the base URL, so
|
|
@@ -3,4 +3,9 @@ export declare function isCacheNoStoreSupported(): boolean;
|
|
|
3
3
|
* Reset the cached result of `isCacheNoStoreSupported`. Exposed for testing only.
|
|
4
4
|
*/
|
|
5
5
|
export declare function resetCacheNoStoreSupported(): void;
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Clears the timeout that `makeRequest` kept running (with `keepTimeoutUntilBodyRead`) so that it also
|
|
8
|
+
* covered reading the response body.
|
|
9
|
+
*/
|
|
10
|
+
export declare function clearResponseTimeout(response: Response): void;
|
|
11
|
+
export declare const makeRequest: (fetchFn: (url: string, init: RequestInit) => Promise<Response>, url: string, method: string, headers: Headers | Record<string, string>, requestBody: BodyInit | undefined, timeoutMs?: number, abortSignal?: AbortSignal, withCredentials?: boolean, duplex?: "half", disableCache?: boolean, keepTimeoutUntilBodyRead?: boolean) => Promise<Response>;
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.makeRequest = void 0;
|
|
13
13
|
exports.isCacheNoStoreSupported = isCacheNoStoreSupported;
|
|
14
14
|
exports.resetCacheNoStoreSupported = resetCacheNoStoreSupported;
|
|
15
|
+
exports.clearResponseTimeout = clearResponseTimeout;
|
|
15
16
|
const signals_1 = require("./signals");
|
|
16
17
|
/**
|
|
17
18
|
* Cached result of checking whether the current runtime supports
|
|
@@ -38,23 +39,55 @@ function isCacheNoStoreSupported() {
|
|
|
38
39
|
function resetCacheNoStoreSupported() {
|
|
39
40
|
_cacheNoStoreSupported = undefined;
|
|
40
41
|
}
|
|
41
|
-
const
|
|
42
|
+
const responseTimeouts = new WeakMap();
|
|
43
|
+
/**
|
|
44
|
+
* Clears the timeout that `makeRequest` kept running (with `keepTimeoutUntilBodyRead`) so that it also
|
|
45
|
+
* covered reading the response body.
|
|
46
|
+
*/
|
|
47
|
+
function clearResponseTimeout(response) {
|
|
48
|
+
const timeoutId = responseTimeouts.get(response);
|
|
49
|
+
if (timeoutId != null) {
|
|
50
|
+
clearTimeout(timeoutId);
|
|
51
|
+
responseTimeouts.delete(response);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const makeRequest = (fetchFn, url, method, headers, requestBody, timeoutMs, abortSignal, withCredentials, duplex, disableCache, keepTimeoutUntilBodyRead) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
55
|
const signals = [];
|
|
43
56
|
let timeoutAbortId;
|
|
57
|
+
let timeoutSignal;
|
|
44
58
|
if (timeoutMs != null) {
|
|
45
59
|
const { signal, abortId } = (0, signals_1.getTimeoutSignal)(timeoutMs);
|
|
46
60
|
timeoutAbortId = abortId;
|
|
61
|
+
timeoutSignal = signal;
|
|
47
62
|
signals.push(signal);
|
|
48
63
|
}
|
|
49
64
|
if (abortSignal != null) {
|
|
50
65
|
signals.push(abortSignal);
|
|
51
66
|
}
|
|
52
67
|
const newSignals = (0, signals_1.anySignal)(signals);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
68
|
+
let response;
|
|
69
|
+
try {
|
|
70
|
+
response = yield fetchFn(url, Object.assign({ method: method, headers, body: requestBody, signal: newSignals, credentials: withCredentials ? "include" : undefined,
|
|
71
|
+
// @ts-ignore
|
|
72
|
+
duplex }, (disableCache && isCacheNoStoreSupported() ? { cache: "no-store" } : {})));
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (timeoutAbortId != null) {
|
|
76
|
+
clearTimeout(timeoutAbortId);
|
|
77
|
+
}
|
|
78
|
+
// Some runtimes (e.g. Node 18) reject with their own error instead of the abort reason.
|
|
79
|
+
if ((timeoutSignal === null || timeoutSignal === void 0 ? void 0 : timeoutSignal.aborted) && !(abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted)) {
|
|
80
|
+
throw signals_1.TIMEOUT;
|
|
81
|
+
}
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
56
84
|
if (timeoutAbortId != null) {
|
|
57
|
-
|
|
85
|
+
if (keepTimeoutUntilBodyRead) {
|
|
86
|
+
responseTimeouts.set(response, timeoutAbortId);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
clearTimeout(timeoutAbortId);
|
|
90
|
+
}
|
|
58
91
|
}
|
|
59
92
|
return response;
|
|
60
93
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function requestWithRetries(requestFn: () => Promise<Response>, maxRetries?: number): Promise<Response>;
|
|
1
|
+
export declare function requestWithRetries(requestFn: () => Promise<Response>, maxRetries?: number, abortSignal?: AbortSignal): Promise<Response>;
|
|
@@ -52,13 +52,34 @@ function getRetryDelayFromHeaders(response, retryAttempt) {
|
|
|
52
52
|
}
|
|
53
53
|
return addSymmetricJitter(Math.min(INITIAL_RETRY_DELAY * Math.pow(2, retryAttempt), MAX_RETRY_DELAY));
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Waits `ms` milliseconds, or rejects as soon as `abortSignal` aborts. The timer and
|
|
57
|
+
* the abort listener are always removed, so a cancelled wait never keeps the process alive.
|
|
58
|
+
*/
|
|
59
|
+
function sleep(ms, abortSignal) {
|
|
60
|
+
return new Promise((resolve, reject) => {
|
|
61
|
+
if (abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted) {
|
|
62
|
+
reject(abortSignal.reason);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const onAbort = () => {
|
|
66
|
+
clearTimeout(timeoutId);
|
|
67
|
+
reject(abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.reason);
|
|
68
|
+
};
|
|
69
|
+
const timeoutId = setTimeout(() => {
|
|
70
|
+
abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.removeEventListener("abort", onAbort);
|
|
71
|
+
resolve();
|
|
72
|
+
}, ms);
|
|
73
|
+
abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.addEventListener("abort", onAbort, { once: true });
|
|
74
|
+
});
|
|
75
|
+
}
|
|
55
76
|
function requestWithRetries(requestFn_1) {
|
|
56
|
-
return __awaiter(this, arguments, void 0, function* (requestFn, maxRetries = DEFAULT_MAX_RETRIES) {
|
|
77
|
+
return __awaiter(this, arguments, void 0, function* (requestFn, maxRetries = DEFAULT_MAX_RETRIES, abortSignal) {
|
|
57
78
|
let response = yield requestFn();
|
|
58
79
|
for (let i = 0; i < maxRetries; ++i) {
|
|
59
80
|
if (isRetryableStatusCode(response.status)) {
|
|
60
81
|
const delay = getRetryDelayFromHeaders(response, i);
|
|
61
|
-
yield
|
|
82
|
+
yield sleep(delay, abortSignal);
|
|
62
83
|
response = yield requestFn();
|
|
63
84
|
}
|
|
64
85
|
else {
|
package/core/fetcher/signals.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TIMEOUT = void 0;
|
|
3
4
|
exports.getTimeoutSignal = getTimeoutSignal;
|
|
4
5
|
exports.anySignal = anySignal;
|
|
5
|
-
|
|
6
|
+
exports.TIMEOUT = "timeout";
|
|
6
7
|
function getTimeoutSignal(timeoutMs) {
|
|
7
8
|
const controller = new AbortController();
|
|
8
|
-
const abortId = setTimeout(() => controller.abort(TIMEOUT), timeoutMs);
|
|
9
|
+
const abortId = setTimeout(() => controller.abort(exports.TIMEOUT), timeoutMs);
|
|
9
10
|
return { signal: controller.signal, abortId };
|
|
10
11
|
}
|
|
11
12
|
function anySignal(...args) {
|
package/core/stream/Stream.d.ts
CHANGED
|
@@ -38,6 +38,8 @@ export declare namespace Stream {
|
|
|
38
38
|
type: "sse";
|
|
39
39
|
streamTerminator?: string;
|
|
40
40
|
eventDiscriminator?: string;
|
|
41
|
+
/** Event names whose union variant wraps the `data:` payload as `{ <eventDiscriminator>, data }`. */
|
|
42
|
+
envelopeEvents?: string[];
|
|
41
43
|
resumable?: boolean;
|
|
42
44
|
}
|
|
43
45
|
}
|
|
@@ -58,6 +60,7 @@ export declare class Stream<T> implements AsyncIterable<T> {
|
|
|
58
60
|
private messageTerminator;
|
|
59
61
|
private streamTerminator;
|
|
60
62
|
private eventDiscriminator;
|
|
63
|
+
private envelopeEvents;
|
|
61
64
|
private resumable;
|
|
62
65
|
private reconnectionEnabled;
|
|
63
66
|
private maxReconnectionAttempts;
|
package/core/stream/Stream.js
CHANGED
|
@@ -56,6 +56,7 @@ class Stream {
|
|
|
56
56
|
this.messageTerminator = "\n";
|
|
57
57
|
this.streamTerminator = eventShape.streamTerminator;
|
|
58
58
|
this.eventDiscriminator = eventShape.eventDiscriminator;
|
|
59
|
+
this.envelopeEvents = eventShape.envelopeEvents != null ? new Set(eventShape.envelopeEvents) : undefined;
|
|
59
60
|
this.resumable = (_a = eventShape.resumable) !== null && _a !== void 0 ? _a : false;
|
|
60
61
|
}
|
|
61
62
|
else {
|
|
@@ -415,9 +416,13 @@ class Stream {
|
|
|
415
416
|
};
|
|
416
417
|
}
|
|
417
418
|
injectDiscriminator(parsed, eventType) {
|
|
419
|
+
var _a;
|
|
418
420
|
if (this.eventDiscriminator == null || eventType == null) {
|
|
419
421
|
return parsed;
|
|
420
422
|
}
|
|
423
|
+
if ((_a = this.envelopeEvents) === null || _a === void 0 ? void 0 : _a.has(eventType)) {
|
|
424
|
+
return { [this.eventDiscriminator]: eventType, data: parsed };
|
|
425
|
+
}
|
|
421
426
|
if (parsed == null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
422
427
|
return parsed;
|
|
423
428
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.encodePathParam = encodePathParam;
|
|
4
|
-
function encodePathParam(param) {
|
|
4
|
+
function encodePathParam(param, InvalidPathParameterError) {
|
|
5
5
|
if (param === null) {
|
|
6
6
|
return "null";
|
|
7
7
|
}
|
|
@@ -17,5 +17,11 @@ function encodePathParam(param) {
|
|
|
17
17
|
param = String(param);
|
|
18
18
|
break;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
const encoded = encodeURIComponent(param);
|
|
21
|
+
// "." and ".." are dot segments: URL resolution would remove them and send the request to a different path.
|
|
22
|
+
if (encoded === "." || encoded === "..") {
|
|
23
|
+
const message = `Invalid path parameter "${encoded}": "." and ".." are not allowed because they change the request path.`;
|
|
24
|
+
throw InvalidPathParameterError != null ? new InvalidPathParameterError({ message }) : new Error(message);
|
|
25
|
+
}
|
|
26
|
+
return encoded;
|
|
21
27
|
}
|
package/core/websocket/ws.d.ts
CHANGED
|
@@ -23,8 +23,9 @@ export declare namespace ReconnectingWebSocket {
|
|
|
23
23
|
startClosed?: boolean;
|
|
24
24
|
debug?: boolean;
|
|
25
25
|
/**
|
|
26
|
-
* Decides whether a close event should trigger a reconnect. Return `false` to treat the close as terminal.
|
|
27
|
-
* Not consulted when `close()` was called or the abort signal fired.
|
|
26
|
+
* Decides whether a server close event should trigger a reconnect. Return `false` to treat the close as terminal.
|
|
27
|
+
* Not consulted for internal closes, when `close()` was called, or when the abort signal fired.
|
|
28
|
+
* Defaults to `event.code !== 1000`.
|
|
28
29
|
*/
|
|
29
30
|
shouldReconnect?: (event: Events.CloseEvent) => boolean;
|
|
30
31
|
};
|
|
@@ -48,6 +49,7 @@ export declare class ReconnectingWebSocket {
|
|
|
48
49
|
private _binaryType;
|
|
49
50
|
private _closeCalled;
|
|
50
51
|
private _messageQueue;
|
|
52
|
+
private _openWaiters;
|
|
51
53
|
private readonly _url;
|
|
52
54
|
private readonly _protocols?;
|
|
53
55
|
private readonly _options;
|
|
@@ -130,6 +132,15 @@ export declare class ReconnectingWebSocket {
|
|
|
130
132
|
* Register an event handler of a specific event type
|
|
131
133
|
*/
|
|
132
134
|
addEventListener<T extends keyof Events.WebSocketEventListenerMap>(type: T, listener: Events.WebSocketEventListenerMap[T]): void;
|
|
135
|
+
/**
|
|
136
|
+
* Resolves once the connection is open. Rejects on an error event, or once the connection is closed and no
|
|
137
|
+
* connection attempt or reconnect is pending (for example after close(), an abort, or a terminal close).
|
|
138
|
+
*/
|
|
139
|
+
waitForOpen(): Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* Returns whether the given listener is registered for the event type
|
|
142
|
+
*/
|
|
143
|
+
hasEventListener<T extends keyof Events.WebSocketEventListenerMap>(type: T, listener: Events.WebSocketEventListenerMap[T]): boolean;
|
|
133
144
|
dispatchEvent(event: Event): boolean;
|
|
134
145
|
/**
|
|
135
146
|
* Removes an event listener
|
|
@@ -141,6 +152,8 @@ export declare class ReconnectingWebSocket {
|
|
|
141
152
|
private _getNextUrl;
|
|
142
153
|
private _connect;
|
|
143
154
|
private _handleAbort;
|
|
155
|
+
private _willNotOpen;
|
|
156
|
+
private _notifyOpenWaiters;
|
|
144
157
|
private _handleTimeout;
|
|
145
158
|
private _disconnect;
|
|
146
159
|
private _acceptOpen;
|
|
@@ -149,6 +162,7 @@ export declare class ReconnectingWebSocket {
|
|
|
149
162
|
private _handleMessage;
|
|
150
163
|
private _handleError;
|
|
151
164
|
private _handleClose;
|
|
165
|
+
private _emitClose;
|
|
152
166
|
private _isReconnectableClose;
|
|
153
167
|
private _removeListeners;
|
|
154
168
|
private _addListeners;
|
package/core/websocket/ws.js
CHANGED
|
@@ -80,6 +80,7 @@ class ReconnectingWebSocket {
|
|
|
80
80
|
this._binaryType = "blob";
|
|
81
81
|
this._closeCalled = false;
|
|
82
82
|
this._messageQueue = [];
|
|
83
|
+
this._openWaiters = new Set();
|
|
83
84
|
this.CONNECTING = ReconnectingWebSocket.CONNECTING;
|
|
84
85
|
this.OPEN = ReconnectingWebSocket.OPEN;
|
|
85
86
|
this.CLOSING = ReconnectingWebSocket.CLOSING;
|
|
@@ -109,17 +110,20 @@ class ReconnectingWebSocket {
|
|
|
109
110
|
this._shouldReconnect = false;
|
|
110
111
|
this._closeCalled = true;
|
|
111
112
|
this._clearTimeouts();
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
113
|
+
this._notifyOpenWaiters();
|
|
114
|
+
if (!this._ws) {
|
|
115
|
+
this._emitClose(new Events.CloseEvent(1000, "aborted", this));
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
this._removeListeners();
|
|
119
|
+
// Absorb async errors emitted by ws when closing during CONNECTING state
|
|
120
|
+
this._ws.addEventListener("error", () => { });
|
|
121
|
+
try {
|
|
122
|
+
this._ws.close(1000, "aborted");
|
|
123
|
+
this._emitClose(new Events.CloseEvent(1000, "aborted", this));
|
|
124
|
+
}
|
|
125
|
+
catch (_error) {
|
|
126
|
+
// ignore
|
|
123
127
|
}
|
|
124
128
|
};
|
|
125
129
|
this._handleOpen = (event) => {
|
|
@@ -162,10 +166,7 @@ class ReconnectingWebSocket {
|
|
|
162
166
|
if (this._shouldReconnect) {
|
|
163
167
|
this._connect();
|
|
164
168
|
}
|
|
165
|
-
|
|
166
|
-
this.onclose(event);
|
|
167
|
-
}
|
|
168
|
-
this._listeners.close.forEach((listener) => this._callEventListener(event, listener));
|
|
169
|
+
this._emitClose(event);
|
|
169
170
|
};
|
|
170
171
|
this._url = url;
|
|
171
172
|
this._protocols = protocols;
|
|
@@ -236,12 +237,14 @@ class ReconnectingWebSocket {
|
|
|
236
237
|
* The current state of the connection; this is one of the Ready state constants
|
|
237
238
|
*/
|
|
238
239
|
get readyState() {
|
|
240
|
+
var _a;
|
|
239
241
|
if (this._ws) {
|
|
240
242
|
return this._ws.readyState;
|
|
241
243
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
244
|
+
if (this._options.startClosed || this._closeCalled || ((_a = this._abortSignal) === null || _a === void 0 ? void 0 : _a.aborted)) {
|
|
245
|
+
return ReconnectingWebSocket.ReadyState.CLOSED;
|
|
246
|
+
}
|
|
247
|
+
return ReconnectingWebSocket.ReadyState.CONNECTING;
|
|
245
248
|
}
|
|
246
249
|
/**
|
|
247
250
|
* The URL as resolved by the constructor
|
|
@@ -257,6 +260,7 @@ class ReconnectingWebSocket {
|
|
|
257
260
|
this._closeCalled = true;
|
|
258
261
|
this._shouldReconnect = false;
|
|
259
262
|
this._clearTimeouts();
|
|
263
|
+
this._notifyOpenWaiters();
|
|
260
264
|
if (!this._ws) {
|
|
261
265
|
this._debug("close enqueued: no ws instance");
|
|
262
266
|
return;
|
|
@@ -308,6 +312,58 @@ class ReconnectingWebSocket {
|
|
|
308
312
|
this._listeners[type].push(listener);
|
|
309
313
|
}
|
|
310
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* Resolves once the connection is open. Rejects on an error event, or once the connection is closed and no
|
|
317
|
+
* connection attempt or reconnect is pending (for example after close(), an abort, or a terminal close).
|
|
318
|
+
*/
|
|
319
|
+
waitForOpen() {
|
|
320
|
+
if (this.readyState === ReconnectingWebSocket.ReadyState.OPEN) {
|
|
321
|
+
return Promise.resolve();
|
|
322
|
+
}
|
|
323
|
+
if (this._willNotOpen()) {
|
|
324
|
+
return Promise.reject(new Error("WebSocket closed before the connection was opened"));
|
|
325
|
+
}
|
|
326
|
+
return new Promise((resolve, reject) => {
|
|
327
|
+
const cleanup = () => {
|
|
328
|
+
this._openWaiters.delete(check);
|
|
329
|
+
this.removeEventListener("open", onOpen);
|
|
330
|
+
this.removeEventListener("error", onError);
|
|
331
|
+
this.removeEventListener("close", check);
|
|
332
|
+
};
|
|
333
|
+
const onOpen = () => {
|
|
334
|
+
cleanup();
|
|
335
|
+
resolve();
|
|
336
|
+
};
|
|
337
|
+
const onError = (event) => {
|
|
338
|
+
cleanup();
|
|
339
|
+
reject(event);
|
|
340
|
+
};
|
|
341
|
+
// Deferred so that a reconnect or error triggered by the same close is accounted for first
|
|
342
|
+
const check = () => {
|
|
343
|
+
Promise.resolve().then(() => {
|
|
344
|
+
if (this._openWaiters.has(check) && this._willNotOpen()) {
|
|
345
|
+
cleanup();
|
|
346
|
+
reject(new Error("WebSocket closed before the connection was opened"));
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
};
|
|
350
|
+
this._openWaiters.add(check);
|
|
351
|
+
this.addEventListener("open", onOpen);
|
|
352
|
+
this.addEventListener("error", onError);
|
|
353
|
+
this.addEventListener("close", check);
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Returns whether the given listener is registered for the event type
|
|
358
|
+
*/
|
|
359
|
+
hasEventListener(type, listener) {
|
|
360
|
+
const listeners = this._listeners[type];
|
|
361
|
+
if (!listeners) {
|
|
362
|
+
return false;
|
|
363
|
+
}
|
|
364
|
+
// @ts-ignore
|
|
365
|
+
return listeners.some((l) => l === listener);
|
|
366
|
+
}
|
|
311
367
|
dispatchEvent(event) {
|
|
312
368
|
const listeners = this._listeners[event.type];
|
|
313
369
|
if (listeners) {
|
|
@@ -378,12 +434,12 @@ class ReconnectingWebSocket {
|
|
|
378
434
|
this._debug("connect aborted");
|
|
379
435
|
return;
|
|
380
436
|
}
|
|
381
|
-
this._connectLock = true;
|
|
382
437
|
const { maxRetries = DEFAULT_OPTIONS.maxRetries, connectionTimeout = DEFAULT_OPTIONS.connectionTimeout, WebSocket = getGlobalWebSocket(), } = this._options;
|
|
383
438
|
if (this._retryCount >= maxRetries) {
|
|
384
439
|
this._debug("max retries reached", this._retryCount, ">=", maxRetries);
|
|
385
440
|
return;
|
|
386
441
|
}
|
|
442
|
+
this._connectLock = true;
|
|
387
443
|
this._retryCount++;
|
|
388
444
|
this._debug("connect", this._retryCount);
|
|
389
445
|
this._removeListeners();
|
|
@@ -413,8 +469,36 @@ class ReconnectingWebSocket {
|
|
|
413
469
|
this._connectLock = false;
|
|
414
470
|
this._addListeners();
|
|
415
471
|
this._connectTimeout = setTimeout(() => this._handleTimeout(), connectionTimeout);
|
|
472
|
+
})
|
|
473
|
+
.catch((error) => {
|
|
474
|
+
this._debug("connect failed", error);
|
|
475
|
+
this._connectLock = false;
|
|
476
|
+
const event = new Events.ErrorEvent(error instanceof Error ? error : new Error(String(error)), this);
|
|
477
|
+
if (this.onerror) {
|
|
478
|
+
this.onerror(event);
|
|
479
|
+
}
|
|
480
|
+
this._listeners.error.forEach((listener) => this._callEventListener(event, listener));
|
|
481
|
+
this._connect();
|
|
416
482
|
});
|
|
417
483
|
}
|
|
484
|
+
_willNotOpen() {
|
|
485
|
+
var _a;
|
|
486
|
+
if (this._closeCalled || ((_a = this._abortSignal) === null || _a === void 0 ? void 0 : _a.aborted)) {
|
|
487
|
+
return true;
|
|
488
|
+
}
|
|
489
|
+
if (this._connectLock) {
|
|
490
|
+
return false;
|
|
491
|
+
}
|
|
492
|
+
if (!this._ws) {
|
|
493
|
+
return true;
|
|
494
|
+
}
|
|
495
|
+
return this._ws.readyState === ReconnectingWebSocket.ReadyState.CLOSED;
|
|
496
|
+
}
|
|
497
|
+
_notifyOpenWaiters() {
|
|
498
|
+
for (const waiter of [...this._openWaiters]) {
|
|
499
|
+
waiter();
|
|
500
|
+
}
|
|
501
|
+
}
|
|
418
502
|
_handleTimeout() {
|
|
419
503
|
this._debug("timeout event");
|
|
420
504
|
this._handleError(new Events.ErrorEvent(Error("TIMEOUT"), this));
|
|
@@ -429,7 +513,7 @@ class ReconnectingWebSocket {
|
|
|
429
513
|
this._ws.addEventListener("error", () => { });
|
|
430
514
|
try {
|
|
431
515
|
this._ws.close(code, reason);
|
|
432
|
-
this.
|
|
516
|
+
this._emitClose(new Events.CloseEvent(code, reason, this));
|
|
433
517
|
}
|
|
434
518
|
catch (_error) {
|
|
435
519
|
// ignore
|
|
@@ -449,6 +533,12 @@ class ReconnectingWebSocket {
|
|
|
449
533
|
listener(event);
|
|
450
534
|
}
|
|
451
535
|
}
|
|
536
|
+
_emitClose(event) {
|
|
537
|
+
if (this.onclose) {
|
|
538
|
+
this.onclose(event);
|
|
539
|
+
}
|
|
540
|
+
this._listeners.close.forEach((listener) => this._callEventListener(event, listener));
|
|
541
|
+
}
|
|
452
542
|
_isReconnectableClose(event) {
|
|
453
543
|
const { shouldReconnect = DEFAULT_OPTIONS.shouldReconnect } = this._options;
|
|
454
544
|
try {
|
package/errors/MavenAGIError.js
CHANGED
|
@@ -19,8 +19,22 @@ class MavenAGIError extends Error {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
get requestId() {
|
|
22
|
-
var _a
|
|
23
|
-
|
|
22
|
+
var _a;
|
|
23
|
+
const headers = (_a = this.rawResponse) === null || _a === void 0 ? void 0 : _a.headers;
|
|
24
|
+
if (headers == null) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const requestId = headers.get("X-Request-Id");
|
|
28
|
+
if (requestId != null) {
|
|
29
|
+
return requestId;
|
|
30
|
+
}
|
|
31
|
+
let fallback;
|
|
32
|
+
headers.forEach((value, name) => {
|
|
33
|
+
if (fallback === undefined && /request[-_]?id$/i.test(name)) {
|
|
34
|
+
fallback = value;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return fallback;
|
|
24
38
|
}
|
|
25
39
|
}
|
|
26
40
|
exports.MavenAGIError = MavenAGIError;
|