update version to 2025.0.2, enhance build scripts, add type exports, and improve reporting interfaces
This commit is contained in:
@@ -3,7 +3,7 @@ import {PCastApi} from '../dist/node/index.js';
|
|||||||
const applicationCredentials = {
|
const applicationCredentials = {
|
||||||
id: 'phenixrts.com-alex.zinn',
|
id: 'phenixrts.com-alex.zinn',
|
||||||
secret: 'AMAsDzr.dIuGMZ.Zu52Dt~MQvP!DZwYg'
|
secret: 'AMAsDzr.dIuGMZ.Zu52Dt~MQvP!DZwYg'
|
||||||
}
|
};
|
||||||
|
|
||||||
const pcastUri = 'https://pcast-stg.phenixrts.com';
|
const pcastUri = 'https://pcast-stg.phenixrts.com';
|
||||||
const pcastApi = new PCastApi(pcastUri, applicationCredentials);
|
const pcastApi = new PCastApi(pcastUri, applicationCredentials);
|
||||||
|
|||||||
26
package.json
26
package.json
@@ -1,13 +1,20 @@
|
|||||||
{
|
{
|
||||||
"name": "@techniker-me/pcast-api",
|
"name": "@techniker-me/pcast-api",
|
||||||
"version": "2025.0.1",
|
"version": "2025.0.2",
|
||||||
"module": "src/index.ts",
|
"module": "src/index.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"clean": "bash scripts/clean.sh",
|
"format": "prettier --write ./",
|
||||||
"ci-build": "bun run build:node && bun run build:browser",
|
"test": "bun test",
|
||||||
|
"test:watch": "bun test --watch",
|
||||||
|
"test:coverage": "bun test --coverage",
|
||||||
|
"build": "bun run build:node && bun run build:browser && bun run build:types",
|
||||||
|
"ci-build": "bun run build:node && bun run build:browser && bun run build:types",
|
||||||
"build:node": "bun build src/index.ts --outdir dist/node --target node --format esm --minify --production",
|
"build:node": "bun build src/index.ts --outdir dist/node --target node --format esm --minify --production",
|
||||||
"build:browser": "bun build src/index.ts --outdir dist/browser --target browser --format esm --minify --production"
|
"build:browser": "bun build src/index.ts --outdir dist/browser --target browser --format esm --minify --production",
|
||||||
|
"build:types": "tsc --outDir dist/types",
|
||||||
|
"prepublishOnly": "bun run build",
|
||||||
|
"clean": "rm -rf dist"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/bun": "latest",
|
"@types/bun": "latest",
|
||||||
@@ -19,10 +26,19 @@
|
|||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"typescript": "^5"
|
"typescript": "^5"
|
||||||
},
|
},
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./dist/types/index.d.ts",
|
||||||
|
"import": "./dist/node/index.js",
|
||||||
|
"default": "./dist/node/index.js"
|
||||||
|
},
|
||||||
|
"./browser": "./dist/browser/index.js"
|
||||||
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"registry": "https://registry-node.techniker.me"
|
"registry": "https://registry-node.techniker.me"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": "24.3.0"
|
"@types/node": "24.3.0",
|
||||||
|
"phenix-edge-auth": "1.2.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,3 +17,11 @@ export interface ChannelsResponse extends IResponse<'channels', Channel[]> {
|
|||||||
export interface MembersResponse extends IResponse<'members', Channel[]> {
|
export interface MembersResponse extends IResponse<'members', Channel[]> {
|
||||||
members: Channel[];
|
members: Channel[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PublishingReportResponse extends IResponse<'publishingReport', string> {
|
||||||
|
publishingReport: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ViewingReportResponse extends IResponse<'viewingReport', string> {
|
||||||
|
viewingReport: string;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assertUnreachable from '../lang/assertUnreachable';
|
|
||||||
import {HttpMethod} from '../net/http/HttpMethod';
|
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 {
|
export enum ReportKind {
|
||||||
Publishing = 0,
|
Publishing = 0,
|
||||||
@@ -57,7 +57,7 @@ export enum ViewingReportKind {
|
|||||||
export type ViewingReportKindType = 'RealTime' | 'HLS' | 'DASH';
|
export type ViewingReportKindType = 'RealTime' | 'HLS' | 'DASH';
|
||||||
|
|
||||||
export type ViewingReportOptions = {
|
export type ViewingReportOptions = {
|
||||||
kind: ViewingReportKind,
|
kind: ViewingReportKind;
|
||||||
applicationIds?: string[];
|
applicationIds?: string[];
|
||||||
streamIds?: string[];
|
streamIds?: string[];
|
||||||
sessionIds?: string[];
|
sessionIds?: string[];
|
||||||
@@ -70,11 +70,8 @@ export type ViewingReportOptions = {
|
|||||||
tags?: string[];
|
tags?: string[];
|
||||||
start: string;
|
start: string;
|
||||||
end: string;
|
end: string;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export class Reporting {
|
export class Reporting {
|
||||||
private readonly _httpRequests: PCastHttpRequests;
|
private readonly _httpRequests: PCastHttpRequests;
|
||||||
|
|
||||||
@@ -97,7 +94,6 @@ export class Reporting {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async requestPublishingReport(options: PublishingReportOptions): Promise<string> {
|
public async requestPublishingReport(options: PublishingReportOptions): Promise<string> {
|
||||||
|
|
||||||
if (!(options.start || options.end)) {
|
if (!(options.start || options.end)) {
|
||||||
throw new Error('[Reporting] [requestPublishingReport] requires a start and end Date');
|
throw new Error('[Reporting] [requestPublishingReport] requires a start and end Date');
|
||||||
}
|
}
|
||||||
@@ -107,12 +103,18 @@ export class Reporting {
|
|||||||
|
|
||||||
const requestPublishingOptions = {
|
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);
|
const response = await this._httpRequests.request<PublishingReportResponse>(
|
||||||
|
HttpMethod.PUT,
|
||||||
|
'/pcast/reporting/publishing',
|
||||||
|
requestPublishingOptions
|
||||||
|
);
|
||||||
|
|
||||||
return response;
|
if (!response.publishingReport) {
|
||||||
|
throw new Error('[Reporting] [requestPublishingReport] Invalid response format - missing publishingReport data');
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.publishingReport;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async requestViewingReport(options: ViewingReportOptions): Promise<string> {
|
private async requestViewingReport(options: ViewingReportOptions): Promise<string> {
|
||||||
@@ -124,9 +126,12 @@ export class Reporting {
|
|||||||
body: JSON.stringify({viewingReport: viewingReportOptions})
|
body: JSON.stringify({viewingReport: viewingReportOptions})
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await this._httpRequests.request<IResponse<'viewingReport', string>>(HttpMethod.PUT, '/pcast/reporting/viewing', requestViewingOptions);
|
const response = await this._httpRequests.request<ViewingReportResponse>(HttpMethod.PUT, '/pcast/reporting/viewing', requestViewingOptions);
|
||||||
|
|
||||||
return response;
|
if (!response.viewingReport) {
|
||||||
|
throw new Error('[Reporting] [requestViewingReport] Invalid response format - missing viewingReport data');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return response.viewingReport;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
|
import {HttpMethod} from '../net/http/HttpMethod';
|
||||||
import { HttpMethod } from "../net/http/HttpMethod";
|
import type IResponse from './IResponse';
|
||||||
import type IResponse from "./IResponse";
|
import type {PCastHttpRequests} from './PCastRequests';
|
||||||
import type { PCastHttpRequests } from "./PCastRequests";
|
|
||||||
|
|
||||||
export class Streams {
|
export class Streams {
|
||||||
private readonly _httpRequests: PCastHttpRequests;
|
private readonly _httpRequests: PCastHttpRequests;
|
||||||
@@ -10,7 +9,6 @@ export class Streams {
|
|||||||
this._httpRequests = httpRequests;
|
this._httpRequests = httpRequests;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async publishUri(mediaUri: string, token: string) {
|
public async publishUri(mediaUri: string, token: string) {
|
||||||
const mediaType = mediaUri.split('.')?.at(-1);
|
const mediaType = mediaUri.split('.')?.at(-1);
|
||||||
|
|
||||||
@@ -18,7 +16,6 @@ export class Streams {
|
|||||||
throw new Error('Invalid media URI no media type found');
|
throw new Error('Invalid media URI no media type found');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const response = await this._httpRequests.request<IResponse<'publishUri', string>>(HttpMethod.PUT, `/stream/publish/uri/${mediaType}`, {
|
const response = await this._httpRequests.request<IResponse<'publishUri', string>>(HttpMethod.PUT, `/stream/publish/uri/${mediaType}`, {
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
token,
|
token,
|
||||||
@@ -29,5 +26,4 @@ export class Streams {
|
|||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,5 +25,7 @@
|
|||||||
"noUnusedLocals": false,
|
"noUnusedLocals": false,
|
||||||
"noUnusedParameters": false,
|
"noUnusedParameters": false,
|
||||||
"noPropertyAccessFromIndexSignature": false
|
"noPropertyAccessFromIndexSignature": false
|
||||||
}
|
},
|
||||||
|
"include": ["src"],
|
||||||
|
"exclude": ["test", "dist", "node_modules"]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user