Comparing version 0.21.0 to 0.22.0-rc.1
@@ -18,2 +18,3 @@ import es6Promise from 'es6-promise'; | ||
import filter from 'lodash/filter'; | ||
import forEach from 'lodash/forEach'; | ||
import isError from 'lodash/isError'; | ||
@@ -137,3 +138,3 @@ import isFunction from 'lodash/isFunction'; | ||
var defaultProperties$4 = ['id', 'body']; | ||
var defaultProperties$4 = ['id', 'body', 'markup_tokens', 'post', 'owner.id', 'owner.first_name', 'owner.last_name', 'owner.name', 'owner.avatar.src', 'created_at']; | ||
@@ -154,2 +155,20 @@ function invalidateAfterCreate() { | ||
// TODO: Update Falcor comment routes to follow standard entity | ||
// *_list and length conventions and then remove this override | ||
function invalidateAfterDestroy() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var rootEntityLeaf = entityToFalcorRootLeaf({ pluralName: pluralName$4 }); | ||
var entityId = options.id; | ||
var parentEntityName = head(keys(options.parent)); | ||
var parentEntity = entities[parentEntityName]; | ||
var rootParentLeaf = entityToFalcorRootLeaf(parentEntity); | ||
var parentId = options.parent[parentEntityName].id; | ||
var paths = [[rootEntityLeaf, entityId], [rootParentLeaf, parentId, 'comment_list'], [rootParentLeaf, parentId, 'comment_count']]; | ||
return paths; | ||
} | ||
var comment = Object.freeze({ | ||
@@ -159,3 +178,4 @@ name: name$4, | ||
defaultProperties: defaultProperties$4, | ||
invalidateAfterCreate: invalidateAfterCreate | ||
invalidateAfterCreate: invalidateAfterCreate, | ||
invalidateAfterDestroy: invalidateAfterDestroy | ||
}); | ||
@@ -995,2 +1015,24 @@ | ||
function invalidateAfterDestroy$1(entity) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var rootEntityLeaf = entityToFalcorRootLeaf(entity); | ||
var entityId = options.id; | ||
var paths = [[rootEntityLeaf, entityId]]; | ||
if (!isNil(options.parent)) { | ||
var parentEntityName = head(keys(options.parent)); | ||
var parentEntity = entities[parentEntityName]; | ||
var parentId = options.parent[parentEntityName].id; | ||
var rootParentLeaf = entityToFalcorRootLeaf(parentEntity); | ||
var listLeaf = entityToFalcorListLeaf(entity); | ||
paths.push([rootParentLeaf, parentId, listLeaf], [rootParentLeaf, parentId, listLeaf, 'length']); | ||
} | ||
return paths; | ||
} | ||
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; }; }(); | ||
@@ -1199,6 +1241,6 @@ | ||
if (pathsToInvalidate) { | ||
var _falcor5; | ||
(_falcor5 = _this.falcor).invalidate.apply(_falcor5, _toConsumableArray(pathsToInvalidate)); | ||
if (!isEmpty(pathsToInvalidate)) { | ||
forEach(pathsToInvalidate, function (path) { | ||
_this.falcor.invalidate(path); | ||
}); | ||
} | ||
@@ -1215,3 +1257,3 @@ | ||
value: function update$$1(entityName) { | ||
var _falcor6; | ||
var _falcor5; | ||
@@ -1232,3 +1274,3 @@ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
return (_falcor6 = this.falcor).set.apply(_falcor6, _toConsumableArray(paths)).then(function (jsonGraph) { | ||
return (_falcor5 = this.falcor).set.apply(_falcor5, _toConsumableArray(paths)).then(function (jsonGraph) { | ||
var updatedProperties = void 0; | ||
@@ -1250,2 +1292,4 @@ if (isNil(get(jsonGraph, 'json'))) { | ||
value: function destroy$$1(entityName) { | ||
var _this2 = this; | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
@@ -1266,2 +1310,10 @@ | ||
return this.falcor.call(destroyPath).then(function () { | ||
var pathsToInvalidate = isFunction(entity.invalidateAfterDestroy) ? entity.invalidateAfterDestroy(options) : invalidateAfterDestroy$1(entity, options); | ||
if (!isEmpty(pathsToInvalidate)) { | ||
forEach(pathsToInvalidate, function (path) { | ||
_this2.falcor.invalidate(path); | ||
}); | ||
} | ||
return 'Entity destroyed'; | ||
@@ -1268,0 +1320,0 @@ }).catch(function (response) { |
{ | ||
"name": "supergloo", | ||
"version": "0.21.0", | ||
"version": "0.22.0-rc.1", | ||
"description": "Easily work with data on the Gloo platform", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
272888
8187