Comparing version 0.14.0 to 0.15.0
@@ -46,4 +46,27 @@ import es6Promise from 'es6-promise'; | ||
var name$2 = 'champion'; | ||
var pluralName$2 = 'champions'; | ||
var defaultProperties$2 = ['id']; | ||
var champion = Object.freeze({ | ||
name: name$2, | ||
pluralName: pluralName$2, | ||
defaultProperties: defaultProperties$2 | ||
}); | ||
var name$3 = 'cohort'; | ||
var pluralName$3 = 'cohorts'; | ||
var defaultProperties$3 = ['id', 'name', 'description']; | ||
var cohort = Object.freeze({ | ||
name: name$3, | ||
pluralName: pluralName$3, | ||
defaultProperties: defaultProperties$3 | ||
}); | ||
var DEFAULT_FROM_INDEX = 0; | ||
var DEFAULT_TO_INDEX = 19; | ||
var MY_PATH_KEYWORD = 'self'; | ||
@@ -87,2 +110,10 @@ function buildPaging(options) { | ||
function entityToFalcorMembershipsListLeaf(entity) { | ||
return 'membership_' + entityToFalcorListLeaf(entity); | ||
} | ||
function entityToFalcorMyListLeaf(entity) { | ||
return 'my_' + entityToFalcorListLeaf(entity); | ||
} | ||
function entityToFalcorRootLeaf(entity) { | ||
@@ -104,4 +135,4 @@ return snakeCase(entity.pluralName); | ||
var name$2 = 'comment'; | ||
var pluralName$2 = 'comments'; | ||
var name$4 = 'comment'; | ||
var pluralName$4 = 'comments'; | ||
@@ -123,21 +154,21 @@ function invalidateAfterCreate() { | ||
var comment = Object.freeze({ | ||
name: name$2, | ||
pluralName: pluralName$2, | ||
name: name$4, | ||
pluralName: pluralName$4, | ||
invalidateAfterCreate: invalidateAfterCreate | ||
}); | ||
var name$4 = 'post'; | ||
var pluralName$4 = 'posts'; | ||
var name$6 = 'post'; | ||
var pluralName$6 = 'posts'; | ||
var defaultProperties$2 = ['id', 'body']; | ||
var defaultProperties$4 = ['id', 'body']; | ||
var post = Object.freeze({ | ||
name: name$4, | ||
pluralName: pluralName$4, | ||
defaultProperties: defaultProperties$2 | ||
name: name$6, | ||
pluralName: pluralName$6, | ||
defaultProperties: defaultProperties$4 | ||
}); | ||
var name$3 = 'feedPost'; | ||
var pluralName$3 = 'feedPosts'; | ||
function getMany$1() { | ||
var name$5 = 'feedPost'; | ||
var pluralName$5 = 'feedPosts'; | ||
function getMany() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
@@ -149,4 +180,4 @@ | ||
var properties = buildProperties(defaultProperties$2, options); | ||
var listLeaf = entityToFalcorListLeaf({ name: name$3 }); | ||
var properties = buildProperties(defaultProperties$4, options); | ||
var listLeaf = entityToFalcorListLeaf({ name: name$5 }); | ||
@@ -167,3 +198,3 @@ var paths = map(properties, function (property) { | ||
var listLeaf = entityToFalcorListLeaf({ name: name$3 }); | ||
var listLeaf = entityToFalcorListLeaf({ name: name$5 }); | ||
var postList = jsonGraph.json.self[listLeaf]; | ||
@@ -179,37 +210,117 @@ | ||
var feedPost = Object.freeze({ | ||
name: name$3, | ||
pluralName: pluralName$3, | ||
defaultProperties: defaultProperties$2, | ||
getMany: getMany$1, | ||
name: name$5, | ||
pluralName: pluralName$5, | ||
defaultProperties: defaultProperties$4, | ||
getMany: getMany, | ||
extractMany: extractMany | ||
}); | ||
var name$5 = 'moment'; | ||
var pluralName$5 = 'moments'; | ||
var name$7 = 'growthAction'; | ||
var pluralName$7 = 'growthActions'; | ||
var defaultProperties$3 = ['id', 'description', 'title', 'user.name', 'cover_image_media.id', 'cover_image_media.src']; | ||
var defaultProperties$5 = ['id', 'agent.id', 'agent.name', 'growee.id', 'growee.name', 'relationship.id', 'relationship.owner.id', 'growth_relationship_id', 'growee_name', 'growee_avatar_url', 'state', 'title']; | ||
var growthAction = Object.freeze({ | ||
name: name$7, | ||
pluralName: pluralName$7, | ||
defaultProperties: defaultProperties$5 | ||
}); | ||
var name$8 = 'growthRelationship'; | ||
var pluralName$8 = 'growthRelationships'; | ||
var defaultProperties$6 = ['id', 'owner_type', 'owner.id', 'owner.name', 'growee.id', 'growee.name', 'agent.id', 'agent.name']; | ||
var growthRelationship = Object.freeze({ | ||
name: name$8, | ||
pluralName: pluralName$8, | ||
defaultProperties: defaultProperties$6 | ||
}); | ||
var name$9 = 'growthAgentPrompt'; | ||
var pluralName$9 = 'growthAgentPrompts'; | ||
var defaultProperties$7 = ['id', 'title', 'state', 'action.id', 'action.growee.id', 'action.growee.name', 'action.agent.id', 'action.relationship.id', 'action.relationship.owner.id']; | ||
var growthAgentPrompt = Object.freeze({ | ||
name: name$9, | ||
pluralName: pluralName$9, | ||
defaultProperties: defaultProperties$7 | ||
}); | ||
var name$10 = 'moment'; | ||
var pluralName$10 = 'moments'; | ||
var defaultProperties$8 = ['id', 'description', 'title', 'user.name', 'cover_image_media.id', 'cover_image_media.src']; | ||
var moment = Object.freeze({ | ||
name: name$5, | ||
pluralName: pluralName$5, | ||
defaultProperties: defaultProperties$3 | ||
name: name$10, | ||
pluralName: pluralName$10, | ||
defaultProperties: defaultProperties$8 | ||
}); | ||
var name$7 = 'review'; | ||
var pluralName$7 = 'reviews'; | ||
var name$11 = 'myGrowthAgentPrompt'; | ||
var pluralName$11 = 'myGrowthAgentPrompts'; | ||
var defaultProperties$4 = ['id', 'rating']; | ||
var defaultProperties$9 = ['id', 'title', 'state', 'action.id', 'action.growee.id', 'action.growee.name', 'action.growee.email', 'action.agent.id', 'action.relationship.id', 'action.relationship.owner.id']; | ||
function getMany$1() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var _buildPaging = buildPaging(options), | ||
from = _buildPaging.from, | ||
to = _buildPaging.to; | ||
var properties = buildProperties(defaultProperties$9, options); | ||
var listLeaf = entityToFalcorListLeaf({ name: name$11 }); | ||
var paths = map(properties, function (property) { | ||
var propertyPath = falcorPathParser(property); | ||
var path = concat(['self', listLeaf, { from: from, to: to }], propertyPath); | ||
return path; | ||
}); | ||
return paths; | ||
} | ||
function extractMany$1() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var jsonGraph = arguments[1]; | ||
var listLeaf = entityToFalcorListLeaf({ name: name$11 }); | ||
var viewList = jsonGraph.json.self[listLeaf]; | ||
var views = map(viewList, function (view) { | ||
return view; | ||
}); | ||
return views; | ||
} | ||
var myGrowthAgentPrompt = Object.freeze({ | ||
name: name$11, | ||
pluralName: pluralName$11, | ||
defaultProperties: defaultProperties$9, | ||
getMany: getMany$1, | ||
extractMany: extractMany$1 | ||
}); | ||
var name$13 = 'review'; | ||
var pluralName$13 = 'reviews'; | ||
var defaultProperties$10 = ['id', 'rating']; | ||
var review = Object.freeze({ | ||
name: name$7, | ||
pluralName: pluralName$7, | ||
defaultProperties: defaultProperties$4 | ||
name: name$13, | ||
pluralName: pluralName$13, | ||
defaultProperties: defaultProperties$10 | ||
}); | ||
var name$8 = 'tree'; | ||
var pluralName$8 = 'trees'; | ||
var name$14 = 'tree'; | ||
var pluralName$14 = 'trees'; | ||
var treeEntity = Object.freeze({ | ||
name: name$8, | ||
pluralName: pluralName$8 | ||
name: name$14, | ||
pluralName: pluralName$14 | ||
}); | ||
@@ -223,5 +334,5 @@ | ||
var name$6 = 'myTreeReview'; | ||
var pluralName$6 = 'myTreeReviews'; | ||
function getOne$1() { | ||
var name$12 = 'myTreeReview'; | ||
var pluralName$12 = 'myTreeReviews'; | ||
function getOne() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
@@ -235,3 +346,3 @@ var tree = options.tree; | ||
var properties = buildProperties(defaultProperties$4, options); | ||
var properties = buildProperties(defaultProperties$10, options); | ||
@@ -264,51 +375,54 @@ var paths = properties.map(function (property) { | ||
var myTreeReview = Object.freeze({ | ||
name: name$6, | ||
pluralName: pluralName$6, | ||
defaultProperties: defaultProperties$4, | ||
getOne: getOne$1, | ||
name: name$12, | ||
pluralName: pluralName$12, | ||
defaultProperties: defaultProperties$10, | ||
getOne: getOne, | ||
extractOne: extractOne | ||
}); | ||
var name$9 = 'note'; | ||
var pluralName$9 = 'notes'; | ||
var name$15 = 'note'; | ||
var pluralName$15 = 'notes'; | ||
var defaultProperties$5 = ['id', 'body']; | ||
var defaultProperties$11 = ['id', 'body']; | ||
var note = Object.freeze({ | ||
name: name$9, | ||
pluralName: pluralName$9, | ||
defaultProperties: defaultProperties$5 | ||
name: name$15, | ||
pluralName: pluralName$15, | ||
defaultProperties: defaultProperties$11 | ||
}); | ||
var name$10 = 'space'; | ||
var pluralName$10 = 'spaces'; | ||
var name$16 = 'space'; | ||
var pluralName$16 = 'spaces'; | ||
var defaultProperties$12 = ['id', 'name', 'topic']; | ||
var space = Object.freeze({ | ||
name: name$10, | ||
pluralName: pluralName$10 | ||
name: name$16, | ||
pluralName: pluralName$16, | ||
defaultProperties: defaultProperties$12 | ||
}); | ||
var name$11 = 'timeline'; | ||
var pluralName$11 = 'timelines'; | ||
var name$17 = 'timeline'; | ||
var pluralName$17 = 'timelines'; | ||
var timeline = Object.freeze({ | ||
name: name$11, | ||
pluralName: pluralName$11 | ||
name: name$17, | ||
pluralName: pluralName$17 | ||
}); | ||
var name$12 = 'topic'; | ||
var pluralName$12 = 'topics'; | ||
var name$18 = 'topic'; | ||
var pluralName$18 = 'topics'; | ||
var defaultProperties$6 = ['id', 'name']; | ||
var defaultProperties$13 = ['id', 'name']; | ||
var topic = Object.freeze({ | ||
name: name$12, | ||
pluralName: pluralName$12, | ||
defaultProperties: defaultProperties$6 | ||
name: name$18, | ||
pluralName: pluralName$18, | ||
defaultProperties: defaultProperties$13 | ||
}); | ||
var name$13 = 'tourTipView'; | ||
var pluralName$13 = 'tourTipViews'; | ||
var name$19 = 'tourTipView'; | ||
var pluralName$19 = 'tourTipViews'; | ||
var defaultProperties$7 = ['id', 'state']; | ||
var defaultProperties$14 = ['id', 'state']; | ||
@@ -322,4 +436,4 @@ function getMany$2() { | ||
var properties = buildProperties(defaultProperties$7, options); | ||
var listLeaf = entityToFalcorListLeaf({ name: name$13 }); | ||
var properties = buildProperties(defaultProperties$14, options); | ||
var listLeaf = entityToFalcorListLeaf({ name: name$19 }); | ||
@@ -336,7 +450,7 @@ var paths = map(properties, function (property) { | ||
function extractMany$1() { | ||
function extractMany$2() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var jsonGraph = arguments[1]; | ||
var listLeaf = entityToFalcorListLeaf({ name: name$13 }); | ||
var listLeaf = entityToFalcorListLeaf({ name: name$19 }); | ||
var viewList = jsonGraph.json.self[listLeaf]; | ||
@@ -352,97 +466,34 @@ | ||
var tourTipView = Object.freeze({ | ||
name: name$13, | ||
pluralName: pluralName$13, | ||
defaultProperties: defaultProperties$7, | ||
name: name$19, | ||
pluralName: pluralName$19, | ||
defaultProperties: defaultProperties$14, | ||
getMany: getMany$2, | ||
extractMany: extractMany$1 | ||
extractMany: extractMany$2 | ||
}); | ||
var name$14 = 'growthAction'; | ||
var pluralName$14 = 'growthActions'; | ||
var name$20 = 'view'; | ||
var pluralName$20 = 'views'; | ||
var defaultProperties$8 = ['id', 'agent.id', 'agent.name', 'growee.id', 'growee.name', 'relationship.id', 'relationship.owner.id', 'growth_relationship_id', 'growee_name', 'growee_avatar_url', 'state', 'title']; | ||
var defaultProperties$15 = ['id', 'viewable_id', 'viewable_type']; | ||
var growthAction = Object.freeze({ | ||
name: name$14, | ||
pluralName: pluralName$14, | ||
defaultProperties: defaultProperties$8 | ||
var view = Object.freeze({ | ||
name: name$20, | ||
pluralName: pluralName$20, | ||
defaultProperties: defaultProperties$15 | ||
}); | ||
var name$15 = 'growthRelationship'; | ||
var pluralName$15 = 'growthRelationships'; | ||
var defaultProperties$9 = ['id', 'owner_type', 'owner.id', 'owner.name', 'growee.id', 'growee.name', 'agent.id', 'agent.name']; | ||
var growthRelationship = Object.freeze({ | ||
name: name$15, | ||
pluralName: pluralName$15, | ||
defaultProperties: defaultProperties$9 | ||
}); | ||
var name$16 = 'growthAgentPrompt'; | ||
var pluralName$16 = 'growthAgentPrompts'; | ||
var defaultProperties$10 = ['id', 'title', 'state', 'action.id', 'action.growee.id', 'action.growee.name', 'action.agent.id']; | ||
var growthAgentPrompt = Object.freeze({ | ||
name: name$16, | ||
pluralName: pluralName$16, | ||
defaultProperties: defaultProperties$10 | ||
}); | ||
var name$17 = 'myGrowthAgentPrompt'; | ||
var pluralName$17 = 'myGrowthAgentPrompts'; | ||
var defaultProperties$11 = ['id', 'title', 'state', 'action.id', 'action.growee.id', 'action.growee.name', 'action.growee.email', 'action.growee.avatar.src', 'action.agent.id', 'action.relationship.id', 'action.relationship.owner.id']; | ||
function getMany$3() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var _buildPaging = buildPaging(options), | ||
from = _buildPaging.from, | ||
to = _buildPaging.to; | ||
var properties = buildProperties(defaultProperties$11, options); | ||
var listLeaf = entityToFalcorListLeaf({ name: name$17 }); | ||
var paths = map(properties, function (property) { | ||
var propertyPath = falcorPathParser(property); | ||
var path = concat(['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$17 }); | ||
var viewList = jsonGraph.json.self[listLeaf]; | ||
var views = map(viewList, function (view) { | ||
return view; | ||
}); | ||
return views; | ||
} | ||
var myGrowthAgentPrompt = Object.freeze({ | ||
name: name$17, | ||
pluralName: pluralName$17, | ||
defaultProperties: defaultProperties$11, | ||
getMany: getMany$3, | ||
extractMany: extractMany$2 | ||
}); | ||
var entities = Object.freeze({ | ||
audioCategory: audioCategory, | ||
audioTrack: audioTrack, | ||
champion: champion, | ||
cohort: cohort, | ||
comment: comment, | ||
feedPost: feedPost, | ||
growthAction: growthAction, | ||
growthRelationship: growthRelationship, | ||
growthAgentPrompt: growthAgentPrompt, | ||
moment: moment, | ||
myGrowthAgentPrompt: myGrowthAgentPrompt, | ||
myTreeReview: myTreeReview, | ||
@@ -456,6 +507,4 @@ note: note, | ||
tourTipView: tourTipView, | ||
growthAction: growthAction, | ||
growthRelationship: growthRelationship, | ||
growthAgentPrompt: growthAgentPrompt, | ||
myGrowthAgentPrompt: myGrowthAgentPrompt | ||
tree: treeEntity, | ||
view: view | ||
}); | ||
@@ -491,3 +540,3 @@ | ||
function getOne$2(entityName, entity) { | ||
function getOne$1(entityName, entity) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
@@ -510,3 +559,3 @@ | ||
var paths = properties.map(function (property) { | ||
var paths = map(properties, function (property) { | ||
var propertyPath = falcorPathParser(property); | ||
@@ -531,3 +580,3 @@ var path = concat([rootLeaf, options.id], propertyPath); | ||
function getMany$4(entityName, entity) { | ||
function getMany$3(entityName, entity) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
@@ -575,8 +624,10 @@ | ||
var qs = stringify(options.query); | ||
basePath.push(qs); | ||
basePath = concat(basePath, qs); | ||
} | ||
var paths = properties.map(function (property) { | ||
basePath = concat(basePath, { from: from, to: to }); | ||
var paths = map(properties, function (property) { | ||
var propertyPath = falcorPathParser(property); | ||
var path = concat(basePath, { from: from, to: to }, propertyPath); | ||
var path = concat(basePath, propertyPath); | ||
@@ -625,3 +676,3 @@ return path; | ||
function create$1(entityName, entity) { | ||
function getMy(entityName, entity) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
@@ -633,2 +684,107 @@ | ||
if (!entityExports(entity, 'defaultProperties')) { | ||
return entityMustExportError(entityName, 'defaultProperties'); | ||
} | ||
var _buildPaging2 = buildPaging(options), | ||
from = _buildPaging2.from, | ||
to = _buildPaging2.to; | ||
var properties = buildProperties(entity.defaultProperties, options); | ||
var listLeaf = entityToFalcorMyListLeaf(entity); | ||
var basePath = [MY_PATH_KEYWORD, listLeaf]; | ||
if (optionsHasQuery(options)) { | ||
var qs = stringify(options.query); | ||
basePath = concat(basePath, qs); | ||
} | ||
basePath = concat(basePath, { from: from, to: to }); | ||
var paths = map(properties, function (property) { | ||
var propertyPath = falcorPathParser(property); | ||
var path = concat(basePath, propertyPath); | ||
return path; | ||
}); | ||
return paths; | ||
} | ||
function extractMy(entity) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var jsonGraph = arguments[2]; | ||
var listLeaf = entityToFalcorMyListLeaf(entity); | ||
var entityList = jsonGraph.json[MY_PATH_KEYWORD][listLeaf]; | ||
if (optionsHasQuery(options)) { | ||
var qs = stringify(options.query); | ||
entityList = entityList[qs]; | ||
} | ||
var extractedEntities = map(entityList, function (entity) { | ||
return entity; | ||
}); | ||
return extractedEntities; | ||
} | ||
function getMemberships(entityName, entity) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
if (!entityExports(entity, 'name')) { | ||
return entityMustExportError(entityName, 'name'); | ||
} | ||
if (!entityExports(entity, 'defaultProperties')) { | ||
return entityMustExportError(entityName, 'defaultProperties'); | ||
} | ||
var _buildPaging3 = buildPaging(options), | ||
from = _buildPaging3.from, | ||
to = _buildPaging3.to; | ||
var properties = buildProperties(entity.defaultProperties, options); | ||
var listLeaf = entityToFalcorMembershipsListLeaf(entity); | ||
var basePath = [MY_PATH_KEYWORD, listLeaf]; | ||
basePath = concat(basePath, { from: from, to: to }); | ||
var paths = map(properties, function (property) { | ||
var propertyPath = falcorPathParser(property); | ||
var path = concat(basePath, propertyPath); | ||
return path; | ||
}); | ||
return paths; | ||
} | ||
function extractMemberships(entity) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var jsonGraph = arguments[2]; | ||
var listLeaf = entityToFalcorMembershipsListLeaf(entity); | ||
var entityList = jsonGraph.json[MY_PATH_KEYWORD][listLeaf]; | ||
if (optionsHasQuery(options)) { | ||
var qs = stringify(options.query); | ||
entityList = entityList[qs]; | ||
} | ||
var extractedEntities = map(entityList, function (entity) { | ||
return entity; | ||
}); | ||
return extractedEntities; | ||
} | ||
function create(entityName, entity) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
if (!entityExports(entity, 'name')) { | ||
return entityMustExportError(entityName, 'name'); | ||
} | ||
if (!entityExports(entity, 'pluralName')) { | ||
@@ -709,3 +865,3 @@ return entityMustExportError(entityName, 'pluralName'); | ||
function update$1(entityName, entity) { | ||
function update(entityName, entity) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
@@ -752,3 +908,3 @@ | ||
function destroy$1(entityName, entity) { | ||
function destroy(entityName, entity) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
@@ -809,4 +965,4 @@ | ||
}, { | ||
key: 'getMany', | ||
value: function getMany(entityName) { | ||
key: 'getOne', | ||
value: function getOne$$1(entityName) { | ||
var _falcor; | ||
@@ -822,3 +978,3 @@ | ||
var paths = isFunction(entity.getMany) ? entity.getMany(options) : getMany$4(entityName, entity, options); | ||
var paths = isFunction(entity.getOne) ? entity.getOne(options) : getOne$1(entityName, entity, options); | ||
@@ -830,2 +986,35 @@ if (isError(paths)) { | ||
return (_falcor = this.falcor).get.apply(_falcor, _toConsumableArray(paths)).then(function (jsonGraph) { | ||
var extractedEntity = void 0; | ||
if (isNil(get(jsonGraph, 'json'))) { | ||
extractedEntity = null; | ||
} else { | ||
extractedEntity = isFunction(entity.extractOne) ? entity.extractOne(options, jsonGraph) : extractOne$1(entity, options, jsonGraph); | ||
} | ||
return extractedEntity; | ||
}).catch(function (response) { | ||
var message = buildGetOneErrorMessage(response); | ||
return Promise.reject(new Error(message)); | ||
}); | ||
} | ||
}, { | ||
key: 'getMany', | ||
value: function getMany$$1(entityName) { | ||
var _falcor2; | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var entity = entities[entityName]; | ||
if (isNil(entity)) { | ||
return Promise.reject(entityIsUndefinedError(entityName)); | ||
} | ||
var paths = isFunction(entity.getMany) ? entity.getMany(options) : getMany$3(entityName, entity, options); | ||
if (isError(paths)) { | ||
return Promise.reject(paths); | ||
} | ||
return (_falcor2 = this.falcor).get.apply(_falcor2, _toConsumableArray(paths)).then(function (jsonGraph) { | ||
var extractedEntities = void 0; | ||
@@ -845,5 +1034,5 @@ if (isNil(get(jsonGraph, 'json'))) { | ||
}, { | ||
key: 'getOne', | ||
value: function getOne(entityName) { | ||
var _falcor2; | ||
key: 'getMy', | ||
value: function getMy$$1(entityName) { | ||
var _falcor3; | ||
@@ -858,3 +1047,3 @@ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var paths = isFunction(entity.getOne) ? entity.getOne(options) : getOne$2(entityName, entity, options); | ||
var paths = isFunction(entity.getMy) ? entity.getMy(options) : getMy(entityName, entity, options); | ||
@@ -865,13 +1054,13 @@ if (isError(paths)) { | ||
return (_falcor2 = this.falcor).get.apply(_falcor2, _toConsumableArray(paths)).then(function (jsonGraph) { | ||
var extractedEntity = void 0; | ||
return (_falcor3 = this.falcor).get.apply(_falcor3, _toConsumableArray(paths)).then(function (jsonGraph) { | ||
var extractedEntities = void 0; | ||
if (isNil(get(jsonGraph, 'json'))) { | ||
extractedEntity = null; | ||
extractedEntities = null; | ||
} else { | ||
extractedEntity = isFunction(entity.extractOne) ? entity.extractOne(options, jsonGraph) : extractOne$1(entity, options, jsonGraph); | ||
extractedEntities = isFunction(entity.extractMy) ? entity.extractMy(options, jsonGraph) : extractMy(entity, options, jsonGraph); | ||
} | ||
return extractedEntity; | ||
return extractedEntities; | ||
}).catch(function (response) { | ||
var message = buildGetOneErrorMessage(response); | ||
var message = buildGetMyErrorMessage(response); | ||
return Promise.reject(new Error(message)); | ||
@@ -881,4 +1070,37 @@ }); | ||
}, { | ||
key: 'getMemberships', | ||
value: function getMemberships$$1(entityName) { | ||
var _falcor4; | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var entity = entities[entityName]; | ||
if (isNil(entity)) { | ||
return Promise.reject(entityIsUndefinedError(entityName)); | ||
} | ||
var paths = isFunction(entity.getMemberships) ? entity.getMemberships(options) : getMemberships(entityName, entity, options); | ||
if (isError(paths)) { | ||
return Promise.reject(paths); | ||
} | ||
return (_falcor4 = this.falcor).get.apply(_falcor4, _toConsumableArray(paths)).then(function (jsonGraph) { | ||
var extractedEntities = void 0; | ||
if (isNil(get(jsonGraph, 'json'))) { | ||
extractedEntities = null; | ||
} else { | ||
extractedEntities = isFunction(entity.extractMemberships) ? entity.extractMemberships(options, jsonGraph) : extractMemberships(entity, options, jsonGraph); | ||
} | ||
return extractedEntities; | ||
}).catch(function (response) { | ||
var message = buildGetMembershipsErrorMessage(response); | ||
return Promise.reject(new Error(message)); | ||
}); | ||
} | ||
}, { | ||
key: 'create', | ||
value: function create(entityName) { | ||
value: function create$$1(entityName) { | ||
var _this = this; | ||
@@ -894,3 +1116,3 @@ | ||
var callOptions = isFunction(entity.create) ? entity.create(options) : create$1(entityName, entity, options); | ||
var callOptions = isFunction(entity.create) ? entity.create(options) : create(entityName, entity, options); | ||
@@ -916,5 +1138,5 @@ if (isError(callOptions)) { | ||
if (pathsToInvalidate) { | ||
var _falcor3; | ||
var _falcor5; | ||
(_falcor3 = _this.falcor).invalidate.apply(_falcor3, _toConsumableArray(pathsToInvalidate)); | ||
(_falcor5 = _this.falcor).invalidate.apply(_falcor5, _toConsumableArray(pathsToInvalidate)); | ||
} | ||
@@ -930,4 +1152,4 @@ | ||
key: 'update', | ||
value: function update(entityName) { | ||
var _falcor4; | ||
value: function update$$1(entityName) { | ||
var _falcor6; | ||
@@ -942,3 +1164,3 @@ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var paths = isFunction(entity.update) ? entity.update(options) : update$1(entityName, entity, options); | ||
var paths = isFunction(entity.update) ? entity.update(options) : update(entityName, entity, options); | ||
@@ -949,3 +1171,3 @@ if (isError(paths)) { | ||
return (_falcor4 = this.falcor).set.apply(_falcor4, _toConsumableArray(paths)).then(function (jsonGraph) { | ||
return (_falcor6 = this.falcor).set.apply(_falcor6, _toConsumableArray(paths)).then(function (jsonGraph) { | ||
var updatedProperties = void 0; | ||
@@ -966,3 +1188,3 @@ if (isNil(get(jsonGraph, 'json'))) { | ||
key: 'destroy', | ||
value: function destroy(entityName) { | ||
value: function destroy$$1(entityName) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
@@ -976,3 +1198,3 @@ | ||
var destroyPath = isFunction(entity.destroy) ? entity.destroy(options) : destroy$1(entityName, entity, options); | ||
var destroyPath = isFunction(entity.destroy) ? entity.destroy(options) : destroy(entityName, entity, options); | ||
@@ -1032,5 +1254,35 @@ if (isError(destroyPath)) { | ||
return 'Could not get ' + entity + ': ' + improvedMessage; | ||
return 'Could not get many ' + entity + ': ' + improvedMessage; | ||
} | ||
function buildGetMyErrorMessage(response) { | ||
if (response instanceof Error) { | ||
return response.message; | ||
} | ||
var firstPath = response[0]; | ||
var entity = camelCase(firstPath.path[0]); | ||
var originalMessage = firstPath.value; | ||
var code = originalMessage.match(/\d{3}/)[0]; | ||
var improvedMessage = codeToMessageMap[code] || codeToMessageMap.default; | ||
return 'Could not get my ' + entity + ': ' + improvedMessage; | ||
} | ||
function buildGetMembershipsErrorMessage(response) { | ||
if (response instanceof Error) { | ||
return response.message; | ||
} | ||
var firstPath = response[0]; | ||
var entity = camelCase(firstPath.path[0]); | ||
var originalMessage = firstPath.value; | ||
var code = originalMessage.match(/\d{3}/)[0]; | ||
var improvedMessage = codeToMessageMap[code] || codeToMessageMap.default; | ||
return 'Could not get ' + entity + ' memberships: ' + improvedMessage; | ||
} | ||
function buildCreateErrorMessage(response) { | ||
@@ -1037,0 +1289,0 @@ if (response instanceof Error) { |
{ | ||
"name": "supergloo", | ||
"version": "0.14.0", | ||
"version": "0.15.0", | ||
"description": "Easily work with data on the Gloo platform", | ||
@@ -22,3 +22,3 @@ "keywords": [ | ||
"falcor-path-syntax": "0.2.4", | ||
"lodash": "4.17.2" | ||
"lodash": "4.17.4" | ||
}, | ||
@@ -25,0 +25,0 @@ "devDependencies": { |
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
261296
7907
0
+ Addedlodash@4.17.4(transitive)
- Removedlodash@4.17.2(transitive)
Updatedlodash@4.17.4