Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jfront/core-redux-saga

Package Overview
Dependencies
Maintainers
4
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jfront/core-redux-saga - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

dist/cjs/slice/createSessionSearchSlice.js

18

CHANGELOG.md

@@ -6,2 +6,20 @@ # Change Log

# [0.4.0](https://github.com/Jepria/jfront-core/compare/@jfront/core-redux-saga@0.3.0...@jfront/core-redux-saga@0.4.0) (2021-03-22)
### Bug Fixes
* create event not working in React 17 without cancelable and bubbles properties ([4de1314](https://github.com/Jepria/jfront-core/commit/4de13140b7fe94dddb4a71f71113b0e9c03ec3b0))
* remove unused ([67623d3](https://github.com/Jepria/jfront-core/commit/67623d324671fa8e44f36f988668768abf994f8c))
* remove unused functions ([166de4d](https://github.com/Jepria/jfront-core/commit/166de4d85ae354313e8669ec9eac39f8280ece41))
### Features
* add SearchSlice ([f14e8c2](https://github.com/Jepria/jfront-core/commit/f14e8c2134ace07c02b33d6a96d1d936b65f3b36))
# [0.3.0](https://github.com/Jepria/jfront-core/compare/@jfront/core-redux-saga@0.2.2...@jfront/core-redux-saga@0.3.0) (2021-03-17)

@@ -8,0 +26,0 @@

@@ -13,2 +13,10 @@ "use strict";

var _createSessionSearchSlice = require("./slice/createSessionSearchSlice");
Object.keys(_createSessionSearchSlice).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _createSessionSearchSlice[key]) return;
exports[key] = _createSessionSearchSlice[key];
});
var _createSearchSlice = require("./slice/createSearchSlice");

@@ -15,0 +23,0 @@

255

dist/cjs/slice/createSearchSlice.js

@@ -26,19 +26,3 @@ "use strict";

state.searchRequest = action.payload.searchTemplate;
state.searchId = undefined;
},
postSearchRequest: function postSearchRequest(state, action) {
state.isLoading = true;
state.searchId = undefined;
},
postSearchRequestSuccess: function postSearchRequestSuccess(state, action) {
state.isLoading = false;
state.searchRequest = action.payload.searchTemplate;
state.searchId = action.payload.searchId;
},
getResultSet: function getResultSet(state, action) {
state.isLoading = true;
state.pageNumber = action.payload.pageNumber;
state.pageSize = action.payload.pageSize;
state.records = [];
},
search: function search(state, action) {

@@ -60,5 +44,2 @@ state.isLoading = true;

},
postSearch: function postSearch(state, action) {
state.isLoading = true;
},
failure: function failure(state, action) {

@@ -75,6 +56,3 @@ state.isLoading = false;

var _marked = /*#__PURE__*/regeneratorRuntime.mark(setSearchTemplate),
_marked2 = /*#__PURE__*/regeneratorRuntime.mark(postSearchRequest),
_marked3 = /*#__PURE__*/regeneratorRuntime.mark(search),
_marked4 = /*#__PURE__*/regeneratorRuntime.mark(getResultSet),
_marked5 = /*#__PURE__*/regeneratorRuntime.mark(postSearch);
_marked2 = /*#__PURE__*/regeneratorRuntime.mark(search);

@@ -102,66 +80,10 @@ function setSearchTemplate(action) {

function postSearchRequest(action) {
var searchId, result;
return regeneratorRuntime.wrap(function postSearchRequest$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.prev = 0;
_context2.next = 3;
return (0, _effects.call)(api.postSearchRequest, action.payload.searchTemplate);
case 3:
searchId = _context2.sent;
result = {
searchId: searchId,
searchTemplate: action.payload.searchTemplate
};
_context2.next = 7;
return (0, _effects.put)(actions.postSearchRequestSuccess(result));
case 7:
if (!action.payload.onSuccess) {
_context2.next = 10;
break;
}
_context2.next = 10;
return (0, _effects.call)(action.payload.onSuccess, result);
case 10:
return _context2.abrupt("return", result);
case 13:
_context2.prev = 13;
_context2.t0 = _context2["catch"](0);
_context2.next = 17;
return (0, _effects.put)(actions.failure({
error: _context2.t0
}));
case 17:
if (!action.payload.onFailure) {
_context2.next = 20;
break;
}
_context2.next = 20;
return (0, _effects.call)(action.payload.onFailure, _context2.t0);
case 20:
case "end":
return _context2.stop();
}
}
}, _marked2, null, [[0, 13]]);
}
function search(action) {
var _action$payload$searc, query, result;
return regeneratorRuntime.wrap(function search$(_context3) {
return regeneratorRuntime.wrap(function search$(_context2) {
while (1) {
switch (_context3.prev = _context3.next) {
switch (_context2.prev = _context2.next) {
case 0:
_context3.prev = 0;
_context2.prev = 0;
query = new URLSearchParams(_extends({}, action.payload.searchTemplate.template, {

@@ -174,8 +96,8 @@ page: String(action.payload.pageNumber),

});
_context3.next = 5;
_context2.next = 5;
return (0, _effects.call)(api.search, query.toString());
case 5:
result = _context3.sent;
_context3.next = 8;
result = _context2.sent;
_context2.next = 8;
return (0, _effects.put)(actions.searchSuccess({

@@ -188,7 +110,7 @@ records: result.data,

if (!action.payload.onSuccess) {
_context3.next = 11;
_context2.next = 11;
break;
}
_context3.next = 11;
_context2.next = 11;
return (0, _effects.call)(action.payload.onSuccess, {

@@ -200,11 +122,11 @@ records: result.data,

case 11:
_context3.next = 20;
_context2.next = 20;
break;
case 13:
_context3.prev = 13;
_context3.t0 = _context3["catch"](0);
_context3.next = 17;
_context2.prev = 13;
_context2.t0 = _context2["catch"](0);
_context2.next = 17;
return (0, _effects.put)(actions.failure({
error: _context3.t0
error: _context2.t0
}));

@@ -214,153 +136,40 @@

if (!action.payload.onFailure) {
_context3.next = 20;
_context2.next = 20;
break;
}
_context3.next = 20;
return (0, _effects.call)(action.payload.onFailure, _context3.t0);
_context2.next = 20;
return (0, _effects.call)(action.payload.onFailure, _context2.t0);
case 20:
case "end":
return _context3.stop();
return _context2.stop();
}
}
}, _marked3, null, [[0, 13]]);
}, _marked2, null, [[0, 13]]);
}
function getResultSet(action) {
var records, resultSetSize;
return regeneratorRuntime.wrap(function getResultSet$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_context4.prev = 0;
_context4.next = 3;
return (0, _effects.call)(api.getResultSet, action.payload.searchId, action.payload.pageSize, action.payload.pageNumber);
case 3:
records = _context4.sent;
_context4.next = 6;
return (0, _effects.call)(api.getResultSetSize, action.payload.searchId);
case 6:
resultSetSize = _context4.sent;
_context4.next = 9;
return (0, _effects.put)(actions.searchSuccess({
records: records,
resultSetSize: resultSetSize
}));
case 9:
if (!action.payload.onSuccess) {
_context4.next = 12;
break;
}
_context4.next = 12;
return (0, _effects.call)(action.payload.onSuccess, {
records: records,
resultSetSize: resultSetSize
});
case 12:
_context4.next = 21;
break;
case 14:
_context4.prev = 14;
_context4.t0 = _context4["catch"](0);
_context4.next = 18;
return (0, _effects.put)(actions.failure({
error: _context4.t0
}));
case 18:
if (!action.payload.onFailure) {
_context4.next = 21;
break;
}
_context4.next = 21;
return (0, _effects.call)(action.payload.onFailure, _context4.t0);
case 21:
case "end":
return _context4.stop();
}
}
}, _marked4, null, [[0, 14]]);
}
function postSearch(action) {
var payload;
return regeneratorRuntime.wrap(function postSearch$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
_context5.next = 2;
return (0, _effects.call)(postSearchRequest, {
type: actions.postSearchRequest.type,
payload: {
searchTemplate: action.payload.searchTemplate,
onFailure: action.payload.onFailure
}
});
case 2:
payload = _context5.sent;
_context5.next = 5;
return (0, _effects.put)(actions.getResultSet({
searchId: payload.searchId,
pageSize: action.payload.pageSize,
page: action.payload.pageNumber,
onSuccess: action.payload.onSuccess,
onFailure: action.payload.onFailure
}));
case 5:
case "end":
return _context5.stop();
}
}
}, _marked5);
}
return /*#__PURE__*/regeneratorRuntime.mark(function saga() {
return regeneratorRuntime.wrap(function saga$(_context6) {
return regeneratorRuntime.wrap(function saga$(_context3) {
while (1) {
switch (_context6.prev = _context6.next) {
switch (_context3.prev = _context3.next) {
case 0:
_context6.t0 = _effects.all;
_context6.next = 3;
_context3.t0 = _effects.all;
_context3.next = 3;
return (0, _effects.takeEvery)(actions.setSearchTemplate.type, setSearchTemplate);
case 3:
_context6.t1 = _context6.sent;
_context6.next = 6;
return (0, _effects.takeLatest)(actions.postSearchRequest.type, postSearchRequest);
_context3.t1 = _context3.sent;
_context3.next = 6;
return (0, _effects.takeLatest)(actions.search.type, search);
case 6:
_context6.t2 = _context6.sent;
_context6.next = 9;
return (0, _effects.takeLatest)(actions.getResultSet.type, getResultSet);
_context3.t2 = _context3.sent;
_context3.t3 = [_context3.t1, _context3.t2];
_context3.next = 10;
return (0, _context3.t0)(_context3.t3);
case 9:
_context6.t3 = _context6.sent;
_context6.next = 12;
return (0, _effects.takeLatest)(actions.search.type, search);
case 12:
_context6.t4 = _context6.sent;
_context6.next = 15;
return (0, _effects.takeLatest)(actions.postSearch.type, postSearch);
case 15:
_context6.t5 = _context6.sent;
_context6.t6 = [_context6.t1, _context6.t2, _context6.t3, _context6.t4, _context6.t5];
_context6.next = 19;
return (0, _context6.t0)(_context6.t6);
case 19:
case 10:
case "end":
return _context6.stop();
return _context3.stop();
}

@@ -367,0 +176,0 @@ }

export * from "./slice/createCrudSlice";
export * from "./slice/createSessionSearchSlice";
export * from "./slice/createSearchSlice";

@@ -3,0 +4,0 @@ export * from "./slice/createOptionsSlice";

@@ -18,23 +18,4 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

state.searchRequest = action.payload.searchTemplate;
state.searchId = undefined;
},
postSearchRequest(state, action) {
state.isLoading = true;
state.searchId = undefined;
},
postSearchRequestSuccess(state, action) {
state.isLoading = false;
state.searchRequest = action.payload.searchTemplate;
state.searchId = action.payload.searchId;
},
getResultSet(state, action) {
state.isLoading = true;
state.pageNumber = action.payload.pageNumber;
state.pageSize = action.payload.pageSize;
state.records = [];
},
search(state, action) {

@@ -58,6 +39,2 @@ state.isLoading = true;

postSearch(state, action) {
state.isLoading = true;
},
failure(state, action) {

@@ -80,27 +57,2 @@ state.isLoading = false;

function* postSearchRequest(action) {
try {
var searchId = yield call(api.postSearchRequest, action.payload.searchTemplate);
var result = {
searchId,
searchTemplate: action.payload.searchTemplate
};
yield put(actions.postSearchRequestSuccess(result));
if (action.payload.onSuccess) {
yield call(action.payload.onSuccess, result);
}
return result;
} catch (error) {
yield put(actions.failure({
error
}));
if (action.payload.onFailure) {
yield call(action.payload.onFailure, error);
}
}
}
function* search(action) {

@@ -138,47 +90,4 @@ try {

function* getResultSet(action) {
try {
var records = yield call(api.getResultSet, action.payload.searchId, action.payload.pageSize, action.payload.pageNumber);
var resultSetSize = yield call(api.getResultSetSize, action.payload.searchId);
yield put(actions.searchSuccess({
records,
resultSetSize
}));
if (action.payload.onSuccess) {
yield call(action.payload.onSuccess, {
records,
resultSetSize
});
}
} catch (error) {
yield put(actions.failure({
error
}));
if (action.payload.onFailure) {
yield call(action.payload.onFailure, error);
}
}
}
function* postSearch(action) {
var payload = yield call(postSearchRequest, {
type: actions.postSearchRequest.type,
payload: {
searchTemplate: action.payload.searchTemplate,
onFailure: action.payload.onFailure
}
});
yield put(actions.getResultSet({
searchId: payload.searchId,
pageSize: action.payload.pageSize,
page: action.payload.pageNumber,
onSuccess: action.payload.onSuccess,
onFailure: action.payload.onFailure
}));
}
return function* saga() {
yield all([yield takeEvery(actions.setSearchTemplate.type, setSearchTemplate), yield takeLatest(actions.postSearchRequest.type, postSearchRequest), yield takeLatest(actions.getResultSet.type, getResultSet), yield takeLatest(actions.search.type, search), yield takeLatest(actions.postSearch.type, postSearch)]);
yield all([yield takeEvery(actions.setSearchTemplate.type, setSearchTemplate), yield takeLatest(actions.search.type, search)]);
};

@@ -185,0 +94,0 @@ };

export * from "./slice/createCrudSlice";
export * from "./slice/createSessionSearchSlice";
export * from "./slice/createSearchSlice";

@@ -3,0 +4,0 @@ export * from "./slice/createOptionsSlice";

import { ActionReducerMapBuilder, CaseReducers, PayloadAction, SliceCaseReducers, ValidateSliceCaseReducers } from "@reduxjs/toolkit";
import { ConnectorSearch } from "@jfront/core-rest";
import { FailureAction } from "../action/actionTypes";
import { GetResultSetAction, PostSearchAction, PostSearchRequestAction, PostSearchRequestSuccessAction, SearchAction, SearchSuccessAction, SetSearchTemplateAction } from "../action/searchActionTypes";
import { SearchAction, SearchSuccessAction, SetSearchTemplateAction } from "../action/searchActionTypes";
import { SearchState } from "../types";

@@ -19,14 +19,2 @@ declare type NoInfer<T> = [T][T extends any ? 0 : never];

}): void;
postSearchRequest(state: S, action: {
payload: PostSearchRequestAction<SearchTemplate>;
type: string;
}): void;
postSearchRequestSuccess(state: S, action: {
payload: PostSearchRequestSuccessAction<SearchTemplate>;
type: string;
}): void;
getResultSet(state: S, action: {
payload: GetResultSetAction<Entity>;
type: string;
}): void;
search(state: S, action: {

@@ -40,6 +28,2 @@ payload: SearchAction<SearchTemplate, Entity>;

}): void;
postSearch(state: S, action: {
payload: PostSearchAction<SearchTemplate, Entity>;
type: string;
}): void;
failure(state: S, action: PayloadAction<FailureAction<any>>): void;

@@ -52,4 +36,4 @@ } & Reducers & { [T in keyof Reducers]: Reducers[T] extends {

reducer: import("redux").Reducer<S, import("redux").AnyAction>;
createSagaMiddleware: (api: ConnectorSearch<Entity, SearchTemplate>) => () => Generator<import("redux-saga/effects").ForkEffect<never> | import("redux-saga/effects").AllEffect<any>, void, any>;
createSagaMiddleware: (api: ConnectorSearch<Entity>) => () => Generator<import("redux-saga/effects").ForkEffect<never> | import("redux-saga/effects").AllEffect<any>, void, any>;
};
export {};

@@ -8,3 +8,3 @@ import { SearchRequest } from "@jfront/core-rest";

};
export declare type SearchState<V, T> = {
export declare type SessionSearchState<V, T> = {
isLoading: boolean;

@@ -19,1 +19,10 @@ searchId?: string;

};
export declare type SearchState<V, T> = {
isLoading: boolean;
searchRequest?: SearchRequest<V>;
pageSize: number;
pageNumber: number;
resultSetSize?: number;
records: T[];
error?: any;
};
{
"name": "@jfront/core-redux-saga",
"version": "0.3.0",
"version": "0.4.0",
"license": "Apache-2.0",

@@ -28,3 +28,3 @@ "main": "dist/cjs/index.js",

"dependencies": {
"@jfront/core-rest": "^0.2.0"
"@jfront/core-rest": "^0.3.0"
},

@@ -36,3 +36,3 @@ "peerDependencies": {

},
"gitHead": "a3b37ba23f7034943f6488ebb854614671dcda2e"
"gitHead": "0cb708272c99ab71b8cb61324ef96af07f6a2f4d"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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