@apistudio/apim-cli
Version:
CLI for API Management Products
34 lines (33 loc) • 1.15 kB
JavaScript
import { isNullOrUndefined } from "../common/data-helper.js";
import { COLON, POLICY } from "../../constants/app-constants.js";
import { isPolicyKind } from "./asset-kinds/policy-helper.js";
const isValidAsset = (asset) => {
if (isNullOrUndefined(asset)) {
return false;
}
if (isNullOrUndefined(asset.kind)) {
return false;
}
if (isNullOrUndefined(asset.metadata)) {
return false;
}
return (!isNullOrUndefined(asset.metadata.name) &&
!isNullOrUndefined(asset.metadata.version));
};
const isValidAssetRefValue = (assetRefValue) => {
if (isNullOrUndefined(assetRefValue)) {
return false;
}
return (assetRefValue.split(COLON).length >= 1 &&
assetRefValue.split(COLON).length <= 3);
};
const hasNamespace = (asset) => {
if (isNullOrUndefined(asset) || isNullOrUndefined(asset.metadata)) {
return false;
}
return !isNullOrUndefined(asset.metadata.namespace);
};
const getTargetModelAssetKind = (kind) => {
return isPolicyKind(kind) ? POLICY : kind;
};
export { isValidAsset, hasNamespace, isValidAssetRefValue, getTargetModelAssetKind, };