Self-hosted multi-platform broadcast newsroom for activist collectives: publishing pipeline with group approval and DST-proof scheduling, TweetDeck-style column wall with hostile-content-safe rendering, live control room with Auto Director, bridged chat governance with polls and quorum, distributed sandboxed transcode workers, encrypted content-addressed archive, monthly analytics. MIT licensed. See README.md and docs/.
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import type { PlatformConnector } from "./types.js";
|
|
import { UnknownProviderError } from "./errors.js";
|
|
|
|
export type ConnectorFactory = () => PlatformConnector;
|
|
|
|
/**
|
|
* Provider registry. Adding a connector = registering here; the rest of the
|
|
* application resolves by provider id and never switches on names.
|
|
*/
|
|
export class ConnectorRegistry {
|
|
private readonly connectors = new Map<string, PlatformConnector>();
|
|
|
|
register(connector: PlatformConnector): void {
|
|
const { id } = connector.manifest();
|
|
if (this.connectorsHas(id)) {
|
|
throw new Error(`connector "${id}" already registered`);
|
|
}
|
|
this.connectors.set(id, connector);
|
|
}
|
|
|
|
get(providerId: string): PlatformConnector {
|
|
const connector = this.connectors.get(providerId);
|
|
if (connector === undefined) throw new UnknownProviderError(providerId);
|
|
return connector;
|
|
}
|
|
|
|
has(providerId: string): boolean {
|
|
return this.connectors.has(providerId);
|
|
}
|
|
|
|
list(): PlatformConnector[] {
|
|
return [...this.connectors.values()];
|
|
}
|
|
|
|
private connectorsHas(id: string): boolean {
|
|
return this.connectors.has(id);
|
|
}
|
|
|
|
}
|
|
|
|
export const CONNECTOR_REGISTRY = Symbol("CONNECTOR_REGISTRY");
|