Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gooddata

Package Overview
Dependencies
Maintainers
10
Versions
200
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gooddata - npm Package Compare versions

Comparing version 5.0.0-vojty-factory-method-2018-02-16T12-36-00-182Z to 5.0.0-vojty-factory-method-2018-03-01T09-38-56-648Z

lib/utils/visualizationObjectHelper.js

6

index.d.ts

@@ -397,2 +397,6 @@ // Copyright (C) 2007-2017, GoodData(R) Corporation. All rights reserved.

export declare function factory(domain?: string): ISdk;
export interface ISdkOptions {
domain?: string;
}
export declare function factory(options?: ISdkOptions): ISdk;

@@ -6,2 +6,3 @@ 'use strict';

});
exports.getAttributesDisplayForms = exports.loadAttributesMap = undefined;

@@ -14,2 +15,10 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _attributesMapLoader = require('./utils/attributesMapLoader');
var _visualizationObjectHelper = require('./utils/visualizationObjectHelper');
exports.loadAttributesMap = _attributesMapLoader.loadAttributesMap;
exports.getAttributesDisplayForms = _visualizationObjectHelper.getAttributesDisplayForms;
var REQUEST_DEFAULTS = {

@@ -16,0 +25,0 @@ types: ['attribute', 'metric', 'fact'],

1

lib/execution.js

@@ -21,3 +21,2 @@ 'use strict';

*/
function createModule(xhr, md) {

@@ -24,0 +23,0 @@ var loadAttributesMap = (0, _attributesMapLoader.createModule)(md);

@@ -30,2 +30,6 @@ 'use strict';

var _attributesMapLoader = require('../utils/attributesMapLoader');
var _visualizationObjectHelper = require('../utils/visualizationObjectHelper');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -78,6 +82,2 @@

function getDefinition(measure) {
return (0, _lodash.get)(measure, ['definition', 'measureDefinition'], {});
}
function getPoPDefinition(measure) {

@@ -87,8 +87,4 @@ return (0, _lodash.get)(measure, ['definition', 'popMeasureDefinition'], {});

function getMeasureFilters(measure) {
return (0, _lodash.get)(getDefinition(measure), 'filters', []);
}
function getAggregation(measure) {
return (0, _lodash.get)(getDefinition(measure), 'aggregation', '').toLowerCase();
return (0, _lodash.get)((0, _visualizationObjectHelper.getDefinition)(measure), 'aggregation', '').toLowerCase();
}

@@ -110,3 +106,3 @@

function allFiltersEmpty(item) {
return (0, _lodash.every)((0, _lodash.map)(getMeasureFilters(item), function (f) {
return (0, _lodash.every)((0, _lodash.map)((0, _visualizationObjectHelper.getMeasureFilters)(item), function (f) {
return isEmptyFilter(f);

@@ -121,6 +117,2 @@ }));

function isAttrMeasureFilter(measureFilter) {
return ((0, _lodash.get)(measureFilter, 'positiveAttributeFilter') || (0, _lodash.get)(measureFilter, 'negativeAttributeFilter')) !== undefined;
}
function getAttrTypeFromMap(dfUri, attributesMap) {

@@ -134,6 +126,2 @@ return (0, _lodash.get)((0, _lodash.get)(attributesMap, [dfUri], {}), ['attribute', 'content', 'type']);

function getAttrMeasureFilterDf(measureFilter) {
return (0, _lodash.get)(measureFilter, ['positiveAttributeFilter', 'displayForm', 'uri']) || (0, _lodash.get)(measureFilter, ['negativeAttributeFilter', 'displayForm', 'uri']);
}
function isAttrFilterNegative(attributeFilter) {

@@ -171,3 +159,3 @@ return (0, _lodash.get)(attributeFilter, 'negativeAttributeFilter') !== undefined;

function getFilterExpression(attributesMap, measureFilter) {
if (isAttrMeasureFilter(measureFilter)) {
if ((0, _visualizationObjectHelper.isAttributeMeasureFilter)(measureFilter)) {
return getAttrFilterExpression(measureFilter, attributesMap);

@@ -180,4 +168,4 @@ }

var aggregation = getAggregation(item).toUpperCase();
var objectUri = (0, _lodash.get)(getDefinition(item), 'item.uri');
var where = (0, _lodash.filter)((0, _lodash.map)(getMeasureFilters(item), (0, _lodash.partial)(getFilterExpression, attributesMap)), function (e) {
var objectUri = (0, _lodash.get)((0, _visualizationObjectHelper.getDefinition)(item), 'item.uri');
var where = (0, _lodash.filter)((0, _lodash.map)((0, _visualizationObjectHelper.getMeasureFilters)(item), (0, _lodash.partial)(getFilterExpression, attributesMap)), function (e) {
return !!e;

@@ -190,3 +178,3 @@ });

function getPercentMetricExpression(category, attributesMap, measure) {
var metricExpressionWithoutFilters = 'SELECT [' + (0, _lodash.get)(getDefinition(measure), 'item.uri') + ']';
var metricExpressionWithoutFilters = 'SELECT [' + (0, _lodash.get)((0, _visualizationObjectHelper.getDefinition)(measure), 'item.uri') + ']';

@@ -198,3 +186,3 @@ if (isDerived(measure)) {

var attributeUri = getAttrUriFromMap((0, _lodash.get)(category, 'displayForm.uri'), attributesMap);
var whereFilters = (0, _lodash.filter)((0, _lodash.map)(getMeasureFilters(measure), (0, _lodash.partial)(getFilterExpression, attributesMap)), function (e) {
var whereFilters = (0, _lodash.filter)((0, _lodash.map)((0, _visualizationObjectHelper.getMeasureFilters)(measure), (0, _lodash.partial)(getFilterExpression, attributesMap)), function (e) {
return !!e;

@@ -226,3 +214,3 @@ });

function getGeneratedMetricIdentifier(item, aggregation, expressionCreator, hasher, attributesMap) {
var _get$split = (0, _lodash.get)(getDefinition(item), 'item.uri', '').split('/'),
var _get$split = (0, _lodash.get)((0, _visualizationObjectHelper.getDefinition)(item), 'item.uri', '').split('/'),
_get$split2 = _slicedToArray(_get$split, 6),

@@ -234,3 +222,3 @@ prjId = _get$split2[3],

var hash = hasher(expressionCreator(item, attributesMap));
var hasNoFilters = (0, _lodash.isEmpty)(getMeasureFilters(item));
var hasNoFilters = (0, _lodash.isEmpty)((0, _visualizationObjectHelper.getMeasureFilters)(item));
var type = getMeasureType(item);

@@ -243,48 +231,6 @@

function isMeasure(bucketItem) {
return (0, _lodash.get)(bucketItem, 'measure') !== undefined;
}
function isCategory(bucketItem) {
return (0, _lodash.get)(bucketItem, 'visualizationAttribute') !== undefined;
}
function getBuckets(mdObj) {
return (0, _lodash.get)(mdObj, 'buckets', []);
}
function getMeasuresInBucket(bucket) {
return (0, _lodash.get)(bucket, 'items').reduce(function (list, bucketItem) {
if (isMeasure(bucketItem)) {
list.push((0, _lodash.get)(bucketItem, 'measure'));
}
return list;
}, []);
}
function getMeasures(buckets) {
return buckets.reduce(function (measuresList, bucket) {
return measuresList.concat(getMeasuresInBucket(bucket));
}, []);
}
function getCategoriesInBucket(bucket) {
return (0, _lodash.get)(bucket, 'items').reduce(function (list, bucketItem) {
if (isCategory(bucketItem)) {
list.push((0, _lodash.get)(bucketItem, 'visualizationAttribute'));
}
return list;
}, []);
}
function getCategories(buckets) {
return buckets.reduce(function (categoriesList, bucket) {
return categoriesList.concat(getCategoriesInBucket(bucket));
}, []);
}
function isDateCategory(category) {
function isDateAttribute(attribute) {
var attributesMap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return getAttrTypeFromMap((0, _lodash.get)(category, ['displayForm', 'uri']), attributesMap) !== undefined;
return getAttrTypeFromMap((0, _lodash.get)(attribute, ['displayForm', 'uri']), attributesMap) !== undefined;
}

@@ -361,4 +307,4 @@

function createContributionMetric(measure, mdObj, measureIndex, attributesMap) {
var category = (0, _lodash.first)(getCategories(getBuckets(mdObj)));
var getMetricExpression = (0, _lodash.partial)(getPercentMetricExpression, category, attributesMap);
var attribute = (0, _lodash.first)((0, _visualizationObjectHelper.getAttributes)(mdObj));
var getMetricExpression = (0, _lodash.partial)(getPercentMetricExpression, attribute, attributesMap);
var title = getBaseMetricTitle((0, _lodash.get)(measure, 'title'));

@@ -385,3 +331,3 @@ var hasher = (0, _lodash.partial)(getGeneratedMetricHash, title, CONTRIBUTION_METRIC_FORMAT);

function getOriginalMeasureForPoP(popMeasure, mdObj) {
return getMeasures(getBuckets(mdObj)).find(function (measure) {
return (0, _visualizationObjectHelper.getMeasures)(mdObj).find(function (measure) {
return (0, _lodash.get)(measure, 'localIdentifier') === (0, _lodash.get)(getPoPDefinition(popMeasure), ['measureIdentifier']);

@@ -399,3 +345,3 @@ });

var originalMeasureExpression = '[' + (0, _lodash.get)(getDefinition(originalMeasure), ['item', 'uri']) + ']';
var originalMeasureExpression = '[' + (0, _lodash.get)((0, _visualizationObjectHelper.getDefinition)(originalMeasure), ['item', 'uri']) + ']';
var getMetricExpression = (0, _lodash.partial)(getPoPExpression, attributeUri, originalMeasureExpression);

@@ -515,5 +461,4 @@

function getExecutionDefinitionsAndColumns(mdObj, options, attributesMap) {
var buckets = getBuckets(mdObj);
var measures = getMeasures(buckets);
var categories = getCategories(buckets);
var measures = (0, _visualizationObjectHelper.getMeasures)(mdObj);
var attributes = (0, _visualizationObjectHelper.getAttributes)(mdObj);

@@ -524,9 +469,9 @@ var metrics = (0, _lodash.flatten)((0, _lodash.map)(measures, function (measure, index) {

if (options.removeDateItems) {
categories = (0, _lodash.filter)(categories, function (category) {
return !isDateCategory(category, attributesMap);
attributes = (0, _lodash.filter)(attributes, function (attribute) {
return !isDateAttribute(attribute, attributesMap);
});
}
categories = (0, _lodash.map)(categories, (0, _lodash.partial)(categoryToElement, attributesMap, mdObj));
attributes = (0, _lodash.map)(attributes, (0, _lodash.partial)(categoryToElement, attributesMap, mdObj));
var columns = (0, _lodash.compact)((0, _lodash.map)([].concat(_toConsumableArray(categories), _toConsumableArray(metrics)), 'element'));
var columns = (0, _lodash.compact)((0, _lodash.map)([].concat(_toConsumableArray(attributes), _toConsumableArray(metrics)), 'element'));
return {

@@ -540,6 +485,8 @@ columns: columns,

function getAttributesMap(options, displayFormUris, projectId) {
if (options.attributesMap) {
return Promise.resolve(options.attributesMap);
}
return loadAttributesMap(projectId, displayFormUris);
var attributesMap = (0, _lodash.get)(options, 'attributesMap', {});
var missingUris = (0, _attributesMapLoader.getMissingUrisInAttributesMap)(displayFormUris, attributesMap);
return loadAttributesMap(projectId, missingUris).then(function (result) {
return _extends({}, attributesMap, result);
});
}

@@ -550,13 +497,4 @@

var buckets = getBuckets(mdObj);
var measures = getMeasures(buckets);
var categories = getCategories(buckets);
var attrMeasureFilters = (0, _lodash.filter)(measures.reduce(function (filters, measure) {
return filters.concat(getMeasureFilters(measure));
}, []), isAttrMeasureFilter);
var attrMeasureFiltersDfs = attrMeasureFilters.map(getAttrMeasureFilterDf);
var categoryDfs = categories.map(function (category) {
return (0, _lodash.get)(category, ['displayForm', 'uri']);
});
var attributesMapPromise = getAttributesMap(options, [].concat(_toConsumableArray(categoryDfs), _toConsumableArray(attrMeasureFiltersDfs)), projectId);
var allDfUris = (0, _visualizationObjectHelper.getAttributesDisplayForms)(mdObj);
var attributesMapPromise = getAttributesMap(options, allDfUris, projectId);

@@ -563,0 +501,0 @@ return attributesMapPromise.then(function (attributesMap) {

@@ -41,11 +41,10 @@ 'use strict';

*/
// const gooddata = { config, xhr, user, md, execution, project, catalogue, admin };
// export default gooddata;
// module.exports = gooddata;
// Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved.
function factory(domain) {
function factory() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var config = (0, _config.createModule)();
if (domain) {
config.setCustomDomain(domain);
if (options.domain) {
config.setCustomDomain(options.domain);
}

@@ -56,3 +55,2 @@ var xhr = (0, _xhr.createModule)(config);

return {
domain: domain,
config: config,

@@ -59,0 +57,0 @@ xhr: xhr,

@@ -6,2 +6,3 @@ 'use strict';

});
exports.getMissingUrisInAttributesMap = getMissingUrisInAttributesMap;
exports.createModule = createModule;

@@ -28,2 +29,9 @@

function getMissingUrisInAttributesMap(displayFormsUris, attributesMap) {
var uris = displayFormsUris || [];
return uris.filter(function (uri) {
return !attributesMap[uri];
});
}
function createModule(md) {

@@ -30,0 +38,0 @@ return function loadAttributesMap(projectId, attributeDisplayFormUris) {

{
"name": "gooddata",
"version": "5.0.0-vojty-factory-method-2018-02-16T12-36-00-182Z",
"version": "5.0.0-vojty-factory-method-2018-03-01T09-38-56-648Z",
"author": "GoodData",

@@ -47,3 +47,3 @@ "description": "GoodData JavaScript SDK",

"babel-register": "6.23.0",
"eslint-config-gooddata": "0.0.16",
"eslint-config-gooddata": "0.0.17",
"exports-loader": "0.6.3",

@@ -50,0 +50,0 @@ "fast-levenshtein": "2.0.6",

import { get, find, omit, cloneDeep } from 'lodash';
import { loadAttributesMap } from './utils/attributesMapLoader';
import { getAttributesDisplayForms } from './utils/visualizationObjectHelper';
export { loadAttributesMap, getAttributesDisplayForms };
const REQUEST_DEFAULTS = {

@@ -4,0 +9,0 @@ types: ['attribute', 'metric', 'fact'],

@@ -13,3 +13,2 @@ // Copyright (C) 2007-2017, GoodData(R) Corporation. All rights reserved.

*/
export function createModule(xhr, md) {

@@ -16,0 +15,0 @@ const loadAttributesMap = loadAttributesMapFactory(md);

@@ -23,2 +23,13 @@ // Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved.

import { sortDefinitions } from '../utils/definitions';
import {
getMissingUrisInAttributesMap
} from '../utils/attributesMapLoader';
import {
getAttributes,
getMeasures,
getMeasureFilters,
getDefinition,
isAttributeMeasureFilter,
getAttributesDisplayForms
} from '../utils/visualizationObjectHelper';

@@ -69,6 +80,2 @@ const notEmpty = negate(isEmpty);

function getDefinition(measure) {
return get(measure, ['definition', 'measureDefinition'], {});
}
function getPoPDefinition(measure) {

@@ -78,6 +85,2 @@ return get(measure, ['definition', 'popMeasureDefinition'], {});

function getMeasureFilters(measure) {
return get(getDefinition(measure), 'filters', []);
}
function getAggregation(measure) {

@@ -111,6 +114,2 @@ return get(getDefinition(measure), 'aggregation', '').toLowerCase();

function isAttrMeasureFilter(measureFilter) {
return (get(measureFilter, 'positiveAttributeFilter') || get(measureFilter, 'negativeAttributeFilter')) !== undefined;
}
function getAttrTypeFromMap(dfUri, attributesMap) {

@@ -124,7 +123,2 @@ return get(get(attributesMap, [dfUri], {}), ['attribute', 'content', 'type']);

function getAttrMeasureFilterDf(measureFilter) {
return get(measureFilter, ['positiveAttributeFilter', 'displayForm', 'uri']) ||
get(measureFilter, ['negativeAttributeFilter', 'displayForm', 'uri']);
}
function isAttrFilterNegative(attributeFilter) {

@@ -160,3 +154,3 @@ return get(attributeFilter, 'negativeAttributeFilter') !== undefined;

function getFilterExpression(attributesMap, measureFilter) {
if (isAttrMeasureFilter(measureFilter)) {
if (isAttributeMeasureFilter(measureFilter)) {
return getAttrFilterExpression(measureFilter, attributesMap);

@@ -220,46 +214,6 @@ }

function isMeasure(bucketItem) {
return get(bucketItem, 'measure') !== undefined;
function isDateAttribute(attribute, attributesMap = {}) {
return getAttrTypeFromMap(get(attribute, ['displayForm', 'uri']), attributesMap) !== undefined;
}
function isCategory(bucketItem) {
return get(bucketItem, 'visualizationAttribute') !== undefined;
}
function getBuckets(mdObj) {
return get(mdObj, 'buckets', []);
}
function getMeasuresInBucket(bucket) {
return get(bucket, 'items').reduce((list, bucketItem) => {
if (isMeasure(bucketItem)) {
list.push(get(bucketItem, 'measure'));
}
return list;
}, []);
}
function getMeasures(buckets) {
return buckets.reduce((measuresList, bucket) =>
measuresList.concat(getMeasuresInBucket(bucket)), []);
}
function getCategoriesInBucket(bucket) {
return get(bucket, 'items').reduce((list, bucketItem) => {
if (isCategory(bucketItem)) {
list.push(get(bucketItem, 'visualizationAttribute'));
}
return list;
}, []);
}
function getCategories(buckets) {
return buckets.reduce((categoriesList, bucket) =>
categoriesList.concat(getCategoriesInBucket(bucket)), []);
}
function isDateCategory(category, attributesMap = {}) {
return getAttrTypeFromMap(get(category, ['displayForm', 'uri']), attributesMap) !== undefined;
}
function getMeasureSorting(measure, mdObj) {

@@ -337,4 +291,4 @@ const sorting = get(mdObj, ['properties', 'sortItems'], []);

function createContributionMetric(measure, mdObj, measureIndex, attributesMap) {
const category = first(getCategories(getBuckets(mdObj)));
const getMetricExpression = partial(getPercentMetricExpression, category, attributesMap);
const attribute = first(getAttributes(mdObj));
const getMetricExpression = partial(getPercentMetricExpression, attribute, attributesMap);
const title = getBaseMetricTitle(get(measure, 'title'));

@@ -361,3 +315,3 @@ const hasher = partial(getGeneratedMetricHash, title, CONTRIBUTION_METRIC_FORMAT);

function getOriginalMeasureForPoP(popMeasure, mdObj) {
return getMeasures(getBuckets(mdObj)).find(measure =>
return getMeasures(mdObj).find(measure =>
get(measure, 'localIdentifier') === get(getPoPDefinition(popMeasure), ['measureIdentifier'])

@@ -499,5 +453,4 @@ );

function getExecutionDefinitionsAndColumns(mdObj, options, attributesMap) {
const buckets = getBuckets(mdObj);
const measures = getMeasures(buckets);
let categories = getCategories(buckets);
const measures = getMeasures(mdObj);
let attributes = getAttributes(mdObj);

@@ -508,7 +461,7 @@ const metrics = flatten(map(measures, (measure, index) =>

if (options.removeDateItems) {
categories = filter(categories, category => !isDateCategory(category, attributesMap));
attributes = filter(attributes, attribute => !isDateAttribute(attribute, attributesMap));
}
categories = map(categories, partial(categoryToElement, attributesMap, mdObj));
attributes = map(attributes, partial(categoryToElement, attributesMap, mdObj));
const columns = compact(map([...categories, ...metrics], 'element'));
const columns = compact(map([...attributes, ...metrics], 'element'));
return {

@@ -522,18 +475,16 @@ columns,

function getAttributesMap(options, displayFormUris, projectId) {
if (options.attributesMap) {
return Promise.resolve(options.attributesMap);
}
return loadAttributesMap(projectId, displayFormUris);
const attributesMap = get(options, 'attributesMap', {});
const missingUris = getMissingUrisInAttributesMap(displayFormUris, attributesMap);
return loadAttributesMap(projectId, missingUris).then((result) => {
return {
...attributesMap,
...result
};
});
}
function mdToExecutionDefinitionsAndColumns(projectId, mdObj, options = {}) {
const buckets = getBuckets(mdObj);
const measures = getMeasures(buckets);
const categories = getCategories(buckets);
const attrMeasureFilters = filter(measures.reduce((filters, measure) =>
filters.concat(getMeasureFilters(measure)),
[]), isAttrMeasureFilter);
const attrMeasureFiltersDfs = attrMeasureFilters.map(getAttrMeasureFilterDf);
const categoryDfs = categories.map(category => get(category, ['displayForm', 'uri']));
const attributesMapPromise = getAttributesMap(options, [...categoryDfs, ...attrMeasureFiltersDfs], projectId);
const allDfUris = getAttributesDisplayForms(mdObj);
const attributesMapPromise = getAttributesMap(options, allDfUris, projectId);

@@ -540,0 +491,0 @@ return attributesMapPromise.then((attributesMap) => {

@@ -28,10 +28,7 @@ // Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved.

*/
// const gooddata = { config, xhr, user, md, execution, project, catalogue, admin };
// export default gooddata;
// module.exports = gooddata;
function factory(domain) {
function factory(options = {}) {
const config = configFactory();
if (domain) {
config.setCustomDomain(domain);
if (options.domain) {
config.setCustomDomain(options.domain);
}

@@ -42,3 +39,2 @@ const xhr = xhrFactory(config);

return {
domain,
config,

@@ -45,0 +41,0 @@ xhr,

@@ -24,2 +24,7 @@ import {

export function getMissingUrisInAttributesMap(displayFormsUris, attributesMap) {
const uris = displayFormsUris || [];
return uris.filter(uri => !attributesMap[uri]);
}
export function createModule(md) {

@@ -26,0 +31,0 @@ return function loadAttributesMap(projectId, attributeDisplayFormUris) {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc