feat(companion): add bootstrap manifest export for app packaging
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
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,
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user