steelseries-sonar-sdk 0.1.1 → 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 (185) hide show
  1. package/dist/consts/fetch-options-put.d.ts +3 -0
  2. package/{src/enums.ts → dist/enums.d.ts} +34 -41
  3. package/dist/exceptions.d.ts +32 -0
  4. package/dist/functions/audio/get-audio-data-classic.d.ts +7 -0
  5. package/dist/functions/audio/get-audio-data-stream.d.ts +7 -0
  6. package/dist/functions/audio/get-audio-mode.d.ts +7 -0
  7. package/dist/functions/audio/set-audio-mode.d.ts +8 -0
  8. package/dist/functions/audio/set-channel-mute-classic.d.ts +9 -0
  9. package/dist/functions/audio/set-channel-mute-streamer.d.ts +10 -0
  10. package/dist/functions/audio/set-channel-volume-classic.d.ts +9 -0
  11. package/dist/functions/audio/set-channel-volume-streamer.d.ts +10 -0
  12. package/dist/functions/chatmix/get-chat-mix-state.d.ts +7 -0
  13. package/dist/functions/chatmix/set-chat-mix-balance.d.ts +7 -0
  14. package/dist/functions/converters/convert-channel-to-api.d.ts +3 -0
  15. package/dist/functions/converters/convert-chat-mix-balance-to-api.d.ts +2 -0
  16. package/dist/functions/converters/convert-chat-mix-balance-to-user.d.ts +2 -0
  17. package/dist/functions/converters/convert-profile-channel-to-api.d.ts +3 -0
  18. package/dist/functions/converters/convert-profile-channel-to-user.d.ts +3 -0
  19. package/dist/functions/converters/convert-volume-to-api.d.ts +1 -0
  20. package/dist/functions/converters/convert-volume-to-user.d.ts +1 -0
  21. package/dist/functions/devices/get-audio-devices.d.ts +3 -0
  22. package/dist/functions/devices/set-audio-device.d.ts +3 -0
  23. package/dist/functions/endpoint/get-app-endpoint.d.ts +14 -0
  24. package/dist/functions/endpoint/get-sonar-endpoint-cached.d.ts +1 -0
  25. package/dist/functions/endpoint/get-sonar-endpoint.d.ts +14 -0
  26. package/dist/functions/profile/get-channel-profiles.d.ts +3 -0
  27. package/dist/functions/profile/get-selected-profiles.d.ts +2 -0
  28. package/dist/functions/profile/set-selected-profile.d.ts +2 -0
  29. package/dist/index.d.ts +29 -0
  30. package/dist/index.js +874 -0
  31. package/{src/sonar/models/audio-settings/chatmix-data.ts → dist/sonar/models/audio-settings/chatmix-data.d.ts} +4 -5
  32. package/dist/sonar/models/audio-settings/enums/audio-mode.d.ts +4 -0
  33. package/dist/sonar/models/audio-settings/enums/chat-mix-state.d.ts +6 -0
  34. package/dist/sonar/models/audio-settings/enums/device-data-flow.d.ts +5 -0
  35. package/dist/sonar/models/audio-settings/enums/device-default-roles.d.ts +6 -0
  36. package/dist/sonar/models/audio-settings/enums/device-role.d.ts +9 -0
  37. package/dist/sonar/models/audio-settings/enums/device-state.d.ts +8 -0
  38. package/dist/sonar/models/audio-settings/enums/sonar-channel.d.ts +8 -0
  39. package/dist/sonar/models/audio-settings/enums/streaming-path.d.ts +4 -0
  40. package/dist/sonar/models/audio-settings/volume-info-classic.d.ts +4 -0
  41. package/dist/sonar/models/audio-settings/volume-info-streamer.d.ts +10 -0
  42. package/dist/sonar/models/audio-settings/volume-settings-classic.d.ts +9 -0
  43. package/dist/sonar/models/audio-settings/volume-settings-streamer.d.ts +9 -0
  44. package/dist/sonar/models/config/config.d.ts +8 -0
  45. package/dist/sonar/models/config/enums/VirtualAudioDevice.d.ts +7 -0
  46. package/dist/sonar/models/devices/audio-device.d.ts +16 -0
  47. package/dist/sonar/models/devices/changed-device.d.ts +6 -0
  48. package/dist/sonar/requests/audio-devices/change-audio-device.d.ts +3 -0
  49. package/dist/sonar/requests/audio-devices/request-audio-devices.d.ts +9 -0
  50. package/dist/sonar/requests/chatmix/change-chat-mix-balance.d.ts +2 -0
  51. package/dist/sonar/requests/chatmix/request-chat-mix-state.d.ts +2 -0
  52. package/dist/sonar/requests/mode/change-audio-mode.d.ts +2 -0
  53. package/dist/sonar/requests/mode/request-audio-mode.d.ts +2 -0
  54. package/dist/sonar/requests/profiles/change-selected-config.d.ts +2 -0
  55. package/dist/sonar/requests/profiles/request-configs.d.ts +3 -0
  56. package/dist/sonar/requests/profiles/request-selected-configs.d.ts +2 -0
  57. package/dist/sonar/requests/volume-settings/change-volume-level-classic.d.ts +3 -0
  58. package/dist/sonar/requests/volume-settings/change-volume-level-streamer.d.ts +4 -0
  59. package/dist/sonar/requests/volume-settings/change-volume-mute-classic.d.ts +3 -0
  60. package/dist/sonar/requests/volume-settings/change-volume-mute-streamer.d.ts +4 -0
  61. package/dist/sonar/requests/volume-settings/request-volume-settings-classic.d.ts +2 -0
  62. package/dist/sonar/requests/volume-settings/request-volume-settings-streamer.d.ts +2 -0
  63. package/dist/types/audio-device.d.ts +6 -0
  64. package/dist/types/changed-device.d.ts +6 -0
  65. package/dist/types/channel-volume-classic.d.ts +4 -0
  66. package/dist/types/channel-volume-streamer-path.d.ts +4 -0
  67. package/dist/types/channel-volume-streamer.d.ts +5 -0
  68. package/dist/types/channel-volumes-classic.d.ts +7 -0
  69. package/dist/types/channel-volumes-streamer.d.ts +7 -0
  70. package/dist/types/chat-mix-data.d.ts +6 -0
  71. package/dist/types/profile-option.d.ts +8 -0
  72. package/package.json +7 -3
  73. package/.gitattributes +0 -8
  74. package/.github/workflows/tests.yml +0 -18
  75. package/.vscode/extensions.json +0 -8
  76. package/.vscode/settings.json +0 -33
  77. package/_.todo +0 -4
  78. package/biome.json +0 -62
  79. package/http/sonar.http +0 -104
  80. package/src/consts/fetch-options-put.ts +0 -3
  81. package/src/exceptions.ts +0 -45
  82. package/src/functions/audio/get-audio-data-classic.ts +0 -31
  83. package/src/functions/audio/get-audio-data-stream.ts +0 -37
  84. package/src/functions/audio/get-audio-mode.ts +0 -11
  85. package/src/functions/audio/set-audio-mode.ts +0 -12
  86. package/src/functions/audio/set-channel-mute-classic.ts +0 -35
  87. package/src/functions/audio/set-channel-mute-streamer.ts +0 -41
  88. package/src/functions/audio/set-channel-volume-classic.ts +0 -37
  89. package/src/functions/audio/set-channel-volume-streamer.ts +0 -43
  90. package/src/functions/chatmix/get-chat-mix-state.ts +0 -20
  91. package/src/functions/chatmix/set-chat-mix-balance.ts +0 -22
  92. package/src/functions/converters/convert-channel-to-api.ts +0 -19
  93. package/src/functions/converters/convert-chat-mix-balance-to-api.ts +0 -6
  94. package/src/functions/converters/convert-chat-mix-balance-to-user.ts +0 -7
  95. package/src/functions/converters/convert-profile-channel-to-api.ts +0 -19
  96. package/src/functions/converters/convert-profile-channel-to-user.ts +0 -19
  97. package/src/functions/converters/convert-volume-to-api.ts +0 -5
  98. package/src/functions/converters/convert-volume-to-user.ts +0 -6
  99. package/src/functions/devices/get-audio-devices.ts +0 -40
  100. package/src/functions/devices/set-audio-device.ts +0 -19
  101. package/src/functions/endpoint/get-app-endpoint.ts +0 -73
  102. package/src/functions/endpoint/get-sonar-endpoint-cached.ts +0 -28
  103. package/src/functions/endpoint/get-sonar-endpoint.ts +0 -88
  104. package/src/functions/profile/get-channel-profiles.ts +0 -26
  105. package/src/functions/profile/get-selected-profiles.ts +0 -17
  106. package/src/functions/profile/set-selected-profile.ts +0 -17
  107. package/src/index.ts +0 -41
  108. package/src/sonar/models/audio-settings/enums/audio-mode.ts +0 -4
  109. package/src/sonar/models/audio-settings/enums/chat-mix-state.ts +0 -6
  110. package/src/sonar/models/audio-settings/enums/device-data-flow.ts +0 -5
  111. package/src/sonar/models/audio-settings/enums/device-default-roles.ts +0 -6
  112. package/src/sonar/models/audio-settings/enums/device-role.ts +0 -9
  113. package/src/sonar/models/audio-settings/enums/device-state.ts +0 -8
  114. package/src/sonar/models/audio-settings/enums/sonar-channel.ts +0 -8
  115. package/src/sonar/models/audio-settings/enums/streaming-path.ts +0 -4
  116. package/src/sonar/models/audio-settings/volume-info-classic.ts +0 -4
  117. package/src/sonar/models/audio-settings/volume-info-streamer.ts +0 -10
  118. package/src/sonar/models/audio-settings/volume-settings-classic.ts +0 -13
  119. package/src/sonar/models/audio-settings/volume-settings-streamer.ts +0 -13
  120. package/src/sonar/models/config/config.ts +0 -9
  121. package/src/sonar/models/config/enums/VirtualAudioDevice.ts +0 -7
  122. package/src/sonar/models/devices/audio-device.ts +0 -17
  123. package/src/sonar/models/devices/changed-device.ts +0 -7
  124. package/src/sonar/requests/audio-devices/change-audio-device.ts +0 -37
  125. package/src/sonar/requests/audio-devices/request-audio-devices.ts +0 -42
  126. package/src/sonar/requests/chatmix/change-chat-mix-balance.ts +0 -25
  127. package/src/sonar/requests/chatmix/request-chat-mix-state.ts +0 -24
  128. package/src/sonar/requests/mode/change-audio-mode.ts +0 -24
  129. package/src/sonar/requests/mode/request-audio-mode.ts +0 -24
  130. package/src/sonar/requests/profiles/change-selected-config.ts +0 -25
  131. package/src/sonar/requests/profiles/request-configs.ts +0 -24
  132. package/src/sonar/requests/profiles/request-selected-configs.ts +0 -22
  133. package/src/sonar/requests/volume-settings/change-volume-level-classic.ts +0 -27
  134. package/src/sonar/requests/volume-settings/change-volume-level-streamer.ts +0 -29
  135. package/src/sonar/requests/volume-settings/change-volume-mute-classic.ts +0 -27
  136. package/src/sonar/requests/volume-settings/change-volume-mute-streamer.ts +0 -29
  137. package/src/sonar/requests/volume-settings/request-volume-settings-classic.ts +0 -22
  138. package/src/sonar/requests/volume-settings/request-volume-settings-streamer.ts +0 -22
  139. package/src/types/audio-device.ts +0 -7
  140. package/src/types/changed-device.ts +0 -7
  141. package/src/types/channel-volume-classic.ts +0 -4
  142. package/src/types/channel-volume-streamer-path.ts +0 -4
  143. package/src/types/channel-volume-streamer.ts +0 -6
  144. package/src/types/channel-volumes-classic.ts +0 -8
  145. package/src/types/channel-volumes-streamer.ts +0 -8
  146. package/src/types/chat-mix-data.ts +0 -7
  147. package/src/types/profile-option.ts +0 -9
  148. package/tests/e2e/audio/get-audio-data-classic.real.test.ts +0 -11
  149. package/tests/e2e/audio/get-audio-data-stream.real.test.ts +0 -11
  150. package/tests/e2e/audio/get-audio-mode.real.test.ts +0 -12
  151. package/tests/e2e/audio/set-audio-mode.real.test.ts +0 -20
  152. package/tests/e2e/audio/set-channel-mute-classic.real.test.ts +0 -18
  153. package/tests/e2e/audio/set-channel-mute-streamer.real.test.ts +0 -18
  154. package/tests/e2e/audio/set-channel-volume-classic.real.test.ts +0 -17
  155. package/tests/e2e/audio/set-channel-volume-streamer.real.test.ts +0 -22
  156. package/tests/e2e/chatmix/get-chat-mix-state.real.test.ts +0 -25
  157. package/tests/e2e/chatmix/set-chat-mix-balance.real.test.ts +0 -25
  158. package/tests/e2e/devices/get-audio-devices.real.test.ts +0 -29
  159. package/tests/e2e/devices/set-audio-device.real.test.ts +0 -32
  160. package/tests/e2e/enpoint/get-app-endpoint.real.test.ts +0 -19
  161. package/tests/e2e/enpoint/get-sonar-endpoint-cached.real.test.ts +0 -32
  162. package/tests/e2e/enpoint/get-sonar-endpoint.real.test.ts +0 -21
  163. package/tests/e2e/profiles/get-channel-profiles.real.test.ts +0 -21
  164. package/tests/e2e/profiles/get-selected-profiles.real.test.ts +0 -11
  165. package/tests/e2e/profiles/set-selected-profile.real.test.ts +0 -17
  166. package/tests/helpers/get-endpoint-e2e.ts +0 -8
  167. package/tests/unit/audio/get-audio-data-classic.test.ts +0 -57
  168. package/tests/unit/audio/get-audio-data-stream.test.ts +0 -65
  169. package/tests/unit/audio/get-audio-mode.test.ts +0 -58
  170. package/tests/unit/audio/set-audio-mode.test.ts +0 -66
  171. package/tests/unit/audio/set-channel-mute-classic.test.ts +0 -58
  172. package/tests/unit/audio/set-channel-mute-streamer.test.ts +0 -64
  173. package/tests/unit/audio/set-channel-volume-classic.test.ts +0 -58
  174. package/tests/unit/audio/set-channel-volume-streamer.test.ts +0 -64
  175. package/tests/unit/chatmix/get-chat-mix-state.test.ts +0 -70
  176. package/tests/unit/chatmix/set-chat-mix-balance.test.ts +0 -58
  177. package/tests/unit/devices/get-audio-devices.test.ts +0 -59
  178. package/tests/unit/devices/set-audio-devices.test.ts +0 -62
  179. package/tests/unit/endpoint/get-app-endpoint.test.ts +0 -72
  180. package/tests/unit/endpoint/get-sonar-endpoint-cached.test.ts +0 -93
  181. package/tests/unit/endpoint/get-sonar-endpoint.test.ts +0 -140
  182. package/tests/unit/profiles/get-channel-profiles.test.ts +0 -91
  183. package/tests/unit/profiles/get-selected-profiles.test.ts +0 -64
  184. package/tests/unit/profiles/set-selected-profile.test.ts +0 -55
  185. package/tsconfig.json +0 -36
