├── .eslintrc ├── .flowconfig ├── .gitignore ├── .nvmrc ├── .prettierrc ├── .travis.yml ├── LICENSE ├── README.md ├── bitmovin ├── account │ ├── apiKeys.ts │ ├── billing │ │ ├── contactDetails.ts │ │ ├── index.ts │ │ ├── invoices.ts │ │ └── statements.ts │ ├── index.ts │ └── organizations │ │ ├── groups.ts │ │ ├── index.ts │ │ ├── permissions.ts │ │ ├── sub-organizations.ts │ │ └── tenants.ts ├── analytics │ ├── domains.ts │ ├── filters.ts │ ├── impressions.ts │ ├── index.ts │ ├── insights │ │ ├── IndustryInsightQueries.ts │ │ ├── IndustryInsightsQueryBuilder.ts │ │ └── OrganizationSettings.ts │ ├── licenses.ts │ ├── metricQueries.ts │ ├── metricQueryBuilder.ts │ ├── queries.ts │ ├── queryBuilder.ts │ ├── releases │ │ └── platforms.ts │ └── statistics.ts ├── encoding │ ├── codecConfigurations.ts │ ├── encodings │ │ ├── drms.ts │ │ ├── index.ts │ │ ├── machineLearning │ │ │ ├── index.ts │ │ │ └── objectDetection.ts │ │ ├── muxings.ts │ │ └── streams │ │ │ ├── burnInSubtitles.ts │ │ │ ├── filters.ts │ │ │ ├── index.ts │ │ │ ├── sprites.ts │ │ │ └── thumbnails.ts │ ├── filters.ts │ ├── index.ts │ ├── infrastructure │ │ ├── aws.ts │ │ └── index.ts │ ├── inputs.ts │ ├── manifests │ │ ├── dash │ │ │ ├── dashManifestAdaptationSets.ts │ │ │ ├── dashManifestContentProtections.ts │ │ │ ├── dashManifestCustomXmlElements.ts │ │ │ ├── dashManifestPeriods.ts │ │ │ ├── dashManifestRepresentations.ts │ │ │ └── index.ts │ │ ├── hls │ │ │ ├── hlsManifestMedia.ts │ │ │ ├── hlsManifestStreams.ts │ │ │ └── index.ts │ │ ├── index.ts │ │ └── smooth │ │ │ ├── index.ts │ │ │ ├── smoothManifestContentProtections.ts │ │ │ └── smoothManifestRepresentations.ts │ ├── outputs.ts │ └── statistics │ │ ├── index.ts │ │ └── liveStatistics.ts ├── index.ts ├── notifications │ ├── emails.ts │ ├── index.ts │ ├── types.ts │ └── webhooks.ts ├── player │ ├── analytics.ts │ ├── channels.ts │ ├── customBuilds.ts │ ├── domains.ts │ ├── index.ts │ ├── licenses.ts │ ├── statistics.ts │ ├── thirdPartyLicensing.ts │ └── webCustomPlayerBuildDomain.ts └── utils │ ├── BitmovinError.ts │ ├── DateUtils.ts │ ├── Logger.ts │ ├── UrlUtils.ts │ ├── Utils.ts │ ├── enums.ts │ ├── http.ts │ └── types.ts ├── examples ├── analytics │ ├── 01_industry_insights.js │ ├── 02_organization_settings.js │ ├── 03_impressions.js │ ├── 04_filters.js │ └── 05_releases.js ├── encoding │ ├── .gitignore │ ├── 01_simple_encoding_dash_manifest.js │ ├── 02_simple_encoding_dash_cenc_hls_fairplay.js │ ├── 03_start_livestream_dash_hls.js │ ├── 04_stop_livestream.js │ ├── 05_live_to_vod_hls_manifest.js │ ├── 06_live_to_vod_dash_manifest.js │ ├── 07_encoding_dash_hls_thumbnail.js │ ├── 08_encoding_hls_aes128.js │ ├── 09_simple_encoding_mp4.js │ ├── 10_encoding_hls_aes128_subtitle.js │ ├── 11_simple_encoding_mp4_smooth_manifest.js │ ├── 12_dash_manifest_vtt_subtitles.js │ ├── 13_encoding_dash_hls_merged_audio_streams.js │ ├── 14_hls_dash_encoding_stream_condition.js │ ├── 15_simple_encoding_dash_manifest_offset_and_duration.js │ ├── 16_dash_on_demand.js │ ├── 17_dash_on_demand_with_cenc_drm.js │ ├── 18_simple_encoding_webm_in_dash_manifest.js │ ├── 19_Create_per_title_encoding_mp4.js │ ├── 20_simple_encoding_mp4_with_burned_in_srt_subtitle.js │ └── README.md └── player │ ├── 01_custom_player_build.js │ └── README.md ├── jest.config.js ├── package.json ├── tests ├── account │ ├── account.test.ts │ ├── apiKeys.test.ts │ ├── billing │ │ ├── contactDetails.test.ts │ │ ├── invoices.test.ts │ │ └── statements.test.ts │ └── organizations │ │ ├── groups.test.ts │ │ ├── organizations.test.ts │ │ ├── permissions.test.ts │ │ ├── sub-organizations.test.ts │ │ └── tenants.test.ts ├── analytics │ ├── domains.test.ts │ ├── filters.test.ts │ ├── impressions.test.ts │ ├── insights │ │ └── settings.test.ts │ ├── licenses.test.ts │ ├── queries.test.ts │ └── statistics.test.ts ├── assertions.ts ├── bitmovin.test.ts ├── encoding │ ├── burnInSubtitles.test.ts │ ├── codecConfigurations.test.ts │ ├── dashManifestAdaptationSets.test.ts │ ├── dashManifestContentProtections.test.ts │ ├── dashManifestCustomXmlEvents.test.ts │ ├── dashManifestPeriods.test.ts │ ├── dashManifestRepresentations.test.ts │ ├── dashManifests.test.ts │ ├── drms.test.ts │ ├── encodings.test.ts │ ├── filters.test.ts │ ├── hlsManifestMedia.test.ts │ ├── hlsManifestStreams.test.ts │ ├── hlsManifests.test.ts │ ├── infrastructure.test.ts │ ├── inputs.test.ts │ ├── liveStatistics.test.ts │ ├── manifests.test.ts │ ├── muxings.test.ts │ ├── objectDetection.test.ts │ ├── outputs.test.ts │ ├── smoothManifestContentProtections.test.ts │ ├── smoothManifestRepresentations.test.ts │ ├── smoothManifests.test.ts │ ├── sprites.test.ts │ ├── statistics.test.ts │ ├── streams.test.ts │ └── thumbnails.test.ts ├── notifications │ ├── emails │ │ ├── emails.test.ts │ │ ├── error.test.ts │ │ └── liveInputStreamChanged.test.ts │ ├── index.test.ts │ └── webhooks │ │ ├── encodingEncodings.test.ts │ │ └── encodingTransfers.test.ts ├── player │ ├── customPlayerBuilds.test.ts │ ├── licenses.test.ts │ └── statistics.test.ts ├── utils.ts └── utils │ ├── DateUtils.test.ts │ ├── UrlBuilderUtils.test.ts │ └── http.test.ts ├── tsconfig.json ├── tslint.json ├── webpack4.config.js └── yarn.lock /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "node": true, 5 | "es6": true 6 | }, 7 | "parser": "esprima", 8 | "rules": { 9 | "quotes": [2, "single", { 10 | "avoidEscape": true 11 | }], 12 | "strict": [2, "never"], 13 | "no-debugger": "warn", 14 | "no-undef": "error", 15 | "import/no-named-as-default": "off", 16 | "no-unreachable": "warn", 17 | "no-unused-expressions": "warn", 18 | "no-unused-vars": "error", 19 | "eqeqeq": ["error", "always", { 20 | "null": "ignore" 21 | }] 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | .*/dist/**/* 3 | 4 | [include] 5 | 6 | [libs] 7 | 8 | [lints] 9 | 10 | [options] 11 | 12 | [strict] 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | node_modules 5 | 6 | # testing 7 | coverage 8 | 9 | # build 10 | dist 11 | 12 | # misc 13 | .DS_Store 14 | .env 15 | npm-debug.log 16 | jest/ 17 | yarn-error.log 18 | 19 | # User-specific stuff: 20 | .idea/* 21 | 22 | ## File-based project format: 23 | *.iws 24 | 25 | ## Plugin-specific files: 26 | 27 | # IntelliJ 28 | /out/ 29 | 30 | # mpeltonen/sbt-idea plugin 31 | .idea_modules/ 32 | 33 | tests/**/settings.json 34 | tests_it/**/settings.json 35 | 36 | # JIRA plugin 37 | atlassian-ide-plugin.xml 38 | 39 | # Crashlytics plugin (for Android Studio and IntelliJ) 40 | com_crashlytics_export_strings.xml 41 | crashlytics.properties 42 | crashlytics-build.properties 43 | fabric.properties 44 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | lts/dubnium -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "bracketSpacing": false, 4 | "jsxBracketSameLine": true, 5 | "semi": true, 6 | "printWidth": 120 7 | } 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "node" 4 | script: 5 | - "yarn format-check" 6 | - "yarn lint" 7 | - "yarn lint-examples" 8 | - "yarn coverage-ci" 9 | - "yarn run codecov" 10 | - "yarn build" 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Contentful 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /bitmovin/account/apiKeys.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import {utils} from '../utils/http'; 4 | import {HttpClient} from '../utils/types'; 5 | 6 | const apiKeys = (configuration, httpClient: HttpClient) => { 7 | const apiKeysBaseUrl = urljoin(configuration.apiBaseUrl, 'account', 'api-keys'); 8 | const {get, post, delete_} = httpClient; 9 | 10 | const resourceDetails = apiKeyId => { 11 | const url = urljoin(apiKeysBaseUrl, apiKeyId); 12 | return get(configuration, url); 13 | }; 14 | 15 | const list = utils.buildListCallFunction(httpClient, configuration, apiKeysBaseUrl); 16 | 17 | const create = () => { 18 | const url = apiKeysBaseUrl; 19 | return post(configuration, url); 20 | }; 21 | 22 | const deleteApiKey = apiKeyId => { 23 | const url = urljoin(apiKeysBaseUrl, apiKeyId); 24 | return delete_(configuration, url); 25 | }; 26 | 27 | const resource = Object.assign(resourceDetails, {delete: deleteApiKey, create, list}); 28 | return resource; 29 | }; 30 | 31 | export default apiKeys; 32 | -------------------------------------------------------------------------------- /bitmovin/account/billing/contactDetails.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http from '../../utils/http'; 4 | import {HttpClient} from '../../utils/types'; 5 | 6 | export const contactDetails = (configuration, httpClient: HttpClient) => { 7 | const contactDetailsBaseUrl = urljoin(configuration.apiBaseUrl, 'account', 'billing', 'contact-details'); 8 | const {get, put} = httpClient; 9 | 10 | return { 11 | details: () => { 12 | return get(configuration, contactDetailsBaseUrl); 13 | }, 14 | update: contactDetailsPayload => { 15 | return put(configuration, contactDetailsBaseUrl, contactDetailsPayload); 16 | } 17 | }; 18 | }; 19 | 20 | export default configuration => { 21 | return contactDetails(configuration, http); 22 | }; 23 | -------------------------------------------------------------------------------- /bitmovin/account/billing/index.ts: -------------------------------------------------------------------------------- 1 | import contactDetails from './contactDetails'; 2 | import invoices from './invoices'; 3 | import statements from './statements'; 4 | 5 | const billing = configuration => { 6 | return { 7 | statements: statements(configuration), 8 | invoices: invoices(configuration), 9 | contactDetails: contactDetails(configuration) 10 | }; 11 | }; 12 | 13 | export default billing; 14 | -------------------------------------------------------------------------------- /bitmovin/account/billing/invoices.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../utils/http'; 4 | import {HttpClient} from '../../utils/types'; 5 | 6 | export const invoices = (configuration, httpClient: HttpClient) => { 7 | const invoicesBaseUrl = urljoin(configuration.apiBaseUrl, 'account', 'billing', 'invoices'); 8 | const {get} = httpClient; 9 | 10 | return { 11 | encoding: { 12 | list: (limit, offset) => { 13 | let url = urljoin(invoicesBaseUrl, 'encoding'); 14 | const getParams = utils.buildGetParamString({ 15 | limit, 16 | offset 17 | }); 18 | if (getParams.length > 0) { 19 | url = urljoin(url, getParams); 20 | } 21 | return get(configuration, url); 22 | } 23 | }, 24 | player: { 25 | list: (limit, offset) => { 26 | let url = urljoin(invoicesBaseUrl, 'player'); 27 | const getParams = utils.buildGetParamString({ 28 | limit, 29 | offset 30 | }); 31 | if (getParams.length > 0) { 32 | url = urljoin(url, getParams); 33 | } 34 | return get(configuration, url); 35 | } 36 | }, 37 | analytics: { 38 | list: (limit, offset) => { 39 | let url = urljoin(invoicesBaseUrl, 'analytics'); 40 | const getParams = utils.buildGetParamString({ 41 | limit, 42 | offset 43 | }); 44 | if (getParams.length > 0) { 45 | url = urljoin(url, getParams); 46 | } 47 | return get(configuration, url); 48 | } 49 | } 50 | }; 51 | }; 52 | 53 | export default configuration => { 54 | return invoices(configuration, http); 55 | }; 56 | -------------------------------------------------------------------------------- /bitmovin/account/billing/statements.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../utils/http'; 4 | import {HttpClient} from '../../utils/types'; 5 | 6 | export const statements = (configuration, httpClient: HttpClient) => { 7 | const statementsBaseUrl = urljoin(configuration.apiBaseUrl, 'account', 'billing', 'statements'); 8 | const {get} = httpClient; 9 | 10 | return { 11 | encoding: { 12 | list: (limit, offset) => { 13 | let url = urljoin(statementsBaseUrl, 'encoding'); 14 | const getParams = utils.buildGetParamString({ 15 | limit, 16 | offset 17 | }); 18 | if (getParams.length > 0) { 19 | url = urljoin(url, getParams); 20 | } 21 | return get(configuration, url); 22 | } 23 | }, 24 | player: { 25 | list: (limit, offset) => { 26 | let url = urljoin(statementsBaseUrl, 'player'); 27 | const getParams = utils.buildGetParamString({ 28 | limit, 29 | offset 30 | }); 31 | if (getParams.length > 0) { 32 | url = urljoin(url, getParams); 33 | } 34 | return get(configuration, url); 35 | } 36 | }, 37 | analytics: { 38 | list: (limit, offset) => { 39 | let url = urljoin(statementsBaseUrl, 'analytics'); 40 | const getParams = utils.buildGetParamString({ 41 | limit, 42 | offset 43 | }); 44 | if (getParams.length > 0) { 45 | url = urljoin(url, getParams); 46 | } 47 | return get(configuration, url); 48 | } 49 | } 50 | }; 51 | }; 52 | 53 | export default configuration => { 54 | return statements(configuration, http); 55 | }; 56 | -------------------------------------------------------------------------------- /bitmovin/account/index.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http from '../utils/http'; 4 | import {ApiResource, Details, HttpClient, InternalConfiguration} from '../utils/types'; 5 | 6 | import apiKeys from './apiKeys'; 7 | import billing from './billing'; 8 | import organizations from './organizations'; 9 | 10 | export const account = (configuration: InternalConfiguration, httpClient: HttpClient): Account => { 11 | const {get, post} = httpClient; 12 | const accountBaseUrl = urljoin(configuration.apiBaseUrl, 'account'); 13 | 14 | const information: Details = () => { 15 | const url = urljoin(accountBaseUrl, '/information'); 16 | 17 | return get(configuration, url); 18 | }; 19 | 20 | const login = (eMail: string, password: string) => { 21 | const url = urljoin(accountBaseUrl, '/login'); 22 | const loginRequestPayload = { 23 | eMail, 24 | password 25 | }; 26 | 27 | return post, any>(configuration, url, loginRequestPayload); 28 | }; 29 | 30 | const changePassword = (eMail, currentPassword, newPassword) => { 31 | const url = urljoin(accountBaseUrl, '/password/change'); 32 | const changePasswordPayload = { 33 | eMail, 34 | currentPassword, 35 | newPassword 36 | }; 37 | return post, any>(configuration, url, changePasswordPayload); 38 | }; 39 | 40 | return { 41 | information, 42 | login, 43 | changePassword, 44 | billing: billing(configuration), 45 | organizations: organizations(configuration), 46 | apiKeys: apiKeys(configuration, httpClient) 47 | }; 48 | }; 49 | 50 | export interface Account { 51 | information: Details; 52 | login: (eMail: string, password: string) => Promise>; 53 | changePassword: (eMail: string, currentPassword: string, newPassword: string) => Promise>; 54 | billing: any; 55 | organizations: any; 56 | apiKeys: any; 57 | } 58 | 59 | export default (configuration): Account => { 60 | return account(configuration, http); 61 | }; 62 | -------------------------------------------------------------------------------- /bitmovin/account/organizations/groups.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http from '../../utils/http'; 4 | import {HttpClient} from '../../utils/types'; 5 | 6 | import permissions from './permissions'; 7 | import tenants from './tenants'; 8 | 9 | export const groups = (configuration, organizationId, httpClient: HttpClient) => { 10 | const {get, post, delete_} = httpClient; 11 | const groupsBaseUrl = urljoin(configuration.apiBaseUrl, 'account', 'organizations', organizationId, 'groups'); 12 | 13 | const resourceDetails = groupId => { 14 | return { 15 | details: () => { 16 | const url = urljoin(groupsBaseUrl, groupId); 17 | return get(configuration, url); 18 | }, 19 | delete: () => { 20 | const url = urljoin(groupsBaseUrl, groupId); 21 | return delete_(configuration, url); 22 | }, 23 | permissions: permissions(configuration, organizationId, groupId), 24 | tenants: tenants(configuration, organizationId, groupId) 25 | }; 26 | }; 27 | 28 | const add = group => { 29 | const url = urljoin(groupsBaseUrl); 30 | return post(configuration, url, group); 31 | }; 32 | 33 | const list = () => { 34 | const url = urljoin(groupsBaseUrl); 35 | return get(configuration, url); 36 | }; 37 | 38 | const resource = Object.assign(resourceDetails, {add, list}); 39 | return resource; 40 | }; 41 | 42 | export default (configuration, organizationId) => { 43 | return groups(configuration, organizationId, http); 44 | }; 45 | -------------------------------------------------------------------------------- /bitmovin/account/organizations/index.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http from '../../utils/http'; 4 | import {HttpClient} from '../../utils/types'; 5 | 6 | import groups from './groups'; 7 | import subOrganizations from './sub-organizations'; 8 | 9 | export const organizations = (configuration, httpClient: HttpClient) => { 10 | const {get, post, delete_, put} = httpClient; 11 | const organizationsBaseUrl = urljoin(configuration.apiBaseUrl, 'account', 'organizations'); 12 | 13 | const resourceDetails = organizationId => { 14 | return { 15 | details: () => { 16 | const url = urljoin(organizationsBaseUrl, organizationId); 17 | return get(configuration, url); 18 | }, 19 | delete: () => { 20 | const url = urljoin(organizationsBaseUrl, organizationId); 21 | return delete_(configuration, url); 22 | }, 23 | update: organization => { 24 | const url = urljoin(organizationsBaseUrl, organizationId); 25 | return put(configuration, url, organization); 26 | }, 27 | groups: groups(configuration, organizationId), 28 | subOrganizations: subOrganizations(configuration, organizationId) 29 | }; 30 | }; 31 | 32 | const add = organization => { 33 | const url = urljoin(organizationsBaseUrl); 34 | return post(configuration, url, organization); 35 | }; 36 | 37 | const list = () => { 38 | const url = urljoin(organizationsBaseUrl); 39 | return get(configuration, url); 40 | }; 41 | 42 | const resource = Object.assign(resourceDetails, {add, list}); 43 | return resource; 44 | }; 45 | 46 | export default configuration => { 47 | return organizations(configuration, http); 48 | }; 49 | -------------------------------------------------------------------------------- /bitmovin/account/organizations/permissions.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http from '../../utils/http'; 4 | import {HttpClient} from '../../utils/types'; 5 | 6 | export const permissions = (configuration, organizationId, groupId, httpClient: HttpClient) => { 7 | const {get, post, delete_} = httpClient; 8 | const permissionsBaseUrl = urljoin( 9 | configuration.apiBaseUrl, 10 | 'account', 11 | 'organizations', 12 | organizationId, 13 | 'groups', 14 | groupId, 15 | 'permissions' 16 | ); 17 | 18 | const resourceDetails = permissionId => { 19 | return { 20 | details: () => { 21 | const url = urljoin(permissionsBaseUrl, permissionId); 22 | return get(configuration, url); 23 | }, 24 | delete: () => { 25 | const url = urljoin(permissionsBaseUrl, permissionId); 26 | return delete_(configuration, url); 27 | } 28 | }; 29 | }; 30 | 31 | const add = permission => { 32 | const url = urljoin(permissionsBaseUrl); 33 | return post(configuration, url, permission); 34 | }; 35 | 36 | const list = () => { 37 | const url = urljoin(permissionsBaseUrl); 38 | return get(configuration, url); 39 | }; 40 | 41 | const resource = Object.assign(resourceDetails, {add, list}); 42 | return resource; 43 | }; 44 | 45 | export default (configuration, organizationId, groupId) => { 46 | return permissions(configuration, organizationId, groupId, http); 47 | }; 48 | -------------------------------------------------------------------------------- /bitmovin/account/organizations/sub-organizations.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http from '../../utils/http'; 4 | import {HttpClient} from '../../utils/types'; 5 | 6 | export const subOrganizations = (configuration, organizationId, httpClient: HttpClient) => { 7 | const {get} = httpClient; 8 | const subOrganizationBaseUrl = urljoin( 9 | configuration.apiBaseUrl, 10 | 'account', 11 | 'organizations', 12 | organizationId, 13 | 'sub-organizations' 14 | ); 15 | 16 | const list = () => { 17 | const url = urljoin(subOrganizationBaseUrl); 18 | return get(configuration, url); 19 | }; 20 | 21 | const resource = Object.assign({list}); 22 | return resource; 23 | }; 24 | 25 | export default (configuration, organizationId) => { 26 | return subOrganizations(configuration, organizationId, http); 27 | }; 28 | -------------------------------------------------------------------------------- /bitmovin/account/organizations/tenants.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http from '../../utils/http'; 4 | import {HttpClient} from '../../utils/types'; 5 | 6 | export const tenants = (configuration, organizationId, groupId, httpClient: HttpClient) => { 7 | const {get, post, delete_} = httpClient; 8 | const tenantsBaseUrl = urljoin( 9 | configuration.apiBaseUrl, 10 | 'account', 11 | 'organizations', 12 | organizationId, 13 | 'groups', 14 | groupId, 15 | 'tenants' 16 | ); 17 | 18 | const resourceDetails = tenantId => { 19 | return { 20 | details: () => { 21 | const url = urljoin(tenantsBaseUrl, tenantId); 22 | return get(configuration, url); 23 | }, 24 | delete: () => { 25 | const url = urljoin(tenantsBaseUrl, tenantId); 26 | return delete_(configuration, url); 27 | } 28 | }; 29 | }; 30 | 31 | const add = tenant => { 32 | const url = urljoin(tenantsBaseUrl); 33 | return post(configuration, url, tenant); 34 | }; 35 | 36 | const list = () => { 37 | const url = urljoin(tenantsBaseUrl); 38 | return get(configuration, url); 39 | }; 40 | 41 | const resource = Object.assign(resourceDetails, {add, list}); 42 | return resource; 43 | }; 44 | 45 | export default (configuration, organizationId, groupId) => { 46 | return tenants(configuration, organizationId, groupId, http); 47 | }; 48 | -------------------------------------------------------------------------------- /bitmovin/analytics/domains.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../utils/http'; 4 | import {HttpClient} from '../utils/types'; 5 | 6 | export const domains = (configuration, licenseId, httpClient: HttpClient) => { 7 | const {get, post, delete_} = httpClient; 8 | 9 | const resourceDetails = domainId => { 10 | return { 11 | delete: () => { 12 | const url = urljoin(configuration.apiBaseUrl, 'analytics/licenses', licenseId, 'domains', domainId); 13 | return delete_(configuration, url); 14 | } 15 | }; 16 | }; 17 | 18 | const add = (domain: string) => { 19 | const url = urljoin(configuration.apiBaseUrl, 'analytics/licenses', licenseId, 'domains'); 20 | return post(configuration, url, domain); 21 | }; 22 | 23 | const list = (limit, offset) => { 24 | let url = urljoin(configuration.apiBaseUrl, 'analytics/licenses', licenseId, 'domains'); 25 | 26 | const getParams = utils.buildGetParamString({ 27 | limit, 28 | offset 29 | }); 30 | if (getParams.length > 0) { 31 | url = urljoin(url, getParams); 32 | } 33 | 34 | return get(configuration, url); 35 | }; 36 | 37 | const resource = Object.assign(resourceDetails, {add, list}); 38 | return resource; 39 | }; 40 | 41 | export default (configuration, licenseId) => { 42 | return domains(configuration, licenseId, http); 43 | }; 44 | -------------------------------------------------------------------------------- /bitmovin/analytics/filters.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http from '../utils/http'; 4 | import {HttpClient} from '../utils/types'; 5 | 6 | export interface CustomUserIdQuery { 7 | licenseKey: string; 8 | start: number; 9 | end: number; 10 | query: string; 11 | } 12 | 13 | export interface VideoQuery { 14 | licenseKey: string; 15 | start: number; 16 | end: number; 17 | query: string; 18 | } 19 | 20 | export const filters = (configuration, httpClient: HttpClient) => { 21 | const {post} = httpClient; 22 | const filtersBaseUrl = urljoin(configuration.apiBaseUrl, 'analytics', 'filters'); 23 | 24 | const customUserId = (query: CustomUserIdQuery) => { 25 | const url = urljoin(filtersBaseUrl, 'customUserId'); 26 | return post(configuration, url, query); 27 | }; 28 | 29 | const video = (query: VideoQuery) => { 30 | const url = urljoin(filtersBaseUrl, 'video'); 31 | return post(configuration, url, query); 32 | }; 33 | 34 | const resource = Object.assign({customUserId, video}); 35 | return resource; 36 | }; 37 | 38 | export default configuration => { 39 | return filters(configuration, http); 40 | }; 41 | -------------------------------------------------------------------------------- /bitmovin/analytics/impressions.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http from '../utils/http'; 4 | import {HttpClient} from '../utils/types'; 5 | 6 | export interface ImpressionsQuery { 7 | licenseKey: string; 8 | start: number; 9 | end: number; 10 | filters?: Array<{name: string; operator: string; value: any}>; 11 | } 12 | 13 | export const impressions = (configuration, httpClient: HttpClient) => { 14 | const {post} = httpClient; 15 | const impressionsBaseUrl = urljoin(configuration.apiBaseUrl, 'analytics', 'impressions'); 16 | 17 | const details = (impressionId: string, licenseKey: string) => { 18 | const url = urljoin(impressionsBaseUrl, impressionId); 19 | return post(configuration, url, {licenseKey}); 20 | }; 21 | const list = (query: ImpressionsQuery) => { 22 | const url = impressionsBaseUrl; 23 | return post(configuration, url, query); 24 | }; 25 | 26 | const resource = Object.assign(list, {details}); 27 | return resource; 28 | }; 29 | 30 | export default configuration => { 31 | return impressions(configuration, http); 32 | }; 33 | -------------------------------------------------------------------------------- /bitmovin/analytics/index.ts: -------------------------------------------------------------------------------- 1 | import {InternalConfiguration} from '../utils/types'; 2 | 3 | import analyticsFilters from './filters'; 4 | import analyticsImpressions from './impressions'; 5 | import IndustryInsightQueries from './insights/IndustryInsightQueries'; 6 | import OrganizationSettings from './insights/OrganizationSettings'; 7 | import analyticsLicenses from './licenses'; 8 | import MetricQueries from './metricQueries'; 9 | import analyticsQueries from './queries'; 10 | import analyticsPlatforms, {Platforms} from './releases/platforms'; 11 | import analyticsStatistics from './statistics'; 12 | const ANALYTICS_PATH_QUERIES_ADS = 'analytics/ads/queries'; 13 | const ANALYTICS_PATH_QUERIES = 'analytics/queries'; 14 | const ANALYTICS_PATH_METRIC_QUERIES = 'analytics/metrics'; 15 | const ANALYTICS_PATH_INSIGHTS = 'analytics/insights'; 16 | 17 | export const enum MetricName { 18 | MaxConcurrentViewers = 'max_concurrentviewers', 19 | AvgConcurrentViewers = 'avg_concurrentviewers' 20 | } 21 | 22 | export const enum IndustryInsightMetric { 23 | VideoBitrate = 'video_bitrate', 24 | RebufferPercentage = 'rebuffer_percentage', 25 | ErrorPercentage = 'error_percentage', 26 | Startuptime = 'startuptime', 27 | Videostartuptime = 'videostartuptime' 28 | } 29 | 30 | export const enum IndustryInsightFilter { 31 | Browser = 'browser', 32 | Isp = 'isp', 33 | Country = 'country' 34 | } 35 | 36 | export interface Analytics { 37 | licenses: any; 38 | statistics: any; 39 | impressions: any; 40 | filters: any; 41 | queries: any; 42 | metrics: MetricQueries; 43 | ads: { 44 | queries: any; 45 | }; 46 | releases: { 47 | platforms: Platforms; 48 | }; 49 | insights: { 50 | industry: IndustryInsightQueries; 51 | organizations: OrganizationSettings; 52 | }; 53 | } 54 | 55 | const analytics = (internalConfig: InternalConfiguration): Analytics => ({ 56 | licenses: analyticsLicenses(internalConfig), 57 | queries: analyticsQueries(internalConfig, ANALYTICS_PATH_QUERIES), 58 | ads: { 59 | queries: analyticsQueries(internalConfig, ANALYTICS_PATH_QUERIES_ADS) 60 | }, 61 | metrics: new MetricQueries(internalConfig, ANALYTICS_PATH_METRIC_QUERIES), 62 | impressions: analyticsImpressions(internalConfig), 63 | filters: analyticsFilters(internalConfig), 64 | statistics: analyticsStatistics(internalConfig), 65 | releases: { 66 | platforms: analyticsPlatforms(internalConfig) 67 | }, 68 | insights: { 69 | industry: new IndustryInsightQueries(internalConfig, ANALYTICS_PATH_INSIGHTS), 70 | organizations: new OrganizationSettings(internalConfig, ANALYTICS_PATH_INSIGHTS) 71 | } 72 | }); 73 | 74 | export default analytics; 75 | -------------------------------------------------------------------------------- /bitmovin/analytics/insights/IndustryInsightQueries.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http from '../../utils/http'; 4 | import {HttpClient, InternalConfiguration} from '../../utils/types'; 5 | 6 | import {IndustryInsightsQueryBuilder} from './IndustryInsightsQueryBuilder'; 7 | 8 | export interface IndustryInsightValue { 9 | value?: number; 10 | } 11 | 12 | export interface IndustryInsightQuery { 13 | metric: string; 14 | industry?: string; 15 | subindustry?: string; 16 | [filter: string]: string | undefined; 17 | } 18 | 19 | export default class IndustryInsightQueries { 20 | private baseUrl: string; 21 | 22 | constructor(private configuration: InternalConfiguration, urlPath: string, private httpClient: HttpClient = http) { 23 | this.configuration = configuration; 24 | this.baseUrl = urljoin(configuration.apiBaseUrl, urlPath, 'industry'); 25 | } 26 | 27 | public metric(query: IndustryInsightQuery): Promise { 28 | const {metric, ...data} = query; 29 | return this.httpClient.get(this.configuration, `${urljoin(this.baseUrl, metric)}?${this.encodeQueryData(data)}`); 30 | } 31 | 32 | private encodeQueryData(data) { 33 | return Object.keys(data) 34 | .filter(key => data[key] !== undefined) 35 | .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(data[key])}`) 36 | .join('&'); 37 | } 38 | 39 | get builder(): IndustryInsightsQueryBuilder { 40 | return new IndustryInsightsQueryBuilder(this); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /bitmovin/analytics/insights/IndustryInsightsQueryBuilder.ts: -------------------------------------------------------------------------------- 1 | import {IndustryInsightFilter, IndustryInsightMetric} from '..'; 2 | 3 | import IndustryInsightQueries, {IndustryInsightQuery, IndustryInsightValue} from './IndustryInsightQueries'; 4 | 5 | export class IndustryInsightsQueryBuilder { 6 | private queryObj: IndustryInsightQuery; 7 | 8 | constructor(private queries: IndustryInsightQueries, query?: IndustryInsightQuery) { 9 | this.queryObj = query || { 10 | metric: '' 11 | }; 12 | } 13 | 14 | public metric(metric: IndustryInsightMetric | string): IndustryInsightsQueryBuilder { 15 | return this.extendQuery_({metric}); 16 | } 17 | 18 | public industry(industry: string) { 19 | return this.extendQuery_({industry}); 20 | } 21 | 22 | public subIndustry(subIndustry: string) { 23 | return this.extendQuery_({subindustry: subIndustry}); 24 | } 25 | 26 | public filter(name: IndustryInsightFilter, value: string) { 27 | return this.extendQuery_({ 28 | [name]: value 29 | }); 30 | } 31 | 32 | public extendQuery_(extensions: any): IndustryInsightsQueryBuilder { 33 | return new IndustryInsightsQueryBuilder(this.queries, {...this.queryObj, ...extensions}); 34 | } 35 | 36 | public query(): Promise { 37 | return this.queries.metric(this.queryObj); 38 | } 39 | 40 | public queryObject(): IndustryInsightQuery { 41 | return this.queryObj; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /bitmovin/analytics/insights/OrganizationSettings.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http from '../../utils/http'; 4 | import {HttpClient, InternalConfiguration} from '../../utils/types'; 5 | 6 | export interface Settings { 7 | orgId: string; 8 | includeInInsights: boolean; 9 | industry: string; 10 | subIndustry: string; 11 | isTrial: boolean; 12 | } 13 | 14 | export default class OrganizationSettings { 15 | private baseUrl: string; 16 | 17 | constructor(private configuration: InternalConfiguration, urlPath: string, private httpClient: HttpClient = http) { 18 | this.configuration = configuration; 19 | this.baseUrl = urljoin(configuration.apiBaseUrl, urlPath, 'organizations'); 20 | } 21 | 22 | public settings(orgId: string) { 23 | return { 24 | details: (): Promise => { 25 | return this.httpClient.get(this.configuration, urljoin(this.baseUrl, orgId, 'settings')); 26 | }, 27 | update: (settings: {includeInInsights: boolean}): Promise => { 28 | return this.httpClient.put(this.configuration, urljoin(this.baseUrl, orgId, 'settings'), settings); 29 | } 30 | }; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /bitmovin/analytics/licenses.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../utils/http'; 4 | import {HttpClient} from '../utils/types'; 5 | 6 | import domains from './domains'; 7 | 8 | export const licenses = (configuration, httpClient: HttpClient) => { 9 | const {get, post, put} = httpClient; 10 | const resourceDetails = licenseId => { 11 | return { 12 | details: () => { 13 | const url = urljoin(configuration.apiBaseUrl, 'analytics/licenses', licenseId); 14 | return get(configuration, url); 15 | }, 16 | update: license => { 17 | const url = urljoin(configuration.apiBaseUrl, 'analytics/licenses', licenseId); 18 | return put(configuration, url, license); 19 | }, 20 | domains: domains(configuration, licenseId) 21 | }; 22 | }; 23 | 24 | const create = licensePayload => { 25 | const url = urljoin(configuration.apiBaseUrl, 'analytics/licenses'); 26 | return post(configuration, url, licensePayload); 27 | }; 28 | 29 | const list = (limit, offset) => { 30 | let url = urljoin(configuration.apiBaseUrl, 'analytics/licenses'); 31 | 32 | const getParams = utils.buildGetParamString({ 33 | limit, 34 | offset 35 | }); 36 | if (getParams.length > 0) { 37 | url = urljoin(url, getParams); 38 | } 39 | 40 | return get(configuration, url); 41 | }; 42 | 43 | const reorder = (licenseId, orderIndex) => { 44 | let url = urljoin(configuration.apiBaseUrl, 'analytics/licenses', licenseId, 'changeorder'); 45 | 46 | const getParams = utils.buildGetParamString({ 47 | orderIndex 48 | }); 49 | if (getParams.length > 0) { 50 | url = urljoin(url, getParams); 51 | } 52 | 53 | return post(configuration, url); 54 | }; 55 | 56 | const resource = Object.assign(resourceDetails, {create, list, reorder}); 57 | return resource; 58 | }; 59 | 60 | export default configuration => { 61 | return licenses(configuration, http); 62 | }; 63 | -------------------------------------------------------------------------------- /bitmovin/analytics/metricQueries.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http from '../utils/http'; 4 | import {HttpClient} from '../utils/types'; 5 | 6 | import {MetricQueryBuilder} from './metricQueryBuilder'; 7 | 8 | export interface MetricQuery { 9 | metric: string; 10 | filters: Array<{name: string; operator: string; value: any}>; 11 | groupBy: string[]; 12 | orderBy: Array<{name: string; order: string}>; 13 | } 14 | 15 | export default class MetricQueries { 16 | private configuration; 17 | private baseUrl: string; 18 | private httpClient: HttpClient; 19 | 20 | constructor(configuration, urlPath: string, httpClient: HttpClient = http) { 21 | this.httpClient = httpClient; 22 | this.configuration = configuration; 23 | this.baseUrl = urljoin(configuration.apiBaseUrl, urlPath); 24 | } 25 | 26 | public metric(query: MetricQuery): Promise<{}> { 27 | return this.httpClient.post(this.configuration, urljoin(this.baseUrl, query.metric), query); 28 | } 29 | 30 | get builder(): MetricQueryBuilder { 31 | return new MetricQueryBuilder(this); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /bitmovin/analytics/metricQueryBuilder.ts: -------------------------------------------------------------------------------- 1 | import {MetricName} from '.'; 2 | import MetricQueries, {MetricQuery} from './metricQueries'; 3 | 4 | export class MetricQueryBuilder { 5 | private queryObj: MetricQuery; 6 | private queries: MetricQueries; 7 | 8 | constructor(queries: MetricQueries, query?: MetricQuery) { 9 | this.queries = queries; 10 | this.queryObj = query || { 11 | metric: '', 12 | filters: [], 13 | groupBy: [], 14 | orderBy: [] 15 | }; 16 | } 17 | 18 | public metric(metric: MetricName | string): MetricQueryBuilder { 19 | return this.extendQuery_({metric}); 20 | } 21 | 22 | public between(start, end): MetricQueryBuilder { 23 | return this.extendQuery_({start, end}); 24 | } 25 | 26 | public interval(interval: string): MetricQueryBuilder { 27 | return this.extendQuery_({interval}); 28 | } 29 | 30 | public filter(name: string, operator: string, value: any): MetricQueryBuilder { 31 | return this.extendQuery_({filters: [...this.queryObj.filters, {name, operator, value}]}); 32 | } 33 | 34 | public groupBy(dimension: string): MetricQueryBuilder { 35 | return this.extendQuery_({groupBy: [...this.queryObj.groupBy, dimension]}); 36 | } 37 | 38 | public orderBy(name: string, order: string): MetricQueryBuilder { 39 | return this.extendQuery_({orderBy: [...this.queryObj.orderBy, {name, order}]}); 40 | } 41 | 42 | public percentile_(percentile: number): MetricQueryBuilder { 43 | return this.extendQuery_({percentile}); 44 | } 45 | 46 | public licenseKey(licenseKey: string): MetricQueryBuilder { 47 | return this.extendQuery_({licenseKey}); 48 | } 49 | 50 | public limit(limit: number): MetricQueryBuilder { 51 | return this.extendQuery_({limit}); 52 | } 53 | 54 | public offset(offset: number): MetricQueryBuilder { 55 | return this.extendQuery_({offset}); 56 | } 57 | 58 | public async(async) { 59 | return this.extendQuery_({async}); 60 | } 61 | 62 | public jobId(jobId) { 63 | return this.extendQuery_({jobId}); 64 | } 65 | 66 | public cursor(cursor) { 67 | return this.extendQuery_({cursor}); 68 | } 69 | 70 | public extendQuery_(extensions: any): MetricQueryBuilder { 71 | return new MetricQueryBuilder(this.queries, {...this.queryObj, ...extensions}); 72 | } 73 | 74 | public query(): Promise<{}> { 75 | return this.queries.metric(this.queryObj); 76 | } 77 | 78 | public queryObject(): MetricQuery { 79 | return this.queryObj; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /bitmovin/analytics/queries.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http from '../utils/http'; 4 | import {HttpClient} from '../utils/types'; 5 | 6 | import queryBuilder from './queryBuilder'; 7 | 8 | export const queries = (configuration, httpClient: HttpClient, urlPath: string) => { 9 | const {post} = httpClient; 10 | const baseUrl = urljoin(configuration.apiBaseUrl, urlPath); 11 | 12 | const queryMethods = ['count', 'sum', 'avg', 'min', 'max', 'median', 'percentile', 'stddev', 'variance'].reduce( 13 | (obj, method) => ({...obj, [method]: query => post(configuration, urljoin(baseUrl, method), query)}), 14 | {} 15 | ); 16 | 17 | const fn = Object.assign(() => ({}), queryMethods); 18 | 19 | Object.defineProperty(fn, 'builder', { 20 | get() { 21 | return queryBuilder(queryMethods); 22 | } 23 | }); 24 | 25 | return fn; 26 | }; 27 | 28 | export default (configuration, urlPath) => { 29 | return queries(configuration, http, urlPath); 30 | }; 31 | -------------------------------------------------------------------------------- /bitmovin/analytics/queryBuilder.ts: -------------------------------------------------------------------------------- 1 | class Builder { 2 | private queryObj: { 3 | target: any; 4 | filters: any[]; 5 | groupBy: any[]; 6 | orderBy: any[]; 7 | }; 8 | private aggregations: any; 9 | private percentile: any; 10 | 11 | constructor(aggregations, query?) { 12 | this.aggregations = aggregations; 13 | this.queryObj = 14 | query || 15 | Object.freeze({ 16 | filters: [], 17 | groupBy: [], 18 | orderBy: [] 19 | }); 20 | 21 | Object.keys(aggregations).forEach(key => { 22 | this[key] = dimension => this.extendQuery_({target: aggregations[key], dimension}); 23 | }); 24 | 25 | const defaultPercentile = this.percentile; 26 | this.percentile = (dimension, percentile) => defaultPercentile(dimension).percentile_(percentile); 27 | } 28 | 29 | public between(start, end) { 30 | return this.extendQuery_({start, end}); 31 | } 32 | 33 | public interval(interval) { 34 | return this.extendQuery_({interval}); 35 | } 36 | 37 | public includeContext(includeContext) { 38 | return this.extendQuery_({includeContext}); 39 | } 40 | 41 | public filter(name, operator, value) { 42 | const filter = Object.freeze({name, operator, value}); 43 | return this.extendQuery_({filters: Object.freeze([...this.queryObj.filters, filter])}); 44 | } 45 | 46 | public groupBy(dimension) { 47 | return this.extendQuery_({groupBy: Object.freeze([...this.queryObj.groupBy, dimension])}); 48 | } 49 | 50 | public orderBy(name, order) { 51 | const newOrder = Object.freeze({name, order}); 52 | return this.extendQuery_({orderBy: Object.freeze([...this.queryObj.orderBy, newOrder])}); 53 | } 54 | 55 | public percentile_(percentile) { 56 | return this.extendQuery_({percentile}); 57 | } 58 | 59 | public licenseKey(licenseKey) { 60 | return this.extendQuery_({licenseKey}); 61 | } 62 | 63 | public limit(limit) { 64 | return this.extendQuery_({limit}); 65 | } 66 | 67 | public offset(offset) { 68 | return this.extendQuery_({offset}); 69 | } 70 | 71 | public async(async) { 72 | return this.extendQuery_({async}); 73 | } 74 | 75 | public jobId(jobId) { 76 | return this.extendQuery_({jobId}); 77 | } 78 | 79 | public cursor(cursor) { 80 | return this.extendQuery_({cursor}); 81 | } 82 | 83 | public extendQuery_(extensions) { 84 | return new Builder(this.aggregations, Object.freeze({...this.queryObj, ...extensions})); 85 | } 86 | 87 | public query() { 88 | const {target, ...queryAttrs} = this.queryObj; 89 | return target(queryAttrs); 90 | } 91 | } 92 | 93 | export default aggregations => new Builder(aggregations); 94 | -------------------------------------------------------------------------------- /bitmovin/analytics/releases/platforms.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import {Channel} from '../../player/channels'; 4 | import http, {utils} from '../../utils/http'; 5 | import {ApiResource, Details, HttpClient, List} from '../../utils/types'; 6 | 7 | export enum Platform { 8 | TvOs = 'tvos', 9 | AndroidExo = 'android-exo', 10 | AndroidBitmovin = 'android-bitmovin', 11 | IOs = 'ios', 12 | Web = 'web' 13 | } 14 | 15 | export interface AnalyticsVersion { 16 | version: string; 17 | podName: string; 18 | gitUrl: string; 19 | gitTag: string; 20 | } 21 | 22 | export interface Platforms { 23 | (platformName: Platform): { 24 | channels: { 25 | (channelName: Channel): { 26 | versions: { 27 | (versionNumber: string): { 28 | latest: Details; 29 | list: List; 30 | }; 31 | list: List; 32 | }; 33 | }; 34 | list: List; 35 | }; 36 | }; 37 | list: List; 38 | } 39 | 40 | export const platforms = (configuration, httpClient: HttpClient): Platforms => { 41 | const {get} = httpClient; 42 | const platformResourceDetails = (platformName: Platform) => { 43 | const channelResourceDetails = (channelName: Channel) => { 44 | const versionResourceDetails = (versionNumber: string) => ({ 45 | latest: () => { 46 | const url = urljoin( 47 | configuration.apiBaseUrl, 48 | 'analytics/releases', 49 | platformName, 50 | channelName, 51 | versionNumber, 52 | 'latest' 53 | ); 54 | return get>(configuration, url); 55 | }, 56 | list: utils.buildListCallFunction( 57 | httpClient, 58 | configuration, 59 | urljoin(configuration.apiBaseUrl, 'analytics/releases', platformName, channelName, versionNumber) 60 | ) 61 | }); 62 | 63 | const versionList = utils.buildListCallFunction( 64 | httpClient, 65 | configuration, 66 | urljoin(configuration.apiBaseUrl, 'analytics/releases', platformName, channelName) 67 | ); 68 | 69 | const versionResource = Object.assign(versionResourceDetails, {list: versionList}); 70 | 71 | return {versions: versionResource}; 72 | }; 73 | 74 | const channelList = utils.buildListCallFunction( 75 | httpClient, 76 | configuration, 77 | urljoin(configuration.apiBaseUrl, 'analytics/releases', platformName) 78 | ); 79 | 80 | const channelResource = Object.assign(channelResourceDetails, {list: channelList}); 81 | 82 | return {channels: channelResource}; 83 | }; 84 | 85 | const platformList = utils.buildListCallFunction( 86 | httpClient, 87 | configuration, 88 | urljoin(configuration.apiBaseUrl, 'analytics/releases/platforms') 89 | ); 90 | 91 | const resource = Object.assign(platformResourceDetails, {list: platformList}); 92 | 93 | return resource; 94 | }; 95 | 96 | export default configuration => { 97 | return platforms(configuration, http); 98 | }; 99 | -------------------------------------------------------------------------------- /bitmovin/analytics/statistics.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import BitmovinError from '../utils/BitmovinError'; 4 | import http, {utils} from '../utils/http'; 5 | import {HttpClient} from '../utils/types'; 6 | 7 | export const statistics = (configuration, httpClient: HttpClient) => { 8 | const {get} = httpClient; 9 | 10 | return { 11 | impressions: (licenseKeyId, start, end, interval, offset, limit) => { 12 | if (!start || !end) { 13 | return Promise.reject(new BitmovinError('Not all required params given.', undefined)); 14 | } 15 | 16 | const analyticsStatisticsBaseUrl = urljoin(configuration.apiBaseUrl, '/analytics/statistics/impressions'); 17 | 18 | const getParams = utils.buildGetParamString({ 19 | licenseKeyId, 20 | start, 21 | end, 22 | interval, 23 | offset, 24 | limit 25 | }); 26 | 27 | const url = urljoin(analyticsStatisticsBaseUrl, getParams); 28 | return get(configuration, url); 29 | }, 30 | INTERVAL: { 31 | DAILY: 'DAILY' 32 | } 33 | }; 34 | }; 35 | 36 | export default configuration => { 37 | return statistics(configuration, http); 38 | }; 39 | -------------------------------------------------------------------------------- /bitmovin/encoding/codecConfigurations.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../utils/http'; 4 | import {HttpClient} from '../utils/types'; 5 | 6 | export const codecConfigurations = (configuration, httpClient: HttpClient) => { 7 | const {get, post, delete_} = httpClient; 8 | const typeFn = typeUrl => { 9 | const resourceDetails = codecConfigId => { 10 | return { 11 | details: () => { 12 | const url = urljoin(configuration.apiBaseUrl, 'encoding/configurations', typeUrl, codecConfigId); 13 | return get(configuration, url); 14 | }, 15 | customData: () => { 16 | const url = urljoin( 17 | configuration.apiBaseUrl, 18 | 'encoding/configurations', 19 | typeUrl, 20 | codecConfigId, 21 | 'customData' 22 | ); 23 | 24 | return get(configuration, url); 25 | }, 26 | delete: () => { 27 | const url = urljoin(configuration.apiBaseUrl, 'encoding/configurations', typeUrl, codecConfigId); 28 | return delete_(configuration, url); 29 | } 30 | }; 31 | }; 32 | 33 | const create = codecConfig => { 34 | const url = urljoin(configuration.apiBaseUrl, 'encoding/configurations', typeUrl); 35 | 36 | return post(configuration, url, codecConfig); 37 | }; 38 | 39 | const list = utils.buildListCallFunction( 40 | httpClient, 41 | configuration, 42 | urljoin(configuration.apiBaseUrl, 'encoding/configurations', typeUrl) 43 | ); 44 | 45 | const resource = Object.assign(resourceDetails, {create, list}); 46 | return resource; 47 | }; 48 | 49 | return { 50 | h264: typeFn('video/h264'), 51 | h265: typeFn('video/h265'), 52 | aac: typeFn('audio/aac'), 53 | av1: typeFn('video/av1'), 54 | vp9: typeFn('video/vp9'), 55 | ac3: typeFn('audio/ac3'), 56 | eac3: typeFn('audio/eac3'), 57 | vorbis: typeFn('audio/vorbis'), 58 | opus: typeFn('audio/opus'), 59 | mp2: typeFn('audio/mp2'), 60 | mp3: typeFn('audio/mp3'), 61 | vp8: typeFn('video/vp8'), 62 | mjpeg: typeFn('video/mjpeg'), 63 | ['he-aac-v1']: typeFn('audio/he-aac-v1'), 64 | ['he-aac-v2']: typeFn('audio/he-aac-v2'), 65 | 66 | list: utils.buildListCallFunction( 67 | httpClient, 68 | configuration, 69 | urljoin(configuration.apiBaseUrl, 'encoding/configurations') 70 | ), 71 | 72 | getType: configurationId => { 73 | const url = urljoin(configuration.apiBaseUrl, 'encoding/configurations', configurationId, 'type'); 74 | 75 | return get(configuration, url); 76 | } 77 | }; 78 | }; 79 | 80 | export default configuration => { 81 | return codecConfigurations(configuration, http); 82 | }; 83 | -------------------------------------------------------------------------------- /bitmovin/encoding/encodings/machineLearning/index.ts: -------------------------------------------------------------------------------- 1 | import http from '../../../utils/http'; 2 | import {HttpClient, InternalConfiguration} from '../../../utils/types'; 3 | 4 | import {objectDetection} from './objectDetection'; 5 | 6 | export const machineLearning = ( 7 | configuration: InternalConfiguration, 8 | encodingId: string, 9 | httpClient: HttpClient 10 | ): MachineLearning => ({ 11 | objectDetection: objectDetection(configuration, encodingId, httpClient) 12 | }); 13 | 14 | export interface MachineLearning { 15 | objectDetection: any; 16 | } 17 | 18 | export default (configuration: InternalConfiguration, encodingId: string): MachineLearning => { 19 | return machineLearning(configuration, encodingId, http); 20 | }; 21 | -------------------------------------------------------------------------------- /bitmovin/encoding/encodings/muxings.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../utils/http'; 4 | import {HttpClient, InternalConfiguration, List} from '../../utils/types'; 5 | 6 | import drms from './drms'; 7 | 8 | export const muxings = (configuration: InternalConfiguration, encodingId: string, httpClient: HttpClient): Muxings => { 9 | const {get, post, delete_} = httpClient; 10 | 11 | const typeFn = typeUrl => { 12 | const resourceDetails = muxingId => { 13 | return { 14 | details: () => { 15 | const url = urljoin(configuration.apiBaseUrl, 'encoding/encodings', encodingId, 'muxings', typeUrl, muxingId); 16 | return get(configuration, url); 17 | }, 18 | customData: () => { 19 | const url = urljoin( 20 | configuration.apiBaseUrl, 21 | 'encoding/encodings', 22 | encodingId, 23 | 'muxings', 24 | typeUrl, 25 | muxingId, 26 | 'customData' 27 | ); 28 | return get(configuration, url); 29 | }, 30 | delete: () => { 31 | const url = urljoin(configuration.apiBaseUrl, 'encoding/encodings', encodingId, 'muxings', typeUrl, muxingId); 32 | 33 | return delete_(configuration, url); 34 | }, 35 | drms: drms(configuration, encodingId, typeUrl, muxingId) 36 | }; 37 | }; 38 | 39 | const add = muxing => { 40 | const url = urljoin(configuration.apiBaseUrl, 'encoding/encodings', encodingId, 'muxings', typeUrl); 41 | return post(configuration, url, muxing); 42 | }; 43 | 44 | const list = utils.buildListCallFunction( 45 | httpClient, 46 | configuration, 47 | urljoin(configuration.apiBaseUrl, 'encoding/encodings', encodingId, 'muxings', typeUrl) 48 | ); 49 | 50 | const resource = Object.assign(resourceDetails, { 51 | add, 52 | list 53 | }); 54 | 55 | return resource; 56 | }; 57 | 58 | return { 59 | fmp4: typeFn('fmp4'), 60 | ts: typeFn('ts'), 61 | broadcastTs: typeFn('broadcast-ts'), 62 | mp4: typeFn('mp4'), 63 | webm: typeFn('webm'), 64 | progressiveWebm: typeFn('progressive-webm'), 65 | 66 | list: utils.buildListCallFunction( 67 | httpClient, 68 | configuration, 69 | urljoin(configuration.apiBaseUrl, 'encoding/encodings', encodingId, 'muxings') 70 | ) 71 | }; 72 | }; 73 | 74 | interface Muxing {} 75 | 76 | export interface Muxings { 77 | list: List; 78 | fmp4: any; 79 | ts: any; 80 | broadcastTs: any; 81 | mp4: any; 82 | webm: any; 83 | progressiveWebm: any; 84 | } 85 | 86 | export default (configuration: InternalConfiguration, encodingId: string): Muxings => { 87 | return muxings(configuration, encodingId, http); 88 | }; 89 | -------------------------------------------------------------------------------- /bitmovin/encoding/encodings/streams/burnInSubtitles.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../../utils/http'; 4 | import {HttpClient} from '../../../utils/types'; 5 | 6 | export const burnInSubtitles = (configuration, encodingId, streamId, httpClient: HttpClient) => { 7 | const {get, post, delete_} = httpClient; 8 | const typeFn = typeUrl => { 9 | const resourceDetails = burnInSubtitleId => { 10 | return { 11 | details: () => { 12 | const url = urljoin( 13 | configuration.apiBaseUrl, 14 | 'encoding/encodings', 15 | encodingId, 16 | 'streams', 17 | streamId, 18 | 'burn-in-subtitles', 19 | typeUrl, 20 | burnInSubtitleId 21 | ); 22 | return get(configuration, url); 23 | }, 24 | delete: () => { 25 | const url = urljoin( 26 | configuration.apiBaseUrl, 27 | 'encoding/encodings', 28 | encodingId, 29 | 'streams', 30 | streamId, 31 | 'burn-in-subtitles', 32 | typeUrl, 33 | burnInSubtitleId 34 | ); 35 | return delete_(configuration, url); 36 | } 37 | }; 38 | }; 39 | 40 | const add = burnInSubtitle => { 41 | const url = urljoin( 42 | configuration.apiBaseUrl, 43 | 'encoding/encodings', 44 | encodingId, 45 | 'streams', 46 | streamId, 47 | 'burn-in-subtitles', 48 | typeUrl 49 | ); 50 | return post(configuration, url, burnInSubtitle); 51 | }; 52 | 53 | const list = utils.buildListCallFunction( 54 | httpClient, 55 | configuration, 56 | urljoin( 57 | configuration.apiBaseUrl, 58 | 'encoding/encodings', 59 | encodingId, 60 | 'streams', 61 | streamId, 62 | 'burn-in-subtitles', 63 | typeUrl 64 | ) 65 | ); 66 | 67 | const resource = Object.assign(resourceDetails, {add, list}); 68 | return resource; 69 | }; 70 | 71 | return { 72 | srt: typeFn('srt') 73 | }; 74 | }; 75 | 76 | export default (configuration, encodingId, streamId) => { 77 | return burnInSubtitles(configuration, encodingId, streamId, http); 78 | }; 79 | -------------------------------------------------------------------------------- /bitmovin/encoding/encodings/streams/filters.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../../utils/http'; 4 | import {HttpClient, InternalConfiguration} from '../../../utils/types'; 5 | 6 | export const filters = ( 7 | configuration: InternalConfiguration, 8 | encodingId: string, 9 | streamId: string, 10 | httpClient: HttpClient 11 | ) => { 12 | const {post, delete_} = httpClient; 13 | 14 | const resourceDetails = filterId => { 15 | return { 16 | delete: () => { 17 | const url = urljoin( 18 | configuration.apiBaseUrl, 19 | 'encoding/encodings', 20 | encodingId, 21 | 'streams', 22 | streamId, 23 | 'filters', 24 | filterId 25 | ); 26 | 27 | return delete_(configuration, url); 28 | } 29 | }; 30 | }; 31 | 32 | const add = filter => { 33 | const url = urljoin(configuration.apiBaseUrl, 'encoding/encodings', encodingId, 'streams', streamId, 'filters'); 34 | return post(configuration, url, filter); 35 | }; 36 | 37 | const list = utils.buildListCallFunction( 38 | httpClient, 39 | configuration, 40 | urljoin(configuration.apiBaseUrl, 'encoding/encodings', encodingId, 'streams', streamId, 'filters') 41 | ); 42 | 43 | const deleteAll = () => { 44 | const url = urljoin(configuration.apiBaseUrl, 'encoding/encodings', encodingId, 'streams', streamId, 'filters'); 45 | return delete_(configuration, url); 46 | }; 47 | 48 | const resource = Object.assign(resourceDetails, {add, list, deleteAll}); 49 | return resource; 50 | }; 51 | 52 | export default (configuration, encodingId, streamId) => { 53 | return filters(configuration, encodingId, streamId, http); 54 | }; 55 | -------------------------------------------------------------------------------- /bitmovin/encoding/encodings/streams/index.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../../utils/http'; 4 | import { 5 | ApiResource, 6 | Create, 7 | CustomData, 8 | Delete, 9 | Details, 10 | HttpClient, 11 | InternalConfiguration, 12 | List 13 | } from '../../../utils/types'; 14 | 15 | import {burnInSubtitles} from './burnInSubtitles'; 16 | import {filters} from './filters'; 17 | import {sprites} from './sprites'; 18 | import {thumbnails} from './thumbnails'; 19 | 20 | export const streams = (configuration: InternalConfiguration, encodingId: string, httpClient: HttpClient): Streams => { 21 | const {get, post, delete_} = httpClient; 22 | 23 | const resourceDetails = (streamId): StreamDetail => { 24 | return { 25 | details: () => { 26 | const url = urljoin(configuration.apiBaseUrl, 'encoding/encodings', encodingId, 'streams', streamId); 27 | 28 | return get(configuration, url); 29 | }, 30 | customData: () => { 31 | const url = urljoin( 32 | configuration.apiBaseUrl, 33 | 'encoding/encodings', 34 | encodingId, 35 | 'streams', 36 | streamId, 37 | 'customData' 38 | ); 39 | return get(configuration, url); 40 | }, 41 | delete: () => { 42 | const url = urljoin(configuration.apiBaseUrl, 'encoding/encodings', encodingId, 'streams', streamId); 43 | return delete_(configuration, url); 44 | }, 45 | inputDetails: () => { 46 | const url = urljoin(configuration.apiBaseUrl, 'encoding/encodings', encodingId, 'streams', streamId, 'input'); 47 | return get(configuration, url); 48 | }, 49 | filters: filters(configuration, encodingId, streamId, httpClient), 50 | thumbnails: thumbnails(configuration, encodingId, streamId, httpClient), 51 | sprites: sprites(configuration, encodingId, streamId, httpClient), 52 | burnInSubtitles: burnInSubtitles(configuration, encodingId, streamId, httpClient) 53 | }; 54 | }; 55 | 56 | const add = stream => { 57 | const url = urljoin(configuration.apiBaseUrl, 'encoding/encodings', encodingId, 'streams'); 58 | 59 | return post, any>(configuration, url, stream); 60 | }; 61 | 62 | const list = utils.buildListCallFunction( 63 | httpClient, 64 | configuration, 65 | urljoin(configuration.apiBaseUrl, 'encoding/encodings', encodingId, 'streams') 66 | ); 67 | 68 | const resource = Object.assign(resourceDetails, {add, list}); 69 | return resource; 70 | }; 71 | 72 | interface Stream {} 73 | interface StreamInput {} 74 | 75 | interface StreamDetail { 76 | details: Details; 77 | inputDetails: Details; 78 | delete: Delete<{}>; 79 | customData: CustomData; 80 | filters: any; 81 | thumbnails: any; 82 | sprites: any; 83 | burnInSubtitles: any; 84 | } 85 | 86 | export interface Streams { 87 | (id: string): StreamDetail; 88 | list: List; 89 | add: Create; 90 | } 91 | 92 | export default (configuration: InternalConfiguration, encodingId: string): Streams => { 93 | return streams(configuration, encodingId, http); 94 | }; 95 | -------------------------------------------------------------------------------- /bitmovin/encoding/encodings/streams/sprites.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../../utils/http'; 4 | import {HttpClient} from '../../../utils/types'; 5 | 6 | export const sprites = (configuration, encodingId, streamId, httpClient: HttpClient) => { 7 | const {get, post, delete_} = httpClient; 8 | const resourceDetails = spriteId => { 9 | return { 10 | details: () => { 11 | const url = urljoin( 12 | configuration.apiBaseUrl, 13 | 'encoding/encodings', 14 | encodingId, 15 | 'streams', 16 | streamId, 17 | 'sprites', 18 | spriteId 19 | ); 20 | 21 | return get(configuration, url); 22 | }, 23 | customData: () => { 24 | const url = urljoin( 25 | configuration.apiBaseUrl, 26 | 'encoding/encodings', 27 | encodingId, 28 | 'streams', 29 | streamId, 30 | 'sprites', 31 | spriteId, 32 | 'customData' 33 | ); 34 | 35 | return get(configuration, url); 36 | }, 37 | delete: () => { 38 | const url = urljoin( 39 | configuration.apiBaseUrl, 40 | 'encoding/encodings', 41 | encodingId, 42 | 'streams', 43 | streamId, 44 | 'sprites', 45 | spriteId 46 | ); 47 | 48 | return delete_(configuration, url); 49 | } 50 | }; 51 | }; 52 | 53 | const add = sprite => { 54 | const url = urljoin(configuration.apiBaseUrl, 'encoding/encodings', encodingId, 'streams', streamId, 'sprites'); 55 | return post(configuration, url, sprite); 56 | }; 57 | 58 | const list = utils.buildListCallFunction( 59 | httpClient, 60 | configuration, 61 | urljoin(configuration.apiBaseUrl, 'encoding/encodings', encodingId, 'streams', streamId, 'sprites') 62 | ); 63 | 64 | const resource = Object.assign(resourceDetails, {add, list}); 65 | return resource; 66 | }; 67 | 68 | export default (configuration, encodingId, streamId) => { 69 | return sprites(configuration, encodingId, streamId, http); 70 | }; 71 | -------------------------------------------------------------------------------- /bitmovin/encoding/encodings/streams/thumbnails.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../../utils/http'; 4 | import {HttpClient} from '../../../utils/types'; 5 | 6 | export const thumbnails = (configuration, encodingId, streamId, httpClient: HttpClient) => { 7 | const {get, post, delete_} = httpClient; 8 | 9 | const details = thumbnailId => { 10 | return { 11 | details: () => { 12 | const url = urljoin( 13 | configuration.apiBaseUrl, 14 | 'encoding/encodings', 15 | encodingId, 16 | 'streams', 17 | streamId, 18 | 'thumbnails', 19 | thumbnailId 20 | ); 21 | return get(configuration, url); 22 | }, 23 | customData: () => { 24 | const url = urljoin( 25 | configuration.apiBaseUrl, 26 | 'encoding/encodings', 27 | encodingId, 28 | 'streams', 29 | streamId, 30 | 'thumbnails', 31 | thumbnailId, 32 | 'customData' 33 | ); 34 | return get(configuration, url); 35 | }, 36 | delete: () => { 37 | const url = urljoin( 38 | configuration.apiBaseUrl, 39 | 'encoding/encodings', 40 | encodingId, 41 | 'streams', 42 | streamId, 43 | 'thumbnails', 44 | thumbnailId 45 | ); 46 | return delete_(configuration, url); 47 | } 48 | }; 49 | }; 50 | 51 | const add = thumbnail => { 52 | const url = urljoin(configuration.apiBaseUrl, 'encoding/encodings', encodingId, 'streams', streamId, 'thumbnails'); 53 | return post(configuration, url, thumbnail); 54 | }; 55 | 56 | const list = utils.buildListCallFunction( 57 | httpClient, 58 | configuration, 59 | urljoin(configuration.apiBaseUrl, 'encoding/encodings', encodingId, 'streams', streamId, 'thumbnails') 60 | ); 61 | 62 | const resourceDetails = Object.assign(details, { 63 | add, 64 | list 65 | }); 66 | 67 | const resource = Object.assign(resourceDetails, {add, list}); 68 | return resource; 69 | }; 70 | 71 | export default (configuration, encodingId, streamId) => { 72 | return thumbnails(configuration, encodingId, streamId, http); 73 | }; 74 | -------------------------------------------------------------------------------- /bitmovin/encoding/filters.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../utils/http'; 4 | import {HttpClient} from '../utils/types'; 5 | 6 | export const filters = (configuration, httpClient: HttpClient) => { 7 | const {get, post, delete_} = httpClient; 8 | 9 | const typeFn = typeUrl => { 10 | const resourceDetails = filterId => { 11 | return { 12 | details: () => { 13 | const url = urljoin(configuration.apiBaseUrl, 'encoding/filters', typeUrl, filterId); 14 | 15 | return get(configuration, url); 16 | }, 17 | customData: () => { 18 | const url = urljoin(configuration.apiBaseUrl, 'encoding/filters', typeUrl, filterId, 'customData'); 19 | 20 | return get(configuration, url); 21 | }, 22 | delete: () => { 23 | const url = urljoin(configuration.apiBaseUrl, 'encoding/filters', typeUrl, filterId); 24 | 25 | return delete_(configuration, url); 26 | } 27 | }; 28 | }; 29 | 30 | const create = filter => { 31 | const url = urljoin(configuration.apiBaseUrl, 'encoding/filters', typeUrl); 32 | 33 | return post(configuration, url, filter); 34 | }; 35 | 36 | const list = utils.buildListCallFunction( 37 | httpClient, 38 | configuration, 39 | urljoin(configuration.apiBaseUrl, 'encoding/filters', typeUrl) 40 | ); 41 | 42 | const resource = Object.assign(resourceDetails, {create, list}); 43 | return resource; 44 | }; 45 | 46 | return { 47 | crop: typeFn('crop'), 48 | deinterlace: typeFn('deinterlace'), 49 | rotate: typeFn('rotate'), 50 | watermark: typeFn('watermark'), 51 | enhancedWatermark: typeFn('enhanced-watermark'), 52 | audioMix: typeFn('audio-mix'), 53 | audioVolume: typeFn('audio-volume'), 54 | denoiseHqdn3d: typeFn('denoise-hqdn3d'), 55 | text: typeFn('text'), 56 | unsharp: typeFn('unsharp'), 57 | scale: typeFn('scale'), 58 | interlace: typeFn('interlace'), 59 | ebuR128SinglePass: typeFn('ebu-r128-single-pass'), 60 | 61 | list: utils.buildListCallFunction(httpClient, configuration, urljoin(configuration.apiBaseUrl, 'encoding/filters')), 62 | getType: filterId => { 63 | const url = urljoin(configuration.apiBaseUrl, 'encoding/filters', filterId, 'type'); 64 | 65 | return get(configuration, url); 66 | } 67 | }; 68 | }; 69 | 70 | export default configuration => { 71 | return filters(configuration, http); 72 | }; 73 | -------------------------------------------------------------------------------- /bitmovin/encoding/index.ts: -------------------------------------------------------------------------------- 1 | import codecConfigurations from './codecConfigurations'; 2 | import {Encodings} from './encodings'; 3 | import encodings from './encodings'; 4 | import filters from './filters'; 5 | import infrastructure from './infrastructure'; 6 | import inputs from './inputs'; 7 | import manifests from './manifests'; 8 | import outputs from './outputs'; 9 | import statistics from './statistics'; 10 | 11 | export interface Encoding { 12 | encodings: Encodings; 13 | codecConfigurations: any; 14 | inputs: any; 15 | outputs: any; 16 | manifests: any; 17 | filters: any; 18 | statistics: any; 19 | infrastructure: any; 20 | } 21 | 22 | const encoding = internalConfig => ({ 23 | encodings: encodings(internalConfig), 24 | codecConfigurations: codecConfigurations(internalConfig), 25 | inputs: inputs(internalConfig), 26 | outputs: outputs(internalConfig), 27 | manifests: manifests(internalConfig), 28 | filters: filters(internalConfig), 29 | statistics: statistics(internalConfig), 30 | infrastructure: infrastructure(internalConfig) 31 | }); 32 | 33 | export default encoding; 34 | -------------------------------------------------------------------------------- /bitmovin/encoding/infrastructure/aws.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../utils/http'; 4 | import {HttpClient} from '../../utils/types'; 5 | 6 | export const aws = (configuration, httpClient: HttpClient) => { 7 | const {get, post, delete_} = httpClient; 8 | 9 | const typeFn = type => { 10 | const resourceDetails = id => { 11 | const regionDetails = regionName => { 12 | return { 13 | add: region => { 14 | const url = urljoin(configuration.apiBaseUrl, 'encoding/infrastructure', type, id, 'regions', regionName); 15 | return post(configuration, url, region); 16 | }, 17 | delete: () => { 18 | const url = urljoin(configuration.apiBaseUrl, 'encoding/infrastructure', type, id, 'regions', regionName); 19 | return delete_(configuration, url); 20 | }, 21 | details: () => { 22 | const url = urljoin(configuration.apiBaseUrl, 'encoding/infrastructure', type, id, 'regions', regionName); 23 | return get(configuration, url); 24 | } 25 | }; 26 | }; 27 | 28 | const listRegions = utils.buildListCallFunction( 29 | httpClient, 30 | configuration, 31 | urljoin(configuration.apiBaseUrl, 'encoding/infrastructure', type, id, 'regions') 32 | ); 33 | 34 | const regions = Object.assign(regionDetails, { 35 | list: listRegions 36 | }); 37 | 38 | return { 39 | status: () => { 40 | const url = urljoin(configuration.apiBaseUrl, 'encoding/infrastructure', type, id, 'status'); 41 | return get(configuration, url); 42 | }, 43 | details: () => { 44 | const url = urljoin(configuration.apiBaseUrl, 'encoding/infrastructure', type, id); 45 | return get(configuration, url); 46 | }, 47 | delete: () => { 48 | const url = urljoin(configuration.apiBaseUrl, 'encoding/infrastructure', type, id); 49 | return delete_(configuration, url); 50 | }, 51 | regions 52 | }; 53 | }; 54 | 55 | const create = infrastructure => { 56 | const url = urljoin(configuration.apiBaseUrl, 'encoding/infrastructure', type); 57 | return post(configuration, url, infrastructure); 58 | }; 59 | 60 | const list = utils.buildListCallFunction( 61 | httpClient, 62 | configuration, 63 | urljoin(configuration.apiBaseUrl, 'encoding/infrastructure', type) 64 | ); 65 | 66 | const resource = Object.assign(resourceDetails, {create, list}); 67 | return resource; 68 | }; 69 | 70 | return typeFn('aws'); 71 | }; 72 | 73 | export default configuration => { 74 | return aws(configuration, http); 75 | }; 76 | -------------------------------------------------------------------------------- /bitmovin/encoding/infrastructure/index.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../utils/http'; 4 | import {HttpClient} from '../../utils/types'; 5 | 6 | import {aws as awsInfra} from './aws'; 7 | 8 | export const infrastructure = (configuration, httpClient: HttpClient) => { 9 | const {get, post, delete_} = httpClient; 10 | 11 | const typeFn = type => { 12 | const resourceDetails = id => { 13 | return { 14 | status: () => { 15 | const url = urljoin(configuration.apiBaseUrl, 'encoding/infrastructure', type, id, 'status'); 16 | return get(configuration, url); 17 | }, 18 | details: () => { 19 | const url = urljoin(configuration.apiBaseUrl, 'encoding/infrastructure', type, id); 20 | return get(configuration, url); 21 | }, 22 | delete: () => { 23 | const url = urljoin(configuration.apiBaseUrl, 'encoding/infrastructure', type, id); 24 | return delete_(configuration, url); 25 | }, 26 | customData: () => { 27 | const url = urljoin(configuration.apiBaseUrl, 'encoding/infrastructure', type, id, 'customData'); 28 | return get(configuration, url); 29 | } 30 | }; 31 | }; 32 | 33 | const create = infrastructurePayload => { 34 | const url = urljoin(configuration.apiBaseUrl, 'encoding/infrastructure', type); 35 | return post(configuration, url, infrastructurePayload); 36 | }; 37 | 38 | const list = utils.buildListCallFunction( 39 | httpClient, 40 | configuration, 41 | urljoin(configuration.apiBaseUrl, 'encoding/infrastructure', type) 42 | ); 43 | 44 | const resource = Object.assign(resourceDetails, {create, list}); 45 | return resource; 46 | }; 47 | 48 | const kubernetes = typeFn('kubernetes'); 49 | 50 | const aws = awsInfra(configuration, http); 51 | 52 | return { 53 | kubernetes, 54 | aws 55 | }; 56 | }; 57 | 58 | export default configuration => { 59 | return infrastructure(configuration, http); 60 | }; 61 | -------------------------------------------------------------------------------- /bitmovin/encoding/inputs.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../utils/http'; 4 | import {HttpClient} from '../utils/types'; 5 | 6 | export const inputs = (configuration, httpClient: HttpClient) => { 7 | const {get, post, delete_} = httpClient; 8 | const typeFn = typeUrl => { 9 | const resourceDetails = inputId => { 10 | return { 11 | details: () => { 12 | const url = urljoin(configuration.apiBaseUrl, 'encoding/inputs', typeUrl, inputId); 13 | return get(configuration, url); 14 | }, 15 | customData: () => { 16 | const url = urljoin(configuration.apiBaseUrl, 'encoding/inputs', typeUrl, inputId, 'customData'); 17 | return get(configuration, url); 18 | }, 19 | delete: () => { 20 | const url = urljoin(configuration.apiBaseUrl, 'encoding/inputs', typeUrl, inputId); 21 | return delete_(configuration, url); 22 | } 23 | }; 24 | }; 25 | 26 | const create = input => { 27 | const url = urljoin(configuration.apiBaseUrl, 'encoding/inputs', typeUrl); 28 | return post(configuration, url, input); 29 | }; 30 | 31 | const list = utils.buildListCallFunction( 32 | httpClient, 33 | configuration, 34 | urljoin(configuration.apiBaseUrl, 'encoding/inputs', typeUrl) 35 | ); 36 | 37 | const resource = Object.assign(resourceDetails, {create, list}); 38 | return resource; 39 | }; 40 | 41 | const rtmpTypeFn = typeUrl => { 42 | const rtmpDetails = inputId => { 43 | return { 44 | details: () => { 45 | const url = urljoin(configuration.apiBaseUrl, 'encoding/inputs', typeUrl, inputId); 46 | return get(configuration, url); 47 | } 48 | }; 49 | }; 50 | 51 | const list = utils.buildListCallFunction( 52 | httpClient, 53 | configuration, 54 | urljoin(configuration.apiBaseUrl, 'encoding/inputs', typeUrl) 55 | ); 56 | 57 | const rtmp = Object.assign(rtmpDetails, { 58 | list 59 | }); 60 | 61 | return rtmp; 62 | }; 63 | 64 | return { 65 | aspera: typeFn('aspera'), 66 | azure: typeFn('azure'), 67 | ftp: typeFn('ftp'), 68 | gcs: typeFn('gcs'), 69 | http: typeFn('http'), 70 | https: typeFn('https'), 71 | rtmp: rtmpTypeFn('rtmp'), 72 | s3: typeFn('s3'), 73 | genericS3: typeFn('generic-s3'), 74 | sftp: typeFn('sftp'), 75 | local: typeFn('local'), 76 | akamaiNetstorage: typeFn('akamai-netstorage'), 77 | roleBasedS3: typeFn('s3-role-based'), 78 | srt: typeFn('srt'), 79 | zixi: typeFn('zixi'), 80 | 81 | list: utils.buildListCallFunction(httpClient, configuration, urljoin(configuration.apiBaseUrl, 'encoding/inputs')), 82 | 83 | getType: inputId => { 84 | const url = urljoin(configuration.apiBaseUrl, 'encoding/inputs', inputId, 'type'); 85 | return get(configuration, url); 86 | } 87 | }; 88 | }; 89 | 90 | export default configuration => { 91 | return inputs(configuration, http); 92 | }; 93 | -------------------------------------------------------------------------------- /bitmovin/encoding/manifests/dash/dashManifestAdaptationSets.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../../utils/http'; 4 | import {HttpClient, InternalConfiguration} from '../../../utils/types'; 5 | 6 | import contentProtections from './dashManifestContentProtections'; 7 | import representations from './dashManifestRepresentations'; 8 | 9 | export const adaptationSets = (configuration: InternalConfiguration, manifestId, periodId, httpClient: HttpClient) => { 10 | const {get, post, delete_} = httpClient; 11 | const typeFn = typeUrl => { 12 | const resourceDetails = adaptationSetId => { 13 | return { 14 | details: () => { 15 | const url = urljoin( 16 | configuration.apiBaseUrl, 17 | 'encoding/manifests/dash', 18 | manifestId, 19 | 'periods', 20 | periodId, 21 | 'adaptationsets', 22 | typeUrl, 23 | adaptationSetId 24 | ); 25 | 26 | return get(configuration, url); 27 | }, 28 | delete: () => { 29 | const url = urljoin( 30 | configuration.apiBaseUrl, 31 | 'encoding/manifests/dash', 32 | manifestId, 33 | 'periods', 34 | periodId, 35 | 'adaptationsets', 36 | typeUrl, 37 | adaptationSetId 38 | ); 39 | return delete_(configuration, url); 40 | } 41 | }; 42 | }; 43 | 44 | const create = period => { 45 | const url = urljoin( 46 | configuration.apiBaseUrl, 47 | 'encoding/manifests/dash', 48 | manifestId, 49 | 'periods', 50 | periodId, 51 | 'adaptationsets', 52 | typeUrl 53 | ); 54 | 55 | return post(configuration, url, period); 56 | }; 57 | 58 | const list = utils.buildListCallFunction( 59 | httpClient, 60 | configuration, 61 | urljoin( 62 | configuration.apiBaseUrl, 63 | 'encoding/manifests/dash', 64 | manifestId, 65 | 'periods', 66 | periodId, 67 | 'adaptationsets', 68 | typeUrl 69 | ) 70 | ); 71 | 72 | const resource = Object.assign(resourceDetails, {create, list}); 73 | return resource; 74 | }; 75 | 76 | const fn = adaptationSetId => { 77 | return { 78 | representations: representations(configuration, manifestId, periodId, adaptationSetId), 79 | contentProtections: contentProtections(configuration, manifestId, periodId, adaptationSetId, undefined) 80 | }; 81 | }; 82 | 83 | const audio = typeFn('audio'); 84 | const video = typeFn('video'); 85 | const subtitle = typeFn('subtitle'); 86 | const custom = typeFn('custom'); 87 | 88 | return Object.assign(fn, {audio, video, subtitle, custom}); 89 | }; 90 | 91 | export default (configuration, manifestId, periodId) => { 92 | return adaptationSets(configuration, manifestId, periodId, http); 93 | }; 94 | -------------------------------------------------------------------------------- /bitmovin/encoding/manifests/dash/dashManifestContentProtections.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../../utils/http'; 4 | import {HttpClient} from '../../../utils/types'; 5 | 6 | export const contentProtections = ( 7 | configuration, 8 | manifestId, 9 | periodId, 10 | adaptationSetId, 11 | representationInfo, 12 | httpClient: HttpClient 13 | ) => { 14 | const {get, post, delete_} = httpClient; 15 | 16 | let baseUrl = urljoin( 17 | configuration.apiBaseUrl, 18 | 'encoding/manifests/dash', 19 | manifestId, 20 | 'periods', 21 | periodId, 22 | 'adaptationsets', 23 | adaptationSetId 24 | ); 25 | if (representationInfo !== null && representationInfo !== undefined) { 26 | baseUrl = urljoin(baseUrl, 'representations', representationInfo.type, representationInfo.id); 27 | } 28 | baseUrl = urljoin(baseUrl, 'contentprotection'); 29 | 30 | const resourceDetails = contentProtectionId => { 31 | return { 32 | details: () => { 33 | const url = urljoin(baseUrl, contentProtectionId); 34 | return get(configuration, url); 35 | }, 36 | delete: () => { 37 | const url = urljoin(baseUrl, contentProtectionId); 38 | return delete_(configuration, url); 39 | } 40 | }; 41 | }; 42 | 43 | const add = contentProtection => { 44 | const url = baseUrl; 45 | return post(configuration, url, contentProtection); 46 | }; 47 | 48 | const list = (limit, offset) => { 49 | let url = baseUrl; 50 | 51 | const getParams = utils.buildGetParamString({ 52 | limit, 53 | offset 54 | }); 55 | if (getParams.length > 0) { 56 | url = urljoin(url, getParams); 57 | } 58 | 59 | return get(configuration, url); 60 | }; 61 | 62 | const resource = Object.assign(resourceDetails, {add, list}); 63 | return resource; 64 | }; 65 | 66 | export default (configuration, manifestId, periodId, adaptationSetId, representationInfo) => { 67 | return contentProtections(configuration, manifestId, periodId, adaptationSetId, representationInfo, http); 68 | }; 69 | -------------------------------------------------------------------------------- /bitmovin/encoding/manifests/dash/dashManifestCustomXmlElements.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../../utils/http'; 4 | import {HttpClient, InternalConfiguration} from '../../../utils/types'; 5 | 6 | export const customXmlElements = ( 7 | configuration: InternalConfiguration, 8 | manifestId, 9 | periodId, 10 | httpClient: HttpClient 11 | ) => { 12 | const {get, post, delete_} = httpClient; 13 | const resourceDetails = customXmlElementId => { 14 | return { 15 | details: () => { 16 | const url = urljoin( 17 | configuration.apiBaseUrl, 18 | 'encoding/manifests/dash', 19 | manifestId, 20 | 'periods', 21 | periodId, 22 | 'custom-xml-elements', 23 | customXmlElementId 24 | ); 25 | return get(configuration, url); 26 | }, 27 | delete: () => { 28 | const url = urljoin( 29 | configuration.apiBaseUrl, 30 | 'encoding/manifests/dash', 31 | manifestId, 32 | 'periods', 33 | periodId, 34 | 'custom-xml-elements', 35 | customXmlElementId 36 | ); 37 | return delete_(configuration, url); 38 | } 39 | }; 40 | }; 41 | 42 | const add = customXmlElement => { 43 | const url = urljoin( 44 | configuration.apiBaseUrl, 45 | 'encoding/manifests/dash', 46 | manifestId, 47 | 'periods', 48 | periodId, 49 | 'custom-xml-elements' 50 | ); 51 | return post(configuration, url, customXmlElement); 52 | }; 53 | 54 | const list = (limit, offset) => { 55 | let url = urljoin( 56 | configuration.apiBaseUrl, 57 | 'encoding/manifests/dash', 58 | manifestId, 59 | 'periods', 60 | periodId, 61 | 'custom-xml-elements' 62 | ); 63 | 64 | const getParams = utils.buildGetParamString({ 65 | limit, 66 | offset 67 | }); 68 | if (getParams.length > 0) { 69 | url = urljoin(url, getParams); 70 | } 71 | 72 | return get(configuration, url); 73 | }; 74 | 75 | const resource = Object.assign(resourceDetails, {add, list}); 76 | return resource; 77 | }; 78 | 79 | export default (configuration, manifestId, periodId) => { 80 | return customXmlElements(configuration, manifestId, periodId, http); 81 | }; 82 | -------------------------------------------------------------------------------- /bitmovin/encoding/manifests/dash/dashManifestPeriods.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../../utils/http'; 4 | import {HttpClient} from '../../../utils/types'; 5 | 6 | import adaptationSets from './dashManifestAdaptationSets'; 7 | import customXmlElements from './dashManifestCustomXmlElements'; 8 | 9 | export const dashManifestPeriods = (configuration, manifestId, httpClient: HttpClient) => { 10 | const {get, post, delete_} = httpClient; 11 | const resourceDetails = periodId => { 12 | return { 13 | details: () => { 14 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/dash', manifestId, 'periods', periodId); 15 | return get(configuration, url); 16 | }, 17 | delete: () => { 18 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/dash', manifestId, 'periods', periodId); 19 | return delete_(configuration, url); 20 | }, 21 | adaptationSets: adaptationSets(configuration, manifestId, periodId), 22 | customXmlElements: customXmlElements(configuration, manifestId, periodId) 23 | }; 24 | }; 25 | 26 | const add = period => { 27 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/dash', manifestId, 'periods'); 28 | return post(configuration, url, period); 29 | }; 30 | 31 | const list = (limit, offset) => { 32 | let url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/dash', manifestId, 'periods'); 33 | 34 | const getParams = utils.buildGetParamString({ 35 | limit, 36 | offset 37 | }); 38 | if (getParams.length > 0) { 39 | url = urljoin(url, getParams); 40 | } 41 | 42 | return get(configuration, url); 43 | }; 44 | 45 | const resource = Object.assign(resourceDetails, {add, list}); 46 | return resource; 47 | }; 48 | 49 | export default (configuration, manifestId) => { 50 | return dashManifestPeriods(configuration, manifestId, http); 51 | }; 52 | -------------------------------------------------------------------------------- /bitmovin/encoding/manifests/dash/dashManifestRepresentations.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../../utils/http'; 4 | import {HttpClient} from '../../../utils/types'; 5 | 6 | import contentProtections from './dashManifestContentProtections'; 7 | 8 | export const representations = (configuration, manifestId, periodId, adaptationSetId, httpClient: HttpClient) => { 9 | const {get, post, delete_} = httpClient; 10 | const dashManifestsBaseUrl = urljoin(configuration.apiBaseUrl, 'encoding/manifests/dash'); 11 | 12 | const typeFn = typeUrl => { 13 | const resourceDetails = representationId => { 14 | return { 15 | details: () => { 16 | const url = urljoin( 17 | dashManifestsBaseUrl, 18 | manifestId, 19 | 'periods', 20 | periodId, 21 | 'adaptationsets', 22 | adaptationSetId, 23 | 'representations', 24 | typeUrl, 25 | representationId 26 | ); 27 | return get(configuration, url); 28 | }, 29 | delete: () => { 30 | const url = urljoin( 31 | dashManifestsBaseUrl, 32 | manifestId, 33 | 'periods', 34 | periodId, 35 | 'adaptationsets', 36 | adaptationSetId, 37 | 'representations', 38 | typeUrl, 39 | representationId 40 | ); 41 | return delete_(configuration, url); 42 | }, 43 | contentProtections: contentProtections(configuration, manifestId, periodId, adaptationSetId, { 44 | type: typeUrl, 45 | id: representationId 46 | }) 47 | }; 48 | }; 49 | 50 | const add = representation => { 51 | const url = urljoin( 52 | dashManifestsBaseUrl, 53 | manifestId, 54 | 'periods', 55 | periodId, 56 | 'adaptationsets', 57 | adaptationSetId, 58 | 'representations', 59 | typeUrl 60 | ); 61 | return post(configuration, url, representation); 62 | }; 63 | 64 | const list = (limit, offset) => { 65 | let url = urljoin( 66 | dashManifestsBaseUrl, 67 | manifestId, 68 | 'periods', 69 | periodId, 70 | 'adaptationsets', 71 | adaptationSetId, 72 | 'representations', 73 | typeUrl 74 | ); 75 | 76 | const getParams = utils.buildGetParamString({ 77 | limit, 78 | offset 79 | }); 80 | if (getParams.length > 0) { 81 | url = urljoin(url, getParams); 82 | } 83 | 84 | return get(configuration, url); 85 | }; 86 | 87 | const resource = Object.assign(resourceDetails, {add, list}); 88 | return resource; 89 | }; 90 | 91 | return { 92 | fmp4: typeFn('fmp4'), 93 | drmFmp4: typeFn('fmp4/drm'), 94 | sidecar: typeFn('sidecar'), 95 | vtt: typeFn('vtt'), 96 | mp4: typeFn('mp4'), 97 | drmMp4: typeFn('mp4/drm'), 98 | webm: typeFn('webm') 99 | }; 100 | }; 101 | 102 | export default (configuration, manifestId, periodId, adaptationSetId) => { 103 | return representations(configuration, manifestId, periodId, adaptationSetId, http); 104 | }; 105 | -------------------------------------------------------------------------------- /bitmovin/encoding/manifests/dash/index.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../../utils/http'; 4 | import {HttpClient} from '../../../utils/types'; 5 | 6 | import periods from './dashManifestPeriods'; 7 | 8 | export const dashManifests = (configuration, httpClient: HttpClient) => { 9 | const {get, post, delete_} = httpClient; 10 | const resourceDetails = manifestId => { 11 | return { 12 | details: () => { 13 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/dash', manifestId); 14 | return get(configuration, url); 15 | }, 16 | delete: () => { 17 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/dash', manifestId); 18 | return delete_(configuration, url); 19 | }, 20 | start: () => { 21 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/dash', manifestId, 'start'); 22 | return post(configuration, url); 23 | }, 24 | stop: () => { 25 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/dash', manifestId, 'stop'); 26 | return post(configuration, url); 27 | }, 28 | status: () => { 29 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/dash', manifestId, 'status'); 30 | return get(configuration, url); 31 | }, 32 | periods: periods(configuration, manifestId) 33 | }; 34 | }; 35 | 36 | const create = manifest => { 37 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/dash'); 38 | return post(configuration, url, manifest); 39 | }; 40 | 41 | const list = (limit, offset, encodingId) => { 42 | let url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/dash'); 43 | 44 | const getParams = utils.buildGetParamString({ 45 | limit, 46 | offset, 47 | encodingId 48 | }); 49 | if (getParams.length > 0) { 50 | url = urljoin(url, getParams); 51 | } 52 | 53 | return get(configuration, url); 54 | }; 55 | 56 | const resource = Object.assign(resourceDetails, {create, list}); 57 | return resource; 58 | }; 59 | 60 | export default configuration => { 61 | return dashManifests(configuration, http); 62 | }; 63 | -------------------------------------------------------------------------------- /bitmovin/encoding/manifests/hls/hlsManifestMedia.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../../utils/http'; 4 | import {HttpClient} from '../../../utils/types'; 5 | 6 | export const hlsManifestMedia = (configuration, manifestId, httpClient: HttpClient) => { 7 | const {get, post, delete_} = httpClient; 8 | const typeFn = typeUrl => { 9 | const resourceDetails = mediaId => { 10 | return { 11 | details: () => { 12 | const url = urljoin( 13 | configuration.apiBaseUrl, 14 | 'encoding/manifests/hls', 15 | manifestId, 16 | 'media', 17 | typeUrl, 18 | mediaId 19 | ); 20 | 21 | return get(configuration, url); 22 | }, 23 | delete: () => { 24 | const url = urljoin( 25 | configuration.apiBaseUrl, 26 | 'encoding/manifests/hls', 27 | manifestId, 28 | 'media', 29 | typeUrl, 30 | mediaId 31 | ); 32 | 33 | return delete_(configuration, url); 34 | } 35 | }; 36 | }; 37 | 38 | const add = media => { 39 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/hls', manifestId, 'media', typeUrl); 40 | 41 | return post(configuration, url, media); 42 | }; 43 | 44 | const list = (limit, offset) => { 45 | let url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/hls', manifestId, 'media', typeUrl); 46 | 47 | const getParams = utils.buildGetParamString({ 48 | limit, 49 | offset 50 | }); 51 | if (getParams.length > 0) { 52 | url = urljoin(url, getParams); 53 | } 54 | 55 | return get(configuration, url); 56 | }; 57 | 58 | const resource = Object.assign(resourceDetails, {add, list}); 59 | return resource; 60 | }; 61 | 62 | return { 63 | video: typeFn('video'), 64 | audio: typeFn('audio'), 65 | subtitles: typeFn('subtitles'), 66 | closedCaptions: typeFn('closed-captions'), 67 | vtt: typeFn('vtt') 68 | }; 69 | }; 70 | 71 | export default (configuration, manifestId) => { 72 | return hlsManifestMedia(configuration, manifestId, http); 73 | }; 74 | -------------------------------------------------------------------------------- /bitmovin/encoding/manifests/hls/hlsManifestStreams.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../../utils/http'; 4 | import {HttpClient} from '../../../utils/types'; 5 | 6 | export const hlsManifestStreams = (configuration, manifestId, httpClient: HttpClient) => { 7 | const {get, post, delete_} = httpClient; 8 | const resourceDetails = streamId => { 9 | return { 10 | details: () => { 11 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/hls', manifestId, 'streams', streamId); 12 | return get(configuration, url); 13 | }, 14 | delete: () => { 15 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/hls', manifestId, 'streams', streamId); 16 | return delete_(configuration, url); 17 | } 18 | }; 19 | }; 20 | 21 | const add = stream => { 22 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/hls', manifestId, 'streams'); 23 | return post(configuration, url, stream); 24 | }; 25 | 26 | const list = (limit, offset) => { 27 | let url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/hls', manifestId, 'streams'); 28 | 29 | const getParams = utils.buildGetParamString({ 30 | limit, 31 | offset 32 | }); 33 | if (getParams.length > 0) { 34 | url = urljoin(url, getParams); 35 | } 36 | 37 | return get(configuration, url); 38 | }; 39 | 40 | const resource = Object.assign(resourceDetails, {add, list}); 41 | return resource; 42 | }; 43 | 44 | export default (configuration, manifestId) => { 45 | return hlsManifestStreams(configuration, manifestId, http); 46 | }; 47 | -------------------------------------------------------------------------------- /bitmovin/encoding/manifests/hls/index.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../../utils/http'; 4 | import {HttpClient} from '../../../utils/types'; 5 | 6 | import media from './hlsManifestMedia'; 7 | import streams from './hlsManifestStreams'; 8 | 9 | export const hlsManifests = (configuration, httpClient: HttpClient) => { 10 | const {get, post, delete_} = httpClient; 11 | const resourceDetails = manifestId => { 12 | return { 13 | details: () => { 14 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/hls', manifestId); 15 | return get(configuration, url); 16 | }, 17 | delete: () => { 18 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/hls', manifestId); 19 | return delete_(configuration, url); 20 | }, 21 | start: () => { 22 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/hls', manifestId, 'start'); 23 | return post(configuration, url); 24 | }, 25 | stop: () => { 26 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/hls', manifestId, 'stop'); 27 | return post(configuration, url); 28 | }, 29 | status: () => { 30 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/hls', manifestId, 'status'); 31 | return get(configuration, url); 32 | }, 33 | media: media(configuration, manifestId), 34 | streams: streams(configuration, manifestId) 35 | }; 36 | }; 37 | 38 | const create = manifest => { 39 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/hls'); 40 | return post(configuration, url, manifest); 41 | }; 42 | 43 | const list = (limit, offset, encodingId) => { 44 | let url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/hls'); 45 | 46 | const getParams = utils.buildGetParamString({ 47 | limit, 48 | offset, 49 | encodingId 50 | }); 51 | if (getParams.length > 0) { 52 | url = urljoin(url, getParams); 53 | } 54 | 55 | return get(configuration, url); 56 | }; 57 | 58 | const resource = Object.assign(resourceDetails, {create, list}); 59 | return resource; 60 | }; 61 | 62 | export default configuration => { 63 | return hlsManifests(configuration, http); 64 | }; 65 | -------------------------------------------------------------------------------- /bitmovin/encoding/manifests/index.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../utils/http'; 4 | import {HttpClient} from '../../utils/types'; 5 | 6 | import dashManifests from './dash'; 7 | import hlsManifests from './hls'; 8 | import smoothManifests from './smooth'; 9 | 10 | export const manifests = (configuration, httpClient: HttpClient) => { 11 | const {get} = httpClient; 12 | 13 | return { 14 | list: utils.buildListCallFunction( 15 | httpClient, 16 | configuration, 17 | urljoin(configuration.apiBaseUrl, 'encoding/manifests') 18 | ), 19 | dash: dashManifests(configuration), 20 | hls: hlsManifests(configuration), 21 | smooth: smoothManifests(configuration), 22 | getType: manifestId => { 23 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests', manifestId, 'type'); 24 | 25 | return get(configuration, url); 26 | } 27 | }; 28 | }; 29 | 30 | export default configuration => { 31 | return manifests(configuration, http); 32 | }; 33 | -------------------------------------------------------------------------------- /bitmovin/encoding/manifests/smooth/index.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../../utils/http'; 4 | import {HttpClient} from '../../../utils/types'; 5 | 6 | import contentProtections from './smoothManifestContentProtections'; 7 | import representations from './smoothManifestRepresentations'; 8 | 9 | export const smoothManifests = (configuration, httpClient: HttpClient) => { 10 | const {get, post, delete_} = httpClient; 11 | const resourceDetails = manifestId => { 12 | return { 13 | details: () => { 14 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/smooth', manifestId); 15 | return get(configuration, url); 16 | }, 17 | delete: () => { 18 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/smooth', manifestId); 19 | return delete_(configuration, url); 20 | }, 21 | start: () => { 22 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/smooth', manifestId, 'start'); 23 | return post(configuration, url); 24 | }, 25 | stop: () => { 26 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/smooth', manifestId, 'stop'); 27 | return post(configuration, url); 28 | }, 29 | status: () => { 30 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/smooth', manifestId, 'status'); 31 | return get(configuration, url); 32 | }, 33 | representations: representations(configuration, manifestId), 34 | contentProtections: contentProtections(configuration, manifestId) 35 | }; 36 | }; 37 | 38 | const create = manifest => { 39 | const url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/smooth'); 40 | return post(configuration, url, manifest); 41 | }; 42 | 43 | const list = (limit, offset, encodingId) => { 44 | let url = urljoin(configuration.apiBaseUrl, 'encoding/manifests/smooth'); 45 | 46 | const getParams = utils.buildGetParamString({ 47 | limit, 48 | offset, 49 | encodingId 50 | }); 51 | if (getParams.length > 0) { 52 | url = urljoin(url, getParams); 53 | } 54 | 55 | return get(configuration, url); 56 | }; 57 | 58 | const resource = Object.assign(resourceDetails, {create, list}); 59 | return resource; 60 | }; 61 | 62 | export default configuration => { 63 | return smoothManifests(configuration, http); 64 | }; 65 | -------------------------------------------------------------------------------- /bitmovin/encoding/manifests/smooth/smoothManifestContentProtections.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../../utils/http'; 4 | import {HttpClient} from '../../../utils/types'; 5 | 6 | export const contentProtection = (configuration, manifestId, httpClient: HttpClient) => { 7 | const {get, post, delete_} = httpClient; 8 | const baseUrl = urljoin(configuration.apiBaseUrl, 'encoding/manifests/smooth', manifestId, 'contentprotection'); 9 | 10 | const resourceDetails = contentProtectionId => { 11 | return { 12 | details: () => { 13 | const url = urljoin(baseUrl, contentProtectionId); 14 | return get(configuration, url); 15 | }, 16 | delete: () => { 17 | const url = urljoin(baseUrl, contentProtectionId); 18 | return delete_(configuration, url); 19 | } 20 | }; 21 | }; 22 | 23 | const add = protection => { 24 | return post(configuration, baseUrl, protection); 25 | }; 26 | 27 | const list = (limit, offset) => { 28 | let url = baseUrl; 29 | 30 | const getParams = utils.buildGetParamString({ 31 | limit, 32 | offset 33 | }); 34 | if (getParams.length > 0) { 35 | url = urljoin(url, getParams); 36 | } 37 | 38 | return get(configuration, url); 39 | }; 40 | 41 | const resource = Object.assign(resourceDetails, {add, list}); 42 | return resource; 43 | }; 44 | 45 | export default (configuration, manifestId) => { 46 | return contentProtection(configuration, manifestId, http); 47 | }; 48 | -------------------------------------------------------------------------------- /bitmovin/encoding/manifests/smooth/smoothManifestRepresentations.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../../utils/http'; 4 | import {HttpClient} from '../../../utils/types'; 5 | 6 | export const representations = (configuration, manifestId, httpClient: HttpClient) => { 7 | const {get, post, delete_} = httpClient; 8 | const typeFn = typeUrl => { 9 | const baseUrl = urljoin( 10 | configuration.apiBaseUrl, 11 | 'encoding/manifests/smooth', 12 | manifestId, 13 | 'representations', 14 | typeUrl 15 | ); 16 | 17 | const resourceDetails = representationId => { 18 | return { 19 | details: () => { 20 | const url = urljoin(baseUrl, representationId); 21 | return get(configuration, url); 22 | }, 23 | delete: () => { 24 | const url = urljoin(baseUrl, representationId); 25 | return delete_(configuration, url); 26 | } 27 | }; 28 | }; 29 | 30 | const add = representation => { 31 | return post(configuration, baseUrl, representation); 32 | }; 33 | 34 | const list = (limit, offset) => { 35 | let url = baseUrl; 36 | 37 | const getParams = utils.buildGetParamString({ 38 | limit, 39 | offset 40 | }); 41 | if (getParams.length > 0) { 42 | url = urljoin(url, getParams); 43 | } 44 | 45 | return get(configuration, url); 46 | }; 47 | 48 | const resource = Object.assign(resourceDetails, {add, list}); 49 | return resource; 50 | }; 51 | 52 | return { 53 | mp4: typeFn('mp4') 54 | }; 55 | }; 56 | 57 | export default (configuration, manifestId) => { 58 | return representations(configuration, manifestId, http); 59 | }; 60 | -------------------------------------------------------------------------------- /bitmovin/encoding/outputs.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../utils/http'; 4 | import {HttpClient} from '../utils/types'; 5 | 6 | export const outputs = (configuration, httpClient: HttpClient) => { 7 | const {get, post, delete_} = httpClient; 8 | const typeFn = typeUrl => { 9 | const resourceDetails = outputId => { 10 | return { 11 | details: () => { 12 | const url = urljoin(configuration.apiBaseUrl, 'encoding/outputs', typeUrl, outputId); 13 | return get(configuration, url); 14 | }, 15 | customData: () => { 16 | const url = urljoin(configuration.apiBaseUrl, 'encoding/outputs', typeUrl, outputId, 'customData'); 17 | 18 | return get(configuration, url); 19 | }, 20 | delete: () => { 21 | const url = urljoin(configuration.apiBaseUrl, 'encoding/outputs', typeUrl, outputId); 22 | return delete_(configuration, url); 23 | } 24 | }; 25 | }; 26 | 27 | const create = output => { 28 | const url = urljoin(configuration.apiBaseUrl, 'encoding/outputs', typeUrl); 29 | return post(configuration, url, output); 30 | }; 31 | 32 | const list = utils.buildListCallFunction( 33 | httpClient, 34 | configuration, 35 | urljoin(configuration.apiBaseUrl, 'encoding/outputs', typeUrl) 36 | ); 37 | 38 | const resource = Object.assign(resourceDetails, {create, list}); 39 | return resource; 40 | }; 41 | 42 | return { 43 | s3: typeFn('s3'), 44 | gcs: typeFn('gcs'), 45 | azure: typeFn('azure'), 46 | ftp: typeFn('ftp'), 47 | sftp: typeFn('sftp'), 48 | genericS3: typeFn('generic-s3'), 49 | bitmovinTempS3: typeFn('bitmovin-temp-s3'), 50 | local: typeFn('local'), 51 | akamaiNetstorage: typeFn('akamai-netstorage'), 52 | akamaiMsl: typeFn('akamai-msl'), 53 | roleBasedS3: typeFn('s3-role-based'), 54 | liveMediaIngest: typeFn('live-media-ingest'), 55 | 56 | list: utils.buildListCallFunction(httpClient, configuration, urljoin(configuration.apiBaseUrl, 'encoding/outputs')), 57 | 58 | getType: outputId => { 59 | const url = urljoin(configuration.apiBaseUrl, 'encoding/outputs', outputId, 'type'); 60 | 61 | return get(configuration, url); 62 | } 63 | }; 64 | }; 65 | 66 | export default configuration => { 67 | return outputs(configuration, http); 68 | }; 69 | -------------------------------------------------------------------------------- /bitmovin/encoding/statistics/index.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import BitmovinError from '../../utils/BitmovinError'; 4 | import {isValidApiRequestDateString} from '../../utils/DateUtils'; 5 | import http, {utils} from '../../utils/http'; 6 | import {HttpClient} from '../../utils/types'; 7 | 8 | import liveStatistics from './liveStatistics'; 9 | 10 | export const statistics = (configuration, httpClient: HttpClient) => { 11 | const {get} = httpClient; 12 | 13 | const addOptionsToUrl = (url, options) => { 14 | let newUrl = url; 15 | const {limit, offset} = options; 16 | 17 | if (options !== {} && options.from && options.to) { 18 | if (!isValidApiRequestDateString(options.from) || !isValidApiRequestDateString(options.to)) { 19 | return Promise.reject(new BitmovinError('Wrong date format! Correct format is yyyy-MM-dd', {})); 20 | } 21 | newUrl = urljoin(newUrl, options.from, options.to); 22 | } 23 | 24 | const getParams = utils.buildGetParamString({ 25 | limit, 26 | offset 27 | }); 28 | 29 | if (getParams.length > 0) { 30 | newUrl = urljoin(newUrl, getParams); 31 | } 32 | 33 | return newUrl; 34 | }; 35 | 36 | const daily = (options = {}) => { 37 | const url = urljoin(configuration.apiBaseUrl, 'encoding/statistics/daily'); 38 | const urlWithOptions = addOptionsToUrl(url, options); 39 | return get(configuration, urlWithOptions); 40 | }; 41 | 42 | const typeFn = type => { 43 | return { 44 | daily: (options = {}) => { 45 | const url = urljoin(configuration.apiBaseUrl, 'encoding/statistics/encodings/', type, '/daily'); 46 | const urlWithOptions = addOptionsToUrl(url, options); 47 | return get(configuration, urlWithOptions); 48 | }, 49 | 50 | list: (options = {}) => { 51 | const url = urljoin(configuration.apiBaseUrl, 'encoding/statistics/encodings/', type); 52 | const urlWithOptions = addOptionsToUrl(url, options); 53 | return get(configuration, urlWithOptions); 54 | } 55 | }; 56 | }; 57 | 58 | return { 59 | /* 60 | * Gets the overall encoding statistics 61 | * 62 | * Options is a hash with optional parameters: 63 | * limit: Number - maximum results 64 | * offset: Number - skip n results 65 | * 66 | * If from and to is set only statistics between these two dates are returned 67 | * from: Date 68 | * to: Date 69 | */ 70 | overall: (from?: string, to?: string) => { 71 | let url = urljoin(configuration.apiBaseUrl, 'encoding/statistics'); 72 | if (from && to) { 73 | url = urljoin(url, from, to); 74 | } 75 | return get(configuration, url); 76 | }, 77 | 78 | vod: typeFn('vod'), 79 | live: typeFn('live'), 80 | daily, 81 | 82 | encodings: encodingId => { 83 | return { 84 | statistics: () => { 85 | const url = urljoin(configuration.apiBaseUrl, 'encoding/statistics/encodings', encodingId); 86 | return get(configuration, url); 87 | }, 88 | liveStatistics: liveStatistics(configuration, encodingId) 89 | }; 90 | } 91 | }; 92 | }; 93 | 94 | export default configuration => { 95 | return statistics(configuration, http); 96 | }; 97 | -------------------------------------------------------------------------------- /bitmovin/encoding/statistics/liveStatistics.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../../utils/http'; 4 | import {ApiResource, HttpClient, InternalConfiguration, List} from '../../utils/types'; 5 | 6 | export const liveStatistics = ( 7 | configuration: InternalConfiguration, 8 | encodingId: string, 9 | httpClient: HttpClient 10 | ): LiveStatistics => { 11 | const {get} = httpClient; 12 | 13 | const resourceDetails = (): Promise => { 14 | const url = urljoin(configuration.apiBaseUrl, 'encoding/statistics/encodings', encodingId, 'live-statistics'); 15 | return get(configuration, url); 16 | }; 17 | 18 | const events = { 19 | list: utils.buildListCallFunction( 20 | httpClient, 21 | configuration, 22 | urljoin(configuration.apiBaseUrl, 'encoding/statistics/encodings', encodingId, 'live-statistics/events') 23 | ) 24 | }; 25 | 26 | const streams = { 27 | list: utils.buildListCallFunction( 28 | httpClient, 29 | configuration, 30 | urljoin(configuration.apiBaseUrl, 'encoding/statistics/encodings', encodingId, 'live-statistics/streams') 31 | ) 32 | }; 33 | 34 | const resource = Object.assign(resourceDetails, { 35 | events, 36 | streams 37 | }); 38 | 39 | return resource; 40 | }; 41 | 42 | export interface Stream { 43 | id: string; 44 | userId: string; 45 | orgId: string; 46 | createdAt: string; 47 | customDataCreatedAt: string; 48 | time: string; 49 | streamInfos?: any; 50 | } 51 | 52 | interface Events { 53 | list: List; 54 | } 55 | 56 | interface Streams { 57 | list: List; 58 | } 59 | 60 | export type LiveStatisticsDetail = ApiResource<{ 61 | encodingId: string; 62 | status: string; 63 | events: Event[]; 64 | statistics: Stream[]; 65 | }>; 66 | 67 | export interface LiveStatistics { 68 | (): Promise; 69 | events: Events; 70 | streams: Streams; 71 | } 72 | 73 | export default (configuration: InternalConfiguration, encodingId: string): LiveStatistics => { 74 | return liveStatistics(configuration, encodingId, http); 75 | }; 76 | -------------------------------------------------------------------------------- /bitmovin/index.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import account, {Account} from './account'; 4 | import analytics, {Analytics} from './analytics'; 5 | import encoding, {Encoding} from './encoding'; 6 | import notifications, {Notifications} from './notifications'; 7 | import player, {Player} from './player'; 8 | import logger from './utils/Logger'; 9 | import utils from './utils/Utils'; 10 | import {BitmovinConfiguration, InternalConfiguration} from './utils/types'; 11 | 12 | declare const __VERSION__: any; 13 | 14 | const checkAuthorizationInConfiguration = configuration => { 15 | if (utils.isNoEmptyString(configuration.apiKey)) { 16 | return; 17 | } 18 | 19 | logger.log('No apiKey provided in configuration.'); 20 | }; 21 | 22 | const setupConfiguration = configuration => { 23 | const internalConfig: InternalConfiguration = { 24 | ...configuration 25 | }; 26 | 27 | if (configuration.debug && configuration.debug === true) { 28 | logger.enableLogging(); 29 | } 30 | 31 | if (internalConfig.protocol === undefined) { 32 | internalConfig.protocol = 'https'; 33 | } 34 | 35 | if (internalConfig.host === undefined) { 36 | internalConfig.host = 'api.bitmovin.com'; 37 | } 38 | 39 | if (internalConfig.basePath === undefined) { 40 | internalConfig.basePath = '/v1'; 41 | } 42 | 43 | if (internalConfig.requestTimeout === undefined) { 44 | internalConfig.requestTimeout = 30000; 45 | } 46 | 47 | if (internalConfig.xApiClient === undefined) { 48 | internalConfig.xApiClient = 'bitmovin-javascript'; 49 | } 50 | 51 | if (internalConfig.additionalHeaders === undefined) { 52 | internalConfig.additionalHeaders = {}; 53 | } 54 | 55 | internalConfig.apiBaseUrl = urljoin(internalConfig.protocol + '://' + internalConfig.host, internalConfig.basePath); 56 | 57 | internalConfig.httpHeaders = { 58 | 'Content-Type': 'application/json', 59 | 'X-Api-Key': internalConfig.apiKey, 60 | 'X-Api-Client': internalConfig.xApiClient, 61 | 'X-Api-Client-Version': `${__VERSION__}`, 62 | ...internalConfig.additionalHeaders 63 | }; 64 | 65 | if (internalConfig.tenantOrgId !== undefined) { 66 | internalConfig.httpHeaders['X-Tenant-Org-Id'] = internalConfig.tenantOrgId; 67 | } 68 | 69 | return internalConfig; 70 | }; 71 | 72 | export interface BitmovinAPI { 73 | encoding: Encoding; 74 | player: Player; 75 | analytics: Analytics; 76 | account: Account; 77 | notifications: Notifications; 78 | } 79 | 80 | const Bitmovin = (configuration: BitmovinConfiguration): BitmovinAPI => { 81 | checkAuthorizationInConfiguration(configuration); 82 | 83 | const internalConfig: InternalConfiguration = setupConfiguration(configuration); 84 | 85 | const bitmovin: BitmovinAPI = { 86 | encoding: encoding(internalConfig), 87 | player: player(internalConfig), 88 | analytics: analytics(internalConfig), 89 | account: account(internalConfig), 90 | notifications: notifications(internalConfig) 91 | }; 92 | 93 | return bitmovin; 94 | }; 95 | 96 | export default Bitmovin; 97 | -------------------------------------------------------------------------------- /bitmovin/notifications/index.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../utils/http'; 4 | import {ApiResource, Delete, Details, HttpClient, InternalConfiguration, List, ResourceId} from '../utils/types'; 5 | 6 | import emails from './emails'; 7 | import {NotificationEmails} from './emails'; 8 | import { 9 | EmailNotification, 10 | EmailNotificationWithConditionsDetails, 11 | EncodingErrorWebhook, 12 | EncodingFinishedWebhook, 13 | TransferFinishedWebhook 14 | } from './types'; 15 | import webhooks from './webhooks'; 16 | import {NotificationWebhooks} from './webhooks'; 17 | 18 | export const notifications = (configuration: InternalConfiguration, httpClient: HttpClient = http): Notifications => { 19 | const list = (notificationId: string) => { 20 | const url = urljoin(configuration.apiBaseUrl, 'notifications', notificationId); 21 | return { 22 | details: () => httpClient.get(configuration, url), 23 | delete: () => httpClient.delete_(configuration, url), 24 | mute: () => httpClient.post(configuration, urljoin(url, 'mute')), 25 | unmute: () => httpClient.post(configuration, urljoin(url, 'unmute')) 26 | }; 27 | }; 28 | 29 | const api = Object.assign(list, { 30 | emails: emails(configuration, httpClient), 31 | webhooks: webhooks(configuration, httpClient), 32 | list: utils.buildListCallFunction>( 33 | httpClient, 34 | configuration, 35 | urljoin(configuration.apiBaseUrl, 'notifications') 36 | ) 37 | }); 38 | 39 | return api; 40 | }; 41 | 42 | export interface Notifications { 43 | (notificationId: string): { 44 | details: Details; 45 | delete: Delete; 46 | mute: () => Promise; 47 | unmute: () => Promise; 48 | }; 49 | 50 | emails: NotificationEmails; 51 | webhooks: NotificationWebhooks; 52 | list: List; 53 | } 54 | 55 | export default notifications; 56 | -------------------------------------------------------------------------------- /bitmovin/player/analytics.ts: -------------------------------------------------------------------------------- 1 | import * as urlJoin from 'url-join'; 2 | 3 | import http from '../utils/http'; 4 | import {Create, Delete, HttpClient} from '../utils/types'; 5 | 6 | export interface Analytics { 7 | enable: Create; 8 | disable: Delete; 9 | } 10 | 11 | export const analytics = (configuration, licenseId, httpClient: HttpClient): Analytics => { 12 | const {post, delete_} = httpClient; 13 | 14 | const url = urlJoin(configuration.apiBaseUrl, 'player/licenses', licenseId, 'analytics'); 15 | 16 | return { 17 | enable: payload => { 18 | return post(configuration, url, payload); 19 | }, 20 | disable: () => { 21 | return delete_(configuration, url); 22 | } 23 | }; 24 | }; 25 | 26 | export default (configuration, licenseId): Analytics => { 27 | return analytics(configuration, licenseId, http); 28 | }; 29 | -------------------------------------------------------------------------------- /bitmovin/player/channels.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../utils/http'; 4 | import {ApiResource, Details, HttpClient, List} from '../utils/types'; 5 | 6 | export enum Channel { 7 | Developer = 'developer', 8 | Beta = 'beta', 9 | Staging = 'staging', 10 | Stable = 'stable' 11 | } 12 | 13 | export interface PlayerVersion { 14 | version: string; 15 | playerUrl: string; 16 | } 17 | 18 | export interface Channels { 19 | (channelName: string): { 20 | versions: { 21 | list: List; 22 | latest: Details; 23 | }; 24 | }; 25 | list: List; 26 | } 27 | 28 | export const channels = (configuration, httpClient: HttpClient): Channels => { 29 | const {get} = httpClient; 30 | const resourceDetails = (channelName: string) => { 31 | const versions = { 32 | list: utils.buildListCallFunction( 33 | httpClient, 34 | configuration, 35 | urljoin(configuration.apiBaseUrl, 'player/channels', channelName, 'versions') 36 | ), 37 | latest: () => { 38 | const url = urljoin(configuration.apiBaseUrl, 'player/channels', channelName, 'versions', 'latest'); 39 | return get>(configuration, url); 40 | } 41 | }; 42 | 43 | return { 44 | versions 45 | }; 46 | }; 47 | 48 | const list = utils.buildListCallFunction( 49 | httpClient, 50 | configuration, 51 | urljoin(configuration.apiBaseUrl, 'player/channels') 52 | ); 53 | 54 | const resource = Object.assign(resourceDetails, {list}); 55 | return resource; 56 | }; 57 | 58 | export default configuration => { 59 | return channels(configuration, http); 60 | }; 61 | -------------------------------------------------------------------------------- /bitmovin/player/domains.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../utils/http'; 4 | import {Create, Create2, Delete, HttpClient, List} from '../utils/types'; 5 | 6 | import {Domain, DomainDetails} from './licenses'; 7 | 8 | export interface Domains { 9 | (domainId: string): { 10 | delete: Delete; 11 | }; 12 | 13 | add: Create2; 14 | list: List; 15 | } 16 | 17 | export const domains = (configuration, licenseId, httpClient: HttpClient) => { 18 | const {post, delete_} = httpClient; 19 | 20 | const resourceDetails = domainId => { 21 | return { 22 | delete: () => { 23 | const url = urljoin(configuration.apiBaseUrl, 'player/licenses', licenseId, 'domains', domainId); 24 | return delete_(configuration, url); 25 | } 26 | }; 27 | }; 28 | 29 | const add = domain => { 30 | const url = urljoin(configuration.apiBaseUrl, 'player/licenses', licenseId, 'domains'); 31 | return post(configuration, url, domain); 32 | }; 33 | 34 | const list = utils.buildListCallFunction( 35 | httpClient, 36 | configuration, 37 | urljoin(configuration.apiBaseUrl, 'player/licenses', licenseId, 'domains') 38 | ); 39 | 40 | const resource = Object.assign(resourceDetails, {add, list}); 41 | return resource; 42 | }; 43 | 44 | export default (configuration, licenseId): Domains => { 45 | return domains(configuration, licenseId, http); 46 | }; 47 | -------------------------------------------------------------------------------- /bitmovin/player/index.ts: -------------------------------------------------------------------------------- 1 | import playerChannels, {Channels} from './channels'; 2 | import customBuilds, {CustomBuilds} from './customBuilds'; 3 | import playerLicenses, {Licenses} from './licenses'; 4 | import playerStatistics, {Statistics} from './statistics'; 5 | 6 | const player = (internalConfig): Player => ({ 7 | channels: playerChannels(internalConfig), 8 | licenses: playerLicenses(internalConfig), 9 | statistics: playerStatistics(internalConfig), 10 | customBuilds: customBuilds(internalConfig) 11 | }); 12 | 13 | export interface Player { 14 | channels: Channels; 15 | licenses: Licenses; 16 | statistics: Statistics; 17 | customBuilds: CustomBuilds; 18 | } 19 | 20 | export default player; 21 | -------------------------------------------------------------------------------- /bitmovin/player/licenses.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../utils/http'; 4 | import {ApiResource, Details, HttpClient, List} from '../utils/types'; 5 | 6 | import analytics, {Analytics} from './analytics'; 7 | import domains, {Domains} from './domains'; 8 | import thirdPartyLicensing, {ThirdPartyLicensing} from './thirdPartyLicensing'; 9 | 10 | export interface Domain { 11 | url: string; 12 | } 13 | 14 | export interface DomainDetails { 15 | id: string; 16 | url: string; 17 | } 18 | 19 | export interface PlayerLicense { 20 | id: string; 21 | name: string; 22 | licenseKey: string; 23 | impressions: number; 24 | maxImpressions: number; 25 | thirdPartyLicensingEnabled: boolean; 26 | domains: DomainDetails[]; 27 | } 28 | 29 | export interface UpdatePlayerLicense { 30 | name?: string; 31 | licenseKey?: string; 32 | impressions?: number; 33 | maxImpressions?: number; 34 | thirdPartyLicensingEnabled?: boolean; 35 | } 36 | 37 | export interface CreatePlayerLicensePayload { 38 | name: string; 39 | } 40 | 41 | export interface Licenses { 42 | (licenseId: string): { 43 | details: Details; 44 | update: (license: UpdatePlayerLicense) => Promise>; 45 | domains: Domains; 46 | thirdPartyLicensing: ThirdPartyLicensing; 47 | analytics: Analytics; 48 | }; 49 | 50 | create: (licensePayload: CreatePlayerLicensePayload) => Promise; 51 | list: List; 52 | } 53 | 54 | export const licenses = (configuration, httpClient: HttpClient): Licenses => { 55 | const {get, post, put} = httpClient; 56 | const resourceDetails = licenseId => { 57 | return { 58 | details: () => { 59 | const url = urljoin(configuration.apiBaseUrl, 'player/licenses', licenseId); 60 | return get(configuration, url); 61 | }, 62 | update: license => { 63 | const url = urljoin(configuration.apiBaseUrl, 'player/licenses', licenseId); 64 | return put(configuration, url, license); 65 | }, 66 | domains: domains(configuration, licenseId), 67 | thirdPartyLicensing: thirdPartyLicensing(configuration, licenseId), 68 | analytics: analytics(configuration, licenseId) 69 | }; 70 | }; 71 | 72 | const create = (licensePayload: CreatePlayerLicensePayload) => { 73 | const url = urljoin(configuration.apiBaseUrl, 'player/licenses'); 74 | return post(configuration, url, licensePayload); 75 | }; 76 | 77 | const list = utils.buildListCallFunction( 78 | httpClient, 79 | configuration, 80 | urljoin(configuration.apiBaseUrl, 'player/licenses') 81 | ); 82 | 83 | const resource = Object.assign(resourceDetails, {create, list}); 84 | return resource; 85 | }; 86 | 87 | export default configuration => { 88 | return licenses(configuration, http); 89 | }; 90 | -------------------------------------------------------------------------------- /bitmovin/player/statistics.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import BitmovinError from '../utils/BitmovinError'; 4 | import http, {utils} from '../utils/http'; 5 | import {HttpClient} from '../utils/types'; 6 | 7 | export interface Statistics { 8 | impressions: ( 9 | licenseKeyId: string, 10 | start?: string, 11 | end?: string, 12 | interval?: string, 13 | offset?: number, 14 | limit?: number 15 | ) => Promise; // TODO: properly type return type, couldn't find it in the api spec 16 | INTERVAL: { 17 | DAILY: 'DAILY'; 18 | }; 19 | } 20 | 21 | export const statistics = (configuration, httpClient: HttpClient): Statistics => { 22 | const {get} = httpClient; 23 | 24 | return { 25 | impressions: (licenseKeyId, start, end, interval, offset, limit) => { 26 | if (!start || !end) { 27 | return Promise.reject(new BitmovinError('Not all required params given.', undefined)); 28 | } 29 | 30 | const playerStatisticsBaseUrl = urljoin(configuration.apiBaseUrl, '/player/statistics/impressions'); 31 | 32 | const getParams = utils.buildGetParamString({ 33 | licenseKeyId, 34 | start, 35 | end, 36 | interval, 37 | offset, 38 | limit 39 | }); 40 | 41 | const url = urljoin(playerStatisticsBaseUrl, getParams); 42 | return get(configuration, url); 43 | }, 44 | INTERVAL: { 45 | DAILY: 'DAILY' 46 | } 47 | }; 48 | }; 49 | 50 | export default configuration => { 51 | return statistics(configuration, http); 52 | }; 53 | -------------------------------------------------------------------------------- /bitmovin/player/thirdPartyLicensing.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http from '../utils/http'; 4 | import {Create, Delete, Details, HttpClient} from '../utils/types'; 5 | 6 | export interface ThirdPartyLicensing { 7 | delete: Delete; 8 | get: Details; 9 | add: Create; 10 | } 11 | 12 | export const thirdPartyLicensing = (configuration, licenseId, httpClient: HttpClient) => { 13 | const {get, post, delete_} = httpClient; 14 | 15 | return { 16 | delete: () => { 17 | const url = urljoin(configuration.apiBaseUrl, 'player/licenses', licenseId, 'third-party-licensing'); 18 | return delete_(configuration, url); 19 | }, 20 | get: () => { 21 | const url = urljoin(configuration.apiBaseUrl, 'player/licenses', licenseId, 'third-party-licensing'); 22 | return get(configuration, url); 23 | }, 24 | add: thirdPartyLicensingPayload => { 25 | const url = urljoin(configuration.apiBaseUrl, 'player/licenses', licenseId, 'third-party-licensing'); 26 | return post(configuration, url, thirdPartyLicensingPayload); 27 | } 28 | }; 29 | }; 30 | 31 | export default (configuration, licenseId): ThirdPartyLicensing => { 32 | return thirdPartyLicensing(configuration, licenseId, http); 33 | }; 34 | -------------------------------------------------------------------------------- /bitmovin/player/webCustomPlayerBuildDomain.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import http, {utils} from '../utils/http'; 4 | import {HttpClient} from '../utils/types'; 5 | 6 | export const webCustomPlayerBuildDomain = (configuration, httpClient: HttpClient) => { 7 | const {get, post, delete_} = httpClient; 8 | 9 | const resourceDetails = domainId => { 10 | return { 11 | details: () => { 12 | const url = urljoin(configuration.apiBaseUrl, 'player/custom-builds/web/domains', domainId); 13 | return get(configuration, url); 14 | }, 15 | delete: () => { 16 | const url = urljoin(configuration.apiBaseUrl, 'player/custom-builds/web/domains', domainId); 17 | return delete_(configuration, url); 18 | } 19 | }; 20 | }; 21 | 22 | const add = customPlayerBuildDomain => { 23 | const url = urljoin(configuration.apiBaseUrl, 'player/custom-builds/web/domains'); 24 | return post(configuration, url, customPlayerBuildDomain); 25 | }; 26 | 27 | const list = utils.buildListCallFunction( 28 | httpClient, 29 | configuration, 30 | urljoin(configuration.apiBaseUrl, 'player/custom-builds/web/domains') 31 | ); 32 | 33 | const resource = Object.assign(resourceDetails, {add, list}); 34 | return resource; 35 | }; 36 | 37 | export default configuration => { 38 | return webCustomPlayerBuildDomain(configuration, http); 39 | }; 40 | -------------------------------------------------------------------------------- /bitmovin/utils/BitmovinError.ts: -------------------------------------------------------------------------------- 1 | export default class BitmovinError extends Error { 2 | private response: any; 3 | 4 | constructor(message, response) { 5 | super(message); 6 | this.response = response; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /bitmovin/utils/DateUtils.ts: -------------------------------------------------------------------------------- 1 | import * as moment from 'moment'; 2 | 3 | export const getFirstDayOfMonthFromDate = (date = new Date()) => { 4 | return moment 5 | .utc(date) 6 | .startOf('month') 7 | .toDate(); 8 | }; 9 | 10 | export const getLastDayOfMonthFromDate = (date = new Date()) => { 11 | return moment 12 | .utc(date) 13 | .endOf('month') 14 | .toDate(); 15 | }; 16 | 17 | export const getFirstDayOfTheWeekFromDate = (date = new Date()) => { 18 | return moment 19 | .utc(date) 20 | .startOf('isoWeek') 21 | .toDate(); 22 | }; 23 | 24 | export const getLastDayOfWeekFromDate = (date = new Date()) => { 25 | return moment 26 | .utc(date) 27 | .endOf('isoWeek') 28 | .toDate(); 29 | }; 30 | 31 | export const dateToApiRequestString = date => { 32 | return moment(date) 33 | .format('YYYY-MM-DD') 34 | .toString(); 35 | }; 36 | 37 | export const isValidApiRequestDateString = dateString => { 38 | if (typeof dateString !== 'string') { 39 | return false; 40 | } 41 | 42 | const regex = /^\d{4}-\d{2}-\d{2}$/; 43 | return dateString.match(regex) !== null; 44 | }; 45 | -------------------------------------------------------------------------------- /bitmovin/utils/Logger.ts: -------------------------------------------------------------------------------- 1 | class Logger { 2 | public logging: boolean; 3 | 4 | constructor(logging) { 5 | this.setLogging(logging); 6 | } 7 | 8 | public setLogging(logging) { 9 | this.logging = logging; 10 | } 11 | 12 | public enableLogging() { 13 | this.setLogging(true); 14 | } 15 | 16 | public disableLogging() { 17 | this.setLogging(false); 18 | } 19 | 20 | public log(message) { 21 | if (!this.logging) { 22 | return; 23 | } 24 | 25 | // tslint:disable-next-line 26 | console.log(message); 27 | } 28 | 29 | public error(message) { 30 | if (!this.logging) { 31 | return; 32 | } 33 | // tslint:disable-next-line 34 | console.error(message); 35 | } 36 | } 37 | 38 | const logger = new Logger(false); 39 | 40 | export default logger; 41 | -------------------------------------------------------------------------------- /bitmovin/utils/UrlUtils.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import {utils} from './http'; 4 | 5 | export const buildListUrl = (url, limit, offset, sort, filter) => { 6 | const filterParams = utils.buildFilterParamString(filter); 7 | const getParams = utils.buildGetParamString({ 8 | ...filterParams, 9 | limit, 10 | offset, 11 | sort 12 | }); 13 | if (getParams.length > 0) { 14 | return urljoin(url, getParams); 15 | } 16 | return url; 17 | }; 18 | -------------------------------------------------------------------------------- /bitmovin/utils/Utils.ts: -------------------------------------------------------------------------------- 1 | class Utils { 2 | public isNoEmptyString(value) { 3 | return typeof value === 'string' && value.length > 0; 4 | } 5 | } 6 | 7 | const utils = new Utils(); 8 | 9 | export default utils; 10 | -------------------------------------------------------------------------------- /bitmovin/utils/enums.ts: -------------------------------------------------------------------------------- 1 | export enum SortingDirection { 2 | Ascending = 'ASC', 3 | Descending = 'DESC', 4 | None = 'NONE' 5 | } 6 | -------------------------------------------------------------------------------- /bitmovin/utils/types.ts: -------------------------------------------------------------------------------- 1 | export interface BitmovinConfiguration { 2 | apiKey: string; 3 | tenantOrgId?: string; 4 | debug?: boolean; 5 | protocol?: string; 6 | host?: string; 7 | apiBaseUrl?: string; 8 | basePath?: string; 9 | requestTimeout?: number; 10 | xApiClient?: string; 11 | additionalHeaders?: any; 12 | httpHeaders?: any; 13 | } 14 | 15 | export interface InternalConfiguration { 16 | apiKey: string; 17 | tenantOrgId?: string; 18 | debug?: boolean; 19 | protocol: string; 20 | host: string; 21 | apiBaseUrl: string; 22 | basePath: string; 23 | requestTimeout: number; 24 | xApiClient: string; 25 | additionalHeaders?: any; 26 | httpHeaders?: any; 27 | } 28 | 29 | export type Pagination = J & { 30 | totalCount: number; 31 | items: Array>; 32 | }; 33 | 34 | interface ResponseSuccessData { 35 | result: T; 36 | messages?: Array<{ 37 | id: string; 38 | date: string; 39 | interface: string; 40 | }>; 41 | } 42 | 43 | interface ResponseErrorData { 44 | code: number; 45 | message: string; 46 | developerMessage: string; 47 | } 48 | 49 | export interface ResponseEnvelope { 50 | requestId: string; 51 | status: 'SUCCESS' | 'ERROR'; 52 | data: ResponseSuccessData | ResponseErrorData; 53 | } 54 | 55 | export interface ResourceId { 56 | id: string; 57 | } 58 | 59 | export type ApiResource = T & { 60 | id: string; 61 | name?: string; 62 | description?: string; 63 | createdAt?: string; 64 | customData?: string; 65 | }; 66 | 67 | interface CustomDataT { 68 | customData?: string; 69 | createdAt?: string; 70 | } 71 | 72 | export type List = ( 73 | limit?: number, 74 | offset?: number, 75 | sort?: string, 76 | filter?: any 77 | ) => Promise, J>>; 78 | 79 | export type Create2 = (data: TParam) => Promise>; 80 | export type Create = (data: T) => Promise>; 81 | export type OptionalCreate = (data?: T) => Promise>; 82 | export type Details = () => Promise>; 83 | export type Delete = () => Promise; 84 | export type CustomData = () => Promise; 85 | 86 | export interface HttpClient { 87 | get(configuration: InternalConfiguration, url: string, fetchMethod?: any): Promise; 88 | post(configuration: InternalConfiguration, url: string, object?: J, fetchMethod?: any): Promise; 89 | put(configuration: InternalConfiguration, url: string, object?: J, fetchMethod?: any): Promise; 90 | delete_(configuration: InternalConfiguration, url: string, fetchMethod?: any): Promise; 91 | } 92 | 93 | export interface BitmovinDetails { 94 | createdAt: string; 95 | modifiedAt: string; 96 | } 97 | 98 | export interface DeleteResult extends ResourceId {} 99 | -------------------------------------------------------------------------------- /examples/analytics/01_industry_insights.js: -------------------------------------------------------------------------------- 1 | const Bitmovin = require('../../dist/index').default; 2 | console.log(Bitmovin); 3 | 4 | const BITMOVIN_API_KEY = ''; 5 | const bitmovin = new Bitmovin({apiKey: BITMOVIN_API_KEY, debug: false}); 6 | bitmovin.analytics.insights.industry.builder 7 | .metric('error_percentage') 8 | .industry('all') 9 | .subIndustry('test') 10 | .filter('browser', 'Firefox') 11 | .query() 12 | .then(result => { 13 | console.log('value: ' + result.value); 14 | }) 15 | .catch(error => { 16 | console.error('Error getting industry insight!', error); 17 | }); 18 | -------------------------------------------------------------------------------- /examples/analytics/02_organization_settings.js: -------------------------------------------------------------------------------- 1 | const Bitmovin = require('../../dist/index').default; 2 | console.log(Bitmovin); 3 | 4 | const BITMOVIN_API_KEY = ''; 5 | const ORGANIZATION_ID = ''; 6 | const bitmovin = new Bitmovin({apiKey: BITMOVIN_API_KEY, debug: false}); 7 | bitmovin.analytics.insights.organizations 8 | .settings(ORGANIZATION_ID) 9 | .details() 10 | .then(result => { 11 | console.log(result); 12 | }) 13 | .catch(error => { 14 | console.error('Error getting details for organization settings!', error); 15 | }); 16 | 17 | bitmovin.analytics.insights.organizations 18 | .settings(ORGANIZATION_ID) 19 | .update({ 20 | includeInInsights: false 21 | }) 22 | .then(result => { 23 | console.log(result); 24 | }) 25 | .catch(error => { 26 | console.error('Error updating organization settings!', error); 27 | }); 28 | -------------------------------------------------------------------------------- /examples/analytics/03_impressions.js: -------------------------------------------------------------------------------- 1 | const Bitmovin = require('../../dist/index').default; 2 | console.log(Bitmovin); 3 | 4 | const BITMOVIN_API_KEY = ''; 5 | const bitmovin = new Bitmovin({apiKey: BITMOVIN_API_KEY, debug: false}); 6 | 7 | bitmovin.analytics 8 | .impressions({ 9 | licenseKey: '', 10 | start: new Date('2019-11-07').getTime(), 11 | end: new Date('2019-11-10').getTime(), 12 | filters: [{name: 'CUSTOM_USER_ID', operator: 'EQ', value: 'customer#1'}] 13 | }) 14 | .then(result => { 15 | console.log(result); 16 | }) 17 | .catch(error => { 18 | console.error('Error fetching impressions', error); 19 | }); 20 | 21 | bitmovin.analytics.impressions 22 | .details('', '') 23 | .then(result => { 24 | console.log(result); 25 | }) 26 | .catch(error => { 27 | console.error('Error getting impression details', error); 28 | }); 29 | -------------------------------------------------------------------------------- /examples/analytics/04_filters.js: -------------------------------------------------------------------------------- 1 | const Bitmovin = require('../../dist/index').default; 2 | console.log(Bitmovin); 3 | 4 | const BITMOVIN_API_KEY = ''; 5 | const bitmovin = new Bitmovin({apiKey: BITMOVIN_API_KEY, debug: false}); 6 | 7 | bitmovin.analytics.filters 8 | .customUserId({ 9 | licenseKey: '', 10 | start: new Date('2019-11-07').getTime(), 11 | end: new Date('2019-11-10').getTime(), 12 | query: '' 13 | }) 14 | .then(result => { 15 | console.log(result); 16 | }) 17 | .catch(error => { 18 | console.error('Error fetching impressions', error); 19 | }); 20 | -------------------------------------------------------------------------------- /examples/analytics/05_releases.js: -------------------------------------------------------------------------------- 1 | const Bitmovin = require('../../dist/index').default; 2 | console.log(Bitmovin); 3 | 4 | const BITMOVIN_API_KEY = ''; 5 | const bitmovin = new Bitmovin({apiKey: BITMOVIN_API_KEY, debug: false}); 6 | 7 | bitmovin.analytics.releases.platforms 8 | .list() 9 | .then(result => { 10 | console.log(result); 11 | }) 12 | .catch(error => { 13 | console.error('Error fetching platforms', error); 14 | }); 15 | 16 | bitmovin.analytics.releases 17 | .platforms('web') 18 | .channels.list() 19 | .then(result => { 20 | console.log(result); 21 | }) 22 | .catch(error => { 23 | console.error('Error fetching channels', error); 24 | }); 25 | 26 | bitmovin.analytics.releases 27 | .platforms('web') 28 | .channels('stable') 29 | .versions.list() 30 | .then(result => { 31 | console.log(result); 32 | }) 33 | .catch(error => { 34 | console.error('Error fetching versions', error); 35 | }); 36 | -------------------------------------------------------------------------------- /examples/encoding/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | *_compiled.js 3 | 4 | -------------------------------------------------------------------------------- /examples/encoding/04_stop_livestream.js: -------------------------------------------------------------------------------- 1 | // 04_stop_livestream.js 2 | 3 | const Bitmovin = require('bitmovin-javascript').default; 4 | 5 | const BITMOVIN_API_KEY = 'INSERT_YOUR_API_KEY'; 6 | const ENCODING_ID_TO_STOP = 'ENCODING ID TO STOP'; 7 | 8 | const bitmovin = new Bitmovin({apiKey: BITMOVIN_API_KEY}); 9 | 10 | const main = () => { 11 | return bitmovin.encoding.encodings(ENCODING_ID_TO_STOP).stopLive(); 12 | }; 13 | 14 | main() 15 | .then(stopResponse => { 16 | console.log('----------------------------------------------------------------------'); 17 | console.log('Successfully stopped live encoding with id ' + stopResponse.id + '!'); 18 | console.log('----------------------------------------------------------------------'); 19 | }) 20 | .catch(error => { 21 | console.error('ERROR!', error); 22 | process.exit(100); 23 | }); 24 | -------------------------------------------------------------------------------- /examples/encoding/README.md: -------------------------------------------------------------------------------- 1 | # Bitmovin Javascript Encoding Examples 2 | 3 | - run `yarn add bitmovin-javascript` 4 | - copy one of the examples to your project 5 | - replace the `` with your api key, input credentials, etc. 6 | - run the example with `node xx_example_name.js` 7 | -------------------------------------------------------------------------------- /examples/player/README.md: -------------------------------------------------------------------------------- 1 | # Bitmovin Javascript Player Examples 2 | 3 | - run `yarn add bitmovin-javascript` 4 | - copy one of the examples to your project 5 | - replace the `` with your api key, etc. 6 | - run the example with `node xx_example_name.js` 7 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "transform": { 3 | "^.+\\.ts$": "ts-jest" 4 | }, 5 | "testRegex": "/tests/.*.test.ts$", 6 | "moduleFileExtensions": [ 7 | "ts", 8 | "js", 9 | "json" 10 | ], 11 | "globals": { 12 | "ts-jest": { 13 | "tsConfigFile": "tsconfig.json" 14 | }, 15 | "__VERSION__": "test" 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bitmovin-javascript", 3 | "version": "2.35.0", 4 | "main": "./dist/index.js", 5 | "browser": "./dist/bitmovin.browser.js", 6 | "types": "./dist/index.d.ts", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/bitmovin/bitmovin-javascript.git" 10 | }, 11 | "files": [ 12 | "dist" 13 | ], 14 | "license": "MIT", 15 | "scripts": { 16 | "clean": "rimraf dist", 17 | "lint": "tslint \"./{bitmovin,tests}/**/*.ts\"", 18 | "lint-examples": "eslint ./examples", 19 | "test": "jest --watch", 20 | "coverage-ci": "jest --runInBand --coverage", 21 | "format": "prettier --config ./.prettierrc --write \"./{bitmovin,examples,tests}/**/*.ts\"", 22 | "format-files": "prettier --config ./.prettierrc --write", 23 | "format-check": "prettier --config ./.prettierrc --list-different \"./{bitmovin,examples,tests}/**/*.ts\"", 24 | "build": "yarn clean && yarn build:bundle:dev && yarn build:bundle:prod && yarn build:modules", 25 | "build:bundle:dev": "cross-env NODE_ENV=development webpack --config=./webpack4.config.js", 26 | "build:bundle:prod": "cross-env NODE_ENV=production webpack --config=./webpack4.config.js", 27 | "build:modules": "tsc --project ./tsconfig.json && replace \"__VERSION__\" \"'$(node -p \"require('./package.json').version\")'\" ./dist/index.js", 28 | "prepublish": "yarn lint && yarn build", 29 | "precommit": "lint-staged" 30 | }, 31 | "lint-staged": { 32 | "*.ts": [ 33 | "yarn format-files", 34 | "tslint --fix", 35 | "git add" 36 | ], 37 | "*.js": [ 38 | "yarn format-files", 39 | "eslint --fix", 40 | "git add" 41 | ] 42 | }, 43 | "devDependencies": { 44 | "@types/isomorphic-fetch": "^0.0.34", 45 | "@types/jest": "^23.0.0", 46 | "@types/url-join": "^0.8.2", 47 | "awesome-typescript-loader": "^5.0.0", 48 | "codecov": "^2.2.0", 49 | "cross-env": "^5.2.0", 50 | "eslint": "^4.19.1", 51 | "esprima": "^4.0.0", 52 | "husky": "^0.14.3", 53 | "jest": "^23.1.0", 54 | "lint-staged": "^7.2.0", 55 | "prettier": "^1.12.1", 56 | "replace": "^1.0.0", 57 | "rimraf": "^2.6.2", 58 | "ts-jest": "^22.4.6", 59 | "tslint": "^5.10.0", 60 | "typescript": "^2.9.1", 61 | "uglifyjs-webpack-plugin": "^1.2.5", 62 | "webpack": "^4.10.2", 63 | "webpack-cli": "^3.1.1" 64 | }, 65 | "dependencies": { 66 | "es6-promise": "^4.2.4", 67 | "isomorphic-fetch": "^2.2.1", 68 | "moment": "^2.17.1", 69 | "url-join": "^1.1.0" 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /tests/account/account.test.ts: -------------------------------------------------------------------------------- 1 | import {account} from '../../bitmovin/account'; 2 | import { 3 | assertItCallsCorrectUrl, 4 | assertItReturnsUnderlyingPromise, 5 | assertPayload, 6 | mockGet, 7 | mockHttp, 8 | mockPost, 9 | testSetup 10 | } from '../assertions'; 11 | import {getConfiguration} from '../utils'; 12 | 13 | const testConfigurationWithHeaders = getConfiguration(); 14 | 15 | describe('account', () => { 16 | beforeEach(() => { 17 | testSetup(); 18 | }); 19 | const client = account(testConfigurationWithHeaders, mockHttp); 20 | 21 | describe('information', () => { 22 | assertItCallsCorrectUrl('GET', '/v1/account/information', client.information); 23 | assertItReturnsUnderlyingPromise(mockGet, client.information); 24 | }); 25 | 26 | describe('login', () => { 27 | const email = 'test@email.com'; 28 | const password = 'mypassword'; 29 | 30 | assertItReturnsUnderlyingPromise(mockPost, () => client.login(email, password)); 31 | 32 | it('should call POST /v1/account/login', () => { 33 | return client.login(email, password).then(() => { 34 | const callParams = mockPost.mock.calls[0]; 35 | expect(callParams[1]).toEqual(expect.stringMatching('/v1/account/login$')); 36 | }); 37 | }); 38 | 39 | it('should send appropriate login request payload', () => { 40 | return client.login(email, password).then(() => { 41 | const callParams = mockPost.mock.calls[0]; 42 | expect(callParams[2]).toEqual({ 43 | eMail: email, 44 | password 45 | }); 46 | }); 47 | }); 48 | }); 49 | 50 | describe('changePassword', () => { 51 | const email = 'test@email.com'; 52 | const currentPassword = 'oldpwd'; 53 | const newPassword = 'newpwd'; 54 | 55 | assertItCallsCorrectUrl('POST', '/v1/account/password/change', () => 56 | client.changePassword(email, currentPassword, newPassword) 57 | ); 58 | assertItReturnsUnderlyingPromise(mockPost, () => client.changePassword(email, currentPassword, newPassword)); 59 | assertPayload(mockPost, () => client.changePassword(email, currentPassword, newPassword), { 60 | eMail: email, 61 | currentPassword, 62 | newPassword 63 | }); 64 | }); 65 | }); 66 | -------------------------------------------------------------------------------- /tests/account/apiKeys.test.ts: -------------------------------------------------------------------------------- 1 | import apiKeys from '../../bitmovin/account/apiKeys'; 2 | import {assertItCallsCorrectUrl, assertItReturnsUnderlyingPromise, mockGet, mockHttp, testSetup} from '../assertions'; 3 | import {getConfiguration} from '../utils'; 4 | 5 | const testConfiguration = getConfiguration(); 6 | 7 | describe('apiKeys', () => { 8 | beforeEach(testSetup); 9 | 10 | describe('should list all api keys', () => { 11 | const client = apiKeys(testConfiguration, mockHttp); 12 | assertItCallsCorrectUrl('GET', '/v1/account/api-keys', client.list); 13 | assertItReturnsUnderlyingPromise(mockGet, client); 14 | }); 15 | 16 | describe('should create an api key', () => { 17 | const client = apiKeys(testConfiguration, mockHttp); 18 | assertItCallsCorrectUrl('POST', '/v1/account/api-keys', client.create); 19 | assertItReturnsUnderlyingPromise(mockGet, client); 20 | }); 21 | 22 | describe('should get the api key', () => { 23 | const client = apiKeys(testConfiguration, mockHttp); 24 | assertItCallsCorrectUrl('GET', '/v1/account/api-keys/aaaaaaaaaa', () => client('aaaaaaaaaa')); 25 | assertItReturnsUnderlyingPromise(mockGet, client); 26 | }); 27 | 28 | describe('should delete the api key', () => { 29 | const client = apiKeys(testConfiguration, mockHttp); 30 | assertItCallsCorrectUrl('DELETE', '/v1/account/api-keys/aaaaaaaaaa', () => client.delete('aaaaaaaaaa')); 31 | assertItReturnsUnderlyingPromise(mockGet, client); 32 | }); 33 | }); 34 | -------------------------------------------------------------------------------- /tests/account/billing/contactDetails.test.ts: -------------------------------------------------------------------------------- 1 | import {contactDetails} from '../../../bitmovin/account/billing/contactDetails'; 2 | import { 3 | assertItCallsCorrectUrl, 4 | assertItReturnsUnderlyingPromise, 5 | mockGet, 6 | mockHttp, 7 | mockPut, 8 | testSetup 9 | } from '../../assertions'; 10 | import {getConfiguration} from '../../utils'; 11 | 12 | const testConfiguration = getConfiguration(); 13 | 14 | describe('account', () => { 15 | beforeEach(testSetup); 16 | describe('billing', () => { 17 | describe('accountDetails', () => { 18 | const client = contactDetails(testConfiguration, mockHttp); 19 | describe('details', () => { 20 | assertItCallsCorrectUrl('GET', '/v1/account/billing/contact-details', client.details); 21 | assertItReturnsUnderlyingPromise(mockGet, client.details); 22 | }); 23 | describe('update', () => { 24 | assertItCallsCorrectUrl('PUT', '/v1/account/billing/contact-details', client.update); 25 | assertItReturnsUnderlyingPromise(mockPut, client.update); 26 | }); 27 | }); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /tests/account/billing/invoices.test.ts: -------------------------------------------------------------------------------- 1 | import {invoices} from '../../../bitmovin/account/billing/invoices'; 2 | import { 3 | assertItCallsCorrectUrl, 4 | assertItReturnsUnderlyingPromise, 5 | mockGet, 6 | mockHttp, 7 | testSetup 8 | } from '../../assertions'; 9 | import {getConfiguration} from '../../utils'; 10 | 11 | const testConfiguration = getConfiguration(); 12 | 13 | describe('account', () => { 14 | beforeEach(testSetup); 15 | describe('billing', () => { 16 | describe('invoices/encodings', () => { 17 | const client = invoices(testConfiguration, mockHttp); 18 | describe('list', () => { 19 | assertItCallsCorrectUrl('GET', '/v1/account/billing/invoices/encoding', client.encoding.list); 20 | assertItReturnsUnderlyingPromise(mockGet, client.encoding.list); 21 | }); 22 | 23 | describe('list with limit offset', () => { 24 | const limit = 100; 25 | const offset = 15; 26 | const expectedGetParameters = '\\?limit=' + limit + '&offset=' + offset; 27 | 28 | assertItCallsCorrectUrl('GET', '/v1/account/billing/invoices/encoding' + expectedGetParameters, () => 29 | client.encoding.list(limit, offset) 30 | ); 31 | assertItReturnsUnderlyingPromise(mockGet, client.encoding.list); 32 | }); 33 | }); 34 | 35 | describe('invoices/player', () => { 36 | const client = invoices(testConfiguration, mockHttp); 37 | describe('list', () => { 38 | assertItCallsCorrectUrl('GET', '/v1/account/billing/invoices/player', client.player.list); 39 | assertItReturnsUnderlyingPromise(mockGet, client.player.list); 40 | }); 41 | 42 | describe('list with limit offset', () => { 43 | const limit = 100; 44 | const offset = 15; 45 | const expectedGetParameters = '\\?limit=' + limit + '&offset=' + offset; 46 | 47 | assertItCallsCorrectUrl('GET', '/v1/account/billing/invoices/player' + expectedGetParameters, () => 48 | client.player.list(limit, offset) 49 | ); 50 | assertItReturnsUnderlyingPromise(mockGet, client.encoding.list); 51 | }); 52 | }); 53 | 54 | describe('invoices/analytics', () => { 55 | const client = invoices(testConfiguration, mockHttp); 56 | describe('list', () => { 57 | assertItCallsCorrectUrl('GET', '/v1/account/billing/invoices/analytics', client.analytics.list); 58 | assertItReturnsUnderlyingPromise(mockGet, client.player.list); 59 | }); 60 | 61 | describe('list with limit offset', () => { 62 | const limit = 100; 63 | const offset = 15; 64 | const expectedGetParameters = '\\?limit=' + limit + '&offset=' + offset; 65 | 66 | assertItCallsCorrectUrl('GET', '/v1/account/billing/invoices/analytics' + expectedGetParameters, () => 67 | client.analytics.list(limit, offset) 68 | ); 69 | assertItReturnsUnderlyingPromise(mockGet, client.encoding.list); 70 | }); 71 | }); 72 | }); 73 | }); 74 | -------------------------------------------------------------------------------- /tests/account/billing/statements.test.ts: -------------------------------------------------------------------------------- 1 | import {statements} from '../../../bitmovin/account/billing/statements'; 2 | import { 3 | assertItCallsCorrectUrl, 4 | assertItReturnsUnderlyingPromise, 5 | mockGet, 6 | mockHttp, 7 | testSetup 8 | } from '../../assertions'; 9 | import {getConfiguration} from '../../utils'; 10 | 11 | const testConfiguration = getConfiguration(); 12 | 13 | describe('account', () => { 14 | beforeEach(testSetup); 15 | describe('billing', () => { 16 | describe('statements/encodings', () => { 17 | const client = statements(testConfiguration, mockHttp); 18 | describe('list', () => { 19 | assertItCallsCorrectUrl('GET', '/v1/account/billing/statements/encoding', client.encoding.list); 20 | assertItReturnsUnderlyingPromise(mockGet, client.encoding.list); 21 | }); 22 | 23 | describe('list with limit offset', () => { 24 | const limit = 100; 25 | const offset = 15; 26 | const expectedGetParameters = '\\?limit=' + limit + '&offset=' + offset; 27 | 28 | assertItCallsCorrectUrl('GET', '/v1/account/billing/statements/encoding' + expectedGetParameters, () => 29 | client.encoding.list(limit, offset) 30 | ); 31 | assertItReturnsUnderlyingPromise(mockGet, client.encoding.list); 32 | }); 33 | }); 34 | 35 | describe('statements/player', () => { 36 | const client = statements(testConfiguration, mockHttp); 37 | describe('list', () => { 38 | assertItCallsCorrectUrl('GET', '/v1/account/billing/statements/player', client.player.list); 39 | assertItReturnsUnderlyingPromise(mockGet, client.player.list); 40 | }); 41 | 42 | describe('list with limit offset', () => { 43 | const limit = 100; 44 | const offset = 15; 45 | const expectedGetParameters = '\\?limit=' + limit + '&offset=' + offset; 46 | 47 | assertItCallsCorrectUrl('GET', '/v1/account/billing/statements/player' + expectedGetParameters, () => 48 | client.player.list(limit, offset) 49 | ); 50 | assertItReturnsUnderlyingPromise(mockGet, client.encoding.list); 51 | }); 52 | }); 53 | 54 | describe('statements/analytics', () => { 55 | const client = statements(testConfiguration, mockHttp); 56 | describe('list', () => { 57 | assertItCallsCorrectUrl('GET', '/v1/account/billing/statements/analytics', client.analytics.list); 58 | assertItReturnsUnderlyingPromise(mockGet, client.player.list); 59 | }); 60 | 61 | describe('list with limit offset', () => { 62 | const limit = 100; 63 | const offset = 15; 64 | const expectedGetParameters = '\\?limit=' + limit + '&offset=' + offset; 65 | 66 | assertItCallsCorrectUrl('GET', '/v1/account/billing/statements/analytics' + expectedGetParameters, () => 67 | client.analytics.list(limit, offset) 68 | ); 69 | assertItReturnsUnderlyingPromise(mockGet, client.encoding.list); 70 | }); 71 | }); 72 | }); 73 | }); 74 | -------------------------------------------------------------------------------- /tests/account/organizations/groups.test.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import {groups} from '../../../bitmovin/account/organizations/groups'; 4 | import { 5 | assertItCallsCorrectUrl, 6 | assertItReturnsUnderlyingPromise, 7 | mockDelete, 8 | mockGet, 9 | mockHttp, 10 | mockPost, 11 | testSetup 12 | } from '../../assertions'; 13 | import {getConfiguration} from '../../utils'; 14 | 15 | const testConfiguration = getConfiguration(); 16 | 17 | describe('account', () => { 18 | beforeEach(testSetup); 19 | describe('organizations', () => { 20 | describe('groups', () => { 21 | const testOrgId = '123'; 22 | const client = groups(testConfiguration, testOrgId, mockHttp); 23 | 24 | describe('list', () => { 25 | assertItCallsCorrectUrl('GET', urljoin('/v1/account/organizations', testOrgId, 'groups'), client.list); 26 | assertItReturnsUnderlyingPromise(mockGet, client.list); 27 | }); 28 | 29 | describe('add', () => { 30 | assertItCallsCorrectUrl('POST', urljoin('/v1/account/organizations', testOrgId, 'groups'), client.add); 31 | assertItReturnsUnderlyingPromise(mockPost, client.add); 32 | }); 33 | 34 | describe('group', () => { 35 | const testGroupId = '123'; 36 | 37 | describe('details', () => { 38 | assertItCallsCorrectUrl( 39 | 'GET', 40 | urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId), 41 | client(testGroupId).details 42 | ); 43 | assertItReturnsUnderlyingPromise(mockGet, client(testOrgId).details); 44 | }); 45 | describe('delete', () => { 46 | assertItCallsCorrectUrl( 47 | 'DELETE', 48 | urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId), 49 | client(testGroupId).delete 50 | ); 51 | assertItReturnsUnderlyingPromise(mockDelete, client(testOrgId).delete); 52 | }); 53 | }); 54 | }); 55 | }); 56 | }); 57 | -------------------------------------------------------------------------------- /tests/account/organizations/organizations.test.ts: -------------------------------------------------------------------------------- 1 | import {organizations} from '../../../bitmovin/account/organizations'; 2 | import { 3 | assertItCallsCorrectUrl, 4 | assertItReturnsUnderlyingPromise, 5 | mockDelete, 6 | mockGet, 7 | mockHttp, 8 | mockPost, 9 | testSetup 10 | } from '../../assertions'; 11 | import {getConfiguration} from '../../utils'; 12 | 13 | const testConfiguration = getConfiguration(); 14 | 15 | describe('account', () => { 16 | beforeEach(testSetup); 17 | describe('organizations', () => { 18 | const client = organizations(testConfiguration, mockHttp); 19 | describe('list', () => { 20 | assertItCallsCorrectUrl('GET', '/v1/account/organizations', client.list); 21 | assertItReturnsUnderlyingPromise(mockGet, client.list); 22 | }); 23 | describe('add', () => { 24 | assertItCallsCorrectUrl('POST', '/v1/account/organizations', client.add); 25 | assertItReturnsUnderlyingPromise(mockPost, client.add); 26 | }); 27 | describe('organization', () => { 28 | describe('details', () => { 29 | assertItCallsCorrectUrl('GET', '/v1/account/organizations/org-id', client('org-id').details); 30 | assertItReturnsUnderlyingPromise(mockGet, client('org-id').details); 31 | }); 32 | describe('delete', () => { 33 | assertItCallsCorrectUrl('DELETE', '/v1/account/organizations/org-id', client('org-id').delete); 34 | assertItReturnsUnderlyingPromise(mockDelete, client('org-id').delete); 35 | }); 36 | }); 37 | }); 38 | }); 39 | -------------------------------------------------------------------------------- /tests/account/organizations/permissions.test.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import {permissions} from '../../../bitmovin/account/organizations/permissions'; 4 | import { 5 | assertItCallsCorrectUrl, 6 | assertItReturnsUnderlyingPromise, 7 | mockDelete, 8 | mockGet, 9 | mockHttp, 10 | mockPost, 11 | testSetup 12 | } from '../../assertions'; 13 | import {getConfiguration} from '../../utils'; 14 | 15 | const testConfiguration = getConfiguration(); 16 | 17 | describe('account', () => { 18 | beforeEach(testSetup); 19 | describe('organizations', () => { 20 | describe('groups', () => { 21 | describe('permissions', () => { 22 | const testOrgId = '123'; 23 | const testGroupId = '123'; 24 | 25 | const client = permissions(testConfiguration, testOrgId, testGroupId, mockHttp); 26 | 27 | describe('list', () => { 28 | assertItCallsCorrectUrl( 29 | 'GET', 30 | urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'permissions'), 31 | client.list 32 | ); 33 | assertItReturnsUnderlyingPromise(mockGet, client.list); 34 | }); 35 | 36 | describe('add', () => { 37 | assertItCallsCorrectUrl( 38 | 'POST', 39 | urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'permissions'), 40 | client.add 41 | ); 42 | assertItReturnsUnderlyingPromise(mockPost, client.add); 43 | }); 44 | 45 | describe('permission', () => { 46 | const testPermissionId = '123'; 47 | 48 | describe('details', () => { 49 | assertItCallsCorrectUrl( 50 | 'GET', 51 | urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'permissions', testPermissionId), 52 | client(testGroupId).details 53 | ); 54 | assertItReturnsUnderlyingPromise(mockGet, client(testOrgId).details); 55 | }); 56 | describe('delete', () => { 57 | assertItCallsCorrectUrl( 58 | 'DELETE', 59 | urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'permissions', testPermissionId), 60 | client(testGroupId).delete 61 | ); 62 | assertItReturnsUnderlyingPromise(mockDelete, client(testOrgId).delete); 63 | }); 64 | }); 65 | }); 66 | }); 67 | }); 68 | }); 69 | -------------------------------------------------------------------------------- /tests/account/organizations/sub-organizations.test.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import {subOrganizations} from '../../../bitmovin/account/organizations/sub-organizations'; 4 | import { 5 | assertItCallsCorrectUrl, 6 | assertItReturnsUnderlyingPromise, 7 | mockGet, 8 | mockHttp, 9 | testSetup 10 | } from '../../assertions'; 11 | 12 | import {getConfiguration} from '../../utils'; 13 | const testConfiguration = getConfiguration(); 14 | 15 | describe('account', () => { 16 | beforeEach(testSetup); 17 | describe('organizations', () => { 18 | describe('sub-organizations', () => { 19 | const testOrgId = '123'; 20 | const client = subOrganizations(testConfiguration, testOrgId, mockHttp); 21 | 22 | describe('list', () => { 23 | assertItCallsCorrectUrl( 24 | 'GET', 25 | urljoin('/v1/account/organizations', testOrgId, 'sub-organizations'), 26 | client.list 27 | ); 28 | assertItReturnsUnderlyingPromise(mockGet, client.list); 29 | }); 30 | }); 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /tests/account/organizations/tenants.test.ts: -------------------------------------------------------------------------------- 1 | import * as urljoin from 'url-join'; 2 | 3 | import {tenants} from '../../../bitmovin/account/organizations/tenants'; 4 | import { 5 | assertItCallsCorrectUrl, 6 | assertItReturnsUnderlyingPromise, 7 | mockDelete, 8 | mockGet, 9 | mockHttp, 10 | mockPost, 11 | testSetup 12 | } from '../../assertions'; 13 | import {getConfiguration} from '../../utils'; 14 | 15 | const testConfiguration = getConfiguration(); 16 | 17 | describe('account', () => { 18 | beforeEach(testSetup); 19 | describe('organizations', () => { 20 | describe('groups', () => { 21 | describe('tenants', () => { 22 | const testOrgId = '123'; 23 | const testGroupId = '123'; 24 | 25 | const client = tenants(testConfiguration, testOrgId, testGroupId, mockHttp); 26 | 27 | describe('list', () => { 28 | assertItCallsCorrectUrl( 29 | 'GET', 30 | urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'tenants'), 31 | client.list 32 | ); 33 | assertItReturnsUnderlyingPromise(mockGet, client.list); 34 | }); 35 | 36 | describe('add', () => { 37 | assertItCallsCorrectUrl( 38 | 'POST', 39 | urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'tenants'), 40 | client.add 41 | ); 42 | assertItReturnsUnderlyingPromise(mockPost, client.add); 43 | }); 44 | 45 | describe('tenant', () => { 46 | const testTenantId = '123'; 47 | 48 | describe('details', () => { 49 | assertItCallsCorrectUrl( 50 | 'GET', 51 | urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'tenants', testTenantId), 52 | client(testGroupId).details 53 | ); 54 | assertItReturnsUnderlyingPromise(mockGet, client(testOrgId).details); 55 | }); 56 | describe('delete', () => { 57 | assertItCallsCorrectUrl( 58 | 'DELETE', 59 | urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'tenants', testTenantId), 60 | client(testGroupId).delete 61 | ); 62 | assertItReturnsUnderlyingPromise(mockDelete, client(testOrgId).delete); 63 | }); 64 | }); 65 | }); 66 | }); 67 | }); 68 | }); 69 | -------------------------------------------------------------------------------- /tests/analytics/domains.test.ts: -------------------------------------------------------------------------------- 1 | import {domains} from '../../bitmovin/analytics/domains'; 2 | import {licenses} from '../../bitmovin/analytics/licenses'; 3 | import { 4 | assertItCallsCorrectUrl, 5 | assertItReturnsUnderlyingPromise, 6 | assertPayload, 7 | mockDelete, 8 | mockGet, 9 | mockHttp, 10 | mockPost, 11 | mockPut, 12 | testSetup 13 | } from '../assertions'; 14 | import {getConfiguration} from '../utils'; 15 | 16 | const testConfiguration = getConfiguration(); 17 | 18 | describe('analytics', () => { 19 | beforeEach(testSetup); 20 | const licensesClient = licenses(testConfiguration, mockHttp); 21 | 22 | describe('license', () => { 23 | describe('list', () => { 24 | assertItCallsCorrectUrl('GET', '/v1/analytics/licenses', licensesClient.list); 25 | assertItReturnsUnderlyingPromise(mockGet, licensesClient.list); 26 | }); 27 | describe('detail', () => { 28 | assertItCallsCorrectUrl('GET', '/v1/analytics/licenses/my-license-id', () => 29 | licensesClient('my-license-id').details() 30 | ); 31 | assertItReturnsUnderlyingPromise(mockGet, licensesClient('my-license-id').details); 32 | }); 33 | 34 | describe('update', () => { 35 | assertItCallsCorrectUrl('PUT', '/v1/analytics/licenses/my-license-id', () => 36 | licensesClient('my-license-id').update() 37 | ); 38 | assertItReturnsUnderlyingPromise(mockPut, licensesClient('my-license-id').update); 39 | assertPayload(mockPut, () => licensesClient('my-license-id').update({name: 'foo'}), {name: 'foo'}); 40 | }); 41 | 42 | describe('domains', () => { 43 | const domainClient = domains(testConfiguration, 'license-id', mockHttp); 44 | 45 | describe('list', () => { 46 | assertItCallsCorrectUrl('GET', '/v1/analytics/licenses/license-id/domains', domainClient.list); 47 | assertItReturnsUnderlyingPromise(mockGet, domainClient.list); 48 | }); 49 | describe('add', () => { 50 | assertItCallsCorrectUrl('POST', '/v1/analytics/licenses/license-id/domains', domainClient.add); 51 | 52 | assertItReturnsUnderlyingPromise(mockPost, () => 53 | domainClient.add({ 54 | url: 'foo' 55 | }) 56 | ); 57 | assertPayload(mockPost, () => domainClient.add({url: 'foo'}), {url: 'foo'}); 58 | }); 59 | describe('delete', () => { 60 | assertItCallsCorrectUrl( 61 | 'DELETE', 62 | '/v1/analytics/licenses/license-id/domains/domain-id', 63 | domainClient('domain-id').delete 64 | ); 65 | assertItReturnsUnderlyingPromise(mockDelete, domainClient('domain-id').delete); 66 | }); 67 | }); 68 | }); 69 | }); 70 | -------------------------------------------------------------------------------- /tests/analytics/filters.test.ts: -------------------------------------------------------------------------------- 1 | import {filters} from '../../bitmovin/analytics/filters'; 2 | import { 3 | assertItCallsCorrectUrl, 4 | assertItReturnsUnderlyingPromise, 5 | assertPayload, 6 | mockHttp, 7 | mockPost, 8 | testSetup 9 | } from '../assertions'; 10 | import {getConfiguration} from '../utils'; 11 | 12 | const testConfiguration = getConfiguration(); 13 | 14 | describe('analytics', () => { 15 | beforeEach(testSetup); 16 | const filtersClient = filters(testConfiguration, mockHttp); 17 | 18 | describe('filters customUserId', () => { 19 | const start = 1573137000000; 20 | const end = 1573396200000; 21 | assertItCallsCorrectUrl('POST', '/v1/analytics/filters/customUserId', () => 22 | filtersClient.customUserId({licenseKey: 'license-key', start, end}) 23 | ); 24 | assertItReturnsUnderlyingPromise(mockPost, () => 25 | filtersClient.customUserId({licenseKey: 'license-key', start, end}) 26 | ); 27 | assertPayload( 28 | mockPost, 29 | () => { 30 | return filtersClient.customUserId({licenseKey: 'license-key', start, end, query: 'foo'}); 31 | }, 32 | { 33 | licenseKey: 'license-key', 34 | start: 1573137000000, 35 | end: 1573396200000, 36 | query: 'foo' 37 | } 38 | ); 39 | }); 40 | 41 | describe('filters video', () => { 42 | const start = 1573137000000; 43 | const end = 1573396200000; 44 | assertItCallsCorrectUrl('POST', '/v1/analytics/filters/video', () => 45 | filtersClient.video({licenseKey: 'license-key', start, end}) 46 | ); 47 | assertItReturnsUnderlyingPromise(mockPost, () => filtersClient.video({licenseKey: 'license-key', start, end})); 48 | assertPayload( 49 | mockPost, 50 | () => { 51 | return filtersClient.video({licenseKey: 'license-key', start, end, query: 'foo'}); 52 | }, 53 | { 54 | licenseKey: 'license-key', 55 | start: 1573137000000, 56 | end: 1573396200000, 57 | query: 'foo' 58 | } 59 | ); 60 | }); 61 | }); 62 | -------------------------------------------------------------------------------- /tests/analytics/impressions.test.ts: -------------------------------------------------------------------------------- 1 | import {impressions} from '../../bitmovin/analytics/impressions'; 2 | import { 3 | assertItCallsCorrectUrl, 4 | assertItReturnsUnderlyingPromise, 5 | assertPayload, 6 | mockHttp, 7 | mockPost, 8 | testSetup 9 | } from '../assertions'; 10 | import {getConfiguration} from '../utils'; 11 | 12 | const testConfiguration = getConfiguration(); 13 | 14 | describe('analytics', () => { 15 | beforeEach(testSetup); 16 | const impressionsClient = impressions(testConfiguration, mockHttp); 17 | 18 | describe('impression details', () => { 19 | assertItCallsCorrectUrl('POST', '/v1/analytics/impressions/my-impression-id', () => 20 | impressionsClient.details('my-impression-id', 'license-key') 21 | ); 22 | assertItReturnsUnderlyingPromise(mockPost, () => impressionsClient.details('my-impression-id', 'license-key')); 23 | assertPayload(mockPost, () => impressionsClient.details('my-impression-id', 'license-key'), { 24 | licenseKey: 'license-key' 25 | }); 26 | 27 | describe('without license key', () => { 28 | assertItCallsCorrectUrl('POST', '/v1/analytics/impressions/my-impression-id', () => 29 | impressionsClient.details('my-impression-id', undefined) 30 | ); 31 | assertItReturnsUnderlyingPromise(mockPost, () => impressionsClient.details('my-impression-id', undefined)); 32 | assertPayload(mockPost, () => impressionsClient.details('my-impression-id', undefined), {licenseKey: undefined}); 33 | }); 34 | }); 35 | 36 | describe('impressions', () => { 37 | const start = 1573137000000; 38 | const end = 1573396200000; 39 | assertItCallsCorrectUrl('POST', '/v1/analytics/impressions', () => 40 | impressionsClient({licenseKey: 'license-key', start, end}) 41 | ); 42 | assertItReturnsUnderlyingPromise(mockPost, () => impressionsClient({licenseKey: 'license-key', start, end})); 43 | assertPayload( 44 | mockPost, 45 | () => { 46 | const filters = [{name: 'CUSTOM_USER_ID', operator: 'EQ', value: 'customer#1'}]; 47 | return impressionsClient({licenseKey: 'license-key', start, end, filters}); 48 | }, 49 | { 50 | licenseKey: 'license-key', 51 | start: 1573137000000, 52 | end: 1573396200000, 53 | filters: [{name: 'CUSTOM_USER_ID', operator: 'EQ', value: 'customer#1'}] 54 | } 55 | ); 56 | }); 57 | }); 58 | -------------------------------------------------------------------------------- /tests/analytics/insights/settings.test.ts: -------------------------------------------------------------------------------- 1 | import OrganizationSettings from '../../../bitmovin/analytics/insights/OrganizationSettings'; 2 | import { 3 | assertItCallsCorrectUrl, 4 | assertItReturnsUnderlyingPromise, 5 | assertPayload, 6 | mockGet, 7 | mockHttp, 8 | mockPut, 9 | testSetup 10 | } from '../../assertions'; 11 | import {getConfiguration} from '../../utils'; 12 | 13 | const testConfiguration = getConfiguration(); 14 | const ORG_ID = 'my-org-id'; 15 | const INSIGHTS_PATH = 'analytics/insights'; 16 | 17 | describe('analytics', () => { 18 | const settingsClient = new OrganizationSettings(testConfiguration, INSIGHTS_PATH, mockHttp); 19 | beforeEach(testSetup); 20 | 21 | describe('organizations', () => { 22 | describe('settings', () => { 23 | describe('details', () => { 24 | assertItCallsCorrectUrl('GET', `/v1/analytics/insights/organizations/${ORG_ID}/settings`, () => 25 | settingsClient.settings(ORG_ID).details() 26 | ); 27 | assertItReturnsUnderlyingPromise(mockGet, settingsClient.settings(ORG_ID).details); 28 | }); 29 | describe('update', () => { 30 | assertItCallsCorrectUrl('PUT', `/v1/analytics/insights/organizations/${ORG_ID}/settings`, () => 31 | settingsClient.settings(ORG_ID).update({ 32 | includeInInsights: true 33 | }) 34 | ); 35 | assertItReturnsUnderlyingPromise(mockPut, settingsClient.settings(ORG_ID).update); 36 | assertPayload( 37 | mockPut, 38 | () => 39 | settingsClient.settings(ORG_ID).update({ 40 | includeInInsights: true 41 | }), 42 | { 43 | includeInInsights: true 44 | } 45 | ); 46 | }); 47 | }); 48 | }); 49 | }); 50 | -------------------------------------------------------------------------------- /tests/analytics/statistics.test.ts: -------------------------------------------------------------------------------- 1 | import {statistics} from '../../bitmovin/analytics/statistics'; 2 | import {assertItCallsCorrectUrl, assertItReturnsUnderlyingPromise, mockGet, mockHttp, testSetup} from '../assertions'; 3 | import {getConfiguration} from '../utils'; 4 | 5 | const testConfiguration = getConfiguration(); 6 | 7 | describe('analytics', () => { 8 | const statisticsClient = statistics(testConfiguration, mockHttp); 9 | beforeEach(testSetup); 10 | 11 | describe('statistics', () => { 12 | describe('impressions', () => { 13 | describe('impressions default interval', () => { 14 | assertItCallsCorrectUrl( 15 | 'GET', 16 | '/v1/analytics/statistics/impressions', 17 | statisticsClient.impressions.bind(this, 'asdf', '2017-01-01', '2017-01-02') 18 | ); 19 | assertItReturnsUnderlyingPromise( 20 | mockGet, 21 | statisticsClient.impressions.bind(this, 'asdf', '2017-01-01', '2017-01-02') 22 | ); 23 | }); 24 | describe('impressions daily interval', () => { 25 | assertItCallsCorrectUrl( 26 | 'GET', 27 | '/v1/analytics/statistics/impressions', 28 | statisticsClient.impressions.bind(this, 'asdf', '2017-01-01', '2017-01-02', statisticsClient.INTERVAL.DAILY) 29 | ); 30 | assertItReturnsUnderlyingPromise( 31 | mockGet, 32 | statisticsClient.impressions.bind(this, 'asdf', '2017-01-01', '2017-01-02', statisticsClient.INTERVAL.DAILY) 33 | ); 34 | }); 35 | }); 36 | }); 37 | }); 38 | -------------------------------------------------------------------------------- /tests/assertions.ts: -------------------------------------------------------------------------------- 1 | import {Promise} from 'es6-promise'; 2 | 3 | export const mockGet = jest.fn().mockReturnValue(Promise.resolve({})); 4 | export const mockPost = jest.fn().mockReturnValue(Promise.resolve({})); 5 | export const mockDelete = jest.fn().mockReturnValue(Promise.resolve({})); 6 | export const mockPut = jest.fn().mockReturnValue(Promise.resolve({})); 7 | export const mockHttp = {get: mockGet, post: mockPost, delete_: mockDelete, put: mockPut}; 8 | 9 | export const methodToMock = method => { 10 | if (method.toLowerCase() === 'get') { 11 | return mockGet; 12 | } 13 | if (method.toLowerCase() === 'delete') { 14 | return mockDelete; 15 | } 16 | if (method.toLowerCase() === 'put') { 17 | return mockPut; 18 | } 19 | return mockPost; 20 | }; 21 | 22 | export const testSetup = () => { 23 | mockGet.mockClear(); 24 | mockPost.mockClear(); 25 | mockPut.mockClear(); 26 | mockDelete.mockClear(); 27 | }; 28 | 29 | export const assertPayload = (mock, call, expectedPayload) => { 30 | it('should send appropriate payload', () => { 31 | return call().then(() => { 32 | expect(mock.mock.calls[0][2]).toEqual(expectedPayload); 33 | }); 34 | }); 35 | }; 36 | 37 | export const assertItReturnsPromise = (mock, call) => { 38 | it('should return promise', () => { 39 | expect(typeof call).toEqual('function'); 40 | mock.mockReturnValue(Promise.resolve('success')); 41 | const retVal = call(); 42 | expect(typeof retVal.then).toEqual('function'); 43 | return retVal; 44 | }); 45 | }; 46 | export const assertItReturnsCorrectResponse = (mock, call, expectedResponse) => { 47 | it('should return correct response object', () => { 48 | const retVal = call(); 49 | return retVal.then(response => { 50 | expect(response).toEqual(expectedResponse); 51 | }); 52 | }); 53 | }; 54 | 55 | export const assertItReturnsUnderlyingPromise = (mock, call) => { 56 | mock.mockReturnValue(Promise.resolve('success')); 57 | assertItReturnsCorrectResponse(mock, call, 'success'); 58 | assertItReturnsPromise(mock, call); 59 | }; 60 | 61 | export const assertItCallsCorrectUrl = (method, expectedUrl, fn) => { 62 | it(`should call ${method} with URL ${expectedUrl} once`, () => { 63 | return fn().then(() => { 64 | expect(methodToMock(method)).toBeCalled(); 65 | }); 66 | }); 67 | 68 | it(`should call ${method} with ${expectedUrl}`, () => { 69 | return fn().then(() => { 70 | expect(methodToMock(method).mock.calls[0][1]).toEqual(expect.stringMatching(expectedUrl)); 71 | }); 72 | }); 73 | }; 74 | 75 | export const assertItCallsUrlAndReturnsPromise = (method, url, fn) => { 76 | assertItCallsCorrectUrl(method, url, fn); 77 | assertItReturnsUnderlyingPromise(methodToMock(method), fn); 78 | }; 79 | -------------------------------------------------------------------------------- /tests/bitmovin.test.ts: -------------------------------------------------------------------------------- 1 | import Bitmovin from '../bitmovin'; 2 | 3 | describe('Bitmovin default exports', () => { 4 | const apiKey = 'test-api-key'; 5 | const additionalHeaders = {'X-Test-Header': 'test'}; 6 | 7 | const client = Bitmovin({ 8 | apiKey, 9 | additionalHeaders 10 | }); 11 | 12 | describe('encoding', () => { 13 | const assertItContains = key => { 14 | it('should contain ' + key, () => { 15 | expect(typeof client.encoding[key]).toBeDefined(); 16 | }); 17 | }; 18 | assertItContains('encodings'); 19 | assertItContains('codecConfigurations'); 20 | assertItContains('inputs'); 21 | assertItContains('outputs'); 22 | assertItContains('manifests'); 23 | assertItContains('filters'); 24 | assertItContains('statistics'); 25 | assertItContains('infrastructure'); 26 | }); 27 | describe('analytics', () => { 28 | const assertItContains = (obj, key) => { 29 | it('should contain ' + key, () => { 30 | expect(typeof obj[key]).toEqual('function'); 31 | }); 32 | }; 33 | const generalApi = client.analytics; 34 | assertItContains(generalApi, 'impressions'); 35 | assertItContains(generalApi, 'licenses'); 36 | assertItContains(generalApi, 'queries'); 37 | 38 | const adsApi = client.analytics.ads; 39 | expect(adsApi).not.toBeNull(); 40 | assertItContains(adsApi, 'queries'); 41 | }); 42 | describe('player', () => { 43 | const assertItContains = key => { 44 | it('should contain ' + key, () => { 45 | expect(typeof client.player[key]).toEqual('function'); 46 | }); 47 | }; 48 | assertItContains('licenses'); 49 | assertItContains('channels'); 50 | expect(typeof client.player.customBuilds).toBeDefined(); 51 | }); 52 | }); 53 | -------------------------------------------------------------------------------- /tests/encoding/burnInSubtitles.test.ts: -------------------------------------------------------------------------------- 1 | import {burnInSubtitles} from '../../bitmovin/encoding/encodings/streams/burnInSubtitles'; 2 | import { 3 | assertItCallsCorrectUrl, 4 | assertItReturnsUnderlyingPromise, 5 | mockDelete, 6 | mockGet, 7 | mockHttp, 8 | mockPost, 9 | testSetup 10 | } from '../assertions'; 11 | import {getConfiguration} from '../utils'; 12 | 13 | const testConfiguration = getConfiguration(); 14 | 15 | describe('encoding', () => { 16 | describe('streams', () => { 17 | beforeEach(testSetup); 18 | const burnInSubtitle = burnInSubtitles(testConfiguration, 'encoding-id', 'stream-id', mockHttp); 19 | describe('stream', () => { 20 | describe('burnInSubtitles', () => { 21 | const testBurnInSubtitleType = type => { 22 | describe(type, () => { 23 | const client = burnInSubtitle[type]; 24 | type = type.toLowerCase(); 25 | describe('list', () => { 26 | assertItCallsCorrectUrl( 27 | 'GET', 28 | `/v1/encoding/encodings/encoding-id/streams/stream-id/burn-in-subtitles/${type}`, 29 | client.list 30 | ); 31 | assertItReturnsUnderlyingPromise(mockGet, client.list); 32 | }); 33 | describe('add', () => { 34 | assertItCallsCorrectUrl( 35 | 'POST', 36 | `/v1/encoding/encodings/encoding-id/streams/stream-id/burn-in-subtitles/${type}`, 37 | client.add 38 | ); 39 | assertItReturnsUnderlyingPromise(mockPost, client.add); 40 | }); 41 | describe('burnInSubtitle', () => { 42 | describe('details', () => { 43 | assertItCallsCorrectUrl( 44 | 'GET', 45 | `/v1/encoding/encodings/encoding-id/streams/stream-id/burn-in-subtitles/${type}/burn-in-subtitle-id`, 46 | client('burn-in-subtitle-id').details 47 | ); 48 | assertItReturnsUnderlyingPromise(mockGet, client('burn-in-subtitle-id').details); 49 | }); 50 | describe('delete', () => { 51 | assertItCallsCorrectUrl( 52 | 'DELETE', 53 | `/v1/encoding/encodings/encoding-id/streams/stream-id/burn-in-subtitles/${type}/burn-in-subtitle-id`, 54 | client('burn-in-subtitle-id').delete 55 | ); 56 | assertItReturnsUnderlyingPromise(mockDelete, client('burn-in-subtitle-id').delete); 57 | }); 58 | }); 59 | }); 60 | }; 61 | testBurnInSubtitleType('srt'); 62 | }); 63 | }); 64 | }); 65 | }); 66 | -------------------------------------------------------------------------------- /tests/encoding/dashManifestAdaptationSets.test.ts: -------------------------------------------------------------------------------- 1 | import {adaptationSets} from '../../bitmovin/encoding/manifests/dash/dashManifestAdaptationSets'; 2 | import {assertItCallsUrlAndReturnsPromise, mockHttp, testSetup} from '../assertions'; 3 | import {getConfiguration} from '../utils'; 4 | 5 | const testConfiguration = getConfiguration(); 6 | 7 | describe('encoding', () => { 8 | describe('manifests.dash', () => { 9 | describe('periods', () => { 10 | describe('adaptationSets', () => { 11 | beforeEach(testSetup); 12 | const client = adaptationSets(testConfiguration, 'manifest-id', 'period-id', mockHttp); 13 | 14 | describe('detail subpath', () => { 15 | it('should return object containing representations', () => { 16 | expect(client('foo').representations).toBeDefined(); 17 | }); 18 | it('should return object containing contentProtections', () => { 19 | expect(client('foo').contentProtections).toBeDefined(); 20 | }); 21 | }); 22 | 23 | const testType = (type, url = type) => { 24 | describe(type, () => { 25 | const typeClient = client[type]; 26 | describe('create', () => { 27 | assertItCallsUrlAndReturnsPromise( 28 | 'POST', 29 | `/v1/encoding/manifests/dash/manifest-id/periods/period-id/adaptationsets/${url}`, 30 | typeClient.create 31 | ); 32 | }); 33 | describe('list', () => { 34 | assertItCallsUrlAndReturnsPromise( 35 | 'GET', 36 | `/v1/encoding/manifests/dash/manifest-id/periods/period-id/adaptationsets/${url}`, 37 | typeClient.list 38 | ); 39 | }); 40 | 41 | describe('adaptation-set', () => { 42 | const setClient = typeClient('adaptationset-id'); 43 | describe('details', () => { 44 | assertItCallsUrlAndReturnsPromise( 45 | 'GET', 46 | `/v1/encoding/manifests/dash/manifest-id/periods/period-id/adaptationsets/${url}/adaptationset-id`, 47 | setClient.details 48 | ); 49 | }); 50 | describe('delete', () => { 51 | assertItCallsUrlAndReturnsPromise( 52 | 'DELETE', 53 | `/v1/encoding/manifests/dash/manifest-id/periods/period-id/adaptationsets/${url}/adaptationset-id`, 54 | setClient.delete 55 | ); 56 | }); 57 | }); 58 | }); 59 | }; 60 | testType('audio'); 61 | }); 62 | }); 63 | }); 64 | }); 65 | -------------------------------------------------------------------------------- /tests/encoding/dashManifestContentProtections.test.ts: -------------------------------------------------------------------------------- 1 | import {contentProtections} from '../../bitmovin/encoding/manifests/dash/dashManifestContentProtections'; 2 | import {assertItCallsUrlAndReturnsPromise, mockHttp, testSetup} from '../assertions'; 3 | import {getConfiguration} from '../utils'; 4 | 5 | const testConfiguration = getConfiguration(); 6 | 7 | describe('encoding', () => { 8 | describe('manifests.dash', () => { 9 | describe('periods', () => { 10 | describe('adaptationSets', () => { 11 | describe('representations', () => { 12 | const testType = (type, url = type) => { 13 | describe(type, () => { 14 | beforeEach(testSetup); 15 | const info = { 16 | type: url, 17 | id: 'representation-id' 18 | }; 19 | const client = contentProtections( 20 | testConfiguration, 21 | 'manifest-id', 22 | 'period-id', 23 | 'adaptationset-id', 24 | info, 25 | mockHttp 26 | ); 27 | 28 | describe('list', () => { 29 | assertItCallsUrlAndReturnsPromise( 30 | 'GET', 31 | `/v1/encoding/manifests/dash/manifest-id/periods/period-id/adaptationsets/adaptationset-id/representations/${url}/representation-id/contentprotection`, 32 | client.list 33 | ); 34 | }); 35 | describe('add', () => { 36 | assertItCallsUrlAndReturnsPromise( 37 | 'POST', 38 | `/v1/encoding/manifests/dash/manifest-id/periods/period-id/adaptationsets/adaptationset-id/representations/${url}/representation-id/contentprotection`, 39 | client.add 40 | ); 41 | }); 42 | describe('representation', () => { 43 | const protectionClient = client('protection-id'); 44 | describe('details', () => { 45 | assertItCallsUrlAndReturnsPromise( 46 | 'GET', 47 | `/v1/encoding/manifests/dash/manifest-id/periods/period-id/adaptationsets/adaptationset-id/representations/${url}/representation-id/contentprotection/protection-id`, 48 | protectionClient.details 49 | ); 50 | }); 51 | describe('delete', () => { 52 | assertItCallsUrlAndReturnsPromise( 53 | 'DELETE', 54 | `/v1/encoding/manifests/dash/manifest-id/periods/period-id/adaptationsets/adaptationset-id/representations/${url}/representation-id/contentprotection/protection-id`, 55 | protectionClient.delete 56 | ); 57 | }); 58 | }); 59 | }); 60 | }; 61 | testType('fmp4'); 62 | }); 63 | }); 64 | }); 65 | }); 66 | }); 67 | -------------------------------------------------------------------------------- /tests/encoding/dashManifestCustomXmlEvents.test.ts: -------------------------------------------------------------------------------- 1 | import {customXmlElements} from '../../bitmovin/encoding/manifests/dash/dashManifestCustomXmlElements'; 2 | import {assertItCallsUrlAndReturnsPromise, mockHttp, testSetup} from '../assertions'; 3 | import {getConfiguration} from '../utils'; 4 | 5 | const testConfiguration = getConfiguration(); 6 | 7 | describe('encoding', () => { 8 | describe('manifests.dash', () => { 9 | describe('periods', () => { 10 | beforeEach(testSetup); 11 | const client = customXmlElements(testConfiguration, 'manifest-id', 'period-id', mockHttp); 12 | 13 | describe('list', () => { 14 | assertItCallsUrlAndReturnsPromise( 15 | 'GET', 16 | '/v1/encoding/manifests/dash/manifest-id/periods/period-id/custom-xml-elements', 17 | client.list 18 | ); 19 | }); 20 | describe('add', () => { 21 | assertItCallsUrlAndReturnsPromise( 22 | 'POST', 23 | '/v1/encoding/manifests/dash/manifest-id/periods/period-id/custom-xml-elements', 24 | client.add 25 | ); 26 | }); 27 | describe('customXmlElement', () => { 28 | const customXmlElement = client('custom-xml-element-id'); 29 | describe('details', () => { 30 | assertItCallsUrlAndReturnsPromise( 31 | 'GET', 32 | '/v1/encoding/manifests/dash/manifest-id/periods/period-id/custom-xml-elements/custom-xml-element-id', 33 | customXmlElement.details 34 | ); 35 | }); 36 | describe('delete', () => { 37 | assertItCallsUrlAndReturnsPromise( 38 | 'DELETE', 39 | '/v1/encoding/manifests/dash/manifest-id/periods/period-id/custom-xml-elements/custom-xml-element-id', 40 | customXmlElement.delete 41 | ); 42 | }); 43 | }); 44 | }); 45 | }); 46 | }); 47 | -------------------------------------------------------------------------------- /tests/encoding/dashManifestPeriods.test.ts: -------------------------------------------------------------------------------- 1 | import {dashManifestPeriods} from '../../bitmovin/encoding/manifests/dash/dashManifestPeriods'; 2 | import {assertItCallsUrlAndReturnsPromise, mockHttp, testSetup} from '../assertions'; 3 | import {getConfiguration} from '../utils'; 4 | 5 | const testConfiguration = getConfiguration(); 6 | 7 | describe('encoding', () => { 8 | describe('manifests.dash', () => { 9 | describe('periods', () => { 10 | beforeEach(testSetup); 11 | const client = dashManifestPeriods(testConfiguration, 'manifest-id', mockHttp); 12 | 13 | describe('list', () => { 14 | assertItCallsUrlAndReturnsPromise('GET', '/v1/encoding/manifests/dash/manifest-id/periods', client.list); 15 | }); 16 | describe('add', () => { 17 | assertItCallsUrlAndReturnsPromise('POST', '/v1/encoding/manifests/dash/manifest-id/periods', client.add); 18 | }); 19 | describe('period', () => { 20 | const period = client('period-id'); 21 | describe('details', () => { 22 | assertItCallsUrlAndReturnsPromise( 23 | 'GET', 24 | '/v1/encoding/manifests/dash/manifest-id/periods/period-id', 25 | period.details 26 | ); 27 | }); 28 | describe('delete', () => { 29 | assertItCallsUrlAndReturnsPromise( 30 | 'DELETE', 31 | '/v1/encoding/manifests/dash/manifest-id/periods/period-id', 32 | period.delete 33 | ); 34 | }); 35 | }); 36 | }); 37 | }); 38 | }); 39 | -------------------------------------------------------------------------------- /tests/encoding/dashManifestRepresentations.test.ts: -------------------------------------------------------------------------------- 1 | import {representations} from '../../bitmovin/encoding/manifests/dash/dashManifestRepresentations'; 2 | import {assertItCallsUrlAndReturnsPromise, mockHttp, testSetup} from '../assertions'; 3 | import {getConfiguration} from '../utils'; 4 | 5 | const testConfiguration = getConfiguration(); 6 | 7 | describe('encoding', () => { 8 | describe('manifests.dash', () => { 9 | describe('periods', () => { 10 | describe('adaptationSets', () => { 11 | describe('representations', () => { 12 | beforeEach(testSetup); 13 | const testType = (type, url = type) => { 14 | const client = representations(testConfiguration, 'manifest-id', 'period-id', 'adaptationset-id', mockHttp)[ 15 | type 16 | ]; 17 | 18 | describe(type, () => { 19 | describe('list', () => { 20 | assertItCallsUrlAndReturnsPromise( 21 | 'GET', 22 | `/v1/encoding/manifests/dash/manifest-id/periods/period-id/adaptationsets/adaptationset-id/representations/${url}`, 23 | client.list 24 | ); 25 | }); 26 | describe('add', () => { 27 | assertItCallsUrlAndReturnsPromise( 28 | 'POST', 29 | `/v1/encoding/manifests/dash/manifest-id/periods/period-id/adaptationsets/adaptationset-id/representations/${url}`, 30 | client.add 31 | ); 32 | }); 33 | describe('representation', () => { 34 | const repClient = client('representation-id'); 35 | describe('details', () => { 36 | assertItCallsUrlAndReturnsPromise( 37 | 'GET', 38 | `/v1/encoding/manifests/dash/manifest-id/periods/period-id/adaptationsets/adaptationset-id/representations/${url}/representation-id`, 39 | repClient.details 40 | ); 41 | }); 42 | describe('delete', () => { 43 | assertItCallsUrlAndReturnsPromise( 44 | 'DELETE', 45 | `/v1/encoding/manifests/dash/manifest-id/periods/period-id/adaptationsets/adaptationset-id/representations/${url}/representation-id`, 46 | repClient.delete 47 | ); 48 | }); 49 | describe('has contentprotections', () => { 50 | expect(repClient.contentProtections).toBeDefined(); 51 | }); 52 | }); 53 | }); 54 | }; 55 | 56 | testType('fmp4'); 57 | testType('drmFmp4', 'fmp4/drm'); 58 | testType('sidecar'); 59 | testType('mp4'); 60 | testType('drmMp4', 'mp4/drm'); 61 | testType('webm'); 62 | }); 63 | }); 64 | }); 65 | }); 66 | }); 67 | -------------------------------------------------------------------------------- /tests/encoding/dashManifests.test.ts: -------------------------------------------------------------------------------- 1 | import {dashManifests} from '../../bitmovin/encoding/manifests/dash'; 2 | import {assertItCallsUrlAndReturnsPromise, mockHttp, testSetup} from '../assertions'; 3 | import {getConfiguration} from '../utils'; 4 | 5 | const testConfiguration = getConfiguration(); 6 | 7 | describe('encoding', () => { 8 | describe('manifests.dash', () => { 9 | beforeEach(testSetup); 10 | const client = dashManifests(testConfiguration, mockHttp); 11 | 12 | describe('list', () => { 13 | assertItCallsUrlAndReturnsPromise('GET', '/v1/encoding/manifests/dash', client.list); 14 | }); 15 | describe('create', () => { 16 | assertItCallsUrlAndReturnsPromise('POST', '/v1/encoding/manifests/dash', client.create); 17 | }); 18 | describe('manifest', () => { 19 | const manifest = client('manifest-id'); 20 | describe('details', () => { 21 | assertItCallsUrlAndReturnsPromise('GET', '/v1/encoding/manifests/dash/manifest-id', manifest.details); 22 | }); 23 | describe('delete', () => { 24 | assertItCallsUrlAndReturnsPromise('DELETE', '/v1/encoding/manifests/dash/manifest-id', manifest.delete); 25 | }); 26 | describe('start', () => { 27 | assertItCallsUrlAndReturnsPromise('POST', '/v1/encoding/manifests/dash/manifest-id/start', manifest.start); 28 | }); 29 | describe('stop', () => { 30 | assertItCallsUrlAndReturnsPromise('POST', '/v1/encoding/manifests/dash/manifest-id/stop', manifest.stop); 31 | }); 32 | describe('status', () => { 33 | assertItCallsUrlAndReturnsPromise('GET', '/v1/encoding/manifests/dash/manifest-id/status', manifest.status); 34 | }); 35 | }); 36 | }); 37 | }); 38 | -------------------------------------------------------------------------------- /tests/encoding/hlsManifestMedia.test.ts: -------------------------------------------------------------------------------- 1 | import {hlsManifestMedia} from '../../bitmovin/encoding/manifests/hls/hlsManifestMedia'; 2 | import {assertItCallsUrlAndReturnsPromise, mockHttp, testSetup} from '../assertions'; 3 | import {getConfiguration} from '../utils'; 4 | 5 | const testConfiguration = getConfiguration(); 6 | 7 | describe('encoding', () => { 8 | describe('manifests.hls', () => { 9 | describe('media', () => { 10 | beforeEach(testSetup); 11 | const testType = (type, url = type) => { 12 | describe(type, () => { 13 | const client = hlsManifestMedia(testConfiguration, 'manifest-id', mockHttp)[type]; 14 | describe('list', () => { 15 | assertItCallsUrlAndReturnsPromise( 16 | 'GET', 17 | `/v1/encoding/manifests/hls/manifest-id/media/${url}`, 18 | client.list 19 | ); 20 | }); 21 | describe('add', () => { 22 | assertItCallsUrlAndReturnsPromise( 23 | 'POST', 24 | `/v1/encoding/manifests/hls/manifest-id/media/${url}`, 25 | client.add 26 | ); 27 | }); 28 | describe('item', () => { 29 | describe('details', () => { 30 | assertItCallsUrlAndReturnsPromise( 31 | 'GET', 32 | `/v1/encoding/manifests/hls/manifest-id/media/${url}/media-id`, 33 | client('media-id').details 34 | ); 35 | }); 36 | describe('delete', () => { 37 | assertItCallsUrlAndReturnsPromise( 38 | 'DELETE', 39 | `/v1/encoding/manifests/hls/manifest-id/media/${url}/media-id`, 40 | client('media-id').delete 41 | ); 42 | }); 43 | }); 44 | }); 45 | }; 46 | testType('video'); 47 | testType('audio'); 48 | testType('subtitles'); 49 | testType('closedCaptions', 'closed-captions'); 50 | }); 51 | }); 52 | }); 53 | -------------------------------------------------------------------------------- /tests/encoding/hlsManifestStreams.test.ts: -------------------------------------------------------------------------------- 1 | import {hlsManifestStreams} from '../../bitmovin/encoding/manifests/hls/hlsManifestStreams'; 2 | import {assertItCallsUrlAndReturnsPromise, mockHttp, testSetup} from '../assertions'; 3 | import {getConfiguration} from '../utils'; 4 | 5 | const testConfiguration = getConfiguration(); 6 | 7 | describe('encoding', () => { 8 | describe('manifests.hls', () => { 9 | describe('streams', () => { 10 | beforeEach(testSetup); 11 | const client = hlsManifestStreams(testConfiguration, 'manifest-id', mockHttp); 12 | 13 | describe('list', () => { 14 | assertItCallsUrlAndReturnsPromise('GET', '/v1/encoding/manifests/hls/manifest-id/streams', client.list); 15 | }); 16 | describe('add', () => { 17 | assertItCallsUrlAndReturnsPromise('POST', '/v1/encoding/manifests/hls/manifest-id/streams', client.add); 18 | }); 19 | describe('stream', () => { 20 | const stream = client('stream-id'); 21 | describe('details', () => { 22 | assertItCallsUrlAndReturnsPromise( 23 | 'GET', 24 | '/v1/encoding/manifests/hls/manifest-id/streams/stream-id', 25 | stream.details 26 | ); 27 | }); 28 | describe('delete', () => { 29 | assertItCallsUrlAndReturnsPromise( 30 | 'DELETE', 31 | '/v1/encoding/manifests/hls/manifest-id/streams/stream-id', 32 | stream.delete 33 | ); 34 | }); 35 | }); 36 | }); 37 | }); 38 | }); 39 | -------------------------------------------------------------------------------- /tests/encoding/hlsManifests.test.ts: -------------------------------------------------------------------------------- 1 | import {hlsManifests} from '../../bitmovin/encoding/manifests/hls'; 2 | import {assertItCallsUrlAndReturnsPromise, mockHttp, testSetup} from '../assertions'; 3 | import {getConfiguration} from '../utils'; 4 | 5 | const testConfiguration = getConfiguration(); 6 | 7 | describe('encoding', () => { 8 | describe('manifests.hls', () => { 9 | beforeEach(testSetup); 10 | const client = hlsManifests(testConfiguration, mockHttp); 11 | 12 | describe('list', () => { 13 | assertItCallsUrlAndReturnsPromise('GET', '/v1/encoding/manifests/hls', client.list); 14 | }); 15 | describe('create', () => { 16 | assertItCallsUrlAndReturnsPromise('POST', '/v1/encoding/manifests/hls', client.create); 17 | }); 18 | describe('manifest', () => { 19 | const manifest = client('manifest-id'); 20 | describe('details', () => { 21 | assertItCallsUrlAndReturnsPromise('GET', '/v1/encoding/manifests/hls/manifest-id', manifest.details); 22 | }); 23 | describe('delete', () => { 24 | assertItCallsUrlAndReturnsPromise('DELETE', '/v1/encoding/manifests/hls/manifest-id', manifest.delete); 25 | }); 26 | describe('start', () => { 27 | assertItCallsUrlAndReturnsPromise('POST', '/v1/encoding/manifests/hls/manifest-id/start', manifest.start); 28 | }); 29 | describe('stop', () => { 30 | assertItCallsUrlAndReturnsPromise('POST', '/v1/encoding/manifests/hls/manifest-id/stop', manifest.stop); 31 | }); 32 | describe('status', () => { 33 | assertItCallsUrlAndReturnsPromise('GET', '/v1/encoding/manifests/hls/manifest-id/status', manifest.status); 34 | }); 35 | }); 36 | }); 37 | }); 38 | -------------------------------------------------------------------------------- /tests/encoding/smoothManifestContentProtections.test.ts: -------------------------------------------------------------------------------- 1 | import {contentProtection} from '../../bitmovin/encoding/manifests/smooth/smoothManifestContentProtections'; 2 | import {assertItCallsUrlAndReturnsPromise, mockHttp, testSetup} from '../assertions'; 3 | import {getConfiguration} from '../utils'; 4 | 5 | const testConfiguration = getConfiguration(); 6 | 7 | describe('encoding', () => { 8 | describe('manifests.smooth', () => { 9 | describe('contentprotection', () => { 10 | beforeEach(testSetup); 11 | const client = contentProtection(testConfiguration, 'manifest-id', mockHttp); 12 | 13 | describe('list', () => { 14 | assertItCallsUrlAndReturnsPromise( 15 | 'GET', 16 | '/v1/encoding/manifests/smooth/manifest-id/contentprotection', 17 | client.list 18 | ); 19 | }); 20 | describe('add', () => { 21 | assertItCallsUrlAndReturnsPromise( 22 | 'POST', 23 | '/v1/encoding/manifests/smooth/manifest-id/contentprotection', 24 | client.add 25 | ); 26 | }); 27 | describe('protection', () => { 28 | describe('details', () => { 29 | assertItCallsUrlAndReturnsPromise( 30 | 'GET', 31 | '/v1/encoding/manifests/smooth/manifest-id/contentprotection/protection-id', 32 | client('protection-id').details 33 | ); 34 | }); 35 | describe('delete', () => { 36 | assertItCallsUrlAndReturnsPromise( 37 | 'DELETE', 38 | '/v1/encoding/manifests/smooth/manifest-id/contentprotection/protection-id', 39 | client('protection-id').delete 40 | ); 41 | }); 42 | }); 43 | }); 44 | }); 45 | }); 46 | -------------------------------------------------------------------------------- /tests/encoding/smoothManifestRepresentations.test.ts: -------------------------------------------------------------------------------- 1 | import {representations} from '../../bitmovin/encoding/manifests/smooth/smoothManifestRepresentations'; 2 | import {assertItCallsUrlAndReturnsPromise, mockHttp, testSetup} from '../assertions'; 3 | import {getConfiguration} from '../utils'; 4 | 5 | const testConfiguration = getConfiguration(); 6 | 7 | describe('encoding', () => { 8 | describe('manifests.smooth', () => { 9 | describe('representations', () => { 10 | beforeEach(testSetup); 11 | const testType = (type, url = type) => { 12 | const client = representations(testConfiguration, 'manifest-id', mockHttp)[type]; 13 | 14 | describe(type, () => { 15 | describe('list', () => { 16 | assertItCallsUrlAndReturnsPromise( 17 | 'GET', 18 | `/v1/encoding/manifests/smooth/manifest-id/representations/${url}`, 19 | client.list 20 | ); 21 | }); 22 | describe('add', () => { 23 | assertItCallsUrlAndReturnsPromise( 24 | 'POST', 25 | `/v1/encoding/manifests/smooth/manifest-id/representations/${url}`, 26 | client.add 27 | ); 28 | }); 29 | describe('representation', () => { 30 | const repClient = client('representation-id'); 31 | describe('details', () => { 32 | assertItCallsUrlAndReturnsPromise( 33 | 'GET', 34 | `/v1/encoding/manifests/smooth/manifest-id/representations/${url}/representation-id`, 35 | repClient.details 36 | ); 37 | }); 38 | describe('delete', () => { 39 | assertItCallsUrlAndReturnsPromise( 40 | 'DELETE', 41 | `/v1/encoding/manifests/smooth/manifest-id/representations/${url}/representation-id`, 42 | repClient.delete 43 | ); 44 | }); 45 | }); 46 | }); 47 | }; 48 | 49 | testType('mp4'); 50 | }); 51 | }); 52 | }); 53 | -------------------------------------------------------------------------------- /tests/encoding/smoothManifests.test.ts: -------------------------------------------------------------------------------- 1 | import {smoothManifests} from '../../bitmovin/encoding/manifests/smooth'; 2 | import {assertItCallsUrlAndReturnsPromise, mockHttp, testSetup} from '../assertions'; 3 | import {getConfiguration} from '../utils'; 4 | 5 | const testConfiguration = getConfiguration(); 6 | 7 | describe('encoding', () => { 8 | describe('manifests.smooth', () => { 9 | beforeEach(testSetup); 10 | const client = smoothManifests(testConfiguration, mockHttp); 11 | 12 | describe('list', () => { 13 | assertItCallsUrlAndReturnsPromise('GET', '/v1/encoding/manifests/smooth', client.list); 14 | }); 15 | describe('create', () => { 16 | assertItCallsUrlAndReturnsPromise('POST', '/v1/encoding/manifests/smooth', client.create); 17 | }); 18 | describe('manifest', () => { 19 | const manifest = client('manifest-id'); 20 | describe('details', () => { 21 | assertItCallsUrlAndReturnsPromise('GET', '/v1/encoding/manifests/smooth/manifest-id', manifest.details); 22 | }); 23 | describe('delete', () => { 24 | assertItCallsUrlAndReturnsPromise('DELETE', '/v1/encoding/manifests/smooth/manifest-id', manifest.delete); 25 | }); 26 | describe('start', () => { 27 | assertItCallsUrlAndReturnsPromise('POST', '/v1/encoding/manifests/smooth/manifest-id/start', manifest.start); 28 | }); 29 | describe('stop', () => { 30 | assertItCallsUrlAndReturnsPromise('POST', '/v1/encoding/manifests/smooth/manifest-id/stop', manifest.stop); 31 | }); 32 | describe('status', () => { 33 | assertItCallsUrlAndReturnsPromise('GET', '/v1/encoding/manifests/smooth/manifest-id/status', manifest.status); 34 | }); 35 | }); 36 | }); 37 | }); 38 | -------------------------------------------------------------------------------- /tests/encoding/sprites.test.ts: -------------------------------------------------------------------------------- 1 | import {sprites} from '../../bitmovin/encoding/encodings/streams/sprites'; 2 | import { 3 | assertItCallsCorrectUrl, 4 | assertItReturnsUnderlyingPromise, 5 | mockDelete, 6 | mockGet, 7 | mockHttp, 8 | mockPost, 9 | testSetup 10 | } from '../assertions'; 11 | import {getConfiguration} from '../utils'; 12 | 13 | const testConfiguration = getConfiguration(); 14 | 15 | describe('encoding', () => { 16 | describe('streams', () => { 17 | beforeEach(testSetup); 18 | const client = sprites(testConfiguration, 'encoding-id', 'stream-id', mockHttp); 19 | 20 | describe('stream', () => { 21 | describe('sprites', () => { 22 | describe('list', () => { 23 | assertItCallsCorrectUrl('GET', '/v1/encoding/encodings/encoding-id/streams/stream-id/sprites', client.list); 24 | assertItReturnsUnderlyingPromise(mockGet, client.list); 25 | }); 26 | 27 | describe('add', () => { 28 | assertItCallsCorrectUrl('POST', '/v1/encoding/encodings/encoding-id/streams/stream-id/sprites', client.add); 29 | assertItReturnsUnderlyingPromise(mockPost, client.add); 30 | }); 31 | 32 | describe('sprite', () => { 33 | describe('details', () => { 34 | assertItCallsCorrectUrl( 35 | 'GET', 36 | '/v1/encoding/encodings/encoding-id/streams/stream-id/sprites/sprite-id', 37 | client('sprite-id').details 38 | ); 39 | assertItReturnsUnderlyingPromise(mockGet, client('sprite-id').details); 40 | }); 41 | describe('customData', () => { 42 | assertItCallsCorrectUrl( 43 | 'GET', 44 | '/v1/encoding/encodings/encoding-id/streams/stream-id/sprites/sprite-id/customData', 45 | client('sprite-id').customData 46 | ); 47 | assertItReturnsUnderlyingPromise(mockGet, client('sprite-id').customData); 48 | }); 49 | describe('delete', () => { 50 | assertItCallsCorrectUrl( 51 | 'DELETE', 52 | '/v1/encoding/encodings/encoding-id/streams/stream-id/sprites/sprite-id', 53 | client('sprite-id').delete 54 | ); 55 | assertItReturnsUnderlyingPromise(mockDelete, client('sprite-id').delete); 56 | }); 57 | }); 58 | }); 59 | }); 60 | }); 61 | }); 62 | -------------------------------------------------------------------------------- /tests/encoding/streams.test.ts: -------------------------------------------------------------------------------- 1 | import {streams} from '../../bitmovin/encoding/encodings/streams'; 2 | import { 3 | assertItCallsCorrectUrl, 4 | assertItReturnsUnderlyingPromise, 5 | mockDelete, 6 | mockGet, 7 | mockHttp, 8 | mockPost, 9 | testSetup 10 | } from '../assertions'; 11 | import {getConfiguration} from '../utils'; 12 | 13 | const testConfiguration = getConfiguration(); 14 | describe('encoding', () => { 15 | describe('streams', () => { 16 | beforeEach(testSetup); 17 | const client = streams(testConfiguration, 'encoding-id', mockHttp); 18 | 19 | describe('list', () => { 20 | assertItCallsCorrectUrl('GET', '/v1/encoding/encodings/encoding-id/streams', client.list); 21 | assertItReturnsUnderlyingPromise(mockGet, client.list); 22 | }); 23 | describe('add', () => { 24 | assertItCallsCorrectUrl('POST', '/v1/encoding/encodings/encoding-id/streams', () => client.add({})); 25 | assertItReturnsUnderlyingPromise(mockPost, () => client.add({})); 26 | }); 27 | 28 | describe('stream', () => { 29 | describe('details', () => { 30 | assertItCallsCorrectUrl( 31 | 'GET', 32 | '/v1/encoding/encodings/encoding-id/streams/stream-id', 33 | client('stream-id').details 34 | ); 35 | assertItReturnsUnderlyingPromise(mockGet, client('stream-id').details); 36 | }); 37 | describe('customData', () => { 38 | assertItCallsCorrectUrl( 39 | 'GET', 40 | '/v1/encoding/encodings/encoding-id/streams/stream-id/customData', 41 | client('stream-id').customData 42 | ); 43 | assertItReturnsUnderlyingPromise(mockGet, client('stream-id').details); 44 | }); 45 | describe('delete', () => { 46 | assertItCallsCorrectUrl( 47 | 'DELETE', 48 | '/v1/encoding/encodings/encoding-id/streams/stream-id', 49 | client('stream-id').delete 50 | ); 51 | assertItReturnsUnderlyingPromise(mockDelete, client('stream-id').delete); 52 | }); 53 | describe('inputDetails', () => { 54 | assertItCallsCorrectUrl( 55 | 'GET', 56 | '/v1/encoding/encodings/encoding-id/streams/stream-id/input', 57 | client('stream-id').inputDetails 58 | ); 59 | assertItReturnsUnderlyingPromise(mockGet, client('stream-id').inputDetails); 60 | }); 61 | }); 62 | }); 63 | }); 64 | -------------------------------------------------------------------------------- /tests/encoding/thumbnails.test.ts: -------------------------------------------------------------------------------- 1 | import {thumbnails} from '../../bitmovin/encoding/encodings/streams/thumbnails'; 2 | import { 3 | assertItCallsCorrectUrl, 4 | assertItReturnsUnderlyingPromise, 5 | mockDelete, 6 | mockGet, 7 | mockHttp, 8 | mockPost, 9 | testSetup 10 | } from '../assertions'; 11 | import {getConfiguration} from '../utils'; 12 | 13 | const testConfiguration = getConfiguration(); 14 | 15 | describe('encoding', () => { 16 | describe('streams', () => { 17 | beforeEach(testSetup); 18 | const client = thumbnails(testConfiguration, 'encoding-id', 'stream-id', mockHttp); 19 | describe('stream', () => { 20 | describe('thumbnails', () => { 21 | describe('list', () => { 22 | assertItCallsCorrectUrl( 23 | 'GET', 24 | '/v1/encoding/encodings/encoding-id/streams/stream-id/thumbnails', 25 | client.list 26 | ); 27 | assertItReturnsUnderlyingPromise(mockGet, client.list); 28 | }); 29 | 30 | describe('add', () => { 31 | assertItCallsCorrectUrl( 32 | 'POST', 33 | '/v1/encoding/encodings/encoding-id/streams/stream-id/thumbnails', 34 | client.add 35 | ); 36 | assertItReturnsUnderlyingPromise(mockPost, client.add); 37 | }); 38 | 39 | describe('thumbnail', () => { 40 | describe('details', () => { 41 | assertItCallsCorrectUrl( 42 | 'GET', 43 | '/v1/encoding/encodings/encoding-id/streams/stream-id/thumbnails/thumbnail-id', 44 | client('thumbnail-id').details 45 | ); 46 | assertItReturnsUnderlyingPromise(mockGet, client('thumbnail-id').details); 47 | }); 48 | describe('customData', () => { 49 | assertItCallsCorrectUrl( 50 | 'GET', 51 | '/v1/encoding/encodings/encoding-id/streams/stream-id/thumbnails/thumbnail-id/customData', 52 | client('thumbnail-id').customData 53 | ); 54 | assertItReturnsUnderlyingPromise(mockGet, client('thumbnail-id').customData); 55 | }); 56 | describe('delete', () => { 57 | assertItCallsCorrectUrl( 58 | 'DELETE', 59 | '/v1/encoding/encodings/encoding-id/streams/stream-id/thumbnails/thumbnail-id', 60 | client('thumbnail-id').delete 61 | ); 62 | assertItReturnsUnderlyingPromise(mockDelete, client('thumbnail-id').delete); 63 | }); 64 | }); 65 | }); 66 | }); 67 | }); 68 | }); 69 | -------------------------------------------------------------------------------- /tests/notifications/emails/error.test.ts: -------------------------------------------------------------------------------- 1 | import emails from '../../../bitmovin/notifications/emails'; 2 | import {EmailNotificationWithConditions, EventTypes} from '../../../bitmovin/notifications/types'; 3 | import {mockHttp, testSetup} from '../../assertions'; 4 | import {getConfiguration} from '../../utils'; 5 | 6 | const testConfiguration = getConfiguration(); 7 | const notificationEmails = emails(testConfiguration, mockHttp); 8 | 9 | const testEmailNotificationWithConditions: EmailNotificationWithConditions = { 10 | id: 'id', 11 | type: 'EMAIL', 12 | eventType: EventTypes.ENCODING_ERROR, 13 | resolve: true, 14 | conditions: { 15 | type: 'AND', 16 | conditions: [] 17 | }, 18 | emails: [], 19 | name: 'name', 20 | description: 'description', 21 | resourceId: 'aaaaa-aaaa-aaaa-aaaaa' 22 | }; 23 | 24 | const testNotificationId = 'testNotificationId'; 25 | const testEncodingId = 'testEncodingId'; 26 | 27 | describe('error', () => { 28 | beforeEach(() => { 29 | testSetup(); 30 | }); 31 | 32 | describe('create', () => { 33 | it('should call the correct url', async () => { 34 | await notificationEmails.encoding.encodings.error.create(testEmailNotificationWithConditions); 35 | expect(mockHttp.post).toHaveBeenCalledWith( 36 | testConfiguration, 37 | 'https://api.bitmovin.com/v1/notifications/emails/encoding/encodings/error', 38 | testEmailNotificationWithConditions 39 | ); 40 | }); 41 | }); 42 | 43 | describe('replace', () => { 44 | it('should call the correct url', async () => { 45 | await notificationEmails.encoding.encodings 46 | .error(testNotificationId) 47 | .replace(testEmailNotificationWithConditions); 48 | expect(mockHttp.put).toHaveBeenCalledWith( 49 | testConfiguration, 50 | `https://api.bitmovin.com/v1/notifications/emails/encoding/encodings/error/${testNotificationId}`, 51 | testEmailNotificationWithConditions 52 | ); 53 | }); 54 | }); 55 | 56 | describe('single encoding notifications', () => { 57 | describe('create', () => { 58 | it('should call the correct url', async () => { 59 | await notificationEmails.encoding.encodings(testEncodingId).error.create(testEmailNotificationWithConditions); 60 | expect(mockHttp.post).toHaveBeenCalledWith( 61 | testConfiguration, 62 | `https://api.bitmovin.com/v1/notifications/emails/encoding/encodings/${testEncodingId}/error`, 63 | testEmailNotificationWithConditions 64 | ); 65 | }); 66 | }); 67 | 68 | describe('replace', () => { 69 | it('should call the correct url', async () => { 70 | await notificationEmails.encoding 71 | .encodings(testEncodingId) 72 | .error(testNotificationId) 73 | .replace(testEmailNotificationWithConditions); 74 | expect(mockHttp.put).toHaveBeenCalledWith( 75 | testConfiguration, 76 | `https://api.bitmovin.com/v1/notifications/emails/encoding/encodings/${testEncodingId}/error/${testNotificationId}`, 77 | testEmailNotificationWithConditions 78 | ); 79 | }); 80 | }); 81 | }); 82 | }); 83 | -------------------------------------------------------------------------------- /tests/notifications/index.test.ts: -------------------------------------------------------------------------------- 1 | import notifications from '../../bitmovin/notifications'; 2 | import {mockHttp, testSetup} from '../assertions'; 3 | import {getConfiguration} from '../utils'; 4 | 5 | const testConfiguration = getConfiguration(); 6 | const notificationsApi = notifications(testConfiguration, mockHttp); 7 | 8 | const testNotificationId = 'id'; 9 | 10 | describe('notifications', () => { 11 | beforeEach(() => { 12 | testSetup(); 13 | }); 14 | 15 | describe('list', () => { 16 | it('should call correct url', async () => { 17 | await notificationsApi.list(); 18 | expect(mockHttp.get).toHaveBeenCalledWith(testConfiguration, 'https://api.bitmovin.com/v1/notifications'); 19 | }); 20 | 21 | it('should include limit', async () => { 22 | await notificationsApi.list(10); 23 | expect(mockHttp.get).toHaveBeenCalledWith( 24 | testConfiguration, 25 | 'https://api.bitmovin.com/v1/notifications?limit=10' 26 | ); 27 | }); 28 | 29 | it('should include offset', async () => { 30 | await notificationsApi.list(undefined, 10); 31 | expect(mockHttp.get).toHaveBeenCalledWith( 32 | testConfiguration, 33 | 'https://api.bitmovin.com/v1/notifications?offset=10' 34 | ); 35 | }); 36 | }); 37 | 38 | describe('details', () => { 39 | it('should call correct url', async () => { 40 | await notificationsApi(testNotificationId).details(); 41 | expect(mockHttp.get).toHaveBeenCalledWith( 42 | testConfiguration, 43 | `https://api.bitmovin.com/v1/notifications/${testNotificationId}` 44 | ); 45 | }); 46 | }); 47 | 48 | describe('mute', () => { 49 | it('should call correct url', async () => { 50 | await notificationsApi(testNotificationId).mute(); 51 | expect(mockHttp.post).toHaveBeenCalledWith( 52 | testConfiguration, 53 | `https://api.bitmovin.com/v1/notifications/${testNotificationId}/mute` 54 | ); 55 | }); 56 | }); 57 | 58 | describe('unmute', () => { 59 | it('should call correct url', async () => { 60 | await notificationsApi(testNotificationId).unmute(); 61 | expect(mockHttp.post).toHaveBeenCalledWith( 62 | testConfiguration, 63 | `https://api.bitmovin.com/v1/notifications/${testNotificationId}/unmute` 64 | ); 65 | }); 66 | }); 67 | 68 | describe('delete', () => { 69 | it('should call correct url', async () => { 70 | await notificationsApi(testNotificationId).delete(); 71 | expect(mockHttp.delete_).toHaveBeenCalledWith( 72 | testConfiguration, 73 | `https://api.bitmovin.com/v1/notifications/${testNotificationId}` 74 | ); 75 | }); 76 | }); 77 | }); 78 | -------------------------------------------------------------------------------- /tests/player/statistics.test.ts: -------------------------------------------------------------------------------- 1 | import {statistics} from '../../bitmovin/player/statistics'; 2 | import {assertItCallsCorrectUrl, assertItReturnsUnderlyingPromise, mockGet, mockHttp, testSetup} from '../assertions'; 3 | import {getConfiguration} from '../utils'; 4 | 5 | const testConfiguration = getConfiguration(); 6 | 7 | describe('player', () => { 8 | const statisticsClient = statistics(testConfiguration, mockHttp); 9 | beforeEach(testSetup); 10 | 11 | describe('statistics', () => { 12 | describe('impressions', () => { 13 | describe('impressions default interval', () => { 14 | assertItCallsCorrectUrl( 15 | 'GET', 16 | '/v1/player/statistics/impressions', 17 | statisticsClient.impressions.bind(this, 'asdf', '2017-01-01', '2017-01-02') 18 | ); 19 | assertItReturnsUnderlyingPromise( 20 | mockGet, 21 | statisticsClient.impressions.bind(this, 'asdf', '2017-01-01', '2017-01-02') 22 | ); 23 | }); 24 | describe('impressions daily interval', () => { 25 | assertItCallsCorrectUrl( 26 | 'GET', 27 | '/v1/player/statistics/impressions', 28 | statisticsClient.impressions.bind(this, 'asdf', '2017-01-01', '2017-01-02', statisticsClient.INTERVAL.DAILY) 29 | ); 30 | assertItReturnsUnderlyingPromise( 31 | mockGet, 32 | statisticsClient.impressions.bind(this, 'asdf', '2017-01-01', '2017-01-02', statisticsClient.INTERVAL.DAILY) 33 | ); 34 | }); 35 | }); 36 | }); 37 | }); 38 | -------------------------------------------------------------------------------- /tests/utils.ts: -------------------------------------------------------------------------------- 1 | import {InternalConfiguration} from '../bitmovin/utils/types'; 2 | 3 | const settings = { 4 | apiKey: 'test-api-key', 5 | tenantOrgId: 'test-org-id' 6 | }; 7 | 8 | const getConfiguration = (): InternalConfiguration => { 9 | return { 10 | ...settings, 11 | protocol: 'https', 12 | host: 'api.bitmovin.com', 13 | basePath: '/v1', 14 | requestTimeout: 300000, 15 | xApiClient: 'bitmovin-javascript', 16 | apiBaseUrl: 'https://api.bitmovin.com/v1/', 17 | httpHeaders: { 18 | 'Content-Type': 'application/json', 19 | 'X-Api-Key': settings.apiKey, 20 | 'X-Tenant-Org-Id': settings.tenantOrgId, 21 | 'X-Api-Client': 'bitmovin-javascript', 22 | 'X-Api-Client-Version': '1.1.20' 23 | } 24 | }; 25 | }; 26 | 27 | export {getConfiguration}; 28 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "emitDecoratorMetadata": true, 5 | "experimentalDecorators": true, 6 | "removeComments": false, 7 | "noImplicitAny": false, 8 | "typeRoots": [ 9 | "./node_modules/@types" 10 | ], 11 | "strictNullChecks": true, 12 | "declaration": true, 13 | "outDir": "./dist", 14 | "target": "es5", 15 | "lib": [ 16 | "dom", 17 | "es2015", 18 | "es2016" 19 | ] 20 | }, 21 | "exclude": [ 22 | "node_modules", 23 | "tests", 24 | "examples", 25 | "scripts", 26 | "dist" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "tslint:recommended" 4 | ], 5 | "rules": { 6 | "quotemark": [true, "single", "avoid-escape"], 7 | "arrow-parens": false, 8 | "trailing-comma": false, 9 | "object-literal-sort-keys": false, 10 | "ordered-imports": [true, { 11 | "import-sources-order": "lowercase-last", 12 | "grouped-imports": true, 13 | "named-imports-order": "lowercase-last" 14 | }], 15 | "interface-name": false, 16 | "object-literal-key-quotes": [true, "as-needed"], 17 | "no-null-keyword": true, 18 | "no-empty-interface": false, 19 | "max-line-length": [false] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /webpack4.config.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack'); 2 | const path = require('path'); 3 | const packageJson = require('./package'); 4 | 5 | const isProd = process.env.NODE_ENV === 'production'; 6 | 7 | const baseFileName = 'bitmovin'; 8 | 9 | const config = { 10 | mode: isProd ? 'production' : 'development', 11 | context: path.join(__dirname, 'bitmovin'), 12 | entry: ['./index.ts'], 13 | output: { 14 | filename: `${baseFileName}.browser${isProd ? '.min' : ''}.js`, 15 | path: path.join(__dirname, 'dist'), 16 | libraryTarget: 'umd', 17 | library: 'bitmovin' 18 | }, 19 | module: { 20 | rules: [ 21 | { 22 | test: /\.ts$/, 23 | loader: 'awesome-typescript-loader', 24 | exclude: /node_modules/ 25 | } 26 | ] 27 | }, 28 | optimization: { 29 | noEmitOnErrors: false 30 | }, 31 | resolve: { 32 | extensions: ['.tsx', '.ts', '.js'] 33 | }, 34 | devtool: isProd ? false : 'source-map', 35 | stats: process.env.WEBPACK_MODE === 'log' ? 'verbose' : 'normal', 36 | plugins: [ 37 | new webpack.DefinePlugin({ 38 | __VERSION__: JSON.stringify(packageJson.version) 39 | }) 40 | ] 41 | }; 42 | 43 | module.exports = config; 44 | --------------------------------------------------------------------------------