Line data Source code
1 : import type { ClientFunctionSpec } from './clfn_spec.js';
2 :
3 : /// The client function specs of extensions/, as JSON that Bazel generates from their sources. Each one is a chunk of its own, so that a
4 : /// connection only loads it when it needs it.
5 1 : const SPECS = import.meta.glob<ClientFunctionSpec>('@dashql/extensions/*/clfn/spec/spec.json', { import: 'default' });
6 :
7 : /// Load the client function spec of an extension by its folder in extensions/, such as `d360-api`
8 1 : export async function loadClientFunctionSpec(folder: string): Promise<ClientFunctionSpec> {
9 1 : const suffix = `/${folder}/clfn/spec/spec.json`;
10 1 : const load = Object.entries(SPECS).find(([path]) => path.endsWith(suffix))?.[1];
11 1 : if (load === undefined) {
12 1 : throw new Error(`no extension in the folder ${folder}`);
13 : }
14 1 : return load();
15 1 : }
|