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,58 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it } from 'bun:test'
2
- import { AudioMode } from '@/enums'
3
- import { SonarRequestException } from '@/exceptions'
4
- import { getAudioMode } from '@/functions/audio/get-audio-mode'
5
-
6
- let originalFetch: typeof fetch
7
-
8
- const request = () => getAudioMode('https://localhost')
9
-
10
- describe('getAudioMode', () => {
11
- beforeEach(() => {
12
- originalFetch = globalThis.fetch
13
- })
14
-
15
- afterEach(() => {
16
- globalThis.fetch = originalFetch
17
- })
18
-
19
- it('throws SonarException when response not 200', async () => {
20
- globalThis.fetch = (async () =>
21
- ({
22
- ok: false,
23
- text: async () => 'Some error occurred'
24
- }) as Response) as unknown as typeof fetch
25
-
26
- expect(request()).rejects.toThrow(SonarRequestException)
27
- })
28
-
29
- it('throws SonarException when response 200 but not data', async () => {
30
- globalThis.fetch = (async () =>
31
- ({
32
- ok: true,
33
- json: async () => ({})
34
- }) as Response) as unknown as typeof fetch
35
-
36
- expect(request()).rejects.toThrow(SonarRequestException)
37
- })
38
-
39
- it('return classic when response 200', async () => {
40
- globalThis.fetch = (async () =>
41
- ({
42
- ok: true,
43
- json: async () => AudioMode.Classic
44
- }) as Response) as unknown as typeof fetch
45
-
46
- expect(request()).resolves.toBe(AudioMode.Classic)
47
- })
48
-
49
- it('return streamer when response 200', async () => {
50
- globalThis.fetch = (async () =>
51
- ({
52
- ok: true,
53
- json: async () => AudioMode.Streamer
54
- }) as Response) as unknown as typeof fetch
55
-
56
- expect(request()).resolves.toBe(AudioMode.Streamer)
57
- })
58
- })
@@ -1,66 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it } from 'bun:test'
2
- import { AudioMode } from '@/enums'
3
- import { SonarRequestException } from '@/exceptions'
4
- import { setAudioMode } from '@/functions/audio/set-audio-mode'
5
-
6
- let originalFetch: typeof fetch
7
-
8
- const request = (mode: AudioMode) => setAudioMode('https://localhost', mode)
9
-
10
- describe('setAudioMode', () => {
11
- beforeEach(() => {
12
- originalFetch = globalThis.fetch
13
- })
14
-
15
- afterEach(() => {
16
- globalThis.fetch = originalFetch
17
- })
18
-
19
- it('throws SonarException when response not 200', async () => {
20
- globalThis.fetch = (async () =>
21
- ({
22
- ok: false,
23
- text: async () => 'Some error occurred'
24
- }) as Response) as unknown as typeof fetch
25
-
26
- const method = request(AudioMode.Classic)
27
-
28
- expect(method).rejects.toThrow(SonarRequestException)
29
- })
30
-
31
- it('throws SonarException when response 200 but not data', async () => {
32
- globalThis.fetch = (async () =>
33
- ({
34
- ok: true,
35
- json: async () => ({})
36
- }) as Response) as unknown as typeof fetch
37
-
38
- const method = request(AudioMode.Classic)
39
-
40
- expect(method).rejects.toThrow(SonarRequestException)
41
- })
42
-
43
- it('return classic when response 200', async () => {
44
- globalThis.fetch = (async () =>
45
- ({
46
- ok: true,
47
- json: async () => AudioMode.Classic
48
- }) as Response) as unknown as typeof fetch
49
-
50
- const method = request(AudioMode.Classic)
51
-
52
- expect(method).resolves.toBe(AudioMode.Classic)
53
- })
54
-
55
- it('return streamer when response 200', async () => {
56
- globalThis.fetch = (async () =>
57
- ({
58
- ok: true,
59
- json: async () => AudioMode.Streamer
60
- }) as Response) as unknown as typeof fetch
61
-
62
- const method = request(AudioMode.Streamer)
63
-
64
- expect(method).resolves.toBe(AudioMode.Streamer)
65
- })
66
- })
@@ -1,58 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it } from 'bun:test'
2
- import { AudioChannel } from '@/enums'
3
- import { SonarRequestException } from '@/exceptions'
4
- import { setChannelMuteClassic } from '@/functions/audio/set-channel-mute-classic'
5
-
6
- let originalFetch: typeof fetch
7
-
8
- const request = () => setChannelMuteClassic('https://localhost', true, AudioChannel.Master)
9
-
10
- describe('setChannelMuteClassic', () => {
11
- beforeEach(() => {
12
- originalFetch = globalThis.fetch
13
- })
14
-
15
- afterEach(() => {
16
- globalThis.fetch = originalFetch
17
- })
18
-
19
- it('throws SonarException when response not 200', async () => {
20
- globalThis.fetch = (async () =>
21
- ({
22
- ok: false,
23
- json: async () => 'Some error occurred'
24
- }) as Response) as unknown as typeof fetch
25
-
26
- expect(request()).rejects.toThrow(SonarRequestException)
27
- })
28
-
29
- it('throws SonarException when response 200 but not data', async () => {
30
- globalThis.fetch = (async () =>
31
- ({
32
- ok: true,
33
- json: async () => ({})
34
- }) as Response) as unknown as typeof fetch
35
-
36
- expect(request()).rejects.toThrow(SonarRequestException)
37
- })
38
-
39
- it('return data when response 200', async () => {
40
- globalThis.fetch = (async () =>
41
- ({
42
- ok: true,
43
- json: async () => ({
44
- masters: {
45
- classic: {
46
- volume: 0.49,
47
- muted: false
48
- }
49
- },
50
- devices: {}
51
- })
52
- }) as Response) as unknown as typeof fetch
53
-
54
- const response = await request()
55
- expect(response.volume).toBe(49)
56
- expect(response.isMuted).toBe(false)
57
- })
58
- })
@@ -1,64 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it } from 'bun:test'
2
- import { AudioChannel, StreamerPath } from '@/enums'
3
- import { SonarRequestException } from '@/exceptions'
4
- import { setChannelMuteStreamer } from '@/functions/audio/set-channel-mute-streamer'
5
-
6
- let originalFetch: typeof fetch
7
-
8
- const request = () => setChannelMuteStreamer('https://localhost', false, AudioChannel.Master, StreamerPath.Streaming)
9
-
10
- describe('setChannelMuteStreamer', () => {
11
- beforeEach(() => {
12
- originalFetch = globalThis.fetch
13
- })
14
-
15
- afterEach(() => {
16
- globalThis.fetch = originalFetch
17
- })
18
-
19
- it('throws SonarException when response not 200', async () => {
20
- globalThis.fetch = (async () =>
21
- ({
22
- ok: false,
23
- json: async () => 'Some error occurred'
24
- }) as Response) as unknown as typeof fetch
25
-
26
- expect(request()).rejects.toThrow(SonarRequestException)
27
- })
28
-
29
- it('throws SonarException when response 200 but not data', async () => {
30
- globalThis.fetch = (async () =>
31
- ({
32
- ok: true,
33
- json: async () => ({})
34
- }) as Response) as unknown as typeof fetch
35
-
36
- expect(request()).rejects.toThrow(SonarRequestException)
37
- })
38
-
39
- it('return data when response 200', async () => {
40
- globalThis.fetch = (async () =>
41
- ({
42
- ok: true,
43
- json: async () => ({
44
- masters: {
45
- stream: {
46
- streaming: {
47
- volume: 0.49,
48
- muted: true
49
- },
50
- monitoring: {
51
- volume: 0.48,
52
- muted: false
53
- }
54
- }
55
- },
56
- devices: {}
57
- })
58
- }) as Response) as unknown as typeof fetch
59
-
60
- const response = await request()
61
- expect(response.volume).toBe(49)
62
- expect(response.isMuted).toBe(true)
63
- })
64
- })
@@ -1,58 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it } from 'bun:test'
2
- import { AudioChannel } from '@/enums'
3
- import { SonarRequestException } from '@/exceptions'
4
- import { setChannelVolumeClassic } from '@/functions/audio/set-channel-volume-classic'
5
-
6
- let originalFetch: typeof fetch
7
-
8
- const request = () => setChannelVolumeClassic('https://localhost', 75, AudioChannel.Master)
9
-
10
- describe('setChannelVolumeClassic', () => {
11
- beforeEach(() => {
12
- originalFetch = globalThis.fetch
13
- })
14
-
15
- afterEach(() => {
16
- globalThis.fetch = originalFetch
17
- })
18
-
19
- it('throws SonarException when response not 200', async () => {
20
- globalThis.fetch = (async () =>
21
- ({
22
- ok: false,
23
- json: async () => 'Some error occurred'
24
- }) as Response) as unknown as typeof fetch
25
-
26
- expect(request()).rejects.toThrow(SonarRequestException)
27
- })
28
-
29
- it('throws SonarException when response 200 but not data', async () => {
30
- globalThis.fetch = (async () =>
31
- ({
32
- ok: true,
33
- json: async () => ({})
34
- }) as Response) as unknown as typeof fetch
35
-
36
- expect(request()).rejects.toThrow(SonarRequestException)
37
- })
38
-
39
- it('return data when response 200', async () => {
40
- globalThis.fetch = (async () =>
41
- ({
42
- ok: true,
43
- json: async () => ({
44
- masters: {
45
- classic: {
46
- volume: 0.49,
47
- muted: false
48
- }
49
- },
50
- devices: {}
51
- })
52
- }) as Response) as unknown as typeof fetch
53
-
54
- const response = await request()
55
- expect(response.volume).toBe(49)
56
- expect(response.isMuted).toBe(false)
57
- })
58
- })
@@ -1,64 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it } from 'bun:test'
2
- import { AudioChannel, StreamerPath } from '@/enums'
3
- import { SonarRequestException } from '@/exceptions'
4
- import { setChannelVolumeStreamer } from '@/functions/audio/set-channel-volume-streamer'
5
-
6
- let originalFetch: typeof fetch
7
-
8
- const request = () => setChannelVolumeStreamer('https://localhost', 75, AudioChannel.Master, StreamerPath.Streaming)
9
-
10
- describe('setChannelVolumeStreamer', () => {
11
- beforeEach(() => {
12
- originalFetch = globalThis.fetch
13
- })
14
-
15
- afterEach(() => {
16
- globalThis.fetch = originalFetch
17
- })
18
-
19
- it('throws SonarException when response not 200', async () => {
20
- globalThis.fetch = (async () =>
21
- ({
22
- ok: false,
23
- json: async () => 'Some error occurred'
24
- }) as Response) as unknown as typeof fetch
25
-
26
- expect(request()).rejects.toThrow(SonarRequestException)
27
- })
28
-
29
- it('throws SonarException when response 200 but not data', async () => {
30
- globalThis.fetch = (async () =>
31
- ({
32
- ok: true,
33
- json: async () => ({})
34
- }) as Response) as unknown as typeof fetch
35
-
36
- expect(request()).rejects.toThrow(SonarRequestException)
37
- })
38
-
39
- it('return data when response 200', async () => {
40
- globalThis.fetch = (async () =>
41
- ({
42
- ok: true,
43
- json: async () => ({
44
- masters: {
45
- stream: {
46
- streaming: {
47
- volume: 0.49,
48
- muted: true
49
- },
50
- monitoring: {
51
- volume: 0.48,
52
- muted: false
53
- }
54
- }
55
- },
56
- devices: {}
57
- })
58
- }) as Response) as unknown as typeof fetch
59
-
60
- const response = await request()
61
- expect(response.volume).toBe(49)
62
- expect(response.isMuted).toBe(true)
63
- })
64
- })
@@ -1,70 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it } from 'bun:test'
2
- import { ChatMixState } from '@/enums'
3
- import { SonarRequestException } from '@/exceptions'
4
- import { getChatMixState } from '@/functions/chatmix/get-chat-mix-state'
5
-
6
- let originalFetch: typeof fetch
7
-
8
- const request = () => getChatMixState('http://localhost')
9
-
10
- describe('getChatMixState', () => {
11
- beforeEach(() => {
12
- originalFetch = globalThis.fetch
13
- })
14
-
15
- afterEach(() => {
16
- globalThis.fetch = originalFetch
17
- })
18
-
19
- it('throws SonarException when response not 200', async () => {
20
- globalThis.fetch = (async () =>
21
- ({
22
- ok: false,
23
- text: async () => 'Some error occurred'
24
- }) as Response) as unknown as typeof fetch
25
-
26
- expect(request()).rejects.toThrow(SonarRequestException)
27
- })
28
-
29
- it('throws SonarException when response 200 but not data', async () => {
30
- globalThis.fetch = (async () =>
31
- ({
32
- ok: true,
33
- json: async () => ({})
34
- }) as Response) as unknown as typeof fetch
35
-
36
- expect(request()).rejects.toThrow(SonarRequestException)
37
- })
38
-
39
- it('return data when classic and response 200', async () => {
40
- globalThis.fetch = (async () =>
41
- ({
42
- ok: true,
43
- json: async () => ({
44
- balance: 0.5,
45
- state: ChatMixState.Enabled
46
- })
47
- }) as Response) as unknown as typeof fetch
48
-
49
- const response = await request()
50
- expect(response.chatBalance).toBe(75)
51
- expect(response.state).toBe(ChatMixState.Enabled)
52
- expect(response.isEnabled).toBeTrue()
53
- })
54
-
55
- it('return data when streamer and response 200', async () => {
56
- globalThis.fetch = (async () =>
57
- ({
58
- ok: true,
59
- json: async () => ({
60
- balance: 0.5,
61
- state: ChatMixState.FiniteWheel
62
- })
63
- }) as Response) as unknown as typeof fetch
64
-
65
- const response = await request()
66
- expect(response.chatBalance).toBe(75)
67
- expect(response.state).toBe(ChatMixState.FiniteWheel)
68
- expect(response.isEnabled).toBeFalse()
69
- })
70
- })
@@ -1,58 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it } from 'bun:test'
2
- import { ChatMixState } from '@/enums'
3
- import { SonarRequestException } from '@/exceptions'
4
- import { setChatMixBalance } from '@/functions/chatmix/set-chat-mix-balance'
5
-
6
- let originalFetch: typeof fetch
7
-
8
- const request = (chatBalance: number) => setChatMixBalance('http://localhost', chatBalance)
9
-
10
- describe('setChatBalance', () => {
11
- beforeEach(() => {
12
- originalFetch = globalThis.fetch
13
- })
14
-
15
- afterEach(() => {
16
- globalThis.fetch = originalFetch
17
- })
18
-
19
- it('throws SonarException when response not 200', async () => {
20
- globalThis.fetch = (async () =>
21
- ({
22
- ok: false,
23
- json: async () => ({
24
- message: 'Some error occurred'
25
- })
26
- }) as Response) as unknown as typeof fetch
27
-
28
- expect(request(0)).rejects.toThrow(SonarRequestException)
29
- })
30
-
31
- it('throws SonarException when response 200 but not data', async () => {
32
- globalThis.fetch = (async () =>
33
- ({
34
- ok: true,
35
- json: async () => ({
36
- message: 'Some error occurred'
37
- })
38
- }) as Response) as unknown as typeof fetch
39
-
40
- expect(request(0)).rejects.toThrow(SonarRequestException)
41
- })
42
-
43
- it('return data when response 200', async () => {
44
- globalThis.fetch = (async () =>
45
- ({
46
- ok: true,
47
- json: async () => ({
48
- balance: 0.5,
49
- state: ChatMixState.Enabled
50
- })
51
- }) as Response) as unknown as typeof fetch
52
-
53
- const response = await request(0.5)
54
- expect(response.chatBalance).toBe(75)
55
- expect(response.state).toBe(ChatMixState.Enabled)
56
- expect(response.isEnabled).toBeTrue()
57
- })
58
- })
@@ -1,59 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it } from 'bun:test'
2
- import { SonarRequestException } from '@/exceptions'
3
- import { getAudioDevices } from '@/functions/devices/get-audio-devices'
4
-
5
- let originalFetch: typeof fetch
6
-
7
- const request = () => getAudioDevices('http://localhost')
8
-
9
- describe('getAudioDevices', () => {
10
- beforeEach(() => {
11
- originalFetch = globalThis.fetch
12
- })
13
-
14
- afterEach(() => {
15
- globalThis.fetch = originalFetch
16
- })
17
-
18
- it('throws SonarException when response not 200', async () => {
19
- globalThis.fetch = (async () =>
20
- ({
21
- ok: false,
22
- text: async () => 'Some error occurred'
23
- }) as Response) as unknown as typeof fetch
24
-
25
- expect(request()).rejects.toThrow(SonarRequestException)
26
- })
27
-
28
- it('throws SonarException when response 200 but not data', async () => {
29
- globalThis.fetch = (async () =>
30
- ({
31
- ok: true,
32
- json: async () => ({})
33
- }) as Response) as unknown as typeof fetch
34
-
35
- expect(request()).rejects.toThrow(SonarRequestException)
36
- })
37
-
38
- it('return data when response 200', async () => {
39
- globalThis.fetch = (async () =>
40
- ({
41
- ok: true,
42
- json: async () => [
43
- {
44
- friendlyName: 'Speakers',
45
- id: 'speaker',
46
- dataFlow: 'render'
47
- },
48
- {
49
- friendlyName: 'Microphone',
50
- id: 'mic',
51
- dataFlow: 'capture'
52
- }
53
- ]
54
- }) as Response) as unknown as typeof fetch
55
-
56
- const response = await request()
57
- expect(response.length).toBe(2)
58
- })
59
- })
@@ -1,62 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it } from 'bun:test'
2
- import { DeviceChannel } from '@/enums'
3
- import { SonarRequestException } from '@/exceptions'
4
- import { setAudioDevice } from '@/functions/devices/set-audio-device'
5
-
6
- let originalFetch: typeof fetch
7
-
8
- const request = () => setAudioDevice('http://localhost', DeviceChannel.Output, 'game_ID')
9
-
10
- describe('setAudioDevices', () => {
11
- beforeEach(() => {
12
- originalFetch = globalThis.fetch
13
- })
14
-
15
- afterEach(() => {
16
- globalThis.fetch = originalFetch
17
- })
18
-
19
- it('throws SonarException when response not 200', async () => {
20
- globalThis.fetch = (async () =>
21
- ({
22
- ok: false,
23
- text: async () => 'Some error occurred'
24
- }) as Response) as unknown as typeof fetch
25
-
26
- expect(request()).rejects.toThrow(SonarRequestException)
27
- })
28
-
29
- it('throws SonarException when response 200 but not data', async () => {
30
- globalThis.fetch = (async () =>
31
- ({
32
- ok: true,
33
- json: async () => ({})
34
- }) as Response) as unknown as typeof fetch
35
-
36
- expect(request()).rejects.toThrow(SonarRequestException)
37
- })
38
-
39
- it('return data when response 200', async () => {
40
- globalThis.fetch = (async () =>
41
- ({
42
- ok: true,
43
- json: async () => [
44
- {
45
- id: 'game',
46
- deviceId: 'game_ID',
47
- isRunning: true
48
- },
49
- {
50
- id: 'aux',
51
- deviceId: 'game_ID',
52
- isRunning: false
53
- }
54
- ]
55
- }) as Response) as unknown as typeof fetch
56
-
57
- const response = await request()
58
- expect(response.length).toBe(2)
59
- expect(response[0]?.deviceChannel).toBe(DeviceChannel.Game)
60
- expect(response[1]?.deviceChannel).toBe(DeviceChannel.Aux)
61
- })
62
- })
@@ -1,72 +0,0 @@
1
- import { describe, expect, it, mock } from 'bun:test'
2
- import { InitializeErrorReason, SonarInitializationException } from '../../../src/exceptions'
3
- import { getAppEndpoint } from '../../../src/functions/endpoint/get-app-endpoint'
4
-
5
- describe('getAppEndpoint', () => {
6
- it('throws Unsupported Exception on unsupported OS', async () => {
7
- mock.module('node:os', () => ({
8
- platform: () => 'linux'
9
- }))
10
- const rejects = expect(getAppEndpoint()).rejects
11
- rejects.toThrow(SonarInitializationException)
12
- rejects.toMatchObject({ reason: InitializeErrorReason.OSUnsupported })
13
- })
14
-
15
- it('throws BadConfig Exception when appData file does not exist', async () => {
16
- mock.module('node:os', () => ({
17
- platform: () => 'win32'
18
- }))
19
- mock.module('node:fs', () => ({
20
- promises: {
21
- readFile: async () => {
22
- throw new Error('File not found')
23
- }
24
- }
25
- }))
26
- const rejects = expect(getAppEndpoint()).rejects
27
- rejects.toThrow(SonarInitializationException)
28
- rejects.toMatchObject({ reason: InitializeErrorReason.BadConfig })
29
- })
30
-
31
- it('throws BadConfig Exception when appData file is invalid JSON', async () => {
32
- mock.module('node:os', () => ({
33
- platform: () => 'win32'
34
- }))
35
- mock.module('node:fs', () => ({
36
- promises: {
37
- readFile: async () => 'invalid json'
38
- }
39
- }))
40
- const rejects = expect(getAppEndpoint()).rejects
41
- rejects.toThrow(SonarInitializationException)
42
- rejects.toMatchObject({ reason: InitializeErrorReason.BadConfig })
43
- })
44
-
45
- it('throws BadConfig Exception when ggEncryptedAddress is missing', async () => {
46
- mock.module('node:os', () => ({
47
- platform: () => 'win32'
48
- }))
49
- mock.module('node:fs', () => ({
50
- promises: {
51
- readFile: async () => JSON.stringify({})
52
- }
53
- }))
54
- const rejects = expect(getAppEndpoint()).rejects
55
- rejects.toThrow(SonarInitializationException)
56
- rejects.toMatchObject({ reason: InitializeErrorReason.BadConfig })
57
- })
58
-
59
- it('returns ggEncryptedAddress when file is valid', async () => {
60
- const mockAddress = 'encrypted-address-123'
61
- const expectedUrl = `https://${mockAddress}`
62
- mock.module('node:os', () => ({
63
- platform: () => 'win32'
64
- }))
65
- mock.module('node:fs', () => ({
66
- promises: {
67
- readFile: async () => JSON.stringify({ ggEncryptedAddress: mockAddress })
68
- }
69
- }))
70
- expect(getAppEndpoint()).resolves.toBe(expectedUrl)
71
- })
72
- })