From 9bbf86a95189cc4db6efbc081b5dd2b19b970602 Mon Sep 17 00:00:00 2001 From: Vitaly Gashkov Date: Sun, 1 Dec 2024 19:27:44 +0500 Subject: [PATCH] feat(api): add extension types --- package-lock.json | 2 +- packages/api/package.json | 2 +- packages/api/streamyx.d.ts | 1 + packages/api/types/extension.d.ts | 94 +++++++++++++++++++++++++++++++ 4 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 packages/api/types/extension.d.ts diff --git a/package-lock.json b/package-lock.json index 998cc0c..c3577b8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19711,7 +19711,7 @@ }, "packages/api": { "name": "@streamyx/api", - "version": "0.0.5", + "version": "0.0.6", "funding": [ { "type": "individual", diff --git a/packages/api/package.json b/packages/api/package.json index 0393fe7..4a9c955 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "@streamyx/api", - "version": "0.0.5", + "version": "0.0.6", "description": "Type definitions for the latest Streamyx API", "main": "streamyx.js", "types": "streamyx.d.ts", diff --git a/packages/api/streamyx.d.ts b/packages/api/streamyx.d.ts index 0c956d0..ac88e20 100644 --- a/packages/api/streamyx.d.ts +++ b/packages/api/streamyx.d.ts @@ -5,3 +5,4 @@ export * from './types/http'; export * from './types/logger'; export * from './types/question'; export * from './types/common'; +export * from './types/extension'; diff --git a/packages/api/types/extension.d.ts b/packages/api/types/extension.d.ts new file mode 100644 index 0000000..e8ebf90 --- /dev/null +++ b/packages/api/types/extension.d.ts @@ -0,0 +1,94 @@ +export interface Extension { + /** + * Extension name (e.g. Netflix, Prime Video, Apple TV+, etc.) + */ + name: string; + + /** + * Short tag which will be used in filename (e.g. NF, AMZN, ATVP, etc.) + */ + tag?: string; + + /** + * Logo icon URL + */ + icon?: string; + + /** + * Substring pattern to match URL host handled by this plugin + */ + match?: string; + + /** + * Performs initialization of extension (e.g. loading auth data from storage or token refresh) + */ + init?: () => void | Promise; + + /** + * Fetches content metadata from URL + */ + fetchContentMetadata: ( + url: string, + options: Options, + ) => Promise; + + /** + * Fetches data about content source (e.g. manifest URL, external subtitles, etc.) + */ + fetchContentSource?: ( + contentId: string, + options: Options, + ) => Promise; + + /** + * Fetches just content DRM config (e.g. license server URL, request headers, etc.) + */ + fetchContentDrm?: (payload: any, options: Options) => Promise; +} + +export interface CommonContentMetadata { + tag?: string; + /** + * Required if no `fetchContentSource` method is provided + */ + source?: ContentSource; +} + +export interface MovieMetadata extends CommonContentMetadata { + id?: string; + title?: string; +} + +export interface EpisodeMetadata extends CommonContentMetadata { + id?: string; + title?: string; + episodeNumber: number; + seasonNumber?: number; + episodeTitle?: string; +} + +export type ContentMetadata = MovieMetadata | EpisodeMetadata; + +export type ContentSource = { + /** + * URL of the content: manifest URL / playlist URL / direct link to media file + */ + url: string; + headers?: Record; + http2?: boolean; + type?: 'video' | 'audio' | 'subtitle' | 'any'; + audioLanguage?: string; + audioType?: string; + subtitles?: any[]; + drm?: DrmConfig; +}; + +export type DrmConfig = + | { + server: string; + headers?: Record; + params?: object; + template?: string; + http2?: boolean; + } + | { payload: any };