@sap/adp-abap
Version:
abap service for all yeoman generators
73 lines • 3.48 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const store_1 = require("@sap-ux/store");
const adp_common_1 = require("@sap/adp-common");
class LocalDestinationService {
constructor() {
this.isExtensionInstalled = adp_common_1.VSCodeUtils.isExtensionInstalled("sapse.sap-ux-application-modeler-extension");
}
getIsExtensionInstalled() {
return this.isExtensionInstalled;
}
shouldGetLocalSystemAuthDetails() {
return !adp_common_1.EnvironmentUtils.isRunningInBAS() && this.isExtensionInstalled;
}
getDestinationRequiresAuthentication(system) {
return __awaiter(this, void 0, void 0, function* () {
if (!this.isExtensionInstalled) {
return true;
}
const systems = yield this.getLocalSystems();
if (systems.length === 0) {
return true;
}
return !(systems.filter((backEndSystem) => backEndSystem.url === system).length > 0 || systems.filter((backEndSystem) => backEndSystem.name === system).length > 0);
});
}
getDestinationNames() {
return __awaiter(this, void 0, void 0, function* () {
const systems = yield this.getLocalSystems();
return systems
.map((system) => system.name)
.sort((a, b) => {
return a.toLowerCase().localeCompare(b.toLowerCase(), "en", { sensitivity: "base" });
});
});
}
getSystemAuthDetails(system) {
return __awaiter(this, void 0, void 0, function* () {
const localSystems = yield this.getLocalSystems();
let foundSystem = localSystems.find((backEndSystem) => backEndSystem.name === system);
if (!foundSystem) {
foundSystem = localSystems.find((backEndSystem) => backEndSystem.url === system);
}
return foundSystem;
});
}
getSystemNameByUrl(systemUrl) {
return __awaiter(this, void 0, void 0, function* () {
const localSystems = yield this.getLocalSystems();
const foundSystemByUrl = localSystems.find((backEndSystem) => backEndSystem.url === systemUrl);
return foundSystemByUrl === null || foundSystemByUrl === void 0 ? void 0 : foundSystemByUrl.name;
});
}
getLocalSystems() {
return __awaiter(this, void 0, void 0, function* () {
const systemStore = yield (0, store_1.getService)({ entityName: "system" });
let systems = yield systemStore.getAll();
systems = systems.filter((system) => !system.serviceKeys);
return systems;
});
}
}
exports.default = LocalDestinationService;
//# sourceMappingURL=LocalDestinationService.js.map