cape-firebase
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -18,2 +18,4 @@ 'use strict'; | ||
var _reduxGraph = require('redux-graph'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -34,5 +36,5 @@ | ||
var SAVE_TRIPLE = exports.SAVE_TRIPLE = 'fire/SAVE_TRIPLE'; | ||
var saveTriple = exports.saveTriple = (0, _capeRedux.createSimpleAction)(SAVE_TRIPLE, _identity3.default, (0, _nthArg3.default)(1)); | ||
var saveTriple = exports.saveTriple = (0, _capeRedux.createSimpleAction)(SAVE_TRIPLE, _reduxGraph.buildTriple, (0, _nthArg3.default)(1)); | ||
var UPLOAD_FILE = exports.UPLOAD_FILE = 'fire/UPLOAD_FILE'; | ||
var uploadFile = exports.uploadFile = (0, _capeRedux.createAction)(UPLOAD_FILE); |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.onChildChanged = exports.getWatchChild = exports.onChild = exports.getChild = exports.ensureIdType = exports.authUsr = exports.userEntity = exports.userFields = undefined; | ||
exports.onChildChanged = exports.getWatchChild = exports.onChild = exports.getChild = exports.entityPath = exports.ensureIdType = exports.authUsr = exports.userEntity = exports.userFields = undefined; | ||
@@ -17,2 +17,6 @@ var _pick2 = require('lodash/fp/pick'); | ||
var _join2 = require('lodash/fp/join'); | ||
var _join3 = _interopRequireDefault(_join2); | ||
var _zipObject2 = require('lodash/zipObject'); | ||
@@ -26,2 +30,6 @@ | ||
var _get2 = require('lodash/get'); | ||
var _get3 = _interopRequireDefault(_get2); | ||
var _flow2 = require('lodash/flow'); | ||
@@ -42,3 +50,2 @@ | ||
exports.entityDb = entityDb; | ||
exports.entityPath = entityPath; | ||
exports.getValue = getValue; | ||
@@ -49,2 +56,3 @@ exports.getDbEntity = getDbEntity; | ||
exports.entityUpdate = entityUpdate; | ||
exports.getTriplePath = getTriplePath; | ||
exports.triplePut = triplePut; | ||
@@ -80,8 +88,4 @@ exports.arrayTrueObj = arrayTrueObj; | ||
} | ||
function entityPath(item) { | ||
var field = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
var entityPath = exports.entityPath = (0, _flow3.default)(_reduxGraph.getPath, (0, _join3.default)('/')); | ||
return item.type + '/' + item.id + '/' + field; | ||
} | ||
function getValue(method, db, id) { | ||
@@ -130,3 +134,8 @@ return db.child(id)[method]('value').then(function (res) { | ||
} | ||
function getTriplePath(subject, predicate, object, single) { | ||
return (0, _reduxGraph.fullRefPath)(subject, predicate, single ? null : object).join('/'); | ||
} | ||
// Use action instead of calling this directly. | ||
// Save refs to subject. | ||
function triplePut(_ref2, _ref3) { | ||
@@ -141,17 +150,16 @@ var _updateObj; | ||
// Payload needs to be a have triple style object props. | ||
var triple = (0, _reduxGraph.buildTriple)(payload); | ||
var subject = triple.subject, | ||
predicate = triple.predicate, | ||
object = triple.object; | ||
var subject = payload.subject, | ||
predicate = payload.predicate, | ||
object = payload.object, | ||
single = payload.single; | ||
var path = _reduxGraph.REFS + '/' + predicate + '/' + (0, _reduxGraph.getKey)(object); | ||
var updateObj = (_updateObj = {}, _defineProperty(_updateObj, entityPath(subject, path), object), _defineProperty(_updateObj, entityPath(subject, 'dateModified'), TIMESTAMP), _updateObj); | ||
var updateObj = (_updateObj = {}, _defineProperty(_updateObj, getTriplePath(subject, predicate, object, single), object), _defineProperty(_updateObj, entityPath(subject, 'dateModified'), TIMESTAMP), _updateObj); | ||
// Allow a previously linked subject to change. | ||
if (meta && meta.previousSubject) { | ||
var prevSubj = meta.previousSubject; | ||
updateObj[entityPath(prevSubj, path)] = null; | ||
var prevSubj = (0, _get3.default)(meta, 'previousSubject'); | ||
if (prevSubj) { | ||
updateObj[getTriplePath(prevSubj, predicate, object, single)] = null; | ||
updateObj[entityPath(prevSubj, 'dateModified')] = TIMESTAMP; | ||
} | ||
return entity.update(updateObj).then(function () { | ||
return triple; | ||
return payload; | ||
}); | ||
@@ -158,0 +166,0 @@ } |
{ | ||
"name": "cape-firebase", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "Help integrate CAPE redux projects with Firebase.", | ||
@@ -23,3 +23,3 @@ "main": "lib/index", | ||
"redux-field": "^4.4.1", | ||
"redux-graph": "^2.10.0" | ||
"redux-graph": "^2.11.0" | ||
}, | ||
@@ -26,0 +26,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
117490
455
Updatedredux-graph@^2.11.0