steelseries-sonar-sdk 0.2.0 → 0.2.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.
Files changed (188) hide show
  1. package/dist/index.js +874 -0
  2. package/package.json +7 -3
  3. package/.gitattributes +0 -8
  4. package/.github/workflows/tests.yml +0 -18
  5. package/.vscode/extensions.json +0 -8
  6. package/.vscode/settings.json +0 -33
  7. package/_.todo +0 -4
  8. package/biome.json +0 -62
  9. package/http/sonar.http +0 -104
  10. package/src/consts/fetch-options-put.ts +0 -3
  11. package/src/enums.ts +0 -88
  12. package/src/exceptions.ts +0 -45
  13. package/src/functions/audio/get-audio-data-classic.ts +0 -31
  14. package/src/functions/audio/get-audio-data-stream.ts +0 -37
  15. package/src/functions/audio/get-audio-mode.ts +0 -11
  16. package/src/functions/audio/set-audio-mode.ts +0 -12
  17. package/src/functions/audio/set-channel-mute-classic.ts +0 -35
  18. package/src/functions/audio/set-channel-mute-streamer.ts +0 -41
  19. package/src/functions/audio/set-channel-volume-classic.ts +0 -37
  20. package/src/functions/audio/set-channel-volume-streamer.ts +0 -43
  21. package/src/functions/chatmix/get-chat-mix-state.ts +0 -20
  22. package/src/functions/chatmix/set-chat-mix-balance.ts +0 -22
  23. package/src/functions/converters/convert-channel-to-api.ts +0 -19
  24. package/src/functions/converters/convert-chat-mix-balance-to-api.ts +0 -6
  25. package/src/functions/converters/convert-chat-mix-balance-to-user.ts +0 -7
  26. package/src/functions/converters/convert-profile-channel-to-api.ts +0 -19
  27. package/src/functions/converters/convert-profile-channel-to-user.ts +0 -19
  28. package/src/functions/converters/convert-volume-to-api.ts +0 -5
  29. package/src/functions/converters/convert-volume-to-user.ts +0 -6
  30. package/src/functions/devices/get-audio-devices.ts +0 -40
  31. package/src/functions/devices/set-audio-device.ts +0 -19
  32. package/src/functions/endpoint/get-app-endpoint.ts +0 -73
  33. package/src/functions/endpoint/get-sonar-endpoint-cached.ts +0 -28
  34. package/src/functions/endpoint/get-sonar-endpoint.ts +0 -88
  35. package/src/functions/profile/get-channel-profiles.ts +0 -26
  36. package/src/functions/profile/get-selected-profiles.ts +0 -17
  37. package/src/functions/profile/set-selected-profile.ts +0 -17
  38. package/src/index.ts +0 -41
  39. package/src/sonar/models/audio-settings/chatmix-data.ts +0 -6
  40. package/src/sonar/models/audio-settings/enums/audio-mode.ts +0 -4
  41. package/src/sonar/models/audio-settings/enums/chat-mix-state.ts +0 -6
  42. package/src/sonar/models/audio-settings/enums/device-data-flow.ts +0 -5
  43. package/src/sonar/models/audio-settings/enums/device-default-roles.ts +0 -6
  44. package/src/sonar/models/audio-settings/enums/device-role.ts +0 -9
  45. package/src/sonar/models/audio-settings/enums/device-state.ts +0 -8
  46. package/src/sonar/models/audio-settings/enums/sonar-channel.ts +0 -8
  47. package/src/sonar/models/audio-settings/enums/streaming-path.ts +0 -4
  48. package/src/sonar/models/audio-settings/volume-info-classic.ts +0 -4
  49. package/src/sonar/models/audio-settings/volume-info-streamer.ts +0 -10
  50. package/src/sonar/models/audio-settings/volume-settings-classic.ts +0 -13
  51. package/src/sonar/models/audio-settings/volume-settings-streamer.ts +0 -13
  52. package/src/sonar/models/config/config.ts +0 -9
  53. package/src/sonar/models/config/enums/VirtualAudioDevice.ts +0 -7
  54. package/src/sonar/models/devices/audio-device.ts +0 -17
  55. package/src/sonar/models/devices/changed-device.ts +0 -7
  56. package/src/sonar/requests/audio-devices/change-audio-device.ts +0 -37
  57. package/src/sonar/requests/audio-devices/request-audio-devices.ts +0 -42
  58. package/src/sonar/requests/chatmix/change-chat-mix-balance.ts +0 -25
  59. package/src/sonar/requests/chatmix/request-chat-mix-state.ts +0 -24
  60. package/src/sonar/requests/mode/change-audio-mode.ts +0 -24
  61. package/src/sonar/requests/mode/request-audio-mode.ts +0 -24
  62. package/src/sonar/requests/profiles/change-selected-config.ts +0 -25
  63. package/src/sonar/requests/profiles/request-configs.ts +0 -24
  64. package/src/sonar/requests/profiles/request-selected-configs.ts +0 -22
  65. package/src/sonar/requests/volume-settings/change-volume-level-classic.ts +0 -27
  66. package/src/sonar/requests/volume-settings/change-volume-level-streamer.ts +0 -29
  67. package/src/sonar/requests/volume-settings/change-volume-mute-classic.ts +0 -27
  68. package/src/sonar/requests/volume-settings/change-volume-mute-streamer.ts +0 -29
  69. package/src/sonar/requests/volume-settings/request-volume-settings-classic.ts +0 -22
  70. package/src/sonar/requests/volume-settings/request-volume-settings-streamer.ts +0 -22
  71. package/src/types/audio-device.ts +0 -7
  72. package/src/types/changed-device.ts +0 -7
  73. package/src/types/channel-volume-classic.ts +0 -4
  74. package/src/types/channel-volume-streamer-path.ts +0 -4
  75. package/src/types/channel-volume-streamer.ts +0 -6
  76. package/src/types/channel-volumes-classic.ts +0 -8
  77. package/src/types/channel-volumes-streamer.ts +0 -8
  78. package/src/types/chat-mix-data.ts +0 -7
  79. package/src/types/profile-option.ts +0 -9
  80. package/tests/e2e/audio/get-audio-data-classic.real.test.ts +0 -11
  81. package/tests/e2e/audio/get-audio-data-stream.real.test.ts +0 -11
  82. package/tests/e2e/audio/get-audio-mode.real.test.ts +0 -12
  83. package/tests/e2e/audio/set-audio-mode.real.test.ts +0 -20
  84. package/tests/e2e/audio/set-channel-mute-classic.real.test.ts +0 -18
  85. package/tests/e2e/audio/set-channel-mute-streamer.real.test.ts +0 -18
  86. package/tests/e2e/audio/set-channel-volume-classic.real.test.ts +0 -17
  87. package/tests/e2e/audio/set-channel-volume-streamer.real.test.ts +0 -22
  88. package/tests/e2e/chatmix/get-chat-mix-state.real.test.ts +0 -25
  89. package/tests/e2e/chatmix/set-chat-mix-balance.real.test.ts +0 -25
  90. package/tests/e2e/devices/get-audio-devices.real.test.ts +0 -29
  91. package/tests/e2e/devices/set-audio-device.real.test.ts +0 -32
  92. package/tests/e2e/enpoint/get-app-endpoint.real.test.ts +0 -19
  93. package/tests/e2e/enpoint/get-sonar-endpoint-cached.real.test.ts +0 -32
  94. package/tests/e2e/enpoint/get-sonar-endpoint.real.test.ts +0 -21
  95. package/tests/e2e/profiles/get-channel-profiles.real.test.ts +0 -21
  96. package/tests/e2e/profiles/get-selected-profiles.real.test.ts +0 -11
  97. package/tests/e2e/profiles/set-selected-profile.real.test.ts +0 -17
  98. package/tests/helpers/get-endpoint-e2e.ts +0 -8
  99. package/tests/unit/audio/get-audio-data-classic.test.ts +0 -57
  100. package/tests/unit/audio/get-audio-data-stream.test.ts +0 -65
  101. package/tests/unit/audio/get-audio-mode.test.ts +0 -58
  102. package/tests/unit/audio/set-audio-mode.test.ts +0 -66
  103. package/tests/unit/audio/set-channel-mute-classic.test.ts +0 -58
  104. package/tests/unit/audio/set-channel-mute-streamer.test.ts +0 -64
  105. package/tests/unit/audio/set-channel-volume-classic.test.ts +0 -58
  106. package/tests/unit/audio/set-channel-volume-streamer.test.ts +0 -64
  107. package/tests/unit/chatmix/get-chat-mix-state.test.ts +0 -70
  108. package/tests/unit/chatmix/set-chat-mix-balance.test.ts +0 -58
  109. package/tests/unit/devices/get-audio-devices.test.ts +0 -59
  110. package/tests/unit/devices/set-audio-devices.test.ts +0 -62
  111. package/tests/unit/endpoint/get-app-endpoint.test.ts +0 -72
  112. package/tests/unit/endpoint/get-sonar-endpoint-cached.test.ts +0 -93
  113. package/tests/unit/endpoint/get-sonar-endpoint.test.ts +0 -140
  114. package/tests/unit/profiles/get-channel-profiles.test.ts +0 -91
  115. package/tests/unit/profiles/get-selected-profiles.test.ts +0 -64
  116. package/tests/unit/profiles/set-selected-profile.test.ts +0 -55
  117. package/tsconfig.build.json +0 -12
  118. package/tsconfig.json +0 -36
  119. /package/{src → dist}/consts/fetch-options-put.d.ts +0 -0
  120. /package/{src → dist}/enums.d.ts +0 -0
  121. /package/{src → dist}/exceptions.d.ts +0 -0
  122. /package/{src → dist}/functions/audio/get-audio-data-classic.d.ts +0 -0
  123. /package/{src → dist}/functions/audio/get-audio-data-stream.d.ts +0 -0
  124. /package/{src → dist}/functions/audio/get-audio-mode.d.ts +0 -0
  125. /package/{src → dist}/functions/audio/set-audio-mode.d.ts +0 -0
  126. /package/{src → dist}/functions/audio/set-channel-mute-classic.d.ts +0 -0
  127. /package/{src → dist}/functions/audio/set-channel-mute-streamer.d.ts +0 -0
  128. /package/{src → dist}/functions/audio/set-channel-volume-classic.d.ts +0 -0
  129. /package/{src → dist}/functions/audio/set-channel-volume-streamer.d.ts +0 -0
  130. /package/{src → dist}/functions/chatmix/get-chat-mix-state.d.ts +0 -0
  131. /package/{src → dist}/functions/chatmix/set-chat-mix-balance.d.ts +0 -0
  132. /package/{src → dist}/functions/converters/convert-channel-to-api.d.ts +0 -0
  133. /package/{src → dist}/functions/converters/convert-chat-mix-balance-to-api.d.ts +0 -0
  134. /package/{src → dist}/functions/converters/convert-chat-mix-balance-to-user.d.ts +0 -0
  135. /package/{src → dist}/functions/converters/convert-profile-channel-to-api.d.ts +0 -0
  136. /package/{src → dist}/functions/converters/convert-profile-channel-to-user.d.ts +0 -0
  137. /package/{src → dist}/functions/converters/convert-volume-to-api.d.ts +0 -0
  138. /package/{src → dist}/functions/converters/convert-volume-to-user.d.ts +0 -0
  139. /package/{src → dist}/functions/devices/get-audio-devices.d.ts +0 -0
  140. /package/{src → dist}/functions/devices/set-audio-device.d.ts +0 -0
  141. /package/{src → dist}/functions/endpoint/get-app-endpoint.d.ts +0 -0
  142. /package/{src → dist}/functions/endpoint/get-sonar-endpoint-cached.d.ts +0 -0
  143. /package/{src → dist}/functions/endpoint/get-sonar-endpoint.d.ts +0 -0
  144. /package/{src → dist}/functions/profile/get-channel-profiles.d.ts +0 -0
  145. /package/{src → dist}/functions/profile/get-selected-profiles.d.ts +0 -0
  146. /package/{src → dist}/functions/profile/set-selected-profile.d.ts +0 -0
  147. /package/{src → dist}/index.d.ts +0 -0
  148. /package/{src → dist}/sonar/models/audio-settings/chatmix-data.d.ts +0 -0
  149. /package/{src → dist}/sonar/models/audio-settings/enums/audio-mode.d.ts +0 -0
  150. /package/{src → dist}/sonar/models/audio-settings/enums/chat-mix-state.d.ts +0 -0
  151. /package/{src → dist}/sonar/models/audio-settings/enums/device-data-flow.d.ts +0 -0
  152. /package/{src → dist}/sonar/models/audio-settings/enums/device-default-roles.d.ts +0 -0
  153. /package/{src → dist}/sonar/models/audio-settings/enums/device-role.d.ts +0 -0
  154. /package/{src → dist}/sonar/models/audio-settings/enums/device-state.d.ts +0 -0
  155. /package/{src → dist}/sonar/models/audio-settings/enums/sonar-channel.d.ts +0 -0
  156. /package/{src → dist}/sonar/models/audio-settings/enums/streaming-path.d.ts +0 -0
  157. /package/{src → dist}/sonar/models/audio-settings/volume-info-classic.d.ts +0 -0
  158. /package/{src → dist}/sonar/models/audio-settings/volume-info-streamer.d.ts +0 -0
  159. /package/{src → dist}/sonar/models/audio-settings/volume-settings-classic.d.ts +0 -0
  160. /package/{src → dist}/sonar/models/audio-settings/volume-settings-streamer.d.ts +0 -0
  161. /package/{src → dist}/sonar/models/config/config.d.ts +0 -0
  162. /package/{src → dist}/sonar/models/config/enums/VirtualAudioDevice.d.ts +0 -0
  163. /package/{src → dist}/sonar/models/devices/audio-device.d.ts +0 -0
  164. /package/{src → dist}/sonar/models/devices/changed-device.d.ts +0 -0
  165. /package/{src → dist}/sonar/requests/audio-devices/change-audio-device.d.ts +0 -0
  166. /package/{src → dist}/sonar/requests/audio-devices/request-audio-devices.d.ts +0 -0
  167. /package/{src → dist}/sonar/requests/chatmix/change-chat-mix-balance.d.ts +0 -0
  168. /package/{src → dist}/sonar/requests/chatmix/request-chat-mix-state.d.ts +0 -0
  169. /package/{src → dist}/sonar/requests/mode/change-audio-mode.d.ts +0 -0
  170. /package/{src → dist}/sonar/requests/mode/request-audio-mode.d.ts +0 -0
  171. /package/{src → dist}/sonar/requests/profiles/change-selected-config.d.ts +0 -0
  172. /package/{src → dist}/sonar/requests/profiles/request-configs.d.ts +0 -0
  173. /package/{src → dist}/sonar/requests/profiles/request-selected-configs.d.ts +0 -0
  174. /package/{src → dist}/sonar/requests/volume-settings/change-volume-level-classic.d.ts +0 -0
  175. /package/{src → dist}/sonar/requests/volume-settings/change-volume-level-streamer.d.ts +0 -0
  176. /package/{src → dist}/sonar/requests/volume-settings/change-volume-mute-classic.d.ts +0 -0
  177. /package/{src → dist}/sonar/requests/volume-settings/change-volume-mute-streamer.d.ts +0 -0
  178. /package/{src → dist}/sonar/requests/volume-settings/request-volume-settings-classic.d.ts +0 -0
  179. /package/{src → dist}/sonar/requests/volume-settings/request-volume-settings-streamer.d.ts +0 -0
  180. /package/{src → dist}/types/audio-device.d.ts +0 -0
  181. /package/{src → dist}/types/changed-device.d.ts +0 -0
  182. /package/{src → dist}/types/channel-volume-classic.d.ts +0 -0
  183. /package/{src → dist}/types/channel-volume-streamer-path.d.ts +0 -0
  184. /package/{src → dist}/types/channel-volume-streamer.d.ts +0 -0
  185. /package/{src → dist}/types/channel-volumes-classic.d.ts +0 -0
  186. /package/{src → dist}/types/channel-volumes-streamer.d.ts +0 -0
  187. /package/{src → dist}/types/chat-mix-data.d.ts +0 -0
  188. /package/{src → dist}/types/profile-option.d.ts +0 -0
