Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return regeneratorRuntime.mark(function _crudSaga() {
return regeneratorRuntime.wrap(function _crudSaga$(_context9) {
while (1) {
switch (_context9.prev = _context9.next) {
case 0:
_context9.next = 2;
return (0, _effects.all)([(0, _effects.fork)(watchFetch(apiClient)), (0, _effects.fork)(watchFetchOne(apiClient)), (0, _effects.fork)(watchCreate(apiClient)), (0, _effects.fork)(watchUpdate(apiClient)), (0, _effects.fork)(watchDelete(apiClient)), (0, _effects.fork)(watchApiCall(apiClient)), (0, _effects.fork)(garbageCollector)]);
case 2:
case 'end':
return _context9.stop();
}
}
}, _crudSaga, this);
});
}
function updateDocumentOnServerWorker(action) {
var className, objectId, keys, parseDataBeforeSave, objectToUpdate, imputableData, res, errType;
return regeneratorRuntime.wrap(function updateDocumentOnServerWorker$(context$1$0) {
while (1) switch (context$1$0.prev = context$1$0.next) {
case 0:
className = action.className;
objectId = action.objectId;
keys = action.keys;
parseDataBeforeSave = action.parseDataBeforeSave;
if (objectId) {
context$1$0.next = 6;
break;
}
return context$1$0.abrupt('return');
case 6:
context$1$0.next = 8;
function getDocument(action) {
var className, objectId, include, res, errType, data;
return regeneratorRuntime.wrap(function getDocument$(context$1$0) {
while (1) switch (context$1$0.prev = context$1$0.next) {
case 0:
className = action.className;
objectId = action.objectId;
include = action.include;
context$1$0.next = 5;
return (0, _reduxSagaEffects.put)((0, _actions.setDocumentStatus)(objectId, START));
case 5:
return context$1$0.delegateYield((0, _serverApiSagaWrapper.httpRequest)(_serverApi2['default'].query, className, { objectId: objectId }, null, null, null, null, include, null), 't0', 6);
case 6:
res = context$1$0.t0;
if (!res.error) {
context$1$0.next = 14;
return regeneratorRuntime.mark(function _watchUpdate() {
return regeneratorRuntime.wrap(function _watchUpdate$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
_context6.next = 2;
return (0, _effects.takeEvery)(_actionTypes.UPDATE, apiGeneric(apiClient));
case 2:
case 'end':
return _context6.stop();
}
}
}, _watchUpdate, this);
});
};
function updateDocumentFromCollection(action) {
var collectionName, objectId, data, targetName, res, errType;
return regeneratorRuntime.wrap(function updateDocumentFromCollection$(context$1$0) {
while (1) switch (context$1$0.prev = context$1$0.next) {
case 0:
collectionName = action.collectionName;
objectId = action.objectId;
data = action.data;
targetName = action.targetName || action.collectionName;
context$1$0.next = 6;
return (0, _reduxSagaEffects.put)((0, _actions.setStatus)(targetName, START));
case 6:
return context$1$0.delegateYield((0, _serverApiSagaWrapper.httpRequest)(_serverApi2['default'].updateObject, collectionName, objectId, data), 't0', 7);
case 7:
res = context$1$0.t0;
if (!res.error) {
return regeneratorRuntime.mark(function _watchFetch() {
return regeneratorRuntime.wrap(function _watchFetch$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return (0, _effects.takeEvery)(_actionTypes.FETCH, apiGeneric(apiClient));
case 2:
case 'end':
return _context3.stop();
}
}
}, _watchFetch, this);
});
};
function deleteDocument(action) {
var className, objectId, res, errType;
return regeneratorRuntime.wrap(function deleteDocument$(context$1$0) {
while (1) switch (context$1$0.prev = context$1$0.next) {
case 0:
className = action.className;
objectId = action.objectId;
context$1$0.next = 4;
return (0, _reduxSagaEffects.put)((0, _actions.setDocumentStatus)(objectId, START));
case 4:
return context$1$0.delegateYield((0, _serverApiSagaWrapper.httpRequest)(_serverApi2['default'].deleteObject, className, objectId), 't0', 5);
case 5:
res = context$1$0.t0;
if (!res.error) {
context$1$0.next = 12;
break;
return regeneratorRuntime.mark(function _watchApiCall() {
return regeneratorRuntime.wrap(function _watchApiCall$(_context8) {
while (1) {
switch (_context8.prev = _context8.next) {
case 0:
_context8.next = 2;
return (0, _effects.takeEvery)(_actionTypes.API_CALL, apiGeneric(apiClient));
case 2:
case 'end':
return _context8.stop();
}
}
}, _watchApiCall, this);
});
};
var garbageCollector = regeneratorRuntime.mark(function garbageCollector() {
return regeneratorRuntime.wrap(function garbageCollector$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return (0, _effects.call)(delay, _cachePeriod.cachePeriod);
case 2:
_context.next = 4;
return (0, _effects.call)(delay, _cachePeriod.halfCachePeriod);
case 4:
_context.next = 6;
return (0, _effects.put)({ type: _actionTypes.GARBAGE_COLLECT, meta: { now: Date.now() } });
case 6:
_context.next = 2;