gooddata
Advanced tools
Comparing version 6.0.0-vaclavbohac-typescript-2018-04-04T10-40-44-156Z to 6.0.0-zdenek.vidensky-one-3017-2018-04-04T14-04-24-329Z
@@ -1,12 +0,24 @@ | ||
"use strict"; | ||
// Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var dataProducts_1 = require("./admin/dataProducts"); | ||
var domainDataProducts_1 = require("./admin/domainDataProducts"); | ||
var domains_1 = require("./admin/domains"); | ||
var domainSegments_1 = require("./admin/domainSegments"); | ||
var clients_1 = require("./admin/clients"); | ||
var segments_1 = require("./admin/segments"); | ||
var logs_1 = require("./admin/logs"); | ||
var contracts_1 = require("./admin/contracts"); | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.createModule = createModule; | ||
var _dataProducts = require('./admin/dataProducts'); | ||
var _domainDataProducts = require('./admin/domainDataProducts'); | ||
var _domains = require('./admin/domains'); | ||
var _domainSegments = require('./admin/domainSegments'); | ||
var _clients = require('./admin/clients'); | ||
var _segments = require('./admin/segments'); | ||
var _logs = require('./admin/logs'); | ||
var _contracts = require('./admin/contracts'); | ||
/** | ||
@@ -19,16 +31,15 @@ * Network-UI support methods. Mostly private | ||
*/ | ||
var AdminModule = /** @class */ (function () { | ||
function AdminModule(xhr) { | ||
this.xhr = xhr; | ||
this.dataProducts = new dataProducts_1.DataProductsModule(this.xhr); | ||
this.domainDataProducts = new domainDataProducts_1.DomainDataProductModule(this.xhr); | ||
this.domains = new domains_1.DomainsModule(this.xhr); | ||
this.domainSegments = new domainSegments_1.DomainSegmentsModule(this.xhr); | ||
this.clients = new clients_1.ClientsModule(this.xhr); | ||
this.logs = new logs_1.LogsModule(this.xhr); | ||
this.contracts = new contracts_1.ContractsModule(this.xhr); | ||
this.segments = new segments_1.SegmentsModule(this.xhr); | ||
} | ||
return AdminModule; | ||
}()); | ||
exports.AdminModule = AdminModule; | ||
// Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved. | ||
function createModule(xhr) { | ||
return { | ||
dataProducts: (0, _dataProducts.createModule)(xhr), | ||
domainDataProducts: (0, _domainDataProducts.createModule)(xhr), | ||
domains: (0, _domains.createModule)(xhr), | ||
domainSegments: (0, _domainSegments.createModule)(xhr), | ||
clients: (0, _clients.createModule)(xhr), | ||
logs: (0, _logs.createModule)(xhr), | ||
contracts: (0, _contracts.createModule)(xhr), | ||
segments: (0, _segments.createModule)(xhr) | ||
}; | ||
} |
@@ -1,62 +0,85 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
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; }; | ||
exports.createModule = createModule; | ||
var _routes = require('./routes'); | ||
var routes = _interopRequireWildcard(_routes); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
var transformClient = function transformClient(item) { | ||
var _routes$parse = routes.parse(item.client.links.self, routes.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENT), | ||
contractId = _routes$parse.contractId, | ||
dataProductId = _routes$parse.dataProductId, | ||
domainId = _routes$parse.domainId, | ||
segmentId = _routes$parse.segmentId; | ||
return _extends({ | ||
contractId: contractId, | ||
dataProductId: dataProductId, | ||
domainId: domainId, | ||
segmentId: segmentId | ||
}, item.client); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var routes_1 = require("./routes"); | ||
var ClientsModule = /** @class */ (function () { | ||
function ClientsModule(xhr) { | ||
this.xhr = xhr; | ||
} | ||
ClientsModule.prototype.getClient = function (contractId, dataProductId, segmentId, domainId, clientId) { | ||
var _this = this; | ||
var transformClientUser = function transformClientUser(user) { | ||
return _extends({ | ||
id: user.login, | ||
fullName: user.firstName + ' ' + user.lastName, | ||
role: user.roles[0] | ||
}, user); | ||
}; | ||
function createModule(xhr) { | ||
var getClient = function getClient(contractId, dataProductId, segmentId, domainId, clientId) { | ||
var query = { stats: 'user' }; | ||
var uri = routes_1.interpolate(routes_1.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENT, { contractId: contractId, dataProductId: dataProductId, segmentId: segmentId, domainId: domainId, clientId: clientId }, query); | ||
return this.xhr.get(uri).then(function (r) { return r.getData(); }).then(function (result) { return _this.transformClient(result); }); | ||
var uri = routes.interpolate(routes.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENT, { contractId: contractId, dataProductId: dataProductId, segmentId: segmentId, domainId: domainId, clientId: clientId }, query); | ||
return xhr.get(uri).then(function (result) { | ||
return transformClient(result); | ||
}); | ||
}; | ||
ClientsModule.prototype.getClients = function (contractId, dataProductId, segmentId, domainId, filter, paging) { | ||
var _this = this; | ||
var getClients = function getClients(contractId, dataProductId, segmentId, domainId, filter, paging) { | ||
var query = filter ? { clientPrefix: filter, stats: 'user' } : { stats: 'user' }; | ||
var uri = paging ? | ||
paging.next : | ||
routes_1.interpolate(routes_1.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENTS, { contractId: contractId, dataProductId: dataProductId, segmentId: segmentId, domainId: domainId }, query); | ||
var uri = paging ? paging.next : routes.interpolate(routes.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENTS, { contractId: contractId, dataProductId: dataProductId, segmentId: segmentId, domainId: domainId }, query); | ||
if (uri) { | ||
return this.xhr.get(uri) | ||
.then(function (r) { return r.getData(); }) | ||
.then(function (result) { return ({ | ||
items: result.clients.items.map(_this.transformClient), | ||
paging: result.clients.paging | ||
}); }); | ||
return xhr.get(uri).then(function (result) { | ||
return { | ||
items: result.clients.items.map(transformClient), | ||
paging: result.clients.paging | ||
}; | ||
}); | ||
} | ||
return Promise.resolve({ items: [], paging: {} }); | ||
}; | ||
ClientsModule.prototype.getClientUsers = function (contractId, dataProductId, domainId, segmentId, clientId, query, paging) { | ||
var _this = this; | ||
var getClientUsers = function getClientUsers(contractId, dataProductId, domainId, segmentId, clientId, query, paging) { | ||
if (paging && !paging.next) { | ||
return Promise.resolve({ items: [], paging: {} }); | ||
} | ||
var uri = paging ? | ||
paging.next : | ||
routes_1.interpolate(routes_1.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENT_USERS, { contractId: contractId, dataProductId: dataProductId, domainId: domainId, segmentId: segmentId, clientId: clientId }, query); | ||
return this.xhr.get(uri) | ||
.then((function (r) { return r.getData(); })) | ||
.then(function (result) { return (__assign({}, result.clientUsers, { items: result.clientUsers.items.map(_this.transformClientUser) })); }); | ||
var uri = paging ? paging.next : routes.interpolate(routes.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENT_USERS, { contractId: contractId, dataProductId: dataProductId, domainId: domainId, segmentId: segmentId, clientId: clientId }, query); | ||
return xhr.get(uri).then(function (result) { | ||
return _extends({}, result.clientUsers, { | ||
items: result.clientUsers.items.map(transformClientUser) | ||
}); | ||
}); | ||
}; | ||
ClientsModule.prototype.transformClient = function (item) { | ||
var _a = routes_1.parse(item.client.links.self, routes_1.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENT), contractId = _a.contractId, dataProductId = _a.dataProductId, domainId = _a.domainId, segmentId = _a.segmentId; | ||
return __assign({ contractId: contractId, | ||
dataProductId: dataProductId, | ||
domainId: domainId, | ||
segmentId: segmentId }, item.client); | ||
return { | ||
getClient: getClient, | ||
getClients: getClients, | ||
getClientUsers: getClientUsers | ||
}; | ||
ClientsModule.prototype.transformClientUser = function (user) { | ||
return __assign({ id: user.login, fullName: user.firstName + " " + user.lastName, role: user.roles[0] }, user); | ||
}; | ||
return ClientsModule; | ||
}()); | ||
exports.ClientsModule = ClientsModule; | ||
} |
@@ -1,16 +0,29 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var routes = require("./routes"); | ||
var ContractsModule = /** @class */ (function () { | ||
function ContractsModule(xhr) { | ||
this.xhr = xhr; | ||
} | ||
ContractsModule.prototype.getUserContracts = function () { | ||
return this.xhr.get(routes.CONTRACTS).then(function (data) { return ({ | ||
items: data.getData().contracts.items.map(function (item) { return item.contract; }), | ||
paging: data.getData().contracts.paging | ||
}); }); | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.createModule = createModule; | ||
var _routes = require('./routes'); | ||
var routes = _interopRequireWildcard(_routes); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function createModule(xhr) { | ||
var getUserContracts = function getUserContracts() { | ||
return xhr.get(routes.CONTRACTS).then(function (data) { | ||
return { | ||
items: data.contracts.items.map(function (item) { | ||
return item.contract; | ||
}), | ||
paging: data.contracts.paging | ||
}; | ||
}); | ||
}; | ||
return ContractsModule; | ||
}()); | ||
exports.ContractsModule = ContractsModule; | ||
return { | ||
getUserContracts: getUserContracts | ||
}; | ||
} |
@@ -1,48 +0,67 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var routes_1 = require("./routes"); | ||
var segments_1 = require("./segments"); | ||
var domainDataProducts = require("./domainDataProducts"); | ||
exports.transformDataProduct = function (item) { | ||
var contractId = routes_1.parse(item.dataProduct.links.self, routes_1.CONTRACT_DATA_PRODUCT).contractId; | ||
var dataProduct = __assign({ contractId: contractId }, item.dataProduct); | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.transformDataProduct = undefined; | ||
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; }; | ||
exports.createModule = createModule; | ||
var _routes = require('./routes'); | ||
var routes = _interopRequireWildcard(_routes); | ||
var _segments = require('./segments'); | ||
var segments = _interopRequireWildcard(_segments); | ||
var _domainDataProducts = require('./domainDataProducts'); | ||
var domainDataProducts = _interopRequireWildcard(_domainDataProducts); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
var transformDataProduct = exports.transformDataProduct = function transformDataProduct(item) { | ||
var _routes$parse = routes.parse(item.dataProduct.links.self, routes.CONTRACT_DATA_PRODUCT), | ||
contractId = _routes$parse.contractId; | ||
var dataProduct = _extends({ | ||
contractId: contractId | ||
}, item.dataProduct); | ||
if (dataProduct.domainDataProducts) { | ||
dataProduct.domainDataProducts = | ||
dataProduct.domainDataProducts.map(domainDataProducts.transformDomainDataProduct); | ||
dataProduct.domainDataProducts = dataProduct.domainDataProducts.map(domainDataProducts.transformDomainDataProduct); | ||
} | ||
if (dataProduct.segments) { | ||
dataProduct.segments = dataProduct.segments.map(segments_1.transformSegment); | ||
dataProduct.segments = dataProduct.segments.map(segments.transformSegment); | ||
} | ||
return dataProduct; | ||
}; | ||
var DataProductsModule = /** @class */ (function () { | ||
function DataProductsModule(xhr) { | ||
this.xhr = xhr; | ||
} | ||
DataProductsModule.prototype.getDataProducts = function (contractId, include) { | ||
return this.xhr.get(routes_1.interpolate(routes_1.CONTRACT_DATA_PRODUCTS, { contractId: contractId }, include && { include: include })) | ||
.then(function (r) { return r.getData(); }) | ||
.then(function (data) { return ({ | ||
items: data.dataProducts.items.map(exports.transformDataProduct) | ||
}); }); | ||
function createModule(xhr) { | ||
var getDataProducts = function getDataProducts(contractId, include) { | ||
return xhr.get(routes.interpolate(routes.CONTRACT_DATA_PRODUCTS, { contractId: contractId }, include && { include: include })).then(function (data) { | ||
return { | ||
items: data.dataProducts.items.map(transformDataProduct) | ||
}; | ||
}); | ||
}; | ||
DataProductsModule.prototype.getDataProduct = function (contractId, dataProductId, include, stats, state) { | ||
return this.xhr.get(routes_1.interpolate(routes_1.CONTRACT_DATA_PRODUCT, { contractId: contractId, dataProductId: dataProductId }, __assign({}, (include && { include: include }), (stats && { stats: stats }), (state && { state: state })))) | ||
.then(function (r) { return r.getData(); }) | ||
.then(function (data) { return exports.transformDataProduct(data); }); | ||
var getDataProduct = function getDataProduct(contractId, dataProductId, include, stats, state) { | ||
return xhr.get(routes.interpolate(routes.CONTRACT_DATA_PRODUCT, { contractId: contractId, dataProductId: dataProductId }, Object.assign(include && { include: include }, stats && { stats: stats }, state && { state: state }))).then(function (data) { | ||
return transformDataProduct(data); | ||
}); | ||
}; | ||
DataProductsModule.prototype.createDataProduct = function (contractId, dataProductId, domainIds) { | ||
return this.xhr.post(routes_1.interpolate(routes_1.CONTRACT_DATA_PRODUCTS, { contractId: contractId }), { | ||
body: JSON.stringify({ | ||
var createDataProduct = function createDataProduct(contractId, dataProductId, domainIds) { | ||
return xhr.post(routes.interpolate(routes.CONTRACT_DATA_PRODUCTS, { contractId: contractId }), { | ||
data: JSON.stringify({ | ||
dataProductCreate: { | ||
id: dataProductId, | ||
domains: domainIds.map(function (domainId) { return routes_1.interpolate(routes_1.CONTRACT_DOMAIN, { contractId: contractId, domainId: domainId }); }) | ||
domains: domainIds.map(function (domainId) { | ||
return routes.interpolate(routes.CONTRACT_DOMAIN, { contractId: contractId, domainId: domainId }); | ||
}) | ||
} | ||
@@ -52,12 +71,20 @@ }) | ||
}; | ||
DataProductsModule.prototype.renameDataProduct = function (contractId, dataProductId, newDataProductId) { | ||
return this.xhr.post(routes_1.interpolate(routes_1.CONTRACT_DATA_PRODUCT_RENAME, { contractId: contractId, dataProductId: dataProductId }), { | ||
body: JSON.stringify({ dataProductRename: { id: newDataProductId } }) | ||
var renameDataProduct = function renameDataProduct(contractId, dataProductId, newDataProductId) { | ||
return xhr.post(routes.interpolate(routes.CONTRACT_DATA_PRODUCT_RENAME, { contractId: contractId, dataProductId: dataProductId }), { | ||
data: JSON.stringify({ dataProductRename: { id: newDataProductId } }) | ||
}); | ||
}; | ||
DataProductsModule.prototype.deleteDataProduct = function (contractId, dataProductId) { | ||
return this.xhr.del(routes_1.interpolate(routes_1.CONTRACT_DATA_PRODUCT, { contractId: contractId, dataProductId: dataProductId })); | ||
var deleteDataProduct = function deleteDataProduct(contractId, dataProductId) { | ||
return xhr.del(routes.interpolate(routes.CONTRACT_DATA_PRODUCT, { contractId: contractId, dataProductId: dataProductId })); | ||
}; | ||
return DataProductsModule; | ||
}()); | ||
exports.DataProductsModule = DataProductsModule; | ||
return { | ||
getDataProducts: getDataProducts, | ||
getDataProduct: getDataProduct, | ||
createDataProduct: createDataProduct, | ||
renameDataProduct: renameDataProduct, | ||
deleteDataProduct: deleteDataProduct | ||
}; | ||
} |
@@ -1,29 +0,40 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var routes_1 = require("./routes"); | ||
exports.transformDomainDataProduct = function (_a) { | ||
var domainDataProduct = _a.domainDataProduct; | ||
var _b = routes_1.parse(domainDataProduct.links.self, routes_1.CONTRACT_DATA_PRODUCT_DOMAIN_DATA_PRODUCT), contractId = _b.contractId, domainId = _b.domainId, dataProductId = _b.dataProductId; | ||
return __assign({ contractId: contractId, | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.transformDomainDataProduct = undefined; | ||
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; }; | ||
exports.createModule = createModule; | ||
var _routes = require('./routes'); | ||
var routes = _interopRequireWildcard(_routes); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
var transformDomainDataProduct = exports.transformDomainDataProduct = function transformDomainDataProduct(_ref) { | ||
var domainDataProduct = _ref.domainDataProduct; | ||
var _routes$parse = routes.parse(domainDataProduct.links.self, routes.CONTRACT_DATA_PRODUCT_DOMAIN_DATA_PRODUCT), | ||
contractId = _routes$parse.contractId, | ||
domainId = _routes$parse.domainId, | ||
dataProductId = _routes$parse.dataProductId; | ||
return _extends({ | ||
contractId: contractId, | ||
domainId: domainId, | ||
dataProductId: dataProductId }, domainDataProduct); | ||
dataProductId: dataProductId | ||
}, domainDataProduct); | ||
}; | ||
var DomainDataProductModule = /** @class */ (function () { | ||
function DomainDataProductModule(xhr) { | ||
this.xhr = xhr; | ||
} | ||
DomainDataProductModule.prototype.getDomainDataProducts = function (contractId, dataProductId) { | ||
return this.xhr.get(routes_1.interpolate(routes_1.CONTRACT_DATA_PRODUCT_DOMAIN_DATA_PRODUCTS, { contractId: contractId, dataProductId: dataProductId })) | ||
.then(function (result) { | ||
var _a = result.getData(), items = _a.domainDataProducts.items, status = _a.status; | ||
function createModule(xhr) { | ||
var getDomainDataProducts = function getDomainDataProducts(contractId, dataProductId) { | ||
return xhr.get(routes.interpolate(routes.CONTRACT_DATA_PRODUCT_DOMAIN_DATA_PRODUCTS, { contractId: contractId, dataProductId: dataProductId })).then(function (_ref2) { | ||
var items = _ref2.domainDataProducts.items, | ||
status = _ref2.status; | ||
return { | ||
items: items.map(exports.transformDomainDataProduct), | ||
items: items.map(transformDomainDataProduct), | ||
status: status | ||
@@ -33,4 +44,6 @@ }; | ||
}; | ||
return DomainDataProductModule; | ||
}()); | ||
exports.DomainDataProductModule = DomainDataProductModule; | ||
return { | ||
getDomainDataProducts: getDomainDataProducts | ||
}; | ||
} |
@@ -1,64 +0,88 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
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; }; | ||
exports.createModule = createModule; | ||
var _routes = require('./routes'); | ||
var routes = _interopRequireWildcard(_routes); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
var transformDomain = function transformDomain(item) { | ||
var _routes$parse = routes.parse(item.domain.links.self, routes.CONTRACT_DOMAIN), | ||
domainId = _routes$parse.domainId, | ||
contractId = _routes$parse.contractId; | ||
return _extends({ | ||
id: domainId, | ||
contractId: contractId | ||
}, item.domain); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var routes_1 = require("./routes"); | ||
var transformDomain = function (item) { | ||
var _a = routes_1.parse(item.domain.links.self, routes_1.CONTRACT_DOMAIN), domainId = _a.domainId, contractId = _a.contractId; | ||
return __assign({ id: domainId, contractId: contractId }, item.domain); | ||
var transformDomainUser = function transformDomainUser(_ref) { | ||
var user = _ref.user; | ||
var params = routes.parse(user.links.domain, routes.CONTRACT_DOMAIN); | ||
return _extends({ | ||
id: user.login | ||
}, params, { | ||
fullName: user.firstName + ' ' + user.lastName | ||
}, user); | ||
}; | ||
var transformDomainUser = function (_a) { | ||
var user = _a.user; | ||
var params = routes_1.parse(user.links.domain, routes_1.CONTRACT_DOMAIN); | ||
return __assign({ id: user.login }, params, { fullName: user.firstName + " " + user.lastName }, user); | ||
}; | ||
var DomainsModule = /** @class */ (function () { | ||
function DomainsModule(xhr) { | ||
this.xhr = xhr; | ||
} | ||
DomainsModule.prototype.getDomain = function (contractId, domainId, query) { | ||
var uri = routes_1.interpolate(routes_1.CONTRACT_DOMAIN, { contractId: contractId, domainId: domainId }, query); | ||
return this.xhr.get(uri) | ||
.then(function (r) { return r.getData(); }) | ||
.then(transformDomain); | ||
function createModule(xhr) { | ||
var getDomain = function getDomain(contractId, domainId, query) { | ||
var uri = routes.interpolate(routes.CONTRACT_DOMAIN, { contractId: contractId, domainId: domainId }, query); | ||
return xhr.get(uri).then(transformDomain); | ||
}; | ||
DomainsModule.prototype.getDomains = function (contractId, query) { | ||
return this.xhr.get(routes_1.interpolate(routes_1.CONTRACT_DOMAINS, { contractId: contractId }, query)) | ||
.then(function (r) { return r.getData(); }) | ||
.then(function (result) { return ({ items: result.domains.items.map(transformDomain) }); }); // TODO: paging? | ||
var getDomains = function getDomains(contractId, query) { | ||
return xhr.get(routes.interpolate(routes.CONTRACT_DOMAINS, { contractId: contractId }, query)).then(function (result) { | ||
return { items: result.domains.items.map(transformDomain) }; | ||
}); // TODO: paging? | ||
}; | ||
DomainsModule.prototype.getDomainUsers = function (contractId, domainId, query, paging) { | ||
var getDomainUsers = function getDomainUsers(contractId, domainId, query, paging) { | ||
if (paging && !paging.next) { | ||
return Promise.resolve({ items: [], paging: {} }); | ||
} | ||
var uri = paging ? | ||
paging.next : routes_1.interpolate(routes_1.CONTRACT_DOMAIN_USERS, { contractId: contractId, domainId: domainId }, query); | ||
return this.xhr.get(uri) | ||
.then(function (r) { return r.getData(); }) | ||
.then(function (result) { return (__assign({}, result.domainUsers, { items: result.domainUsers.items.map(transformDomainUser) })); }); | ||
var uri = paging ? paging.next : routes.interpolate(routes.CONTRACT_DOMAIN_USERS, { contractId: contractId, domainId: domainId }, query); | ||
return xhr.get(uri).then(function (result) { | ||
return _extends({}, result.domainUsers, { | ||
items: result.domainUsers.items.map(transformDomainUser) | ||
}); | ||
}); | ||
}; | ||
DomainsModule.prototype.getDomainProjects = function (contractId, domainId, state, query, paging) { | ||
var uri = null; | ||
if (paging) { | ||
if (!paging.next) { | ||
return Promise.resolve({ items: [], paging: {} }); | ||
} | ||
uri = paging.next; | ||
var getDomainProjects = function getDomainProjects(contractId, domainId, state, query, paging) { | ||
if (paging && !paging.next) { | ||
return Promise.resolve({ items: [], paging: {} }); | ||
} | ||
else { | ||
var queryObject = (state || query) ? __assign({}, (state ? { state: state } : undefined), (query ? { prefixSearch: query } : undefined)) : null; | ||
uri = routes_1.interpolate(routes_1.CONTRACT_DOMAIN_PROJECTS, { contractId: contractId, domainId: domainId }, queryObject); | ||
} | ||
return this.xhr.get(uri) | ||
.then(function (r) { return r.getData(); }) | ||
.then(function (result) { return (__assign({}, result.domainProjects, { items: result.domainProjects.items.map(function (item) { return item.project; }) })); }); | ||
var uri = paging ? paging.next : routes.interpolate(routes.CONTRACT_DOMAIN_PROJECTS, { contractId: contractId, domainId: domainId }, state || query ? Object.assign(state && { state: state }, query && { prefixSearch: query }) : null); | ||
return xhr.get(uri).then(function (result) { | ||
return _extends({}, result.domainProjects, { | ||
items: result.domainProjects.items.map(function (item) { | ||
return item.project; | ||
}) | ||
}); | ||
}); | ||
}; | ||
return DomainsModule; | ||
}()); | ||
exports.DomainsModule = DomainsModule; | ||
return { | ||
getDomain: getDomain, | ||
getDomains: getDomains, | ||
getDomainUsers: getDomainUsers, | ||
getDomainProjects: getDomainProjects | ||
}; | ||
} |
@@ -1,35 +0,51 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var lodash_1 = require("lodash"); | ||
var routes_1 = require("./routes"); | ||
exports.transformDomainSegment = function (item) { | ||
var _a = routes_1.parse(item.domainSegment.links.self, routes_1.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT), contractId = _a.contractId, dataProductId = _a.dataProductId, segmentId = _a.segmentId, domainId = _a.domainId; | ||
return __assign({ contractId: contractId, | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.transformDomainSegment = undefined; | ||
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; }; | ||
exports.createModule = createModule; | ||
var _lodash = require('lodash'); | ||
var _routes = require('./routes'); | ||
var routes = _interopRequireWildcard(_routes); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
var transformDomainSegment = exports.transformDomainSegment = function transformDomainSegment(item) { | ||
var _routes$parse = routes.parse(item.domainSegment.links.self, routes.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT), | ||
contractId = _routes$parse.contractId, | ||
dataProductId = _routes$parse.dataProductId, | ||
segmentId = _routes$parse.segmentId, | ||
domainId = _routes$parse.domainId; | ||
return _extends({ | ||
contractId: contractId, | ||
dataProductId: dataProductId, | ||
segmentId: segmentId, | ||
domainId: domainId }, item.domainSegment); | ||
domainId: domainId | ||
}, item.domainSegment); | ||
}; | ||
var DomainSegmentsModule = /** @class */ (function () { | ||
function DomainSegmentsModule(xhr) { | ||
this.xhr = xhr; | ||
} | ||
DomainSegmentsModule.prototype.getDomainSegments = function (contractId, dataProductId, segmentId, query) { | ||
return this.xhr.get(routes_1.interpolate(routes_1.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENTS, { contractId: contractId, dataProductId: dataProductId, segmentId: segmentId }, query)) | ||
.then(function (result) { return ({ items: result.getData().domainSegments.items.map(exports.transformDomainSegment) }); }); | ||
function createModule(xhr) { | ||
var getDomainSegments = function getDomainSegments(contractId, dataProductId, segmentId, query) { | ||
return xhr.get(routes.interpolate(routes.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENTS, { contractId: contractId, dataProductId: dataProductId, segmentId: segmentId }, query)).then(function (result) { | ||
return { items: result.domainSegments.items.map(transformDomainSegment) }; | ||
}); | ||
}; | ||
DomainSegmentsModule.prototype.getDomainSegment = function (contractId, dataProductId, segmentId, domainId, query) { | ||
return this.xhr.get(routes_1.interpolate(routes_1.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT, { contractId: contractId, dataProductId: dataProductId, segmentId: segmentId, domainId: domainId }, query)) | ||
.then(function (result) { return exports.transformDomainSegment(result.getData()); }); | ||
var getDomainSegment = function getDomainSegment(contractId, dataProductId, segmentId, domainId, query) { | ||
return xhr.get(routes.interpolate(routes.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT, { contractId: contractId, dataProductId: dataProductId, segmentId: segmentId, domainId: domainId }, query)).then(function (result) { | ||
return transformDomainSegment(result); | ||
}); | ||
}; | ||
DomainSegmentsModule.prototype.cloneDomainSegment = function (contractId, dataProductId, segmentId, domainId, newSegmentId, newDomainId) { | ||
return this.xhr.post(routes_1.interpolate(routes_1.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLONE, { contractId: contractId, dataProductId: dataProductId, segmentId: segmentId, domainId: domainId }), { | ||
body: JSON.stringify({ | ||
var cloneDomainSegment = function cloneDomainSegment(contractId, dataProductId, segmentId, domainId, newSegmentId, newDomainId) { | ||
return xhr.post(routes.interpolate(routes.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLONE, { contractId: contractId, dataProductId: dataProductId, segmentId: segmentId, domainId: domainId }), { | ||
data: JSON.stringify({ | ||
cloneSegmentRequest: { | ||
@@ -42,8 +58,10 @@ clonedSegmentId: newSegmentId, | ||
}; | ||
DomainSegmentsModule.prototype.deleteDomainSegment = function (contractId, dataProductId, segmentId, domainId) { | ||
return this.xhr.del(routes_1.interpolate(routes_1.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT, { contractId: contractId, dataProductId: dataProductId, segmentId: segmentId, domainId: domainId })); | ||
var deleteDomainSegment = function deleteDomainSegment(contractId, dataProductId, segmentId, domainId) { | ||
return xhr.del(routes.interpolate(routes.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT, { contractId: contractId, dataProductId: dataProductId, segmentId: segmentId, domainId: domainId })); | ||
}; | ||
DomainSegmentsModule.prototype.renameDomainSegment = function (contractId, dataProductId, segmentId, domainId, newSegmentId) { | ||
return this.xhr.post(routes_1.interpolate(routes_1.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_RENAME, { contractId: contractId, dataProductId: dataProductId, segmentId: segmentId, domainId: domainId }), { | ||
body: JSON.stringify({ | ||
var renameDomainSegment = function renameDomainSegment(contractId, dataProductId, segmentId, domainId, newSegmentId) { | ||
return xhr.post(routes.interpolate(routes.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_RENAME, { contractId: contractId, dataProductId: dataProductId, segmentId: segmentId, domainId: domainId }), { | ||
data: JSON.stringify({ | ||
domainSegmentRename: { | ||
@@ -55,19 +73,33 @@ id: newSegmentId | ||
}; | ||
DomainSegmentsModule.prototype.syncDomainSegment = function (contractId, dataProductId, segmentId, domainId) { | ||
return this.xhr.post(routes_1.interpolate(routes_1.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_SYNC, { contractId: contractId, dataProductId: dataProductId, segmentId: segmentId, domainId: domainId })); | ||
var syncDomainSegment = function syncDomainSegment(contractId, dataProductId, segmentId, domainId) { | ||
return xhr.post(routes.interpolate(routes.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_SYNC, { contractId: contractId, dataProductId: dataProductId, segmentId: segmentId, domainId: domainId })); | ||
}; | ||
DomainSegmentsModule.prototype.deployDomainSegment = function (contractId, dataProductId, segmentId, domainId, targetDomainId, synchronize) { | ||
return this.xhr.post(routes_1.interpolate(routes_1.DEPLOY_SEGMENT, { contractId: contractId, dataProductId: dataProductId, segmentId: segmentId, domainId: domainId }, synchronize && { synchronize: synchronize }), { body: JSON.stringify({ deploySegmentRequest: { domain: targetDomainId } }) }); | ||
var deployDomainSegment = function deployDomainSegment(contractId, dataProductId, segmentId, domainId, targetDomainId, synchronize) { | ||
return xhr.post(routes.interpolate(routes.DEPLOY_SEGMENT, { contractId: contractId, dataProductId: dataProductId, segmentId: segmentId, domainId: domainId }, synchronize && { synchronize: synchronize }), { data: JSON.stringify({ deploySegmentRequest: { domain: targetDomainId } }) }); | ||
}; | ||
DomainSegmentsModule.prototype.updateDomainSegment = function (domainSegment) { | ||
return this.xhr.put(routes_1.interpolate(routes_1.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT, domainSegment), { | ||
body: JSON.stringify({ | ||
domainSegment: lodash_1.omit(domainSegment, ['contractId', 'dataProductId', 'segmentId', 'domainId']) | ||
var updateDomainSegment = function updateDomainSegment(domainSegment) { | ||
return xhr.put(routes.interpolate(routes.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT, domainSegment), { | ||
data: JSON.stringify({ | ||
domainSegment: (0, _lodash.omit)(domainSegment, ['contractId', 'dataProductId', 'segmentId', 'domainId']) | ||
}) | ||
}) | ||
.then(function (result) { return result.json(); }) | ||
.then(function (result) { return exports.transformDomainSegment(result); }); | ||
}).then(function (result) { | ||
return result.json(); | ||
}).then(function (result) { | ||
return transformDomainSegment(result); | ||
}); | ||
}; | ||
return DomainSegmentsModule; | ||
}()); | ||
exports.DomainSegmentsModule = DomainSegmentsModule; | ||
return { | ||
getDomainSegments: getDomainSegments, | ||
getDomainSegment: getDomainSegment, | ||
cloneDomainSegment: cloneDomainSegment, | ||
deleteDomainSegment: deleteDomainSegment, | ||
renameDomainSegment: renameDomainSegment, | ||
syncDomainSegment: syncDomainSegment, | ||
deployDomainSegment: deployDomainSegment, | ||
updateDomainSegment: updateDomainSegment | ||
}; | ||
} |
@@ -1,10 +0,17 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var routes_1 = require("./routes"); | ||
var LogsModule = /** @class */ (function () { | ||
function LogsModule(xhr) { | ||
this.xhr = xhr; | ||
} | ||
LogsModule.prototype.getLogs = function (contractId, dataProductId, domainId, segmentId) { | ||
return this.xhr.get(routes_1.interpolate(routes_1.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_LOG, { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.createModule = createModule; | ||
var _routes = require('./routes'); | ||
var routes = _interopRequireWildcard(_routes); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function createModule(xhr) { | ||
var getLogs = function getLogs(contractId, dataProductId, domainId, segmentId) { | ||
return xhr.get(routes.interpolate(routes.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_LOG, { | ||
contractId: contractId, | ||
@@ -14,6 +21,12 @@ dataProductId: dataProductId, | ||
segmentId: segmentId | ||
})).then(function (data) { return data.logs.map(function (item) { return item.log; }); }); | ||
})).then(function (data) { | ||
return data.logs.map(function (item) { | ||
return item.log; | ||
}); | ||
}); | ||
}; | ||
return LogsModule; | ||
}()); | ||
exports.LogsModule = LogsModule; | ||
return { | ||
getLogs: getLogs | ||
}; | ||
} |
@@ -1,66 +0,75 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var util_1 = require("../util"); | ||
exports.ROOT = '/gdc/admin'; | ||
exports.CONTRACTS = exports.ROOT + "/contracts"; | ||
exports.CONTRACT = exports.CONTRACTS + "/:contractId"; | ||
exports.CONTRACT_DATA_PRODUCTS = exports.CONTRACT + "/dataproducts"; | ||
exports.CONTRACT_DATA_PRODUCT = exports.CONTRACT_DATA_PRODUCTS + "/:dataProductId"; | ||
exports.CONTRACT_DATA_PRODUCT_DOMAIN_DATA_PRODUCTS = exports.CONTRACT_DATA_PRODUCT + "/domaindataproducts"; | ||
exports.CONTRACT_DATA_PRODUCT_DOMAIN_DATA_PRODUCT = exports.CONTRACT_DATA_PRODUCT_DOMAIN_DATA_PRODUCTS + "/:domainId"; | ||
exports.CONTRACT_DATA_PRODUCT_RENAME = exports.CONTRACT_DATA_PRODUCT + "/rename"; | ||
exports.CONTRACT_DATA_PRODUCT_SEGMENTS = exports.CONTRACT_DATA_PRODUCT + "/segments"; | ||
exports.CONTRACT_DATA_PRODUCT_SEGMENT = exports.CONTRACT_DATA_PRODUCT_SEGMENTS + "/:segmentId"; | ||
exports.CONTRACT_DATA_PRODUCT_SEGMENT_RENAME = exports.CONTRACT_DATA_PRODUCT_SEGMENT + "/rename"; | ||
exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENTS = exports.CONTRACT_DATA_PRODUCT_SEGMENT + "/domainsegments"; | ||
exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENTS + "/:domainId"; | ||
exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLONE = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT + "/clone"; | ||
exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_RENAME = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT + "/rename"; | ||
exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_SYNC = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT + "/synchronizeClients"; | ||
exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_LOG = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT + "/activityLog"; | ||
exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENTS = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT + "/clients"; | ||
exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENT = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENTS + "/:clientId"; | ||
exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENT_USERS = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENT + "/project/users"; | ||
exports.CONTRACT_DOMAINS = exports.CONTRACT + "/domains"; | ||
exports.CONTRACT_DOMAIN = exports.CONTRACT_DOMAINS + "/:domainId"; | ||
exports.CONTRACT_DOMAIN_USERS = exports.CONTRACT_DOMAIN + "/users"; | ||
exports.CONTRACT_DOMAIN_PROJECTS = exports.CONTRACT_DOMAIN + "/projects"; | ||
exports.CONTRACT_DOMAIN_PROJECT = exports.CONTRACT_DOMAIN_PROJECTS + "/:projectId"; | ||
exports.CONTRACT_USERS = exports.CONTRACT + "/users"; | ||
exports.USER_CONTRACTS = exports.ROOT + "/users/:userId/contracts"; | ||
exports.DEPLOY_SEGMENT = exports.CONTRACT_DOMAIN + "/dataProducts/:dataProductId/segments/:segmentId/deploy"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.interpolate = exports.parse = exports.DEPLOY_SEGMENT = exports.USER_CONTRACTS = exports.CONTRACT_USERS = exports.CONTRACT_DOMAIN_PROJECT = exports.CONTRACT_DOMAIN_PROJECTS = exports.CONTRACT_DOMAIN_USERS = exports.CONTRACT_DOMAIN = exports.CONTRACT_DOMAINS = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENT_USERS = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENT = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENTS = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_LOG = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_SYNC = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_RENAME = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLONE = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENTS = exports.CONTRACT_DATA_PRODUCT_SEGMENT_RENAME = exports.CONTRACT_DATA_PRODUCT_SEGMENT = exports.CONTRACT_DATA_PRODUCT_SEGMENTS = exports.CONTRACT_DATA_PRODUCT_RENAME = exports.CONTRACT_DATA_PRODUCT_DOMAIN_DATA_PRODUCT = exports.CONTRACT_DATA_PRODUCT_DOMAIN_DATA_PRODUCTS = exports.CONTRACT_DATA_PRODUCT = exports.CONTRACT_DATA_PRODUCTS = exports.CONTRACT = exports.CONTRACTS = exports.ROOT = undefined; | ||
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 _util = require('../util'); | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var ROOT = exports.ROOT = '/gdc/admin'; | ||
var CONTRACTS = exports.CONTRACTS = ROOT + '/contracts'; | ||
var CONTRACT = exports.CONTRACT = CONTRACTS + '/:contractId'; | ||
var CONTRACT_DATA_PRODUCTS = exports.CONTRACT_DATA_PRODUCTS = CONTRACT + '/dataproducts'; | ||
var CONTRACT_DATA_PRODUCT = exports.CONTRACT_DATA_PRODUCT = CONTRACT_DATA_PRODUCTS + '/:dataProductId'; | ||
var CONTRACT_DATA_PRODUCT_DOMAIN_DATA_PRODUCTS = exports.CONTRACT_DATA_PRODUCT_DOMAIN_DATA_PRODUCTS = CONTRACT_DATA_PRODUCT + '/domaindataproducts'; | ||
var CONTRACT_DATA_PRODUCT_DOMAIN_DATA_PRODUCT = exports.CONTRACT_DATA_PRODUCT_DOMAIN_DATA_PRODUCT = CONTRACT_DATA_PRODUCT_DOMAIN_DATA_PRODUCTS + '/:domainId'; | ||
var CONTRACT_DATA_PRODUCT_RENAME = exports.CONTRACT_DATA_PRODUCT_RENAME = CONTRACT_DATA_PRODUCT + '/rename'; | ||
var CONTRACT_DATA_PRODUCT_SEGMENTS = exports.CONTRACT_DATA_PRODUCT_SEGMENTS = CONTRACT_DATA_PRODUCT + '/segments'; | ||
var CONTRACT_DATA_PRODUCT_SEGMENT = exports.CONTRACT_DATA_PRODUCT_SEGMENT = CONTRACT_DATA_PRODUCT_SEGMENTS + '/:segmentId'; | ||
var CONTRACT_DATA_PRODUCT_SEGMENT_RENAME = exports.CONTRACT_DATA_PRODUCT_SEGMENT_RENAME = CONTRACT_DATA_PRODUCT_SEGMENT + '/rename'; | ||
var CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENTS = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENTS = CONTRACT_DATA_PRODUCT_SEGMENT + '/domainsegments'; | ||
var CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT = CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENTS + '/:domainId'; | ||
var CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLONE = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLONE = CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT + '/clone'; | ||
var CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_RENAME = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_RENAME = CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT + '/rename'; | ||
var CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_SYNC = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_SYNC = CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT + '/synchronizeClients'; | ||
var CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_LOG = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_LOG = CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT + '/activityLog'; | ||
var CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENTS = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENTS = CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT + '/clients'; | ||
var CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENT = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENT = CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENTS + '/:clientId'; | ||
var CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENT_USERS = exports.CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENT_USERS = CONTRACT_DATA_PRODUCT_DOMAIN_SEGMENT_CLIENT + '/project/users'; | ||
var CONTRACT_DOMAINS = exports.CONTRACT_DOMAINS = CONTRACT + '/domains'; | ||
var CONTRACT_DOMAIN = exports.CONTRACT_DOMAIN = CONTRACT_DOMAINS + '/:domainId'; | ||
var CONTRACT_DOMAIN_USERS = exports.CONTRACT_DOMAIN_USERS = CONTRACT_DOMAIN + '/users'; | ||
var CONTRACT_DOMAIN_PROJECTS = exports.CONTRACT_DOMAIN_PROJECTS = CONTRACT_DOMAIN + '/projects'; | ||
var CONTRACT_DOMAIN_PROJECT = exports.CONTRACT_DOMAIN_PROJECT = CONTRACT_DOMAIN_PROJECTS + '/:projectId'; | ||
var CONTRACT_USERS = exports.CONTRACT_USERS = CONTRACT + '/users'; | ||
var USER_CONTRACTS = exports.USER_CONTRACTS = ROOT + '/users/:userId/contracts'; | ||
var DEPLOY_SEGMENT = exports.DEPLOY_SEGMENT = CONTRACT_DOMAIN + '/dataProducts/:dataProductId/segments/:segmentId/deploy'; | ||
// parse params in route string accoring to template | ||
// returns params as plain object | ||
exports.parse = function (route, template) { | ||
var parsedRoute = ''; | ||
if (route.startsWith('http')) { | ||
var routeMatch = route.match(/^(https?:)\/\/(([^:/?#]*)(?::([0-9]+))?)([/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/); | ||
parsedRoute = routeMatch ? routeMatch[5] : ''; | ||
} | ||
else { | ||
parsedRoute = route; | ||
} | ||
var parse = exports.parse = function parse(route, template) { | ||
var parsedRoute = route.startsWith('http') ? route.match(/^(https?:)\/\/(([^:/?#]*)(?::([0-9]+))?)([/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/)[5] : route; | ||
var values = parsedRoute.split('/'); | ||
var views = template.split('/'); | ||
return views.reduce(function (result, view, idx) { | ||
if (view[0] === ':') { | ||
return __assign({}, result, (_a = {}, _a[view.substr(1)] = values[idx], _a)); | ||
return _extends({}, result, _defineProperty({}, view.substr(1), values[idx])); | ||
} | ||
return result; | ||
var _a; | ||
}, {}); | ||
}; | ||
// interpolates specified parameters from params into | ||
// the specified route string and returns the result | ||
exports.interpolate = function (route, params, query) { | ||
if (query === void 0) { query = null; } | ||
return route.split('/').map(function (view) { return (view[0] === ':' ? params[view.substr(1)] : view); }).join('/') + util_1.queryString(query); | ||
}; | ||
var interpolate = exports.interpolate = function interpolate(route, params, query) { | ||
return route.split('/').map(function (view) { | ||
return view[0] === ':' ? params[view.substr(1)] : view; | ||
}).join('/') + (0, _util.queryString)(query); | ||
}; |
@@ -1,41 +0,57 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var routes_1 = require("./routes"); | ||
var domainSegments = require("./domainSegments"); | ||
exports.transformSegment = function (item) { | ||
var _a = routes_1.parse(item.segment.links.self, routes_1.CONTRACT_DATA_PRODUCT_SEGMENT), contractId = _a.contractId, dataProductId = _a.dataProductId; | ||
var segment = __assign({ contractId: contractId, | ||
dataProductId: dataProductId }, item.segment); | ||
if (segment.domainSegments) { | ||
segment.domainSegments = segment.domainSegments.map(domainSegments.transformDomainSegment); | ||
} | ||
return segment; | ||
}; | ||
var SegmentsModule = /** @class */ (function () { | ||
function SegmentsModule(xhr) { | ||
this.xhr = xhr; | ||
} | ||
SegmentsModule.prototype.getDataProductSegments = function (contractId, dataProductId) { | ||
return this.xhr.get(routes_1.interpolate(routes_1.CONTRACT_DATA_PRODUCT_SEGMENTS, { contractId: contractId, dataProductId: dataProductId })) | ||
.then(function (r) { return r.getData(); }) | ||
.then(function (data) { return ({ | ||
items: data.segments.items.map(exports.transformSegment), | ||
status: data.segments.status | ||
}); }); | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
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; }; | ||
exports.createModule = createModule; | ||
var _routes = require('./routes'); | ||
var routes = _interopRequireWildcard(_routes); | ||
var _domainSegments = require('./domainSegments'); | ||
var domainSegments = _interopRequireWildcard(_domainSegments); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function createModule(xhr) { | ||
var transformSegment = function transformSegment(item) { | ||
var _routes$parse = routes.parse(item.segment.links.self, routes.CONTRACT_DATA_PRODUCT_SEGMENT), | ||
contractId = _routes$parse.contractId, | ||
dataProductId = _routes$parse.dataProductId; | ||
var segment = _extends({ | ||
contractId: contractId, | ||
dataProductId: dataProductId | ||
}, item.segment); | ||
if (segment.domainSegments) { | ||
segment.domainSegments = segment.domainSegments.map(domainSegments.transformDomainSegment); | ||
} | ||
return segment; | ||
}; | ||
SegmentsModule.prototype.createSegment = function (contractId, dataProductId, segmentId, domainIds) { | ||
return this.xhr.post(routes_1.interpolate(routes_1.CONTRACT_DATA_PRODUCT_SEGMENTS, { contractId: contractId, dataProductId: dataProductId }), { | ||
body: JSON.stringify({ | ||
var getDataProductSegments = function getDataProductSegments(contractId, dataProductId) { | ||
return xhr.get(routes.interpolate(routes.CONTRACT_DATA_PRODUCT_SEGMENTS, { contractId: contractId, dataProductId: dataProductId })).then(function (data) { | ||
return { | ||
items: data.segments.items.map(transformSegment), | ||
status: data.segments.status | ||
}; | ||
}); | ||
}; | ||
var createSegment = function createSegment(contractId, dataProductId, segmentId, domainIds) { | ||
return xhr.post(routes.interpolate(routes.CONTRACT_DATA_PRODUCT_SEGMENTS, { contractId: contractId, dataProductId: dataProductId }), { | ||
data: JSON.stringify({ | ||
segmentCreate: { | ||
id: segmentId, | ||
title: segmentId, | ||
domains: domainIds.map(function (domainId) { return routes_1.interpolate(routes_1.CONTRACT_DOMAIN, { contractId: contractId, domainId: domainId }); }) | ||
domains: domainIds.map(function (domainId) { | ||
return routes.interpolate(routes.CONTRACT_DOMAIN, { contractId: contractId, domainId: domainId }); | ||
}) | ||
} | ||
@@ -45,12 +61,18 @@ }) | ||
}; | ||
SegmentsModule.prototype.renameSegment = function (contractId, dataProductId, segmentId, newSegmentId) { | ||
return this.xhr.post(routes_1.interpolate(routes_1.CONTRACT_DATA_PRODUCT_SEGMENT_RENAME, { contractId: contractId, dataProductId: dataProductId, segmentId: segmentId }), { | ||
body: JSON.stringify({ segmentRename: { id: newSegmentId } }) | ||
}); | ||
var renameSegment = function renameSegment(contractId, dataProductId, segmentId, newSegmentId) { | ||
return xhr.post(routes.interpolate(routes.CONTRACT_DATA_PRODUCT_SEGMENT_RENAME, { contractId: contractId, dataProductId: dataProductId, segmentId: segmentId }), { data: JSON.stringify({ segmentRename: { id: newSegmentId } }) }); | ||
}; | ||
SegmentsModule.prototype.deleteSegment = function (contractId, dataProductId, segmentId) { | ||
return this.xhr.del(routes_1.interpolate(routes_1.CONTRACT_DATA_PRODUCT_SEGMENT, { contractId: contractId, dataProductId: dataProductId, segmentId: segmentId })); | ||
var deleteSegment = function deleteSegment(contractId, dataProductId, segmentId) { | ||
return xhr.del(routes.interpolate(routes.CONTRACT_DATA_PRODUCT_SEGMENT, { contractId: contractId, dataProductId: dataProductId, segmentId: segmentId })); | ||
}; | ||
return SegmentsModule; | ||
}()); | ||
exports.SegmentsModule = SegmentsModule; | ||
return { | ||
transformSegment: transformSegment, | ||
getDataProductSegments: getDataProductSegments, | ||
createSegment: createSegment, | ||
renameSegment: renameSegment, | ||
deleteSegment: deleteSegment | ||
}; | ||
} |
@@ -1,12 +0,13 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var lodash_1 = require("lodash"); | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
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; }; | ||
exports.createModule = createModule; | ||
var _lodash = require('lodash'); | ||
var REQUEST_DEFAULTS = { | ||
@@ -18,2 +19,3 @@ types: ['attribute', 'metric', 'fact'], | ||
}; | ||
var LOAD_DATE_DATASET_DEFAULTS = { | ||
@@ -23,2 +25,3 @@ includeUnavailableDateDataSetsCount: true, | ||
}; | ||
/** | ||
@@ -37,55 +40,84 @@ * Convert specific params in options to "requiredDataSets" structure. For more details look into | ||
*/ | ||
var getRequiredDataSets = function (options) { | ||
if (lodash_1.get(options, 'returnAllRelatedDateDataSets')) { | ||
var getRequiredDataSets = function getRequiredDataSets(options) { | ||
if ((0, _lodash.get)(options, 'returnAllRelatedDateDataSets')) { | ||
return {}; | ||
} | ||
if (lodash_1.get(options, 'returnAllDateDataSets')) { | ||
if ((0, _lodash.get)(options, 'returnAllDateDataSets')) { | ||
return { requiredDataSets: { type: 'ALL' } }; | ||
} | ||
if (lodash_1.get(options, 'dataSetIdentifier')) { | ||
if ((0, _lodash.get)(options, 'dataSetIdentifier')) { | ||
return { requiredDataSets: { | ||
type: 'CUSTOM', | ||
customIdentifiers: [lodash_1.get(options, 'dataSetIdentifier')] | ||
customIdentifiers: [(0, _lodash.get)(options, 'dataSetIdentifier')] | ||
} }; | ||
} | ||
return { requiredDataSets: { type: 'PRODUCTION' } }; | ||
}; | ||
var CatalogueModule = /** @class */ (function () { | ||
function CatalogueModule(xhr, execution) { | ||
this.xhr = xhr; | ||
this.execution = execution; | ||
function createModule(xhr, execution) { | ||
function bucketItemsToExecConfig(projectId, mdObj) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
return execution.mdToExecutionDefinitionsAndColumns(projectId, mdObj, options).then(function (definitionsAndColumns) { | ||
var definitions = (0, _lodash.get)(definitionsAndColumns, 'definitions'); | ||
return (0, _lodash.get)(definitionsAndColumns, 'columns', []).map(function (column) { | ||
var definition = (0, _lodash.find)(definitions, function (_ref) { | ||
var metricDefinition = _ref.metricDefinition; | ||
return (0, _lodash.get)(metricDefinition, 'identifier') === column; | ||
}); | ||
var maql = (0, _lodash.get)(definition, 'metricDefinition.expression'); | ||
if (maql) { | ||
return maql; | ||
} | ||
return column; | ||
}); | ||
}); | ||
} | ||
CatalogueModule.prototype.loadItems = function (projectId, options) { | ||
var _this = this; | ||
if (options === void 0) { options = {}; } | ||
var request = lodash_1.omit(__assign({}, REQUEST_DEFAULTS, options, getRequiredDataSets(options)), [ | ||
'dataSetIdentifier', | ||
'returnAllDateDataSets', | ||
'attributesMap' | ||
]); | ||
var mdObj = lodash_1.get(lodash_1.cloneDeep(options), 'bucketItems'); | ||
var attributesMap = lodash_1.get(options, 'attributesMap'); | ||
var hasBuckets = lodash_1.get(mdObj, 'buckets') !== undefined; | ||
function loadCatalog(projectId, catalogRequest) { | ||
var uri = '/gdc/internal/projects/' + projectId + '/loadCatalog'; | ||
return xhr.post(uri, { data: { catalogRequest: catalogRequest } }).then(xhr.parseJSON).then(function (data) { | ||
return data.catalogResponse; | ||
}); | ||
} | ||
function loadItems(projectId) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var request = (0, _lodash.omit)(_extends({}, REQUEST_DEFAULTS, options, getRequiredDataSets(options)), ['dataSetIdentifier', 'returnAllDateDataSets', 'attributesMap']); | ||
var mdObj = (0, _lodash.get)((0, _lodash.cloneDeep)(options), 'bucketItems'); | ||
var attributesMap = (0, _lodash.get)(options, 'attributesMap'); | ||
var hasBuckets = (0, _lodash.get)(mdObj, 'buckets') !== undefined; | ||
if (hasBuckets) { | ||
return this.bucketItemsToExecConfig(projectId, mdObj, { attributesMap: attributesMap }) | ||
.then(function (bucketItems) { return _this.loadCatalog(projectId, __assign({}, request, { bucketItems: bucketItems })); }); | ||
return bucketItemsToExecConfig(projectId, mdObj, { attributesMap: attributesMap }).then(function (bucketItems) { | ||
return loadCatalog(projectId, _extends({}, request, { | ||
bucketItems: bucketItems | ||
})); | ||
}); | ||
} | ||
return this.loadCatalog(projectId, request); | ||
}; | ||
CatalogueModule.prototype.loadDateDataSets = function (projectId, options) { | ||
var _this = this; | ||
var mdObj = lodash_1.get(lodash_1.cloneDeep(options), 'bucketItems'); | ||
var bucketItemsPromise = mdObj | ||
? this.bucketItemsToExecConfig(projectId, mdObj, { removeDateItems: true, attributesMap: lodash_1.get(options, 'attributesMap') }) | ||
: Promise.resolve(); | ||
return loadCatalog(projectId, request); | ||
} | ||
function requestDateDataSets(projectId, dateDataSetsRequest) { | ||
var uri = '/gdc/internal/projects/' + projectId + '/loadDateDataSets'; | ||
return xhr.post(uri, { data: { dateDataSetsRequest: dateDataSetsRequest } }).then(xhr.parseJSON).then(function (data) { | ||
return data.dateDataSetsResponse; | ||
}); | ||
} | ||
function loadDateDataSets(projectId, options) { | ||
var mdObj = (0, _lodash.get)((0, _lodash.cloneDeep)(options), 'bucketItems'); | ||
var bucketItemsPromise = mdObj ? bucketItemsToExecConfig(projectId, mdObj, { removeDateItems: true, attributesMap: (0, _lodash.get)(options, 'attributesMap') }) : Promise.resolve(); | ||
return bucketItemsPromise.then(function (bucketItems) { | ||
var omittedOptions = [ | ||
'filter', | ||
'types', | ||
'paging', | ||
'dataSetIdentifier', | ||
'returnAllDateDataSets', | ||
'returnAllRelatedDateDataSets', | ||
'attributesMap' | ||
]; | ||
var omittedOptions = ['filter', 'types', 'paging', 'dataSetIdentifier', 'returnAllDateDataSets', 'returnAllRelatedDateDataSets', 'attributesMap']; | ||
// includeObjectsWithTags has higher priority than excludeObjectsWithTags, | ||
@@ -96,38 +128,15 @@ // so when present omit excludeObjectsWithTags | ||
} | ||
var request = lodash_1.omit(__assign({}, LOAD_DATE_DATASET_DEFAULTS, REQUEST_DEFAULTS, options, getRequiredDataSets(options), { bucketItems: bucketItems }), omittedOptions); | ||
return _this.requestDateDataSets(projectId, request); | ||
var request = (0, _lodash.omit)(_extends({}, LOAD_DATE_DATASET_DEFAULTS, REQUEST_DEFAULTS, options, getRequiredDataSets(options), { | ||
bucketItems: bucketItems | ||
}), omittedOptions); | ||
return requestDateDataSets(projectId, request); | ||
}); | ||
} | ||
return { | ||
loadItems: loadItems, | ||
loadDateDataSets: loadDateDataSets | ||
}; | ||
CatalogueModule.prototype.requestDateDataSets = function (projectId, dateDataSetsRequest) { | ||
var uri = "/gdc/internal/projects/" + projectId + "/loadDateDataSets"; | ||
return this.xhr.post(uri, { data: { dateDataSetsRequest: dateDataSetsRequest } }) | ||
.then((function (r) { return r.getData(); })) | ||
.then(function (data) { return data.dateDataSetsResponse; }); | ||
}; | ||
CatalogueModule.prototype.bucketItemsToExecConfig = function (projectId, mdObj, options) { | ||
if (options === void 0) { options = {}; } | ||
return this.execution.mdToExecutionDefinitionsAndColumns(projectId, mdObj, options) | ||
.then(function (definitionsAndColumns) { | ||
var definitions = lodash_1.get(definitionsAndColumns, 'definitions'); | ||
return lodash_1.get(definitionsAndColumns, 'columns', []).map(function (column) { | ||
var definition = lodash_1.find(definitions, function (_a) { | ||
var metricDefinition = _a.metricDefinition; | ||
return lodash_1.get(metricDefinition, 'identifier') === column; | ||
}); | ||
var maql = lodash_1.get(definition, 'metricDefinition.expression'); | ||
if (maql) { | ||
return maql; | ||
} | ||
return column; | ||
}); | ||
}); | ||
}; | ||
CatalogueModule.prototype.loadCatalog = function (projectId, catalogRequest) { | ||
var uri = "/gdc/internal/projects/" + projectId + "/loadCatalog"; | ||
return this.xhr.post(uri, { data: { catalogRequest: catalogRequest } }) | ||
.then((function (r) { return r.getData(); })) | ||
.then(function (data) { return data.catalogResponse; }); | ||
}; | ||
return CatalogueModule; | ||
}()); | ||
exports.CatalogueModule = CatalogueModule; | ||
} |
@@ -1,13 +0,16 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved. | ||
var lodash_1 = require("lodash"); | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
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; }; // Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved. | ||
exports.sanitizeDomain = sanitizeDomain; | ||
exports.sanitizeConfig = sanitizeConfig; | ||
exports.createModule = createModule; | ||
var _lodash = require('lodash'); | ||
/** | ||
@@ -24,3 +27,5 @@ * Config module holds SDK configuration variables | ||
*/ | ||
var URL_REGEXP = '(?:(https)://+|(www\\.)?)\\w[:;,\\.?\\[\\]\\w/~%&=+#-@!]*'; | ||
function sanitizeDomain(domain) { | ||
@@ -30,11 +35,13 @@ if (domain === null) { | ||
} | ||
var sanitizedDomain = domain || ''; | ||
var link = sanitizedDomain.match(URL_REGEXP); | ||
if (!link) { | ||
throw new Error(domain + " is not a valid url"); | ||
throw new Error(domain + ' is not a valid url'); | ||
} | ||
// ensure https:// prefix and strip possible trailing / | ||
return "https://" + link[0].replace(/^https?:\/\/|\/$/g, ''); | ||
return 'https://' + link[0].replace(/^https?:\/\/|\/$/g, ''); | ||
} | ||
exports.sanitizeDomain = sanitizeDomain; | ||
/** | ||
@@ -47,3 +54,3 @@ * Returns sanitized config | ||
function sanitizeConfig(config) { | ||
var sanitized = __assign({}, config); | ||
var sanitized = _extends({}, config); | ||
if (config.domain) { | ||
@@ -54,3 +61,3 @@ sanitized.domain = sanitizeDomain(config.domain); | ||
} | ||
exports.sanitizeConfig = sanitizeConfig; | ||
/** | ||
@@ -63,9 +70,7 @@ * Config factory | ||
*/ | ||
var ConfigModule = /** @class */ (function () { | ||
function ConfigModule(configStorage) { | ||
this.configStorage = configStorage; | ||
if (arguments.length !== 1) { | ||
throw new Error('Config module has to be called with exactly one argument.'); | ||
} | ||
function createModule(configStorage) { | ||
if (arguments.length !== 1) { | ||
throw new Error('Config module has to be called with exactly one argument.'); | ||
} | ||
/** | ||
@@ -80,5 +85,6 @@ * Sets custom domain. Parameter is url which has always to be https:// | ||
*/ | ||
ConfigModule.prototype.setCustomDomain = function (domain) { | ||
this.configStorage.domain = sanitizeDomain(domain); // eslint-disable-line no-param-reassign | ||
}; | ||
function setCustomDomain(domain) { | ||
configStorage.domain = sanitizeDomain(domain); // eslint-disable-line no-param-reassign | ||
} | ||
/** | ||
@@ -89,5 +95,6 @@ * Returns current domain | ||
*/ | ||
ConfigModule.prototype.getCustomDomain = function () { | ||
return this.configStorage.domain; | ||
}; | ||
function getCustomDomain() { | ||
return configStorage.domain; | ||
} | ||
/** | ||
@@ -101,7 +108,9 @@ * Sets JS package and version info | ||
*/ | ||
ConfigModule.prototype.setJsPackage = function (name, version) { | ||
if (!this.configStorage.originPackage) { // only set the first (topmost) package | ||
this.configStorage.originPackage = { name: name, version: version }; // eslint-disable-line no-param-reassign | ||
function setJsPackage(name, version) { | ||
if (!configStorage.originPackage) { | ||
// only set the first (topmost) package | ||
configStorage.originPackage = { name: name, version: version }; // eslint-disable-line no-param-reassign | ||
} | ||
}; | ||
} | ||
/** | ||
@@ -114,13 +123,22 @@ * Returns JS package and version info | ||
*/ | ||
ConfigModule.prototype.getJsPackage = function () { | ||
return this.configStorage.originPackage; | ||
function getJsPackage() { | ||
return configStorage.originPackage; | ||
} | ||
function setRequestHeader(key, value) { | ||
(0, _lodash.set)(configStorage, ['xhrSettings', 'headers', key], value); | ||
} | ||
function getRequestHeader(key) { | ||
return (0, _lodash.get)(configStorage, ['xhrSettings', 'headers', key]); | ||
} | ||
return { | ||
setCustomDomain: setCustomDomain, | ||
getCustomDomain: getCustomDomain, | ||
setJsPackage: setJsPackage, | ||
getJsPackage: getJsPackage, | ||
setRequestHeader: setRequestHeader, | ||
getRequestHeader: getRequestHeader | ||
}; | ||
ConfigModule.prototype.setRequestHeader = function (key, value) { | ||
lodash_1.set(this.configStorage, ['xhrSettings', 'headers', key], value); | ||
}; | ||
ConfigModule.prototype.getRequestHeader = function (key) { | ||
return lodash_1.get(this.configStorage, ['xhrSettings', 'headers', key]); | ||
}; | ||
return ConfigModule; | ||
}()); | ||
exports.ConfigModule = ConfigModule; | ||
} |
@@ -1,7 +0,14 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// Copyright (C) 2007-2017, GoodData(R) Corporation. All rights reserved. | ||
var experimental_executions_1 = require("./execution/experimental-executions"); | ||
var attributesMapLoader_1 = require("./utils/attributesMapLoader"); | ||
var execute_afm_1 = require("./execution/execute-afm"); | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.createModule = createModule; | ||
var _experimentalExecutions = require('./execution/experimental-executions'); | ||
var _attributesMapLoader = require('./utils/attributesMapLoader'); | ||
var _executeAfm = require('./execution/execute-afm'); | ||
/** | ||
@@ -14,25 +21,14 @@ * Execution endpoints | ||
*/ | ||
var ExecutionModule = /** @class */ (function () { | ||
function ExecutionModule(xhr, md) { | ||
this.xhr = xhr; | ||
this.md = md; | ||
} | ||
ExecutionModule.prototype.getData = function (projectId, columns, executionConfiguration, settings) { | ||
if (executionConfiguration === void 0) { executionConfiguration = {}; } | ||
if (settings === void 0) { settings = {}; } | ||
return this.getExperimentalExecutionsModule().getData(projectId, columns, executionConfiguration, settings); | ||
function createModule(xhr, md) { | ||
var loadAttributesMap = (0, _attributesMapLoader.createModule)(md); | ||
var _experimentalExecutio = (0, _experimentalExecutions.createModule)(xhr, loadAttributesMap), | ||
getData = _experimentalExecutio.getData, | ||
mdToExecutionDefinitionsAndColumns = _experimentalExecutio.mdToExecutionDefinitionsAndColumns; | ||
return { | ||
getData: getData, | ||
mdToExecutionDefinitionsAndColumns: mdToExecutionDefinitionsAndColumns, | ||
executeAfm: (0, _executeAfm.createModule)(xhr) | ||
}; | ||
ExecutionModule.prototype.mdToExecutionDefinitionsAndColumns = function (projectId, mdObj, options) { | ||
if (options === void 0) { options = {}; } | ||
return this.getExperimentalExecutionsModule().mdToExecutionDefinitionsAndColumns(projectId, mdObj, options); | ||
}; | ||
ExecutionModule.prototype.executeAfm = function (projectId, execution) { | ||
return (new execute_afm_1.ExecuteAfmModule(this.xhr)).executeAfm(projectId, execution); | ||
}; | ||
ExecutionModule.prototype.getExperimentalExecutionsModule = function () { | ||
var loaderModule = new attributesMapLoader_1.AttributesMapLoaderModule(this.md); | ||
return new experimental_executions_1.ExperimentalExecutionsModule(this.xhr, loaderModule.loadAttributesMap.bind(loaderModule)); | ||
}; | ||
return ExecutionModule; | ||
}()); | ||
exports.ExecutionModule = ExecutionModule; | ||
} // Copyright (C) 2007-2017, GoodData(R) Corporation. All rights reserved. |
@@ -1,49 +0,76 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved. | ||
var lodash_1 = require("lodash"); | ||
var invariant = require("invariant"); | ||
var qs = require("qs"); | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
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 _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"); } }; }(); | ||
exports.mergePageData = mergePageData; | ||
exports.nextPageOffset = nextPageOffset; | ||
exports.createModule = createModule; | ||
var _lodash = require('lodash'); | ||
var _invariant = require('invariant'); | ||
var _invariant2 = _interopRequireDefault(_invariant); | ||
var _qs = require('qs'); | ||
var _qs2 = _interopRequireDefault(_qs); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } // Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved. | ||
var PAGE_SIZE = 500; | ||
var DEFAULT_DIMENSION_COUNT = 2; | ||
function getDimensionality(execution) { | ||
var dimensions = lodash_1.get(execution, 'execution.resultSpec.dimensions'); | ||
return dimensions | ||
? dimensions.length | ||
: DEFAULT_DIMENSION_COUNT; | ||
var dimensions = (0, _lodash.get)(execution, 'execution.resultSpec.dimensions'); | ||
return dimensions ? dimensions.length : DEFAULT_DIMENSION_COUNT; | ||
} | ||
function getLimit(offset) { | ||
return Array(offset.length).fill(PAGE_SIZE); | ||
} | ||
// works only for one or two dimensions | ||
function mergePageData(result, currentPage) { | ||
var _a = currentPage.executionResult, paging = _a.paging, data = _a.data, headerItems = _a.headerItems; | ||
var _currentPage$executio = currentPage.executionResult, | ||
paging = _currentPage$executio.paging, | ||
data = _currentPage$executio.data, | ||
headerItems = _currentPage$executio.headerItems; | ||
var rowOffset = paging.offset[0]; | ||
if (result.executionResult.data[rowOffset]) { // appending columns to existing rows | ||
if (result.executionResult.data[rowOffset]) { | ||
// appending columns to existing rows | ||
for (var i = 0; i < data.length; i += 1) { | ||
var columns = data[i]; | ||
(_b = result.executionResult.data[i + rowOffset]).push.apply(_b, columns); | ||
var _result$executionResu; | ||
(_result$executionResu = result.executionResult.data[i + rowOffset]).push.apply(_result$executionResu, _toConsumableArray(data[i])); | ||
} | ||
} else { | ||
var _result$executionResu2; | ||
// appending new rows | ||
(_result$executionResu2 = result.executionResult.data).push.apply(_result$executionResu2, _toConsumableArray(data)); | ||
} | ||
else { // appending new rows | ||
(_c = result.executionResult.data).push.apply(_c, data); | ||
} | ||
var doDimension = function (dim) { | ||
var otherDimension = (dim === 0 ? 1 : 0); | ||
var isEdge = (paging.offset[otherDimension] === 0); | ||
if (isEdge && headerItems && result.executionResult.headerItems) { | ||
var doDimension = function doDimension(dim) { | ||
var otherDimension = dim === 0 ? 1 : 0; | ||
var isEdge = paging.offset[otherDimension] === 0; | ||
if (isEdge) { | ||
for (var attrIdx = 0; attrIdx < headerItems[dim].length; attrIdx += 1) { | ||
(_a = result.executionResult.headerItems[dim][attrIdx]).push.apply(_a, headerItems[dim][attrIdx]); | ||
var _result$executionResu3; | ||
(_result$executionResu3 = result.executionResult.headerItems[dim][attrIdx]).push.apply(_result$executionResu3, _toConsumableArray(headerItems[dim][attrIdx])); | ||
} | ||
} | ||
var _a; | ||
}; | ||
// careful: for 1 dimension we already have the headers from first page | ||
@@ -54,9 +81,11 @@ if (paging.offset.length > 1) { | ||
} | ||
return result; | ||
var _b, _c; | ||
} | ||
exports.mergePageData = mergePageData; | ||
function nextPageOffset(_a) { | ||
var offset = _a.offset, total = _a.total; | ||
var newOffset = lodash_1.clone(offset); | ||
function nextPageOffset(_ref) { | ||
var offset = _ref.offset, | ||
total = _ref.total; | ||
var newOffset = (0, _lodash.clone)(offset); | ||
var maxDimension = offset.length - 1; | ||
@@ -73,7 +102,38 @@ // we need last dimension first (aka columns, then rows) to allow array appending in merge fnc | ||
} | ||
exports.nextPageOffset = nextPageOffset; | ||
var ExecuteAfmModule = /** @class */ (function () { | ||
function ExecuteAfmModule(xhr) { | ||
this.xhr = xhr; | ||
function createModule(xhr) { | ||
function fetchExecutionResult(pollingUri, offset) { | ||
var _pollingUri$split = pollingUri.split(/\?(.+)/), | ||
_pollingUri$split2 = _slicedToArray(_pollingUri$split, 2), | ||
uriPart = _pollingUri$split2[0], | ||
queryPart = _pollingUri$split2[1]; | ||
var query = _extends({}, _qs2.default.parse(queryPart), { | ||
limit: getLimit(offset).join(','), | ||
offset: offset.join(',') | ||
}); | ||
var finalPollingUri = uriPart + _qs2.default.stringify(query, { addQueryPrefix: true }); | ||
return xhr.ajax(finalPollingUri, { method: 'GET' }).then(function (r) { | ||
if (r.status === 204) { | ||
return null; | ||
} | ||
return r.json(); | ||
}); | ||
} | ||
function getOnePage(pollingUri, offset) { | ||
var prevResult = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; | ||
return fetchExecutionResult(pollingUri, offset).then(function (executionResult) { | ||
if (executionResult === null) { | ||
return null; | ||
} | ||
var newResult = prevResult ? mergePageData(prevResult, executionResult) : executionResult; | ||
var nextOffset = nextPageOffset(executionResult.executionResult.paging); | ||
return nextOffset ? getOnePage(pollingUri, nextOffset, newResult) : newResult; | ||
}); | ||
} | ||
/** | ||
@@ -89,12 +149,10 @@ * Execute AFM and fetch data results | ||
*/ | ||
ExecuteAfmModule.prototype.executeAfm = function (projectId, execution) { | ||
var _this = this; | ||
function executeAfm(projectId, execution) { | ||
var dimensionality = getDimensionality(execution); | ||
invariant(dimensionality <= 2, 'executeAfm does not support more than 2 dimensions'); | ||
return this.xhr.post("/gdc/app/projects/" + projectId + "/executeAfm", { body: JSON.stringify(execution) }) | ||
.then((function (r) { return r.getData(); })) | ||
.then(function (executionResponse) { | ||
(0, _invariant2.default)(dimensionality <= 2, 'executeAfm does not support more than 2 dimensions'); | ||
return xhr.post('/gdc/app/projects/' + projectId + '/executeAfm', { body: JSON.stringify(execution) }).then(xhr.parseJSON).then(function (executionResponse) { | ||
var offset = Array(dimensionality).fill(0); // offset holds information on dimensionality | ||
var pollingUri = executionResponse.executionResponse.links.executionResult; | ||
return _this.getOnePage(pollingUri, offset).then(function (executionResult) { | ||
return getOnePage(pollingUri, offset).then(function (executionResult) { | ||
return { | ||
@@ -106,30 +164,5 @@ executionResponse: executionResponse, | ||
}); | ||
}; | ||
ExecuteAfmModule.prototype.fetchExecutionResult = function (pollingUri, offset) { | ||
var _a = pollingUri.split(/\?(.+)/), uriPart = _a[0], queryPart = _a[1]; | ||
var query = __assign({}, qs.parse(queryPart), { limit: getLimit(offset).join(','), offset: offset.join(',') }); | ||
var finalPollingUri = uriPart + qs.stringify(query, { addQueryPrefix: true }); | ||
return this.xhr.ajax(finalPollingUri, { method: 'GET' }).then(function (r) { | ||
if (r.response.status === 204) { | ||
return null; | ||
} | ||
return r.getData(); | ||
}); | ||
}; | ||
ExecuteAfmModule.prototype.getOnePage = function (pollingUri, offset, prevResult) { | ||
var _this = this; | ||
if (prevResult === void 0) { prevResult = null; } | ||
return this.fetchExecutionResult(pollingUri, offset).then(function (executionResult) { | ||
if (executionResult === null) { | ||
return null; | ||
} | ||
var newResult = prevResult ? mergePageData(prevResult, executionResult) : executionResult; | ||
var nextOffset = nextPageOffset(executionResult.executionResult.paging); | ||
return nextOffset | ||
? _this.getOnePage(pollingUri, nextOffset, newResult) | ||
: newResult; | ||
}); | ||
}; | ||
return ExecuteAfmModule; | ||
}()); | ||
exports.ExecuteAfmModule = ExecuteAfmModule; | ||
} | ||
return executeAfm; | ||
} |
@@ -1,28 +0,48 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved. | ||
var md5 = require("md5"); | ||
var invariant = require("invariant"); | ||
var lodash_1 = require("lodash"); | ||
var rules_1 = require("../utils/rules"); | ||
var definitions_1 = require("../utils/definitions"); | ||
var attributesMapLoader_1 = require("../utils/attributesMapLoader"); | ||
var visualizationObjectHelper_1 = require("../utils/visualizationObjectHelper"); | ||
var notEmpty = lodash_1.negate(lodash_1.isEmpty); | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
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 _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.createModule = createModule; | ||
var _md = require('md5'); | ||
var _md2 = _interopRequireDefault(_md); | ||
var _invariant = require('invariant'); | ||
var _invariant2 = _interopRequireDefault(_invariant); | ||
var _lodash = require('lodash'); | ||
var _rules = require('../utils/rules'); | ||
var _rules2 = _interopRequireDefault(_rules); | ||
var _definitions = require('../utils/definitions'); | ||
var _attributesMapLoader = require('../utils/attributesMapLoader'); | ||
var _visualizationObjectHelper = require('../utils/visualizationObjectHelper'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
var notEmpty = (0, _lodash.negate)(_lodash.isEmpty); | ||
function findHeaderForMappingFn(mapping, header) { | ||
return ((mapping.element === header.id || mapping.element === header.uri) && | ||
header.measureIndex === undefined); | ||
return (mapping.element === header.id || mapping.element === header.uri) && header.measureIndex === undefined; | ||
} | ||
function wrapMeasureIndexesFromMappings(metricMappings, headers) { | ||
if (metricMappings) { | ||
metricMappings.forEach(function (mapping) { | ||
var header = lodash_1.find(headers, lodash_1.partial(findHeaderForMappingFn, mapping)); | ||
var header = (0, _lodash.find)(headers, (0, _lodash.partial)(findHeaderForMappingFn, mapping)); | ||
if (header) { | ||
@@ -36,2 +56,3 @@ header.measureIndex = mapping.measureIndex; | ||
} | ||
var emptyResult = { | ||
@@ -43,3 +64,5 @@ extendedTabularDataResult: { | ||
}; | ||
var MAX_TITLE_LENGTH = 1000; | ||
function getMetricTitle(suffix, title) { | ||
@@ -49,63 +72,79 @@ var maxLength = MAX_TITLE_LENGTH - suffix.length; | ||
if (title[title.length - 1] === ')') { | ||
return title.substring(0, maxLength - 2) + "\u2026)" + suffix; | ||
return title.substring(0, maxLength - 2) + '\u2026)' + suffix; | ||
} | ||
return title.substring(0, maxLength - 1) + "\u2026" + suffix; | ||
return title.substring(0, maxLength - 1) + '\u2026' + suffix; | ||
} | ||
return "" + title + suffix; | ||
return '' + title + suffix; | ||
} | ||
var getBaseMetricTitle = lodash_1.partial(getMetricTitle, ''); | ||
var getBaseMetricTitle = (0, _lodash.partial)(getMetricTitle, ''); | ||
var CONTRIBUTION_METRIC_FORMAT = '#,##0.00%'; | ||
function getPoPDefinition(measure) { | ||
return lodash_1.get(measure, ['definition', 'popMeasureDefinition'], {}); | ||
return (0, _lodash.get)(measure, ['definition', 'popMeasureDefinition'], {}); | ||
} | ||
function getAggregation(measure) { | ||
return lodash_1.get(visualizationObjectHelper_1.getDefinition(measure), 'aggregation', '').toLowerCase(); | ||
return (0, _lodash.get)((0, _visualizationObjectHelper.getDefinition)(measure), 'aggregation', '').toLowerCase(); | ||
} | ||
function isEmptyFilter(metricFilter) { | ||
if (lodash_1.get(metricFilter, 'positiveAttributeFilter')) { | ||
return lodash_1.isEmpty(lodash_1.get(metricFilter, ['positiveAttributeFilter', 'in'])); | ||
if ((0, _lodash.get)(metricFilter, 'positiveAttributeFilter')) { | ||
return (0, _lodash.isEmpty)((0, _lodash.get)(metricFilter, ['positiveAttributeFilter', 'in'])); | ||
} | ||
if (lodash_1.get(metricFilter, 'negativeAttributeFilter')) { | ||
return lodash_1.isEmpty(lodash_1.get(metricFilter, ['negativeAttributeFilter', 'notIn'])); | ||
if ((0, _lodash.get)(metricFilter, 'negativeAttributeFilter')) { | ||
return (0, _lodash.isEmpty)((0, _lodash.get)(metricFilter, ['negativeAttributeFilter', 'notIn'])); | ||
} | ||
if (lodash_1.get(metricFilter, 'absoluteDateFilter')) { | ||
return lodash_1.get(metricFilter, ['absoluteDateFilter', 'from']) === undefined && | ||
lodash_1.get(metricFilter, ['absoluteDateFilter', 'to']) === undefined; | ||
if ((0, _lodash.get)(metricFilter, 'absoluteDateFilter')) { | ||
return (0, _lodash.get)(metricFilter, ['absoluteDateFilter', 'from']) === undefined && (0, _lodash.get)(metricFilter, ['absoluteDateFilter', 'to']) === undefined; | ||
} | ||
return lodash_1.get(metricFilter, ['relativeDateFilter', 'from']) === undefined && | ||
lodash_1.get(metricFilter, ['relativeDateFilter', 'to']) === undefined; | ||
return (0, _lodash.get)(metricFilter, ['relativeDateFilter', 'from']) === undefined && (0, _lodash.get)(metricFilter, ['relativeDateFilter', 'to']) === undefined; | ||
} | ||
function allFiltersEmpty(item) { | ||
return lodash_1.every(lodash_1.map(visualizationObjectHelper_1.getMeasureFilters(item), function (f) { return isEmptyFilter(f); })); | ||
return (0, _lodash.every)((0, _lodash.map)((0, _visualizationObjectHelper.getMeasureFilters)(item), function (f) { | ||
return isEmptyFilter(f); | ||
})); | ||
} | ||
function isDerived(measure) { | ||
var aggregation = getAggregation(measure); | ||
return (aggregation !== '' || !allFiltersEmpty(measure)); | ||
return aggregation !== '' || !allFiltersEmpty(measure); | ||
} | ||
function getAttrTypeFromMap(dfUri, attributesMap) { | ||
return lodash_1.get(lodash_1.get(attributesMap, [dfUri], {}), ['attribute', 'content', 'type']); | ||
return (0, _lodash.get)((0, _lodash.get)(attributesMap, [dfUri], {}), ['attribute', 'content', 'type']); | ||
} | ||
function getAttrUriFromMap(dfUri, attributesMap) { | ||
return lodash_1.get(lodash_1.get(attributesMap, [dfUri], {}), ['attribute', 'meta', 'uri']); | ||
return (0, _lodash.get)((0, _lodash.get)(attributesMap, [dfUri], {}), ['attribute', 'meta', 'uri']); | ||
} | ||
function isAttrFilterNegative(attributeFilter) { | ||
return lodash_1.get(attributeFilter, 'negativeAttributeFilter') !== undefined; | ||
return (0, _lodash.get)(attributeFilter, 'negativeAttributeFilter') !== undefined; | ||
} | ||
function getAttrFilterElements(attributeFilter) { | ||
var isNegative = isAttrFilterNegative(attributeFilter); | ||
var pathToElements = isNegative ? ['negativeAttributeFilter', 'notIn'] : ['positiveAttributeFilter', 'in']; | ||
return lodash_1.get(attributeFilter, pathToElements, []); | ||
return (0, _lodash.get)(attributeFilter, pathToElements, []); | ||
} | ||
function getAttrFilterExpression(measureFilter, attributesMap) { | ||
var isNegative = lodash_1.get(measureFilter, 'negativeAttributeFilter', false); | ||
var isNegative = (0, _lodash.get)(measureFilter, 'negativeAttributeFilter', false); | ||
var detailPath = isNegative ? 'negativeAttributeFilter' : 'positiveAttributeFilter'; | ||
var attributeUri = getAttrUriFromMap(lodash_1.get(measureFilter, [detailPath, 'displayForm', 'uri']), attributesMap); | ||
var attributeUri = getAttrUriFromMap((0, _lodash.get)(measureFilter, [detailPath, 'displayForm', 'uri']), attributesMap); | ||
var elements = getAttrFilterElements(measureFilter); | ||
if (lodash_1.isEmpty(elements)) { | ||
if ((0, _lodash.isEmpty)(elements)) { | ||
return null; | ||
} | ||
var elementsForQuery = lodash_1.map(elements, function (e) { return "[" + e + "]"; }); | ||
var elementsForQuery = (0, _lodash.map)(elements, function (e) { | ||
return '[' + e + ']'; | ||
}); | ||
var negative = isNegative ? 'NOT ' : ''; | ||
return "[" + attributeUri + "] " + negative + "IN (" + elementsForQuery.join(',') + ")"; | ||
return '[' + attributeUri + '] ' + negative + 'IN (' + elementsForQuery.join(',') + ')'; | ||
} | ||
function getDateFilterExpression() { | ||
@@ -115,31 +154,44 @@ // measure date filter was never supported | ||
} | ||
function getFilterExpression(attributesMap, measureFilter) { | ||
if (visualizationObjectHelper_1.isAttributeMeasureFilter(measureFilter)) { | ||
if ((0, _visualizationObjectHelper.isAttributeMeasureFilter)(measureFilter)) { | ||
return getAttrFilterExpression(measureFilter, attributesMap); | ||
} | ||
return getDateFilterExpression(); | ||
return getDateFilterExpression(measureFilter); | ||
} | ||
function getGeneratedMetricExpression(item, attributesMap) { | ||
var aggregation = getAggregation(item).toUpperCase(); | ||
var objectUri = lodash_1.get(visualizationObjectHelper_1.getDefinition(item), 'item.uri'); | ||
var where = lodash_1.filter(lodash_1.map(visualizationObjectHelper_1.getMeasureFilters(item), lodash_1.partial(getFilterExpression, attributesMap)), function (e) { return !!e; }); | ||
return "SELECT " + (aggregation ? aggregation + "([" + objectUri + "])" : "[" + objectUri + "]") + (notEmpty(where) ? " WHERE " + where.join(' AND ') : ''); | ||
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; | ||
}); | ||
return 'SELECT ' + (aggregation ? aggregation + '([' + objectUri + '])' : '[' + objectUri + ']') + (notEmpty(where) ? ' WHERE ' + where.join(' AND ') : ''); | ||
} | ||
function getPercentMetricExpression(category, attributesMap, measure) { | ||
var metricExpressionWithoutFilters = "SELECT [" + lodash_1.get(visualizationObjectHelper_1.getDefinition(measure), 'item.uri') + "]"; | ||
var metricExpressionWithoutFilters = 'SELECT [' + (0, _lodash.get)((0, _visualizationObjectHelper.getDefinition)(measure), 'item.uri') + ']'; | ||
if (isDerived(measure)) { | ||
metricExpressionWithoutFilters = getGeneratedMetricExpression(lodash_1.set(lodash_1.cloneDeep(measure), ['definition', 'measureDefinition', 'filters'], []), attributesMap); | ||
metricExpressionWithoutFilters = getGeneratedMetricExpression((0, _lodash.set)((0, _lodash.cloneDeep)(measure), ['definition', 'measureDefinition', 'filters'], []), attributesMap); | ||
} | ||
var attributeUri = getAttrUriFromMap(lodash_1.get(category, 'displayForm.uri'), attributesMap); | ||
var whereFilters = lodash_1.filter(lodash_1.map(visualizationObjectHelper_1.getMeasureFilters(measure), lodash_1.partial(getFilterExpression, attributesMap)), function (e) { return !!e; }); | ||
var whereExpression = notEmpty(whereFilters) ? " WHERE " + whereFilters.join(' AND ') : ''; | ||
// tslint:disable-next-line:max-line-length | ||
return "SELECT (" + metricExpressionWithoutFilters + whereExpression + ") / (" + metricExpressionWithoutFilters + " BY ALL [" + attributeUri + "]" + whereExpression + ")"; | ||
var attributeUri = getAttrUriFromMap((0, _lodash.get)(category, 'displayForm.uri'), attributesMap); | ||
var whereFilters = (0, _lodash.filter)((0, _lodash.map)((0, _visualizationObjectHelper.getMeasureFilters)(measure), (0, _lodash.partial)(getFilterExpression, attributesMap)), function (e) { | ||
return !!e; | ||
}); | ||
var whereExpression = notEmpty(whereFilters) ? ' WHERE ' + whereFilters.join(' AND ') : ''; | ||
return 'SELECT (' + metricExpressionWithoutFilters + whereExpression + ') / (' + metricExpressionWithoutFilters + ' BY ALL [' + attributeUri + ']' + whereExpression + ')'; | ||
} | ||
function getPoPExpression(attributeUri, metricExpression) { | ||
return "SELECT " + metricExpression + " FOR PREVIOUS ([" + attributeUri + "])"; | ||
return 'SELECT ' + metricExpression + ' FOR PREVIOUS ([' + attributeUri + '])'; | ||
} | ||
function getGeneratedMetricHash(title, format, expression) { | ||
return md5(expression + "#" + title + "#" + format); | ||
return (0, _md2.default)(expression + '#' + title + '#' + format); | ||
} | ||
function getMeasureType(measure) { | ||
@@ -149,4 +201,3 @@ var aggregation = getAggregation(measure); | ||
return 'metric'; | ||
} | ||
else if (aggregation === 'count') { | ||
} else if (aggregation === 'count') { | ||
return 'attribute'; | ||
@@ -156,23 +207,32 @@ } | ||
} | ||
function getGeneratedMetricIdentifier(item, aggregation, expressionCreator, hasher, attributesMap) { | ||
var _a = lodash_1.get(visualizationObjectHelper_1.getDefinition(item), 'item.uri', '').split('/'), prjId = _a[3], id = _a[5]; | ||
var identifier = prjId + "_" + id; | ||
var _get$split = (0, _lodash.get)((0, _visualizationObjectHelper.getDefinition)(item), 'item.uri', '').split('/'), | ||
_get$split2 = _slicedToArray(_get$split, 6), | ||
prjId = _get$split2[3], | ||
id = _get$split2[5]; | ||
var identifier = prjId + '_' + id; | ||
var hash = hasher(expressionCreator(item, attributesMap)); | ||
var hasNoFilters = lodash_1.isEmpty(visualizationObjectHelper_1.getMeasureFilters(item)); | ||
var hasNoFilters = (0, _lodash.isEmpty)((0, _visualizationObjectHelper.getMeasureFilters)(item)); | ||
var type = getMeasureType(item); | ||
var prefix = (hasNoFilters || allFiltersEmpty(item)) ? '' : '_filtered'; | ||
return type + "_" + identifier + ".generated." + hash + prefix + "_" + aggregation; | ||
var prefix = hasNoFilters || allFiltersEmpty(item) ? '' : '_filtered'; | ||
return type + '_' + identifier + '.generated.' + hash + prefix + '_' + aggregation; | ||
} | ||
function isDateAttribute(attribute, attributesMap) { | ||
if (attributesMap === void 0) { attributesMap = {}; } | ||
return getAttrTypeFromMap(lodash_1.get(attribute, ['displayForm', 'uri']), attributesMap) !== undefined; | ||
function isDateAttribute(attribute) { | ||
var attributesMap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
return getAttrTypeFromMap((0, _lodash.get)(attribute, ['displayForm', 'uri']), attributesMap) !== undefined; | ||
} | ||
function getMeasureSorting(measure, mdObj) { | ||
var sorting = lodash_1.get(mdObj, ['properties', 'sortItems'], []); | ||
var sorting = (0, _lodash.get)(mdObj, ['properties', 'sortItems'], []); | ||
var matchedSorting = sorting.find(function (sortItem) { | ||
var measureSortItem = lodash_1.get(sortItem, ['measureSortItem']); | ||
var measureSortItem = (0, _lodash.get)(sortItem, ['measureSortItem']); | ||
if (measureSortItem) { | ||
// only one item now, we support only 2d data | ||
var identifier = lodash_1.get(measureSortItem, ['locators', 0, 'measureLocatorItem', 'measureIdentifier']); | ||
return identifier === lodash_1.get(measure, 'localIdentifier'); | ||
var identifier = (0, _lodash.get)(measureSortItem, ['locators', 0, 'measureLocatorItem', 'measureIdentifier']); // only one item now, we support only 2d data | ||
return identifier === (0, _lodash.get)(measure, 'localIdentifier'); | ||
} | ||
@@ -182,13 +242,14 @@ return false; | ||
if (matchedSorting) { | ||
return lodash_1.get(matchedSorting, ['measureSortItem', 'direction'], null); | ||
return (0, _lodash.get)(matchedSorting, ['measureSortItem', 'direction'], null); | ||
} | ||
return null; | ||
} | ||
function getCategorySorting(category, mdObj) { | ||
var sorting = lodash_1.get(mdObj, ['properties', 'sortItems'], []); | ||
var sorting = (0, _lodash.get)(mdObj, ['properties', 'sortItems'], []); | ||
var matchedSorting = sorting.find(function (sortItem) { | ||
var attributeSortItem = lodash_1.get(sortItem, ['attributeSortItem']); | ||
var attributeSortItem = (0, _lodash.get)(sortItem, ['attributeSortItem']); | ||
if (attributeSortItem) { | ||
var identifier = lodash_1.get(attributeSortItem, ['attributeIdentifier']); | ||
return identifier === lodash_1.get(category, 'localIdentifier'); | ||
var identifier = (0, _lodash.get)(attributeSortItem, ['attributeIdentifier']); | ||
return identifier === (0, _lodash.get)(category, 'localIdentifier'); | ||
} | ||
@@ -198,16 +259,22 @@ return false; | ||
if (matchedSorting) { | ||
return lodash_1.get(matchedSorting, ['attributeSortItem', 'direction'], null); | ||
return (0, _lodash.get)(matchedSorting, ['attributeSortItem', 'direction'], null); | ||
} | ||
return null; | ||
} | ||
var createPureMetric = function (measure, mdObj, measureIndex) { return ({ | ||
element: lodash_1.get(measure, ['definition', 'measureDefinition', 'item', 'uri']), | ||
sort: getMeasureSorting(measure, mdObj), | ||
meta: { measureIndex: measureIndex } | ||
}); }; | ||
var createPureMetric = function createPureMetric(measure, mdObj, measureIndex) { | ||
return { | ||
element: (0, _lodash.get)(measure, ['definition', 'measureDefinition', 'item', 'uri']), | ||
sort: getMeasureSorting(measure, mdObj), | ||
meta: { measureIndex: measureIndex } | ||
}; | ||
}; | ||
function createDerivedMetric(measure, mdObj, measureIndex, attributesMap) { | ||
var format = measure.format; | ||
var sort = getMeasureSorting(measure, mdObj); | ||
var title = getBaseMetricTitle(measure.title); | ||
var hasher = lodash_1.partial(getGeneratedMetricHash, title, format); | ||
var hasher = (0, _lodash.partial)(getGeneratedMetricHash, title, format); | ||
var aggregation = getAggregation(measure); | ||
@@ -223,2 +290,3 @@ var element = getGeneratedMetricIdentifier(measure, aggregation.length ? aggregation : 'base', getGeneratedMetricExpression, hasher, attributesMap); | ||
}; | ||
return { | ||
@@ -233,7 +301,8 @@ element: element, | ||
} | ||
function createContributionMetric(measure, mdObj, measureIndex, attributesMap) { | ||
var attribute = lodash_1.first(visualizationObjectHelper_1.getAttributes(mdObj)); | ||
var getMetricExpression = lodash_1.partial(getPercentMetricExpression, attribute, attributesMap); | ||
var title = getBaseMetricTitle(lodash_1.get(measure, 'title')); | ||
var hasher = lodash_1.partial(getGeneratedMetricHash, title, CONTRIBUTION_METRIC_FORMAT); | ||
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')); | ||
var hasher = (0, _lodash.partial)(getGeneratedMetricHash, title, CONTRIBUTION_METRIC_FORMAT); | ||
var identifier = getGeneratedMetricIdentifier(measure, 'percent', getMetricExpression, hasher, attributesMap); | ||
@@ -245,3 +314,3 @@ return { | ||
identifier: identifier, | ||
expression: getMetricExpression(measure), | ||
expression: getMetricExpression(measure, attributesMap), | ||
title: title, | ||
@@ -257,21 +326,28 @@ format: CONTRIBUTION_METRIC_FORMAT | ||
} | ||
function getOriginalMeasureForPoP(popMeasure, mdObj) { | ||
return visualizationObjectHelper_1.getMeasures(mdObj).find(function (measure) { | ||
return lodash_1.get(measure, 'localIdentifier') === lodash_1.get(getPoPDefinition(popMeasure), ['measureIdentifier']); | ||
return (0, _visualizationObjectHelper.getMeasures)(mdObj).find(function (measure) { | ||
return (0, _lodash.get)(measure, 'localIdentifier') === (0, _lodash.get)(getPoPDefinition(popMeasure), ['measureIdentifier']); | ||
}); | ||
} | ||
function createPoPMetric(popMeasure, mdObj, measureIndex, attributesMap) { | ||
var title = getBaseMetricTitle(lodash_1.get(popMeasure, 'title')); | ||
var format = lodash_1.get(popMeasure, 'format'); | ||
var hasher = lodash_1.partial(getGeneratedMetricHash, title, format); | ||
var attributeUri = lodash_1.get(popMeasure, 'definition.popMeasureDefinition.popAttribute.uri'); | ||
var title = getBaseMetricTitle((0, _lodash.get)(popMeasure, 'title')); | ||
var format = (0, _lodash.get)(popMeasure, 'format'); | ||
var hasher = (0, _lodash.partial)(getGeneratedMetricHash, title, format); | ||
var attributeUri = (0, _lodash.get)(popMeasure, 'definition.popMeasureDefinition.popAttribute.uri'); | ||
var originalMeasure = getOriginalMeasureForPoP(popMeasure, mdObj); | ||
var originalMeasureExpression = "[" + lodash_1.get(visualizationObjectHelper_1.getDefinition(originalMeasure), ['item', 'uri']) + "]"; | ||
var metricExpression = getPoPExpression(attributeUri, originalMeasureExpression); | ||
var originalMeasureExpression = '[' + (0, _lodash.get)((0, _visualizationObjectHelper.getDefinition)(originalMeasure), ['item', 'uri']) + ']'; | ||
var getMetricExpression = (0, _lodash.partial)(getPoPExpression, attributeUri, originalMeasureExpression); | ||
if (isDerived(originalMeasure)) { | ||
var generated = createDerivedMetric(originalMeasure, mdObj, measureIndex, attributesMap); | ||
var generatedMeasureExpression = "(" + lodash_1.get(generated, ['definition', 'metricDefinition', 'expression']) + ")"; | ||
metricExpression = getPoPExpression(attributeUri, generatedMeasureExpression); | ||
var generatedMeasureExpression = '(' + (0, _lodash.get)(generated, ['definition', 'metricDefinition', 'expression']) + ')'; | ||
getMetricExpression = (0, _lodash.partial)(getPoPExpression, attributeUri, generatedMeasureExpression); | ||
} | ||
var identifier = getGeneratedMetricIdentifier(originalMeasure, 'pop', function () { return metricExpression; }, hasher, attributesMap); | ||
var identifier = getGeneratedMetricIdentifier(originalMeasure, 'pop', getMetricExpression, hasher, attributesMap); | ||
return { | ||
@@ -282,3 +358,3 @@ element: identifier, | ||
identifier: identifier, | ||
expression: metricExpression, | ||
expression: getMetricExpression(), | ||
title: title, | ||
@@ -295,12 +371,19 @@ format: format | ||
} | ||
function createContributionPoPMetric(popMeasure, mdObj, measureIndex, attributesMap) { | ||
var attributeUri = lodash_1.get(popMeasure, ['definition', 'popMeasureDefinition', 'popAttribute', 'uri']); | ||
var attributeUri = (0, _lodash.get)(popMeasure, ['definition', 'popMeasureDefinition', 'popAttribute', 'uri']); | ||
var originalMeasure = getOriginalMeasureForPoP(popMeasure, mdObj); | ||
var generated = createContributionMetric(originalMeasure, mdObj, measureIndex, attributesMap); | ||
var title = getBaseMetricTitle(lodash_1.get(popMeasure, 'title')); | ||
var title = getBaseMetricTitle((0, _lodash.get)(popMeasure, 'title')); | ||
var format = CONTRIBUTION_METRIC_FORMAT; | ||
var hasher = lodash_1.partial(getGeneratedMetricHash, title, format); | ||
var generatedMeasureExpression = "(" + lodash_1.get(generated, ['definition', 'metricDefinition', 'expression']) + ")"; | ||
var metricExpression = getPoPExpression(attributeUri, generatedMeasureExpression); | ||
var identifier = getGeneratedMetricIdentifier(originalMeasure, 'pop', function () { return metricExpression; }, hasher, attributesMap); | ||
var hasher = (0, _lodash.partial)(getGeneratedMetricHash, title, format); | ||
var generatedMeasureExpression = '(' + (0, _lodash.get)(generated, ['definition', 'metricDefinition', 'expression']) + ')'; | ||
var getMetricExpression = (0, _lodash.partial)(getPoPExpression, attributeUri, generatedMeasureExpression); | ||
var identifier = getGeneratedMetricIdentifier(originalMeasure, 'pop', getMetricExpression, hasher, attributesMap); | ||
return { | ||
@@ -311,3 +394,3 @@ element: identifier, | ||
identifier: identifier, | ||
expression: metricExpression, | ||
expression: getMetricExpression(), | ||
title: title, | ||
@@ -324,4 +407,5 @@ format: format | ||
} | ||
function categoryToElement(attributesMap, mdObj, category) { | ||
var element = getAttrUriFromMap(lodash_1.get(category, ['displayForm', 'uri']), attributesMap); | ||
var element = getAttrUriFromMap((0, _lodash.get)(category, ['displayForm', 'uri']), attributesMap); | ||
return { | ||
@@ -332,9 +416,12 @@ element: element, | ||
} | ||
function isPoP(_a) { | ||
var definition = _a.definition; | ||
return lodash_1.get(definition, 'popMeasureDefinition') !== undefined; | ||
function isPoP(_ref) { | ||
var definition = _ref.definition; | ||
return (0, _lodash.get)(definition, 'popMeasureDefinition') !== undefined; | ||
} | ||
function isContribution(_a) { | ||
var definition = _a.definition; | ||
return lodash_1.get(definition, ['measureDefinition', 'computeRatio']); | ||
function isContribution(_ref2) { | ||
var definition = _ref2.definition; | ||
return (0, _lodash.get)(definition, ['measureDefinition', 'computeRatio']); | ||
} | ||
@@ -348,38 +435,113 @@ function isPoPContribution(popMeasure, mdObj) { | ||
} | ||
function isCalculatedMeasure(_a) { | ||
var definition = _a.definition; | ||
return lodash_1.get(definition, ['measureDefinition', 'aggregation']) === undefined; | ||
function isCalculatedMeasure(_ref3) { | ||
var definition = _ref3.definition; | ||
return (0, _lodash.get)(definition, ['measureDefinition', 'aggregation']) === undefined; | ||
} | ||
var rules = new rules_1.Rules(); | ||
var rules = new _rules2.default(); | ||
rules.addRule([isPoPContribution], createContributionPoPMetric); | ||
rules.addRule([isPoP], createPoPMetric); | ||
rules.addRule([isContribution], createContributionMetric); | ||
rules.addRule([isDerived], createDerivedMetric); | ||
rules.addRule([isCalculatedMeasure], createPureMetric); | ||
function getMetricFactory(measure, mdObj) { | ||
var factory = rules.match(measure, mdObj); | ||
invariant(factory, "Unknown factory for: " + measure); | ||
(0, _invariant2.default)(factory, 'Unknown factory for: ' + measure); | ||
return factory; | ||
} | ||
function getExecutionDefinitionsAndColumns(mdObj, options, attributesMap) { | ||
var measures = visualizationObjectHelper_1.getMeasures(mdObj); | ||
var attributes = visualizationObjectHelper_1.getAttributes(mdObj); | ||
var metrics = lodash_1.flatten(lodash_1.map(measures, function (measure, index) { | ||
var measures = (0, _visualizationObjectHelper.getMeasures)(mdObj); | ||
var attributes = (0, _visualizationObjectHelper.getAttributes)(mdObj); | ||
var metrics = (0, _lodash.flatten)((0, _lodash.map)(measures, function (measure, index) { | ||
return getMetricFactory(measure, mdObj)(measure, mdObj, index, attributesMap); | ||
})); | ||
if (options.removeDateItems) { | ||
attributes = lodash_1.filter(attributes, function (attribute) { return !isDateAttribute(attribute, attributesMap); }); | ||
attributes = (0, _lodash.filter)(attributes, function (attribute) { | ||
return !isDateAttribute(attribute, attributesMap); | ||
}); | ||
} | ||
attributes = lodash_1.map(attributes, lodash_1.partial(categoryToElement, attributesMap, mdObj)); | ||
var columns = lodash_1.compact(lodash_1.map(attributes.concat(metrics), 'element')); | ||
attributes = (0, _lodash.map)(attributes, (0, _lodash.partial)(categoryToElement, attributesMap, mdObj)); | ||
var columns = (0, _lodash.compact)((0, _lodash.map)([].concat(_toConsumableArray(attributes), _toConsumableArray(metrics)), 'element')); | ||
return { | ||
columns: columns, | ||
definitions: definitions_1.sortDefinitions(lodash_1.compact(lodash_1.map(metrics, 'definition'))) | ||
definitions: (0, _definitions.sortDefinitions)((0, _lodash.compact)((0, _lodash.map)(metrics, 'definition'))) | ||
}; | ||
} | ||
var ExperimentalExecutionsModule = /** @class */ (function () { | ||
function ExperimentalExecutionsModule(xhr, loadAttributesMap) { | ||
this.xhr = xhr; | ||
this.loadAttributesMap = loadAttributesMap; | ||
function createModule(xhr, loadAttributesMap) { | ||
function getAttributesMap(options, displayFormUris, projectId) { | ||
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); | ||
}); | ||
} | ||
function mdToExecutionDefinitionsAndColumns(projectId, mdObj) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var allDfUris = (0, _visualizationObjectHelper.getAttributesDisplayForms)(mdObj); | ||
var attributesMapPromise = getAttributesMap(options, allDfUris, projectId); | ||
return attributesMapPromise.then(function (attributesMap) { | ||
return getExecutionDefinitionsAndColumns(mdObj, options, attributesMap); | ||
}); | ||
} | ||
function loadExtendedDataResults(uri, settings) { | ||
var prevResult = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : emptyResult; | ||
return new Promise(function (resolve, reject) { | ||
xhr.ajax(uri, settings).then(function (r) { | ||
if (r.status === 204) { | ||
return { | ||
status: r.status, | ||
result: '' | ||
}; | ||
} | ||
return r.json().then(function (result) { | ||
return { | ||
status: r.status, | ||
result: result | ||
}; | ||
}); | ||
}).then(function (_ref4) { | ||
var status = _ref4.status, | ||
result = _ref4.result; | ||
var values = [].concat(_toConsumableArray((0, _lodash.get)(prevResult, 'extendedTabularDataResult.values', [])), _toConsumableArray((0, _lodash.get)(result, 'extendedTabularDataResult.values', []))); | ||
var warnings = [].concat(_toConsumableArray((0, _lodash.get)(prevResult, 'extendedTabularDataResult.warnings', [])), _toConsumableArray((0, _lodash.get)(result, 'extendedTabularDataResult.warnings', []))); | ||
var updatedResult = (0, _lodash.merge)({}, prevResult, { | ||
extendedTabularDataResult: { | ||
values: values, | ||
warnings: warnings | ||
} | ||
}); | ||
var nextUri = (0, _lodash.get)(result, 'extendedTabularDataResult.paging.next'); | ||
if (nextUri) { | ||
resolve(loadExtendedDataResults(nextUri, settings, updatedResult)); | ||
} else { | ||
resolve({ status: status, result: updatedResult }); | ||
} | ||
}, reject); | ||
}); | ||
} | ||
/** | ||
@@ -391,2 +553,3 @@ * Module for execution on experimental execution resource | ||
*/ | ||
/** | ||
@@ -408,9 +571,10 @@ * For the given projectId it returns table structure with the given | ||
*/ | ||
ExperimentalExecutionsModule.prototype.getData = function (projectId, columns, executionConfiguration, settings) { | ||
var _this = this; | ||
if (executionConfiguration === void 0) { executionConfiguration = {}; } | ||
if (settings === void 0) { settings = {}; } | ||
function getData(projectId, columns) { | ||
var executionConfiguration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var settings = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; | ||
var executedReport = { | ||
isLoaded: false | ||
}; | ||
// Create request and result structures | ||
@@ -427,70 +591,29 @@ var request = { | ||
}); | ||
// Execute request | ||
return this.xhr.post("/gdc/internal/projects/" + projectId + "/experimental/executions", __assign({}, settings, { body: JSON.stringify(request) })) | ||
.then((function (r) { return r.getData(); })) | ||
.then(function (response) { | ||
executedReport.headers = wrapMeasureIndexesFromMappings(lodash_1.get(executionConfiguration, 'metricMappings'), lodash_1.get(response, ['executionResult', 'headers'], [])); | ||
return xhr.post('/gdc/internal/projects/' + projectId + '/experimental/executions', _extends({}, settings, { | ||
body: JSON.stringify(request) | ||
})).then(xhr.parseJSON).then(function (result) { | ||
executedReport.headers = wrapMeasureIndexesFromMappings((0, _lodash.get)(executionConfiguration, 'metricMappings'), (0, _lodash.get)(result, ['executionResult', 'headers'], [])); | ||
// Start polling on url returned in the executionResult for tabularData | ||
return _this.loadExtendedDataResults(response.executionResult.extendedTabularDataResult, settings); | ||
}) | ||
.then(function (r) { | ||
var result = r.result, status = r.status; | ||
return __assign({}, executedReport, { rawData: lodash_1.get(result, 'extendedTabularDataResult.values', []), warnings: lodash_1.get(result, 'extendedTabularDataResult.warnings', []), isLoaded: true, isEmpty: status === 204 }); | ||
return loadExtendedDataResults(result.executionResult.extendedTabularDataResult, settings); | ||
}).then(function (r) { | ||
var result = r.result, | ||
status = r.status; | ||
return Object.assign({}, executedReport, { | ||
rawData: (0, _lodash.get)(result, 'extendedTabularDataResult.values', []), | ||
warnings: (0, _lodash.get)(result, 'extendedTabularDataResult.warnings', []), | ||
isLoaded: true, | ||
isEmpty: status === 204 | ||
}); | ||
}); | ||
} | ||
return { | ||
getData: getData, | ||
mdToExecutionDefinitionsAndColumns: mdToExecutionDefinitionsAndColumns | ||
}; | ||
ExperimentalExecutionsModule.prototype.mdToExecutionDefinitionsAndColumns = function (projectId, mdObj, options) { | ||
if (options === void 0) { options = {}; } | ||
var allDfUris = visualizationObjectHelper_1.getAttributesDisplayForms(mdObj); | ||
var attributesMapPromise = this.getAttributesMap(options, allDfUris, projectId); | ||
return attributesMapPromise.then(function (attributesMap) { | ||
return getExecutionDefinitionsAndColumns(mdObj, options, attributesMap); | ||
}); | ||
}; | ||
ExperimentalExecutionsModule.prototype.getAttributesMap = function (options, displayFormUris, projectId) { | ||
var attributesMap = lodash_1.get(options, 'attributesMap', {}); | ||
var missingUris = attributesMapLoader_1.getMissingUrisInAttributesMap(displayFormUris, attributesMap); | ||
return this.loadAttributesMap(projectId, missingUris).then(function (result) { | ||
return __assign({}, attributesMap, result); | ||
}); | ||
}; | ||
ExperimentalExecutionsModule.prototype.loadExtendedDataResults = function (uri, settings, prevResult) { | ||
var _this = this; | ||
if (prevResult === void 0) { prevResult = emptyResult; } | ||
return new Promise(function (resolve, reject) { | ||
_this.xhr.ajax(uri, settings) | ||
.then(function (r) { | ||
var response = r.response; | ||
if (response.status === 204) { | ||
return { | ||
status: response.status, | ||
result: '' | ||
}; | ||
} | ||
return { | ||
status: response.status, | ||
result: r.getData() | ||
}; | ||
}) | ||
.then(function (_a) { | ||
var status = _a.status, result = _a.result; | ||
var values = lodash_1.get(prevResult, 'extendedTabularDataResult.values', []).concat(lodash_1.get(result, 'extendedTabularDataResult.values', [])); | ||
var warnings = lodash_1.get(prevResult, 'extendedTabularDataResult.warnings', []).concat(lodash_1.get(result, 'extendedTabularDataResult.warnings', [])); | ||
var updatedResult = lodash_1.merge({}, prevResult, { | ||
extendedTabularDataResult: { | ||
values: values, | ||
warnings: warnings | ||
} | ||
}); | ||
var nextUri = lodash_1.get(result, 'extendedTabularDataResult.paging.next'); | ||
if (nextUri) { | ||
resolve(_this.loadExtendedDataResults(nextUri, settings, updatedResult)); | ||
} | ||
else { | ||
resolve({ status: status, result: updatedResult }); | ||
} | ||
}, reject); | ||
}); | ||
}; | ||
return ExperimentalExecutionsModule; | ||
}()); | ||
exports.ExperimentalExecutionsModule = ExperimentalExecutionsModule; | ||
} |
@@ -1,15 +0,26 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved. | ||
require("isomorphic-fetch"); | ||
var gooddata_1 = require("./gooddata"); | ||
exports.SDK = gooddata_1.SDK; | ||
var xhr_1 = require("./xhr"); | ||
exports.ApiResponse = xhr_1.ApiResponse; | ||
exports.ApiResponseError = xhr_1.ApiResponseError; | ||
exports.ApiNetworkError = xhr_1.ApiNetworkError; | ||
var DataLayer = require("./DataLayer"); | ||
exports.DataLayer = DataLayer; | ||
var factoryBrowser = gooddata_1.factory(fetch.bind(window)); | ||
exports.factory = factoryBrowser; | ||
exports.default = factoryBrowser(); | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.factory = undefined; | ||
var _isomorphicFetch = require('isomorphic-fetch'); | ||
var _isomorphicFetch2 = _interopRequireDefault(_isomorphicFetch); | ||
var _fetch = require('./utils/fetch'); | ||
var _gooddata = require('./gooddata'); | ||
var _gooddata2 = _interopRequireDefault(_gooddata); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// Fetch requests will be sent through the isomorphic-fetch. Our authentication | ||
// relies on cookies, so it will work in browser environment automatically. | ||
// For node see `gooddata-node.js` file. | ||
(0, _fetch.setFetch)(_isomorphicFetch2.default); // Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved. | ||
exports.factory = _gooddata.factory; | ||
exports.default = _gooddata2.default; |
@@ -1,15 +0,25 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved. | ||
var fetchCookie = require('fetch-cookie'); // tslint:disable-line:no-var-requires | ||
var node_fetch_1 = require("node-fetch"); | ||
var gooddata_1 = require("./gooddata"); | ||
exports.SDK = gooddata_1.SDK; | ||
var gooddata_browser_1 = require("./gooddata-browser"); | ||
exports.DataLayer = gooddata_browser_1.DataLayer; | ||
exports.ApiResponse = gooddata_browser_1.ApiResponse; | ||
exports.ApiResponseError = gooddata_browser_1.ApiResponseError; | ||
exports.ApiNetworkError = gooddata_browser_1.ApiNetworkError; | ||
var factoryNode = gooddata_1.factory(fetchCookie(node_fetch_1.default)); | ||
exports.factory = factoryNode; | ||
exports.default = factoryNode(); | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _gooddata = require('./gooddata'); | ||
var _gooddata2 = _interopRequireDefault(_gooddata); | ||
var _fetch = require('./utils/fetch'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// Fetch requests will be sent through the node-fetch wrapped by the fetch-cookie. | ||
// This is necessary in order to preserve cookies between requests like it would be | ||
// done in the browser environment. Otherwise the SDK would forget about authentication | ||
// immediately. | ||
(0, _fetch.setFetch)(require('fetch-cookie')(require('node-fetch'))); | ||
// Backward compatibility | ||
_gooddata2.default.factory = _gooddata.factory; // eslint-disable-line import/no-named-as-default-member | ||
exports.default = _gooddata2.default; | ||
module.exports = _gooddata2.default; |
@@ -1,15 +0,36 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// Copyright (C) 2007-2017, GoodData(R) Corporation. All rights reserved. | ||
var lodash_1 = require("lodash"); | ||
var xhr_1 = require("./xhr"); | ||
var user_1 = require("./user"); | ||
var metadata_1 = require("./metadata"); | ||
var execution_1 = require("./execution"); | ||
var project_1 = require("./project"); | ||
var config_1 = require("./config"); | ||
var catalogue_1 = require("./catalogue"); | ||
var admin_1 = require("./admin"); | ||
var attributesMapLoader_1 = require("./utils/attributesMapLoader"); | ||
var visualizationObjectHelper_1 = require("./utils/visualizationObjectHelper"); | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); // Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved. | ||
exports.factory = factory; | ||
var _lodash = require('lodash'); | ||
var _xhr = require('./xhr'); | ||
var _user = require('./user'); | ||
var _metadata = require('./metadata'); | ||
var _execution = require('./execution'); | ||
var _project = require('./project'); | ||
var _config = require('./config'); | ||
var _catalogue = require('./catalogue'); | ||
var _admin = require('./admin'); | ||
var _attributesMapLoader = require('./utils/attributesMapLoader'); | ||
var _visualizationObjectHelper = require('./utils/visualizationObjectHelper'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
/** | ||
@@ -32,27 +53,34 @@ * # JS SDK | ||
*/ | ||
var SDK = /** @class */ (function () { | ||
function SDK(fetchMethod, config) { | ||
if (config === void 0) { config = {}; } | ||
this.fetchMethod = fetchMethod; | ||
this.configStorage = config_1.sanitizeConfig(config); // must be plain object, SDK modules MUST use this storage | ||
this.config = new config_1.ConfigModule(this.configStorage); | ||
this.xhr = new xhr_1.XhrModule(fetchMethod, this.configStorage); | ||
this.user = new user_1.UserModule(this.xhr); | ||
this.md = new metadata_1.MetadataModule(this.xhr); | ||
this.execution = new execution_1.ExecutionModule(this.xhr, this.md); | ||
this.project = new project_1.ProjectModule(this.xhr); | ||
this.catalogue = new catalogue_1.CatalogueModule(this.xhr, this.execution); | ||
this.admin = new admin_1.AdminModule(this.xhr); | ||
var attributesMapLoaderModule = new attributesMapLoader_1.AttributesMapLoaderModule(this.md); | ||
var SDK = function () { | ||
function SDK() { | ||
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
_classCallCheck(this, SDK); | ||
this.configStorage = (0, _config.sanitizeConfig)(config); // must be plain object, SDK modules MUST use this storage | ||
this.config = (0, _config.createModule)(this.configStorage); | ||
this.xhr = (0, _xhr.createModule)(this.configStorage); | ||
this.user = (0, _user.createModule)(this.xhr); | ||
this.md = (0, _metadata.createModule)(this.xhr); | ||
this.execution = (0, _execution.createModule)(this.xhr, this.md); | ||
this.project = (0, _project.createModule)(this.xhr); | ||
this.catalogue = (0, _catalogue.createModule)(this.xhr, this.execution); | ||
this.admin = (0, _admin.createModule)(this.xhr); | ||
this.utils = { | ||
loadAttributesMap: attributesMapLoaderModule.loadAttributesMap.bind(attributesMapLoaderModule), | ||
getAttributesDisplayForms: visualizationObjectHelper_1.getAttributesDisplayForms | ||
loadAttributesMap: (0, _attributesMapLoader.createModule)(this.md), | ||
getAttributesDisplayForms: _visualizationObjectHelper.getAttributesDisplayForms | ||
}; | ||
} | ||
SDK.prototype.clone = function () { | ||
return new SDK(this.fetchMethod, lodash_1.cloneDeep(this.configStorage)); | ||
}; | ||
_createClass(SDK, [{ | ||
key: 'clone', | ||
value: function clone() { | ||
return new SDK((0, _lodash.cloneDeep)(this.configStorage)); | ||
} | ||
}]); | ||
return SDK; | ||
}()); | ||
exports.SDK = SDK; | ||
}(); | ||
/** | ||
@@ -64,5 +92,12 @@ * # Factory for creating SDK instances | ||
*/ | ||
exports.factory = function (fetchMethod) { return function (config) { | ||
if (config === void 0) { config = {}; } | ||
return new SDK(fetchMethod, config); | ||
}; }; | ||
function factory() { | ||
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return new SDK(config); | ||
} | ||
var defaultInstance = factory(); | ||
exports.default = defaultInstance; |
@@ -1,15 +0,20 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved. | ||
var lodash_1 = require("lodash"); | ||
var util_1 = require("./util"); | ||
var xhr_1 = require("./xhr"); | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
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"); } }; }(); | ||
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; }; | ||
exports.createModule = createModule; | ||
var _lodash = require('lodash'); | ||
var _util = require('./util'); | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } // Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved. | ||
/** | ||
@@ -21,6 +26,3 @@ * Functions for working with metadata objects | ||
*/ | ||
var MetadataModule = /** @class */ (function () { | ||
function MetadataModule(xhr) { | ||
this.xhr = xhr; | ||
} | ||
function createModule(xhr) { | ||
/** | ||
@@ -35,9 +37,10 @@ * Load all objects with given uris | ||
*/ | ||
MetadataModule.prototype.getObjects = function (projectId, objectUris) { | ||
var _this = this; | ||
function getObjects(projectId, objectUris) { | ||
var LIMIT = 50; | ||
var uri = "/gdc/md/" + projectId + "/objects/get"; | ||
var objectsUrisChunks = lodash_1.chunk(objectUris, LIMIT); | ||
var uri = '/gdc/md/' + projectId + '/objects/get'; | ||
var objectsUrisChunks = (0, _lodash.chunk)(objectUris, LIMIT); | ||
var promises = objectsUrisChunks.map(function (objectUrisChunk) { | ||
var body = { | ||
var data = { | ||
get: { | ||
@@ -47,13 +50,21 @@ items: objectUrisChunk | ||
}; | ||
return _this.xhr.post(uri, { body: body }) | ||
.then(function (r) { | ||
if (!r.response.ok) { | ||
throw new xhr_1.ApiResponseError(r.response.statusText, r.response, r.responseBody); | ||
return xhr.post(uri, { | ||
data: JSON.stringify(data) | ||
}).then(function (r) { | ||
if (!r.ok) { | ||
var err = new Error(r.statusText); | ||
err.response = r; | ||
throw err; | ||
} | ||
return r.getData(); | ||
}) | ||
.then(function (result) { return lodash_1.get(result, ['objects', 'items']); }); | ||
return r.json(); | ||
}).then(function (result) { | ||
return (0, _lodash.get)(result, ['objects', 'items']); | ||
}); | ||
}); | ||
return Promise.all(promises).then(lodash_1.flatten); | ||
}; | ||
return Promise.all(promises).then(_lodash.flatten); | ||
} | ||
/** | ||
@@ -69,21 +80,23 @@ * Loads all objects by query (fetches all pages, one by one) | ||
* - limit {number} default is 50 (also maximum) | ||
* - deprecated {number BOOLEAN 1 or 0 (default)} show also deprecated objects | ||
* @return {Promise<Array>} array of returned objects | ||
*/ | ||
MetadataModule.prototype.getObjectsByQuery = function (projectId, options) { | ||
var _this = this; | ||
var getOnePage = function (uri, items) { | ||
if (items === void 0) { items = []; } | ||
return _this.xhr.get(uri) | ||
.then(function (r) { return r.getData(); }) | ||
.then(function (_a) { | ||
var objects = _a.objects; | ||
items.push.apply(items, objects.items); | ||
function getObjectsByQuery(projectId, options) { | ||
function getOnePage(uri) { | ||
var items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; | ||
return xhr.get(uri).then(function (_ref) { | ||
var objects = _ref.objects; | ||
items.push.apply(items, _toConsumableArray(objects.items)); | ||
var nextUri = objects.paging.next; | ||
return nextUri ? getOnePage(nextUri, items) : items; | ||
}); | ||
}; | ||
var uri = "/gdc/md/" + projectId + "/objects/query"; | ||
var query = lodash_1.pick(__assign({ limit: 50 }, options), ['category', 'mode', 'author', 'limit']); | ||
return getOnePage(uri + util_1.queryString(query)); | ||
}; | ||
} | ||
var uri = '/gdc/md/' + projectId + '/objects/query'; | ||
var query = (0, _lodash.pick)(_extends({ limit: 50 }, options), ['category', 'mode', 'author', 'limit', 'deprecated']); | ||
return getOnePage(uri + (0, _util.queryString)(query)); | ||
} | ||
/** | ||
@@ -102,7 +115,12 @@ * Get MD objects from using2 resource. Include only objects of given types | ||
*/ | ||
MetadataModule.prototype.getObjectUsing = function (projectId, uri, options) { | ||
if (options === void 0) { options = {}; } | ||
var _a = options.types, types = _a === void 0 ? [] : _a, _b = options.nearest, nearest = _b === void 0 ? false : _b; | ||
var resourceUri = "/gdc/md/" + projectId + "/using2"; | ||
var body = { | ||
function getObjectUsing(projectId, uri) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var _options$types = options.types, | ||
types = _options$types === undefined ? [] : _options$types, | ||
_options$nearest = options.nearest, | ||
nearest = _options$nearest === undefined ? false : _options$nearest; | ||
var resourceUri = '/gdc/md/' + projectId + '/using2'; | ||
var data = { | ||
inUse: { | ||
@@ -114,11 +132,18 @@ uri: uri, | ||
}; | ||
return this.xhr.post(resourceUri, { body: body }) | ||
.then(function (r) { | ||
if (!r.response.ok) { | ||
throw new xhr_1.ApiResponseError(r.response.statusText, r.response, r.getData()); | ||
return xhr.post(resourceUri, { | ||
data: JSON.stringify(data) | ||
}).then(function (r) { | ||
if (!r.ok) { | ||
var err = new Error(r.statusText); | ||
err.response = r; | ||
throw err; | ||
} | ||
return r.getData(); | ||
}) | ||
.then(function (result) { return result.entries; }); | ||
}; | ||
return r.json(); | ||
}).then(function (result) { | ||
return result.entries; | ||
}); | ||
} | ||
/** | ||
@@ -137,7 +162,12 @@ * Get MD objects from using2 resource. Include only objects of given types | ||
*/ | ||
MetadataModule.prototype.getObjectUsingMany = function (projectId, uris, options) { | ||
if (options === void 0) { options = {}; } | ||
var _a = options.types, types = _a === void 0 ? [] : _a, _b = options.nearest, nearest = _b === void 0 ? false : _b; | ||
var resourceUri = "/gdc/md/" + projectId + "/using2"; | ||
var body = { | ||
function getObjectUsingMany(projectId, uris) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var _options$types2 = options.types, | ||
types = _options$types2 === undefined ? [] : _options$types2, | ||
_options$nearest2 = options.nearest, | ||
nearest = _options$nearest2 === undefined ? false : _options$nearest2; | ||
var resourceUri = '/gdc/md/' + projectId + '/using2'; | ||
var data = { | ||
inUseMany: { | ||
@@ -149,11 +179,18 @@ uris: uris, | ||
}; | ||
return this.xhr.post(resourceUri, { body: body }) | ||
.then(function (r) { | ||
if (!r.response.ok) { | ||
throw new xhr_1.ApiResponseError(r.response.statusText, r.response, r.getData()); | ||
return xhr.post(resourceUri, { | ||
data: JSON.stringify(data) | ||
}).then(function (r) { | ||
if (!r.ok) { | ||
var err = new Error(r.statusText); | ||
err.response = r; | ||
throw err; | ||
} | ||
return r.getData(); | ||
}). | ||
then(function (result) { return result.useMany; }); | ||
}; | ||
return r.json(); | ||
}).then(function (result) { | ||
return result.useMany; | ||
}); | ||
} | ||
/** | ||
@@ -166,21 +203,21 @@ * Returns all visualizationObjects metadata in a project specified by projectId param | ||
*/ | ||
MetadataModule.prototype.getVisualizations = function (projectId) { | ||
return this.xhr.get("/gdc/md/" + projectId + "/query/visualizationobjects") | ||
.then(function (apiResponse) { | ||
return (apiResponse.response.ok ? apiResponse.getData() : apiResponse.response); | ||
}) | ||
.then(util_1.getIn('query.entries')); | ||
}; | ||
function getVisualizations(projectId) { | ||
return xhr.get('/gdc/md/' + projectId + '/query/visualizationobjects').then(function (r) { | ||
return r.ok ? r.json() : r; | ||
}).then((0, _util.getIn)('query.entries')); | ||
} | ||
/** | ||
* Returns all attributes in a project specified by projectId param | ||
* | ||
* @method getAttributes | ||
* @param {string} projectId Project identifier | ||
* @return {Array} An array of attribute objects | ||
*/ | ||
MetadataModule.prototype.getAttributes = function (projectId) { | ||
return this.xhr.get("/gdc/md/" + projectId + "/query/attributes") | ||
.then(function (apiResponse) { return (apiResponse.response.ok ? apiResponse.getData() : apiResponse.response); }) | ||
.then(util_1.getIn('query.entries')); | ||
}; | ||
* Returns all attributes in a project specified by projectId param | ||
* | ||
* @method getAttributes | ||
* @param {string} projectId Project identifier | ||
* @return {Array} An array of attribute objects | ||
*/ | ||
function getAttributes(projectId) { | ||
return xhr.get('/gdc/md/' + projectId + '/query/attributes').then(function (r) { | ||
return r.ok ? r.json() : r; | ||
}).then((0, _util.getIn)('query.entries')); | ||
} | ||
/** | ||
@@ -194,7 +231,8 @@ * Returns all dimensions in a project specified by projectId param | ||
*/ | ||
MetadataModule.prototype.getDimensions = function (projectId) { | ||
return this.xhr.get("/gdc/md/" + projectId + "/query/dimensions") | ||
.then(function (apiResponse) { return (apiResponse.response.ok ? apiResponse.getData() : apiResponse.response); }) | ||
.then(util_1.getIn('query.entries')); | ||
}; | ||
function getDimensions(projectId) { | ||
return xhr.get('/gdc/md/' + projectId + '/query/dimensions').then(function (r) { | ||
return r.ok ? r.json() : r; | ||
}).then((0, _util.getIn)('query.entries')); | ||
} | ||
/** | ||
@@ -209,10 +247,9 @@ * Returns project folders. Folders can be of specific types and you can specify | ||
*/ | ||
MetadataModule.prototype.getFolders = function (projectId, type) { | ||
var _this = this; | ||
var getFolderEntries = function (pId, t) { | ||
var typeURL = t ? "?type=" + t : ''; | ||
return _this.xhr.get("/gdc/md/" + pId + "/query/folders" + typeURL) | ||
.then((function (r) { return r.getData(); })) | ||
.then(util_1.getIn('query.entries')); | ||
}; | ||
function getFolders(projectId, type) { | ||
function getFolderEntries(pId, t) { | ||
var typeURL = t ? '?type=' + t : ''; | ||
return xhr.get('/gdc/md/' + pId + '/query/folders' + typeURL).then((0, _util.getIn)('query.entries')); | ||
} | ||
switch (type) { | ||
@@ -223,15 +260,15 @@ case 'fact': | ||
case 'attribute': | ||
return this.getDimensions(projectId); | ||
return getDimensions(projectId); | ||
default: | ||
return Promise.all([ | ||
getFolderEntries(projectId, 'fact'), | ||
getFolderEntries(projectId, 'metric'), | ||
this.getDimensions(projectId) | ||
]) | ||
.then(function (_a) { | ||
var facts = _a[0], metrics = _a[1], attributes = _a[2]; | ||
return Promise.all([getFolderEntries(projectId, 'fact'), getFolderEntries(projectId, 'metric'), getDimensions(projectId)]).then(function (_ref2) { | ||
var _ref3 = _slicedToArray(_ref2, 3), | ||
facts = _ref3[0], | ||
metrics = _ref3[1], | ||
attributes = _ref3[2]; | ||
return { fact: facts, metric: metrics, attribute: attributes }; | ||
}); | ||
} | ||
}; | ||
} | ||
/** | ||
@@ -244,7 +281,8 @@ * Returns all facts in a project specified by the given projectId | ||
*/ | ||
MetadataModule.prototype.getFacts = function (projectId) { | ||
return this.xhr.get("/gdc/md/" + projectId + "/query/facts") | ||
.then(function (apiResponse) { return (apiResponse.response.ok ? apiResponse.getData() : apiResponse.response); }) | ||
.then(util_1.getIn('query.entries')); | ||
}; | ||
function getFacts(projectId) { | ||
return xhr.get('/gdc/md/' + projectId + '/query/facts').then(function (r) { | ||
return r.ok ? r.json() : r; | ||
}).then((0, _util.getIn)('query.entries')); | ||
} | ||
/** | ||
@@ -257,7 +295,8 @@ * Returns all metrics in a project specified by the given projectId | ||
*/ | ||
MetadataModule.prototype.getMetrics = function (projectId) { | ||
return this.xhr.get("/gdc/md/" + projectId + "/query/metrics") | ||
.then(function (apiResponse) { return (apiResponse.response.ok ? apiResponse.getData() : apiResponse.response); }) | ||
.then(util_1.getIn('query.entries')); | ||
}; | ||
function getMetrics(projectId) { | ||
return xhr.get('/gdc/md/' + projectId + '/query/metrics').then(function (r) { | ||
return r.ok ? r.json() : r; | ||
}).then((0, _util.getIn)('query.entries')); | ||
} | ||
/** | ||
@@ -275,8 +314,12 @@ * Returns all metrics that are reachable (with respect to ldm of the project | ||
*/ | ||
MetadataModule.prototype.getAvailableMetrics = function (projectId, attrs) { | ||
if (attrs === void 0) { attrs = []; } | ||
return this.xhr.post("/gdc/md/" + projectId + "/availablemetrics", { body: attrs }) | ||
.then(function (apiResponse) { return (apiResponse.response.ok ? apiResponse.getData() : apiResponse.response); }) | ||
.then(function (data) { return data.entries; }); | ||
}; | ||
function getAvailableMetrics(projectId, attrs) { | ||
return xhr.post('/gdc/md/' + projectId + '/availablemetrics', { | ||
data: JSON.stringify(attrs) | ||
}).then(function (r) { | ||
return r.ok ? r.json() : r; | ||
}).then(function (r) { | ||
return r.entries; | ||
}); | ||
} | ||
/** | ||
@@ -294,8 +337,12 @@ * Returns all attributes that are reachable (with respect to ldm of the project | ||
*/ | ||
MetadataModule.prototype.getAvailableAttributes = function (projectId, metrics) { | ||
if (metrics === void 0) { metrics = []; } | ||
return this.xhr.post("/gdc/md/" + projectId + "/drillcrosspaths", { body: metrics }) | ||
.then(function (apiResponse) { return (apiResponse.response.ok ? apiResponse.getData() : apiResponse.response); }) | ||
.then(function (r) { return r.drillcrosspath.links; }); | ||
}; | ||
function getAvailableAttributes(projectId, metrics) { | ||
return xhr.post('/gdc/md/' + projectId + '/drillcrosspaths', { | ||
body: JSON.stringify(metrics) | ||
}).then(function (r) { | ||
return r.ok ? r.json() : r; | ||
}).then(function (r) { | ||
return r.drillcrosspath.links; | ||
}); | ||
} | ||
/** | ||
@@ -313,7 +360,12 @@ * Returns all attributes that are reachable (with respect to ldm of the project | ||
*/ | ||
MetadataModule.prototype.getAvailableFacts = function (projectId, items) { | ||
if (items === void 0) { items = []; } | ||
return this.xhr.post("/gdc/md/" + projectId + "/availablefacts", { body: items }) | ||
.then(function (r) { return (r.response.ok ? r.getData() : r.response); }).then(function (r) { return r.entries; }); | ||
}; | ||
function getAvailableFacts(projectId, items) { | ||
return xhr.post('/gdc/md/' + projectId + '/availablefacts', { | ||
data: JSON.stringify(items) | ||
}).then(function (r) { | ||
return r.ok ? r.json() : r; | ||
}).then(function (r) { | ||
return r.entries; | ||
}); | ||
} | ||
/** | ||
@@ -326,5 +378,6 @@ * Get details of a metadata object specified by its uri | ||
*/ | ||
MetadataModule.prototype.getObjectDetails = function (uri) { | ||
return this.xhr.get(uri).then(function (r) { return r.getData(); }); | ||
}; | ||
function getObjectDetails(uri) { | ||
return xhr.get(uri); | ||
} | ||
/** | ||
@@ -341,14 +394,16 @@ * Get folders with items. | ||
*/ | ||
MetadataModule.prototype.getFoldersWithItems = function (projectId, type) { | ||
var _this = this; | ||
function getFoldersWithItems(projectId, type) { | ||
// fetch all folders of given type and process them | ||
return this.getFolders(projectId, type).then(function (folders) { | ||
// Helper public to get details for each metric in the given | ||
return getFolders(projectId, type).then(function (folders) { | ||
// Helper function to get details for each metric in the given | ||
// array of links to the metadata objects representing the metrics. | ||
// @return the array of promises | ||
var getMetricItemsDetails = function (array) { | ||
return Promise.all(array.map(_this.getObjectDetails)).then(function (metricArgs) { | ||
return metricArgs.map(function (item) { return item.metric; }); | ||
function getMetricItemsDetails(array) { | ||
return Promise.all(array.map(getObjectDetails)).then(function (metricArgs) { | ||
return metricArgs.map(function (item) { | ||
return item.metric; | ||
}); | ||
}); | ||
}; | ||
} | ||
// helper mapBy function | ||
@@ -360,5 +415,6 @@ function mapBy(array, key) { | ||
} | ||
// helper for sorting folder tree structure | ||
// sadly @returns void (sorting == mutating array in js) | ||
var sortFolderTree = function (structure) { | ||
var sortFolderTree = function sortFolderTree(structure) { | ||
structure.forEach(function (folder) { | ||
@@ -368,6 +424,6 @@ folder.items.sort(function (a, b) { | ||
return -1; | ||
} | ||
else if (a.meta.title > b.meta.title) { | ||
} else if (a.meta.title > b.meta.title) { | ||
return 1; | ||
} | ||
return 0; | ||
@@ -379,13 +435,15 @@ }); | ||
return -1; | ||
} | ||
else if (a.title > b.title) { | ||
} else if (a.title > b.title) { | ||
return 1; | ||
} | ||
return 0; | ||
}); | ||
}; | ||
var foldersLinks = mapBy(folders, 'link'); | ||
var foldersTitles = mapBy(folders, 'title'); | ||
// fetch details for each folder | ||
return Promise.all(foldersLinks.map(_this.getObjectDetails)).then(function (folderDetails) { | ||
return Promise.all(foldersLinks.map(getObjectDetails)).then(function (folderDetails) { | ||
// if attribute, just parse everything from what we've received | ||
@@ -396,3 +454,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 | ||
return _this.getAttributes(projectId).then(function (attributes) { | ||
return getAttributes(projectId).then(function (attributes) { | ||
// get uris of attributes which are in some dimension folders | ||
@@ -406,10 +464,14 @@ var attributesInFolders = []; | ||
// unsortedUris now contains uris of all attributes which aren't in a folder | ||
var unsortedUris = attributes | ||
.filter(function (item) { return attributesInFolders.indexOf(item.link) === -1; }) | ||
.map(function (item) { return item.link; }); | ||
var unsortedUris = attributes.filter(function (item) { | ||
return attributesInFolders.indexOf(item.link) === -1; | ||
}).map(function (item) { | ||
return item.link; | ||
}); | ||
// now get details of attributes in no folders | ||
return Promise.all(unsortedUris.map(_this.getObjectDetails)) | ||
.then(function (unsortedAttributeArgs) { | ||
return Promise.all(unsortedUris.map(getObjectDetails)).then(function (unsortedAttributeArgs) { | ||
// TODO add map to r.json | ||
// get unsorted attribute objects | ||
var unsortedAttributes = unsortedAttributeArgs.map(function (attr) { return attr.attribute; }); | ||
var unsortedAttributes = unsortedAttributeArgs.map(function (attr) { | ||
return attr.attribute; | ||
}); | ||
// create structure of folders with attributes | ||
@@ -428,10 +490,12 @@ var structure = folderDetails.map(function (folderDetail) { | ||
sortFolderTree(structure); | ||
return structure; | ||
}); | ||
}); | ||
} | ||
else if (type === 'metric') { | ||
var entriesLinks_1 = folderDetails.map(function (entry) { return mapBy(entry.folder.content.entries, 'link'); }); | ||
} else if (type === 'metric') { | ||
var entriesLinks = folderDetails.map(function (entry) { | ||
return mapBy(entry.folder.content.entries, 'link'); | ||
}); | ||
// get all metrics, subtract what we have and add rest in unsorted folder | ||
return _this.getMetrics(projectId).then(function (metrics) { | ||
return getMetrics(projectId).then(function (metrics) { | ||
// get uris of metrics which are in some dimension folders | ||
@@ -445,10 +509,16 @@ var metricsInFolders = []; | ||
// unsortedUris now contains uris of all metrics which aren't in a folder | ||
var unsortedUris = metrics | ||
.filter(function (item) { return metricsInFolders.indexOf(item.link) === -1; }) | ||
.map(function (item) { return item.link; }); | ||
var unsortedUris = metrics.filter(function (item) { | ||
return metricsInFolders.indexOf(item.link) === -1; | ||
}).map(function (item) { | ||
return item.link; | ||
}); | ||
// sadly order of parameters of concat matters! (we want unsorted last) | ||
entriesLinks_1.push(unsortedUris); | ||
entriesLinks.push(unsortedUris); | ||
// now get details of all metrics | ||
return Promise.all(entriesLinks_1.map(function (linkArray) { return getMetricItemsDetails(linkArray); })) | ||
.then(function (tree) { | ||
return Promise.all(entriesLinks.map(function (linkArray) { | ||
return getMetricItemsDetails(linkArray); | ||
})).then(function (tree) { | ||
// TODO add map to r.json | ||
// all promises resolved, i.e. details for each metric are available | ||
@@ -458,3 +528,3 @@ var structure = tree.map(function (treeItems, idx) { | ||
return { | ||
title: (foldersTitles[idx] || 'Unsorted'), | ||
title: foldersTitles[idx] || 'Unsorted', | ||
items: treeItems | ||
@@ -468,6 +538,8 @@ }; | ||
} | ||
return Promise.reject(null); | ||
return Promise.reject(); | ||
}); | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -480,20 +552,23 @@ * Get identifier of a metadata object identified by its uri | ||
*/ | ||
MetadataModule.prototype.getObjectIdentifier = function (uri) { | ||
function getObjectIdentifier(uri) { | ||
function idFinder(obj) { | ||
if (obj.attribute) { | ||
return obj.attribute.content.displayForms[0].meta.identifier; | ||
} | ||
else if (obj.dimension) { | ||
} else if (obj.dimension) { | ||
return obj.dimension.content.attributes.content.displayForms[0].meta.identifier; | ||
} | ||
else if (obj.metric) { | ||
} else if (obj.metric) { | ||
return obj.metric.meta.identifier; | ||
} | ||
throw Error('Unknown object!'); | ||
} | ||
if (!lodash_1.isPlainObject(uri)) { | ||
return this.getObjectDetails(uri).then(function (data) { return idFinder(data); }); | ||
if (!(0, _lodash.isPlainObject)(uri)) { | ||
return getObjectDetails(uri).then(function (data) { | ||
return idFinder(data); | ||
}); | ||
} | ||
return Promise.resolve(idFinder(uri)); | ||
}; | ||
} | ||
/** | ||
@@ -507,16 +582,21 @@ * Get uri of an metadata object, specified by its identifier and project id it belongs to | ||
*/ | ||
MetadataModule.prototype.getObjectUri = function (projectId, identifier) { | ||
return this.xhr.post("/gdc/md/" + projectId + "/identifiers", { | ||
function getObjectUri(projectId, identifier) { | ||
return xhr.ajax('/gdc/md/' + projectId + '/identifiers', { | ||
method: 'POST', | ||
body: { | ||
identifierToUri: [identifier] | ||
} | ||
}).then(function (r) { | ||
var data = r.getData(); | ||
var found = data.identifiers.find(function (pair) { return pair.identifier === identifier; }); | ||
}).then(xhr.parseJSON).then(function (data) { | ||
var found = data.identifiers.find(function (pair) { | ||
return pair.identifier === identifier; | ||
}); | ||
if (found) { | ||
return found.uri; | ||
} | ||
throw new xhr_1.ApiResponseError("Object with identifier " + identifier + " not found in project " + projectId, r.response, r.responseBody); | ||
throw new Error('Object with identifier ' + identifier + ' not found in project ' + projectId); | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -530,11 +610,12 @@ * Get uris specified by identifiers | ||
*/ | ||
MetadataModule.prototype.getUrisFromIdentifiers = function (projectId, identifiers) { | ||
return this.xhr.post("/gdc/md/" + projectId + "/identifiers", { | ||
function getUrisFromIdentifiers(projectId, identifiers) { | ||
return xhr.post('/gdc/md/' + projectId + '/identifiers', { | ||
body: { | ||
identifierToUri: identifiers | ||
} | ||
}).then((function (r) { return r.getData(); })).then(function (data) { | ||
}).then(xhr.parseJSON).then(function (data) { | ||
return data.identifiers; | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -548,11 +629,12 @@ * Get identifiers specified by uris | ||
*/ | ||
MetadataModule.prototype.getIdentifiersFromUris = function (projectId, uris) { | ||
return this.xhr.post("/gdc/md/" + projectId + "/identifiers", { | ||
function getIdentifiersFromUris(projectId, uris) { | ||
return xhr.post('/gdc/md/' + projectId + '/identifiers', { | ||
body: { | ||
uriToIdentifier: uris | ||
} | ||
}).then((function (r) { return r.getData(); })).then(function (data) { | ||
}).then(xhr.parseJSON).then(function (data) { | ||
return data.identifiers; | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -567,16 +649,20 @@ * Get attribute elements with their labels and uris. | ||
*/ | ||
MetadataModule.prototype.translateElementLabelsToUris = function (projectId, labelUri, patterns, mode) { | ||
if (mode === void 0) { mode = 'EXACT'; } | ||
return this.xhr.post("/gdc/md/" + projectId + "/labels", { | ||
function translateElementLabelsToUris(projectId, labelUri, patterns) { | ||
var mode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'EXACT'; | ||
return xhr.post('/gdc/md/' + projectId + '/labels', { | ||
body: { | ||
elementLabelToUri: [ | ||
{ | ||
labelUri: labelUri, | ||
mode: mode, | ||
patterns: patterns | ||
} | ||
] | ||
elementLabelToUri: [{ | ||
labelUri: labelUri, | ||
mode: mode, | ||
patterns: patterns | ||
}] | ||
} | ||
}).then(function (r) { return (r.response.ok ? lodash_1.get(r.getData(), 'elementLabelUri') : r.response); }); | ||
}; | ||
}).then(function (r) { | ||
return r.ok ? r.json() : r; | ||
}).then(function (r) { | ||
return (0, _lodash.get)(r, 'elementLabelUri'); | ||
}); | ||
} | ||
/** | ||
@@ -604,31 +690,36 @@ * Get valid elements of an attribute, specified by its identifier and project id it belongs to | ||
*/ | ||
MetadataModule.prototype.getValidElements = function (projectId, id, options) { | ||
var _this = this; | ||
if (options === void 0) { options = {}; } | ||
var query = lodash_1.pick(options, ['limit', 'offset', 'order', 'filter', 'prompt']); | ||
var queryParams = util_1.queryString(query); | ||
var pickedOptions = lodash_1.pick(options, [ | ||
'uris', 'complement', 'includeTotalCountWithoutFilters', 'restrictiveDefinition' | ||
]); | ||
function getValidElements(projectId, id) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var query = (0, _lodash.pick)(options, ['limit', 'offset', 'order', 'filter', 'prompt']); | ||
var queryParams = (0, _util.queryString)(query); | ||
var pickedOptions = (0, _lodash.pick)(options, ['uris', 'complement', 'includeTotalCountWithoutFilters', 'restrictiveDefinition']); | ||
var afm = options.afm; | ||
var getRequestBodyWithReportDefinition = function () { return _this.xhr | ||
.post("/gdc/app/projects/" + projectId + "/executeAfm/debug", { | ||
body: { | ||
execution: { | ||
afm: afm | ||
var getRequestBodyWithReportDefinition = function getRequestBodyWithReportDefinition() { | ||
return xhr.post('/gdc/app/projects/' + projectId + '/executeAfm/debug', { | ||
body: { | ||
execution: { | ||
afm: afm | ||
} | ||
} | ||
} | ||
}) | ||
.then(function (response) { return response.getData(); }) | ||
.then(function (reportDefinitionResult) { return (__assign({}, pickedOptions, { restrictiveDefinitionContent: reportDefinitionResult.reportDefinition.content })); }); }; | ||
var getOptions = afm ? getRequestBodyWithReportDefinition : function () { return Promise.resolve(pickedOptions); }; | ||
return getOptions() | ||
.then(function (requestBody) { return _this.xhr | ||
.post(("/gdc/md/" + projectId + "/obj/" + id + "/validElements" + queryParams).replace(/\?$/, ''), { | ||
body: { | ||
validElementsRequest: requestBody | ||
} | ||
}) | ||
.then(function (response) { return response.getData(); }); }); | ||
}; | ||
}).then(xhr.parseJSON).then(function (reportDefinitionResult) { | ||
return _extends({}, pickedOptions, { | ||
restrictiveDefinitionContent: reportDefinitionResult.reportDefinition.content | ||
}); | ||
}); | ||
}; | ||
var getOptions = afm ? getRequestBodyWithReportDefinition : function () { | ||
return Promise.resolve(pickedOptions); | ||
}; | ||
return getOptions().then(function (requestBody) { | ||
return xhr.post(('/gdc/md/' + projectId + '/obj/' + id + '/validElements' + queryParams).replace(/\?$/, ''), { | ||
data: JSON.stringify({ validElementsRequest: requestBody }) | ||
}).then(xhr.parseJSON); | ||
}); | ||
} | ||
/** | ||
@@ -641,5 +732,6 @@ * Delete object | ||
*/ | ||
MetadataModule.prototype.deleteObject = function (uri) { | ||
return this.xhr.del(uri); | ||
}; | ||
function deleteObject(uri) { | ||
return xhr.del(uri); | ||
} | ||
/** | ||
@@ -653,7 +745,20 @@ * Create object | ||
*/ | ||
MetadataModule.prototype.createObject = function (projectId, obj) { | ||
return this.xhr.post("/gdc/md/" + projectId + "/obj?createAndGet=true", { | ||
body: obj | ||
}).then((function (r) { return r.getData(); })); | ||
}; | ||
function createObject(projectId, obj) { | ||
return xhr.post('/gdc/md/' + projectId + '/obj?createAndGet=true', { | ||
data: JSON.stringify(obj) | ||
}).then(xhr.parseJSON); | ||
} | ||
function isTaskFinished(task) { | ||
var taskState = task.wTaskStatus.status; | ||
return taskState === 'OK' || taskState === 'ERROR'; | ||
} | ||
function checkStatusForError(response) { | ||
if (response.wTaskStatus.status === 'ERROR') { | ||
return Promise.reject(response); | ||
} | ||
return response; | ||
} | ||
/** | ||
@@ -668,13 +773,15 @@ * LDM manage | ||
*/ | ||
MetadataModule.prototype.ldmManage = function (projectId, maql, options) { | ||
var _this = this; | ||
if (options === void 0) { options = {}; } | ||
return this.xhr.post("/gdc/md/" + projectId + "/ldm/manage2", { body: { manage: { maql: maql } } }) | ||
.then((function (r) { return r.getData(); })) | ||
.then(function (response) { | ||
function ldmManage(projectId, maql) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
return xhr.post('/gdc/md/' + projectId + '/ldm/manage2', { | ||
data: JSON.stringify({ | ||
manage: { maql: maql } | ||
}) | ||
}).then(xhr.parseJSON).then(function (response) { | ||
var manageStatusUri = response.entries[0].link; | ||
return util_1.handlePolling(_this.xhr.get.bind(_this.xhr), manageStatusUri, _this.isTaskFinished, options); | ||
}) | ||
.then(this.checkStatusForError); | ||
}; | ||
return (0, _util.handlePolling)(xhr.get, manageStatusUri, isTaskFinished, options); | ||
}).then(checkStatusForError); | ||
} | ||
/** | ||
@@ -689,25 +796,41 @@ * ETL pull | ||
*/ | ||
MetadataModule.prototype.etlPull = function (projectId, uploadsDir, options) { | ||
var _this = this; | ||
if (options === void 0) { options = {}; } | ||
return this.xhr.post("/gdc/md/" + projectId + "/etl/pull2", { body: { pullIntegration: uploadsDir } }) | ||
.then((function (r) { return r.getData(); })) | ||
.then(function (response) { | ||
function etlPull(projectId, uploadsDir) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
return xhr.post('/gdc/md/' + projectId + '/etl/pull2', { | ||
data: JSON.stringify({ | ||
pullIntegration: uploadsDir | ||
}) | ||
}).then(xhr.parseJSON).then(function (response) { | ||
var etlPullStatusUri = response.pull2Task.links.poll; | ||
return util_1.handlePolling(_this.xhr.get.bind(_this.xhr), etlPullStatusUri, _this.isTaskFinished, options); | ||
}) | ||
.then(this.checkStatusForError); | ||
return (0, _util.handlePolling)(xhr.get, etlPullStatusUri, isTaskFinished, options); | ||
}).then(checkStatusForError); | ||
} | ||
return { | ||
createObject: createObject, | ||
deleteObject: deleteObject, | ||
etlPull: etlPull, | ||
getAttributes: getAttributes, | ||
getAvailableAttributes: getAvailableAttributes, | ||
getAvailableFacts: getAvailableFacts, | ||
getAvailableMetrics: getAvailableMetrics, | ||
getDimensions: getDimensions, | ||
getFacts: getFacts, | ||
getFoldersWithItems: getFoldersWithItems, | ||
getIdentifiersFromUris: getIdentifiersFromUris, | ||
getMetrics: getMetrics, | ||
getObjectDetails: getObjectDetails, | ||
getObjectIdentifier: getObjectIdentifier, | ||
getObjects: getObjects, | ||
getObjectsByQuery: getObjectsByQuery, | ||
getObjectUri: getObjectUri, | ||
getObjectUsing: getObjectUsing, | ||
getObjectUsingMany: getObjectUsingMany, | ||
getUrisFromIdentifiers: getUrisFromIdentifiers, | ||
getValidElements: getValidElements, | ||
getVisualizations: getVisualizations, | ||
ldmManage: ldmManage, | ||
translateElementLabelsToUris: translateElementLabelsToUris | ||
}; | ||
MetadataModule.prototype.isTaskFinished = function (task) { | ||
var taskState = task.wTaskStatus.status; | ||
return taskState === 'OK' || taskState === 'ERROR'; | ||
}; | ||
MetadataModule.prototype.checkStatusForError = function (response) { | ||
if (response.wTaskStatus.status === 'ERROR') { | ||
return Promise.reject(response); | ||
} | ||
return response; | ||
}; | ||
return MetadataModule; | ||
}()); | ||
exports.MetadataModule = MetadataModule; | ||
} |
@@ -1,5 +0,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// Copyright (C) 2007-2017, GoodData(R) Corporation. All rights reserved. | ||
var util_1 = require("./util"); | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.createModule = createModule; | ||
var _util = require('./util'); | ||
/** | ||
@@ -11,31 +16,13 @@ * Functions for working with projects | ||
*/ | ||
var DEFAULT_PALETTE = [ | ||
{ r: 0x2b, g: 0x6b, b: 0xae }, | ||
{ r: 0x69, g: 0xaa, b: 0x51 }, | ||
{ r: 0xee, g: 0xb1, b: 0x4c }, | ||
{ r: 0xd5, g: 0x3c, b: 0x38 }, | ||
{ r: 0x89, g: 0x4d, b: 0x94 }, | ||
{ r: 0x73, g: 0x73, b: 0x73 }, | ||
{ r: 0x44, g: 0xa9, b: 0xbe }, | ||
{ r: 0x96, g: 0xbd, b: 0x5f }, | ||
{ r: 0xfd, g: 0x93, b: 0x69 }, | ||
{ r: 0xe1, g: 0x5d, b: 0x86 }, | ||
{ r: 0x7c, g: 0x6f, b: 0xad }, | ||
{ r: 0xa5, g: 0xa5, b: 0xa5 }, | ||
{ r: 0x7a, g: 0xa6, b: 0xd5 }, | ||
{ r: 0x82, g: 0xd0, b: 0x8d }, | ||
{ r: 0xff, g: 0xd2, b: 0x89 }, | ||
{ r: 0xf1, g: 0x84, b: 0x80 }, | ||
{ r: 0xbf, g: 0x90, b: 0xc6 }, | ||
{ r: 0xbf, g: 0xbf, b: 0xbf } | ||
]; | ||
var isProjectCreated = function (project) { | ||
var DEFAULT_PALETTE = [{ r: 0x2b, g: 0x6b, b: 0xae }, { r: 0x69, g: 0xaa, b: 0x51 }, { r: 0xee, g: 0xb1, b: 0x4c }, { r: 0xd5, g: 0x3c, b: 0x38 }, { r: 0x89, g: 0x4d, b: 0x94 }, { r: 0x73, g: 0x73, b: 0x73 }, { r: 0x44, g: 0xa9, b: 0xbe }, { r: 0x96, g: 0xbd, b: 0x5f }, { r: 0xfd, g: 0x93, b: 0x69 }, { r: 0xe1, g: 0x5d, b: 0x86 }, { r: 0x7c, g: 0x6f, b: 0xad }, { r: 0xa5, g: 0xa5, b: 0xa5 }, { r: 0x7a, g: 0xa6, b: 0xd5 }, { r: 0x82, g: 0xd0, b: 0x8d }, { r: 0xff, g: 0xd2, b: 0x89 }, { r: 0xf1, g: 0x84, b: 0x80 }, { r: 0xbf, g: 0x90, b: 0xc6 }, { r: 0xbf, g: 0xbf, b: 0xbf }]; // Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved. | ||
var isProjectCreated = function isProjectCreated(project) { | ||
var projectState = project.content.state; | ||
return projectState === 'ENABLED' || | ||
projectState === 'DELETED'; | ||
return projectState === 'ENABLED' || projectState === 'DELETED'; | ||
}; | ||
var ProjectModule = /** @class */ (function () { | ||
function ProjectModule(xhr) { | ||
this.xhr = xhr; | ||
} | ||
function createModule(xhr) { | ||
/** | ||
@@ -47,6 +34,4 @@ * Get current project id | ||
*/ | ||
ProjectModule.prototype.getCurrentProjectId = function () { | ||
return this.xhr.get('/gdc/app/account/bootstrap') | ||
.then(function (r) { return r.getData(); }) | ||
.then(function (result) { | ||
function getCurrentProjectId() { | ||
return xhr.get('/gdc/app/account/bootstrap').then(function (result) { | ||
var currentProject = result.bootstrapResource.current.project; | ||
@@ -57,5 +42,7 @@ // handle situation in which current project is missing (e.g. new user) | ||
} | ||
return result.bootstrapResource.current.project.links.self.split('/').pop(); | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -68,9 +55,10 @@ * Fetches projects available for the user represented by the given profileId | ||
*/ | ||
ProjectModule.prototype.getProjects = function (profileId) { | ||
return this.xhr.get("/gdc/account/profile/" + profileId + "/projects") | ||
.then(function (r) { return r.getData(); }) | ||
.then(function (r) { | ||
return r.projects.map(function (p) { return p.project; }); | ||
function getProjects(profileId) { | ||
return xhr.get('/gdc/account/profile/' + profileId + '/projects').then(function (r) { | ||
return r.projects.map(function (p) { | ||
return p.project; | ||
}); | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -83,7 +71,6 @@ * Fetches all datasets for the given project | ||
*/ | ||
ProjectModule.prototype.getDatasets = function (projectId) { | ||
return this.xhr.get("/gdc/md/" + projectId + "/query/datasets") | ||
.then(function (r) { return r.getData(); }) | ||
.then(util_1.getIn('query.entries')); | ||
}; | ||
function getDatasets(projectId) { | ||
return xhr.get('/gdc/md/' + projectId + '/query/datasets').then((0, _util.getIn)('query.entries')); | ||
} | ||
/** | ||
@@ -98,6 +85,4 @@ * Fetches a chart color palette for a project represented by the given | ||
*/ | ||
ProjectModule.prototype.getColorPalette = function (projectId) { | ||
return this.xhr.get("/gdc/projects/" + projectId + "/styleSettings") | ||
.then(function (r) { return r.getData(); }) | ||
.then(function (result) { | ||
function getColorPalette(projectId) { | ||
return xhr.get('/gdc/projects/' + projectId + '/styleSettings').then(function (result) { | ||
return result.styleSettings.chartPalette.map(function (c) { | ||
@@ -114,5 +99,7 @@ return { | ||
} | ||
throw new Error(err.statusText); | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -124,10 +111,10 @@ * Sets given colors as a color palette for a given project. | ||
* @param {Array} colors - An array of colors that we want to use within the project. | ||
* Each color should be an object with r, g, b fields. // TODO really object? | ||
* Each color should be an object with r, g, b fields. | ||
*/ | ||
ProjectModule.prototype.setColorPalette = function (projectId, colors) { | ||
return this.xhr.put("/gdc/projects/" + projectId + "/styleSettings", { | ||
body: { | ||
function setColorPalette(projectId, colors) { | ||
return xhr.put('/gdc/projects/' + projectId + '/styleSettings', { | ||
data: { | ||
styleSettings: { | ||
chartPalette: colors.map(function (fill, idx) { | ||
return { fill: fill, guid: "guid" + idx }; | ||
return { fill: fill, guid: 'guid' + idx }; | ||
}) | ||
@@ -137,3 +124,4 @@ } | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -151,19 +139,22 @@ * Gets current timezone and its offset. Example output: | ||
*/ | ||
ProjectModule.prototype.getTimezone = function (projectId) { | ||
var bootstrapUrl = "/gdc/app/account/bootstrap?projectId=" + projectId; | ||
return this.xhr.get(bootstrapUrl) | ||
.then((function (r) { return r.getData(); })) | ||
.then(function (result) { | ||
function getTimezone(projectId) { | ||
var bootstrapUrl = '/gdc/app/account/bootstrap?projectId=' + projectId; | ||
return xhr.get(bootstrapUrl).then(function (result) { | ||
return result.bootstrapResource.current.timezone; | ||
}); | ||
}; | ||
ProjectModule.prototype.setTimezone = function (projectId, timezone) { | ||
var timezoneServiceUrl = "/gdc/md/" + projectId + "/service/timezone"; | ||
} | ||
function setTimezone(projectId, timezone) { | ||
var timezoneServiceUrl = '/gdc/md/' + projectId + '/service/timezone'; | ||
var data = { | ||
service: { timezone: timezone } | ||
}; | ||
return this.xhr.post(timezoneServiceUrl, { | ||
return xhr.ajax(timezoneServiceUrl, { | ||
method: 'POST', | ||
body: data | ||
}).then((function (r) { return r.getData(); })); | ||
}; | ||
}).then(xhr.parseJSON); | ||
} | ||
/** | ||
@@ -180,7 +171,15 @@ * Create project | ||
*/ | ||
ProjectModule.prototype.createProject = function (title, authorizationToken, options) { | ||
var _this = this; | ||
if (options === void 0) { options = {}; } | ||
var summary = options.summary, projectTemplate = options.projectTemplate, _a = options.driver, driver = _a === void 0 ? 'Pg' : _a, _b = options.environment, environment = _b === void 0 ? 'TESTING' : _b, _c = options.guidedNavigation, guidedNavigation = _c === void 0 ? 1 : _c; | ||
return this.xhr.post('/gdc/projects', { | ||
function createProject(title, authorizationToken) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var summary = options.summary, | ||
projectTemplate = options.projectTemplate, | ||
_options$driver = options.driver, | ||
driver = _options$driver === undefined ? 'Pg' : _options$driver, | ||
_options$environment = options.environment, | ||
environment = _options$environment === undefined ? 'TESTING' : _options$environment, | ||
_options$guidedNaviga = options.guidedNavigation, | ||
guidedNavigation = _options$guidedNaviga === undefined ? 1 : _options$guidedNaviga; | ||
return xhr.post('/gdc/projects', { | ||
body: JSON.stringify({ | ||
@@ -201,10 +200,9 @@ project: { | ||
}) | ||
}) | ||
.then((function (r) { return r.getData(); })) | ||
.then(function (project) { | ||
return util_1.handlePolling(_this.xhr.get.bind(_this.xhr), project.uri, function (response) { | ||
}).then(xhr.parseJSON).then(function (project) { | ||
return (0, _util.handlePolling)(xhr.get, project.uri, function (response) { | ||
return isProjectCreated(response.project); | ||
}, options); | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -216,7 +214,17 @@ * Delete project | ||
*/ | ||
ProjectModule.prototype.deleteProject = function (projectId) { | ||
return this.xhr.del("/gdc/projects/" + projectId); | ||
function deleteProject(projectId) { | ||
return xhr.del('/gdc/projects/' + projectId); | ||
} | ||
return { | ||
getCurrentProjectId: getCurrentProjectId, | ||
getProjects: getProjects, | ||
getDatasets: getDatasets, | ||
getColorPalette: getColorPalette, | ||
setColorPalette: setColorPalette, | ||
getTimezone: getTimezone, | ||
setTimezone: setTimezone, | ||
createProject: createProject, | ||
deleteProject: deleteProject | ||
}; | ||
return ProjectModule; | ||
}()); | ||
exports.ProjectModule = ProjectModule; | ||
} |
130
lib/user.js
@@ -1,7 +0,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var UserModule = /** @class */ (function () { | ||
function UserModule(xhr) { | ||
this.xhr = xhr; | ||
} | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.createModule = createModule; | ||
// Copyright (C) 2007-2017, GoodData(R) Corporation. All rights reserved. | ||
function createModule(xhr) { | ||
/** | ||
@@ -13,9 +16,11 @@ * Find out whether a user is logged in | ||
*/ | ||
UserModule.prototype.isLoggedIn = function () { | ||
var _this = this; | ||
function isLoggedIn() { | ||
return new Promise(function (resolve, reject) { | ||
_this.xhr.get('/gdc/account/token').then(function (r) { | ||
if (r.response.ok) { | ||
// cannot use get here directly - we need to access to response | ||
// not to responses JSON get returns | ||
xhr.ajax('/gdc/account/token', { method: 'GET' }).then(function (r) { | ||
if (r.ok) { | ||
resolve(true); | ||
} | ||
resolve(false); | ||
@@ -25,4 +30,3 @@ }, function (err) { | ||
resolve(false); | ||
} | ||
else { | ||
} else { | ||
reject(err); | ||
@@ -32,3 +36,4 @@ } | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -43,4 +48,4 @@ * This function provides an authentication entry point to the GD API. It is needed to authenticate | ||
*/ | ||
UserModule.prototype.login = function (username, password) { | ||
return this.xhr.post('/gdc/account/login', { | ||
function login(username, password) { | ||
return xhr.post('/gdc/account/login', { | ||
body: JSON.stringify({ | ||
@@ -55,4 +60,5 @@ postUserLogin: { | ||
}) | ||
}).then((function (r) { return r.getData(); })); | ||
}; | ||
}).then(xhr.parseJSON); | ||
} | ||
/** | ||
@@ -67,5 +73,7 @@ * This function provides an authentication entry point to the GD API via SSO | ||
*/ | ||
UserModule.prototype.loginSso = function (sessionId, serverUrl, targetUrl) { | ||
return this.xhr.get("/gdc/account/customerlogin?sessionId=" + sessionId + "&serverURL=" + serverUrl + "&targetURL=" + targetUrl); | ||
}; | ||
function loginSso(sessionId, serverUrl, targetUrl) { | ||
// cannot use xhr.get, server doesn't respond with JSON | ||
return xhr.ajax('/gdc/account/customerlogin?sessionId=' + sessionId + '&serverURL=' + serverUrl + '&targetURL=' + targetUrl, { method: 'GET' }); | ||
} | ||
/** | ||
@@ -75,18 +83,19 @@ * Logs out current user | ||
*/ | ||
UserModule.prototype.logout = function () { | ||
var _this = this; | ||
return this.isLoggedIn().then(function (loggedIn) { | ||
function logout() { | ||
return isLoggedIn().then(function (loggedIn) { | ||
if (loggedIn) { | ||
return _this.xhr | ||
.get('/gdc/app/account/bootstrap') | ||
.then(function (result) { | ||
var data = result.getData(); | ||
var userUri = data.bootstrapResource.accountSetting.links.self; | ||
return xhr.get('/gdc/app/account/bootstrap').then(function (result) { | ||
var userUri = result.bootstrapResource.accountSetting.links.self; | ||
var userId = userUri.match(/([^\/]+)\/?$/)[1]; // eslint-disable-line no-useless-escape | ||
return _this.xhr.del("/gdc/account/login/" + userId); | ||
return xhr.ajax('/gdc/account/login/' + userId, { | ||
method: 'delete' | ||
}); | ||
}); | ||
} | ||
return Promise.resolve(); | ||
}, function (err) { return Promise.reject(err); }); | ||
}; | ||
}); | ||
} | ||
/** | ||
@@ -97,8 +106,9 @@ * Updates user's profile settings | ||
* @param {Object} profileSetting | ||
*/ | ||
UserModule.prototype.updateProfileSettings = function (profileId, profileSetting) { | ||
return this.xhr.put("/gdc/account/profile/" + profileId + "/settings", { | ||
body: profileSetting | ||
*/ | ||
function updateProfileSettings(profileId, profileSetting) { | ||
return xhr.put('/gdc/account/profile/' + profileId + '/settings', { | ||
data: profileSetting | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -108,16 +118,18 @@ * Returns info about currently logged in user from bootstrap resource | ||
*/ | ||
UserModule.prototype.getAccountInfo = function () { | ||
return this.xhr.get('/gdc/app/account/bootstrap') | ||
.then(function (result) { | ||
var bootstrapResource = result.getData().bootstrapResource; | ||
return { | ||
login: bootstrapResource.accountSetting.login, | ||
loginMD5: bootstrapResource.current.loginMD5, | ||
firstName: bootstrapResource.accountSetting.firstName, | ||
lastName: bootstrapResource.accountSetting.lastName, | ||
organizationName: bootstrapResource.settings.organizationName, | ||
profileUri: bootstrapResource.accountSetting.links.self | ||
function getAccountInfo() { | ||
return xhr.get('/gdc/app/account/bootstrap').then(function (result) { | ||
var br = result.bootstrapResource; | ||
var accountInfo = { | ||
login: br.accountSetting.login, | ||
loginMD5: br.current.loginMD5, | ||
firstName: br.accountSetting.firstName, | ||
lastName: br.accountSetting.lastName, | ||
organizationName: br.settings.organizationName, | ||
profileUri: br.accountSetting.links.self | ||
}; | ||
return accountInfo; | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -127,9 +139,17 @@ * Returns the feature flags valid for the currently logged in user. | ||
*/ | ||
UserModule.prototype.getFeatureFlags = function () { | ||
return this.xhr.get('/gdc/app/account/bootstrap') | ||
.then((function (r) { return r.getData(); })) | ||
.then(function (result) { return result.bootstrapResource.current.featureFlags; }); | ||
function getFeatureFlags() { | ||
return xhr.get('/gdc/app/account/bootstrap').then(function (result) { | ||
return result.bootstrapResource.current.featureFlags; | ||
}); | ||
} | ||
return { | ||
isLoggedIn: isLoggedIn, | ||
login: login, | ||
loginSso: loginSso, | ||
logout: logout, | ||
updateProfileSettings: updateProfileSettings, | ||
getAccountInfo: getAccountInfo, | ||
getFeatureFlags: getFeatureFlags | ||
}; | ||
return UserModule; | ||
}()); | ||
exports.UserModule = UserModule; | ||
} |
@@ -1,15 +0,18 @@ | ||
"use strict"; | ||
// Copyright (C) 2007-2017, GoodData(R) Corporation. All rights reserved. | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var lodash_1 = require("lodash"); | ||
var promise_1 = require("./utils/promise"); | ||
var package_json_1 = require("../package.json"); | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.handlePolling = exports.getIn = exports.thisPackage = undefined; | ||
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; }; // Copyright (C) 2007-2017, GoodData(R) Corporation. All rights reserved. | ||
exports.queryString = queryString; | ||
var _lodash = require('lodash'); | ||
var _promise = require('./utils/promise'); | ||
var _package = require('../package.json'); | ||
/** | ||
@@ -22,2 +25,3 @@ * Utility methods. Mostly private | ||
*/ | ||
/** | ||
@@ -27,3 +31,4 @@ * Gooddata-js package signature | ||
*/ | ||
exports.thisPackage = { name: package_json_1.name, version: package_json_1.version }; | ||
var thisPackage = exports.thisPackage = { name: _package.name, version: _package.version }; | ||
/** | ||
@@ -36,3 +41,8 @@ * Create getter function for accessing nested objects | ||
*/ | ||
exports.getIn = function (path) { return function (object) { return lodash_1.get(object, path); }; }; | ||
var getIn = exports.getIn = function getIn(path) { | ||
return function (object) { | ||
return (0, _lodash.get)(object, path); | ||
}; | ||
}; | ||
/** | ||
@@ -46,18 +56,24 @@ * Helper for polling | ||
*/ | ||
exports.handlePolling = function (xhrGet, uri, isPollingDone, options) { | ||
if (options === void 0) { options = {}; } | ||
var _a = options.attempts, attempts = _a === void 0 ? 0 : _a, _b = options.maxAttempts, maxAttempts = _b === void 0 ? 50 : _b, _c = options.pollStep, pollStep = _c === void 0 ? 5000 : _c; | ||
return xhrGet(uri) | ||
.then(function (r) { return r.getData(); }) | ||
.then(function (response) { | ||
var handlePolling = exports.handlePolling = function handlePolling(xhrGet, uri, isPollingDone) { | ||
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; | ||
var _options$attempts = options.attempts, | ||
attempts = _options$attempts === undefined ? 0 : _options$attempts, | ||
_options$maxAttempts = options.maxAttempts, | ||
maxAttempts = _options$maxAttempts === undefined ? 50 : _options$maxAttempts, | ||
_options$pollStep = options.pollStep, | ||
pollStep = _options$pollStep === undefined ? 5000 : _options$pollStep; | ||
return xhrGet(uri).then(function (response) { | ||
if (attempts > maxAttempts) { | ||
return Promise.reject(new Error(response)); | ||
} | ||
return isPollingDone(response) ? | ||
Promise.resolve(response) : | ||
promise_1.delay(pollStep).then(function () { | ||
return exports.handlePolling(xhrGet, uri, isPollingDone, __assign({}, options, { attempts: attempts + 1 })); | ||
}); | ||
return isPollingDone(response) ? Promise.resolve(response) : (0, _promise.delay)(pollStep).then(function () { | ||
return handlePolling(xhrGet, uri, isPollingDone, _extends({}, options, { | ||
attempts: attempts + 1 | ||
})); | ||
}); | ||
}); | ||
}; | ||
/** | ||
@@ -72,8 +88,10 @@ * Builds query string from plain object | ||
function getSingleParam(key, value) { | ||
return (Array.isArray(value) ? | ||
value.map(function (item) { return encodeURIComponent(key) + "=" + encodeURIComponent(item); }).join('&') : | ||
encodeURIComponent(key) + "=" + encodeURIComponent(value)); | ||
return Array.isArray(value) ? value.map(function (item) { | ||
return encodeURIComponent(key) + '=' + encodeURIComponent(item); | ||
}).join('&') : encodeURIComponent(key) + '=' + encodeURIComponent(value); | ||
} | ||
return query ? "?" + Object.keys(query).map(function (k) { return getSingleParam(k, query[k]); }).join('&') : ''; | ||
} | ||
exports.queryString = queryString; | ||
return query ? '?' + Object.keys(query).map(function (k) { | ||
return getSingleParam(k, query[k]); | ||
}).join('&') : ''; | ||
} |
@@ -1,33 +0,44 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var lodash_1 = require("lodash"); | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.getMissingUrisInAttributesMap = getMissingUrisInAttributesMap; | ||
exports.createModule = createModule; | ||
var _lodash = require('lodash'); | ||
function getAttributeUris(displayForms) { | ||
return displayForms.map(function (displayForm) { return lodash_1.get(displayForm, ['attributeDisplayForm', 'content', 'formOf']); }); | ||
return displayForms.map(function (displayForm) { | ||
return (0, _lodash.get)(displayForm, ['attributeDisplayForm', 'content', 'formOf']); | ||
}); | ||
} | ||
function createAttributesMap(displayForms, attributes) { | ||
return displayForms.reduce(function (attributesMap, displayForm) { | ||
var dfUri = lodash_1.get(displayForm, ['attributeDisplayForm', 'meta', 'uri']); | ||
var dfUri = (0, _lodash.get)(displayForm, ['attributeDisplayForm', 'meta', 'uri']); | ||
var attribute = attributes.find(function (attr) { | ||
return lodash_1.get(attr, ['attribute', 'meta', 'uri']) === lodash_1.get(displayForm, ['attributeDisplayForm', 'content', 'formOf']); | ||
return (0, _lodash.get)(attr, ['attribute', 'meta', 'uri']) === (0, _lodash.get)(displayForm, ['attributeDisplayForm', 'content', 'formOf']); | ||
}); | ||
return lodash_1.set(attributesMap, [dfUri], attribute); | ||
return (0, _lodash.set)(attributesMap, [dfUri], attribute); | ||
}, {}); | ||
} | ||
function getMissingUrisInAttributesMap(displayFormsUris, attributesMap) { | ||
var uris = displayFormsUris || []; | ||
return uris.filter(function (uri) { return !attributesMap[uri]; }); | ||
return uris.filter(function (uri) { | ||
return !attributesMap[uri]; | ||
}); | ||
} | ||
exports.getMissingUrisInAttributesMap = getMissingUrisInAttributesMap; | ||
var AttributesMapLoaderModule = /** @class */ (function () { | ||
function AttributesMapLoaderModule(md) { | ||
this.md = md; | ||
} | ||
AttributesMapLoaderModule.prototype.loadAttributesMap = function (projectId, attributeDisplayFormUris) { | ||
var _this = this; | ||
function createModule(md) { | ||
return function loadAttributesMap(projectId, attributeDisplayFormUris) { | ||
if (attributeDisplayFormUris.length === 0) { | ||
return Promise.resolve({}); | ||
} | ||
return this.md.getObjects(projectId, attributeDisplayFormUris).then(function (displayForms) { | ||
return md.getObjects(projectId, attributeDisplayFormUris).then(function (displayForms) { | ||
var attributeUris = getAttributeUris(displayForms); | ||
return _this.md.getObjects(projectId, attributeUris).then(function (attributes) { | ||
return md.getObjects(projectId, attributeUris).then(function (attributes) { | ||
return createAttributesMap(displayForms, attributes); | ||
@@ -37,4 +48,2 @@ }); | ||
}; | ||
return AttributesMapLoaderModule; | ||
}()); | ||
exports.AttributesMapLoaderModule = AttributesMapLoaderModule; | ||
} |
@@ -1,22 +0,38 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var lodash_1 = require("lodash"); | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.sortDefinitions = sortDefinitions; | ||
var _lodash = require('lodash'); | ||
var IDENTIFIER_REGEX = /{\S+}/g; | ||
function getDependencies(_a) { | ||
var metricDefinition = _a.metricDefinition; | ||
return (metricDefinition.expression.match(IDENTIFIER_REGEX) || []) | ||
.map(function (s) { return s.substring(1, s.length - 1); }); | ||
function getDependencies(_ref) { | ||
var metricDefinition = _ref.metricDefinition; | ||
return (metricDefinition.expression.match(IDENTIFIER_REGEX) || []).map(function (s) { | ||
return s.substring(1, s.length - 1); | ||
}); | ||
} | ||
function getIdentifier(_a) { | ||
var metricDefinition = _a.metricDefinition; | ||
function getIdentifier(_ref2) { | ||
var metricDefinition = _ref2.metricDefinition; | ||
return metricDefinition.identifier; | ||
} | ||
function resolvedDependencies(resolved, _a) { | ||
var dependencies = _a.dependencies; | ||
var identifiers = lodash_1.map(resolved, 'identifier'); | ||
return lodash_1.difference(dependencies, identifiers).length === 0; | ||
function resolvedDependencies(resolved, _ref3) { | ||
var dependencies = _ref3.dependencies; | ||
var identifiers = (0, _lodash.map)(resolved, 'identifier'); | ||
return (0, _lodash.difference)(dependencies, identifiers).length === 0; | ||
} | ||
function scan(resolved, unresolved) { | ||
for (var i = 0; i < unresolved.length; i += 1) { | ||
var tested = unresolved[i]; | ||
if (resolvedDependencies(resolved, tested)) { | ||
@@ -29,8 +45,11 @@ resolved.push(tested); | ||
} | ||
function sort(unresolved) { | ||
var resolved = []; | ||
var lastLength; | ||
var lastLength = void 0; | ||
while (unresolved.length > 0) { | ||
lastLength = unresolved.length; | ||
scan(resolved, unresolved); | ||
if (unresolved.length === lastLength) { | ||
@@ -40,12 +59,16 @@ throw new Error('Metric defintions cannot be sorted due to missing dependencies.'); | ||
} | ||
return resolved; | ||
} | ||
function sortDefinitions(definitions) { | ||
var indexed = definitions.map(function (definition) { return ({ | ||
definition: definition, | ||
identifier: getIdentifier(definition), | ||
dependencies: getDependencies(definition) | ||
}); }); | ||
return lodash_1.map(sort(indexed), 'definition'); | ||
} | ||
exports.sortDefinitions = sortDefinitions; | ||
var indexed = definitions.map(function (definition) { | ||
return { | ||
definition: definition, | ||
identifier: getIdentifier(definition), | ||
dependencies: getDependencies(definition) | ||
}; | ||
}); | ||
return (0, _lodash.map)(sort(indexed), 'definition'); | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.delay = delay; | ||
/** | ||
@@ -11,5 +15,6 @@ * Return promise that will resolve after `ms` miliseconds | ||
return new Promise(function (resolve) { | ||
setTimeout(function () { return resolve(); }, ms); | ||
setTimeout(function () { | ||
return resolve(); | ||
}, ms); | ||
}); | ||
} | ||
exports.delay = delay; | ||
} |
@@ -1,22 +0,56 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var invariant = require("invariant"); | ||
var lodash_1 = require("lodash"); | ||
var Rules = /** @class */ (function () { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
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"); } }; }(); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _invariant = require('invariant'); | ||
var _invariant2 = _interopRequireDefault(_invariant); | ||
var _lodash = require('lodash'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var Rules = function () { | ||
function Rules() { | ||
_classCallCheck(this, Rules); | ||
this.rules = []; | ||
} | ||
Rules.prototype.addRule = function (tests, callback) { | ||
this.rules.push([tests, callback]); | ||
}; | ||
Rules.prototype.match = function (subject, params) { | ||
var _a = lodash_1.find(this.rules, function (_a) { | ||
var tests = _a[0]; | ||
return lodash_1.every(tests, function (test) { return test(subject, params); }); | ||
}), callback = _a[1]; | ||
invariant(callback, 'Callback not found :-('); | ||
return callback; | ||
}; | ||
_createClass(Rules, [{ | ||
key: 'addRule', | ||
value: function addRule(tests, callback) { | ||
this.rules.push([tests, callback]); | ||
} | ||
}, { | ||
key: 'match', | ||
value: function match(subject, params) { | ||
var _find = (0, _lodash.find)(this.rules, function (_ref) { | ||
var _ref2 = _slicedToArray(_ref, 1), | ||
tests = _ref2[0]; | ||
return (0, _lodash.every)(tests, function (test) { | ||
return test(subject, params); | ||
}); | ||
}), | ||
_find2 = _slicedToArray(_find, 2), | ||
callback = _find2[1]; | ||
(0, _invariant2.default)(callback, 'Callback not found :-('); | ||
return callback; | ||
} | ||
}]); | ||
return Rules; | ||
}()); | ||
exports.Rules = Rules; | ||
}(); | ||
exports.default = Rules; |
@@ -1,23 +0,41 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var lodash_1 = require("lodash"); | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.getBuckets = getBuckets; | ||
exports.isAttributeMeasureFilter = isAttributeMeasureFilter; | ||
exports.getAttributes = getAttributes; | ||
exports.getDefinition = getDefinition; | ||
exports.getMeasures = getMeasures; | ||
exports.getMeasureFilters = getMeasureFilters; | ||
exports.getMeasureAttributeFilters = getMeasureAttributeFilters; | ||
exports.getAttributesDisplayForms = getAttributesDisplayForms; | ||
var _lodash = require('lodash'); | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
var BUCKETS = 'buckets'; | ||
function getBuckets(mdObj) { | ||
return lodash_1.get(mdObj, BUCKETS, []); | ||
return (0, _lodash.get)(mdObj, BUCKETS, []); | ||
} | ||
exports.getBuckets = getBuckets; | ||
function isAttribute(bucketItem) { | ||
return lodash_1.get(bucketItem, 'visualizationAttribute') !== undefined; | ||
return (0, _lodash.get)(bucketItem, 'visualizationAttribute') !== undefined; | ||
} | ||
function isAttributeMeasureFilter(measureFilter) { | ||
return (lodash_1.get(measureFilter, 'positiveAttributeFilter') || lodash_1.get(measureFilter, 'negativeAttributeFilter')) !== undefined; | ||
return ((0, _lodash.get)(measureFilter, 'positiveAttributeFilter') || (0, _lodash.get)(measureFilter, 'negativeAttributeFilter')) !== undefined; | ||
} | ||
exports.isAttributeMeasureFilter = isAttributeMeasureFilter; | ||
function isMeasure(bucketItem) { | ||
return lodash_1.get(bucketItem, 'measure') !== undefined; | ||
return (0, _lodash.get)(bucketItem, 'measure') !== undefined; | ||
} | ||
function getAttributesInBucket(bucket) { | ||
return lodash_1.get(bucket, 'items').reduce(function (list, bucketItem) { | ||
return (0, _lodash.get)(bucket, 'items').reduce(function (list, bucketItem) { | ||
if (isAttribute(bucketItem)) { | ||
list.push(lodash_1.get(bucketItem, 'visualizationAttribute')); | ||
list.push((0, _lodash.get)(bucketItem, 'visualizationAttribute')); | ||
} | ||
@@ -27,2 +45,3 @@ return list; | ||
} | ||
function getAttributes(mdObject) { | ||
@@ -34,15 +53,17 @@ var buckets = getBuckets(mdObject); | ||
} | ||
exports.getAttributes = getAttributes; | ||
function getMeasuresInBucket(bucket) { | ||
return lodash_1.get(bucket, 'items').reduce(function (list, bucketItem) { | ||
return (0, _lodash.get)(bucket, 'items').reduce(function (list, bucketItem) { | ||
if (isMeasure(bucketItem)) { | ||
list.push(lodash_1.get(bucketItem, 'measure')); | ||
list.push((0, _lodash.get)(bucketItem, 'measure')); | ||
} | ||
return list; | ||
}, []); | ||
} | ||
function getDefinition(measure) { | ||
return lodash_1.get(measure, ['definition', 'measureDefinition'], {}); | ||
return (0, _lodash.get)(measure, ['definition', 'measureDefinition'], {}); | ||
} | ||
exports.getDefinition = getDefinition; | ||
function getMeasures(mdObject) { | ||
@@ -54,11 +75,11 @@ var buckets = getBuckets(mdObject); | ||
} | ||
exports.getMeasures = getMeasures; | ||
function getMeasureFilters(measure) { | ||
return lodash_1.get(getDefinition(measure), 'filters', []); | ||
return (0, _lodash.get)(getDefinition(measure), 'filters', []); | ||
} | ||
exports.getMeasureFilters = getMeasureFilters; | ||
function getMeasureAttributeFilters(measure) { | ||
return getMeasureFilters(measure).filter(isAttributeMeasureFilter); | ||
} | ||
exports.getMeasureAttributeFilters = getMeasureAttributeFilters; | ||
function getAttributeFilters(mdObject) { | ||
@@ -69,12 +90,14 @@ return getMeasures(mdObject).reduce(function (filters, measure) { | ||
} | ||
function getAttributeFilterDisplayForm(measureFilter) { | ||
return lodash_1.get(measureFilter, ['positiveAttributeFilter', 'displayForm', 'uri']) || | ||
lodash_1.get(measureFilter, ['negativeAttributeFilter', 'displayForm', 'uri']); | ||
return (0, _lodash.get)(measureFilter, ['positiveAttributeFilter', 'displayForm', 'uri']) || (0, _lodash.get)(measureFilter, ['negativeAttributeFilter', 'displayForm', 'uri']); | ||
} | ||
function getAttributesDisplayForms(mdObject) { | ||
var attributesDfs = getAttributes(mdObject).map(function (attribute) { return lodash_1.get(attribute, ['displayForm', 'uri']); }); | ||
var attributesDfs = getAttributes(mdObject).map(function (attribute) { | ||
return (0, _lodash.get)(attribute, ['displayForm', 'uri']); | ||
}); | ||
var attrMeasureFilters = getAttributeFilters(mdObject); | ||
var attrMeasureFiltersDfs = attrMeasureFilters.map(getAttributeFilterDisplayForm); | ||
return attrMeasureFiltersDfs.concat(attributesDfs); | ||
} | ||
exports.getAttributesDisplayForms = getAttributesDisplayForms; | ||
return [].concat(_toConsumableArray(attrMeasureFiltersDfs), _toConsumableArray(attributesDfs)); | ||
} |
493
lib/xhr.js
@@ -1,66 +0,31 @@ | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [0, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// Copyright (C) 2007-2013, GoodData(R) Corporation. All rights reserved. | ||
var lodash_1 = require("lodash"); | ||
var util_1 = require("./util"); | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.originPackageHeaders = exports.parseJSON = undefined; | ||
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; }; // Copyright (C) 2007-2013, GoodData(R) Corporation. All rights reserved. | ||
exports.handlePolling = handlePolling; | ||
exports.createModule = createModule; | ||
var _lodash = require('lodash'); | ||
var _util = require('./util'); | ||
var _fetch = require('./utils/fetch'); | ||
var _fetch2 = _interopRequireDefault(_fetch); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
* Ajax wrapper around GDC authentication mechanisms, SST and TT token handling and polling. | ||
* Inteface is same as original jQuery.ajax. | ||
* | ||
* If token is expired, current request is "paused", token is refreshed and request is retried and result. | ||
* is transparently returned to original call. | ||
* | ||
* Additionally polling is handled. Only final result of polling returned. | ||
@@ -70,13 +35,17 @@ * @module xhr | ||
*/ | ||
var DEFAULT_POLL_DELAY = 1000; | ||
function simulateBeforeSend(url, settings) { | ||
function simulateBeforeSend(settings, url) { | ||
var xhrMockInBeforeSend = { | ||
setRequestHeader: function (key, value) { | ||
lodash_1.set(settings, ['headers', key], value); | ||
setRequestHeader: function setRequestHeader(key, value) { | ||
(0, _lodash.set)(settings, ['headers', key], value); | ||
} | ||
}; | ||
if (lodash_1.isFunction(settings.beforeSend)) { | ||
if ((0, _lodash.isFunction)(settings.beforeSend)) { | ||
settings.beforeSend(xhrMockInBeforeSend, url); | ||
} | ||
} | ||
function enrichSettingWithCustomDomain(originalUrl, originalSettings, domain) { | ||
@@ -93,6 +62,39 @@ var url = originalUrl; | ||
} | ||
return { url: url, settings: settings }; | ||
} | ||
function isLoginRequest(url) { | ||
return url.indexOf('/gdc/account/login') !== -1; | ||
} | ||
/** | ||
* @param {Response} response | ||
* @return {Promise} promise which resolves to result JSON () | ||
*/ | ||
var parseJSON = exports.parseJSON = function parseJSON(response) { | ||
return response.json(); | ||
}; | ||
/** | ||
* @param {Response} response see https://developer.mozilla.org/en-US/docs/Web/API/Response | ||
* @return {Response} or {Error} | ||
*/ | ||
var checkStatus = function checkStatus(response) { | ||
if (response.status >= 200 && response.status < 399) { | ||
return response; | ||
} | ||
if (response instanceof Error && (0, _lodash.has)(response, 'response')) { | ||
throw response; | ||
} | ||
var error = new Error(response.statusText); | ||
error.response = response; | ||
throw error; | ||
}; | ||
function handlePolling(url, settings, sendRequest) { | ||
var pollingDelay = lodash_1.result(settings, 'pollDelay'); | ||
var pollingDelay = (0, _lodash.result)(settings, 'pollDelay'); | ||
return new Promise(function (resolve, reject) { | ||
@@ -104,5 +106,6 @@ setTimeout(function () { | ||
} | ||
exports.handlePolling = handlePolling; | ||
function originPackageHeaders(_a) { | ||
var name = _a.name, version = _a.version; | ||
var originPackageHeaders = exports.originPackageHeaders = function originPackageHeaders(_ref) { | ||
var name = _ref.name, | ||
version = _ref.version; | ||
return { | ||
@@ -112,67 +115,31 @@ 'X-GDC-JS-PKG': name, | ||
}; | ||
} | ||
exports.originPackageHeaders = originPackageHeaders; | ||
var ApiError = /** @class */ (function (_super) { | ||
__extends(ApiError, _super); | ||
function ApiError(message, cause) { | ||
var _this = _super.call(this, message) || this; | ||
_this.cause = cause; | ||
return _this; | ||
} | ||
return ApiError; | ||
}(Error)); | ||
exports.ApiError = ApiError; | ||
var ApiResponseError = /** @class */ (function (_super) { | ||
__extends(ApiResponseError, _super); | ||
function ApiResponseError(message, response, responseBody) { | ||
var _this = _super.call(this, message, null) || this; | ||
_this.response = response; | ||
_this.responseBody = responseBody; | ||
return _this; | ||
} | ||
return ApiResponseError; | ||
}(ApiError)); | ||
exports.ApiResponseError = ApiResponseError; | ||
var ApiNetworkError = /** @class */ (function (_super) { | ||
__extends(ApiNetworkError, _super); | ||
function ApiNetworkError() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return ApiNetworkError; | ||
}(ApiError)); | ||
exports.ApiNetworkError = ApiNetworkError; | ||
var ApiResponse = /** @class */ (function () { | ||
function ApiResponse(response, responseBody) { | ||
this.response = response; | ||
this.responseBody = responseBody; | ||
} | ||
Object.defineProperty(ApiResponse.prototype, "data", { | ||
get: function () { | ||
try { | ||
return JSON.parse(this.responseBody); | ||
} | ||
catch (error) { | ||
return this.responseBody; | ||
} | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
ApiResponse.prototype.getData = function () { | ||
try { | ||
return JSON.parse(this.responseBody); | ||
}; | ||
function createModule(configStorage) { | ||
var tokenRequest = void 0; // TODO make app-wide persitent (ie. extract outside of the SDK) | ||
(0, _lodash.defaults)(configStorage, { xhrSettings: {} }); | ||
function createRequestSettings(customSettings) { | ||
var settings = (0, _lodash.merge)({ | ||
headers: _extends({ | ||
Accept: 'application/json; charset=utf-8', | ||
'Content-Type': 'application/json' | ||
}, originPackageHeaders(configStorage.originPackage || _util.thisPackage)) | ||
}, configStorage.xhrSettings, customSettings); | ||
settings.pollDelay = settings.pollDelay !== undefined ? settings.pollDelay : DEFAULT_POLL_DELAY; | ||
// TODO jquery compat - add to warnings | ||
settings.body = settings.data ? settings.data : settings.body; | ||
settings.mode = 'same-origin'; | ||
settings.credentials = 'same-origin'; | ||
if ((0, _lodash.isPlainObject)(settings.body)) { | ||
settings.body = JSON.stringify(settings.body); | ||
} | ||
catch (error) { | ||
return this.responseBody; | ||
} | ||
}; | ||
return ApiResponse; | ||
}()); | ||
exports.ApiResponse = ApiResponse; | ||
var XhrModule = /** @class */ (function () { | ||
function XhrModule(fetch, configStorage) { | ||
this.fetch = fetch; | ||
this.configStorage = configStorage; | ||
lodash_1.defaults(configStorage, { xhrSettings: {} }); | ||
return settings; | ||
} | ||
/** | ||
@@ -185,152 +152,146 @@ * Back compatible method for setting common XHR settings | ||
*/ | ||
XhrModule.prototype.ajaxSetup = function (settings) { | ||
Object.assign(this.configStorage.xhrSettings, settings); | ||
}; | ||
XhrModule.prototype.ajax = function (originalUrl, customSettings) { | ||
if (customSettings === void 0) { customSettings = {}; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var firstSettings, _a, url, settings, response, e_1, responseBody, finalUrl, finalSettings; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
firstSettings = this.createRequestSettings(customSettings); | ||
_a = enrichSettingWithCustomDomain(originalUrl, firstSettings, this.configStorage.domain), url = _a.url, settings = _a.settings; | ||
simulateBeforeSend(url, settings); // mutates `settings` param | ||
if (this.tokenRequest) { | ||
return [2 /*return*/, this.continueAfterTokenRequest(url, settings)]; | ||
} | ||
_b.label = 1; | ||
case 1: | ||
_b.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, this.fetch(url, settings)]; | ||
case 2: | ||
// TODO: We should clean up the settings at this point to be pure `RequestInit` object | ||
response = _b.sent(); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
e_1 = _b.sent(); | ||
throw new ApiNetworkError(e_1.message, e_1); // TODO is it really necessary? couldn't we throw just Error? | ||
case 4: return [4 /*yield*/, response.text()]; | ||
case 5: | ||
responseBody = _b.sent(); | ||
if (response.status === 401) { | ||
// if 401 is in login-request, it means wrong user/password (we wont continue) | ||
if (url.indexOf('/gdc/account/login') !== -1) { | ||
throw new ApiResponseError('Unauthorized', response, responseBody); | ||
} | ||
return [2 /*return*/, this.handleUnauthorized(url, settings)]; | ||
} | ||
// Note: Fetch does redirects automagically for 301 (and maybe more .. TODO when?) | ||
// see https://fetch.spec.whatwg.org/#ref-for-concept-request%E2%91%A3%E2%91%A2 | ||
if (response.status === 202 && !settings.dontPollOnResult) { | ||
finalUrl = response.url || url; | ||
finalSettings = settings; | ||
// if the response is 202 and Location header is not empty, let's poll on the new Location | ||
if (response.headers.has('Location')) { | ||
finalUrl = response.headers.get('Location'); | ||
} | ||
finalSettings.method = 'GET'; | ||
delete finalSettings.data; | ||
delete finalSettings.body; | ||
return [2 /*return*/, handlePolling(finalUrl, finalSettings, this.ajax.bind(this))]; | ||
} | ||
if (response.status >= 200 && response.status <= 399) { | ||
return [2 /*return*/, new ApiResponse(response, responseBody)]; | ||
} | ||
// throws on 400, 500, etc. | ||
throw new ApiResponseError(response.statusText, response, responseBody); | ||
function ajaxSetup(settings) { | ||
Object.assign(configStorage.xhrSettings, settings); | ||
} | ||
function continueAfterTokenRequest(url, settings) { | ||
return tokenRequest.then(function (response) { | ||
if (!response.ok) { | ||
var err = new Error('Unauthorized'); | ||
err.response = response; | ||
throw err; | ||
} | ||
tokenRequest = null; | ||
return ajax(url, settings); // eslint-disable-line no-use-before-define | ||
}, function (reason) { | ||
tokenRequest = null; | ||
return reason; | ||
}); | ||
} | ||
function handleUnauthorized(originalUrl, originalSettings) { | ||
if (!tokenRequest) { | ||
// Create only single token request for any number of waiting request. | ||
// If token request exist, just listen for it's end. | ||
var _enrichSettingWithCus = enrichSettingWithCustomDomain('/gdc/account/token', createRequestSettings({}), configStorage.domain), | ||
url = _enrichSettingWithCus.url, | ||
settings = _enrichSettingWithCus.settings; | ||
tokenRequest = (0, _fetch2.default)(url, settings).then(function (response) { | ||
// tokenRequest = null; | ||
// TODO jquery compat - allow to attach unauthorized callback and call it if attached | ||
// if ((xhrObj.status === 401) && (isFunction(req.unauthorized))) { | ||
// req.unauthorized(xhrObj, textStatus, err, deferred); | ||
// return; | ||
// } | ||
// unauthorized handler is not defined or not http 401 | ||
// unauthorized when retrieving token -> not logged | ||
if (response.status === 401) { | ||
var err = new Error('Unauthorized'); | ||
err.response = response; | ||
throw err; | ||
} | ||
return response; | ||
}); | ||
}); | ||
}; | ||
} | ||
return continueAfterTokenRequest(originalUrl, originalSettings); | ||
} | ||
function ajax(originalUrl) { | ||
var customSettings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
// TODO refactor to: getRequestParams(originalUrl, customSettings); | ||
var firstSettings = createRequestSettings(customSettings); | ||
var _enrichSettingWithCus2 = enrichSettingWithCustomDomain(originalUrl, firstSettings, configStorage.domain), | ||
url = _enrichSettingWithCus2.url, | ||
settings = _enrichSettingWithCus2.settings; | ||
simulateBeforeSend(settings, url); // mutates `settings` param | ||
if (tokenRequest) { | ||
return continueAfterTokenRequest(url, settings); | ||
} | ||
return (0, _fetch2.default)(url, settings).then(function (response) { | ||
// If response.status id 401 and it was a login request there is no need | ||
// to cycle back for token - login does not need token and this meant you | ||
// are not authorized | ||
if (response.status === 401) { | ||
if (isLoginRequest(url)) { | ||
var err = new Error('Unauthorized'); | ||
err.response = response; | ||
throw err; | ||
} | ||
return handleUnauthorized(url, settings); | ||
} | ||
if (response.status === 202 && !settings.dontPollOnResult) { | ||
// poll on new provided url, fallback to the original one | ||
// (for example validElements returns 303 first with new url which may then return 202 to poll on) | ||
var finalUrl = response.url || url; | ||
var finalSettings = settings; | ||
// if the response is 202 and Location header is not empty, let's poll on the new Location | ||
if (response.headers.has('Location')) { | ||
finalUrl = response.headers.get('Location'); | ||
} | ||
finalSettings.method = 'GET'; | ||
delete finalSettings.data; | ||
delete finalSettings.body; | ||
return handlePolling(finalUrl, finalSettings, ajax); | ||
} | ||
return response; | ||
}).then(checkStatus); | ||
} | ||
/** | ||
* Wrapper for xhr.ajax method GET | ||
* @method get | ||
*/ | ||
XhrModule.prototype.get = function (url, settings) { | ||
return this.ajax(url, lodash_1.merge({ method: 'GET' }, settings)); | ||
var get = function get(url, settings) { | ||
var opts = (0, _lodash.merge)({ method: 'GET' }, settings); | ||
return ajax(url, opts).then(parseJSON); | ||
}; | ||
function xhrMethod(method) { | ||
return function methodFn(url, settings) { | ||
var opts = (0, _lodash.merge)({ method: method }, settings); | ||
return ajax(url, opts); | ||
}; | ||
} | ||
/** | ||
* Wrapper for xhr.ajax method POST | ||
* @method post | ||
*/ | ||
XhrModule.prototype.post = function (url, settings) { | ||
return this.ajax(url, lodash_1.merge({ method: 'POST' }, settings)); | ||
}; | ||
var post = xhrMethod('POST'); | ||
/** | ||
* Wrapper for xhr.ajax method PUT | ||
* @method put | ||
*/ | ||
XhrModule.prototype.put = function (url, settings) { | ||
return this.ajax(url, lodash_1.merge({ method: 'PUT' }, settings)); | ||
}; | ||
var put = xhrMethod('PUT'); | ||
/** | ||
* Wrapper for xhr.ajax method DELETE | ||
* @method delete | ||
*/ | ||
XhrModule.prototype.del = function (url, settings) { | ||
return this.ajax(url, lodash_1.merge({ method: 'DELETE' }, settings)); | ||
var del = xhrMethod('DELETE'); | ||
return { | ||
get: get, | ||
post: post, | ||
put: put, | ||
del: del, | ||
ajax: ajax, | ||
ajaxSetup: ajaxSetup, | ||
parseJSON: parseJSON | ||
}; | ||
XhrModule.prototype.createRequestSettings = function (customSettings) { | ||
var settings = lodash_1.merge({ | ||
headers: __assign({ 'Accept': 'application/json; charset=utf-8', 'Content-Type': 'application/json' }, originPackageHeaders(this.configStorage.originPackage || util_1.thisPackage)) | ||
}, this.configStorage.xhrSettings, customSettings); | ||
settings.pollDelay = (settings.pollDelay !== undefined) ? settings.pollDelay : DEFAULT_POLL_DELAY; | ||
// TODO jquery compat - add to warnings | ||
settings.body = (settings.data) ? settings.data : settings.body; | ||
settings.mode = 'same-origin'; | ||
settings.credentials = 'same-origin'; | ||
if (lodash_1.isPlainObject(settings.body)) { | ||
settings.body = JSON.stringify(settings.body); | ||
} | ||
return settings; | ||
}; | ||
XhrModule.prototype.continueAfterTokenRequest = function (url, settings) { | ||
var _this = this; | ||
return this.tokenRequest.then(function (response) { return __awaiter(_this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
if (!response.ok) { | ||
throw new ApiResponseError('Unauthorized', response, null); | ||
} | ||
this.tokenRequest = null; | ||
return [2 /*return*/, this.ajax(url, settings)]; // eslint-disable-line no-use-before-define | ||
}); | ||
}); }, function (reason) { | ||
_this.tokenRequest = null; | ||
return reason; | ||
}); | ||
}; | ||
XhrModule.prototype.handleUnauthorized = function (originalUrl, originalSettings) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, url, settings, response, responseBody; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
// Create only single token request for any number of waiting request. | ||
// If token request exist, just listen for it's end. | ||
if (this.tokenRequest) { | ||
return [2 /*return*/, this.continueAfterTokenRequest(originalUrl, originalSettings)]; | ||
} | ||
_a = enrichSettingWithCustomDomain('/gdc/account/token', this.createRequestSettings({}), this.configStorage.domain), url = _a.url, settings = _a.settings; | ||
this.tokenRequest = this.fetch(url, settings); | ||
return [4 /*yield*/, this.tokenRequest]; | ||
case 1: | ||
response = _b.sent(); | ||
return [4 /*yield*/, response.text()]; | ||
case 2: | ||
responseBody = _b.sent(); | ||
this.tokenRequest = null; | ||
// TODO jquery compat - allow to attach unauthorized callback and call it if attached | ||
// if ((xhrObj.status === 401) && (isFunction(req.unauthorized))) { | ||
// req.unauthorized(xhrObj, textStatus, err, deferred); | ||
// return; | ||
// } | ||
// unauthorized handler is not defined or not http 401 | ||
// unauthorized when retrieving token -> not logged | ||
if (response.status === 401) { | ||
throw new ApiResponseError('Unauthorized', response, responseBody); | ||
} | ||
return [2 /*return*/, new ApiResponse(response, responseBody)]; | ||
} | ||
}); | ||
}); | ||
}; | ||
return XhrModule; | ||
}()); | ||
exports.XhrModule = XhrModule; | ||
} |
{ | ||
"name": "gooddata", | ||
"version": "6.0.0-vaclavbohac-typescript-2018-04-04T10-40-44-156Z", | ||
"version": "6.0.0-zdenek.vidensky-one-3017-2018-04-04T14-04-24-329Z", | ||
"author": "GoodData", | ||
@@ -9,3 +9,3 @@ "description": "GoodData JavaScript SDK", | ||
"browser": "lib/gooddata-browser.js", | ||
"typings": "lib/gooddata-browser.d.ts", | ||
"typings": "./index.d.ts", | ||
"files": [ | ||
@@ -15,21 +15,15 @@ "dist", | ||
"src", | ||
"LICENSE" | ||
"LICENSE", | ||
"index.d.ts" | ||
], | ||
"config": { | ||
"tslint": "'./{src,test}/**/*.ts'" | ||
}, | ||
"scripts": { | ||
"dev": "tsc --watch", | ||
"build": "yarn run build:lib && yarn run build:dist", | ||
"build:lib": "rm -rf lib && tsc", | ||
"build": "npm run build:lib && npm run build:dist", | ||
"build:lib": "rm -rf lib && babel src --out-dir lib", | ||
"build:dist": "rm -rf dist && grunt dist", | ||
"prepublishOnly": "yarn run build", | ||
"prepublish": "npm run build", | ||
"test": "jest --watch", | ||
"test-single-run": "jest", | ||
"test-ci": "JEST_JUNIT_OUTPUT=./ci/results/test-results.xml jest --config jest.ci.json", | ||
"run-tslint": "tslint -p tsconfig.base.json", | ||
"tslint": "yarn run-tslint -t verbose $npm_package_config_tslint", | ||
"tslint-ci": "mkdir -p ./ci/results && yarn run-tslint -t checkstyle -o ./ci/results/tslint-results.xml $npm_package_config_tslint", | ||
"validate": "tsc -p tsconfig.base.json --noEmit && yarn tslint", | ||
"validate-ci": "tsc -p tsconfig.base.json --noEmit && yarn tslint-ci" | ||
"validate": "eslint --ext .js,.jsx src test", | ||
"validate:ci": "yarn validate -f checkstyle -o ci/results/eslint-results.xml", | ||
"test:typings": "tsc --noEmit index.d.ts", | ||
"test:ci": "JEST_JUNIT_OUTPUT=./ci/results/test-results.xml jest --config jest.ci.json" | ||
}, | ||
@@ -41,34 +35,17 @@ "repository": { | ||
"jest": { | ||
"setupTestFrameworkScriptFile": "<rootDir>/jest.setup.js", | ||
"transform": { | ||
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js" | ||
}, | ||
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(tsx?)$", | ||
"collectCoverageFrom": [ | ||
"src/**/*.{ts,tsx}", | ||
"!**/*.d.ts" | ||
], | ||
"collectCoverage": false, | ||
"coverageReporters": [ | ||
"html" | ||
], | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"tsx", | ||
"js" | ||
] | ||
".(js|jsx)": "babel-jest" | ||
} | ||
}, | ||
"devDependencies": { | ||
"@types/es6-promise": "3.3.0", | ||
"@types/fast-levenshtein": "0.0.1", | ||
"@types/fetch-mock": "5.*", | ||
"@types/invariant": "2.2.29", | ||
"@types/isomorphic-fetch": "0.0.34", | ||
"@types/jest": "22.2.0", | ||
"@types/json-stable-stringify": "1.0.32", | ||
"@types/lodash": "4.14.105", | ||
"@types/md5": "2.1.32", | ||
"@types/node-fetch": "1.6.7", | ||
"@types/qs": "6.5.1", | ||
"@gooddata/typings": "2.0.0-alpha0", | ||
"async": "2.1.5", | ||
"babel-cli": "6.23.0", | ||
"babel-core": "6.23.1", | ||
"babel-jest": "22.2.2", | ||
"babel-loader": "6.3.2", | ||
"babel-plugin-lodash": "3.2.11", | ||
"babel-preset-es2015": "6.22.0", | ||
"babel-preset-stage-0": "6.22.0", | ||
"babel-register": "6.23.0", | ||
"eslint-config-gooddata": "0.0.18", | ||
@@ -89,3 +66,3 @@ "exports-loader": "0.6.3", | ||
"istanbul-instrumenter-loader": "0.2.0", | ||
"jest": "21.2.1", | ||
"jest": "21.0.0", | ||
"jest-junit": "3.0.0", | ||
@@ -95,6 +72,3 @@ "js-object-pretty-print": "0.2.0", | ||
"lodash-webpack-plugin": "0.11.0", | ||
"ts-jest": "21.2.3", | ||
"ts-loader": "3.2.0", | ||
"tslint-config-gooddata": "0.0.8", | ||
"typescript": "2.8.1", | ||
"typescript": "2.7.2", | ||
"webpack": "1.13.2", | ||
@@ -104,3 +78,2 @@ "webpack-dev-server": "1.16.1" | ||
"dependencies": { | ||
"@gooddata/typings": "2.0.0-alpha0", | ||
"es6-promise": "3.0.2", | ||
@@ -110,9 +83,6 @@ "fetch-cookie": "0.4.0", | ||
"isomorphic-fetch": "2.2.1", | ||
"json-stable-stringify": "1.0.1", | ||
"lodash": "4.17.4", | ||
"md5": "2.2.1", | ||
"node-fetch": "2.1.1", | ||
"qs": "6.5.1", | ||
"rxjs": "^5.5.6" | ||
"qs": "6.5.1" | ||
} | ||
} |
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
7
33
1189499
66
27725
6
- Removed@gooddata/typings@2.0.0-alpha0
- Removedjson-stable-stringify@1.0.1
- Removednode-fetch@2.1.1
- Removedrxjs@^5.5.6
- Removed@gooddata/typings@2.0.0-alpha0(transitive)
- Removedjson-stable-stringify@1.0.1(transitive)
- Removedjsonify@0.0.1(transitive)
- Removednode-fetch@2.1.1(transitive)
- Removedrxjs@5.5.12(transitive)
- Removedsymbol-observable@1.0.1(transitive)