update version to 2025.0.2, enhance build scripts, add type exports, and improve reporting interfaces
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import assertUnreachable from '../lang/assertUnreachable';
|
||||
import {HttpMethod} from '../net/http/HttpMethod';
|
||||
import type IResponse from './IResponse';
|
||||
import type { PCastHttpRequests } from './PCastRequests';
|
||||
import type {PCastHttpRequests} from './PCastRequests';
|
||||
import type {PublishingReportResponse, ViewingReportResponse} from './IResponse';
|
||||
import assertUnreachable from '../lang/assertUnreachable';
|
||||
|
||||
export enum ReportKind {
|
||||
Publishing = 0,
|
||||
@@ -42,7 +42,7 @@ export type PublishingReportOptions = {
|
||||
channelIds?: string[];
|
||||
channelAliases?: string[];
|
||||
roomIds?: string[];
|
||||
roomAliases?:string[];
|
||||
roomAliases?: string[];
|
||||
tags?: string[];
|
||||
start: string;
|
||||
end: string;
|
||||
@@ -57,7 +57,7 @@ export enum ViewingReportKind {
|
||||
export type ViewingReportKindType = 'RealTime' | 'HLS' | 'DASH';
|
||||
|
||||
export type ViewingReportOptions = {
|
||||
kind: ViewingReportKind,
|
||||
kind: ViewingReportKind;
|
||||
applicationIds?: string[];
|
||||
streamIds?: string[];
|
||||
sessionIds?: string[];
|
||||
@@ -66,15 +66,12 @@ export type ViewingReportOptions = {
|
||||
channelIds?: string[];
|
||||
channelAliases?: string[];
|
||||
roomIds?: string[];
|
||||
roomAliases?:string[];
|
||||
roomAliases?: string[];
|
||||
tags?: string[];
|
||||
start: string;
|
||||
end: string;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
export class Reporting {
|
||||
private readonly _httpRequests: PCastHttpRequests;
|
||||
|
||||
@@ -97,36 +94,44 @@ export class Reporting {
|
||||
}
|
||||
|
||||
public async requestPublishingReport(options: PublishingReportOptions): Promise<string> {
|
||||
|
||||
if (!(options.start || options.end)) {
|
||||
throw new Error('[Reporting] [requestPublishingReport] requires a start and end Date');
|
||||
}
|
||||
const publishingReportOptions = {
|
||||
...options
|
||||
...options
|
||||
};
|
||||
|
||||
const requestPublishingOptions = {
|
||||
body: JSON.stringify({publishingReport: publishingReportOptions})
|
||||
|
||||
body: JSON.stringify({publishingReport: publishingReportOptions})
|
||||
};
|
||||
const response = await this._httpRequests.request<IResponse<'publishingReport', string>>(HttpMethod.PUT, '/pcast/reporting/publishing', requestPublishingOptions);
|
||||
|
||||
return response;
|
||||
const response = await this._httpRequests.request<PublishingReportResponse>(
|
||||
HttpMethod.PUT,
|
||||
'/pcast/reporting/publishing',
|
||||
requestPublishingOptions
|
||||
);
|
||||
|
||||
if (!response.publishingReport) {
|
||||
throw new Error('[Reporting] [requestPublishingReport] Invalid response format - missing publishingReport data');
|
||||
}
|
||||
|
||||
private async requestViewingReport(options: ViewingReportOptions): Promise<string> {
|
||||
const viewingReportOptions = {
|
||||
...options
|
||||
};
|
||||
|
||||
const requestViewingOptions = {
|
||||
body: JSON.stringify({viewingReport: viewingReportOptions})
|
||||
};
|
||||
return response.publishingReport;
|
||||
}
|
||||
|
||||
const response = await this._httpRequests.request<IResponse<'viewingReport', string>>(HttpMethod.PUT, '/pcast/reporting/viewing', requestViewingOptions);
|
||||
private async requestViewingReport(options: ViewingReportOptions): Promise<string> {
|
||||
const viewingReportOptions = {
|
||||
...options
|
||||
};
|
||||
|
||||
return response;
|
||||
const requestViewingOptions = {
|
||||
body: JSON.stringify({viewingReport: viewingReportOptions})
|
||||
};
|
||||
|
||||
const response = await this._httpRequests.request<ViewingReportResponse>(HttpMethod.PUT, '/pcast/reporting/viewing', requestViewingOptions);
|
||||
|
||||
if (!response.viewingReport) {
|
||||
throw new Error('[Reporting] [requestViewingReport] Invalid response format - missing viewingReport data');
|
||||
}
|
||||
|
||||
return response.viewingReport;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user