New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

supergloo

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

supergloo - npm Package Compare versions

Comparing version 0.9.0 to 0.10.0

800

dist/supergloo.es.js

@@ -0,8 +1,6 @@

import es6Promise from 'es6-promise';
import falcorPathParser from 'falcor-path-syntax';
import { reject } from 'bluebird';
import * as Promise from 'bluebird';
import map from 'lodash/map';
import concat from 'lodash/concat';
import filter from 'lodash/filter';
import keys from 'lodash/keys';
import map from 'lodash/map';
import get from 'lodash/get';
import isArray from 'lodash/isArray';

@@ -14,12 +12,11 @@ import isEmpty from 'lodash/isEmpty';

import uniq from 'lodash/uniq';
import filter from 'lodash/filter';
import isNil from 'lodash/isNil';
import keys from 'lodash/keys';
import camelCase from 'lodash/camelCase';
import get from 'lodash/get';
import head from 'lodash/head';
import isError from 'lodash/isError';
import isFunction from 'lodash/isFunction';
import isNil from 'lodash/isNil';
import some from 'lodash/some';
var DEFAULT_FROM_INDEX = 0;
var DEFAULT_TO_INDEX = 19;
/*

@@ -40,8 +37,2 @@ * Default entity properties

var review = ['id', 'rating'];
var tourTipView = ['id', 'state'];
var name = 'comment';

@@ -55,2 +46,12 @@ var pluralName = 'comments';

var DEFAULT_FROM_INDEX = 0;
var DEFAULT_TO_INDEX = 19;
function buildPaging(options) {
return {
from: get(options, 'paging.from') || DEFAULT_FROM_INDEX,
to: get(options, 'paging.to') || DEFAULT_TO_INDEX
};
}
function buildProperties$1(defaults, options) {

@@ -74,6 +75,10 @@ var properties = concat([], options.properties || defaults);

function entityToFilename(entity) {
return kebabCase(entity.name);
function entityNameToFilename(name) {
return kebabCase(name);
}
function entityToFalcorListLeaf(entity) {
return snakeCase(entity.name) + '_list';
}
function entityToFalcorRootLeaf(entity) {

@@ -83,3 +88,60 @@ return snakeCase(entity.pluralName);

function getOne$2(entity) {
var name$2 = 'post';
var pluralName$2 = 'posts';
var defaultProperties = ['id', 'body'];
var post = Object.freeze({
name: name$2,
pluralName: pluralName$2,
defaultProperties: defaultProperties
});
var name$1 = 'feedPost';
var pluralName$1 = 'feedPosts';
function getMany() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var _buildPaging = buildPaging(options),
from = _buildPaging.from,
to = _buildPaging.to;
var properties = buildProperties$1(defaultProperties, options);
var listLeaf = entityToFalcorListLeaf({ name: name$1 });
var paths = map(properties, function (property) {
var propertyPath = falcorPathParser(property);
var path = ['self', listLeaf, { from: from, to: to }, propertyPath];
return path;
});
return paths;
}
function extractMany() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var jsonGraph = arguments[1];
var listLeaf = entityToFalcorListLeaf({ name: name$1 });
var postList = jsonGraph.json.self[listLeaf];
var posts = map(postList, function (post) {
return post;
});
return posts;
}
var feedPost = Object.freeze({
name: name$1,
pluralName: pluralName$1,
defaultProperties: defaultProperties,
getMany: getMany,
extractMany: extractMany
});
function getOne$1(entity) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -90,18 +152,136 @@ var id = options.id;

if (isNil(id)) {
return new Error('options.id is required when getting one ' + entity.name);
}
if (isNil(entity.pluralName)) {
return new Error('The ' + entity.name + ' entity must export pluralName');
}
if (isNil(defaultProperties)) {
return new Error('The ' + entity.name + ' entity must export defaultProperties');
}
var properties = buildProperties$1(defaultProperties, options);
var rootLeaf = entityToFalcorRootLeaf(entity);
var getPaths = properties.map(function (property) {
var path = falcorPathParser(property);
return concat([rootLeaf, id], path);
var paths = properties.map(function (property) {
var propertyPath = falcorPathParser(property);
var path = concat([rootLeaf, id], propertyPath);
return path;
});
return getPaths;
return paths;
}
function update$1(entity) {
function extractOne(entity) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var jsonGraph = arguments[2];
var rootLeaf = entityToFalcorRootLeaf(entity);
var extractedEntity = jsonGraph.json[rootLeaf][options.id];
return extractedEntity;
}
function getMany$1(entity) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var defaultProperties = entity.defaultProperties;
if (isNil(defaultProperties)) {
return new Error('The ' + entity.name + ' entity must export defaultProperties');
}
if (isNil(entity.pluralName)) {
return new Error('The ' + entity.name + ' entity must export pluralName');
}
var _buildPaging = buildPaging(options),
from = _buildPaging.from,
to = _buildPaging.to;
var properties = buildProperties$1(defaultProperties, options);
var parentEntityName = void 0,
parentOption = void 0,
parentEntity = void 0;
if (!isNil(options.parent)) {
parentEntityName = keys(options.parent)[0];
parentOption = options.parent[parentEntityName];
parentEntity = entities[parentEntityName];
}
var basePath = void 0;
if (parentEntity) {
var rootLeaf = entityToFalcorRootLeaf(parentEntity);
var listLeaf = entityToFalcorListLeaf(entity);
basePath = [rootLeaf, parentOption.id, listLeaf];
} else {
var _rootLeaf = entityToFalcorRootLeaf(entity);
basePath = [_rootLeaf];
}
var paths = properties.map(function (property) {
var propertyPath = falcorPathParser(property);
var path = concat(basePath, { from: from, to: to }, propertyPath);
return path;
});
return paths;
}
function extractMany$1(entity) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var jsonGraph = arguments[2];
var parentEntityName = void 0,
parentOption = void 0,
parentEntity = void 0;
if (!isNil(options.parent)) {
parentEntityName = keys(options.parent)[0];
parentOption = options.parent[parentEntityName];
parentEntity = entities[parentEntityName];
}
var entityList = void 0;
if (parentEntity) {
var parentRootLeaf = entityToFalcorRootLeaf(parentEntity);
var entityListLeaf = entityToFalcorListLeaf(entity);
entityList = jsonGraph.json[parentRootLeaf][parentOption.id][entityListLeaf];
} else {
var rootLeaf = entityToFalcorRootLeaf(entity);
entityList = jsonGraph.json[rootLeaf];
}
var extractedEntities = map(entityList, function (entity) {
return entity;
});
return extractedEntities;
}
function update(entity) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var id = options.id;
if (isNil(entity.pluralName)) {
return new Error('The ' + entity.name + ' entity must export pluralName');
}
if (isNil(id)) {
return new Error('options.id is required when updating a tree review');
}
if (keys(options).length === 1) {
return new Error('options must include at least one property to update');
}
var properties = filter(keys(options), function (key) {

@@ -112,15 +292,33 @@ return key !== 'id';

var valuePaths = map(properties, function (property) {
var paths = map(properties, function (property) {
return { path: [rootLeaf, id, property], value: options[property] };
});
return valuePaths;
return paths;
}
function destroy$1(entity) {
function extractUpdate(entity) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var jsonGraph = arguments[2];
var rootLeaf = entityToFalcorRootLeaf(entity);
var updatedProperties = jsonGraph.json[rootLeaf][options.id];
return updatedProperties;
}
function destroy(entity) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var id = options.id;
if (isNil(entity.pluralName)) {
return new Error('The ' + entity.name + ' entity must export pluralName');
}
if (isNil(id)) {
return new Error('options.id is required when destroying one ' + entity.name);
}
var rootLeaf = entityToFalcorRootLeaf(entity);
var destroyPath = [rootLeaf, id, 'delete'];

@@ -131,10 +329,12 @@

var name$1 = 'moment';
var pluralName$1 = 'moments';
var name$3 = 'moment';
var pluralName$3 = 'moments';
var defaultProperties = ['id', 'description', 'title', 'user.name', 'cover_image_media.id', 'cover_image_media.src'];
var defaultProperties$1 = ['id', 'description', 'title', 'user.name', 'cover_image_media.id', 'cover_image_media.src'];
function getOne$1(options) {
var paths = getOne$2({ defaultProperties: defaultProperties, pluralName: pluralName$1 }, options);
function getOne$$1() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var paths = getOne$1({ defaultProperties: defaultProperties$1, pluralName: pluralName$3 }, options);
return paths;

@@ -144,28 +344,133 @@ }

var moment$1 = Object.freeze({
name: name$1,
pluralName: pluralName$1,
defaultProperties: defaultProperties,
getOne: getOne$1
name: name$3,
pluralName: pluralName$3,
defaultProperties: defaultProperties$1,
getOne: getOne$$1
});
var name$2 = 'review';
var pluralName$2 = 'reviews';
var name$5 = 'review';
var pluralName$5 = 'reviews';
var defaultProperties$1 = ['id', 'rating'];
var defaultProperties$2 = ['id', 'rating'];
var review$1 = Object.freeze({
name: name$2,
pluralName: pluralName$2,
defaultProperties: defaultProperties$1
name: name$5,
pluralName: pluralName$5,
defaultProperties: defaultProperties$2
});
var name$3 = 'tourTipView';
var pluralName$3 = 'tourTipViews';
var name$6 = 'tree';
var pluralName$6 = 'trees';
var defaultProperties$2 = ['id', 'state'];
var treeEntity = Object.freeze({
name: name$6,
pluralName: pluralName$6
});
/*
* This entity is temporary while we figure out how to handle "my" entities
* in a standard entity way. We expect to delete it once we have settled on a
* standard "my" approach.
*/
var name$4 = 'myTreeReview';
var pluralName$4 = 'myTreeReviews';
function getOne$2() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var tree = options.tree;
if (isNil(tree) || isNil(tree.id)) {
return new Error("options.tree.id is required when getting the current user's tree review");
}
var properties = buildProperties$1(defaultProperties$2, options);
var paths = properties.map(function (property) {
var rootLeaf = entityToFalcorRootLeaf(treeEntity);
var path = falcorPathParser(property);
return concat([rootLeaf, tree.id, 'my_review'], path);
});
return paths;
}
function extractOne$1() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var jsonGraph = arguments[1];
var tree = options.tree;
if (isNil(tree) || isNil(tree.id)) {
return new Error("options.tree.id is required when getting the current user's tree review");
}
var rootLeaf = entityToFalcorRootLeaf(treeEntity);
return jsonGraph.json[rootLeaf][tree.id].my_review;
}
var myTreeReview = Object.freeze({
name: name$4,
pluralName: pluralName$4,
defaultProperties: defaultProperties$2,
getOne: getOne$2,
extractOne: extractOne$1
});
var name$7 = 'timeline';
var pluralName$7 = 'timelines';
var timeline = Object.freeze({
name: name$7,
pluralName: pluralName$7
});
var name$8 = 'tourTipView';
var pluralName$8 = 'tourTipViews';
var defaultProperties$3 = ['id', 'state'];
function getMany$2() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var _buildPaging = buildPaging(options),
from = _buildPaging.from,
to = _buildPaging.to;
var properties = buildProperties$1(defaultProperties$3, options);
var listLeaf = entityToFalcorListLeaf({ name: name$8 });
var paths = map(properties, function (property) {
var propertyPath = falcorPathParser(property);
var path = ['self', listLeaf, { from: from, to: to }, propertyPath];
return path;
});
return paths;
}
function extractMany$2() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var jsonGraph = arguments[1];
var listLeaf = entityToFalcorListLeaf({ name: name$8 });
var viewList = jsonGraph.json.self[listLeaf];
var views = map(viewList, function (view) {
return view;
});
return views;
}
var tourTipView$1 = Object.freeze({
name: name$3,
pluralName: pluralName$3,
defaultProperties: defaultProperties$2
name: name$8,
pluralName: pluralName$8,
defaultProperties: defaultProperties$3,
getMany: getMany$2,
extractMany: extractMany$2
});

