chore: small refactor to move the handlers out into an extension point

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2024-06-19 17:09:53 +02:00
parent a82cbab3c4
commit 1fbd77fb56
10 changed files with 144 additions and 96 deletions
+21 -11
View File
@@ -80,22 +80,32 @@ export const scaffolderTemplatingExtensionPoint =
id: 'scaffolder.templating',
});
/**
* Autocomplete handler for the scaffolder.
* @alpha
*/
export type AutocompleteHandler = ({
resource,
token,
context,
}: {
resource: string;
token: string;
context: Record<string, string>;
}) => Promise<{ results: { title: string }[] }>;
/**
* Extension point for adding autocomplete handler providers
* @alpha
*/
export interface ScaffolderAutocompleteExtensionPoint {
addAutocompleteProvider(
provider: ({
type,
token,
query,
}: {
type: string;
token: string;
query: Record<string, string>;
}) => Promise<{ results: { title: string }[] }>,
): void;
addAutocompleteProvider({
id,
handler,
}: {
id: string;
handler: AutocompleteHandler;
}): void;
}
/**