UNPKG

@bbc/sofie-server-core-integration

Version:
125 lines 5.28 kB
import { EventEmitter } from 'events'; import { PeripheralDeviceCategory, PeripheralDeviceStatusObject, PeripheralDeviceType } from '@bbc/sofie-shared-lib/dist/peripheralDevice/peripheralDeviceAPI'; import { PeripheralDeviceAPIMethods } from '@bbc/sofie-shared-lib/dist/peripheralDevice/methodsAPI'; import { DDPConnector } from './ddpConnector.js'; import { DDPConnectorOptions, Observer } from './ddpClient.js'; import { DeviceConfigManifest } from './configManifest.js'; import { PeripheralDeviceId } from '@bbc/sofie-shared-lib/dist/core/model/Ids'; import { ExternalPeripheralDeviceAPI } from './methods.js'; import { PeripheralDeviceForDevice } from '@bbc/sofie-shared-lib/dist/core/model/peripheralDevice'; import { ProtectedString } from '@bbc/sofie-shared-lib/dist/lib/protectedString'; import { ChildCoreOptions, CoreConnectionChild } from './CoreConnectionChild.js'; import { ParametersOfFunctionOrNever, SubscriptionId } from './subscriptions.js'; import { PeripheralDevicePubSubCollections, PeripheralDevicePubSubTypes } from '@bbc/sofie-shared-lib/dist/pubsub/peripheralDevice'; export interface CoreCredentials { deviceId: PeripheralDeviceId; deviceToken: string; } export interface CoreOptions extends CoreCredentials { /** * Category of the Device */ deviceCategory: PeripheralDeviceCategory; /** * Type of the Device */ deviceType: PeripheralDeviceType; /** * Name of the device * eg 'MOS Gateway' */ deviceName: string; /** * URL of documentation for this Device */ documentationUrl: string; versions: { [libraryName: string]: string; }; watchDog?: boolean; configManifest: DeviceConfigManifest; } export type CollectionDocCheck<Doc> = Doc extends { _id: ProtectedString<any> | string; } ? Doc : never; export interface Collection<DBObj extends { _id: ProtectedString<any> | string; }> { find: (selector?: any) => Array<DBObj>; findOne: (docId: DBObj['_id']) => DBObj | undefined; } export type CoreConnectionEvents = { connected: []; connectionChanged: [connected: boolean]; disconnected: []; failed: [err: Error]; error: [err: Error | string]; }; export declare class CoreConnection<PubSubTypes = PeripheralDevicePubSubTypes, PubSubCollections = PeripheralDevicePubSubCollections> extends EventEmitter<CoreConnectionEvents> { private _ddp; private _methodQueue; private _subscriptions; private _children; private _coreOptions; private _timeSync; private _watchDog?; private _watchDogPingResponse; private _connected; private _sentConnectionId; private _pinger; private _destroyed; private _peripheralDeviceApi; private _peripheralDeviceApiLowPriority; constructor(coreOptions: CoreOptions); init(ddpOptions0?: DDPConnectorOptions): Promise<PeripheralDeviceId>; destroy(): Promise<void>; createChild(coreOptions: ChildCoreOptions): Promise<CoreConnectionChild<PubSubTypes, PubSubCollections>>; removeChild(childToRemove: CoreConnectionChild<any, any>): void; onConnectionChanged(cb: (connected: boolean) => void): void; onConnected(cb: () => void): void; onDisconnected(cb: () => void): void; onError(cb: (err: Error | string) => void): void; onFailed(cb: (err: Error) => void): void; get ddp(): DDPConnector; get connected(): boolean; get deviceId(): PeripheralDeviceId; get coreMethods(): ExternalPeripheralDeviceAPI; get coreMethodsLowPriority(): ExternalPeripheralDeviceAPI; setStatus(status: PeripheralDeviceStatusObject): Promise<PeripheralDeviceStatusObject>; /** * This should not be used directly, use the `coreMethods` wrapper instead. * Call a meteor method * @param methodName The name of the method to call * @param attrs Parameters to the method * @returns Resopnse, if any */ callMethodRaw(methodName: string, attrs: Array<any>): Promise<any>; callMethodLowPrioRaw(methodName: PeripheralDeviceAPIMethods | string, attrs: Array<any>): Promise<any>; unInitialize(): Promise<PeripheralDeviceId>; getPeripheralDevice(): Promise<PeripheralDeviceForDevice>; getCollection<K extends keyof PubSubCollections>(collectionName: K): Collection<CollectionDocCheck<PubSubCollections[K]>>; /** * Subscribe to a DDP publication * Upon reconnecting to Sofie, this publication will be restarted */ autoSubscribe<Key extends keyof PubSubTypes>(publicationName: Key, ...params: ParametersOfFunctionOrNever<PubSubTypes[Key]>): Promise<SubscriptionId>; /** * Unsubscribe from subscroption to a DDP publication */ unsubscribe(subscriptionId: SubscriptionId): void; /** * Unsubscribe from all subscriptions to DDP publications */ unsubscribeAll(): void; observe<K extends keyof PubSubCollections>(collectionName: K): Observer<CollectionDocCheck<PubSubCollections[K]>>; getCurrentTime(): number; hasSyncedTime(): boolean; syncTimeQuality(): number | null; setPingResponse(message: string): void; private _emitError; private _setConnected; private _maybeSendInit; private _sendInit; private _watchDogCheck; } //# sourceMappingURL=coreConnection.d.ts.map