feat(companion): add runtime bootstrapNode helper
This commit is contained in:
@@ -23,6 +23,7 @@ export type {
|
||||
GetCanvasArtifactInput,
|
||||
DeleteCanvasArtifactInput,
|
||||
NodeRegisterResult,
|
||||
NodeBootstrapResult,
|
||||
NodeCapabilitiesResult,
|
||||
NodeStatusSetResult,
|
||||
NodeLocationSetResult,
|
||||
|
||||
@@ -267,6 +267,36 @@ describe('CompanionRuntimeClient', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('bootstraps node registration and capabilities in one call', async () => {
|
||||
if (!LISTEN_ALLOWED) {
|
||||
return;
|
||||
}
|
||||
|
||||
const client = new CompanionRuntimeClient({
|
||||
url: `ws://127.0.0.1:${TEST_PORT}`,
|
||||
token: TEST_TOKEN,
|
||||
});
|
||||
await client.connect();
|
||||
|
||||
try {
|
||||
const boot = await client.bootstrapNode(
|
||||
{
|
||||
nodeId: 'bootstrap-runtime-node',
|
||||
role: 'companion',
|
||||
capabilities: ['ui.canvas'],
|
||||
},
|
||||
{ includeSystemCapabilities: true },
|
||||
);
|
||||
|
||||
expect(boot.register.registered).toBe(true);
|
||||
expect(boot.capabilities.node.id).toBe('bootstrap-runtime-node');
|
||||
expect(boot.systemCapabilities?.nodes.enabled).toBe(true);
|
||||
expect(boot.systemCapabilities?.nodes.registered).toBe(true);
|
||||
} finally {
|
||||
client.disconnect();
|
||||
}
|
||||
});
|
||||
|
||||
it('updates status/location/push and exposes them through system.nodes', async () => {
|
||||
if (!LISTEN_ALLOWED) {
|
||||
return;
|
||||
|
||||
@@ -89,6 +89,12 @@ export interface NodeCapabilitiesResult {
|
||||
};
|
||||
}
|
||||
|
||||
export interface NodeBootstrapResult {
|
||||
register: NodeRegisterResult;
|
||||
capabilities: NodeCapabilitiesResult;
|
||||
systemCapabilities?: SystemCapabilitiesResult;
|
||||
}
|
||||
|
||||
export interface NodeStatus {
|
||||
platform: 'macos' | 'ios' | 'android' | 'linux' | 'windows' | 'unknown';
|
||||
appVersion?: string;
|
||||
@@ -459,6 +465,26 @@ export class CompanionRuntimeClient {
|
||||
});
|
||||
}
|
||||
|
||||
async bootstrapNode(
|
||||
input: RegisterNodeInput,
|
||||
options?: { includeSystemCapabilities?: boolean },
|
||||
): Promise<NodeBootstrapResult> {
|
||||
const register = await this.registerNode(input);
|
||||
const capabilities = await this.getNodeCapabilities();
|
||||
if (options?.includeSystemCapabilities) {
|
||||
const systemCapabilities = await this.getSystemCapabilities();
|
||||
return {
|
||||
register,
|
||||
capabilities,
|
||||
systemCapabilities,
|
||||
};
|
||||
}
|
||||
return {
|
||||
register,
|
||||
capabilities,
|
||||
};
|
||||
}
|
||||
|
||||
getNodeCapabilities(): Promise<NodeCapabilitiesResult> {
|
||||
return this.call<NodeCapabilitiesResult>('node.capabilities.get');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user