/** * Reference connector: the minimal honest implementation. Every real * connector copies this shape and fills in a provider API. */ import type { ConnectorCapabilities, ConnectorConnection, NormalizedIdentity, NormalizedPost, Publication, } from "@tactical-media-broadcast-hub/core"; import { assertValidManifest, type ConnectorManifest, type PlatformConnector, } from "@tactical-media-broadcast-hub/connector-sdk"; const CAPABILITIES: ConnectorCapabilities = { publishText: true, }; export function createExampleConnector(): PlatformConnector { const manifest: ConnectorManifest = { id: "example", displayName: "Example (reference connector)", capabilities: CAPABILITIES, connectionFields: [ { name: "apiToken", label: "API token", required: true, secret: true }, ], }; return { manifest: () => { assertValidManifest(manifest); return manifest; }, async authorize() { throw new Error("example connector does not implement OAuth"); }, async getIdentity(connection: ConnectorConnection): Promise { return { provider: manifest.id, remoteId: connection.id, handle: "example@example", displayName: "Example Account", }; }, async publish(connection: ConnectorConnection, post: NormalizedPost): Promise { return { id: `pub-${post.text.length}`, workspaceId: connection.workspaceId, draftId: "direct", connectionId: connection.id, remoteId: `remote-${post.text.length}`, publishedAt: new Date(), providerMetadata: post.providerMetadata, }; }, }; }