@@ -1,26 +0,0 @@
1
- import type { ProfileChannel } from '@/enums'
2
- import { convertProfileChannelToApi } from '@/functions/converters/convert-profile-channel-to-api'
3
- import { convertProfileChannelToUser } from '@/functions/converters/convert-profile-channel-to-user'
4
- import { requestConfigs } from '@/sonar/requests/profiles/request-configs'
5
- import type { ProfileOption } from '@/types/profile-option'
6
-
7
- export async function getChannelProfiles(
8
- sonarAddress: string,
9
- channel: ProfileChannel,
10
- favoritesOnly?: boolean
11
- ): Promise<ProfileOption[]> {
12
- const vad = convertProfileChannelToApi(channel)
13
- const data = await requestConfigs(sonarAddress, vad)
14
- const workingSetData = favoritesOnly ? data.filter((x) => x.isFavorite) : data
15
-
16
- return workingSetData.map((x) => {
17
- const profile: ProfileOption = {
18
- id: x.id,
19
- name: x.name,
20
- isFavorite: x.isFavorite,
21
- channel: convertProfileChannelToUser(x.virtualAudioDevice),
22
- image: x.image
23
- }
24
- return profile
25
- })
26
- }
@@ -1,17 +0,0 @@
1
- import { convertProfileChannelToUser } from '@/functions/converters/convert-profile-channel-to-user'
2
- import { requestSelectedConfigs } from '@/sonar/requests/profiles/request-selected-configs'
3
- import type { ProfileOption } from '@/types/profile-option'
4
-
5
- export async function getSelectedProfiles(sonarAddress: string): Promise<ProfileOption[]> {
6
- const data = await requestSelectedConfigs(sonarAddress)
7
- return data.map((x) => {
8
- const profile: ProfileOption = {
9
- id: x.id,
10
- name: x.name,
11
- isFavorite: x.isFavorite,
12
- channel: convertProfileChannelToUser(x.virtualAudioDevice),
13
- image: x.image
14
- }
15
- return profile
16
- })
17
- }
@@ -1,17 +0,0 @@
1
- import { convertProfileChannelToUser } from '@/functions/converters/convert-profile-channel-to-user'
2
- import { changeSelectedConfig } from '@/sonar/requests/profiles/change-selected-config'
3
- import type { ProfileOption } from '@/types/profile-option'
4
-
5
- export async function setSelectedProfile(sonarAddress: string, profileId: string): Promise<ProfileOption> {
6
- const data = await changeSelectedConfig(sonarAddress, profileId)
7
-
8
- const result: ProfileOption = {
9
- id: data.id,
10
- name: data.name,
11
- isFavorite: data.isFavorite,
12
- channel: convertProfileChannelToUser(data.virtualAudioDevice),
13
- image: data.image
14
- }
15
-
16
- return result
17
- }
package/src/index.ts DELETED
@@ -1,41 +0,0 @@
1
- export * from '@/enums'
2
- export * from '@/exceptions'
3
-
4
- // Audio
5
- export * from '@/functions/audio/get-audio-data-classic'
6
- export * from '@/functions/audio/get-audio-data-stream'
7
- export * from '@/functions/audio/get-audio-mode'
8
- export * from '@/functions/audio/set-audio-mode'
9
- export * from '@/functions/audio/set-channel-mute-classic'
10
- export * from '@/functions/audio/set-channel-mute-streamer'
11
- export * from '@/functions/audio/set-channel-volume-classic'
12
- export * from '@/functions/audio/set-channel-volume-streamer'
13
-
14
- // Chatmix
15
- export * from '@/functions/chatmix/get-chat-mix-state'
16
- export * from '@/functions/chatmix/set-chat-mix-balance'
17
-
18
- // Devices
19
- export * from '@/functions/devices/get-audio-devices'
20
- export * from '@/functions/devices/set-audio-device'
21
-
22
- // Endpoint
23
- export * from '@/functions/endpoint/get-app-endpoint'
24
- export * from '@/functions/endpoint/get-sonar-endpoint'
25
- export * from '@/functions/endpoint/get-sonar-endpoint-cached'
26
-
27
- // Profile
28
- export * from '@/functions/profile/get-channel-profiles'
29
- export * from '@/functions/profile/get-selected-profiles'
30
- export * from '@/functions/profile/set-selected-profile'
31
-
32
- // Types
33
- export * from '@/types/audio-device'
34
- export * from '@/types/changed-device'
35
- export * from '@/types/channel-volume-classic'
36
- export * from '@/types/channel-volume-streamer'
37
- export * from '@/types/channel-volume-streamer-path'
38
- export * from '@/types/channel-volumes-classic'
39
- export * from '@/types/channel-volumes-streamer'
40
- export * from '@/types/chat-mix-data'
41
- export * from '@/types/profile-option'
@@ -1,4 +0,0 @@
1
- export enum AudioMode {
2
- Classic = 'classic',
3
- Streamer = 'stream'
4
- }
@@ -1,6 +0,0 @@
1
- export enum ChatMixState {
2
- Enabled = 'enabled',
3
- FiniteWheel = 'finiteWheel',
4
- DifferentDeviceSelected = 'differentDeviceSelected',
5
- NoDeviceSelected = 'noDeviceSelected'
6
- }
@@ -1,5 +0,0 @@
1
- export enum DeviceDataFlow {
2
- Render = 'render',
3
- Capture = 'capture',
4
- All = 'all'
5
- }
@@ -1,6 +0,0 @@
1
- export enum DeviceDefaultRoles {
2
- Console = 0,
3
- Multimedia = 1,
4
- Communications = 2,
5
- All = Communications | Multimedia // 0x00000003
6
- }
@@ -1,9 +0,0 @@
1
- export enum DeviceRole {
2
- None = 'none',
3
- ChatRender = 'chatRender',
4
- Game = 'game',
5
- ChatCapture = 'chatCapture',
6
- Stream = 'stream',
7
- Media = 'media',
8
- Aux = 'aux'
9
- }
@@ -1,8 +0,0 @@
1
- export enum DeviceState {
2
- Active = 1,
3
- Disabled = 2,
4
- ActiveOrDisabled = 3,
5
- Notpresent = 4,
6
- Unplugged = 8,
7
- All = 15 // 0x0000000F
8
- }
@@ -1,8 +0,0 @@
1
- export enum SonarChannel {
2
- Master = 'master',
3
- ChatRender = 'chatRender',
4
- Game = 'game',
5
- ChatCapture = 'chatCapture',
6
- Media = 'media',
7
- Aux = 'aux'
8
- }
@@ -1,4 +0,0 @@
1
- export enum StreamingPath {
2
- Streaming = 'streaming',
3
- Monitoring = 'monitoring'
4
- }
@@ -1,4 +0,0 @@
1
- export type VolumeInfoClassic = {
2
- volume: number
3
- muted: boolean
4
- }
@@ -1,10 +0,0 @@
1
- export type VolumeInfoStreamer = {
2
- streaming: {
3
- volume: number
4
- muted: boolean
5
- }
6
- monitoring: {
7
- volume: number
8
- muted: boolean
9
- }
10
- }
@@ -1,13 +0,0 @@
1
- import type { VolumeInfoClassic } from '@/sonar/models/audio-settings/volume-info-classic'
2
-
3
- export type VolumeSettingsClassic = {
4
- masters: {
5
- classic: VolumeInfoClassic
6
- }
7
- devices: Record<
8
- string,
9
- {
10
- classic: VolumeInfoClassic
11
- }
12
- >
13
- }
@@ -1,13 +0,0 @@
1
- import type { VolumeInfoStreamer } from '@/sonar/models/audio-settings/volume-info-streamer'
2
-
3
- export type VolumeSettingsStreamer = {
4
- masters: {
5
- stream: VolumeInfoStreamer
6
- }
7
- devices: Record<
8
- string,
9
- {
10
- stream: VolumeInfoStreamer
11
- }
12
- >
13
- }
@@ -1,9 +0,0 @@
1
- import type { VirtualAudioDevice } from '@/sonar/models/config/enums/VirtualAudioDevice'
2
-
3
- export type Config = {
4
- id: string
5
- name: string
6
- isFavorite: boolean
7
- virtualAudioDevice: VirtualAudioDevice
8
- image?: string
9
- }
@@ -1,7 +0,0 @@
1
- export enum VirtualAudioDevice {
2
- Game = 'game',
3
- ChatRender = 'chatRender',
4
- ChatCapture = 'chatCapture',
5
- Media = 'media',
6
- Aux = 'aux'
7
- }
@@ -1,17 +0,0 @@
1
- import type { DeviceDataFlow } from '@/sonar/models/audio-settings/enums/device-data-flow'
2
- import type { DeviceDefaultRoles } from '@/sonar/models/audio-settings/enums/device-default-roles'
3
- import type { DeviceRole } from '@/sonar/models/audio-settings/enums/device-role'
4
- import type { DeviceState } from '@/sonar/models/audio-settings/enums/device-state'
5
-
6
- export type AudioDevice = {
7
- id: string
8
- friendlyName: string
9
- dataFlow: DeviceDataFlow
10
- role: DeviceRole
11
- channels: number
12
- defaultRole: DeviceDefaultRoles
13
- fwUpdateRequired: boolean
14
- state: DeviceState
15
- /** `true` if {@link DeviceRole} ≠ {@link DeviceRole.None} */
16
- isVad: boolean
17
- }
@@ -1,7 +0,0 @@
1
- import type { DeviceChannel } from '@/enums'
2
-
3
- export type ChangedDevice = {
4
- id: Exclude<DeviceChannel, DeviceChannel.Output>
5
- deviceId: string
6
- isRunning: boolean
7
- }
@@ -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
- }