From 1711c5652b25b026f272fc5b614794598ce2db4a Mon Sep 17 00:00:00 2001 From: Salim Date: Sat, 30 Aug 2025 10:32:19 +0300 Subject: [PATCH 1/2] changed preferredFormat to a union instead of string --- src/xtream.ts | 4 +++- tests/main.test.ts | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/xtream.ts b/src/xtream.ts index 4dfa253..a8c1707 100644 --- a/src/xtream.ts +++ b/src/xtream.ts @@ -38,6 +38,8 @@ type Serializers = { */ type CustomSerializers = Partial; +export type PreferredFormat = 'ts' | 'm3u8' | 'rtmp'; + /** * Configuration options for initializing the Xtream API client. * @property url - Base URL of the Xtream API server @@ -49,7 +51,7 @@ type Options = { url: string; username: string; password: string; - preferredFormat?: string; + preferredFormat?: PreferredFormat; }; /** diff --git a/tests/main.test.ts b/tests/main.test.ts index 48cb6fe..cd23333 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -4,6 +4,7 @@ import { camelCaseSerializer } from '../src/serializers/camelcase.ts'; import { JSONAPISerializer } from '../src/serializers/jsonapi.ts'; import { standardizedSerializer } from '../src/serializers/standardized.ts'; import { server } from './msw.ts'; +import { PreferredFormat } from 'src/xtream.ts'; // Setup MSW beforeAll(() => server.listen({ onUnhandledRequest: 'error' })); @@ -219,7 +220,7 @@ describe('Xtream API', () => { url: 'http://example.com', username: 'test', password: 'password', - preferredFormat: 'nono', + preferredFormat: 'nono' as PreferredFormat, }); const stream = await formatXtream.getChannels({ page: 1, limit: 1 }); From b4159f9b4455fa0dfbcd2a59f19752f07ba9c247 Mon Sep 17 00:00:00 2001 From: Salim Date: Tue, 9 Sep 2025 07:44:18 +0300 Subject: [PATCH 2/2] chore: change PreferredFormat type to inline and remove type assertion in test --- src/xtream.ts | 4 +--- tests/main.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/xtream.ts b/src/xtream.ts index a8c1707..9073380 100644 --- a/src/xtream.ts +++ b/src/xtream.ts @@ -38,8 +38,6 @@ type Serializers = { */ type CustomSerializers = Partial; -export type PreferredFormat = 'ts' | 'm3u8' | 'rtmp'; - /** * Configuration options for initializing the Xtream API client. * @property url - Base URL of the Xtream API server @@ -51,7 +49,7 @@ type Options = { url: string; username: string; password: string; - preferredFormat?: PreferredFormat; + preferredFormat?: 'ts' | 'm3u8' | 'rtmp'; }; /** diff --git a/tests/main.test.ts b/tests/main.test.ts index cd23333..8659448 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -4,7 +4,6 @@ import { camelCaseSerializer } from '../src/serializers/camelcase.ts'; import { JSONAPISerializer } from '../src/serializers/jsonapi.ts'; import { standardizedSerializer } from '../src/serializers/standardized.ts'; import { server } from './msw.ts'; -import { PreferredFormat } from 'src/xtream.ts'; // Setup MSW beforeAll(() => server.listen({ onUnhandledRequest: 'error' })); @@ -220,7 +219,8 @@ describe('Xtream API', () => { url: 'http://example.com', username: 'test', password: 'password', - preferredFormat: 'nono' as PreferredFormat, + // @ts-expect-error: this should fail due to type checking + preferredFormat: 'nono', }); const stream = await formatXtream.getChannels({ page: 1, limit: 1 });