60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
import type { RegisterNodeInput, SetNodeStatusInput } from './runtimeClient.js';
|
|
|
|
export type CompanionBootstrapPlatform = SetNodeStatusInput['platform'];
|
|
|
|
export interface CompanionBootstrapManifest {
|
|
schemaVersion: 1;
|
|
generatedAt: string;
|
|
gateway: {
|
|
url: string;
|
|
token?: string;
|
|
};
|
|
node: Pick<RegisterNodeInput, 'nodeId' | 'role' | 'capabilities'> & {
|
|
platform: CompanionBootstrapPlatform;
|
|
};
|
|
runtime: {
|
|
heartbeatSeconds: number;
|
|
handoffTimeoutMs: number;
|
|
autoReconnect: boolean;
|
|
};
|
|
}
|
|
|
|
export interface CreateCompanionBootstrapManifestInput {
|
|
gatewayUrl: string;
|
|
gatewayToken?: string;
|
|
nodeId: string;
|
|
role: string;
|
|
platform: CompanionBootstrapPlatform;
|
|
capabilities: string[];
|
|
heartbeatSeconds: number;
|
|
handoffTimeoutMs: number;
|
|
autoReconnect: boolean;
|
|
generatedAt?: Date;
|
|
}
|
|
|
|
export function createCompanionBootstrapManifest(
|
|
input: CreateCompanionBootstrapManifestInput,
|
|
): CompanionBootstrapManifest {
|
|
const generatedAt = (input.generatedAt ?? new Date()).toISOString();
|
|
|
|
return {
|
|
schemaVersion: 1,
|
|
generatedAt,
|
|
gateway: {
|
|
url: input.gatewayUrl,
|
|
...(input.gatewayToken && input.gatewayToken.length > 0 ? { token: input.gatewayToken } : {}),
|
|
},
|
|
node: {
|
|
nodeId: input.nodeId,
|
|
role: input.role,
|
|
platform: input.platform,
|
|
capabilities: input.capabilities,
|
|
},
|
|
runtime: {
|
|
heartbeatSeconds: input.heartbeatSeconds,
|
|
handoffTimeoutMs: input.handoffTimeoutMs,
|
|
autoReconnect: input.autoReconnect,
|
|
},
|
|
};
|
|
}
|