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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | import { getAssetsPath } from "./util";
import { CDKType } from "../../constants/constructs";
import { API_PATHS } from "../../constants/url";
import { PackageTagConfig } from "../config";
export interface ConstructFramework {
name: CDKType;
majorVersion?: number;
}
export interface Metadata {
/**
* Describes the associated Construct framework for a library.
* Back-end will introduce a new metadata.constructFrameworks property to replace metadata.constructFramework
* @deprecated Use constructFrameworks instead
*/
constructFramework?: Partial<ConstructFramework>;
/**
* Describes the associated Construct frameworks for a library.
* Typically, libraries will be associated with a single framework, though some have no
* association or multiple associations.
*/
constructFrameworks?: ConstructFramework[];
date: string;
links?: {
npm: string;
};
packageLinks?: {
[key: string]: string;
};
packageTags?: PackageTagConfig[];
}
/**
* Fetch metadata of a specific package from the backend.
*/
export const fetchMetadata = async (
name: string,
version: string,
scope?: string
): Promise<Metadata> => {
let sanitizedVersion = version;
if (sanitizedVersion.startsWith("^")) {
sanitizedVersion = sanitizedVersion.substring(1, sanitizedVersion.length);
}
const metadataPath = `${getAssetsPath(name, version, scope)}${
API_PATHS.METADATA_SUFFIX
}`;
const response = await fetch(metadataPath);
if (!response.ok) {
throw new Error(
`Failed fetching metadata for ${metadataPath}: ${response.statusText}`
);
}
return response.json();
};
|