Skip to content

Commit 18af79f

Browse files
committed
chore: add common interfaces for Connector and CoreHandlers in server-core-integration
1 parent 5b590dd commit 18af79f

File tree

7 files changed

+23
-14
lines changed

7 files changed

+23
-14
lines changed

packages/mos-gateway/src/connector.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
stringifyError,
99
HealthConfig,
1010
HealthEndpoints,
11+
IConnector,
1112
} from '@sofie-automation/server-core-integration'
1213

1314
export interface Config {
@@ -21,7 +22,7 @@ export interface DeviceConfig {
2122
deviceId: PeripheralDeviceId
2223
deviceToken: string
2324
}
24-
export class Connector {
25+
export class Connector implements IConnector {
2526
public initialized = false
2627
public initializedError: string | undefined = undefined
2728

packages/mos-gateway/src/coreHandler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
stringifyError,
1111
PeripheralDevicePubSub,
1212
PeripheralDevicePubSubCollectionsNames,
13+
ICoreHandler,
1314
} from '@sofie-automation/server-core-integration'
1415
import * as Winston from 'winston'
1516

@@ -29,7 +30,7 @@ export interface CoreConfig {
2930
/**
3031
* Represents a connection between mos-integration and Core
3132
*/
32-
export class CoreHandler {
33+
export class CoreHandler implements ICoreHandler {
3334
core: CoreConnection | undefined
3435
logger: Winston.Logger
3536
public _observers: Array<Observer<any>> = []

packages/playout-gateway/src/connector.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
stringifyError,
1010
HealthConfig,
1111
HealthEndpoints,
12+
IConnector,
1213
} from '@sofie-automation/server-core-integration'
1314

1415
export interface Config {
@@ -24,7 +25,7 @@ export interface DeviceConfig {
2425
deviceId: PeripheralDeviceId
2526
deviceToken: string
2627
}
27-
export class Connector {
28+
export class Connector implements IConnector {
2829
public initialized = false
2930
public initializedError: string | undefined = undefined
3031

packages/playout-gateway/src/coreHandler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
stringifyError,
1212
PeripheralDevicePubSub,
1313
PeripheralDevicePubSubCollectionsNames,
14+
ICoreHandler,
1415
} from '@sofie-automation/server-core-integration'
1516
import { MediaObject, DeviceOptionsAny, ActionExecutionResult } from 'timeline-state-resolver'
1617
import _ from 'underscore'
@@ -40,7 +41,7 @@ export interface MemoryUsageReport {
4041
/**
4142
* Represents a connection between the Gateway and Core
4243
*/
43-
export class CoreHandler {
44+
export class CoreHandler implements ICoreHandler {
4445
core!: CoreConnection
4546
logger: Logger
4647
public _observers: Array<Observer<any>> = []

packages/server-core-integration/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export * from './lib/coreConnection.js'
22
export * from './lib/configManifest.js'
33
export * from './lib/ddpClient.js'
4+
export * from './lib/gateway-types.js'
45
export * from './lib/health.js'
56
export * from './lib/methods.js'
67
export * from './lib/process.js'
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { StatusCode } from '@sofie-automation/shared-lib/dist/lib/status'
2+
3+
export interface IConnector {
4+
initialized: boolean
5+
initializedError: string | undefined
6+
}
7+
8+
export interface ICoreHandler {
9+
getCoreStatus: () => { statusCode: StatusCode; messages: string[] }
10+
connectedToCore: boolean
11+
}

packages/server-core-integration/src/lib/health.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Koa from 'koa'
22
import Router from '@koa/router'
33
import { StatusCode } from '@sofie-automation/shared-lib/dist/lib/status'
44
import { assertNever } from '@sofie-automation/shared-lib/dist/lib/lib'
5+
import { IConnector, ICoreHandler } from './gateway-types.js'
56

67
export interface HealthConfig {
78
/** If set, exposes health HTTP endpoints on the given port */
@@ -15,16 +16,8 @@ export interface HealthConfig {
1516
export class HealthEndpoints {
1617
private app = new Koa()
1718
constructor(
18-
private connector: {
19-
// Connector analog
20-
initialized: boolean
21-
initializedError: string | undefined
22-
},
23-
private coreHandler: {
24-
// CoreHandler analog
25-
getCoreStatus: () => { statusCode: StatusCode; messages: string[] }
26-
connectedToCore: boolean
27-
},
19+
private connector: IConnector,
20+
private coreHandler: ICoreHandler,
2821
private config: HealthConfig
2922
) {
3023
if (!config.port) return // disabled

0 commit comments

Comments
 (0)