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

@codetanzania/emis-api-states

Package Overview
Dependencies
Maintainers
2
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codetanzania/emis-api-states - npm Package Compare versions

Comparing version 0.12.0 to 0.12.1

110

es/index.js

@@ -141,24 +141,24 @@ import forIn from 'lodash/forIn';

return {
[camelize('select', singular)]: (state, action) => Object.assign({}, state, {
[camelize('select', singular)]: (state, action) => ({ ...state,
selected: action.payload
}),
[camelize('filter', plural)]: (state, action) => Object.assign({}, state, {
[camelize('filter', plural)]: (state, action) => ({ ...state,
filter: action.payload
}),
[camelize('sort', plural)]: (state, action) => Object.assign({}, state, {
[camelize('sort', plural)]: (state, action) => ({ ...state,
sort: action.payload
}),
[camelize('search', plural)]: (state, action) => Object.assign({}, state, {
[camelize('search', plural)]: (state, action) => ({ ...state,
q: action.payload
}),
[camelize('clear', plural, 'filters')]: state => Object.assign({}, state, {
[camelize('clear', plural, 'filters')]: state => ({ ...state,
filters: null
}),
[camelize('clear', plural, 'sort')]: state => Object.assign({}, state, {
[camelize('clear', plural, 'sort')]: state => ({ ...state,
sort: null
}),
[camelize('get', plural, 'Request')]: state => Object.assign({}, state, {
[camelize('get', plural, 'Request')]: state => ({ ...state,
loading: true
}),
[camelize('get', plural, 'Success')]: (state, action) => Object.assign({}, state, {
[camelize('get', plural, 'Success')]: (state, action) => ({ ...state,
list: [...action.payload.data],

@@ -170,55 +170,55 @@ page: action.payload.page,

}),
[camelize('get', plural, 'Failure')]: (state, action) => Object.assign({}, state, {
[camelize('get', plural, 'Failure')]: (state, action) => ({ ...state,
error: action.payload,
loading: false
}),
[camelize('get', singular, 'Request')]: state => Object.assign({}, state, {
[camelize('get', singular, 'Request')]: state => ({ ...state,
loading: true
}),
[camelize('get', singular, 'Success')]: state => Object.assign({}, state, {
[camelize('get', singular, 'Success')]: state => ({ ...state,
loading: false
}),
[camelize('get', singular, 'Failure')]: (state, action) => Object.assign({}, state, {
[camelize('get', singular, 'Failure')]: (state, action) => ({ ...state,
loading: false,
error: action.payload
}),
[camelize('post', singular, 'Request')]: state => Object.assign({}, state, {
[camelize('post', singular, 'Request')]: state => ({ ...state,
posting: true
}),
[camelize('post', singular, 'Success')]: state => Object.assign({}, state, {
[camelize('post', singular, 'Success')]: state => ({ ...state,
posting: false,
showForm: false
}),
[camelize('post', singular, 'Failure')]: (state, action) => Object.assign({}, state, {
[camelize('post', singular, 'Failure')]: (state, action) => ({ ...state,
error: action.payload,
posting: false
}),
[camelize('put', singular, 'Request')]: state => Object.assign({}, state, {
[camelize('put', singular, 'Request')]: state => ({ ...state,
posting: true
}),
[camelize('put', singular, 'Success')]: state => Object.assign({}, state, {
[camelize('put', singular, 'Success')]: state => ({ ...state,
posting: false,
showForm: false
}),
[camelize('put', singular, 'Failure')]: (state, action) => Object.assign({}, state, {
[camelize('put', singular, 'Failure')]: (state, action) => ({ ...state,
posting: false,
error: action.payload
}),
[camelize('delete', singular, 'Request')]: state => Object.assign({}, state, {
[camelize('delete', singular, 'Request')]: state => ({ ...state,
posting: true
}),
[camelize('delete', singular, 'Success')]: state => Object.assign({}, state, {
[camelize('delete', singular, 'Success')]: state => ({ ...state,
posting: false
}),
[camelize('delete', singular, 'Failure')]: (state, action) => Object.assign({}, state, {
[camelize('delete', singular, 'Failure')]: (state, action) => ({ ...state,
posting: false,
error: action.payload
}),
[camelize('open', singular, 'Form')]: state => Object.assign({}, state, {
[camelize('open', singular, 'Form')]: state => ({ ...state,
showForm: true
}),
[camelize('close', singular, 'Form')]: state => Object.assign({}, state, {
[camelize('close', singular, 'Form')]: state => ({ ...state,
showForm: false
}),
[camelize('set', singular, 'Schema')]: (state, action) => Object.assign({}, state, {
[camelize('set', singular, 'Schema')]: (state, action) => ({ ...state,
schema: action.payload

@@ -266,3 +266,3 @@ })

*
* @version 0.1.0
* @version 0.1.1
* @since 0.1.0

@@ -284,3 +284,3 @@ */

return createSlice({
slice: sliceName,
name: sliceName,
initialState: initialDefaultState,

@@ -344,39 +344,39 @@ reducers: defaultReducers

case INITIALIZE_APP_START:
return Object.assign({}, state, {
return { ...state,
loading: true
});
};
case INITIALIZE_APP_SUCCESS:
return Object.assign({}, state, {
return { ...state,
loading: false
});
};
case INITIALIZE_APP_FAILURE:
return Object.assign({}, state, {
return { ...state,
loading: false,
error: action.payload
});
};
case SIGNIN_APP_START:
return Object.assign({}, state, {
return { ...state,
signing: true
});
};
case SIGNIN_APP_SUCCESS:
return Object.assign({}, state, {
return { ...state,
party: action.payload,
signing: false
});
};
case SIGNIN_APP_FAILURE:
return Object.assign({}, state, {
return { ...state,
error: action.payload,
signing: false
});
};
case SIGNOUT:
return Object.assign({}, state, {
return { ...state,
error: null,
party: null
});
};

@@ -404,4 +404,4 @@ default:

/**
* @name createThunkFor
* @function
* @name createThunkFor
* @description Create and expose all common thunks for a resource.

@@ -427,3 +427,3 @@ *

* @function
* @name get<Resource Plural Name>
* @name getResources
* @description A thunk that will be dispatched when fetching data from API

@@ -461,3 +461,3 @@ *

* @function
* @name get<Resource Singular Name>
* @name getResource
* @description A thunk that will be dispatched when fetching

@@ -497,3 +497,3 @@ * single resource data from the API

* @function
* @name post<Resource Singular Name>
* @name postResource
* @description A thunk that will be dispatched when creating a single

@@ -537,3 +537,3 @@ * resource data in the API

* @function
* @name put<Resource Singular Name>
* @name putResource
* @description A thunk that will be dispatched when updating a single

@@ -577,3 +577,3 @@ * resource data in the API

* @function
* @name delete<Resource Singular Name>
* @name deleteResource
* @description A thunk that will be dispatched when deleting/archiving

@@ -622,3 +622,3 @@ * a single resource data in the API

* @function
* @name fetch<Resource Name>
* @name fetchResource
* @description A thunk that for fetching data from the API the difference

@@ -632,3 +632,3 @@ * between this and get thunk is this will apply all the criteria on fetch.

* resources from the API fails
*
* @returns {Function} Thunk function
* @version 0.1.0

@@ -655,3 +655,3 @@ * @since 0.1.0

* @function
* @name filter<Resource Plural Name>
* @name filterResources
* @description A thunk that will be dispatched when filtering resources

@@ -680,3 +680,3 @@ * data in the API

* @function
* @name refresh<Resource Plural Name>
* @name refreshResources
* @description A thunk that will be dispatched when refreshing resources

@@ -710,3 +710,3 @@ * data in the API

* @function
* @name search<Resource Plural Name>
* @name searchResources
* @description A thunk that will be dispatched when searching resources

@@ -739,3 +739,3 @@ * data in the API

* @function
* @name sort<Resource Plural Name>
* @name sortResources
* @description A thunk that will be dispatched when sorting resources

@@ -768,3 +768,3 @@ * data in the API

* @function
* @name paginate<Resource Plural Name>
* @name paginateResources
* @description A thunk that will be dispatched when paginating resources

@@ -798,3 +798,3 @@ * data in the API

* @function
* @name clear<Resource Singular Name>Filters
* @name clearResourceFilters
* @description A thunk that will be dispatched when clearing filters on

@@ -828,3 +828,3 @@ * resources data in the API

* @function
* @name clear<Resource Plural Name>Sort
* @name clearResourcesSort
* @description A thunk that will be dispatched when clearing sort order on

@@ -831,0 +831,0 @@ * resources data in the API

{
"name": "@codetanzania/emis-api-states",
"version": "0.12.0",
"version": "0.12.1",
"description": "EMIS Redux state management library",

@@ -12,3 +12,3 @@ "main": "lib/index.js",

"lint": "eslint --fix --ext .jsx,.js src/ test/",
"build": "npm run clean && npm run lint && BABEL_ENV=production rollup -c",
"build": "npm run clean && npm run lint && npm test && BABEL_ENV=production rollup -c",
"commit": "git-cz",

@@ -53,44 +53,44 @@ "commit:all": "git add -A && git-cz",

"dependencies": {
"@codetanzania/emis-api-client": ">=0.16.2",
"@codetanzania/emis-api-client": ">=0.16.3",
"axios": ">=0.19.0",
"inflection": ">=1.12.0",
"lodash": ">=4.17.11",
"lodash": ">=4.17.15",
"prop-types": ">=15.7.2",
"react": ">=16.8.6",
"react-redux": ">=7.1.0",
"redux": ">=4.0.1",
"redux-starter-kit": ">=0.5.1",
"react": ">=16.11.0",
"react-redux": ">=7.1.1",
"redux": ">=4.0.4",
"redux-starter-kit": ">=1.0.1",
"redux-thunk": ">=2.3.0"
},
"devDependencies": {
"@babel/core": "7.4.5",
"@babel/preset-env": "7.4.5",
"@babel/preset-react": "7.0.0",
"@commitlint/cli": "8.0.0",
"@commitlint/config-conventional": "8.0.0",
"@commitlint/travis-cli": "8.0.0",
"@testing-library/react": "8.0.1",
"babel-eslint": "10.0.2",
"babel-jest": "24.8.0",
"commitizen": "3.1.1",
"cz-conventional-changelog": "2.1.0",
"eslint": "5.16.0",
"eslint-config-airbnb": "17.1.0",
"eslint-config-prettier": "5.0.0",
"eslint-plugin-import": "2.17.3",
"eslint-plugin-jest": "22.6.4",
"eslint-plugin-jsdoc": "8.1.0",
"eslint-plugin-jsx-a11y": "6.2.1",
"eslint-plugin-prettier": "3.1.0",
"eslint-plugin-react": "7.13.0",
"@babel/core": "7.6.4",
"@babel/preset-env": "7.6.3",
"@babel/preset-react": "7.6.3",
"@commitlint/cli": "8.2.0",
"@commitlint/config-conventional": "8.2.0",
"@commitlint/travis-cli": "8.2.0",
"@testing-library/react": "9.3.1",
"babel-eslint": "10.0.3",
"babel-jest": "24.9.0",
"commitizen": "4.0.3",
"cz-conventional-changelog": "3.0.2",
"eslint": "6.6.0",
"eslint-config-airbnb": "18.0.1",
"eslint-config-prettier": "6.5.0",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-jest": "23.0.2",
"eslint-plugin-jsdoc": "17.0.1",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-prettier": "3.1.1",
"eslint-plugin-react": "7.16.0",
"faker": "4.1.0",
"generate-changelog": "1.7.1",
"husky": "2.4.1",
"jest": "24.8.0",
"lint-staged": "8.2.1",
"generate-changelog": "1.8.0",
"husky": "3.0.9",
"jest": "24.9.0",
"lint-staged": "9.4.2",
"prettier": "1.18.2",
"react-dom": "16.8.6",
"react-dom": "16.11.0",
"redux-mock-store": "1.5.3",
"rollup": "1.15.6",
"rollup-plugin-babel": "4.3.2"
"rollup": "1.26.3",
"rollup-plugin-babel": "4.3.3"
},

@@ -97,0 +97,0 @@ "jest": {

@@ -23,56 +23,106 @@ import { pluralize, singularize } from 'inflection';

return {
[camelize('select', singular)]: (state, action) =>
Object.assign({}, state, { selected: action.payload }),
[camelize('filter', plural)]: (state, action) =>
Object.assign({}, state, { filter: action.payload }),
[camelize('sort', plural)]: (state, action) =>
Object.assign({}, state, { sort: action.payload }),
[camelize('search', plural)]: (state, action) =>
Object.assign({}, state, { q: action.payload }),
[camelize('clear', plural, 'filters')]: state =>
Object.assign({}, state, { filters: null }),
[camelize('clear', plural, 'sort')]: state =>
Object.assign({}, state, { sort: null }),
[camelize('get', plural, 'Request')]: state =>
Object.assign({}, state, { loading: true }),
[camelize('get', plural, 'Success')]: (state, action) =>
Object.assign({}, state, {
list: [...action.payload.data],
page: action.payload.page,
total: action.payload.total,
size: action.payload.size,
loading: false,
}),
[camelize('get', plural, 'Failure')]: (state, action) =>
Object.assign({}, state, { error: action.payload, loading: false }),
[camelize('get', singular, 'Request')]: state =>
Object.assign({}, state, { loading: true }),
[camelize('get', singular, 'Success')]: state =>
Object.assign({}, state, { loading: false }),
[camelize('get', singular, 'Failure')]: (state, action) =>
Object.assign({}, state, { loading: false, error: action.payload }),
[camelize('post', singular, 'Request')]: state =>
Object.assign({}, state, { posting: true }),
[camelize('post', singular, 'Success')]: state =>
Object.assign({}, state, { posting: false, showForm: false }),
[camelize('post', singular, 'Failure')]: (state, action) =>
Object.assign({}, state, { error: action.payload, posting: false }),
[camelize('put', singular, 'Request')]: state =>
Object.assign({}, state, { posting: true }),
[camelize('put', singular, 'Success')]: state =>
Object.assign({}, state, { posting: false, showForm: false }),
[camelize('put', singular, 'Failure')]: (state, action) =>
Object.assign({}, state, { posting: false, error: action.payload }),
[camelize('delete', singular, 'Request')]: state =>
Object.assign({}, state, { posting: true }),
[camelize('delete', singular, 'Success')]: state =>
Object.assign({}, state, { posting: false }),
[camelize('delete', singular, 'Failure')]: (state, action) =>
Object.assign({}, state, { posting: false, error: action.payload }),
[camelize('open', singular, 'Form')]: state =>
Object.assign({}, state, { showForm: true }),
[camelize('close', singular, 'Form')]: state =>
Object.assign({}, state, { showForm: false }),
[camelize('set', singular, 'Schema')]: (state, action) =>
Object.assign({}, state, { schema: action.payload }),
[camelize('select', singular)]: (state, action) => ({
...state,
selected: action.payload,
}),
[camelize('filter', plural)]: (state, action) => ({
...state,
filter: action.payload,
}),
[camelize('sort', plural)]: (state, action) => ({
...state,
sort: action.payload,
}),
[camelize('search', plural)]: (state, action) => ({
...state,
q: action.payload,
}),
[camelize('clear', plural, 'filters')]: state => ({
...state,
filters: null,
}),
[camelize('clear', plural, 'sort')]: state => ({ ...state, sort: null }),
[camelize('get', plural, 'Request')]: state => ({
...state,
loading: true,
}),
[camelize('get', plural, 'Success')]: (state, action) => ({
...state,
list: [...action.payload.data],
page: action.payload.page,
total: action.payload.total,
size: action.payload.size,
loading: false,
}),
[camelize('get', plural, 'Failure')]: (state, action) => ({
...state,
error: action.payload,
loading: false,
}),
[camelize('get', singular, 'Request')]: state => ({
...state,
loading: true,
}),
[camelize('get', singular, 'Success')]: state => ({
...state,
loading: false,
}),
[camelize('get', singular, 'Failure')]: (state, action) => ({
...state,
loading: false,
error: action.payload,
}),
[camelize('post', singular, 'Request')]: state => ({
...state,
posting: true,
}),
[camelize('post', singular, 'Success')]: state => ({
...state,
posting: false,
showForm: false,
}),
[camelize('post', singular, 'Failure')]: (state, action) => ({
...state,
error: action.payload,
posting: false,
}),
[camelize('put', singular, 'Request')]: state => ({
...state,
posting: true,
}),
[camelize('put', singular, 'Success')]: state => ({
...state,
posting: false,
showForm: false,
}),
[camelize('put', singular, 'Failure')]: (state, action) => ({
...state,
posting: false,
error: action.payload,
}),
[camelize('delete', singular, 'Request')]: state => ({
...state,
posting: true,
}),
[camelize('delete', singular, 'Success')]: state => ({
...state,
posting: false,
}),
[camelize('delete', singular, 'Failure')]: (state, action) => ({
...state,
posting: false,
error: action.payload,
}),
[camelize('open', singular, 'Form')]: state => ({
...state,
showForm: true,
}),
[camelize('close', singular, 'Form')]: state => ({
...state,
showForm: false,
}),
[camelize('set', singular, 'Schema')]: (state, action) => ({
...state,
schema: action.payload,
}),
};

@@ -119,3 +169,3 @@ }

*
* @version 0.1.0
* @version 0.1.1
* @since 0.1.0

@@ -140,3 +190,3 @@ */

return createSlice({
slice: sliceName,
name: sliceName,
initialState: initialDefaultState,

@@ -143,0 +193,0 @@ reducers: defaultReducers,

@@ -12,4 +12,4 @@ import { httpActions as client } from '@codetanzania/emis-api-client';

/**
* @name createThunkFor
* @function
* @name createThunkFor
* @description Create and expose all common thunks for a resource.

@@ -36,3 +36,3 @@ *

* @function
* @name get<Resource Plural Name>
* @name getResources
* @description A thunk that will be dispatched when fetching data from API

@@ -84,3 +84,3 @@ *

* @function
* @name get<Resource Singular Name>
* @name getResource
* @description A thunk that will be dispatched when fetching

@@ -133,3 +133,3 @@ * single resource data from the API

* @function
* @name post<Resource Singular Name>
* @name postResource
* @description A thunk that will be dispatched when creating a single

@@ -195,3 +195,3 @@ * resource data in the API

* @function
* @name put<Resource Singular Name>
* @name putResource
* @description A thunk that will be dispatched when updating a single

@@ -255,3 +255,3 @@ * resource data in the API

* @function
* @name delete<Resource Singular Name>
* @name deleteResource
* @description A thunk that will be dispatched when deleting/archiving

@@ -312,3 +312,3 @@ * a single resource data in the API

* @function
* @name fetch<Resource Name>
* @name fetchResource
* @description A thunk that for fetching data from the API the difference

@@ -322,3 +322,3 @@ * between this and get thunk is this will apply all the criteria on fetch.

* resources from the API fails
*
* @returns {Function} Thunk function
* @version 0.1.0

@@ -344,3 +344,3 @@ * @since 0.1.0

* @function
* @name filter<Resource Plural Name>
* @name filterResources
* @description A thunk that will be dispatched when filtering resources

@@ -373,3 +373,3 @@ * data in the API

* @function
* @name refresh<Resource Plural Name>
* @name refreshResources
* @description A thunk that will be dispatched when refreshing resources

@@ -408,3 +408,3 @@ * data in the API

* @function
* @name search<Resource Plural Name>
* @name searchResources
* @description A thunk that will be dispatched when searching resources

@@ -442,3 +442,3 @@ * data in the API

* @function
* @name sort<Resource Plural Name>
* @name sortResources
* @description A thunk that will be dispatched when sorting resources

@@ -476,3 +476,3 @@ * data in the API

* @function
* @name paginate<Resource Plural Name>
* @name paginateResources
* @description A thunk that will be dispatched when paginating resources

@@ -508,3 +508,3 @@ * data in the API

* @function
* @name clear<Resource Singular Name>Filters
* @name clearResourceFilters
* @description A thunk that will be dispatched when clearing filters on

@@ -545,3 +545,3 @@ * resources data in the API

* @function
* @name clear<Resource Plural Name>Sort
* @name clearResourcesSort
* @description A thunk that will be dispatched when clearing sort order on

@@ -548,0 +548,0 @@ * resources data in the API

@@ -62,27 +62,15 @@ import merge from 'lodash/merge';

case INITIALIZE_APP_START:
return Object.assign({}, state, { loading: true });
return { ...state, loading: true };
case INITIALIZE_APP_SUCCESS:
return Object.assign({}, state, { loading: false });
return { ...state, loading: false };
case INITIALIZE_APP_FAILURE:
return Object.assign({}, state, {
loading: false,
error: action.payload,
});
return { ...state, loading: false, error: action.payload };
case SIGNIN_APP_START:
return Object.assign({}, state, { signing: true });
return { ...state, signing: true };
case SIGNIN_APP_SUCCESS:
return Object.assign({}, state, {
party: action.payload,
signing: false,
});
return { ...state, party: action.payload, signing: false };
case SIGNIN_APP_FAILURE:
return Object.assign({}, state, {
error: action.payload,
signing: false,
});
return { ...state, error: action.payload, signing: false };
case SIGNOUT:
return Object.assign({}, state, {
error: null,
party: null,
});
return { ...state, error: null, party: null };
default:

@@ -89,0 +77,0 @@ return state;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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