nyxlink 0.1.0-dev.3 → 5.3.0-rc.2
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/NOTICE.md +39 -0
- package/README.md +159 -215
- package/dist/index.d.ts +72 -3
- package/dist/index.js +66 -3
- package/dist/index.js.map +1 -1
- package/dist/src/Util.d.ts +13 -5
- package/dist/src/Util.js +153 -76
- package/dist/src/Util.js.map +1 -1
- package/dist/src/autoplay/AutoPlayManager.js +19 -9
- package/dist/src/autoplay/AutoPlayManager.js.map +1 -1
- package/dist/src/autoplay/RecommendationDiscovery.d.ts +27 -0
- package/dist/src/autoplay/RecommendationDiscovery.js +67 -0
- package/dist/src/autoplay/RecommendationDiscovery.js.map +1 -0
- package/dist/src/autoplay/RecommendationPreference.d.ts +15 -0
- package/dist/src/autoplay/RecommendationPreference.js +31 -0
- package/dist/src/autoplay/RecommendationPreference.js.map +1 -0
- package/dist/src/autoplay/RecommendationResolver.js +129 -91
- package/dist/src/autoplay/RecommendationResolver.js.map +1 -1
- package/dist/src/backends/BackendAdapter.d.ts +16 -3
- package/dist/src/backends/BackendAdapter.js +27 -9
- package/dist/src/backends/BackendAdapter.js.map +1 -1
- package/dist/src/backends/BackendDetector.js +36 -8
- package/dist/src/backends/BackendDetector.js.map +1 -1
- package/dist/src/backends/BackendInventory.d.ts +16 -0
- package/dist/src/backends/BackendInventory.js +3 -0
- package/dist/src/backends/BackendInventory.js.map +1 -0
- package/dist/src/backends/CapabilityRegistry.d.ts +17 -0
- package/dist/src/backends/CapabilityRegistry.js +39 -0
- package/dist/src/backends/CapabilityRegistry.js.map +1 -0
- package/dist/src/backends/ClientPCMSeek.d.ts +5 -0
- package/dist/src/backends/ClientPCMSeek.js +46 -0
- package/dist/src/backends/ClientPCMSeek.js.map +1 -0
- package/dist/src/backends/ExtensionRoutes.d.ts +202 -0
- package/dist/src/backends/ExtensionRoutes.js +57 -0
- package/dist/src/backends/ExtensionRoutes.js.map +1 -0
- package/dist/src/backends/HoloTrackMetadata.d.ts +24 -0
- package/dist/src/backends/HoloTrackMetadata.js +50 -0
- package/dist/src/backends/HoloTrackMetadata.js.map +1 -0
- package/dist/src/backends/LavaDSPXContracts.d.ts +27 -0
- package/dist/src/backends/LavaDSPXContracts.js +54 -0
- package/dist/src/backends/LavaDSPXContracts.js.map +1 -0
- package/dist/src/backends/LavaLyricsContracts.d.ts +21 -0
- package/dist/src/backends/LavaLyricsContracts.js +45 -0
- package/dist/src/backends/LavaLyricsContracts.js.map +1 -0
- package/dist/src/backends/LavaSearchContracts.d.ts +33 -0
- package/dist/src/backends/LavaSearchContracts.js +67 -0
- package/dist/src/backends/LavaSearchContracts.js.map +1 -0
- package/dist/src/backends/LavaSrcMetadata.d.ts +18 -0
- package/dist/src/backends/LavaSrcMetadata.js +38 -0
- package/dist/src/backends/LavaSrcMetadata.js.map +1 -0
- package/dist/src/backends/LavalinkAdapter.d.ts +2 -1
- package/dist/src/backends/LavalinkAdapter.js +3 -0
- package/dist/src/backends/LavalinkAdapter.js.map +1 -1
- package/dist/src/backends/LavalinkSponsorBlockContracts.d.ts +8 -0
- package/dist/src/backends/LavalinkSponsorBlockContracts.js +41 -0
- package/dist/src/backends/LavalinkSponsorBlockContracts.js.map +1 -0
- package/dist/src/backends/NodeLinkAdapter.d.ts +2 -1
- package/dist/src/backends/NodeLinkAdapter.js +3 -0
- package/dist/src/backends/NodeLinkAdapter.js.map +1 -1
- package/dist/src/backends/NodeLinkContracts.d.ts +99 -0
- package/dist/src/backends/NodeLinkContracts.js +146 -0
- package/dist/src/backends/NodeLinkContracts.js.map +1 -0
- package/dist/src/backends/NodeLinkMixContracts.d.ts +34 -0
- package/dist/src/backends/NodeLinkMixContracts.js +51 -0
- package/dist/src/backends/NodeLinkMixContracts.js.map +1 -0
- package/dist/src/backends/NodeLinkOrchestration.d.ts +69 -0
- package/dist/src/backends/NodeLinkOrchestration.js +123 -0
- package/dist/src/backends/NodeLinkOrchestration.js.map +1 -0
- package/dist/src/backends/NodeLinkSearchContracts.d.ts +9 -0
- package/dist/src/backends/NodeLinkSearchContracts.js +25 -0
- package/dist/src/backends/NodeLinkSearchContracts.js.map +1 -0
- package/dist/src/backends/NodeLinkStreamResponse.d.ts +1 -0
- package/dist/src/backends/NodeLinkStreamResponse.js +32 -0
- package/dist/src/backends/NodeLinkStreamResponse.js.map +1 -0
- package/dist/src/backends/ProtocolContracts.d.ts +56 -0
- package/dist/src/backends/ProtocolContracts.js +31 -0
- package/dist/src/backends/ProtocolContracts.js.map +1 -0
- package/dist/src/backends/ProtocolValidation.d.ts +13 -0
- package/dist/src/backends/ProtocolValidation.js +119 -0
- package/dist/src/backends/ProtocolValidation.js.map +1 -0
- package/dist/src/backends/SessionPath.d.ts +3 -0
- package/dist/src/backends/SessionPath.js +19 -0
- package/dist/src/backends/SessionPath.js.map +1 -0
- package/dist/src/backends/SponsorBlockEvents.d.ts +31 -0
- package/dist/src/backends/SponsorBlockEvents.js +56 -0
- package/dist/src/backends/SponsorBlockEvents.js.map +1 -0
- package/dist/src/cluster/GuildOwnership.d.ts +30 -0
- package/dist/src/cluster/GuildOwnership.js +190 -0
- package/dist/src/cluster/GuildOwnership.js.map +1 -0
- package/dist/src/cluster/RedisGuildIpcRouter.d.ts +34 -0
- package/dist/src/cluster/RedisGuildIpcRouter.js +150 -0
- package/dist/src/cluster/RedisGuildIpcRouter.js.map +1 -0
- package/dist/src/connectors/Connector.d.ts +3 -1
- package/dist/src/connectors/Connector.js +7 -1
- package/dist/src/connectors/Connector.js.map +1 -1
- package/dist/src/core/Manager.d.ts +26 -8
- package/dist/src/core/Manager.js +91 -23
- package/dist/src/core/Manager.js.map +1 -1
- package/dist/src/database/Local.d.ts +6 -2
- package/dist/src/database/Local.js +49 -14
- package/dist/src/database/Local.js.map +1 -1
- package/dist/src/database/Memory.d.ts +4 -0
- package/dist/src/database/Memory.js +17 -3
- package/dist/src/database/Memory.js.map +1 -1
- package/dist/src/database/PlayerSnapshot.d.ts +35 -0
- package/dist/src/database/PlayerSnapshot.js +176 -0
- package/dist/src/database/PlayerSnapshot.js.map +1 -0
- package/dist/src/database/RedisGuildLeaseCoordinator.d.ts +30 -0
- package/dist/src/database/RedisGuildLeaseCoordinator.js +134 -0
- package/dist/src/database/RedisGuildLeaseCoordinator.js.map +1 -0
- package/dist/src/database/RedisPlayerFence.d.ts +15 -0
- package/dist/src/database/RedisPlayerFence.js +44 -0
- package/dist/src/database/RedisPlayerFence.js.map +1 -0
- package/dist/src/database/RedisStorage.d.ts +32 -0
- package/dist/src/database/RedisStorage.js +209 -0
- package/dist/src/database/RedisStorage.js.map +1 -0
- package/dist/src/database/StorageAdapter.d.ts +1 -0
- package/dist/src/entities/Filters.d.ts +10 -2
- package/dist/src/entities/Filters.js +118 -59
- package/dist/src/entities/Filters.js.map +1 -1
- package/dist/src/entities/Node.d.ts +60 -6
- package/dist/src/entities/Node.js +511 -291
- package/dist/src/entities/Node.js.map +1 -1
- package/dist/src/entities/Player.d.ts +29 -7
- package/dist/src/entities/Player.js +527 -222
- package/dist/src/entities/Player.js.map +1 -1
- package/dist/src/entities/Queue.d.ts +1 -0
- package/dist/src/entities/Queue.js +76 -25
- package/dist/src/entities/Queue.js.map +1 -1
- package/dist/src/entities/Rest.d.ts +48 -8
- package/dist/src/entities/Rest.js +482 -112
- package/dist/src/entities/Rest.js.map +1 -1
- package/dist/src/entities/Track.d.ts +19 -12
- package/dist/src/entities/Track.js +44 -22
- package/dist/src/entities/Track.js.map +1 -1
- package/dist/src/entities/Voice.js +13 -6
- package/dist/src/entities/Voice.js.map +1 -1
- package/dist/src/entities/VoicePacketHandler.js +2 -2
- package/dist/src/entities/VoicePacketHandler.js.map +1 -1
- package/dist/src/entities/VoiceReceiver.d.ts +5 -0
- package/dist/src/entities/VoiceReceiver.js +117 -13
- package/dist/src/entities/VoiceReceiver.js.map +1 -1
- package/dist/src/entities/YouTubeLiveChat.d.ts +1 -0
- package/dist/src/entities/YouTubeLiveChat.js +53 -8
- package/dist/src/entities/YouTubeLiveChat.js.map +1 -1
- package/dist/src/errors/FeatureUnavailableError.d.ts +2 -2
- package/dist/src/errors/FeatureUnavailableError.js +1 -1
- package/dist/src/errors/FeatureUnavailableError.js.map +1 -1
- package/dist/src/errors/HttpError.d.ts +2 -2
- package/dist/src/errors/HttpPolicyError.d.ts +6 -0
- package/dist/src/errors/HttpPolicyError.js +14 -0
- package/dist/src/errors/HttpPolicyError.js.map +1 -0
- package/dist/src/errors/PlayerOperationCancelledError.d.ts +5 -0
- package/dist/src/errors/PlayerOperationCancelledError.js +14 -0
- package/dist/src/errors/PlayerOperationCancelledError.js.map +1 -0
- package/dist/src/extensions/ExtensionHost.d.ts +33 -0
- package/dist/src/extensions/ExtensionHost.js +156 -0
- package/dist/src/extensions/ExtensionHost.js.map +1 -0
- package/dist/src/http/RequestPolicy.d.ts +6 -0
- package/dist/src/http/RequestPolicy.js +52 -0
- package/dist/src/http/RequestPolicy.js.map +1 -0
- package/dist/src/logging/AuroraBootstrap.d.ts +22 -0
- package/dist/src/logging/AuroraBootstrap.js +89 -0
- package/dist/src/logging/AuroraBootstrap.js.map +1 -0
- package/dist/src/logging/AuroraDiagnostics.d.ts +56 -0
- package/dist/src/logging/AuroraDiagnostics.js +152 -0
- package/dist/src/logging/AuroraDiagnostics.js.map +1 -0
- package/dist/src/logging/AuroraEvents.d.ts +423 -0
- package/dist/src/logging/AuroraEvents.js +305 -0
- package/dist/src/logging/AuroraEvents.js.map +1 -0
- package/dist/src/logging/AuroraInspector.d.ts +55 -0
- package/dist/src/logging/AuroraInspector.js +117 -0
- package/dist/src/logging/AuroraInspector.js.map +1 -0
- package/dist/src/logging/AuroraPresentation.d.ts +35 -0
- package/dist/src/logging/AuroraPresentation.js +108 -0
- package/dist/src/logging/AuroraPresentation.js.map +1 -0
- package/dist/src/logging/ErrorDiagnostics.d.ts +11 -0
- package/dist/src/logging/ErrorDiagnostics.js +32 -0
- package/dist/src/logging/ErrorDiagnostics.js.map +1 -0
- package/dist/src/logging/LogFormatter.d.ts +1 -0
- package/dist/src/logging/LogFormatter.js +70 -20
- package/dist/src/logging/LogFormatter.js.map +1 -1
- package/dist/src/logging/LogLevels.d.ts +0 -2
- package/dist/src/logging/LogLevels.js +1 -9
- package/dist/src/logging/LogLevels.js.map +1 -1
- package/dist/src/logging/ManagerLogRoute.d.ts +4 -0
- package/dist/src/logging/ManagerLogRoute.js +18 -0
- package/dist/src/logging/ManagerLogRoute.js.map +1 -0
- package/dist/src/logging/ObservedFields.d.ts +1 -0
- package/dist/src/logging/ObservedFields.js +16 -0
- package/dist/src/logging/ObservedFields.js.map +1 -0
- package/dist/src/logging/PinoEngine.d.ts +13 -0
- package/dist/src/logging/PinoEngine.js +38 -0
- package/dist/src/logging/PinoEngine.js.map +1 -0
- package/dist/src/logging/SafeDiagnostics.d.ts +3 -0
- package/dist/src/logging/SafeDiagnostics.js +71 -0
- package/dist/src/logging/SafeDiagnostics.js.map +1 -0
- package/dist/src/logging/TerminalCoordinator.d.ts +64 -0
- package/dist/src/logging/TerminalCoordinator.js +237 -0
- package/dist/src/logging/TerminalCoordinator.js.map +1 -0
- package/dist/src/logging/index.d.ts +4 -6
- package/dist/src/logging/index.js +5 -8
- package/dist/src/logging/index.js.map +1 -1
- package/dist/src/managers/DatabaseManager.d.ts +10 -0
- package/dist/src/managers/DatabaseManager.js +192 -1
- package/dist/src/managers/DatabaseManager.js.map +1 -1
- package/dist/src/managers/NodeManager.d.ts +13 -8
- package/dist/src/managers/NodeManager.js +116 -22
- package/dist/src/managers/NodeManager.js.map +1 -1
- package/dist/src/managers/PlayerManager.d.ts +3 -0
- package/dist/src/managers/PlayerManager.js +30 -2
- package/dist/src/managers/PlayerManager.js.map +1 -1
- package/dist/src/nodes/NodeCircuitBreaker.js +10 -2
- package/dist/src/nodes/NodeCircuitBreaker.js.map +1 -1
- package/dist/src/nodes/NodeFailover.js +38 -10
- package/dist/src/nodes/NodeFailover.js.map +1 -1
- package/dist/src/nodes/NodeHealthMonitor.js +1 -1
- package/dist/src/nodes/NodeHealthMonitor.js.map +1 -1
- package/dist/src/nodes/NodeScoring.d.ts +4 -0
- package/dist/src/nodes/NodeScoring.js +52 -0
- package/dist/src/nodes/NodeScoring.js.map +1 -0
- package/dist/src/nodes/NodeSelector.d.ts +6 -0
- package/dist/src/nodes/NodeSelector.js +43 -3
- package/dist/src/nodes/NodeSelector.js.map +1 -1
- package/dist/src/nodes/SessionRecovery.js +38 -12
- package/dist/src/nodes/SessionRecovery.js.map +1 -1
- package/dist/src/nodes/SourceHealthMonitor.d.ts +16 -0
- package/dist/src/nodes/SourceHealthMonitor.js +47 -0
- package/dist/src/nodes/SourceHealthMonitor.js.map +1 -0
- package/dist/src/observability/OpenTelemetry.d.ts +64 -0
- package/dist/src/observability/OpenTelemetry.js +183 -0
- package/dist/src/observability/OpenTelemetry.js.map +1 -0
- package/dist/src/observability/PerformanceMonitor.d.ts +69 -0
- package/dist/src/observability/PerformanceMonitor.js +164 -0
- package/dist/src/observability/PerformanceMonitor.js.map +1 -0
- package/dist/src/observability/PrivateMetricsServer.d.ts +47 -0
- package/dist/src/observability/PrivateMetricsServer.js +221 -0
- package/dist/src/observability/PrivateMetricsServer.js.map +1 -0
- package/dist/src/observability/TerminalDashboard.d.ts +60 -0
- package/dist/src/observability/TerminalDashboard.js +111 -0
- package/dist/src/observability/TerminalDashboard.js.map +1 -0
- package/dist/src/players/AdvancedAudioRecovery.d.ts +18 -0
- package/dist/src/players/AdvancedAudioRecovery.js +38 -0
- package/dist/src/players/AdvancedAudioRecovery.js.map +1 -0
- package/dist/src/players/MixRecovery.d.ts +24 -0
- package/dist/src/players/MixRecovery.js +89 -0
- package/dist/src/players/MixRecovery.js.map +1 -0
- package/dist/src/players/PlaybackAttempt.d.ts +2 -1
- package/dist/src/players/PlaybackAttempt.js +1 -0
- package/dist/src/players/PlaybackAttempt.js.map +1 -1
- package/dist/src/players/PlaybackGuard.d.ts +4 -0
- package/dist/src/players/PlaybackGuard.js +15 -2
- package/dist/src/players/PlaybackGuard.js.map +1 -1
- package/dist/src/players/PlayerCommandQueue.d.ts +2 -0
- package/dist/src/players/PlayerCommandQueue.js +4 -1
- package/dist/src/players/PlayerCommandQueue.js.map +1 -1
- package/dist/src/players/PlayerMigration.d.ts +11 -0
- package/dist/src/players/PlayerMigration.js +111 -22
- package/dist/src/players/PlayerMigration.js.map +1 -1
- package/dist/src/players/QueuePreload.d.ts +10 -0
- package/dist/src/players/QueuePreload.js +46 -0
- package/dist/src/players/QueuePreload.js.map +1 -0
- package/dist/src/players/VoiceRecovery.d.ts +7 -0
- package/dist/src/players/VoiceRecovery.js +56 -0
- package/dist/src/players/VoiceRecovery.js.map +1 -0
- package/dist/src/search/SearchService.d.ts +6 -2
- package/dist/src/search/SearchService.js +91 -44
- package/dist/src/search/SearchService.js.map +1 -1
- package/dist/src/search/SharedSearchRequests.d.ts +6 -0
- package/dist/src/search/SharedSearchRequests.js +61 -0
- package/dist/src/search/SharedSearchRequests.js.map +1 -0
- package/dist/src/search/SourceRouting.d.ts +4 -0
- package/dist/src/search/SourceRouting.js +36 -0
- package/dist/src/search/SourceRouting.js.map +1 -0
- package/dist/src/services/WebSocket.d.ts +3 -0
- package/dist/src/services/WebSocket.js +75 -48
- package/dist/src/services/WebSocket.js.map +1 -1
- package/dist/src/sources/deezer.d.ts +2 -0
- package/dist/src/sources/deezer.js +35 -22
- package/dist/src/sources/deezer.js.map +1 -1
- package/dist/src/sources/spotify.d.ts +2 -0
- package/dist/src/sources/spotify.js +27 -18
- package/dist/src/sources/spotify.js.map +1 -1
- package/dist/src/structures/SearchResult.d.ts +6 -3
- package/dist/src/structures/SearchResult.js +13 -4
- package/dist/src/structures/SearchResult.js.map +1 -1
- package/dist/src/tracks/AbortableLookup.d.ts +1 -0
- package/dist/src/tracks/AbortableLookup.js +14 -0
- package/dist/src/tracks/AbortableLookup.js.map +1 -0
- package/dist/src/tracks/MetadataTrackResolver.d.ts +11 -0
- package/dist/src/tracks/MetadataTrackResolver.js +90 -0
- package/dist/src/tracks/MetadataTrackResolver.js.map +1 -0
- package/dist/src/tracks/TrackCodec.js +1 -1
- package/dist/src/tracks/TrackCodec.js.map +1 -1
- package/dist/src/tracks/TrackResolver.d.ts +1 -1
- package/dist/src/tracks/TrackResolver.js +75 -27
- package/dist/src/tracks/TrackResolver.js.map +1 -1
- package/dist/src/typings/Interfaces.d.ts +23 -6
- package/examples/aurora-bootstrap.d.mts +2 -0
- package/examples/aurora-bootstrap.mjs +77 -0
- package/examples/aurora-demo.mjs +63 -0
- package/examples/aurora-diagnostics.d.mts +5 -0
- package/examples/aurora-diagnostics.mjs +73 -0
- package/examples/aurora-file.d.mts +2 -0
- package/examples/aurora-file.mjs +55 -0
- package/examples/aurora-inspector.d.mts +7 -0
- package/examples/aurora-inspector.mjs +173 -0
- package/examples/aurora-otel.d.mts +4 -0
- package/examples/aurora-otel.mjs +4 -0
- package/examples/aurora-pipeline.d.mts +22 -0
- package/examples/aurora-pipeline.mjs +91 -0
- package/examples/aurora-sdk.cjs +73 -0
- package/examples/aurora-sdk.d.cts +2 -0
- package/examples/aurora-terminal-tools.mjs +44 -0
- package/examples/aurora-visual.mjs +55 -0
- package/package.json +109 -7
- package/dist/src/logging/ConsoleReporter.d.ts +0 -8
- package/dist/src/logging/ConsoleReporter.js +0 -25
- package/dist/src/logging/ConsoleReporter.js.map +0 -1
- package/dist/src/logging/Logger.d.ts +0 -37
- package/dist/src/logging/Logger.js +0 -122
- package/dist/src/logging/Logger.js.map +0 -1
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Rest = exports.RestError = void 0;
|
|
4
|
+
const SessionPath_1 = require("../backends/SessionPath");
|
|
5
|
+
const NodeLinkSearchContracts_1 = require("../backends/NodeLinkSearchContracts");
|
|
6
|
+
const LavaSearchContracts_1 = require("../backends/LavaSearchContracts");
|
|
7
|
+
const OpenTelemetry_1 = require("../observability/OpenTelemetry");
|
|
8
|
+
const ManagerLogRoute_1 = require("../logging/ManagerLogRoute");
|
|
9
|
+
const NodeLinkOrchestration_1 = require("../backends/NodeLinkOrchestration");
|
|
10
|
+
const NodeLinkContracts_1 = require("../backends/NodeLinkContracts");
|
|
11
|
+
const LavaLyricsContracts_1 = require("../backends/LavaLyricsContracts");
|
|
12
|
+
const LavalinkSponsorBlockContracts_1 = require("../backends/LavalinkSponsorBlockContracts");
|
|
13
|
+
const ProtocolValidation_1 = require("../backends/ProtocolValidation");
|
|
4
14
|
const HttpError_1 = require("../errors/HttpError");
|
|
15
|
+
const ExtensionRoutes_1 = require("../backends/ExtensionRoutes");
|
|
16
|
+
const ProtocolContracts_1 = require("../backends/ProtocolContracts");
|
|
5
17
|
const FeatureUnavailableError_1 = require("../errors/FeatureUnavailableError");
|
|
6
18
|
const Util_1 = require("../Util");
|
|
7
19
|
const PlaybackGuard_1 = require("../players/PlaybackGuard");
|
|
20
|
+
const NodeLinkStreamResponse_1 = require("../backends/NodeLinkStreamResponse");
|
|
21
|
+
const ClientPCMSeek_1 = require("../backends/ClientPCMSeek");
|
|
22
|
+
const NodeLinkMixContracts_1 = require("../backends/NodeLinkMixContracts");
|
|
8
23
|
class RestError extends Error {
|
|
9
24
|
statusCode;
|
|
10
25
|
isSessionExpired;
|
|
@@ -21,34 +36,77 @@ class Rest {
|
|
|
21
36
|
authHeaders;
|
|
22
37
|
jsonHeaders;
|
|
23
38
|
userAgentHeaders;
|
|
24
|
-
|
|
39
|
+
sessionRecoveries = new WeakSet();
|
|
40
|
+
request;
|
|
41
|
+
streamRequest;
|
|
25
42
|
constructor(node) {
|
|
26
43
|
this.node = node;
|
|
44
|
+
this.request = this.observeTransport(Util_1.makeRequest, 'REST.http');
|
|
45
|
+
this.streamRequest = this.observeTransport(Util_1.makeStreamRequest, 'REST.stream.open');
|
|
27
46
|
this.authHeaders = {
|
|
28
47
|
"Authorization": this.node.password,
|
|
29
|
-
"User-Agent": this.node.manager.options?.userAgent
|
|
48
|
+
"User-Agent": this.node.manager.options?.userAgent ?? "NyxLink"
|
|
30
49
|
};
|
|
31
50
|
this.jsonHeaders = {
|
|
32
51
|
...this.authHeaders,
|
|
33
52
|
"Content-Type": "application/json"
|
|
34
53
|
};
|
|
35
54
|
this.userAgentHeaders = {
|
|
36
|
-
"User-Agent": this.node.manager.options?.userAgent
|
|
55
|
+
"User-Agent": this.node.manager.options?.userAgent ?? "NyxLink"
|
|
37
56
|
};
|
|
38
57
|
}
|
|
39
58
|
get url() {
|
|
40
59
|
return `http${this.node.secure ? "s" : ""}://${this.node.host}:${this.node.port}`;
|
|
41
60
|
}
|
|
61
|
+
observeTransport(transport, operation) {
|
|
62
|
+
return new Proxy(transport, { apply: (target, receiver, args) => {
|
|
63
|
+
const monitor = this.node.manager.performanceMonitor;
|
|
64
|
+
const execute = () => monitor ? monitor.measure(operation === 'REST.http' ? 'rest' : 'streamOpen', () => Reflect.apply(target, receiver, args)) : Reflect.apply(target, receiver, args);
|
|
65
|
+
const run = () => (0, OpenTelemetry_1.observeOperation)(this.node.manager, 'nyxlink.rest', async () => {
|
|
66
|
+
const aurora = (0, ManagerLogRoute_1.getManagerLogRoute)(this.node.manager);
|
|
67
|
+
return aurora ? aurora.observe(operation === 'REST.http' ? 'rest' : 'stream', async () => execute(), { backend: this.node.backend?.kind }, result => {
|
|
68
|
+
if (operation === 'REST.http' && typeof result === 'object' && result !== null && result.loadType === 'error') {
|
|
69
|
+
try {
|
|
70
|
+
if (new URL(args[0]).pathname === '/v4/loadtracks')
|
|
71
|
+
return 'failed';
|
|
72
|
+
}
|
|
73
|
+
catch { }
|
|
74
|
+
}
|
|
75
|
+
return 'completed';
|
|
76
|
+
}) : execute();
|
|
77
|
+
}, result => {
|
|
78
|
+
if (result == null)
|
|
79
|
+
return 'empty';
|
|
80
|
+
let pathname = '';
|
|
81
|
+
try {
|
|
82
|
+
pathname = new URL(args[0]).pathname;
|
|
83
|
+
}
|
|
84
|
+
catch { }
|
|
85
|
+
if (pathname === '/v4/loadtracks' && typeof result === 'object') {
|
|
86
|
+
const type = result.loadType;
|
|
87
|
+
if (type === 'error' || type === 'empty')
|
|
88
|
+
return type;
|
|
89
|
+
}
|
|
90
|
+
return 'resolved';
|
|
91
|
+
});
|
|
92
|
+
return run();
|
|
93
|
+
} });
|
|
94
|
+
}
|
|
42
95
|
async triggerPlayerRecovery(player) {
|
|
43
|
-
if (player.destroyed)
|
|
96
|
+
if (player.destroyed || this.node.destroyed || player.node !== this.node)
|
|
44
97
|
return;
|
|
45
98
|
player.stuckDetectionCount = 0;
|
|
46
99
|
player.silentDetectionCount = 0;
|
|
100
|
+
const guard = (0, PlaybackGuard_1.playbackGuard)(player);
|
|
101
|
+
let ticket = guard.ticket;
|
|
102
|
+
const active = () => !player.destroyed && !this.node.destroyed &&
|
|
103
|
+
player.node === this.node && this.node.manager.players.get(player.guildId) === player &&
|
|
104
|
+
guard.isCurrent(ticket);
|
|
47
105
|
try {
|
|
48
106
|
const recovering = player.softRestart("Session expired (404)");
|
|
49
|
-
|
|
107
|
+
ticket = guard.ticket;
|
|
50
108
|
const recovered = await recovering;
|
|
51
|
-
if (
|
|
109
|
+
if (!active())
|
|
52
110
|
return;
|
|
53
111
|
if (recovered) {
|
|
54
112
|
this.node.manager.emit("playerRecoverySuccess", player);
|
|
@@ -57,86 +115,228 @@ class Rest {
|
|
|
57
115
|
await player.destroy("Session expired and recovery failed");
|
|
58
116
|
}
|
|
59
117
|
}
|
|
60
|
-
catch (
|
|
61
|
-
|
|
62
|
-
|
|
118
|
+
catch (error) {
|
|
119
|
+
if (!active())
|
|
120
|
+
return;
|
|
121
|
+
this.node.manager.emit("debug", `NyxLink > Rest > Recovery error: ${error.message}`);
|
|
122
|
+
if (active())
|
|
123
|
+
await player.destroy("Session recovery error");
|
|
63
124
|
}
|
|
64
125
|
}
|
|
65
|
-
|
|
126
|
+
extensionRoute(operation, params = {}) {
|
|
127
|
+
const parameters = { ...params, sessionId: this.node.sessionId };
|
|
128
|
+
return this.node.backend ? this.node.backend.resolveExtension(operation, parameters)
|
|
129
|
+
: (0, ExtensionRoutes_1.resolveExtensionRoute)(this.node.isNodeLink ? 'nodelink' : 'unknown', operation, parameters);
|
|
130
|
+
}
|
|
131
|
+
async featureRequest(operation, params, options, validate) {
|
|
132
|
+
return this.runFeatureRequest(operation, params, options, validate);
|
|
133
|
+
}
|
|
134
|
+
async runFeatureRequest(operation, params, options, validate) {
|
|
135
|
+
const route = this.extensionRoute(operation, params);
|
|
136
|
+
if (params.guildId && route.method !== 'GET') {
|
|
137
|
+
await this.node.manager.guildOwnership?.assertCurrent(params.guildId);
|
|
138
|
+
}
|
|
139
|
+
const feature = route.feature;
|
|
66
140
|
this.node.assertFeature(feature);
|
|
141
|
+
if (route.transport !== 'json')
|
|
142
|
+
throw new TypeError('Extension requires stream transport');
|
|
143
|
+
const backend = this.node.backend;
|
|
144
|
+
const socket = this.node.socket;
|
|
145
|
+
const session = this.node.sessionId;
|
|
146
|
+
const current = () => !this.node.destroyed && this.node.backend === backend &&
|
|
147
|
+
this.node.socket === socket && this.node.sessionId === session;
|
|
67
148
|
const result = await this.node.circuit.run(async () => {
|
|
68
149
|
try {
|
|
69
|
-
return await (
|
|
150
|
+
return await this.request(this.url + route.path, { ...options, method: route.method, throwOnError: true }, 10000, 0);
|
|
70
151
|
}
|
|
71
152
|
catch (error) {
|
|
72
|
-
this.featureError(feature, error);
|
|
153
|
+
this.featureError(feature, error, backend, current);
|
|
73
154
|
}
|
|
74
155
|
});
|
|
75
|
-
|
|
156
|
+
if (result === undefined)
|
|
157
|
+
throw new Error('Backend did not acknowledge feature request');
|
|
158
|
+
validate?.(result);
|
|
159
|
+
if (current())
|
|
160
|
+
backend?.recordFeature(feature, 'available');
|
|
76
161
|
return result;
|
|
77
162
|
}
|
|
78
|
-
featureError(feature, error) {
|
|
163
|
+
featureError(feature, error, backend, current) {
|
|
79
164
|
const body = error instanceof HttpError_1.HttpError ? error.body : undefined;
|
|
80
165
|
const message = body && typeof body === 'object' && 'message' in body ? String(body.message) : '';
|
|
81
166
|
const unavailable = error instanceof HttpError_1.HttpError && (error.statusCode === 501 ||
|
|
82
167
|
[403, 404].includes(error.statusCode) && /requested route was not found|unknown (?:route|endpoint)|(?:endpoint|feature).*disabled/i.test(message));
|
|
83
168
|
if (unavailable) {
|
|
84
|
-
|
|
85
|
-
|
|
169
|
+
if (current())
|
|
170
|
+
backend?.recordFeature(feature, 'unavailable');
|
|
171
|
+
throw new FeatureUnavailableError_1.FeatureUnavailableError(feature, backend?.kind ?? 'unknown', error.statusCode);
|
|
86
172
|
}
|
|
87
173
|
throw error;
|
|
88
174
|
}
|
|
175
|
+
async getGroups() {
|
|
176
|
+
return this.featureRequest('groups:list', {}, { headers: this.authHeaders }, NodeLinkOrchestration_1.validateGroups);
|
|
177
|
+
}
|
|
178
|
+
async getGroup(groupId) {
|
|
179
|
+
(0, NodeLinkOrchestration_1.requireGroupId)(groupId);
|
|
180
|
+
return this.featureRequest('groups:get', { groupId }, { headers: this.authHeaders }, value => (0, NodeLinkOrchestration_1.validateGroup)(value, groupId));
|
|
181
|
+
}
|
|
182
|
+
async createGroup(options) {
|
|
183
|
+
const body = (0, NodeLinkOrchestration_1.groupCreateBody)(options);
|
|
184
|
+
return this.featureRequest('groups:create', {}, { headers: this.jsonHeaders, body }, value => (0, NodeLinkOrchestration_1.validateGroup)(value, body.id));
|
|
185
|
+
}
|
|
186
|
+
async updateGroup(groupId, options) {
|
|
187
|
+
(0, NodeLinkOrchestration_1.requireGroupId)(groupId);
|
|
188
|
+
return this.featureRequest('groups:update', { groupId }, { headers: this.jsonHeaders, body: (0, NodeLinkOrchestration_1.groupPatchBody)(options) }, value => (0, NodeLinkOrchestration_1.validateGroupPatch)(value, groupId));
|
|
189
|
+
}
|
|
190
|
+
async deleteGroup(groupId) {
|
|
191
|
+
(0, NodeLinkOrchestration_1.requireGroupId)(groupId);
|
|
192
|
+
await this.featureRequest('groups:delete', { groupId }, { headers: this.authHeaders });
|
|
193
|
+
}
|
|
194
|
+
async lavalinkSponsorBlockRequest(method, guildId, categories) {
|
|
195
|
+
if (method !== 'GET')
|
|
196
|
+
await this.node.manager.guildOwnership?.assertCurrent(guildId);
|
|
197
|
+
const path = (0, LavalinkSponsorBlockContracts_1.lavalinkSponsorBlockPath)(this.node.sessionId, guildId);
|
|
198
|
+
const body = method === 'PUT' ? (0, LavalinkSponsorBlockContracts_1.sponsorBlockCategoryBody)(categories) : undefined;
|
|
199
|
+
const backend = this.node.backend;
|
|
200
|
+
if (backend?.kind !== 'lavalink' || !(0, LavalinkSponsorBlockContracts_1.hasLavalinkSponsorBlockPlugin)(backend.plugins) ||
|
|
201
|
+
backend.featureStatus('lavalink:sponsorblock') === 'unavailable') {
|
|
202
|
+
throw new FeatureUnavailableError_1.FeatureUnavailableError('lavalink:sponsorblock', backend?.kind ?? 'unknown');
|
|
203
|
+
}
|
|
204
|
+
const socket = this.node.socket;
|
|
205
|
+
const session = this.node.sessionId;
|
|
206
|
+
const current = () => !this.node.destroyed && this.node.backend === backend &&
|
|
207
|
+
this.node.socket === socket && this.node.sessionId === session;
|
|
208
|
+
const result = await this.node.circuit.run(async () => {
|
|
209
|
+
try {
|
|
210
|
+
return await this.request(this.url + path, {
|
|
211
|
+
method, headers: method === 'PUT' ? this.jsonHeaders : this.authHeaders,
|
|
212
|
+
...(method === 'PUT' ? { body } : {}), throwOnError: true
|
|
213
|
+
}, 10000, 0);
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
this.featureError('lavalink:sponsorblock', error, backend, current);
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
if (method === 'GET')
|
|
220
|
+
(0, LavalinkSponsorBlockContracts_1.validateSponsorBlockCategories)(result);
|
|
221
|
+
if (result === undefined)
|
|
222
|
+
throw new ProtocolValidation_1.ProtocolResponseError('Lavalink SponsorBlock', 'response');
|
|
223
|
+
if (current())
|
|
224
|
+
backend.recordFeature('lavalink:sponsorblock', 'available');
|
|
225
|
+
return method === 'GET' ? [...result] : undefined;
|
|
226
|
+
}
|
|
227
|
+
getLavalinkSponsorBlockCategories(guildId) {
|
|
228
|
+
return this.lavalinkSponsorBlockRequest('GET', guildId);
|
|
229
|
+
}
|
|
230
|
+
async setLavalinkSponsorBlockCategories(guildId, categories) {
|
|
231
|
+
await this.lavalinkSponsorBlockRequest('PUT', guildId, categories);
|
|
232
|
+
}
|
|
233
|
+
async clearLavalinkSponsorBlockCategories(guildId) {
|
|
234
|
+
await this.lavalinkSponsorBlockRequest('DELETE', guildId);
|
|
235
|
+
}
|
|
236
|
+
async getSponsorBlock(guildId) {
|
|
237
|
+
(0, NodeLinkOrchestration_1.requireGuildId)(guildId);
|
|
238
|
+
return this.featureRequest('sponsorblock:get', { guildId }, { headers: this.authHeaders }, NodeLinkOrchestration_1.validateSponsorState);
|
|
239
|
+
}
|
|
240
|
+
async updateSponsorBlock(guildId, options) {
|
|
241
|
+
(0, NodeLinkOrchestration_1.requireGuildId)(guildId);
|
|
242
|
+
return this.featureRequest('sponsorblock:update', { guildId }, { headers: this.jsonHeaders, body: (0, NodeLinkOrchestration_1.sponsorOptionsBody)(options) }, NodeLinkOrchestration_1.validateSponsorState);
|
|
243
|
+
}
|
|
244
|
+
async setSponsorBlockSegments(guildId, segments) {
|
|
245
|
+
(0, NodeLinkOrchestration_1.requireGuildId)(guildId);
|
|
246
|
+
return this.featureRequest('sponsorblock:segments', { guildId }, { headers: this.jsonHeaders, body: (0, NodeLinkOrchestration_1.sponsorSegmentsBody)(segments) }, NodeLinkOrchestration_1.validateSponsorState);
|
|
247
|
+
}
|
|
248
|
+
async clearSponsorBlock(guildId) {
|
|
249
|
+
(0, NodeLinkOrchestration_1.requireGuildId)(guildId);
|
|
250
|
+
await this.featureRequest('sponsorblock:clear', { guildId }, { headers: this.authHeaders });
|
|
251
|
+
}
|
|
89
252
|
async getPlayers() {
|
|
90
|
-
const res = await
|
|
253
|
+
const res = await this.request(`${this.url}${(0, SessionPath_1.sessionPath)(this.node.sessionId)}/players`, {
|
|
91
254
|
method: "GET",
|
|
92
255
|
headers: this.authHeaders
|
|
93
256
|
});
|
|
94
|
-
|
|
257
|
+
if (res === undefined || res === null)
|
|
258
|
+
return null;
|
|
259
|
+
if (!Array.isArray(res))
|
|
260
|
+
throw new ProtocolValidation_1.ProtocolResponseError('get players', 'player array');
|
|
261
|
+
const players = [];
|
|
262
|
+
for (const row of res) {
|
|
263
|
+
(0, ProtocolValidation_1.validatePlayerRead)(row);
|
|
264
|
+
players.push(row);
|
|
265
|
+
}
|
|
266
|
+
return players;
|
|
95
267
|
}
|
|
96
268
|
async getPlayer(guildId) {
|
|
97
|
-
const res = await
|
|
269
|
+
const res = await this.request(`${this.url}${(0, SessionPath_1.playerPath)(this.node.sessionId, guildId)}`, {
|
|
98
270
|
method: "GET",
|
|
99
271
|
headers: this.authHeaders
|
|
100
272
|
});
|
|
101
|
-
|
|
273
|
+
if (res === undefined || res === null)
|
|
274
|
+
return null;
|
|
275
|
+
(0, ProtocolValidation_1.validatePlayerRead)(res, guildId);
|
|
276
|
+
return res;
|
|
102
277
|
}
|
|
103
278
|
async updatePlayer(guildId, data, noReplace = false) {
|
|
279
|
+
return this.updatePlayerRequest(guildId, data, noReplace);
|
|
280
|
+
}
|
|
281
|
+
async updatePlayerRequest(guildId, data, noReplace) {
|
|
282
|
+
(0, NodeLinkOrchestration_1.requireGuildId)(guildId);
|
|
283
|
+
const requestSession = this.node.sessionId;
|
|
284
|
+
const requestBackend = this.node.backend;
|
|
285
|
+
const requestSocket = this.node.socket;
|
|
286
|
+
(0, SessionPath_1.playerPath)(requestSession, guildId);
|
|
287
|
+
await this.node.manager.guildOwnership?.assertCurrent(guildId);
|
|
288
|
+
if (this.node.destroyed || this.node.sessionId !== requestSession ||
|
|
289
|
+
this.node.backend !== requestBackend || this.node.socket !== requestSocket)
|
|
290
|
+
throw new Error('Player update session changed');
|
|
291
|
+
const payload = this.node.backend ? this.node.backend.preparePlayerUpdate(data) : (0, ProtocolContracts_1.preparePlayerUpdate)(this.node.isNodeLink ? 'nodelink' : 'unknown', data);
|
|
104
292
|
const params = new URLSearchParams();
|
|
105
293
|
if (noReplace) {
|
|
106
294
|
params.append("noReplace", "true");
|
|
107
295
|
}
|
|
296
|
+
const owner = this.node.manager.players.get(guildId);
|
|
297
|
+
const intent = owner ? (0, PlaybackGuard_1.playbackGuard)(owner).ticket : undefined;
|
|
298
|
+
const session = this.node.sessionId;
|
|
108
299
|
try {
|
|
109
|
-
const res = await this.node.circuit.run(() =>
|
|
300
|
+
const res = await this.node.circuit.run(() => this.request(`${this.url}${(0, SessionPath_1.playerPath)(session, guildId)}?${params.toString()}`, {
|
|
110
301
|
method: "PATCH",
|
|
111
302
|
headers: this.jsonHeaders,
|
|
112
|
-
body:
|
|
303
|
+
body: payload,
|
|
113
304
|
throwOnError: true
|
|
114
305
|
}, undefined, 0));
|
|
115
|
-
|
|
306
|
+
if (this.node.destroyed || this.node.sessionId !== requestSession ||
|
|
307
|
+
this.node.backend !== requestBackend || this.node.socket !== requestSocket)
|
|
308
|
+
throw new Error('Player update session changed');
|
|
309
|
+
if (res === undefined || res === null)
|
|
310
|
+
return null;
|
|
311
|
+
(0, ProtocolValidation_1.validatePlayerAcknowledgement)(res, guildId);
|
|
312
|
+
return res;
|
|
116
313
|
}
|
|
117
314
|
catch (error) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
this.node.manager.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
.finally(() => { this.sessionRecoveryInProgress = false; });
|
|
128
|
-
}
|
|
129
|
-
}
|
|
315
|
+
if (error instanceof HttpError_1.HttpError && error.statusCode === 404 &&
|
|
316
|
+
owner && !owner.destroyed && !this.node.destroyed && owner.node === this.node &&
|
|
317
|
+
this.node.manager.players.get(guildId) === owner && this.node.sessionId === session &&
|
|
318
|
+
this.node.backend === requestBackend && this.node.socket === requestSocket &&
|
|
319
|
+
(0, PlaybackGuard_1.playbackGuard)(owner).isCurrent(intent) && !this.sessionRecoveries.has(owner)) {
|
|
320
|
+
this.sessionRecoveries.add(owner);
|
|
321
|
+
void this.triggerPlayerRecovery(owner)
|
|
322
|
+
.catch(error => this.node.manager.emit("debug", `NyxLink > Rest > Recovery failed: ${error.message}`))
|
|
323
|
+
.finally(() => { this.sessionRecoveries.delete(owner); });
|
|
130
324
|
}
|
|
131
325
|
throw error;
|
|
132
326
|
}
|
|
133
327
|
}
|
|
134
328
|
async destroyPlayer(guildId, options) {
|
|
329
|
+
(0, NodeLinkOrchestration_1.requireGuildId)(guildId);
|
|
330
|
+
const session = this.node.sessionId, backend = this.node.backend, socket = this.node.socket;
|
|
331
|
+
const path = (0, SessionPath_1.playerPath)(session, guildId);
|
|
332
|
+
await this.node.manager.guildOwnership?.assertCurrent(guildId);
|
|
333
|
+
if (this.node.sessionId !== session || this.node.backend !== backend || this.node.socket !== socket)
|
|
334
|
+
throw new Error('Player cleanup session changed');
|
|
135
335
|
const timeout = options?.timeoutMs ?? 10000;
|
|
136
336
|
if (options && (!Number.isFinite(timeout) || timeout <= 0 || timeout > 60000))
|
|
137
337
|
throw new TypeError('Cleanup timeout must be within 1..60000 ms');
|
|
138
338
|
try {
|
|
139
|
-
await
|
|
339
|
+
await this.request(`${this.url}${path}`, {
|
|
140
340
|
method: "DELETE",
|
|
141
341
|
headers: this.authHeaders,
|
|
142
342
|
signal: options?.signal,
|
|
@@ -144,50 +344,77 @@ class Rest {
|
|
|
144
344
|
}, options ? timeout : undefined, options ? 0 : undefined);
|
|
145
345
|
}
|
|
146
346
|
catch (error) {
|
|
147
|
-
|
|
148
|
-
if (!err.message.includes('status 404')) {
|
|
347
|
+
if (!(error instanceof HttpError_1.HttpError) || error.statusCode !== 404)
|
|
149
348
|
throw error;
|
|
150
|
-
}
|
|
151
349
|
}
|
|
152
350
|
}
|
|
351
|
+
async loadNodeLinkSearch(query, options = {}) {
|
|
352
|
+
const identifier = (0, NodeLinkSearchContracts_1.nodeLinkDiscoveryIdentifier)(query, options);
|
|
353
|
+
const backend = this.node.backend;
|
|
354
|
+
if (backend?.kind !== 'nodelink')
|
|
355
|
+
throw new FeatureUnavailableError_1.FeatureUnavailableError('nodelink:discovery', backend?.kind ?? 'unknown');
|
|
356
|
+
const session = this.node.sessionId;
|
|
357
|
+
const socket = this.node.socket;
|
|
358
|
+
options.signal?.throwIfAborted();
|
|
359
|
+
const result = await this.loadTracks(identifier, { timeoutMs: options.timeoutMs ?? 10000, signal: options.signal });
|
|
360
|
+
options.signal?.throwIfAborted();
|
|
361
|
+
if (this.node.destroyed || this.node.backend !== backend || this.node.sessionId !== session || this.node.socket !== socket) {
|
|
362
|
+
throw new Error('NodeLink discovery session changed');
|
|
363
|
+
}
|
|
364
|
+
return result;
|
|
365
|
+
}
|
|
153
366
|
async loadTracks(identifier, options) {
|
|
154
367
|
const params = new URLSearchParams();
|
|
155
368
|
params.append("identifier", identifier);
|
|
156
369
|
const protectedRequest = this.node.circuit.enabled;
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
370
|
+
return this.node.circuit.run(async () => {
|
|
371
|
+
const res = await this.request(`${this.url}/v4/loadtracks?${params}`, {
|
|
372
|
+
method: "GET",
|
|
373
|
+
headers: this.authHeaders,
|
|
374
|
+
throwOnError: protectedRequest || options !== undefined,
|
|
375
|
+
signal: options?.signal
|
|
376
|
+
}, options?.timeoutMs ?? 10000, protectedRequest || options ? 0 : 3);
|
|
377
|
+
if (res === undefined || res === null)
|
|
378
|
+
return { loadType: "empty", data: {} };
|
|
379
|
+
(0, ProtocolValidation_1.validateLoadResponse)(res);
|
|
380
|
+
return res;
|
|
381
|
+
});
|
|
164
382
|
}
|
|
165
383
|
async decodeTrack(encodedTrack) {
|
|
166
384
|
const params = new URLSearchParams();
|
|
167
385
|
params.append("encodedTrack", encodedTrack);
|
|
168
|
-
const res = await
|
|
386
|
+
const res = await this.request(`${this.url}/v4/decodetrack?${params}`, {
|
|
169
387
|
method: "GET",
|
|
170
388
|
headers: this.authHeaders
|
|
171
389
|
});
|
|
172
|
-
|
|
390
|
+
if (res === undefined || res === null)
|
|
391
|
+
return null;
|
|
392
|
+
(0, ProtocolValidation_1.validateTrackResponse)(res);
|
|
393
|
+
return res;
|
|
173
394
|
}
|
|
174
395
|
async decodeTracks(encodedTracks) {
|
|
175
|
-
const res = await
|
|
396
|
+
const res = await this.request(`${this.url}/v4/decodetracks`, {
|
|
176
397
|
method: "POST",
|
|
177
398
|
headers: this.jsonHeaders,
|
|
178
399
|
body: encodedTracks
|
|
179
400
|
});
|
|
180
|
-
|
|
401
|
+
if (res === undefined || res === null)
|
|
402
|
+
return null;
|
|
403
|
+
if (!Array.isArray(res))
|
|
404
|
+
throw new ProtocolValidation_1.ProtocolResponseError('decode tracks', 'track array');
|
|
405
|
+
for (const track of res)
|
|
406
|
+
(0, ProtocolValidation_1.validateTrackResponse)(track, 'decode tracks');
|
|
407
|
+
return res;
|
|
181
408
|
}
|
|
182
409
|
async getInfo() {
|
|
183
|
-
const res = await
|
|
410
|
+
const res = await this.request(`${this.url}/v4/info`, {
|
|
184
411
|
method: "GET",
|
|
185
412
|
headers: this.authHeaders
|
|
186
413
|
});
|
|
187
414
|
return res || null;
|
|
188
415
|
}
|
|
189
416
|
async getInfoWithHeaders() {
|
|
190
|
-
const res = await
|
|
417
|
+
const res = await this.request(`${this.url}/v4/info`, {
|
|
191
418
|
method: "GET",
|
|
192
419
|
headers: this.authHeaders,
|
|
193
420
|
returnHeaders: true,
|
|
@@ -196,7 +423,7 @@ class Rest {
|
|
|
196
423
|
return res || null;
|
|
197
424
|
}
|
|
198
425
|
async getVersion(timeout, retries) {
|
|
199
|
-
const res = await
|
|
426
|
+
const res = await this.request(`${this.url}/version`, {
|
|
200
427
|
method: "GET",
|
|
201
428
|
headers: this.authHeaders
|
|
202
429
|
}, timeout, retries);
|
|
@@ -205,7 +432,7 @@ class Rest {
|
|
|
205
432
|
async getStats() {
|
|
206
433
|
const protectedRequest = this.node.circuit.enabled;
|
|
207
434
|
const res = await this.node.circuit.run(async () => {
|
|
208
|
-
const stats = await
|
|
435
|
+
const stats = await this.request(`${this.url}/v4/stats`, {
|
|
209
436
|
method: "GET", headers: this.authHeaders, throwOnError: protectedRequest
|
|
210
437
|
}, protectedRequest ? 10000 : undefined, protectedRequest ? 0 : undefined);
|
|
211
438
|
if (protectedRequest) {
|
|
@@ -219,27 +446,27 @@ class Rest {
|
|
|
219
446
|
return res || null;
|
|
220
447
|
}
|
|
221
448
|
async getRoutePlannerStatus() {
|
|
222
|
-
const res = await
|
|
449
|
+
const res = await this.request(`${this.url}/v4/routeplanner/status`, {
|
|
223
450
|
method: "GET",
|
|
224
451
|
headers: this.authHeaders
|
|
225
452
|
});
|
|
226
453
|
return res || null;
|
|
227
454
|
}
|
|
228
455
|
async freeFailedAddress(address) {
|
|
229
|
-
await
|
|
456
|
+
await this.request(`${this.url}/v4/routeplanner/free/address`, {
|
|
230
457
|
method: "POST",
|
|
231
458
|
headers: this.jsonHeaders,
|
|
232
459
|
body: { address }
|
|
233
460
|
});
|
|
234
461
|
}
|
|
235
462
|
async freeAllFailedAddresses() {
|
|
236
|
-
await
|
|
463
|
+
await this.request(`${this.url}/v4/routeplanner/free/all`, {
|
|
237
464
|
method: "POST",
|
|
238
465
|
headers: this.authHeaders
|
|
239
466
|
});
|
|
240
467
|
}
|
|
241
468
|
async updateSession(resuming, timeout) {
|
|
242
|
-
const res = await
|
|
469
|
+
const res = await this.request(`${this.url}${(0, SessionPath_1.sessionPath)(this.node.sessionId)}`, {
|
|
243
470
|
method: "PATCH",
|
|
244
471
|
headers: this.jsonHeaders,
|
|
245
472
|
body: {
|
|
@@ -247,58 +474,126 @@ class Rest {
|
|
|
247
474
|
timeout
|
|
248
475
|
}
|
|
249
476
|
});
|
|
250
|
-
|
|
477
|
+
if (res === undefined || res === null)
|
|
478
|
+
return null;
|
|
479
|
+
(0, ProtocolValidation_1.validateSessionResponse)(res);
|
|
480
|
+
return res;
|
|
251
481
|
}
|
|
252
482
|
async addMixLayer(guildId, data) {
|
|
253
483
|
this.node.assertFeature("mix:add");
|
|
254
|
-
|
|
255
|
-
|
|
484
|
+
(0, NodeLinkOrchestration_1.requireGuildId)(guildId);
|
|
485
|
+
const body = (0, NodeLinkMixContracts_1.mixCreateBody)(data);
|
|
486
|
+
const res = await this.featureRequest("mix:add", { guildId }, {
|
|
256
487
|
headers: this.jsonHeaders,
|
|
257
|
-
body
|
|
258
|
-
});
|
|
259
|
-
return res
|
|
488
|
+
body
|
|
489
|
+
}, NodeLinkMixContracts_1.validateMixCreated);
|
|
490
|
+
return res == null ? null : res;
|
|
260
491
|
}
|
|
261
492
|
async getMixLayers(guildId) {
|
|
262
493
|
this.node.assertFeature("mix:list");
|
|
263
|
-
|
|
264
|
-
|
|
494
|
+
(0, NodeLinkOrchestration_1.requireGuildId)(guildId);
|
|
495
|
+
const res = await this.featureRequest("mix:list", { guildId }, {
|
|
265
496
|
headers: this.authHeaders
|
|
266
|
-
});
|
|
267
|
-
return res
|
|
497
|
+
}, NodeLinkMixContracts_1.validateMixLayers);
|
|
498
|
+
return res == null ? null : res;
|
|
268
499
|
}
|
|
269
500
|
async updateMixLayerVolume(guildId, mixId, volume) {
|
|
270
501
|
this.node.assertFeature("mix:update");
|
|
271
|
-
|
|
272
|
-
|
|
502
|
+
(0, NodeLinkOrchestration_1.requireGuildId)(guildId);
|
|
503
|
+
(0, NodeLinkMixContracts_1.requireMixId)(mixId);
|
|
504
|
+
(0, NodeLinkMixContracts_1.requireMixVolume)(volume);
|
|
505
|
+
await this.featureRequest("mix:update", { guildId, mixId }, {
|
|
273
506
|
headers: this.jsonHeaders,
|
|
274
507
|
body: { volume }
|
|
275
508
|
});
|
|
276
509
|
}
|
|
277
510
|
async removeMixLayer(guildId, mixId) {
|
|
278
511
|
this.node.assertFeature("mix:remove");
|
|
279
|
-
|
|
280
|
-
|
|
512
|
+
(0, NodeLinkOrchestration_1.requireGuildId)(guildId);
|
|
513
|
+
(0, NodeLinkMixContracts_1.requireMixId)(mixId);
|
|
514
|
+
await this.featureRequest("mix:remove", { guildId, mixId }, {
|
|
281
515
|
headers: this.authHeaders
|
|
282
516
|
});
|
|
283
517
|
}
|
|
284
|
-
async
|
|
518
|
+
async loadSearch(query, options = {}) {
|
|
519
|
+
const params = (0, LavaSearchContracts_1.lavaSearchParameters)(query, options);
|
|
520
|
+
const backend = this.node.backend;
|
|
521
|
+
if (backend?.kind !== 'lavalink' || !(0, LavaSearchContracts_1.hasLavaSearchPlugin)(backend.plugins) ||
|
|
522
|
+
backend.featureStatus('lavasearch') === 'unavailable') {
|
|
523
|
+
throw new FeatureUnavailableError_1.FeatureUnavailableError('lavasearch', backend?.kind ?? 'unknown');
|
|
524
|
+
}
|
|
525
|
+
const socket = this.node.socket;
|
|
526
|
+
const session = this.node.sessionId;
|
|
527
|
+
const current = () => !this.node.destroyed && this.node.backend === backend &&
|
|
528
|
+
this.node.socket === socket && this.node.sessionId === session;
|
|
529
|
+
options.signal?.throwIfAborted();
|
|
530
|
+
const result = await this.node.circuit.run(async () => {
|
|
531
|
+
try {
|
|
532
|
+
return await this.request(this.url + '/v4/loadsearch?' + params.toString(), {
|
|
533
|
+
method: 'GET', headers: this.authHeaders, throwOnError: true,
|
|
534
|
+
noContentAsNull: true, signal: options.signal
|
|
535
|
+
}, options.timeoutMs ?? 10000, 0);
|
|
536
|
+
}
|
|
537
|
+
catch (error) {
|
|
538
|
+
this.featureError('lavasearch', error, backend, current);
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
options.signal?.throwIfAborted();
|
|
542
|
+
if (!current())
|
|
543
|
+
throw new Error('LavaSearch backend session changed');
|
|
544
|
+
if (result !== null)
|
|
545
|
+
(0, LavaSearchContracts_1.validateLavaSearch)(result);
|
|
546
|
+
backend.recordFeature('lavasearch', 'available');
|
|
547
|
+
return result;
|
|
548
|
+
}
|
|
549
|
+
async getLavaLyrics(encodedTrack, options) {
|
|
550
|
+
const params = (0, LavaLyricsContracts_1.lavaLyricsParameters)(encodedTrack, options);
|
|
551
|
+
const backend = this.node.backend;
|
|
552
|
+
if (backend?.kind !== 'lavalink' || !(0, LavaLyricsContracts_1.hasLavaLyricsPlugin)(backend.plugins) ||
|
|
553
|
+
backend.featureStatus('lavalyrics') === 'unavailable') {
|
|
554
|
+
throw new FeatureUnavailableError_1.FeatureUnavailableError('lavalyrics', backend?.kind ?? 'unknown');
|
|
555
|
+
}
|
|
556
|
+
const socket = this.node.socket;
|
|
557
|
+
const session = this.node.sessionId;
|
|
558
|
+
const current = () => !this.node.destroyed && this.node.backend === backend &&
|
|
559
|
+
this.node.socket === socket && this.node.sessionId === session;
|
|
560
|
+
const result = await this.node.circuit.run(async () => {
|
|
561
|
+
try {
|
|
562
|
+
return await this.request(this.url + '/v4/lyrics?' + params.toString(), {
|
|
563
|
+
method: 'GET', headers: this.authHeaders, throwOnError: true,
|
|
564
|
+
noContentAsNull: true
|
|
565
|
+
}, 10000, 0);
|
|
566
|
+
}
|
|
567
|
+
catch (error) {
|
|
568
|
+
this.featureError('lavalyrics', error, backend, current);
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
if (result === null) {
|
|
572
|
+
if (current())
|
|
573
|
+
backend.recordFeature('lavalyrics', 'available');
|
|
574
|
+
return null;
|
|
575
|
+
}
|
|
576
|
+
(0, LavaLyricsContracts_1.validateLavaLyrics)(result);
|
|
577
|
+
if (current())
|
|
578
|
+
backend.recordFeature('lavalyrics', 'available');
|
|
579
|
+
return result;
|
|
580
|
+
}
|
|
581
|
+
async loadLyrics(encodedTrack, options) {
|
|
285
582
|
this.node.assertFeature("lyrics");
|
|
286
|
-
const params =
|
|
287
|
-
|
|
288
|
-
if (lang)
|
|
289
|
-
params.append("lang", lang);
|
|
290
|
-
const res = await this.featureRequest("lyrics", `${this.url}/v4/loadlyrics?${params}`, {
|
|
291
|
-
method: "GET",
|
|
583
|
+
const params = (0, NodeLinkContracts_1.lyricsParameters)(encodedTrack, options);
|
|
584
|
+
const res = await this.featureRequest("lyrics", { query: params }, {
|
|
292
585
|
headers: this.authHeaders
|
|
293
586
|
});
|
|
294
587
|
return res ? (0, Util_1.normalizeNodeLinkResponse)(res, res.loadType) : null;
|
|
295
588
|
}
|
|
589
|
+
async getSourceHealth() {
|
|
590
|
+
return this.featureRequest('source-health', {}, { headers: this.authHeaders }, NodeLinkContracts_1.validateSourceHealth);
|
|
591
|
+
}
|
|
296
592
|
async loadChapters(encodedTrack) {
|
|
297
593
|
this.node.assertFeature("chapters");
|
|
298
594
|
const params = new URLSearchParams();
|
|
299
595
|
params.append("encodedTrack", encodedTrack);
|
|
300
|
-
const res = await this.featureRequest("chapters",
|
|
301
|
-
method: "GET",
|
|
596
|
+
const res = await this.featureRequest("chapters", { query: params }, {
|
|
302
597
|
headers: this.authHeaders
|
|
303
598
|
});
|
|
304
599
|
return res ? (0, Util_1.normalizeNodeLinkResponse)(res, "chapters") : null;
|
|
@@ -309,40 +604,35 @@ class Rest {
|
|
|
309
604
|
params.append("encodedTrack", encodedTrack);
|
|
310
605
|
if (lang)
|
|
311
606
|
params.append("lang", lang);
|
|
312
|
-
const res = await this.featureRequest("meaning",
|
|
313
|
-
method: "GET",
|
|
607
|
+
const res = await this.featureRequest("meaning", { query: params }, {
|
|
314
608
|
headers: this.authHeaders
|
|
315
609
|
});
|
|
316
610
|
return res ? (0, Util_1.normalizeNodeLinkResponse)(res, res.loadType) : null;
|
|
317
611
|
}
|
|
318
612
|
async getConnectionStatus() {
|
|
319
613
|
this.node.assertFeature("connection");
|
|
320
|
-
const res = await this.featureRequest("connection",
|
|
321
|
-
method: "GET",
|
|
614
|
+
const res = await this.featureRequest("connection", {}, {
|
|
322
615
|
headers: this.authHeaders
|
|
323
616
|
});
|
|
324
617
|
return res ? (0, Util_1.normalizeNodeLinkResponse)(res, "connection") : null;
|
|
325
618
|
}
|
|
326
619
|
async getMetrics() {
|
|
327
620
|
this.node.assertFeature("metrics");
|
|
328
|
-
const res = await this.featureRequest("metrics",
|
|
329
|
-
method: "GET",
|
|
621
|
+
const res = await this.featureRequest("metrics", {}, {
|
|
330
622
|
headers: this.authHeaders
|
|
331
623
|
});
|
|
332
624
|
return res || null;
|
|
333
625
|
}
|
|
334
626
|
async getWorkers() {
|
|
335
627
|
this.node.assertFeature("workers:get");
|
|
336
|
-
const res = await this.featureRequest("workers:get",
|
|
337
|
-
method: "GET",
|
|
628
|
+
const res = await this.featureRequest("workers:get", {}, {
|
|
338
629
|
headers: this.authHeaders
|
|
339
630
|
});
|
|
340
631
|
return res ? (0, Util_1.normalizeNodeLinkResponse)(res, "workers") : null;
|
|
341
632
|
}
|
|
342
633
|
async patchWorker(payload) {
|
|
343
634
|
this.node.assertFeature("workers:patch");
|
|
344
|
-
const res = await this.featureRequest("workers:patch",
|
|
345
|
-
method: "PATCH",
|
|
635
|
+
const res = await this.featureRequest("workers:patch", {}, {
|
|
346
636
|
headers: this.jsonHeaders,
|
|
347
637
|
body: payload
|
|
348
638
|
});
|
|
@@ -353,16 +643,14 @@ class Rest {
|
|
|
353
643
|
const params = new URLSearchParams();
|
|
354
644
|
if (validate)
|
|
355
645
|
params.append("validate", "true");
|
|
356
|
-
const res = await this.featureRequest("youtube:config",
|
|
357
|
-
method: "GET",
|
|
646
|
+
const res = await this.featureRequest("youtube:config:get", { query: params }, {
|
|
358
647
|
headers: this.authHeaders
|
|
359
648
|
});
|
|
360
649
|
return res || null;
|
|
361
650
|
}
|
|
362
651
|
async updateYoutubeConfig(payload) {
|
|
363
652
|
this.node.assertFeature("youtube:config");
|
|
364
|
-
const res = await this.featureRequest("youtube:config",
|
|
365
|
-
method: "PATCH",
|
|
653
|
+
const res = await this.featureRequest("youtube:config:update", {}, {
|
|
366
654
|
headers: this.jsonHeaders,
|
|
367
655
|
body: payload
|
|
368
656
|
});
|
|
@@ -372,8 +660,7 @@ class Rest {
|
|
|
372
660
|
this.node.assertFeature("youtube:oauth");
|
|
373
661
|
const params = new URLSearchParams();
|
|
374
662
|
params.append("refreshToken", refreshToken);
|
|
375
|
-
const res = await this.featureRequest("youtube:oauth",
|
|
376
|
-
method: "GET",
|
|
663
|
+
const res = await this.featureRequest("youtube:oauth", { query: params }, {
|
|
377
664
|
headers: this.authHeaders
|
|
378
665
|
});
|
|
379
666
|
return res || null;
|
|
@@ -382,16 +669,14 @@ class Rest {
|
|
|
382
669
|
this.node.assertFeature("encodetrack");
|
|
383
670
|
const params = new URLSearchParams();
|
|
384
671
|
params.append("track", track);
|
|
385
|
-
const res = await this.featureRequest("encodetrack",
|
|
386
|
-
method: "GET",
|
|
672
|
+
const res = await this.featureRequest("encodetrack", { query: params }, {
|
|
387
673
|
headers: this.authHeaders
|
|
388
674
|
});
|
|
389
675
|
return res || null;
|
|
390
676
|
}
|
|
391
677
|
async encodeTracksRemote(tracks) {
|
|
392
678
|
this.node.assertFeature("encodedtracks");
|
|
393
|
-
const res = await this.featureRequest("encodedtracks",
|
|
394
|
-
method: "POST",
|
|
679
|
+
const res = await this.featureRequest("encodedtracks", {}, {
|
|
395
680
|
headers: this.jsonHeaders,
|
|
396
681
|
body: tracks
|
|
397
682
|
});
|
|
@@ -404,23 +689,110 @@ class Rest {
|
|
|
404
689
|
if (itag !== undefined && itag !== null) {
|
|
405
690
|
params.append("itag", String(itag));
|
|
406
691
|
}
|
|
407
|
-
const res = await this.featureRequest("trackstream",
|
|
408
|
-
method: "GET",
|
|
692
|
+
const res = await this.featureRequest("trackstream", { query: params }, {
|
|
409
693
|
headers: this.authHeaders
|
|
410
694
|
});
|
|
411
695
|
return res || null;
|
|
412
696
|
}
|
|
697
|
+
async getStreamFormats(encodedTrack, options = {}) {
|
|
698
|
+
this.node.assertFeature('loadstream');
|
|
699
|
+
if (typeof encodedTrack !== 'string' || !encodedTrack.trim())
|
|
700
|
+
throw new TypeError('Stream formats require an encoded track');
|
|
701
|
+
if (options.itag !== undefined && (!Number.isSafeInteger(options.itag) || options.itag <= 0))
|
|
702
|
+
throw new TypeError('itag must be a positive integer');
|
|
703
|
+
if (options.timeoutMs !== undefined && (!Number.isSafeInteger(options.timeoutMs) || options.timeoutMs < 1 || options.timeoutMs > 30000))
|
|
704
|
+
throw new RangeError('Invalid stream formats timeout');
|
|
705
|
+
const route = this.extensionRoute('loadstream');
|
|
706
|
+
const backend = this.node.backend;
|
|
707
|
+
const socket = this.node.socket;
|
|
708
|
+
const session = this.node.sessionId;
|
|
709
|
+
const current = () => !this.node.destroyed && this.node.backend === backend &&
|
|
710
|
+
this.node.socket === socket && this.node.sessionId === session;
|
|
711
|
+
try {
|
|
712
|
+
const response = await this.request(this.url + route.path, {
|
|
713
|
+
method: route.method, headers: this.jsonHeaders,
|
|
714
|
+
body: { encodedTrack, format: 'formats', ...(options.itag !== undefined ? { itag: options.itag } : {}) },
|
|
715
|
+
signal: options.signal, throwOnError: true,
|
|
716
|
+
}, options.timeoutMs ?? 10000, 0);
|
|
717
|
+
(0, NodeLinkContracts_1.validateNodeLinkStreamFormats)(response);
|
|
718
|
+
if (current())
|
|
719
|
+
backend?.recordFeature('loadstream', 'available');
|
|
720
|
+
return response;
|
|
721
|
+
}
|
|
722
|
+
catch (error) {
|
|
723
|
+
this.featureError('loadstream', error, backend, current);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
413
726
|
async loadStream(payload, options = {}) {
|
|
414
727
|
this.node.assertFeature('loadstream');
|
|
728
|
+
if (!payload || typeof payload !== 'object' || typeof payload.encodedTrack !== 'string' || !payload.encodedTrack.trim()) {
|
|
729
|
+
throw new TypeError('LoadStream requires an encoded track');
|
|
730
|
+
}
|
|
731
|
+
if (payload.format !== undefined && !['raw', 'pcm', 'wav', 'passthrough', 'original', 'source'].includes(payload.format)) {
|
|
732
|
+
throw new TypeError('LoadStream format must be raw, wav or passthrough (formats JSON uses getStreamFormats)');
|
|
733
|
+
}
|
|
734
|
+
const passthrough = ['passthrough', 'original', 'source'].includes(payload.format ?? '');
|
|
735
|
+
if (payload.itag !== undefined && (!passthrough || !Number.isSafeInteger(payload.itag) || payload.itag <= 0)) {
|
|
736
|
+
throw new TypeError('itag is only valid for passthrough and must be positive');
|
|
737
|
+
}
|
|
738
|
+
if (options.range !== undefined && (!passthrough ||
|
|
739
|
+
!/^bytes=(?:\d+-\d*|-\d+)$/.test(options.range) || options.range.length > 64)) {
|
|
740
|
+
throw new TypeError('HTTP Range requires passthrough and a valid single byte range');
|
|
741
|
+
}
|
|
742
|
+
if (payload.volume !== undefined && (!Number.isFinite(payload.volume) || payload.volume < 0 || payload.volume > 1000) ||
|
|
743
|
+
payload.position !== undefined && (!Number.isFinite(payload.position) || payload.position < 0) ||
|
|
744
|
+
payload.filters !== undefined && (!payload.filters || typeof payload.filters !== 'object' || Array.isArray(payload.filters))) {
|
|
745
|
+
throw new TypeError('Invalid LoadStream playback options');
|
|
746
|
+
}
|
|
747
|
+
if (options.seekMode !== undefined && !['server', 'pcm-trim'].includes(options.seekMode)) {
|
|
748
|
+
throw new TypeError('LoadStream seekMode must be server or pcm-trim');
|
|
749
|
+
}
|
|
750
|
+
const clientTrim = options.seekMode === 'pcm-trim';
|
|
751
|
+
if (clientTrim) {
|
|
752
|
+
if (payload.format !== undefined && !['raw', 'pcm'].includes(payload.format))
|
|
753
|
+
throw new TypeError('Client PCM seeking supports raw/pcm only; original bytes cannot be trimmed as PCM');
|
|
754
|
+
(0, ClientPCMSeek_1.assertClientPcmSeekPosition)(payload.position ?? 0);
|
|
755
|
+
}
|
|
756
|
+
const requestPayload = clientTrim
|
|
757
|
+
? { ...payload, position: 0, format: 'raw' }
|
|
758
|
+
: payload.format === 'pcm' ? { ...payload, format: 'raw' }
|
|
759
|
+
: passthrough ? { ...payload, format: 'passthrough' } : payload;
|
|
760
|
+
const route = this.extensionRoute('loadstream');
|
|
761
|
+
const backend = this.node.backend;
|
|
762
|
+
const socket = this.node.socket;
|
|
763
|
+
const session = this.node.sessionId;
|
|
764
|
+
const current = () => !this.node.destroyed && this.node.backend === backend &&
|
|
765
|
+
this.node.socket === socket && this.node.sessionId === session;
|
|
415
766
|
try {
|
|
416
|
-
const res = await
|
|
417
|
-
method:
|
|
767
|
+
const res = await this.streamRequest(this.url + route.path, {
|
|
768
|
+
method: route.method,
|
|
769
|
+
headers: options.range ? { ...this.jsonHeaders, Range: options.range } : this.jsonHeaders,
|
|
770
|
+
body: requestPayload, signal: options.signal,
|
|
418
771
|
}, options.timeoutMs ?? 100000);
|
|
419
|
-
|
|
420
|
-
|
|
772
|
+
try {
|
|
773
|
+
(0, NodeLinkStreamResponse_1.validateNodeLinkStreamResponse)(res.headers, passthrough ? 'passthrough' :
|
|
774
|
+
requestPayload.format === 'wav' ? 'wav' : 'raw');
|
|
775
|
+
}
|
|
776
|
+
catch (error) {
|
|
777
|
+
res.stream.destroy();
|
|
778
|
+
throw error;
|
|
779
|
+
}
|
|
780
|
+
if (current())
|
|
781
|
+
backend?.recordFeature('loadstream', 'available');
|
|
782
|
+
if (!clientTrim)
|
|
783
|
+
return { stream: res.stream, headers: res.headers, statusCode: res.statusCode };
|
|
784
|
+
const headers = { ...res.headers };
|
|
785
|
+
delete headers['content-length'];
|
|
786
|
+
delete headers['content-range'];
|
|
787
|
+
delete headers['transfer-encoding'];
|
|
788
|
+
delete headers['accept-ranges'];
|
|
789
|
+
return {
|
|
790
|
+
stream: (0, ClientPCMSeek_1.createClientPcmSeekStream)(res.stream, payload.position ?? 0),
|
|
791
|
+
headers, statusCode: res.statusCode,
|
|
792
|
+
};
|
|
421
793
|
}
|
|
422
794
|
catch (error) {
|
|
423
|
-
this.featureError('loadstream', error);
|
|
795
|
+
this.featureError('loadstream', error, backend, current);
|
|
424
796
|
}
|
|
425
797
|
}
|
|
426
798
|
async subscribeLyrics(guildId, skipTrackSource) {
|
|
@@ -428,15 +800,13 @@ class Rest {
|
|
|
428
800
|
const params = new URLSearchParams();
|
|
429
801
|
if (skipTrackSource)
|
|
430
802
|
params.append("skipTrackSource", "true");
|
|
431
|
-
await this.featureRequest("lyrics:subscribe",
|
|
432
|
-
method: "POST",
|
|
803
|
+
await this.featureRequest("lyrics:subscribe", { guildId, query: params }, {
|
|
433
804
|
headers: this.authHeaders
|
|
434
805
|
});
|
|
435
806
|
}
|
|
436
807
|
async unsubscribeLyrics(guildId) {
|
|
437
808
|
this.node.assertFeature("lyrics:unsubscribe");
|
|
438
|
-
await this.featureRequest("lyrics:unsubscribe",
|
|
439
|
-
method: "DELETE",
|
|
809
|
+
await this.featureRequest("lyrics:unsubscribe", { guildId }, {
|
|
440
810
|
headers: this.authHeaders
|
|
441
811
|
});
|
|
442
812
|
}
|