From 078501cc6481e975f80f276d392d3ff3648f7669 Mon Sep 17 00:00:00 2001 From: "vinh.hoang.bui" Date: Wed, 25 Feb 2026 15:42:38 +0700 Subject: [PATCH] add audio and update type --- .github/workflows/test.yml | 21 +--- README.md | 5 +- docs/api/PlaylistApi.md | 16 ++-- docs/api/VideoApi.md | 5 +- docs/model/AddMediaToPlaylistRequest.md | 13 +++ docs/model/CreateMediaRequest.md | 17 ++-- docs/model/CreatePlaylistRequest.md | 1 + docs/model/GetPlaylistListRequest.md | 1 + docs/model/GetTranscodeCostData.md | 2 +- docs/model/GetVideoListRequest.md | 1 + docs/model/Media.md | 1 + docs/model/Playlist.md | 1 + docs/model/PlaylistItemMedia.md | 3 + ....md => RemoveMediasFromPlaylistRequest.md} | 4 +- package.json | 7 +- src/ObjectSerializer.ts | 6 +- src/api/PlaylistApi.ts | 96 +++++++++++++------ src/api/VideoApi.ts | 25 ++++- src/model/AddMediaToPlaylistRequest.ts | 45 +++++++++ src/model/CreateMediaRequest.ts | 34 +++++++ src/model/CreatePlaylistRequest.ts | 7 ++ src/model/GetPlaylistListRequest.ts | 7 ++ src/model/GetTranscodeCostData.ts | 4 +- src/model/GetVideoListRequest.ts | 7 ++ src/model/Media.ts | 7 ++ src/model/Playlist.ts | 7 ++ src/model/PlaylistItemMedia.ts | 22 +++++ ....ts => RemoveMediasFromPlaylistRequest.ts} | 12 +-- test/PlaylistApi.spec.ts | 26 ++--- test/Video.spec.ts | 48 +++------- test/Webhook.spec.ts | 8 -- 31 files changed, 315 insertions(+), 144 deletions(-) create mode 100644 docs/model/AddMediaToPlaylistRequest.md rename docs/model/{AddVideoToPlaylistRequest.md => RemoveMediasFromPlaylistRequest.md} (54%) create mode 100644 src/model/AddMediaToPlaylistRequest.ts rename src/model/{AddVideoToPlaylistRequest.ts => RemoveMediasFromPlaylistRequest.ts} (64%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0c591743..75b5e16b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,32 +3,23 @@ on: pull_request: branches: - main - jobs: run-tests: runs-on: ubuntu-latest steps: - name: Check out code uses: actions/checkout@v2 + - name: Set up Node.js uses: actions/setup-node@v2 with: - node-version: '16' - - name: Install dependencies - run: npm install + node-version: "16" + - name: Install dependencies + run: npm install - name: Run Prettier run: npm run prettier - - name: Install Jest - run: npm install jest - - - name: Install dotenv - run: npm install dotenv --save - - - name: Install uuid - run: npm install uuid - - name: Create env file run: | touch .env @@ -38,6 +29,4 @@ jobs: echo TEST_ANONYMOUS_SECRET_KEY=${{ secrets.TEST_ANONYMOUS_SECRET_KEY }} >> .env - name: Run tests - run: npm test - - + run: npm test \ No newline at end of file diff --git a/README.md b/README.md index 196a5b90..17b2daf1 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ Method | Description | HTTP request [**getPlaylistPublicInfo()**](https://github.com/AIOZNetwork/aiozstream-nodejs-client/blob/main/docs/api/PlaylistApi.md#getPlaylistPublicInfo) | Get a playlist public | **GET** `/playlists/{id}/player.json` [**getPlaylists()**](https://github.com/AIOZNetwork/aiozstream-nodejs-client/blob/main/docs/api/PlaylistApi.md#getPlaylists) | Get user's playlists | **POST** `/playlists` [**moveVideoInPlaylist()**](https://github.com/AIOZNetwork/aiozstream-nodejs-client/blob/main/docs/api/PlaylistApi.md#moveVideoInPlaylist) | Move a video in a playlist | **PUT** `/playlists/{id}/items` -[**removeVideoFromPlaylist()**](https://github.com/AIOZNetwork/aiozstream-nodejs-client/blob/main/docs/api/PlaylistApi.md#removeVideoFromPlaylist) | Remove a video from a playlist | **DELETE** `/playlists/{id}/items/{item_id}` +[**removeMediaFromPlaylist()**](https://github.com/AIOZNetwork/aiozstream-nodejs-client/blob/main/docs/api/PlaylistApi.md#removeMediaFromPlaylist) | Remove a media from a playlist | **DELETE** `/playlists/{id}/items/{item_id}` [**updatePlaylist()**](https://github.com/AIOZNetwork/aiozstream-nodejs-client/blob/main/docs/api/PlaylistApi.md#updatePlaylist) | Update a playlist | **PATCH** `/playlists/{id}` @@ -156,8 +156,8 @@ Method | Description | HTTP request ### Models + - [AddMediaToPlaylistRequest](https://github.com/AIOZNetwork/aiozstream-nodejs-client/blob/main/docs/model/AddMediaToPlaylistRequest.md) - [AddPlayerThemesToVideoRequest](https://github.com/AIOZNetwork/aiozstream-nodejs-client/blob/main/docs/model/AddPlayerThemesToVideoRequest.md) - - [AddVideoToPlaylistRequest](https://github.com/AIOZNetwork/aiozstream-nodejs-client/blob/main/docs/model/AddVideoToPlaylistRequest.md) - [ApiKey](https://github.com/AIOZNetwork/aiozstream-nodejs-client/blob/main/docs/model/ApiKey.md) - [Asset](https://github.com/AIOZNetwork/aiozstream-nodejs-client/blob/main/docs/model/Asset.md) - [AudioConfig](https://github.com/AIOZNetwork/aiozstream-nodejs-client/blob/main/docs/model/AudioConfig.md) @@ -216,6 +216,7 @@ Method | Description | HTTP request - [PublicPlaylistObject](https://github.com/AIOZNetwork/aiozstream-nodejs-client/blob/main/docs/model/PublicPlaylistObject.md) - [QualityConfig](https://github.com/AIOZNetwork/aiozstream-nodejs-client/blob/main/docs/model/QualityConfig.md) - [QualityObject](https://github.com/AIOZNetwork/aiozstream-nodejs-client/blob/main/docs/model/QualityObject.md) + - [RemoveMediasFromPlaylistRequest](https://github.com/AIOZNetwork/aiozstream-nodejs-client/blob/main/docs/model/RemoveMediasFromPlaylistRequest.md) - [RemovePlayerThemesFromMediaRequest](https://github.com/AIOZNetwork/aiozstream-nodejs-client/blob/main/docs/model/RemovePlayerThemesFromMediaRequest.md) - [RenameAPIKeyRequest](https://github.com/AIOZNetwork/aiozstream-nodejs-client/blob/main/docs/model/RenameAPIKeyRequest.md) - [RequestCreateCaption](https://github.com/AIOZNetwork/aiozstream-nodejs-client/blob/main/docs/model/RequestCreateCaption.md) diff --git a/docs/api/PlaylistApi.md b/docs/api/PlaylistApi.md index 03553373..9164ea2a 100644 --- a/docs/api/PlaylistApi.md +++ b/docs/api/PlaylistApi.md @@ -12,7 +12,7 @@ All URIs are relative to *http://localhost/api* | [**getPlaylistPublicInfo()**](PlaylistApi.md#getPlaylistPublicInfo) | Get a playlist public | **GET** /playlists/{id}/player.json | | [**getPlaylists()**](PlaylistApi.md#getPlaylists) | Get user's playlists | **POST** /playlists | | [**moveVideoInPlaylist()**](PlaylistApi.md#moveVideoInPlaylist) | Move a video in a playlist | **PUT** /playlists/{id}/items | -| [**removeVideoFromPlaylist()**](PlaylistApi.md#removeVideoFromPlaylist) | Remove a video from a playlist | **DELETE** /playlists/{id}/items/{item_id} | +| [**removeMediaFromPlaylist()**](PlaylistApi.md#removeMediaFromPlaylist) | Remove a media from a playlist | **DELETE** /playlists/{id}/items/{item_id} | | [**updatePlaylist()**](PlaylistApi.md#updatePlaylist) | Update a playlist | **PATCH** /playlists/{id} | @@ -27,7 +27,7 @@ Add a specific video to a playlist for the authenticated user | Name | Type | Required | Description | | ------------- | ------------- | ------------- | ------------- | | **id** | **string**| **yes**| Playlist ID | - | **payload** | [**AddVideoToPlaylistRequest**](../model/AddVideoToPlaylistRequest.md)| **yes**| Video details | + | **payload** | [**AddMediaToPlaylistRequest**](../model/AddMediaToPlaylistRequest.md)| **yes**| Video details | ### Return type @@ -116,8 +116,9 @@ Retrieve a specific playlist by its ID for the current user. | Name | Type | Required | Description | | ------------- | ------------- | ------------- | ------------- | | **id** | **string**| **yes**| Playlist ID | - | **sortBy** | **'created_at' \| 'title' \| 'duration'**| no| sort by | - | **orderBy** | **'asc' \| 'desc'**| no| allowed: asc, desc. Default: asc | + | **sortBy** | **string**| no| Sort by field (created_at, title, duration) | + | **orderBy** | **string**| no| Order by (asc, desc) | + | **search** | **string**| no| Search term | ### Return type @@ -196,11 +197,11 @@ Promise<[**ResponseSuccess**](../model/ResponseSuccess.md)>. --- - -## **`removeVideoFromPlaylist()` - Remove a video from a playlist** + +## **`removeMediaFromPlaylist()` - Remove a media from a playlist** -Remove a specific video from a playlist for the authenticated user +Remove a specific media from a playlist for the authenticated user ### Parameters @@ -208,6 +209,7 @@ Remove a specific video from a playlist for the authenticated user | ------------- | ------------- | ------------- | ------------- | | **id** | **string**| **yes**| Playlist ID | | **itemId** | **string**| **yes**| Playlist Item ID | + | **payload** | [**RemoveMediasFromPlaylistRequest**](../model/RemoveMediasFromPlaylistRequest.md)| **yes**| Optional payload | ### Return type diff --git a/docs/api/VideoApi.md b/docs/api/VideoApi.md index 860609c5..b1cada6d 100644 --- a/docs/api/VideoApi.md +++ b/docs/api/VideoApi.md @@ -208,8 +208,9 @@ get video transcoding cost | Name | Type | Required | Description | | ------------- | ------------- | ------------- | ------------- | - | **qualities** | **string**| **yes**| video's qualities | - | **duration** | **number**| **yes**| video's duration | + | **qualities** | **string**| **yes**| media's qualities | + | **type** | **string**| **yes**| media's type | + | **duration** | **number**| **yes**| media's duration | ### Return type diff --git a/docs/model/AddMediaToPlaylistRequest.md b/docs/model/AddMediaToPlaylistRequest.md new file mode 100644 index 00000000..fd93b333 --- /dev/null +++ b/docs/model/AddMediaToPlaylistRequest.md @@ -0,0 +1,13 @@ + +# AddMediaToPlaylistRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**mediaId** | **string** | | [optional] +**optionMediaIds** | **Array<string>** | | [optional] +**optionPlaylists** | **Array<string>** | | [optional] + + + diff --git a/docs/model/CreateMediaRequest.md b/docs/model/CreateMediaRequest.md index 9c677e7b..422b3f89 100644 --- a/docs/model/CreateMediaRequest.md +++ b/docs/model/CreateMediaRequest.md @@ -5,14 +5,15 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**description** | **string** | | [optional] -**isPublic** | **boolean** | | [optional] -**metadata** | [**Array<Metadata>**](Metadata.md) | | [optional] -**qualities** | [**Array<QualityConfig>**](QualityConfig.md) | | [optional] -**segmentDuration** | **number** | | [optional] -**tags** | **Array<string>** | | [optional] -**title** | **string** | | [optional] -**watermark** | [**VideoWatermark**](VideoWatermark.md) | | [optional] +**description** | **string** | Description of the media | [optional] +**isPublic** | **boolean** | // Is panoramic media IsPanoramic *bool `json:\"is_panoramic\" form:\"is_panoramic\"` Is public media | [optional] +**metadata** | [**Array<Metadata>**](Metadata.md) | Metadata of the media (key-value pair, max: 50 items, key max length: 255, value max length: 255) | [optional] +**qualities** | [**Array<QualityConfig>**](QualityConfig.md) | Qualities of the media (default: 1080p, 720p, 360p, allow:2160p, 1440p, 1080p, 720p, 360p, 240p, 144p) | [optional] +**segmentDuration** | **number** | SegmentConfig | [optional] +**tags** | **Array<string>** | Tags of the media (max: 50 items, max length: 255) | [optional] +**title** | **string** | Title of the media | [optional] +**type** | **string** | Type of the media (default: video, allowed: video, audio) | [optional] +**watermark** | [**VideoWatermark**](VideoWatermark.md) | Media thumbnailConfig | [optional] diff --git a/docs/model/CreatePlaylistRequest.md b/docs/model/CreatePlaylistRequest.md index 3d0e89db..99dc5786 100644 --- a/docs/model/CreatePlaylistRequest.md +++ b/docs/model/CreatePlaylistRequest.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **metadata** | [**Array<Metadata>**](Metadata.md) | | [optional] **name** | **string** | | [optional] +**playlistType** | **string** | | [optional] **tags** | **Array<string>** | | [optional] diff --git a/docs/model/GetPlaylistListRequest.md b/docs/model/GetPlaylistListRequest.md index 1e1bb8ea..ac7ad995 100644 --- a/docs/model/GetPlaylistListRequest.md +++ b/docs/model/GetPlaylistListRequest.md @@ -9,6 +9,7 @@ Name | Type | Description | Notes **metadata** | [**Array<Metadata>**](Metadata.md) | | [optional] **offset** | **number** | | [optional] **orderBy** | **string** | | [optional] +**playlistType** | **string** | | [optional] **search** | **string** | | [optional] **sortBy** | **string** | | [optional] **tags** | **Array<string>** | | [optional] diff --git a/docs/model/GetTranscodeCostData.md b/docs/model/GetTranscodeCostData.md index 99bd3ed0..08178d6b 100644 --- a/docs/model/GetTranscodeCostData.md +++ b/docs/model/GetTranscodeCostData.md @@ -6,7 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **isEnough** | **boolean** | | [optional] -**price** | **string** | | [optional] +**price** | **number** | | [optional] diff --git a/docs/model/GetVideoListRequest.md b/docs/model/GetVideoListRequest.md index 87a270d1..af04c566 100644 --- a/docs/model/GetVideoListRequest.md +++ b/docs/model/GetVideoListRequest.md @@ -13,6 +13,7 @@ Name | Type | Description | Notes **sortBy** | **string** | | [optional] **status** | **string** | | [optional] **tags** | **Array<string>** | | [optional] +**type** | **string** | | [optional] diff --git a/docs/model/Media.md b/docs/model/Media.md index 4f14b812..19189d4f 100644 --- a/docs/model/Media.md +++ b/docs/model/Media.md @@ -22,6 +22,7 @@ Name | Type | Description | Notes **status** | **string** | | [optional] **tags** | **Array<string>** | | [optional] **title** | **string** | | [optional] +**type** | **string** | | [optional] **updatedAt** | **string** | | [optional] **userId** | **string** | | [optional] **view** | **number** | | [optional] diff --git a/docs/model/Playlist.md b/docs/model/Playlist.md index dcc63bbf..07173f06 100644 --- a/docs/model/Playlist.md +++ b/docs/model/Playlist.md @@ -12,6 +12,7 @@ Name | Type | Description | Notes **itemCount** | **number** | | [optional] **metadata** | **Map<String, string>** | | [optional] **name** | **string** | | [optional] +**playlistType** | **string** | | [optional] **playlistUrl** | **string** | | [optional] **size** | **number** | | [optional] **tags** | **string** | | [optional] diff --git a/docs/model/PlaylistItemMedia.md b/docs/model/PlaylistItemMedia.md index 0901fa32..c7caa4ea 100644 --- a/docs/model/PlaylistItemMedia.md +++ b/docs/model/PlaylistItemMedia.md @@ -5,10 +5,13 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**captions** | [**Array<VideoCaption>**](VideoCaption.md) | | [optional] **chapters** | [**Array<VideoChapter>**](VideoChapter.md) | | [optional] +**description** | **string** | | [optional] **duration** | **number** | | [optional] **hlsUrl** | **string** | | [optional] **qualities** | **string** | | [optional] +**size** | **number** | | [optional] **thumbnailUrl** | **string** | | [optional] **title** | **string** | | [optional] diff --git a/docs/model/AddVideoToPlaylistRequest.md b/docs/model/RemoveMediasFromPlaylistRequest.md similarity index 54% rename from docs/model/AddVideoToPlaylistRequest.md rename to docs/model/RemoveMediasFromPlaylistRequest.md index a7a84ee7..917cf95b 100644 --- a/docs/model/AddVideoToPlaylistRequest.md +++ b/docs/model/RemoveMediasFromPlaylistRequest.md @@ -1,11 +1,11 @@ -# AddVideoToPlaylistRequest +# RemoveMediasFromPlaylistRequest ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**videoId** | **string** | | [optional] +**optionPlaylists** | **Array<string>** | | [optional] diff --git a/package.json b/package.json index ac799a82..1b9b85fc 100644 --- a/package.json +++ b/package.json @@ -37,18 +37,21 @@ }, "dependencies": { "axios": "^1.4.0", - "js-base64": "^3.7.5" + "js-base64": "^3.7.5", + "uuid": "^8.3.2" }, "devDependencies": { "@tsconfig/node14": "^14.1.0", "@types/node": "^20.3.3", + "@types/jest": "^29.5.2", + "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^5.61.0", "@typescript-eslint/parser": "^5.61.0", + "dotenv": "^16.3.1", "eslint": "^8.44.0", "eslint-config-prettier": "^8.8.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-unused-imports": "^2.0.0", - "@types/jest": "^29.5.2", "jest": "^29.6.0", "ts-jest": "^29.1.1", "typescript": "^5.1.6", diff --git a/src/ObjectSerializer.ts b/src/ObjectSerializer.ts index b98c38da..c08859bb 100644 --- a/src/ObjectSerializer.ts +++ b/src/ObjectSerializer.ts @@ -10,8 +10,8 @@ * Do not edit the class manually. */ +import AddMediaToPlaylistRequest from './model/AddMediaToPlaylistRequest'; import AddPlayerThemesToVideoRequest from './model/AddPlayerThemesToVideoRequest'; -import AddVideoToPlaylistRequest from './model/AddVideoToPlaylistRequest'; import ApiKey from './model/ApiKey'; import Asset from './model/Asset'; import AudioConfig from './model/AudioConfig'; @@ -70,6 +70,7 @@ import PlaylistItemMedia from './model/PlaylistItemMedia'; import PublicPlaylistObject from './model/PublicPlaylistObject'; import QualityConfig from './model/QualityConfig'; import QualityObject from './model/QualityObject'; +import RemoveMediasFromPlaylistRequest from './model/RemoveMediasFromPlaylistRequest'; import RemovePlayerThemesFromMediaRequest from './model/RemovePlayerThemesFromMediaRequest'; import RenameAPIKeyRequest from './model/RenameAPIKeyRequest'; import RequestCreateCaption from './model/RequestCreateCaption'; @@ -116,8 +117,8 @@ const supportedMediaTypes: { [mediaType: string]: number } = { const enumsMap: Set = new Set([]); const typeMap: { [index: string]: any } = { + AddMediaToPlaylistRequest: AddMediaToPlaylistRequest, AddPlayerThemesToVideoRequest: AddPlayerThemesToVideoRequest, - AddVideoToPlaylistRequest: AddVideoToPlaylistRequest, ApiKey: ApiKey, Asset: Asset, AudioConfig: AudioConfig, @@ -176,6 +177,7 @@ const typeMap: { [index: string]: any } = { PublicPlaylistObject: PublicPlaylistObject, QualityConfig: QualityConfig, QualityObject: QualityObject, + RemoveMediasFromPlaylistRequest: RemoveMediasFromPlaylistRequest, RemovePlayerThemesFromMediaRequest: RemovePlayerThemesFromMediaRequest, RenameAPIKeyRequest: RenameAPIKeyRequest, RequestCreateCaption: RequestCreateCaption, diff --git a/src/api/PlaylistApi.ts b/src/api/PlaylistApi.ts index 24710cbb..5c93252f 100644 --- a/src/api/PlaylistApi.ts +++ b/src/api/PlaylistApi.ts @@ -15,7 +15,7 @@ import { URLSearchParams } from 'url'; import FormData from 'form-data'; import ObjectSerializer, { COLLECTION_FORMATS } from '../ObjectSerializer'; import HttpClient, { QueryOptions, ApiResponseHeaders } from '../HttpClient'; -import AddVideoToPlaylistRequest from '../model/AddVideoToPlaylistRequest'; +import AddMediaToPlaylistRequest from '../model/AddMediaToPlaylistRequest'; import CreatePlaylistRequest from '../model/CreatePlaylistRequest'; import CreatePlaylistResponse from '../model/CreatePlaylistResponse'; import GetPlaylistByIdResponse from '../model/GetPlaylistByIdResponse'; @@ -24,6 +24,7 @@ import GetPlaylistListResponse from '../model/GetPlaylistListResponse'; import Metadata from '../model/Metadata'; import MoveVideoInPlaylistRequest from '../model/MoveVideoInPlaylistRequest'; import PublicPlaylistObject from '../model/PublicPlaylistObject'; +import RemoveMediasFromPlaylistRequest from '../model/RemoveMediasFromPlaylistRequest'; import ResponseSuccess from '../model/ResponseSuccess'; import { Readable } from 'stream'; import { readableToBuffer } from '../HttpClient'; @@ -46,7 +47,7 @@ export default class PlaylistApi { */ public async addVideoToPlaylist( id: string, - payload: AddVideoToPlaylistRequest = {} + payload: AddMediaToPlaylistRequest = {} ): Promise { return this.addVideoToPlaylistWithResponseHeaders(id, payload).then( (res) => res.body @@ -61,7 +62,7 @@ export default class PlaylistApi { */ public async addVideoToPlaylistWithResponseHeaders( id: string, - payload: AddVideoToPlaylistRequest = {} + payload: AddMediaToPlaylistRequest = {} ): Promise<{ headers: ApiResponseHeaders; body: ResponseSuccess }> { const queryParams: QueryOptions = {}; queryParams.headers = {}; @@ -87,7 +88,7 @@ export default class PlaylistApi { queryParams.headers['Content-Type'] = contentType; queryParams.body = ObjectSerializer.stringify( - ObjectSerializer.serialize(payload, 'AddVideoToPlaylistRequest', ''), + ObjectSerializer.serialize(payload, 'AddMediaToPlaylistRequest', ''), contentType ); @@ -268,13 +269,15 @@ export default class PlaylistApi { * Get playlist by ID * @param {Object} searchParams * @param { string } searchParams.id Playlist ID - * @param { 'created_at' | 'title' | 'duration' } searchParams.sortBy sort by - * @param { 'asc' | 'desc' } searchParams.orderBy allowed: asc, desc. Default: asc + * @param { string } searchParams.sortBy Sort by field (created_at, title, duration) + * @param { string } searchParams.orderBy Order by (asc, desc) + * @param { string } searchParams.search Search term */ public async getPlaylistById(args: { id: string; - sortBy?: 'created_at' | 'title' | 'duration'; - orderBy?: 'asc' | 'desc'; + sortBy?: string; + orderBy?: string; + search?: string; }): Promise { return this.getPlaylistByIdWithResponseHeaders(args).then( (res) => res.body @@ -286,17 +289,20 @@ export default class PlaylistApi { * Get playlist by ID * @param {Object} searchParams * @param { string } searchParams.id Playlist ID - * @param { 'created_at' | 'title' | 'duration' } searchParams.sortBy sort by - * @param { 'asc' | 'desc' } searchParams.orderBy allowed: asc, desc. Default: asc + * @param { string } searchParams.sortBy Sort by field (created_at, title, duration) + * @param { string } searchParams.orderBy Order by (asc, desc) + * @param { string } searchParams.search Search term */ public async getPlaylistByIdWithResponseHeaders({ id, sortBy, orderBy, + search, }: { id: string; - sortBy?: 'created_at' | 'title' | 'duration'; - orderBy?: 'asc' | 'desc'; + sortBy?: string; + orderBy?: string; + search?: string; }): Promise<{ headers: ApiResponseHeaders; body: GetPlaylistByIdResponse }> { const queryParams: QueryOptions = {}; queryParams.headers = {}; @@ -316,17 +322,19 @@ export default class PlaylistApi { if (sortBy !== undefined) { urlSearchParams.append( 'sort_by', - ObjectSerializer.serialize( - sortBy, - "'created_at' | 'title' | 'duration'", - '' - ) + ObjectSerializer.serialize(sortBy, 'string', '') ); } if (orderBy !== undefined) { urlSearchParams.append( 'order_by', - ObjectSerializer.serialize(orderBy, "'asc' | 'desc'", '') + ObjectSerializer.serialize(orderBy, 'string', '') + ); + } + if (search !== undefined) { + urlSearchParams.append( + 'search', + ObjectSerializer.serialize(search, 'string', '') ); } @@ -529,40 +537,51 @@ export default class PlaylistApi { } /** - * Remove a specific video from a playlist for the authenticated user - * Remove a video from a playlist + * Remove a specific media from a playlist for the authenticated user + * Remove a media from a playlist * @param id Playlist ID * @param itemId Playlist Item ID + * @param payload Optional payload */ - public async removeVideoFromPlaylist( + public async removeMediaFromPlaylist( id: string, - itemId: string + itemId: string, + payload: RemoveMediasFromPlaylistRequest = {} ): Promise { - return this.removeVideoFromPlaylistWithResponseHeaders(id, itemId).then( - (res) => res.body - ); + return this.removeMediaFromPlaylistWithResponseHeaders( + id, + itemId, + payload + ).then((res) => res.body); } /** - * Remove a specific video from a playlist for the authenticated user - * Remove a video from a playlist + * Remove a specific media from a playlist for the authenticated user + * Remove a media from a playlist * @param id Playlist ID * @param itemId Playlist Item ID + * @param payload Optional payload */ - public async removeVideoFromPlaylistWithResponseHeaders( + public async removeMediaFromPlaylistWithResponseHeaders( id: string, - itemId: string + itemId: string, + payload: RemoveMediasFromPlaylistRequest = {} ): Promise<{ headers: ApiResponseHeaders; body: ResponseSuccess }> { const queryParams: QueryOptions = {}; queryParams.headers = {}; if (id === null || id === undefined) { throw new Error( - 'Required parameter id was null or undefined when calling removeVideoFromPlaylist.' + 'Required parameter id was null or undefined when calling removeMediaFromPlaylist.' ); } if (itemId === null || itemId === undefined) { throw new Error( - 'Required parameter itemId was null or undefined when calling removeVideoFromPlaylist.' + 'Required parameter itemId was null or undefined when calling removeMediaFromPlaylist.' + ); + } + if (payload === null || payload === undefined) { + throw new Error( + 'Required parameter payload was null or undefined when calling removeMediaFromPlaylist.' ); } // Path Params @@ -571,6 +590,21 @@ export default class PlaylistApi { .replace('{' + 'id' + '}', encodeURIComponent(String(id))) .replace('{' + 'item_id' + '}', encodeURIComponent(String(itemId))); + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + 'application/json', + ]); + queryParams.headers['Content-Type'] = contentType; + + queryParams.body = ObjectSerializer.stringify( + ObjectSerializer.serialize( + payload, + 'RemoveMediasFromPlaylistRequest', + '' + ), + contentType + ); + queryParams.method = 'DELETE'; return this.httpClient.call(localVarPath, queryParams).then((response) => { diff --git a/src/api/VideoApi.ts b/src/api/VideoApi.ts index 296fe379..281debef 100644 --- a/src/api/VideoApi.ts +++ b/src/api/VideoApi.ts @@ -549,14 +549,16 @@ export default class VideoApi { /** * get video transcoding cost * get video transcoding cost - * @param qualities video's qualities - * @param duration video's duration + * @param qualities media's qualities + * @param type media's type + * @param duration media's duration */ public async getCost( qualities: string, + type: string, duration: number ): Promise { - return this.getCostWithResponseHeaders(qualities, duration).then( + return this.getCostWithResponseHeaders(qualities, type, duration).then( (res) => res.body ); } @@ -564,11 +566,13 @@ export default class VideoApi { /** * get video transcoding cost * get video transcoding cost - * @param qualities video's qualities - * @param duration video's duration + * @param qualities media's qualities + * @param type media's type + * @param duration media's duration */ public async getCostWithResponseHeaders( qualities: string, + type: string, duration: number ): Promise<{ headers: ApiResponseHeaders; body: GetTranscodeCostResponse }> { const queryParams: QueryOptions = {}; @@ -578,6 +582,11 @@ export default class VideoApi { 'Required parameter qualities was null or undefined when calling getCost.' ); } + if (type === null || type === undefined) { + throw new Error( + 'Required parameter type was null or undefined when calling getCost.' + ); + } if (duration === null || duration === undefined) { throw new Error( 'Required parameter duration was null or undefined when calling getCost.' @@ -595,6 +604,12 @@ export default class VideoApi { ObjectSerializer.serialize(qualities, 'string', '') ); } + if (type !== undefined) { + urlSearchParams.append( + 'type', + ObjectSerializer.serialize(type, 'string', '') + ); + } if (duration !== undefined) { urlSearchParams.append( 'duration', diff --git a/src/model/AddMediaToPlaylistRequest.ts b/src/model/AddMediaToPlaylistRequest.ts new file mode 100644 index 00000000..8f249905 --- /dev/null +++ b/src/model/AddMediaToPlaylistRequest.ts @@ -0,0 +1,45 @@ +/** + * @aiozstream/nodejs-client + * Aioz Stream Service + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated. + * Do not edit the class manually. + */ + +import AttributeType from './AttributeType.js'; + +export default class AddMediaToPlaylistRequest { + 'mediaId'?: string; + 'optionMediaIds'?: Array; + 'optionPlaylists'?: Array; + + static readonly discriminator?: string = undefined; + + static readonly attributeTypeMap: Array = [ + { + name: 'mediaId', + baseName: 'media_id', + type: 'string', + format: '', + }, + { + name: 'optionMediaIds', + baseName: 'option_media_ids', + type: 'Array', + format: '', + }, + { + name: 'optionPlaylists', + baseName: 'option_playlists', + type: 'Array', + format: '', + }, + ]; + + static getAttributeTypeMap(): Array { + return AddMediaToPlaylistRequest.attributeTypeMap; + } +} diff --git a/src/model/CreateMediaRequest.ts b/src/model/CreateMediaRequest.ts index 0a09f99d..22ca17f3 100644 --- a/src/model/CreateMediaRequest.ts +++ b/src/model/CreateMediaRequest.ts @@ -15,13 +15,41 @@ import QualityConfig from './QualityConfig.js'; import VideoWatermark from './VideoWatermark.js'; export default class CreateMediaRequest { + /** + * Description of the media + */ 'description'?: string; + /** + * // Is panoramic media IsPanoramic *bool `json:\"is_panoramic\" form:\"is_panoramic\"` Is public media + */ 'isPublic'?: boolean; + /** + * Metadata of the media (key-value pair, max: 50 items, key max length: 255, value max length: 255) + */ 'metadata'?: Array; + /** + * Qualities of the media (default: 1080p, 720p, 360p, allow:2160p, 1440p, 1080p, 720p, 360p, 240p, 144p) + */ 'qualities'?: Array; + /** + * SegmentConfig + */ 'segmentDuration'?: number; + /** + * Tags of the media (max: 50 items, max length: 255) + */ 'tags'?: Array; + /** + * Title of the media + */ 'title'?: string; + /** + * Type of the media (default: video, allowed: video, audio) + */ + 'type'?: string; + /** + * Media thumbnailConfig + */ 'watermark'?: VideoWatermark; static readonly discriminator?: string = undefined; @@ -69,6 +97,12 @@ export default class CreateMediaRequest { type: 'string', format: '', }, + { + name: 'type', + baseName: 'type', + type: 'string', + format: '', + }, { name: 'watermark', baseName: 'watermark', diff --git a/src/model/CreatePlaylistRequest.ts b/src/model/CreatePlaylistRequest.ts index be391eca..f026a1b3 100644 --- a/src/model/CreatePlaylistRequest.ts +++ b/src/model/CreatePlaylistRequest.ts @@ -15,6 +15,7 @@ import Metadata from './Metadata.js'; export default class CreatePlaylistRequest { 'metadata'?: Array; 'name'?: string; + 'playlistType'?: string; 'tags'?: Array; static readonly discriminator?: string = undefined; @@ -32,6 +33,12 @@ export default class CreatePlaylistRequest { type: 'string', format: '', }, + { + name: 'playlistType', + baseName: 'playlist_type', + type: 'string', + format: '', + }, { name: 'tags', baseName: 'tags', diff --git a/src/model/GetPlaylistListRequest.ts b/src/model/GetPlaylistListRequest.ts index aa0afe42..44480f62 100644 --- a/src/model/GetPlaylistListRequest.ts +++ b/src/model/GetPlaylistListRequest.ts @@ -17,6 +17,7 @@ export default class GetPlaylistListRequest { 'metadata'?: Array; 'offset'?: number; 'orderBy'?: string; + 'playlistType'?: string; 'search'?: string; 'sortBy'?: string; 'tags'?: Array; @@ -48,6 +49,12 @@ export default class GetPlaylistListRequest { type: 'string', format: '', }, + { + name: 'playlistType', + baseName: 'playlist_type', + type: 'string', + format: '', + }, { name: 'search', baseName: 'search', diff --git a/src/model/GetTranscodeCostData.ts b/src/model/GetTranscodeCostData.ts index 85d76586..9efa545f 100644 --- a/src/model/GetTranscodeCostData.ts +++ b/src/model/GetTranscodeCostData.ts @@ -13,7 +13,7 @@ import AttributeType from './AttributeType.js'; export default class GetTranscodeCostData { 'isEnough'?: boolean; - 'price'?: string; + 'price'?: number; static readonly discriminator?: string = undefined; @@ -27,7 +27,7 @@ export default class GetTranscodeCostData { { name: 'price', baseName: 'price', - type: 'string', + type: 'number', format: '', }, ]; diff --git a/src/model/GetVideoListRequest.ts b/src/model/GetVideoListRequest.ts index d035da07..5ff3f10f 100644 --- a/src/model/GetVideoListRequest.ts +++ b/src/model/GetVideoListRequest.ts @@ -21,6 +21,7 @@ export default class GetVideoListRequest { 'sortBy'?: string; 'status'?: string; 'tags'?: Array; + 'type'?: string; static readonly discriminator?: string = undefined; @@ -73,6 +74,12 @@ export default class GetVideoListRequest { type: 'Array', format: '', }, + { + name: 'type', + baseName: 'type', + type: 'string', + format: '', + }, ]; static getAttributeTypeMap(): Array { diff --git a/src/model/Media.ts b/src/model/Media.ts index b2c8fc54..b75521f9 100644 --- a/src/model/Media.ts +++ b/src/model/Media.ts @@ -35,6 +35,7 @@ export default class Media { 'status'?: string; 'tags'?: Array; 'title'?: string; + 'type'?: string; 'updatedAt'?: string; 'userId'?: string; 'view'?: number; @@ -144,6 +145,12 @@ export default class Media { type: 'string', format: '', }, + { + name: 'type', + baseName: 'type', + type: 'string', + format: '', + }, { name: 'updatedAt', baseName: 'updated_at', diff --git a/src/model/Playlist.ts b/src/model/Playlist.ts index 63b1ca48..7c2ebe05 100644 --- a/src/model/Playlist.ts +++ b/src/model/Playlist.ts @@ -20,6 +20,7 @@ export default class Playlist { 'itemCount'?: number; 'metadata'?: { [key: string]: string }; 'name'?: string; + 'playlistType'?: string; 'playlistUrl'?: string; 'size'?: number; 'tags'?: string; @@ -73,6 +74,12 @@ export default class Playlist { type: 'string', format: '', }, + { + name: 'playlistType', + baseName: 'playlist_type', + type: 'string', + format: '', + }, { name: 'playlistUrl', baseName: 'playlist_url', diff --git a/src/model/PlaylistItemMedia.ts b/src/model/PlaylistItemMedia.ts index 0f599325..1e78fd7e 100644 --- a/src/model/PlaylistItemMedia.ts +++ b/src/model/PlaylistItemMedia.ts @@ -10,25 +10,41 @@ */ import AttributeType from './AttributeType.js'; +import VideoCaption from './VideoCaption.js'; import VideoChapter from './VideoChapter.js'; export default class PlaylistItemMedia { + 'captions'?: Array; 'chapters'?: Array; + 'description'?: string; 'duration'?: number; 'hlsUrl'?: string; 'qualities'?: string; + 'size'?: number; 'thumbnailUrl'?: string; 'title'?: string; static readonly discriminator?: string = undefined; static readonly attributeTypeMap: Array = [ + { + name: 'captions', + baseName: 'captions', + type: 'Array', + format: '', + }, { name: 'chapters', baseName: 'chapters', type: 'Array', format: '', }, + { + name: 'description', + baseName: 'description', + type: 'string', + format: '', + }, { name: 'duration', baseName: 'duration', @@ -47,6 +63,12 @@ export default class PlaylistItemMedia { type: 'string', format: '', }, + { + name: 'size', + baseName: 'size', + type: 'number', + format: '', + }, { name: 'thumbnailUrl', baseName: 'thumbnail_url', diff --git a/src/model/AddVideoToPlaylistRequest.ts b/src/model/RemoveMediasFromPlaylistRequest.ts similarity index 64% rename from src/model/AddVideoToPlaylistRequest.ts rename to src/model/RemoveMediasFromPlaylistRequest.ts index 589d3d61..5890a42e 100644 --- a/src/model/AddVideoToPlaylistRequest.ts +++ b/src/model/RemoveMediasFromPlaylistRequest.ts @@ -11,21 +11,21 @@ import AttributeType from './AttributeType.js'; -export default class AddVideoToPlaylistRequest { - 'videoId'?: string; +export default class RemoveMediasFromPlaylistRequest { + 'optionPlaylists'?: Array; static readonly discriminator?: string = undefined; static readonly attributeTypeMap: Array = [ { - name: 'videoId', - baseName: 'video_id', - type: 'string', + name: 'optionPlaylists', + baseName: 'option_playlists', + type: 'Array', format: '', }, ]; static getAttributeTypeMap(): Array { - return AddVideoToPlaylistRequest.attributeTypeMap; + return RemoveMediasFromPlaylistRequest.attributeTypeMap; } } diff --git a/test/PlaylistApi.spec.ts b/test/PlaylistApi.spec.ts index 02839568..15181ba9 100644 --- a/test/PlaylistApi.spec.ts +++ b/test/PlaylistApi.spec.ts @@ -149,7 +149,7 @@ describe('Playlist Service', () => { anonymousTestClient.playlist.addVideoToPlaylist( testPlaylistID as string, { - videoId: testVideoIDOne, + mediaId: testVideoIDOne, } ) ).rejects.toThrow(StreamError); @@ -158,7 +158,7 @@ describe('Playlist Service', () => { const response = await testClient.playlist.addVideoToPlaylist( testPlaylistID as string, { - videoId: testVideoIDOne, + mediaId: testVideoIDOne, } ); expect(response).toBeDefined(); @@ -168,7 +168,7 @@ describe('Playlist Service', () => { const response = await testClient.playlist.addVideoToPlaylist( testPlaylistID as string, { - videoId: testVideoIDTwo, + mediaId: testVideoIDTwo, } ); expect(response).toBeDefined(); @@ -178,7 +178,7 @@ describe('Playlist Service', () => { const response = await testClient.playlist.addVideoToPlaylist( testPlaylistID as string, { - videoId: testVideoIDThree, + mediaId: testVideoIDThree, } ); expect(response).toBeDefined(); @@ -187,7 +187,7 @@ describe('Playlist Service', () => { it('Missing Video ID', async () => { await expect( testClient.playlist.addVideoToPlaylist(testPlaylistID as string, { - videoId: '', + mediaId: '', }) ).rejects.toThrow(StreamError); }); @@ -202,7 +202,7 @@ describe('Playlist Service', () => { const newId = uuidv4(); await expect( testClient.playlist.addVideoToPlaylist(newId, { - videoId: testVideoIDOne, + mediaId: testVideoIDOne, }) ).rejects.toThrow(StreamError); }); @@ -332,14 +332,14 @@ describe('Playlist Service', () => { describe('Remove Video from Playlist', () => { it('Remove other', async () => { await expect( - anonymousTestClient.playlist.removeVideoFromPlaylist( + anonymousTestClient.playlist.removeMediaFromPlaylist( testPlaylistID as string, testFirstItemID as string ) ).rejects.toThrow(StreamError); }); it('Valid Remove First Video Request', async () => { - const response = await testClient.playlist.removeVideoFromPlaylist( + const response = await testClient.playlist.removeMediaFromPlaylist( testPlaylistID as string, testFirstItemID as string ); @@ -347,7 +347,7 @@ describe('Playlist Service', () => { }); it('Valid Remove Second Video Request', async () => { - const response = await testClient.playlist.removeVideoFromPlaylist( + const response = await testClient.playlist.removeMediaFromPlaylist( testPlaylistID as string, testSecondItemID as string ); @@ -355,7 +355,7 @@ describe('Playlist Service', () => { }); it('Valid Remove Third Video Request', async () => { - const response = await testClient.playlist.removeVideoFromPlaylist( + const response = await testClient.playlist.removeMediaFromPlaylist( testPlaylistID as string, testThirdItemID as string ); @@ -364,13 +364,13 @@ describe('Playlist Service', () => { it('Invalid Playlist ID', async () => { await expect( - testClient.playlist.removeVideoFromPlaylist('', testVideoIDOne) + testClient.playlist.removeMediaFromPlaylist('', testVideoIDOne) ).rejects.toThrow(StreamError); }); it('Missing Item ID', async () => { await expect( - testClient.playlist.removeVideoFromPlaylist( + testClient.playlist.removeMediaFromPlaylist( testPlaylistID as string, '' ) @@ -380,7 +380,7 @@ describe('Playlist Service', () => { it('Not exist ID', async () => { const newId = uuidv4(); await expect( - testClient.playlist.removeVideoFromPlaylist(newId, newId) + testClient.playlist.removeMediaFromPlaylist(newId, newId) ).rejects.toThrow(StreamError); }); }); diff --git a/test/Video.spec.ts b/test/Video.spec.ts index 1437e96b..3da2dbaa 100644 --- a/test/Video.spec.ts +++ b/test/Video.spec.ts @@ -327,31 +327,31 @@ describe('Video Service', () => { describe('getCost', () => { it('Valid Single Quality', async () => { - const resp = await testClient.video.getCost('720p', 120.5); + const resp = await testClient.video.getCost('720p', 'video', 120.5); expect(resp).toBeDefined(); }); it('Valid Multiple Qualities', async () => { - const resp = await testClient.video.getCost('720p,1080p', 120.5); + const resp = await testClient.video.getCost('720p,1080p', 'video', 120.5); expect(resp).toBeDefined(); }); it('Invalid Quality', async () => { - await expect(testClient.video.getCost('invalid', 120.5)).rejects.toThrow( - StreamError - ); + await expect( + testClient.video.getCost('invalid', 'video', 120.5) + ).rejects.toThrow(StreamError); }); it('Empty Quality', async () => { - await expect(testClient.video.getCost('', 120.5)).rejects.toThrow( - StreamError - ); + await expect( + testClient.video.getCost('', 'video', 120.5) + ).rejects.toThrow(StreamError); }); it('Negative Duration', async () => { - await expect(testClient.video.getCost('720p', -1)).rejects.toThrow( - StreamError - ); + await expect( + testClient.video.getCost('720p', 'video', -1) + ).rejects.toThrow(StreamError); }); }); @@ -403,32 +403,6 @@ describe('Video Service', () => { expect(resp).toBeDefined(); }); - it('Upload when low balance', async () => { - const resp = await anonymousTestClient.video.create({ - title: 'Test Video', - description: 'Test Description', - isPublic: true, - metadata: [ - { key: 'key1', value: 'value1' }, - { key: 'key2', value: 'value2' }, - ], - qualities: [ - { - type: 'hls', - containerType: 'mpegts', - resolution: '240p', - }, - ], - tags: ['tag1', 'tag2'], - }); - const testLowBalanceVideoID = resp.data?.id as string; - const video = await getVideoFilePath('558k.mp4'); - await anonymousTestClient.video.uploadPart(testLowBalanceVideoID, video); - await expect( - anonymousTestClient.video.uploadVideoComplete(testLowBalanceVideoID) - ).rejects.toThrow(StreamError); - }); - it('Invalid Video ID', async () => { await expect( testClient.video.uploadVideoComplete('invalid-id') diff --git a/test/Webhook.spec.ts b/test/Webhook.spec.ts index ce118233..48dd7cd1 100644 --- a/test/Webhook.spec.ts +++ b/test/Webhook.spec.ts @@ -99,14 +99,6 @@ describe('Webhook Service', () => { expect(response).toBeDefined(); }); - it('Update Partial Fields, only Name', async () => { - await expect( - testClient.webhook.update(testWebhookForUpdateAndDelete as string, { - name: 'Updated Name Only', - }) - ).rejects.toThrow(StreamError); - }); - it('Invalid URL', async () => { await expect( testClient.webhook.update(testWebhookForUpdateAndDelete as string, {