@sap/generator-adaptation-project
Version:
Adaptation project allows you to create an app variant for an existing SAP Fiori elements-based or SAPUI5 freestyle application, without changing the original application.
76 lines • 3.78 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 adp_common_1 = require("@sap/adp-common");
class AppIdentifier {
validateSelectedApplication(applicationData, checkForAdpOverAdpSupport, checkForAdpOverAdpPartialSupport, manifest) {
return __awaiter(this, void 0, void 0, function* () {
if (!applicationData) {
throw new Error(adp_common_1.Messages.SELECT_CANNOT_BE_EMPTY_ERROR(adp_common_1.Messages.APPLICATION));
}
AppIdentifier.isV4AppInternalMode = false;
const fileType = applicationData.fileType;
this.setAdpOverAdpSupport(checkForAdpOverAdpSupport, checkForAdpOverAdpPartialSupport, fileType);
yield this.validateSmartTemplateApplication(manifest);
});
}
validateSmartTemplateApplication(appManifest) {
return __awaiter(this, void 0, void 0, function* () {
const manifest = appManifest;
const isV4App = adp_common_1.AppUtils.isV4App(manifest);
AppIdentifier.isV4AppInternalMode = isV4App && (yield this.isInternalMode());
const sAppType = adp_common_1.AppUtils.getApplicationType(manifest);
if (adp_common_1.AppUtils.isSupportedAppTypeForAdaptationProject(sAppType)) {
if (manifest["sap.ui5"]) {
if (manifest["sap.ui5"].flexEnabled === false) {
throw new Error(adp_common_1.Messages.I18N_KEY_APPLICATION_DO_NOT_SUPPORT_ADAPTATION);
}
this._checkForSyncLoadedViews(manifest["sap.ui5"]);
}
}
else {
throw new Error(adp_common_1.Messages.ADAPTATIONPROJECTPLUGIN_SMARTTEMPLATE_PROJECT_CHECK);
}
});
}
setAdpOverAdpSupport(checkForAdpOverAdpSupport, checkForAdpOverAdpPartialSupport, fileType) {
AppIdentifier.isSupportedAdpOverAdp = !(checkForAdpOverAdpSupport && fileType === "appdescr_variant");
AppIdentifier.isPartiallySupportedAdpOverAdp = checkForAdpOverAdpPartialSupport && fileType === "appdescr_variant";
}
_checkForSyncLoadedViews(ui5settings) {
if (ui5settings["rootView"]) {
this.appSync = !ui5settings["rootView"]["async"];
return;
}
if (ui5settings["routing"] && ui5settings["routing"]["config"]) {
this.appSync = !ui5settings["routing"]["config"]["async"];
return;
}
this.appSync = false;
}
appViewsLoadedSynchronously() {
return this.appSync;
}
isInternalMode() {
return adp_common_1.EnvironmentUtils.isInternalUsage();
}
getIsV4InternalMode() {
return AppIdentifier.isV4AppInternalMode;
}
getIsSupportedAdpOverAdp() {
return AppIdentifier.isSupportedAdpOverAdp && !AppIdentifier.isPartiallySupportedAdpOverAdp;
}
getIsPartiallySupportedAdpOverAdp() {
return AppIdentifier.isPartiallySupportedAdpOverAdp;
}
}
exports.default = AppIdentifier;
//# sourceMappingURL=AppIdentifier.js.map