This commit is contained in:
Alex Zinn
2025-08-30 20:28:53 -04:00
parent 96dd978d5d
commit bbed095926
11 changed files with 15 additions and 16 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "@techniker-me/pcast-api", "name": "@techniker-me/pcast-api",
"version": "2025.1.0", "version": "2025.1.4",
"type": "module", "type": "module",
"scripts": { "scripts": {
"ci-build": "bun run build", "ci-build": "bun run build",
@@ -19,10 +19,9 @@
"build:browser:dev": "bun build src/index.ts --outdir dist/browser --target browser --format esm --development", "build:browser:dev": "bun build src/index.ts --outdir dist/browser --target browser --format esm --development",
"build:types:dev": "tsc --emitDeclarationOnly --outDir dist/types", "build:types:dev": "tsc --emitDeclarationOnly --outDir dist/types",
"prebuild:dev": "bun run clean", "prebuild:dev": "bun run clean",
"build:dev": "bun run build:node:dev && bun run build:browser:dev && bun run build:types:dev", "build:dev": "bun run build:node:dev;bun run build:browser:dev;bun run build:types:dev",
"prebuild": "bun run clean", "prebuild": "bun run clean",
"build": "bun run build:node && bun run build:browser && bun run build:types", "build": "bun run build:node && bun run build:browser && bun run build:types",
"postclean": "bun run lint",
"clean": "rm -rf dist", "clean": "rm -rf dist",
"prepublish": "bash scripts/pre-publish.sh" "prepublish": "bash scripts/pre-publish.sh"
}, },
@@ -59,6 +58,6 @@
"registry": "https://registry-node.techniker.me" "registry": "https://registry-node.techniker.me"
}, },
"files": [ "files": [
"dist" "dist/"
] ]
} }

View File

@@ -1,4 +1,4 @@
import {Channels, Streams, type ApplicationCredentials, PCastHttpRequests, Reporting} from './pcast'; import {Channels, Streams, type ApplicationCredentials, PCastHttpRequests, Reporting} from './apis';
export class PCastApi { export class PCastApi {
private readonly _channels: Channels; private readonly _channels: Channels;
@@ -11,7 +11,7 @@ export class PCastApi {
this._reporting = reporting; this._reporting = reporting;
} }
public static create(pcastUri: string, applicationCredentials: ApplicationCredentials): Promise<PCastApi> { public static create(pcastUri: string, applicationCredentials: ApplicationCredentials): PCastApi {
const pcastHttpRequests = new PCastHttpRequests(pcastUri.replace(/\/+$/, '').endsWith('/pcast') ? pcastUri : `${pcastUri}/pcast`, applicationCredentials); const pcastHttpRequests = new PCastHttpRequests(pcastUri.replace(/\/+$/, '').endsWith('/pcast') ? pcastUri : `${pcastUri}/pcast`, applicationCredentials);
const channels = new Channels(pcastHttpRequests); const channels = new Channels(pcastHttpRequests);
const streams = new Streams(pcastHttpRequests); const streams = new Streams(pcastHttpRequests);

View File

@@ -50,7 +50,7 @@ export class Channels {
private readonly _httpRequests: PCastHttpRequests; private readonly _httpRequests: PCastHttpRequests;
private readonly _channelsByAlias: Map<ChannelAlias, Channel> = new Map(); private readonly _channelsByAlias: Map<ChannelAlias, Channel> = new Map();
private constructor(pcastHttpRequests: PCastHttpRequests) { constructor(pcastHttpRequests: PCastHttpRequests) {
this._httpRequests = pcastHttpRequests; this._httpRequests = pcastHttpRequests;
this.initialize(); this.initialize();
} }
@@ -156,7 +156,7 @@ export class Channels {
throw new ChannelError(`Channel not found: ${alias}`, 'CHANNEL_NOT_FOUND'); throw new ChannelError(`Channel not found: ${alias}`, 'CHANNEL_NOT_FOUND');
} }
return this.getChannelMembers(channel.channelId); return this.getMembers(channel.channelId);
} }
public async delete({channelId, alias}: {channelId?: string; alias?: string}): Promise<Channel> { public async delete({channelId, alias}: {channelId?: string; alias?: string}): Promise<Channel> {
@@ -170,7 +170,7 @@ export class Channels {
throw new ChannelError('Unable to find room to delete', 'NOT_FOUND'); throw new ChannelError('Unable to find room to delete', 'NOT_FOUND');
} }
const route = `/channel/${encodeURIComponent(channelId)}`; const route = `/channel/${encodeURIComponent(channelIdToDelete)}`;
const response = await this._httpRequests.request<ChannelResponse>(HttpMethod.DELETE, route); const response = await this._httpRequests.request<ChannelResponse>(HttpMethod.DELETE, route);
if (!response.channel) { if (!response.channel) {

View File

@@ -1,14 +1,14 @@
import {PCastApi} from './PCastApi'; import {PCastApi} from './PCastApi';
import type {Channels, Streams, Reporting, ReportKind, ViewingReportKind} from './pcast'; import type {Channels, Streams, Reporting, ReportKind, ViewingReportKind} from './apis';
import type {ChannelId, Channel, ChannelAlias, Member, ChannelError} from './pcast/Channels'; import type {ChannelId, Channel, ChannelAlias, Member, ChannelError} from './apis/Channels';
import type {HttpMethod} from './net/http/HttpMethod'; import type {HttpMethod} from './net/http/HttpMethod';
import type {HttpRequestError} from './net/http/HttpRequests'; import type {HttpRequestError} from './net/http/HttpRequests';
import type {ChannelResponse, ChannelsResponse, MembersResponse} from './pcast/IResponse'; import type {ChannelResponse, ChannelsResponse, MembersResponse} from './apis/IResponse';
import type {ApplicationCredentials} from './pcast/PCastRequests'; import type {ApplicationCredentials} from './apis/PCastRequests';
import type {PublishingReportOptions, ViewingReportOptions} from './pcast/Reporting'; import type {PublishingReportOptions, ViewingReportOptions} from './apis/Reporting';
import type {ReportKindType} from './pcast/ReportKind'; import type {ReportKindType} from './apis/ReportKind';
import type {ViewingReportKindType} from './pcast/ViewingReportKind'; import type {ViewingReportKindType} from './apis/ViewingReportKind';
export type {Channels, Streams, Reporting, ReportKind, ViewingReportKind}; export type {Channels, Streams, Reporting, ReportKind, ViewingReportKind};
export type {ChannelId, Channel, ChannelAlias, Member, ChannelError}; export type {ChannelId, Channel, ChannelAlias, Member, ChannelError};