/** * @typedef {object} MetaArgument * @property {object} layout The layout the service is using. * @property {object} meta The base meta object created by the service. */ /** * @typedef {object} LayoutService * @property {object} refs Object containing dot notation paths. * @property {string} refs.dataPages Dot notation path to cube's data pages. * @property {object} mode Object containing properties describing cube's mode. * @property {boolean} mode.S If the cube is mode S. * @property {boolean} mode.P If the cube is mode P. * @property {boolean} mode.K If the cube is mode K. * @property {boolean} mode.T If the cube is mode T. * @property {object} meta Object containing meta data. * @property {object} meta.size Object containing information about the cube's size. * @property {number} meta.size.x Cube's size on the x axis. * @property {number} meta.size.y Cube's size on the y axis. * @property {array} meta.size.dimensions Sizes of cube's dimensions. * @property {number} meta.dimensionCount Number of dimensions in the cube. * @property {number} meta.measureCount Number of measures in the cube. * @property {boolean} meta.hasMultipleDimensions If the cube has multiple dimensions. * @property {boolean} meta.hasMultipleMeasures If the cube has multiple measures. * @property {boolean} meta.isOneDimensional If the cube is one dimensional. * @property {boolean} meta.isTwoDimensional If the cube is two dimensional. * @property {object} meta.filteredFields Object containing properties describing filtered fields. * @property {array} meta.filteredFields.dimensions Array of indexes of dimensions filtered out. Will only contain something if `experimental.filter` is set to `true`. * @property {array} meta.filteredFields.measures Array of indexes of measures filtered out. Will only contain something if `experimental.filter` is set to `true`. * @property {function():object} getLayout Gets the layout. * @property {function(string, *):*} getLayoutValue Gets the value at reference path of the layout. * @property {function(string, *):undefined} setLayoutValue Sets the value at reference path of the layout. * @property {function():object} getHyperCube Gets the hyper cube. * @property {function(string, *):*} getHyperCubeValue Gets the value at reference path of the hyper cube. * @property {function(string, *):undefined} setHyperCubeValue Sets the value at reference path of the hyper cube. * @property {function():array} getDataPages Gets the data pages. * @property {function(array):undefined} setDataPages Sets the data pages. */ /** * Creates a layout-service. * * @param {object} config Configuration object. * @param {object} config.source Engine layout to base service on. * @param {function(MetaArgument):object} [config.metaAdditionsFn] Function that returns object with additional data to be added to the meta. * @param {object} config.experimental Configuration object for experimental features subject to change. * @param {boolean} config.experimental.filter If should filter out dimensions and measures with error code 7005 from the layout. * * @returns {LayoutService} The created layout-service. * * @example * * const service = createLayoutService({ * source: { qHyperCube: { qDimensionInfo: [], qMeasureInfo: [{ qFallbackTitle: 'A' }] } }, * metaAdditionsFn: ({ layout }) => { * return { * isDimensionless: layout.qHyperCube.qDimensionInfo.length === 0, * }; * }, * }); * * console.log(service.meta.isDimensionless); * // => true * * service.getLayoutValue('qHyperCube.qMeasureInfo.0.qFallbackTitle', 'B'); * // => 'A' */ export default function createLayoutService({ source, metaAdditionsFn, experimental }: { source: object; metaAdditionsFn?: ((arg0: MetaArgument) => object) | undefined; experimental: { filter: boolean; }; }): LayoutService; export type MetaArgument = { /** * The layout the service is using. */ layout: object; /** * The base meta object created by the service. */ meta: object; }; export type LayoutService = { /** * Object containing dot notation paths. */ refs: { dataPages: string; }; /** * Object containing properties describing cube's mode. */ mode: { S: boolean; P: boolean; K: boolean; T: boolean; }; /** * Object containing meta data. */ meta: { size: { x: number; y: number; dimensions: array; }; dimensionCount: number; measureCount: number; hasMultipleDimensions: boolean; hasMultipleMeasures: boolean; isOneDimensional: boolean; isTwoDimensional: boolean; filteredFields: { dimensions: array; measures: array; }; }; /** * Gets the layout. */ getLayout: () => object; /** * Gets the value at reference path of the layout. */ getLayoutValue: (arg0: string, arg1: any) => any; /** * Sets the value at reference path of the layout. */ setLayoutValue: (arg0: string, arg1: any) => undefined; /** * Gets the hyper cube. */ getHyperCube: () => object; /** * Gets the value at reference path of the hyper cube. */ getHyperCubeValue: (arg0: string, arg1: any) => any; /** * Sets the value at reference path of the hyper cube. */ setHyperCubeValue: (arg0: string, arg1: any) => undefined; /** * Gets the data pages. */ getDataPages: () => array; /** * Sets the data pages. */ setDataPages: (arg0: array) => undefined; };