Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | import * as spec from "@jsii/spec";
import { getAssetsPath } from "./util";
import { API_PATHS } from "../../constants/url";
// These fields are removed from assembly.json during processing to save space,
// and we don't need them here in the client.
// See https://github.com/cdklabs/construct-hub/pull/567
export type SlimAssembly = Omit<
spec.Assembly,
"types" | "readme" | "dependencyClosure"
>;
/**
* Fetch assembly of a specific package from the backend.
*/
export const fetchAssembly = async (
name: string,
version: string,
scope?: string
): Promise<SlimAssembly> => {
const assemblyPath = `${getAssetsPath(name, version, scope)}${
API_PATHS.ASSEMBLY_SUFFIX
}`;
const response = await fetch(assemblyPath);
if (!response.ok) {
throw new Error(
`Failed fetching assembly for ${assemblyPath}: ${response.statusText}`
);
}
return response.json();
};
|