refactor(nx): created shared and m3u-utils library

This commit is contained in:
4gray committed 2025-10-10 11:49:35 +02:00
1 parent 99ed5df404
commit 920afa6850
59 files changed
+566 -225

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
import baseConfig from '../../../eslint.config.mjs';
export default [
...baseConfig,
{
files: ['**/*.json'],
rules: {
'@nx/dependency-checks': [
'error',
{
ignoredFiles: [
'{projectRoot}/eslint.config.{js,cjs,mjs,ts,cts,mts}',
],
},
],
},
languageOptions: {
parser: await import('jsonc-eslint-parser'),
},
},
];
+13
View File
@@ -0,0 +1,13 @@
export default {
displayName: 'shared-interfaces',
preset: '../../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': [
'ts-jest',
{ tsconfig: '<rootDir>/tsconfig.spec.json' },
],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../../coverage/libs/shared/interfaces',
};
+11
View File
@@ -0,0 +1,11 @@
{
"name": "shared-interfaces",
"version": "0.0.1",
"private": true,
"type": "commonjs",
"main": "./src/index.js",
"types": "./src/index.d.ts",
"dependencies": {
"tslib": "^2.3.0"
}
}
+26
View File
@@ -0,0 +1,26 @@
{
"name": "shared-interfaces",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/shared/interfaces/src",
"projectType": "library",
"tags": ["shared"],
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/shared/interfaces",
"main": "libs/shared/interfaces/src/index.ts",
"tsConfig": "libs/shared/interfaces/tsconfig.lib.json",
"assets": []
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "libs/shared/interfaces/jest.config.ts"
}
}
}
}
+4
View File
@@ -0,0 +1,4 @@
export * from './lib/channel.interface';
export * from './lib/constants';
export * from './lib/parsed-playlist.interface';
export * from './lib/playlist.interface';
@@ -0,0 +1,32 @@
/**
* Represents channel object
* TODO: define channel interface in iptv-parser library
*/
export interface Channel {
id: string;
url: string;
name: string;
group: {
title: string;
};
tvg: {
id: string;
name: string;
url: string;
logo: string;
rec: string;
};
epgParams?: string;
timeshift?: string;
catchup?: {
type?: string;
source?: string;
days?: string;
};
http: {
referrer: string;
'user-agent': string;
origin: string;
};
radio: string;
}
@@ -0,0 +1,4 @@
/**
* Id of the channel with favorite channels aggregated from all added playlists
*/
export const GLOBAL_FAVORITES_PLAYLIST_ID = 'GLOBAL_FAVORITES';
@@ -0,0 +1,29 @@
export interface ParsedPlaylist {
header: {
attrs: {
'x-tvg-url': string;
};
raw: string;
};
items: ParsedPlaylistItem[];
}
export interface ParsedPlaylistItem {
name: string;
tvg: {
id: string;
name: string;
url: string;
logo: string;
rec: string;
};
group: {
title: string;
};
http: {
referrer: string;
'user-agent': string;
};
url: string;
raw: string;
}
@@ -0,0 +1,38 @@
/**
* An interface that describe the possible states of the playlist update/refresh process
*/
export enum PlaylistUpdateState {
UPDATED,
IN_PROGRESS,
NOT_UPDATED,
}
/**
* Describes playlist interface
*/
export interface Playlist {
_id: string;
title: string;
filename?: string;
playlist?: any;
importDate: string;
lastUsage: string;
favorites?: string[];
items?: unknown[];
header?: unknown;
count: number;
url?: string;
userAgent?: string;
filePath?: string;
autoRefresh: boolean;
updateDate?: number;
updateState?: PlaylistUpdateState;
position?: number;
isTemporary?: boolean;
serverUrl?: string;
username?: string;
password?: string;
macAddress?: string;
portalUrl?: string;
recentlyViewed?: any[];
}
+23
View File
@@ -0,0 +1,23 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"importHelpers": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noPropertyAccessFromIndexSignature": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
+10
View File
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"include": ["src/**/*.ts"],
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
}
+15
View File
@@ -0,0 +1,15 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"module": "commonjs",
"moduleResolution": "node10",
"types": ["jest", "node"]
},
"include": [
"jest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
}