@autorest/openapi-to-typespec
Version:
Autorest plugin to scaffold a Typespec definition from an OpenAPI document
48 lines • 1.68 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.setSession = setSession;
exports.getSession = getSession;
exports.setArmCommonTypeVersion = setArmCommonTypeVersion;
exports.addArmCommonTypeModel = addArmCommonTypeModel;
exports.isCommonTypeModel = isCommonTypeModel;
exports.getArmCommonTypeVersion = getArmCommonTypeVersion;
exports.getUserSetArmCommonTypeVersion = getUserSetArmCommonTypeVersion;
let _session;
let _armCommonTypeVersion;
let _userSetArmCommonTypeVersion;
const commonTypeModels = new Set();
function setSession(session) {
_session = session;
}
function getSession() {
return _session;
}
function setArmCommonTypeVersion(version) {
if (_userSetArmCommonTypeVersion === undefined) {
_userSetArmCommonTypeVersion = version;
}
}
function addArmCommonTypeModel(model) {
commonTypeModels.add(model);
}
function isCommonTypeModel(model) {
const lowerCaseModel = model.toLowerCase();
return Array.from(commonTypeModels)
.map((m) => m.toLowerCase())
.includes(lowerCaseModel);
}
function getArmCommonTypeVersion() {
if (!_armCommonTypeVersion) {
if (["v3", "v4", "v5", "v6"].includes(_userSetArmCommonTypeVersion)) {
_armCommonTypeVersion = _userSetArmCommonTypeVersion;
}
else {
_armCommonTypeVersion = "v3"; // We hardcode the common type version to v3 if it's not set or the value is not valid, otherwise no model can extend a resource model.
}
}
return _armCommonTypeVersion;
}
function getUserSetArmCommonTypeVersion() {
return _userSetArmCommonTypeVersion;
}
//# sourceMappingURL=autorest-session.js.map