{"size": 5006, "ext": "js", "max_stars_repo_path": "node_modules/@sap/ux-specification/dist/src/sync/v2/generate/analyticalListReport.js", "max_stars_repo_name": "lbritz/RiskApplication", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "node_modules/@sap/ux-specification/dist/src/sync/v2/generate/analyticalListReport.js", "max_issues_repo_name": "lbritz/RiskApplication", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "node_modules/@sap/ux-specification/dist/src/sync/v2/generate/analyticalListReport.js", "max_forks_repo_name": "lbritz/RiskApplication", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 58.8941176471, "max_line_length": 220, "alphanum_fraction": 0.6905713144}
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("./utils");
const import_1 = require("../import");
const common_1 = require("../../common");
const i18next_1 = __importDefault(require("i18next"));
const i18n_1 = require("../../../i18n/i18n");
const v2_1 = require("../../../v2");
/**
 * Generates an app specific schema out of the generic schema.
 * Generic types are replaced by information from the app specific annotations.
 *
 * @param genericSchema - generic JSON schema of a list report
 * @param entityTypeName - the base entity type of the given page
 * @param entityTypes - list of all entity types
 * @param page - page as defined in the manifest
 * @param manifest - manifest.json of the app
 * @param {ExtensionLogger} logger - Logger class for logging messages
 */
function generateAnalyticalListReportSchemaV2(genericSchema, entityTypeName, entityTypes, manifest, fragments, logger) {
    var _a, _b;
    // Initialize i18next
    i18n_1.initI18n();
    const appSchema = JSON.parse(JSON.stringify(genericSchema));
    appSchema['properties']['table']['anyOf'][0]['$ref'] = common_1.DEFINITION_LINK_PREFIX + 'ALPResponsiveTable<LineItems>';
    const tableDefinitionResponsive = JSON.parse(JSON.stringify(appSchema['definitions']['ALPResponsiveTable']));
    tableDefinitionResponsive['properties']['columns'].$ref = common_1.DEFINITION_LINK_PREFIX + 'LineItems';
    tableDefinitionResponsive['properties']['toolBar'].$ref = common_1.DEFINITION_LINK_PREFIX + common_1.TOOLBAR;
    appSchema['definitions']['ALPResponsiveTable<LineItems>'] = tableDefinitionResponsive;
    appSchema['properties']['table']['anyOf'][1]['$ref'] = common_1.DEFINITION_LINK_PREFIX + 'ALPGridTable<LineItems>';
    const tableDefinitionGrid = JSON.parse(JSON.stringify(appSchema['definitions']['ALPGridTable']));
    tableDefinitionGrid['properties']['columns'].$ref = common_1.DEFINITION_LINK_PREFIX + 'LineItems';
    tableDefinitionGrid['properties']['toolBar'].$ref = common_1.DEFINITION_LINK_PREFIX + common_1.TOOLBAR;
    appSchema['definitions']['ALPGridTable<LineItems>'] = tableDefinitionGrid;
    appSchema['properties']['table']['anyOf'][2]['$ref'] = common_1.DEFINITION_LINK_PREFIX + 'ALPAnalyticalTable<LineItems>';
    const tableDefinitionAnalytical = JSON.parse(JSON.stringify(appSchema['definitions']['ALPAnalyticalTable']));
    tableDefinitionAnalytical['properties']['columns'].$ref = common_1.DEFINITION_LINK_PREFIX + 'LineItems';
    tableDefinitionAnalytical['properties']['toolBar'].$ref = common_1.DEFINITION_LINK_PREFIX + common_1.TOOLBAR;
    appSchema['definitions']['ALPAnalyticalTable<LineItems>'] = tableDefinitionAnalytical;
    // Remove Custom Column non existing extensions - TreeTableColumnsExtension does not exist in ALP
    utils_1.removeElementsFromEnum(appSchema['definitions']['TableColumnExtensionTypeV2']['enum'], [
        v2_1.TableColumnExtensionTypeV2.TreeTableColumnsExtension
    ]);
    const entityType = entityTypes === null || entityTypes === void 0 ? void 0 : entityTypes.find((et) => et.name === entityTypeName);
    if (!entityType) {
        v2_1.log(logger, {
            severity: "error" /* Error */,
            message: i18next_1.default.t('NOENTITYTYPE', { entityType: entityTypeName }),
            location: {
                path: common_1.METADATAPATH
            }
        });
    }
    else {
        const lineItemAnnotation = (_b = (_a = entityType === null || entityType === void 0 ? void 0 : entityType.annotations) === null || _a === void 0 ? void 0 : _a.UI) === null || _b === void 0 ? void 0 : _b.LineItem;
        utils_1.addLineItemsType(appSchema, lineItemAnnotation, entityType);
        const pageKeys = [];
        const v2Page = import_1.findAnalyticalListPage(manifest[v2_1.ManifestSection.generic].pages, pageKeys);
        if (!v2Page) {
            v2_1.log(logger, {
                severity: "error" /* Error */,
                message: i18next_1.default.t('NOALP'),
                location: {
                    path: v2_1.MANIFESTPATH,
                    range: [v2_1.ManifestSection.generic]
                }
            });
            return;
        }
        utils_1.addListReportColumnExtensions(appSchema, entityType, v2Page, manifest, fragments);
        // Delete generic definitions that have been replaced
        delete appSchema['definitions']['ALPGridTable'];
        delete appSchema['definitions']['ALPResponsiveTable'];
        delete appSchema['definitions']['ALPAnalyticalTable'];
        delete appSchema['definitions']['GenericColumns'];
        delete appSchema['definitions']['ToolBar'];
        delete appSchema['definitions']['Actions'];
    }
    return appSchema;
}
exports.generateAnalyticalListReportSchemaV2 = generateAnalyticalListReportSchemaV2;
//# sourceMappingURL=analyticalListReport.js.map