@@ -177,5 +482,10 @@

comment: comment,
feedPost: feedPost,
moment: moment$1,
myTreeReview: myTreeReview,
post: post,
review: review$1,
tourTipView: tourTipView$1
timeline: timeline,
tourTipView: tourTipView$1,
tree: treeEntity
});

@@ -189,2 +499,4 @@

es6Promise.polyfill();
var SuperGloo = function () {

@@ -198,3 +510,2 @@ function SuperGloo() {

// Check if any of our required properties are missing
if (some(requiredProperties, function (_) {

@@ -210,3 +521,3 @@ return isNil(get(config, _));

/*
* Generic interfaces
* Standard interfaces
*/

@@ -225,52 +536,57 @@

key: 'getMany',
value: function getMany(entity) {
value: function getMany$$1(entityName) {
var _falcor;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var getManyFunction = camelCase('getMany_' + entity);
var entity = entities[entityName];
if (!isFunction(this[getManyFunction])) {
return reject(new Error('Invalid entity: ' + entity + '. Please check the syntax and try again.'));
if (isNil(entity)) {
var filename = entityNameToFilename(entityName) + '.js';
return Promise.reject(new Error('The ' + entityName + ' entity is undefined. Ensure entities/' + filename + ' exists and is exported by entities/_catalog.js'));
}
return this[getManyFunction](options);
var paths = isFunction(entity.getMany) ? entity.getMany(options) : getMany$1(entity, options);
if (isError(paths)) {
return Promise.reject(paths);
}
return (_falcor = this.falcor).get.apply(_falcor, _toConsumableArray(paths)).then(function (jsonGraph) {
// TODO: How should we handle jsonGraph === undefined?
var extractedEntities = isFunction(entity.extractMany) ? entity.extractMany(options, jsonGraph) : extractMany$1(entity, options, jsonGraph);
return extractedEntities;
}).catch(function (response) {
var message = buildGetManyErrorMessage(response);
return Promise.reject(new Error(message));
});
}
}, {
key: 'getOne',
value: function getOne(entityName) {
var _falcor;
value: function getOne$$1(entityName) {
var _falcor2;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
// TODO: Remove once all getOne methods on this class have been ported to entities
var getOneFunction = camelCase('getOne_' + entityName);
if (isFunction(this[getOneFunction])) {
return this[getOneFunction](options);
}
var entity = entities[entityName];
if (isNil(entity)) {
var filename = entityToFilename(entityName) + '.js';
return reject(new Error('The ' + entityName + ' entity is undefined. Ensure entities/' + filename + ' exists and is exported by entities/_catalog.js'));
var filename = entityNameToFilename(entityName) + '.js';
return Promise.reject(new Error('The ' + entityName + ' entity is undefined. Ensure entities/' + filename + ' exists and is exported by entities/_catalog.js'));
}
if (isNil(entity.pluralName)) {
return reject(new Error('The ' + entityName + ' entity must export a pluralName'));
}
var paths = isFunction(entity.getOne) ? entity.getOne(options) : getOne$1(entity, options);
var id = options.id;
if (isNil(id)) {
return reject(new Error('options.id is required when getting one ' + entityName));
if (isError(paths)) {
return Promise.reject(paths);
}
var getPaths = isFunction(entity.getOne) ? entity.getOne(options) : getOne$2(entity, options);
return (_falcor2 = this.falcor).get.apply(_falcor2, _toConsumableArray(paths)).then(function (jsonGraph) {
var extractedEntity = isFunction(entity.extractOne) ? entity.extractOne(options, jsonGraph) : extractOne(entity, options, jsonGraph);
return (_falcor = this.falcor).get.apply(_falcor, _toConsumableArray(getPaths)).then(function (response) {
var rootLeaf = entityToFalcorRootLeaf(entity);
return response.json[rootLeaf][id];
}).catch(function (errorPaths) {
var errorMessage = createGetOneErrorMessageFromPaths(errorPaths);
return reject(new Error(errorMessage));
return extractedEntity;
}).catch(function (response) {
var message = buildGetOneErrorMessage(response);
return Promise.reject(new Error(message));
});

@@ -286,3 +602,3 @@ }

if (!isFunction(this[createFunction])) {
return reject(new Error('Invalid entity: ' + entity + '. Please check the syntax and try again.'));
return Promise.reject(new Error('Invalid entity: ' + entity + '. Please check the syntax and try again.'));
}

@@ -294,4 +610,4 @@

key: 'update',
value: function update(entityName) {
var _falcor2;
value: function update$$1(entityName) {
var _falcor3;

@@ -303,79 +619,24 @@ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

if (isNil(entity)) {
var filename = entityToFilename(entityName) + '.js';
return reject(new Error('The ' + entityName + ' entity is undefined. Ensure entities/' + filename + ' exists and is exported by entities/_catalog.js'));
var filename = entityNameToFilename(entityName) + '.js';
return Promise.reject(new Error('The ' + entityName + ' entity is undefined. Ensure entities/' + filename + ' exists and is exported by entities/_catalog.js'));
}
if (isNil(entity.pluralName)) {
return reject(new Error('The ' + entityName + ' entity must export a pluralName'));
}
var paths = isFunction(entity.update) ? entity.update(options) : update(entity, options);
var id = options.id;
if (isNil(id)) {
return reject(new Error('options.id is required when updating a tree review'));
if (isError(paths)) {
return Promise.reject(paths);
}
if (keys(options).length === 1) {
return reject(new Error('options must include at least one property to update other than id'));
}
return (_falcor3 = this.falcor).set.apply(_falcor3, _toConsumableArray(paths)).then(function (jsonGraph) {
var updatedProperties = isFunction(entity.extractUpdate) ? entity.extractUpdate(options, jsonGraph) : extractUpdate(entity, options, jsonGraph);
var valuePaths = isFunction(entity.update) ? entity.update(options) : update$1(entity, options);
return (_falcor2 = this.falcor).set.apply(_falcor2, _toConsumableArray(valuePaths)).then(function (response) {
var entities = response.json[entity.pluralName];
var updatedProperties = entities[id];
return updatedProperties;
}).catch(function (paths) {
var errorMessage = createUpdateErrorMessageFromPaths(paths);
return reject(new Error(errorMessage));
}).catch(function (response) {
var message = buildUpdateErrorMessage(response);
return Promise.reject(new Error(message));
});
}
// TODO: Remove once all delete methods have been ported
}, {
key: 'delete',
value: function _delete(entityName) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
console.warn('gloo.delete(\'' + entityName + '\') has been deprecated. Please use gloo.destroy(\'' + entityName + '\') instead.');
var deleteFunction = camelCase('delete_' + entityName);
if (isFunction(this[deleteFunction])) {
return this[deleteFunction](options);
}
var entity = entities[entityName];
if (isNil(entity)) {
var filename = entityToFilename(entityName) + '.js';
return reject(new Error('The ' + entityName + ' entity is undefined. Ensure entities/' + filename + ' exists and is exported by entities/_catalog.js'));
}
if (isNil(entity.pluralName)) {
return reject(new Error('The ' + entityName + ' entity must export a pluralName'));
}
var id = options.id;
if (isNil(id)) {
return reject(new Error('options.id is required when deleting one ' + entityName));
}
var destroyPath = isFunction(entity.destroy) ? entity.destroy(options) : destroy$1(entity, options);
return this.falcor.call(destroyPath).then(function () {
return 'Entity deleted';
}).catch(function (paths) {
var errorMessage = createDeleteErrorMessageFromPaths(paths);
return reject(new Error(errorMessage));
});
}
}, {
key: 'destroy',
value: function destroy(entityName) {
value: function destroy$$1(entityName) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -386,24 +647,17 @@

if (isNil(entity)) {
var filename = entityToFilename(entityName) + '.js';
return reject(new Error('The ' + entityName + ' entity is undefined. Ensure entities/' + filename + ' exists and is exported by entities/_catalog.js'));
var filename = entityNameToFilename(entityName) + '.js';
return Promise.reject(new Error('The ' + entityName + ' entity is undefined. Ensure entities/' + filename + ' exists and is exported by entities/_catalog.js'));
}
if (isNil(entity.pluralName)) {
return reject(new Error('The ' + entityName + ' entity must export a pluralName'));
}
var destroyPath = isFunction(entity.destroy) ? entity.destroy(options) : destroy(entity, options);
var id = options.id;
if (isNil(id)) {
return reject(new Error('options.id is required when destroying one ' + entityName));
if (isError(destroyPath)) {
return Promise.reject(destroyPath);
}
var destroyPath = isFunction(entity.destroy) ? entity.destroy(options) : destroy$1(entity, options);
return this.falcor.call(destroyPath).then(function () {
return 'Entity destroyed';
}).catch(function (paths) {
var errorMessage = createDestroyErrorMessageFromPaths(paths);
return reject(new Error(errorMessage));
}).catch(function (response) {
var message = buildDestroyErrorMessage(response);
return Promise.reject(new Error(message));
});

@@ -417,92 +671,2 @@ }

}, {
key: 'getManyTourTipViews',
value: function getManyTourTipViews() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
// TODO: Account for implicit assumptions in the final API:
// - Query, filter, and paging options will need to be passed through
// - Paging (right now) is zero based. Good opportunity to change?
// - Falcor will correctly handle from and to being undefined (may not be what we want)
// - Default paging indexes will need to be handled by Supergloo
var _buildPaging = buildPaging(options),
from = _buildPaging.from,
to = _buildPaging.to;
var properties = buildProperties$$1(tourTipView, options);
var path = ['self', 'tour_tip_view_list', { from: from, to: to }, properties];
return this.falcor.get(path).then(function (response) {
var viewList = get(response, 'json.self.tour_tip_view_list');
return map(viewList, function (view) {
return view;
});
}).catch(function (paths) {
var errorMessage = createGetManyErrorMessageFromPaths(paths);
return reject(new Error(errorMessage));
});
}
}, {
key: 'getManyTreeReviews',
value: function getManyTreeReviews() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var tree = options.tree;
if (isNil(tree) || isNil(tree.id)) {
return reject(new Error('options.tree.id is required getting tree reviews'));
}
var _buildPaging2 = buildPaging(options),
from = _buildPaging2.from,
to = _buildPaging2.to;
var properties = buildProperties$$1(review, options);
// TODO: Add support for dot notation properties, e.g. user.avatar.src.
// See getOne forEach that uses the falcorPathParser
var path = ['trees', tree.id, 'review_list', { from: from, to: to }, properties];
return this.falcor.get(path).then(function (response) {
var treeList = get(response, 'json.trees');
var first = head(keys(treeList));
var firstTree = treeList[first];
var reviewList = firstTree.review_list;
return map(reviewList, function (review$$1) {
return review$$1;
});
}).catch(function (paths) {
var errorMessage = createGetManyErrorMessageFromPaths(paths);
return reject(new Error(errorMessage));
});
}
}, {
key: 'getOneMyTreeReview',
value: function getOneMyTreeReview() {
var _falcor3;
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var tree = options.tree;
if (isNil(tree) || isNil(tree.id)) {
return reject(new Error("options.tree.id is required when getting the current user's tree review"));
}
var properties = buildProperties$$1(review, options);
var paths = properties.map(function (property) {
var path = falcorPathParser(property);
return concat(['trees', tree.id, 'my_review'], path);
});
return (_falcor3 = this.falcor).get.apply(_falcor3, _toConsumableArray(paths)).then(function (response) {
return response.json.trees[tree.id].my_review;
}).catch(function (paths) {
var errorMessage = createGetOneErrorMessageFromPaths(paths);
return reject(new Error(errorMessage));
});
}
}, {
key: 'createComment',

@@ -522,6 +686,6 @@ value: function createComment() {

// What's the diff between this.falcor.call and ngf.callModel?
return this.falcor.call(['posts', postId, 'comment_list', 'add'], [requestBody]).then(function (response) {
return this.falcor.call(['posts', postId, 'comment_list', 'add'], [requestBody]).then(function (jsonGraph) {
// TODO: This does NOT support a create-many-at-once model, is that
// doable in Falcor?
var comments = response.json.comments;
var comments = jsonGraph.json.comments;
var first = head(keys(comments));

@@ -552,4 +716,4 @@ var createdComment = comments[first];

return this.falcor.call(['tour_tip_views', 'create'], [wrappedTourTipView]).then(function (response) {
var views = response.json.tour_tip_views;
return this.falcor.call(['tour_tip_views', 'create'], [wrappedTourTipView]).then(function (jsonGraph) {
var views = jsonGraph.json.tour_tip_views;
var first = head(keys(views));

@@ -564,4 +728,4 @@ var createdView = views[first];

}).catch(function (paths) {
var errorMessage = createCreateErrorMessageFromPaths(paths);
return reject(new Error(errorMessage));
var message = buildCreateErrorMessage(paths);
return Promise.reject(new Error(message));
});

@@ -574,11 +738,11 @@ }

var review$$1 = options.review,
tree = options.tree;
tree$$1 = options.tree;
if (isNil(review$$1)) {
return reject(new Error('options.review is required when creating a tree review'));
return Promise.reject(new Error('options.review is required when creating a tree review'));
}
if (isNil(tree) || isNil(tree.id)) {
return reject(new Error('options.tree.id is required when creating a tree review'));
if (isNil(tree$$1) || isNil(tree$$1.id)) {
return Promise.reject(new Error('options.tree.id is required when creating a tree review'));
}

@@ -590,4 +754,4 @@

return this.falcor.call(['trees', tree.id, 'review_list', 'add'], [wrappedReview]).then(function (response) {
var reviews = response.json.reviews;
return this.falcor.call(['trees', tree$$1.id, 'review_list', 'add'], [wrappedReview]).then(function (jsonGraph) {
var reviews = jsonGraph.json.reviews;
var first = head(keys(reviews));

@@ -603,24 +767,6 @@ var createdReview = reviews[first];

}).catch(function (paths) {
var errorMessage = createCreateErrorMessageFromPaths(paths);
return reject(new Error(errorMessage));
var message = buildCreateErrorMessage(paths);
return Promise.reject(new Error(message));
});
}
}, {
key: 'deleteTourTipView',
value: function deleteTourTipView() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var id = options.id;
if (isNil(id)) {
return reject(new Error('options.id is required when deleting a tree review'));
}
return this.falcor.call(['tour_tip_views', id, 'delete']).then(function () {
return 'Entity deleted';
}).catch(function (paths) {
var errorMessage = createDeleteErrorMessageFromPaths(paths);
return reject(new Error(errorMessage));
});
}
}]);

@@ -631,27 +777,2 @@

function buildPaging(options) {
return {
from: get(options, 'paging.from') || DEFAULT_FROM_INDEX,
to: get(options, 'paging.to') || DEFAULT_TO_INDEX
};
}
function buildProperties$$1(defaults, options) {
var properties = concat([], options.properties || defaults);
var toAnd = options.andProperties;
if (isArray(toAnd) && !isEmpty(toAnd)) {
properties = concat(properties, toAnd);
}
var toNot = options.notProperties;
if (isArray(toNot) && !isEmpty(toNot)) {
properties = pullAll(properties, toNot);
}
properties = uniq(properties);
return properties;
}
var codeToMessageMap = {

@@ -666,7 +787,8 @@ 400: 'request is malformed',

function createGetOneErrorMessageFromPaths(paths) {
// TODO: Account for implicit assumptions in the final API:
// - if any path fails, the entire request fails
// - the first path's failure message is used to determine the error message
var firstPath = paths[0];
function buildGetOneErrorMessage(response) {
if (response instanceof Error) {
return response.message;
}
var firstPath = response[0];
var entity = camelCase(firstPath.path[0]);

@@ -682,4 +804,8 @@ var entityId = firstPath.path[1];

function createGetManyErrorMessageFromPaths(paths) {
var firstPath = paths[0];
function buildGetManyErrorMessage(response) {
if (response instanceof Error) {
return response.message;
}
var firstPath = response[0];
var entity = camelCase(firstPath.path[0]);

@@ -694,4 +820,8 @@ var originalMessage = firstPath.value;

function createCreateErrorMessageFromPaths(paths) {
var firstPath = paths[0];
function buildCreateErrorMessage(response) {
if (response instanceof Error) {
return response.message;
}
var firstPath = response[0];
var entity = camelCase(firstPath.path[0]);

@@ -706,4 +836,8 @@ var originalMessage = firstPath.value;

function createUpdateErrorMessageFromPaths(paths) {
var firstPath = paths[0];
function buildUpdateErrorMessage(response) {
if (response instanceof Error) {
return response.message;
}
var firstPath = response[0];
var entity = camelCase(firstPath.path[0]);

@@ -719,16 +853,8 @@ var entityId = firstPath.path[1];

function createDeleteErrorMessageFromPaths(paths) {
var firstPath = paths[0];
var entity = camelCase(firstPath.path[0]);
var entityId = firstPath.path[1];
var originalMessage = firstPath.value;
function buildDestroyErrorMessage(response) {
if (response instanceof Error) {
return response.message;
}
var code = originalMessage.match(/\d{3}/)[0];
var improvedMessage = codeToMessageMap[code] || codeToMessageMap.default;
return 'Could not delete ' + entity + ' ' + entityId + ': ' + improvedMessage + ' (' + originalMessage + ')';
}
function createDestroyErrorMessageFromPaths(paths) {
var firstPath = paths[0];
var firstPath = response[0];
var entity = camelCase(firstPath.path[0]);

@@ -735,0 +861,0 @@ var entityId = firstPath.path[1];

{
"name": "supergloo",
"version": "0.9.0",
"version": "0.10.0",
"description": "Easily work with data on the Gloo platform",

@@ -20,3 +20,3 @@ "keywords": [

"dependencies": {
"bluebird": "3.4.7",
"es6-promise": "4.0.5",
"falcor-path-syntax": "0.2.4",

@@ -27,5 +27,5 @@ "lodash": "4.17.2"

"app-module-path": "2.2.0",
"babel-plugin-external-helpers": "6.18.0",
"babel-preset-es2015": "6.18.0",
"babel-register": "6.18.0",
"babel-plugin-external-helpers": "6.22.0",
"babel-preset-es2015": "6.22.0",
"babel-register": "6.22.0",
"easy-sauce": "0.4.1",

@@ -38,5 +38,5 @@ "falcor": "0.1.17",

"rimraf": "2.5.4",
"rollup": "0.37.0",
"rollup": "0.41.4",
"rollup-plugin-babel": "2.7.1",
"rollup-plugin-commonjs": "6.0.0",
"rollup-plugin-commonjs": "6.0.1",
"rollup-plugin-multi-entry": "2.0.1",

@@ -47,3 +47,3 @@ "rollup-plugin-node-builtins": "2.0.0",

"rollup-plugin-replace": "1.1.1",
"shrinkpack": "0.17.1",
"shrinkpack": "0.18.1",
"standard": "8.6.0",

@@ -50,0 +50,0 @@ "ulid": "0.1.0"

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc