Add TypeScript integrations package
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import type { IntegrationRegistry } from '../core/index.js';
|
||||
|
||||
export const commandSetup = async (registryArg: IntegrationRegistry, domainArg: string) => {
|
||||
const integration = registryArg.get(domainArg) as any;
|
||||
if (!integration) {
|
||||
throw new Error(`Integration not found: ${domainArg}`);
|
||||
}
|
||||
if (!integration.configFlow) {
|
||||
return {
|
||||
domain: domainArg,
|
||||
status: 'no-config-flow',
|
||||
};
|
||||
}
|
||||
const step = await integration.configFlow.start(
|
||||
{
|
||||
source: 'manual',
|
||||
integrationDomain: domainArg,
|
||||
id: `${domainArg}:manual`,
|
||||
},
|
||||
{}
|
||||
);
|
||||
return {
|
||||
domain: domainArg,
|
||||
step: {
|
||||
kind: step.kind,
|
||||
title: step.title,
|
||||
description: step.description,
|
||||
fields: step.fields,
|
||||
error: step.error,
|
||||
},
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user