Comparing version 1.6.0 to 1.7.0-strouhaljan-BB-56-2017-06-23T08-16-56-226Z
@@ -205,3 +205,4 @@ 'use strict'; | ||
var MAX_TITLE_LENGTH = 255; | ||
var MAX_TITLE_LENGTH = 1000; | ||
var getMetricTitle = function getMetricTitle(suffix, title) { | ||
@@ -208,0 +209,0 @@ var maxLength = MAX_TITLE_LENGTH - suffix.length; |
@@ -27,6 +27,8 @@ 'use strict'; | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); // Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved. | ||
exports.getObjects = getObjects; | ||
exports.getObjectUsing = getObjectUsing; | ||
exports.getObjectUsingMany = getObjectUsingMany; | ||
exports.getElementDetails = getElementDetails; | ||
exports.getAttributes = getAttributes; | ||
@@ -70,3 +72,2 @@ exports.getDimensions = getDimensions; | ||
*/ | ||
// Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved. | ||
function getObjects(projectId, objectUris) { | ||
@@ -194,76 +195,2 @@ var LIMIT = 50; | ||
/** | ||
* Get additional information about elements specified by their uris | ||
* `elementUris` is the array of uris of elements to be look-up | ||
* Currently makes a request for each object, should be encapsulated | ||
* to one call | ||
* | ||
* @method getElementDetails | ||
* @param {Array} array of element uri strings | ||
* @private | ||
*/ | ||
function getElementDetails(elementUris) { | ||
var fns = elementUris.map(function (uri) { | ||
return (0, _xhr.get)(uri); | ||
}); | ||
return Promise.all(fns).then(function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
var enriched = args.map(function (element) { | ||
var root = element[0]; | ||
if (root.attributeDisplayForm) { | ||
return { | ||
type: 'attribute', | ||
uri: root.attributeDisplayForm.meta.uri, | ||
formOf: root.attributeDisplayForm.content.formOf, | ||
name: root.attributeDisplayForm.meta.title | ||
}; | ||
} else if (root.metric) { | ||
return { | ||
type: 'metric', | ||
uri: root.metric.meta.uri, | ||
name: root.metric.meta.title | ||
}; | ||
} | ||
return undefined; | ||
}); | ||
// override titles with related attribute title | ||
var ids = {}; | ||
var indi = []; | ||
var i = 0; | ||
var formOfFns = []; | ||
enriched.forEach(function (el, idx) { | ||
if (el.formOf) { | ||
formOfFns.push((0, _xhr.get)(el.formOf)); | ||
ids[el.uri] = idx; | ||
indi[i] = idx; | ||
i += 1; | ||
} | ||
}); | ||
// all formOf are executed | ||
return Promise.all(formOfFns).then(function () { | ||
for (var _len2 = arguments.length, formOfArgs = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
formOfArgs[_key2] = arguments[_key2]; | ||
} | ||
formOfArgs.forEach(function (arg, idx) { | ||
// get element to owerwrite | ||
var which = indi[idx]; | ||
var update = enriched[which]; | ||
update.name = arg[0].attribute.meta.title; | ||
}); | ||
return enriched; | ||
}); | ||
}); | ||
} | ||
/** | ||
* Reutrns all attributes in a project specified by projectId param | ||
@@ -318,3 +245,8 @@ * | ||
default: | ||
return Promise.all([getFolderEntries(projectId, 'fact'), getFolderEntries(projectId, 'metric'), getDimensions(projectId)]).then(function (facts, metrics, attributes) { | ||
return Promise.all([getFolderEntries(projectId, 'fact'), getFolderEntries(projectId, 'metric'), getDimensions(projectId)]).then(function (_ref) { | ||
var _ref2 = _slicedToArray(_ref, 3), | ||
facts = _ref2[0], | ||
metrics = _ref2[1], | ||
attributes = _ref2[2]; | ||
return { fact: facts, metric: metrics, attribute: attributes }; | ||
@@ -447,7 +379,3 @@ }); | ||
function getMetricItemsDetails(array) { | ||
return Promise.all(array.map(getObjectDetails)).then(function () { | ||
for (var _len3 = arguments.length, metricArgs = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { | ||
metricArgs[_key3] = arguments[_key3]; | ||
} | ||
return Promise.all(array.map(getObjectDetails)).then(function (metricArgs) { | ||
return metricArgs.map(function (item) { | ||
@@ -495,7 +423,3 @@ return item.metric; | ||
// fetch details for each folder | ||
return Promise.all(foldersLinks.map(getObjectDetails)).then(function () { | ||
for (var _len4 = arguments.length, folderDetails = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { | ||
folderDetails[_key4] = arguments[_key4]; | ||
} | ||
return Promise.all(foldersLinks.map(getObjectDetails)).then(function (folderDetails) { | ||
// if attribute, just parse everything from what we've received | ||
@@ -506,3 +430,3 @@ // and resolve. For metrics, lookup again each metric to get its | ||
// get all attributes, subtract what we have and add rest in unsorted folder | ||
getAttributes(projectId).then(function (attributes) { | ||
return getAttributes(projectId).then(function (attributes) { | ||
// get uris of attributes which are in some dimension folders | ||
@@ -522,7 +446,3 @@ var attributesInFolders = []; | ||
// now get details of attributes in no folders | ||
return Promise.all(unsortedUris.map(getObjectDetails)).then(function () { | ||
for (var _len5 = arguments.length, unsortedAttributeArgs = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { | ||
unsortedAttributeArgs[_key5] = arguments[_key5]; | ||
} | ||
return Promise.all(unsortedUris.map(getObjectDetails)).then(function (unsortedAttributeArgs) { | ||
// TODO add map to r.json | ||
@@ -576,7 +496,3 @@ // get unsorted attribute objects | ||
return getMetricItemsDetails(linkArray); | ||
})).then(function () { | ||
for (var _len6 = arguments.length, tree = Array(_len6), _key6 = 0; _key6 < _len6; _key6++) { | ||
tree[_key6] = arguments[_key6]; | ||
} | ||
})).then(function (tree) { | ||
// TODO add map to r.json | ||
@@ -595,7 +511,5 @@ // all promises resolved, i.e. details for each metric are available | ||
}); | ||
} else { | ||
return Promise.reject(); | ||
} | ||
return undefined; | ||
return Promise.reject(); | ||
}); | ||
@@ -602,0 +516,0 @@ }); |
{ | ||
"name": "gooddata", | ||
"version": "1.6.0", | ||
"version": "1.7.0-strouhaljan-BB-56-2017-06-23T08-16-56-226Z", | ||
"author": "GoodData", | ||
@@ -5,0 +5,0 @@ "description": "GoodData JavaScript SDK", |
@@ -140,3 +140,4 @@ // Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved. | ||
const MAX_TITLE_LENGTH = 255; | ||
const MAX_TITLE_LENGTH = 1000; | ||
const getMetricTitle = (suffix, title) => { | ||
@@ -143,0 +144,0 @@ const maxLength = MAX_TITLE_LENGTH - suffix.length; |
@@ -134,66 +134,2 @@ // Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved. | ||
/** | ||
* Get additional information about elements specified by their uris | ||
* `elementUris` is the array of uris of elements to be look-up | ||
* Currently makes a request for each object, should be encapsulated | ||
* to one call | ||
* | ||
* @method getElementDetails | ||
* @param {Array} array of element uri strings | ||
* @private | ||
*/ | ||
export function getElementDetails(elementUris) { | ||
const fns = elementUris.map(uri => get(uri)); | ||
return Promise.all(fns).then((...args) => { | ||
const enriched = args.map((element) => { | ||
const root = element[0]; | ||
if (root.attributeDisplayForm) { | ||
return { | ||
type: 'attribute', | ||
uri: root.attributeDisplayForm.meta.uri, | ||
formOf: root.attributeDisplayForm.content.formOf, | ||
name: root.attributeDisplayForm.meta.title | ||
}; | ||
} else if (root.metric) { | ||
return { | ||
type: 'metric', | ||
uri: root.metric.meta.uri, | ||
name: root.metric.meta.title | ||
}; | ||
} | ||
return undefined; | ||
}); | ||
// override titles with related attribute title | ||
const ids = {}; | ||
const indi = []; | ||
let i = 0; | ||
const formOfFns = []; | ||
enriched.forEach((el, idx) => { | ||
if (el.formOf) { | ||
formOfFns.push(get(el.formOf)); | ||
ids[el.uri] = idx; | ||
indi[i] = idx; | ||
i += 1; | ||
} | ||
}); | ||
// all formOf are executed | ||
return Promise.all(formOfFns).then((...formOfArgs) => { | ||
formOfArgs.forEach((arg, idx) => { | ||
// get element to owerwrite | ||
const which = indi[idx]; | ||
const update = enriched[which]; | ||
update.name = arg[0].attribute.meta.title; | ||
}); | ||
return enriched; | ||
}); | ||
}); | ||
} | ||
/** | ||
* Reutrns all attributes in a project specified by projectId param | ||
@@ -249,3 +185,3 @@ * | ||
]) | ||
.then((facts, metrics, attributes) => { | ||
.then(([facts, metrics, attributes]) => { | ||
return { fact: facts, metric: metrics, attribute: attributes }; | ||
@@ -362,3 +298,3 @@ }); | ||
function getMetricItemsDetails(array) { | ||
return Promise.all(array.map(getObjectDetails)).then((...metricArgs) => { | ||
return Promise.all(array.map(getObjectDetails)).then((metricArgs) => { | ||
return metricArgs.map(item => item.metric); | ||
@@ -404,3 +340,3 @@ }); | ||
// fetch details for each folder | ||
return Promise.all(foldersLinks.map(getObjectDetails)).then((...folderDetails) => { | ||
return Promise.all(foldersLinks.map(getObjectDetails)).then((folderDetails) => { | ||
// if attribute, just parse everything from what we've received | ||
@@ -411,3 +347,3 @@ // and resolve. For metrics, lookup again each metric to get its | ||
// get all attributes, subtract what we have and add rest in unsorted folder | ||
getAttributes(projectId).then((attributes) => { | ||
return getAttributes(projectId).then((attributes) => { | ||
// get uris of attributes which are in some dimension folders | ||
@@ -427,3 +363,3 @@ const attributesInFolders = []; | ||
return Promise.all(unsortedUris.map(getObjectDetails)) | ||
.then((...unsortedAttributeArgs) => { // TODO add map to r.json | ||
.then((unsortedAttributeArgs) => { // TODO add map to r.json | ||
// get unsorted attribute objects | ||
@@ -470,3 +406,3 @@ const unsortedAttributes = unsortedAttributeArgs.map(attr => attr.attribute); | ||
return Promise.all(entriesLinks.map(linkArray => getMetricItemsDetails(linkArray))) | ||
.then((...tree) => { // TODO add map to r.json | ||
.then((tree) => { // TODO add map to r.json | ||
// all promises resolved, i.e. details for each metric are available | ||
@@ -484,7 +420,5 @@ const structure = tree.map((treeItems, idx) => { | ||
}); | ||
} else { | ||
return Promise.reject(); | ||
} | ||
return undefined; | ||
return Promise.reject(); | ||
}); | ||
@@ -491,0 +425,0 @@ }); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
0
456009
10725
2
7