@@ -1,37 +0,0 @@
1
- import type { DeviceChannel } from '@/enums'
2
- import { SonarRequestException } from '@/exceptions'
3
- import type { ChangedDevice } from '@/sonar/models/devices/changed-device'
4
-
5
- export async function changeAudioDevice(
6
- sonarEndpoint: string,
7
- deviceChannel: DeviceChannel,
8
- deviceId: string
9
- ): Promise<ChangedDevice[]> {
10
- let response: Response
11
- const url = new URL(`${sonarEndpoint}/classicRedirections/${deviceChannel}/deviceId/${deviceId}`)
12
-
13
- try {
14
- response = await fetch(url, { method: 'PUT' })
15
- } catch (error) {
16
- throw new SonarRequestException({
17
- innerException: error as Error
18
- })
19
- }
20
-
21
- if (!response.ok) {
22
- const error = await response.text()
23
- throw new SonarRequestException({ message: `Failed to get audio devices: ${error}` })
24
- }
25
-
26
- const unknownData = (await response.json()) as ChangedDevice[] | ChangedDevice
27
-
28
- const data = Array.isArray(unknownData) ? unknownData : [unknownData]
29
-
30
- const devices = data.filter((x) => x?.deviceId === deviceId)
31
-
32
- if (devices.length === 0) {
33
- throw new SonarRequestException({ message: 'The changed audio devices list is empty.' })
34
- }
35
-
36
- return devices
37
- }
@@ -1,42 +0,0 @@
1
- import { SonarRequestException } from '@/exceptions'
2
- import type { DeviceDataFlow } from '@/sonar/models/audio-settings/enums/device-data-flow'
3
- import type { AudioDevice as SonarAudioDevice } from '@/sonar/models/devices/audio-device'
4
-
5
- type Params = {
6
- deviceDataFlow?: DeviceDataFlow
7
- onlySteelSeriesVAD?: boolean
8
- removeSteelSeriesVAD?: boolean
9
- }
10
-
11
- export async function requestAudioDevices(sonarEndpoint: string, params: Params): Promise<SonarAudioDevice[]> {
12
- const { deviceDataFlow, onlySteelSeriesVAD = false, removeSteelSeriesVAD = false } = params
13
-
14
- const url = new URL(`${sonarEndpoint}/audioDevices`)
15
- url.searchParams.append('onlySteelSeriesVAD', String(onlySteelSeriesVAD))
16
- url.searchParams.append('removeSteelSeriesVAD', String(removeSteelSeriesVAD))
17
- if (deviceDataFlow !== undefined) {
18
- url.searchParams.append('deviceDataFlow', deviceDataFlow.toString())
19
- }
20
-
21
- let response: Response
22
- try {
23
- response = await fetch(url)
24
- } catch (error) {
25
- throw new SonarRequestException({
26
- innerException: error as Error
27
- })
28
- }
29
-
30
- if (!response.ok) {
31
- const error = await response.text()
32
- throw new SonarRequestException({ message: `Failed to get audio devices: ${error}` })
33
- }
34
-
35
- const data = (await response.json()) as SonarAudioDevice[]
36
-
37
- if (!Array.isArray(data)) {
38
- throw new SonarRequestException({ message: 'Invalid audio devices response format.' })
39
- }
40
-
41
- return data
42
- }
@@ -1,25 +0,0 @@
1
- import { SonarRequestException } from '@/exceptions'
2
- import type { ChatMixData } from '@/sonar/models/audio-settings/chatmix-data'
3
-
4
- export async function changeChatMixBalance(sonarEndpoint: string, chatBalance: number) {
5
- const url = new URL(`${sonarEndpoint}/chatMix?balance=${chatBalance}`)
6
- let response: Response
7
- try {
8
- response = await fetch(url, {
9
- method: 'PUT'
10
- })
11
- } catch (error) {
12
- throw new SonarRequestException({ innerException: error as Error })
13
- }
14
-
15
- if (response.ok) {
16
- const data = (await response.json()) as ChatMixData
17
- if (data?.balance == null || data?.state == null) {
18
- throw new SonarRequestException({ message: 'Missing required data in response' })
19
- }
20
- return data
21
- } else {
22
- const data = (await response.json()) as { Message?: string }
23
- throw new SonarRequestException({ message: data.Message })
24
- }
25
- }
@@ -1,24 +0,0 @@
1
- import { SonarRequestException } from '@/exceptions'
2
- import type { ChatMixData } from '@/sonar/models/audio-settings/chatmix-data'
3
-
4
- export async function requestChatMixState(sonarEndpoint: string): Promise<ChatMixData> {
5
- const url = new URL(`${sonarEndpoint}/chatMix`)
6
- let response: Response
7
-
8
- try {
9
- response = await fetch(url)
10
- } catch (error) {
11
- throw new SonarRequestException({ innerException: error as Error })
12
- }
13
-
14
- if (response.ok) {
15
- const data = (await response.json()) as ChatMixData
16
- if (data?.balance == null || data?.state == null) {
17
- throw new SonarRequestException({ message: 'Missing required data in response' })
18
- }
19
- return data
20
- } else {
21
- const data = await response.text()
22
- throw new SonarRequestException({ innerException: new Error(data) })
23
- }
24
- }
@@ -1,24 +0,0 @@
1
- import { SonarRequestException } from '@/exceptions'
2
- import type { AudioMode } from '@/sonar/models/audio-settings/enums/audio-mode'
3
-
4
- export async function changeAudioMode(sonarEndpoint: string, audioMode: AudioMode): Promise<AudioMode> {
5
- let response: Response
6
- const url = new URL(`${sonarEndpoint}/mode/${audioMode}`)
7
- try {
8
- response = await fetch(url, {
9
- method: 'PUT'
10
- })
11
- } catch (error) {
12
- throw new SonarRequestException({ innerException: error as Error })
13
- }
14
- if (response.ok) {
15
- const data = await response.json()
16
- if (data !== audioMode) {
17
- throw new SonarRequestException({ message: 'Returned audio mode does not match requested mode' })
18
- }
19
- return data as AudioMode
20
- } else {
21
- const data = await response.text()
22
- throw new SonarRequestException({ innerException: new Error(data) })
23
- }
24
- }
@@ -1,24 +0,0 @@
1
- import { SonarRequestException } from '@/exceptions'
2
- import { AudioMode } from '@/sonar/models/audio-settings/enums/audio-mode'
3
-
4
- export async function requestAudioMode(sonarEndpoint: string): Promise<AudioMode> {
5
- let response: Response
6
- const url = new URL(`${sonarEndpoint}/mode`)
7
-
8
- try {
9
- response = await fetch(url)
10
- } catch (error) {
11
- throw new SonarRequestException({ innerException: error as Error })
12
- }
13
-
14
- if (response.ok) {
15
- const data = (await response.json()) as AudioMode
16
- if (Object.values(AudioMode).includes(data)) {
17
- return data
18
- }
19
- throw new SonarRequestException({ message: 'Received unhandled audio mode from Sonar server' })
20
- } else {
21
- const data = await response.text()
22
- throw new SonarRequestException({ innerException: new Error(data) })
23
- }
24
- }
@@ -1,25 +0,0 @@
1
- import { SonarRequestException } from '@/exceptions'
2
- import type { Config } from '@/sonar/models/config/config'
3
-
4
- export async function changeSelectedConfig(sonarAddress: string, configId: string): Promise<Config> {
5
- let response: Response
6
-
7
- try {
8
- response = await fetch(`${sonarAddress}/configs/${configId}/select`, {
9
- method: 'PUT'
10
- })
11
- } catch (error) {
12
- throw new SonarRequestException({ innerException: error as Error })
13
- }
14
-
15
- if (response.ok) {
16
- const data = (await response.json()) as Config
17
- if (!data?.id) {
18
- throw new SonarRequestException({ message: 'Missing required data in response' })
19
- }
20
- return data
21
- } else {
22
- const data = (await response.json()) as { error: string }
23
- throw new SonarRequestException({ innerException: new Error(data?.error ?? data) })
24
- }
25
- }
@@ -1,24 +0,0 @@
1
- import { SonarRequestException } from '@/exceptions'
2
- import type { Config } from '@/sonar/models/config/config'
3
- import type { VirtualAudioDevice } from '@/sonar/models/config/enums/VirtualAudioDevice'
4
-
5
- export async function requestConfigs(sonarAddress: string, channel: VirtualAudioDevice): Promise<Config[]> {
6
- let response: Response
7
-
8
- try {
9
- response = await fetch(`${sonarAddress}/configs?vad=${channel}`)
10
- } catch (error) {
11
- throw new SonarRequestException({ innerException: error as Error })
12
- }
13
-
14
- if (response.ok) {
15
- const data = (await response.json()) as Config[]
16
- if (!Array.isArray(data)) {
17
- throw new SonarRequestException({ message: 'Missing required data in response' })
18
- }
19
- return data
20
- } else {
21
- const data = (await response.json()) as { error: string }
22
- throw new SonarRequestException({ innerException: new Error(data?.error ?? data) })
23
- }
24
- }
@@ -1,22 +0,0 @@
1
- import { SonarRequestException } from '@/exceptions'
2
- import type { Config } from '@/sonar/models/config/config'
3
- export async function requestSelectedConfigs(sonarAddress: string): Promise<Config[]> {
4
- let response: Response
5
-
6
- try {
7
- response = await fetch(`${sonarAddress}/configs/selected`)
8
- } catch (error) {
9
- throw new SonarRequestException({ innerException: error as Error })
10
- }
11
-
12
- if (response.ok) {
13
- const data = (await response.json()) as Config[]
14
- if (!Array.isArray(data)) {
15
- throw new SonarRequestException({ message: 'Missing required data in response' })
16
- }
17
- return data
18
- } else {
19
- const data = (await response.json()) as { error: string }
20
- throw new SonarRequestException({ innerException: new Error(data?.error ?? data) })
21
- }
22
- }
@@ -1,27 +0,0 @@
1
- import { SonarRequestException } from '@/exceptions'
2
- import type { SonarChannel } from '@/sonar/models/audio-settings/enums/sonar-channel'
3
- import type { VolumeSettingsClassic } from '@/sonar/models/audio-settings/volume-settings-classic'
4
-
5
- export async function changeVolumeLevelClassic(
6
- sonarEndpoint: string,
7
- volume: number,
8
- deviceRole: SonarChannel
9
- ): Promise<VolumeSettingsClassic> {
10
- let response: Response
11
- try {
12
- const url = new URL(`${sonarEndpoint}/volumeSettings/classic/${deviceRole}/volume/${volume}`)
13
- response = await fetch(url, { method: 'PUT' })
14
- } catch (error) {
15
- throw new SonarRequestException({ innerException: error as Error })
16
- }
17
- if (response.ok) {
18
- const data = (await response.json()) as VolumeSettingsClassic
19
- if (data?.masters?.classic == null) {
20
- throw new SonarRequestException({ innerException: new Error('Missing required data in response.') })
21
- }
22
- return data
23
- } else {
24
- const data = (await response.json()) as { error: string }
25
- throw new SonarRequestException({ innerException: new Error(data?.error ?? data) })
26
- }
27
- }
@@ -1,29 +0,0 @@
1
- import { SonarRequestException } from '@/exceptions'
2
- import type { SonarChannel } from '@/sonar/models/audio-settings/enums/sonar-channel'
3
- import type { StreamingPath } from '@/sonar/models/audio-settings/enums/streaming-path'
4
- import type { VolumeSettingsStreamer } from '@/sonar/models/audio-settings/volume-settings-streamer'
5
-
6
- export async function changeVolumeLevelStreamer(
7
- sonarEndpoint: string,
8
- volume: number,
9
- channel: SonarChannel,
10
- path: StreamingPath
11
- ): Promise<VolumeSettingsStreamer> {
12
- let response: Response
13
- try {
14
- const url = new URL(`${sonarEndpoint}/volumeSettings/streamer/${path}/${channel}/volume/${volume}`)
15
- response = await fetch(url, { method: 'PUT' })
16
- } catch (error) {
17
- throw new SonarRequestException({ innerException: error as Error })
18
- }
19
- if (response.ok) {
20
- const data = (await response.json()) as VolumeSettingsStreamer
21
- if (data?.masters?.stream == null) {
22
- throw new SonarRequestException({ innerException: new Error('Missing required data in response.') })
23
- }
24
- return data
25
- } else {
26
- const data = (await response.json()) as { error: string }
27
- throw new SonarRequestException({ innerException: new Error(data?.error ?? data) })
28
- }
29
- }
@@ -1,27 +0,0 @@
1
- import { SonarRequestException } from '@/exceptions'
2
- import type { SonarChannel } from '@/sonar/models/audio-settings/enums/sonar-channel'
3
- import type { VolumeSettingsClassic } from '@/sonar/models/audio-settings/volume-settings-classic'
4
-
5
- export async function changeVolumeMuteClassic(
6
- sonarEndpoint: string,
7
- isMuted: boolean,
8
- deviceRole: SonarChannel
9
- ): Promise<VolumeSettingsClassic> {
10
- let response: Response
11
- try {
12
- const url = new URL(`${sonarEndpoint}/volumeSettings/classic/${deviceRole}/mute/${isMuted}`)
13
- response = await fetch(url, { method: 'PUT' })
14
- } catch (error) {
15
- throw new SonarRequestException({ innerException: error as Error })
16
- }
17
- if (response.ok) {
18
- const data = (await response.json()) as VolumeSettingsClassic
19
- if (data?.masters?.classic == null) {
20
- throw new SonarRequestException({ innerException: new Error('Missing required data in response.') })
21
- }
22
- return data
23
- } else {
24
- const data = (await response.json()) as { error: string }
25
- throw new SonarRequestException({ innerException: new Error(data?.error ?? data) })
26
- }
27
- }
@@ -1,29 +0,0 @@
1
- import { SonarRequestException } from '@/exceptions'
2
- import type { SonarChannel } from '@/sonar/models/audio-settings/enums/sonar-channel'
3
- import type { StreamingPath } from '@/sonar/models/audio-settings/enums/streaming-path'
4
- import type { VolumeSettingsStreamer } from '@/sonar/models/audio-settings/volume-settings-streamer'
5
-
6
- export async function changeVolumeMuteStreamer(
7
- sonarEndpoint: string,
8
- isMuted: boolean,
9
- deviceRole: SonarChannel,
10
- path: StreamingPath
11
- ): Promise<VolumeSettingsStreamer> {
12
- let response: Response
13
- try {
14
- const url = new URL(`${sonarEndpoint}/volumeSettings/streamer/${path}/${deviceRole}/isMuted/${isMuted}`)
15
- response = await fetch(url, { method: 'PUT' })
16
- } catch (error) {
17
- throw new SonarRequestException({ innerException: error as Error })
18
- }
19
- if (response.ok) {
20
- const data = (await response.json()) as VolumeSettingsStreamer
21
- if (data?.masters?.stream == null) {
22
- throw new SonarRequestException({ innerException: new Error('Missing required data in response.') })
23
- }
24
- return data
25
- } else {
26
- const data = (await response.json()) as { error: string }
27
- throw new SonarRequestException({ innerException: new Error(data?.error ?? data) })
28
- }
29
- }
@@ -1,22 +0,0 @@
1
- import { SonarRequestException } from '@/exceptions'
2
- import type { VolumeSettingsClassic } from '@/sonar/models/audio-settings/volume-settings-classic'
3
-
4
- export async function requestVolumeSettingsClassic(sonarEndpoint: string): Promise<VolumeSettingsClassic> {
5
- let response: Response
6
- try {
7
- const url = new URL(`${sonarEndpoint}/volumeSettings/classic`)
8
- response = await fetch(url)
9
- } catch (error) {
10
- throw new SonarRequestException({ innerException: error as Error })
11
- }
12
- if (response.ok) {
13
- const data = (await response.json()) as VolumeSettingsClassic
14
- if (data?.masters?.classic == null) {
15
- throw new SonarRequestException({ innerException: new Error('Missing required data in response.') })
16
- }
17
- return data
18
- } else {
19
- const data = (await response.json()) as { error: string }
20
- throw new SonarRequestException({ innerException: new Error(data?.error ?? data) })
21
- }
22
- }
@@ -1,22 +0,0 @@
1
- import { SonarRequestException } from '@/exceptions'
2
- import type { VolumeSettingsStreamer } from '@/sonar/models/audio-settings/volume-settings-streamer'
3
-
4
- export async function requestVolumeSettingsStreamer(sonarEndpoint: string): Promise<VolumeSettingsStreamer> {
5
- let response: Response
6
- try {
7
- const url = new URL(`${sonarEndpoint}/volumeSettings/streamer`)
8
- response = await fetch(url)
9
- } catch (error) {
10
- throw new SonarRequestException({ innerException: error as Error })
11
- }
12
- if (response.ok) {
13
- const data = (await response.json()) as VolumeSettingsStreamer
14
- if (data?.masters?.stream == null) {
15
- throw new SonarRequestException({ innerException: new Error('Missing required data in response.') })
16
- }
17
- return data
18
- } else {
19
- const data = (await response.json()) as { error: string }
20
- throw new SonarRequestException({ innerException: new Error(data?.error ?? data) })
21
- }
22
- }
@@ -1,7 +0,0 @@
1
- import type { DeviceFlow } from '@/enums'
2
-
3
- export type AudioDevice = {
4
- id: string
5
- name: string
6
- type: DeviceFlow
7
- }
@@ -1,7 +0,0 @@
1
- import type { DeviceChannel } from '@/enums'
2
-
3
- export type ChangedDevice = {
4
- deviceId: string
5
- deviceChannel: Exclude<DeviceChannel, DeviceChannel.Output>
6
- isRunning: boolean
7
- }
@@ -1,4 +0,0 @@
1
- export type ChannelVolumeClassic = {
2
- volume: number
3
- isMuted: boolean
4
- }
@@ -1,4 +0,0 @@
1
- export type ChannelVolumeStreamerPath = {
2
- volume: number
3
- isMuted: boolean
4
- }
@@ -1,6 +0,0 @@
1
- import type { StreamerPath } from '@/enums'
2
- import type { ChannelVolumeStreamerPath } from '@/types/channel-volume-streamer-path'
3
-
4
- export type ChannelVolumeStreamer = {
5
- [K in StreamerPath]: ChannelVolumeStreamerPath
6
- }
@@ -1,8 +0,0 @@
1
- import type { AudioChannel } from '@/enums'
2
- import type { ChannelVolumeClassic } from '@/types/channel-volume-classic'
3
-
4
- export type ChannelVolumesClassic = {
5
- [AudioChannel.Master]: ChannelVolumeClassic
6
- } & {
7
- [K in Exclude<AudioChannel, 'master'>]?: ChannelVolumeClassic
8
- }
@@ -1,8 +0,0 @@
1
- import type { AudioChannel } from '@/enums'
2
- import type { ChannelVolumeStreamer } from '@/types/channel-volume-streamer'
3
-
4
- export type ChannelVolumesStreamer = {
5
- [AudioChannel.Master]: ChannelVolumeStreamer
6
- } & {
7
- [K in AudioChannel]?: ChannelVolumeStreamer
8
- }
@@ -1,7 +0,0 @@
1
- import type { ChatMixState } from '@/enums'
2
-
3
- export type ChatMixData = {
4
- chatBalance: number
5
- state: ChatMixState
6
- isEnabled: boolean
7
- }
@@ -1,9 +0,0 @@
1
- import type { ProfileChannel } from '@/enums'
2
-
3
- export type ProfileOption = {
4
- id: string
5
- name: string
6
- isFavorite: boolean
7
- channel: ProfileChannel
8
- image?: string
9
- }
@@ -1,11 +0,0 @@
1
- import { describe, expect, it } from 'bun:test'
2
- import { getEndpointEndToEnd } from 'tests/helpers/get-endpoint-e2e'
3
- import { getAudioDataClassic } from '@/functions/audio/get-audio-data-classic'
4
-
5
- describe('getAudioDataClassic', () => {
6
- it('returns audio data', async () => {
7
- const sonarEndpoint = await getEndpointEndToEnd()
8
- const result = await getAudioDataClassic(sonarEndpoint)
9
- expect(result.master.volume).toBeGreaterThan(0)
10
- })
11
- })
@@ -1,11 +0,0 @@
1
- import { describe, expect, it } from 'bun:test'
2
- import { getEndpointEndToEnd } from 'tests/helpers/get-endpoint-e2e'
3
- import { getAudioDataStream } from '@/functions/audio/get-audio-data-stream'
4
-
5
- describe('getAudioDataStreamer', () => {
6
- it('returns audio data', async () => {
7
- const sonarEndpoint = await getEndpointEndToEnd()
8
- const result = await getAudioDataStream(sonarEndpoint)
9
- expect(result.master.monitoring.volume).toBeGreaterThan(0)
10
- })
11
- })
@@ -1,12 +0,0 @@
1
- import { describe, expect, it } from 'bun:test'
2
- import { getEndpointEndToEnd } from 'tests/helpers/get-endpoint-e2e'
3
- import { AudioMode } from '@/enums'
4
- import { getAudioMode } from '@/functions/audio/get-audio-mode'
5
-
6
- describe('getAudioMode', () => {
7
- it('returns an audio mode', async () => {
8
- const sonarEndpoint = await getEndpointEndToEnd()
9
- const result = await getAudioMode(sonarEndpoint)
10
- expect(result).toBeOneOf(Object.values(AudioMode))
11
- })
12
- })
@@ -1,20 +0,0 @@
1
- import { describe, expect, it } from 'bun:test'
2
- import { getEndpointEndToEnd } from 'tests/helpers/get-endpoint-e2e'
3
- import { AudioMode } from '@/enums'
4
- import { setAudioMode } from '@/functions/audio/set-audio-mode'
5
-
6
- describe('setAudioMode', () => {
7
- it('returns classic when set to classic', async () => {
8
- const expectedAudioMode: AudioMode = AudioMode.Classic
9
- const sonarEndpoint = await getEndpointEndToEnd()
10
- const result = await setAudioMode(sonarEndpoint, expectedAudioMode)
11
- expect(result).toBe(expectedAudioMode)
12
- })
13
-
14
- it('returns streamer when set to streamer', async () => {
15
- const expectedAudioMode: AudioMode = AudioMode.Streamer
16
- const sonarEndpoint = await getEndpointEndToEnd()
17
- const result = await setAudioMode(sonarEndpoint, expectedAudioMode)
18
- expect(result).toBe(expectedAudioMode)
19
- })
20
- })
@@ -1,18 +0,0 @@
1
- import { describe, expect, it } from 'bun:test'
2
- import { getEndpointEndToEnd } from 'tests/helpers/get-endpoint-e2e'
3
- import { AudioChannel, AudioMode } from '@/enums'
4
- import { setChannelMuteClassic } from '@/functions/audio/set-channel-mute-classic'
5
- import { setAudioMode } from '@/index'
6
-
7
- describe('setChannelMuteClassic', () => {
8
- it('returns muted false', async () => {
9
- const sonarEndpoint = await getEndpointEndToEnd()
10
-
11
- await setAudioMode(sonarEndpoint, AudioMode.Classic)
12
- const initial = await setChannelMuteClassic(sonarEndpoint, true, AudioChannel.Game)
13
- const expected = await setChannelMuteClassic(sonarEndpoint, false, AudioChannel.Game)
14
-
15
- expect(initial.isMuted).toBeTrue()
16
- expect(expected.isMuted).toBeFalse()
17
- })
18
- })
@@ -1,18 +0,0 @@
1
- import { describe, expect, it } from 'bun:test'
2
- import { getEndpointEndToEnd } from 'tests/helpers/get-endpoint-e2e'
3
- import { AudioChannel, AudioMode, StreamerPath } from '@/enums'
4
- import { setChannelMuteStreamer } from '@/functions/audio/set-channel-mute-streamer'
5
- import { setAudioMode } from '@/index'
6
-
7
- describe('setChannelMuteStreamer', () => {
8
- it('returns muted false', async () => {
9
- const sonarEndpoint = await getEndpointEndToEnd()
10
-
11
- await setAudioMode(sonarEndpoint, AudioMode.Streamer)
12
- const initial = await setChannelMuteStreamer(sonarEndpoint, true, AudioChannel.Game, StreamerPath.Streaming)
13
- const expected = await setChannelMuteStreamer(sonarEndpoint, false, AudioChannel.Game, StreamerPath.Streaming)
14
-
15
- expect(initial.isMuted).toBeTrue()
16
- expect(expected.isMuted).toBeFalse()
17
- })
18
- })
@@ -1,17 +0,0 @@
1
- import { describe, expect, it } from 'bun:test'
2
- import { getEndpointEndToEnd } from 'tests/helpers/get-endpoint-e2e'
3
- import { AudioChannel, AudioMode } from '@/enums'
4
- import { setChannelVolumeClassic } from '@/functions/audio/set-channel-volume-classic'
5
- import { setAudioMode } from '@/index'
6
-
7
- describe('setChannelVolumeClassic', () => {
8
- it('returns new volume', async () => {
9
- const expectedVolume = 39
10
- const sonarEndpoint = await getEndpointEndToEnd()
11
-
12
- await setAudioMode(sonarEndpoint, AudioMode.Classic)
13
- const result = await setChannelVolumeClassic(sonarEndpoint, expectedVolume, AudioChannel.Master)
14
-
15
- expect(result.volume).toBe(expectedVolume)
16
- })
17
- })
@@ -1,22 +0,0 @@
1
- import { describe, expect, it } from 'bun:test'
2
- import { getEndpointEndToEnd } from 'tests/helpers/get-endpoint-e2e'
3
- import { AudioChannel, AudioMode, StreamerPath } from '@/enums'
4
- import { setChannelVolumeStreamer } from '@/functions/audio/set-channel-volume-streamer'
5
- import { setAudioMode } from '@/index'
6
-
7
- describe('setChannelVolumeStreamer', () => {
8
- it('returns new volume', async () => {
9
- const expectedVolume = 39
10
- const sonarEndpoint = await getEndpointEndToEnd()
11
-
12
- await setAudioMode(sonarEndpoint, AudioMode.Streamer)
13
- const result = await setChannelVolumeStreamer(
14
- sonarEndpoint,
15
- expectedVolume,
16
- AudioChannel.Master,
17
- StreamerPath.Monitoring
18
- )
19
-
20
- expect(result.volume).toBe(expectedVolume)
21
- })
22
- })