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 | 1x 3x 3x 3x 2x 3x 1x 2x 1x | import { getPackageChangelog } from "libs/api/package";
import { response } from "libs/handler-lib";
import { events } from "shared-types";
export const getPackageType = async (packageId: string) => {
// use event of current package to determine how ID should be formatted
try {
const packageChangelog = await getPackageChangelog(packageId);
const packageSubmissionType = packageChangelog.hits.hits.find(
(pkg) => pkg._source.event in events,
);
if (!packageSubmissionType) {
throw new Error("The type of package could not be determined.");
}
return packageSubmissionType._source.event;
} catch (error) {
return response({
statusCode: 500,
body: {
message: error.message || "An error occurred determining the package submission type.",
},
});
}
};
|