Skip to content

Commit

Permalink
entities & utils folders complete
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanTGold committed Nov 8, 2023
1 parent 24bc3e1 commit 9e3f49c
Show file tree
Hide file tree
Showing 19 changed files with 62 additions and 72 deletions.
2 changes: 1 addition & 1 deletion src/entities/bumper.js → src/entities/bumper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class Bumper {
* @constructor
* @param {Object} data - The bumper response
*/
constructor(data: Object) {
constructor(data: any) {
this.url = data.url;
this.clickThroughUrl = data.clickThroughUrl;
}
Expand Down
7 changes: 4 additions & 3 deletions src/entities/drm.js → src/entities/drm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@flow
import {ProviderDrmDataObject} from '../types';

export default class Drm {
/**
* @member - license url
Expand All @@ -15,15 +16,15 @@ export default class Drm {
* @member - drm certificate
* @type {string}
*/
certificate: string;
certificate?: string;

Check failure on line 19 in src/entities/drm.ts

View workflow job for this annotation

GitHub Actions / running-tests / running-tests (ubuntu-latest)

Missing accessibility modifier on class property certificate

/**
* @constructor
* @param {string} licenseUrl - the license url
* @param {string} scheme - the drm scheme
* @param {?string} certificate - the drm certificate
*/
constructor(licenseUrl: string, scheme: string, certificate: ?string) {
constructor(licenseUrl: string, scheme: string, certificate?: string) {
this.licenseUrl = licenseUrl;
this.scheme = scheme;
if (certificate) {
Expand Down
2 changes: 0 additions & 2 deletions src/entities/entry-list.js → src/entities/entry-list.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//@flow

import MediaEntry from '../entities/media-entry';

export default class EntryList {
Expand Down
6 changes: 2 additions & 4 deletions src/entities/image-source.js → src/entities/image-source.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//@flow

const BASE_THUMBNAIL_URL_TEMPLATE = '.+entry_id/[a-zA-Z0-9_]+/';

export default class ImageSource {
Expand All @@ -19,7 +17,7 @@ export default class ImageSource {
*/
mimetype: string;

Check failure on line 18 in src/entities/image-source.ts

View workflow job for this annotation

GitHub Actions / running-tests / running-tests (ubuntu-latest)

Missing accessibility modifier on class property mimetype

constructor(entry: Object) {
constructor(entry: any) {
this.id = entry.id;
this.url = ImageSource.extractBaseThumbnailUrl(entry.dataUrl);
this.mimetype = '';
Expand All @@ -31,7 +29,7 @@ export default class ImageSource {
* @returns {string} - The base thumbnail url.
*/
static extractBaseThumbnailUrl(url: string): string {
// $FlowFixMe
// @ts-ignore
return url.match(BASE_THUMBNAIL_URL_TEMPLATE)[0].slice(0, -1);
}
}
17 changes: 9 additions & 8 deletions src/entities/media-entry.js → src/entities/media-entry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//@flow
import MediaSources from './media-sources';
import {ProviderMediaEntryObject} from '../types';

export default class MediaEntry {
static Type: {[type: string]: string} = {
Expand All @@ -18,12 +19,12 @@ export default class MediaEntry {
* @member - entry id
* @type {string}
*/
id: string;
id?: string;
/**
* @member - entry name
* @type {string}
*/
name: string;
name?: string;
/**
* @member - entry sources
* @type {MediaSources}
Expand All @@ -33,7 +34,7 @@ export default class MediaEntry {
* @member - entry duration
* @type {number}
*/
duration: number;
duration?: number;
/**
* @member - entry type
* @type {string}
Expand All @@ -48,29 +49,29 @@ export default class MediaEntry {
* @member - DVR status
* @type {number}
*/
dvrStatus: number;
dvrStatus?: number;
/**
* @member - media status
* @type {number}
*/
status: number;
status?: number;
/**
* @member - media poster
* @type {string | Array<Object>}
*/
poster: string | Array<Object>;
poster?: string | Array<any>;

/**
* @member - assetReferenceType
* @type {string }
*/
assetReferenceType: string;
assetReferenceType?: string;

/**
* @member - The download URL of the entry.
* @type {string}
*/
downloadUrl: string;
downloadUrl?: string;

/**
* @constructor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@flow
import {ProviderMediaFormatType} from '../types';

export const MediaFormat: {[name: string]: ProviderMediaFormatType} = {
DASH: {
name: 'dash',
Expand Down
18 changes: 9 additions & 9 deletions src/entities/media-source.js → src/entities/media-source.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
//@flow
import Drm from './drm';
import {ProviderMediaSourceObject} from '../types';

export default class MediaSource {
/**
* @member - media source id
* @type {string}
*/
id: string;
id!: string;
/**
* @member - media source url
* @type {string}
*/
url: string;
url!: string;
/**
* @member - media source mimetype
* @type {string}
*/
mimetype: string;
mimetype!: string;
/**
* @member - media source drm data
* @type {Array<Drm>}
*/
drmData: Array<Drm>;
drmData?: Array<Drm>;
/**
* @member - media source bandwidth
* @type {number}
*/
bandwidth: number;
bandwidth?: number;
/**
* @member - media source width
* @type {number}
*/
width: number;
width?: number;
/**
* @member - media source height
* @type {number}
*/
height: number;
height?: number;
/**
* @member - media source label
* @type {string}
*/
label: string;
label?: string;

/**
* Convert class to native js object.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow
import MediaSource from './media-source';
import {MediaFormat} from './media-format';
import ImageSource from './image-source';
import {PKExternalCaptionObject, ProviderMediaFormatType, ProviderMediaSourcesObject} from '../types';

export default class MediaSources {
/**
Expand All @@ -23,7 +23,7 @@ export default class MediaSources {
*/
hls: Array<MediaSource>;
image: Array<ImageSource>;
captions: Array<PKExternalCaptionObject>;
captions?: Array<PKExternalCaptionObject>;

/**
* @constructor
Expand All @@ -41,7 +41,7 @@ export default class MediaSources {
* @param {MediaFormat} mediaFormat - The media format of the source.
* @returns {void}
*/
map(source: MediaSource, mediaFormat: ?ProviderMediaFormatType) {
map(source: MediaSource, mediaFormat?: ProviderMediaFormatType) {

Check warning on line 44 in src/entities/media-sources.ts

View workflow job for this annotation

GitHub Actions / running-tests / running-tests (ubuntu-latest)

Missing return type on function
if (mediaFormat) {
switch (mediaFormat.name) {
case MediaFormat.MP4.name:
Expand Down
10 changes: 4 additions & 6 deletions src/entities/playlist.js → src/entities/playlist.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
//@flow

import MediaEntry from '../entities/media-entry';

export default class Playlist {
/**
* @member - playlist id
* @type {string}
*/
id: string;
id?: string;
/**
* @member - playlist name
* @type {string}
*/
name: string;
name?: string;
/**
* @member - playlist description
* @type {string}
*/
description: string;
description?: string;

/**
* @member - playlist poster
* @type {string}
*/
poster: string;
poster?: string;

/**
* @member - playlist items
Expand Down
17 changes: 9 additions & 8 deletions src/types/media-entry.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import {ProviderMediaSourcesObject} from './media-sources';

export type ProviderMediaEntryObject = {
id: string;
name: string;
id?: string;
name?: string;
sources: ProviderMediaSourcesObject;
duration: number;
dvrStatus: number;
status: number;
metadata: Object;
duration?: number;
dvrStatus?: number;
status?: number;
metadata: any;
type: string;
poster: string | Array<Object>;
downloadUrl: string;
poster?: string | Array<any>;
downloadUrl?: string;
assetReferenceType?: string;
};
2 changes: 1 addition & 1 deletion src/types/network-retry-parameters.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type ProviderNetworkRetryParameters = {
async?: boolean;
async: boolean;
timeout?: number;
maxAttempts?: number;
};
1 change: 0 additions & 1 deletion src/util/error/category.js → src/util/error/category.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//@flow
type CategoryType = {[category: string]: number};

const Category: CategoryType = {
Expand Down
2 changes: 0 additions & 2 deletions src/util/error/code.js → src/util/error/code.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//@flow

type CodeType = {[code: string]: number};

const Code: CodeType = {
Expand Down
1 change: 0 additions & 1 deletion src/util/error/error.js → src/util/error/error.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//@flow
import getLogger from '../logger';
import {Severity} from './severity';
import type {SeverityType} from './severity';
Expand Down
2 changes: 0 additions & 2 deletions src/util/error/severity.js → src/util/error/severity.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//@flow

type SeverityType = {[severity: string]: number};

const Severity: SeverityType = {
Expand Down
7 changes: 3 additions & 4 deletions src/util/logger.js → src/util/logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//@flow
export type LogLevelObject = {value: number, name: string};
export type LogLevelType = {[level: string]: LogLevelObject};
export type loggerFunctionType = {
Expand Down Expand Up @@ -66,7 +65,7 @@ let LogLevel: LogLevelType = {};
* @param {LoggerType} logger - the logger
* @returns {void}
*/
function setLogger(logger: ?LoggerType): void {
function setLogger(logger?: LoggerType): void {
if (logger && typeof logger.getLogger === 'function') {
JsLogger.get = logger.getLogger;
}
Expand All @@ -80,8 +79,8 @@ function setLogger(logger: ?LoggerType): void {
* @param {?string} name - the logger name
* @returns {Object} - the logger class
*/
function getLogger(name?: string): Object {
//$FlowFixMe
function getLogger(name?: string): any {
//@ts-ignore
return JsLogger.get(name);
}

Expand Down
2 changes: 1 addition & 1 deletion src/util/param.js → src/util/param.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const param = a => {
let s = [],
let s: string[] = [],
rbracket = /\[\]$/,
isArray = function (obj) {
return Object.prototype.toString.call(obj) === '[object Array]';
Expand Down
Loading

0 comments on commit 9e3f49c

Please sign in to comment.