redux-paginator-immutable 17.0.49 → 17.0.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/package.json +19 -16
  2. package/README.md +0 -3
  3. package/lib/Info.d.ts +0 -9
  4. package/lib/Info.js +0 -18
  5. package/lib/Info.js.map +0 -1
  6. package/lib/LoadDataItem.d.ts +0 -25
  7. package/lib/LoadDataItem.js +0 -60
  8. package/lib/LoadDataItem.js.map +0 -1
  9. package/lib/LoadPaginator.d.ts +0 -4
  10. package/lib/LoadPaginator.js +0 -79
  11. package/lib/LoadPaginator.js.map +0 -1
  12. package/lib/LoadPaginatorTypes.d.ts +0 -29
  13. package/lib/LoadPaginatorTypes.js +0 -3
  14. package/lib/LoadPaginatorTypes.js.map +0 -1
  15. package/lib/LoadingButton.d.ts +0 -8
  16. package/lib/LoadingButton.js +0 -26
  17. package/lib/LoadingButton.js.map +0 -1
  18. package/lib/actionTypes.d.ts +0 -9
  19. package/lib/actionTypes.js +0 -13
  20. package/lib/actionTypes.js.map +0 -1
  21. package/lib/actions.d.ts +0 -42
  22. package/lib/actions.js +0 -82
  23. package/lib/actions.js.map +0 -1
  24. package/lib/agent.d.ts +0 -8
  25. package/lib/agent.js +0 -37
  26. package/lib/agent.js.map +0 -1
  27. package/lib/createDataReducer.d.ts +0 -14
  28. package/lib/createDataReducer.js +0 -67
  29. package/lib/createDataReducer.js.map +0 -1
  30. package/lib/createItemReducer.d.ts +0 -9
  31. package/lib/createItemReducer.js +0 -18
  32. package/lib/createItemReducer.js.map +0 -1
  33. package/lib/createPaginator.d.ts +0 -33
  34. package/lib/createPaginator.js +0 -87
  35. package/lib/createPaginator.js.map +0 -1
  36. package/lib/index.d.ts +0 -11
  37. package/lib/index.js +0 -30
  38. package/lib/index.js.map +0 -1
  39. package/lib/paginatorMiddleware.d.ts +0 -5
  40. package/lib/paginatorMiddleware.js +0 -69
  41. package/lib/paginatorMiddleware.js.map +0 -1
  42. package/lib/reducerItemData.d.ts +0 -18
  43. package/lib/reducerItemData.js +0 -60
  44. package/lib/reducerItemData.js.map +0 -1
  45. package/lib/reducerOperations.d.ts +0 -4
  46. package/lib/reducerOperations.js +0 -75
  47. package/lib/reducerOperations.js.map +0 -1
  48. package/lib/reducers.d.ts +0 -2
  49. package/lib/reducers.js +0 -75
  50. package/lib/reducers.js.map +0 -1
  51. package/lib/selectors.d.ts +0 -38
  52. package/lib/selectors.js +0 -83
  53. package/lib/selectors.js.map +0 -1
  54. package/lib/types.d.ts +0 -107
  55. package/lib/types.js +0 -3
  56. package/lib/types.js.map +0 -1
  57. package/lib/util.d.ts +0 -9
  58. package/lib/util.js +0 -53
  59. package/lib/util.js.map +0 -1
  60. package/src/Info.tsx +0 -28
  61. package/src/LoadDataItem.tsx +0 -84
  62. package/src/LoadPaginator.tsx +0 -104
  63. package/src/LoadPaginatorTypes.ts +0 -31
  64. package/src/LoadingButton.tsx +0 -44
  65. package/src/__tests__/actions.spec.js +0 -130
  66. package/src/__tests__/agent.spec.js +0 -32
  67. package/src/__tests__/createPaginator.spec.js +0 -39
  68. package/src/__tests__/reducers.spec.js +0 -131
  69. package/src/__tests__/selectors.spec.js +0 -180
  70. package/src/__tests__/setup.js +0 -1
  71. package/src/actionTypes.ts +0 -9
  72. package/src/actions.ts +0 -156
  73. package/src/agent.ts +0 -62
  74. package/src/createDataReducer.ts +0 -90
  75. package/src/createItemReducer.ts +0 -29
  76. package/src/createPaginator.ts +0 -104
  77. package/src/index.ts +0 -26
  78. package/src/paginatorMiddleware.ts +0 -93
  79. package/src/reducerItemData.ts +0 -74
  80. package/src/reducerOperations.ts +0 -92
  81. package/src/reducers.ts +0 -77
  82. package/src/selectors.ts +0 -111
  83. package/src/types.ts +0 -130
  84. package/src/util.ts +0 -51
@@ -1,130 +0,0 @@
1
- /* eslint-disable no-undefined, max-lines-per-function, no-magic-numbers */
2
-
3
- import expect from "expect";
4
- import { isFSA } from "flux-standard-action";
5
-
6
- import actions from "../actions";
7
-
8
- const {
9
- receivePage,
10
- requestPage,
11
- resetView,
12
- changeView,
13
- } = actions;
14
-
15
- import {
16
- RECEIVE_PAGE,
17
- REQUEST_PAGE,
18
- RESET_VIEW,
19
- CHANGE_VIEW,
20
- } from "../actionTypes";
21
-
22
- describe("actions", () => {
23
-
24
- it("should create receive page action", () => {
25
- const action = receivePage({
26
- endpoint : "some/api/endpoint/",
27
- pageArgName : "p",
28
- idKey : "id",
29
- page : 2,
30
- token : "foo=bar",
31
- items : [
32
- "foo",
33
- "bar",
34
- "baz",
35
- ],
36
- total: 42,
37
- });
38
-
39
- expect(action).
40
- toEqual({
41
- type : RECEIVE_PAGE,
42
- meta : {
43
- endpoint : "some/api/endpoint/",
44
- pageArgName : "p",
45
- idKey : "id",
46
- },
47
- payload: {
48
- token : "foo=bar",
49
- page : 2,
50
- items : [
51
- "foo",
52
- "bar",
53
- "baz",
54
- ],
55
- total: 42,
56
- },
57
- });
58
-
59
- expect(isFSA(action)).toEqual(true);
60
- });
61
-
62
- it("should create request page action", () => {
63
- const action = requestPage({
64
- endpoint : "some/api/endpoint/",
65
- resultsKey : "results",
66
- totalKey : "total",
67
- pageArgName : "p",
68
- idKey : "id",
69
- page : 2,
70
- token : "foo=bar",
71
- });
72
-
73
- expect(action).
74
- toEqual({
75
- type : REQUEST_PAGE,
76
- meta : {
77
- endpoint : "some/api/endpoint/",
78
- resultsKey : "results",
79
- totalKey : "total",
80
- pageArgName : "p",
81
- idKey : "id",
82
- },
83
- payload: {
84
- token : "foo=bar",
85
- page : 2,
86
- },
87
- });
88
-
89
- expect(isFSA(action)).toEqual(true);
90
- });
91
-
92
- it("should create reset view action", () => {
93
- const action = resetView("some/api/endpoint/", "name");
94
-
95
- expect(action).
96
- toEqual({
97
- type : RESET_VIEW,
98
- meta : {
99
- endpoint: "some/api/endpoint/",
100
- },
101
- payload: {
102
- token: "name",
103
- },
104
- });
105
-
106
- expect(isFSA(action)).toEqual(true);
107
- });
108
-
109
- it("should create change view action", () => {
110
- const action = changeView("some/api/endpoint/", {
111
- token : "name",
112
- view : 2,
113
- });
114
-
115
- expect(action).
116
- toEqual({
117
- type : CHANGE_VIEW,
118
- meta : {
119
- endpoint: "some/api/endpoint/",
120
- },
121
- payload: {
122
- view : 2,
123
- token : "name",
124
- },
125
- });
126
-
127
- expect(isFSA(action)).toEqual(true);
128
- });
129
-
130
- });
@@ -1,32 +0,0 @@
1
- import expect from "expect";
2
-
3
- import { buildSuffix } from "../agent";
4
-
5
- describe("buildSuffix", () => {
6
-
7
- it("should correctly build the url suffix when simple params are provided", () => {
8
- expect(buildSuffix("p", 1, "foo=bar")).
9
- toEqual("?foo=bar&p=1");
10
- });
11
-
12
- it("should correctly build the url suffix when less simple params are provided", () => {
13
- expect(buildSuffix("p", 1, "foo=bar&baz=foo")).
14
- toEqual("?baz=foo&foo=bar&p=1");
15
- });
16
-
17
- it("should correctly build the url suffix when params contains no extractable query params", () => {
18
- expect(buildSuffix("p", 1, "foo/bar")).
19
- toEqual("foo/bar?p=1");
20
- });
21
-
22
- it('should correctly build the url suffix when "params" is not provided', () => {
23
- expect(buildSuffix("p", 1, "")).
24
- toEqual("?p=1");
25
- });
26
-
27
- it("should correctly build the url suffix when complex params are provided", () => {
28
- expect(buildSuffix("p", 1, "foo/bar?bar=biz&baz=foo")).
29
- toEqual("foo/bar?baz=foo&bar=biz&p=1");
30
- });
31
-
32
- });
@@ -1,39 +0,0 @@
1
- /* eslint-disable max-len, no-undefined, no-magic-numbers */
2
-
3
- import expect from "expect";
4
-
5
- import actions from "../actions";
6
- import {
7
- // onlyForEndpoint,
8
- createPaginator,
9
- } from "../createPaginator";
10
-
11
- const {
12
- requestPage,
13
- } = actions;
14
-
15
- describe("createPaginator", () => {
16
-
17
- it("should create correct request action creator", () => {
18
- const paginator = createPaginator("some/api/endpoint", {
19
- pageArgName : "p",
20
- idKey : "id_field",
21
- resultsKey : "results",
22
- totalKey : "count",
23
- }),
24
- action = paginator.requestPage(42, "foo=bar");
25
-
26
- expect(action).
27
- toEqual(requestPage({
28
- endpoint : "some/api/endpoint",
29
- endpointCb : null,
30
- resultsKey : "results",
31
- totalKey : "count",
32
- pageArgName : "p",
33
- idKey : "id_field",
34
- page : 42,
35
- token : "foo=bar",
36
- }));
37
- });
38
-
39
- });
@@ -1,131 +0,0 @@
1
- /* eslint-disable max-len, no-undefined, max-lines-per-function */
2
-
3
- import * as Immutable from "immutable";
4
-
5
- import chai, { expect } from "chai";
6
- import chaiImmutable from "chai-immutable";
7
-
8
- chai.use(chaiImmutable);
9
-
10
- import actions from "../actions";
11
-
12
- const {
13
- requestPage,
14
- receivePage,
15
- } = actions;
16
-
17
- import {
18
- pages,
19
- items,
20
- } from "../reducers";
21
-
22
- const requestPageAction = requestPage({
23
- endpoint : "some/api/endpoint",
24
- resultsKey : "results",
25
- totalKey : "total",
26
- pageArgName : "p",
27
- idKey : "id",
28
- page : 2,
29
- token : "foo=bar",
30
- }),
31
-
32
- receivePageAction = receivePage({
33
- endpoint : "some/api/endpoint/",
34
- pageArgName : "p",
35
- idKey : "id",
36
- page : 2,
37
- token : "foo=bar",
38
- items : [
39
- {
40
- id : "baz",
41
- fooField : "bazValue",
42
- },
43
- {
44
- id : "bar",
45
- fooField : "barValue",
46
- },
47
- ],
48
- total: 2,
49
- });
50
-
51
- describe("pages reducer", () => {
52
-
53
- it("should return the state by default", () => {
54
- const state = pages(Immutable.Map({
55
- some: "state",
56
- }), { type: "some action" });
57
-
58
- expect(state).
59
- to.equal(Immutable.Map({
60
- some: "state",
61
- }));
62
- });
63
-
64
- it("should initialize the pages map with a new page entry when requesting new page", () => {
65
- const state = pages(undefined, requestPageAction);
66
-
67
- expect(state).
68
- to.equal(
69
- Immutable.Map({
70
- "foo=bar": Immutable.Map({
71
- page : 2,
72
- token : "foo=bar",
73
- ids : Immutable.List(),
74
- fetching : true,
75
- error : false,
76
- view : 1,
77
- fetched : false,
78
- }),
79
- }),
80
- );
81
- });
82
-
83
- it("should populate the pages map at the page url key with the item ids", () => {
84
- const state = pages(Immutable.Map({
85
- "foo=bar": Immutable.Map({
86
- page : 2,
87
- token : "foo=bar",
88
- ids : Immutable.List(),
89
- fetching : true,
90
- fetched : false,
91
- }),
92
- }), receivePageAction);
93
-
94
- expect(state).
95
- to.equal(Immutable.Map({
96
- "foo=bar": Immutable.Map({
97
- page : 2,
98
- token : "foo=bar",
99
- ids : Immutable.List([
100
- "baz",
101
- "bar",
102
- ]),
103
- fetching : false,
104
- fetched : true,
105
- error : false,
106
- total : 2,
107
- }),
108
- }));
109
- });
110
-
111
- });
112
-
113
- describe("items reducer", () => {
114
-
115
- it("should populate the items map with item received", () => {
116
- const state = items(undefined, receivePageAction);
117
-
118
- expect(state).
119
- to.equal(Immutable.Map({
120
- "baz": Immutable.Map({
121
- id : "baz",
122
- fooField : "bazValue",
123
- }),
124
- "bar": Immutable.Map({
125
- id : "bar",
126
- fooField : "barValue",
127
- }),
128
- }));
129
- });
130
-
131
- });
@@ -1,180 +0,0 @@
1
- /* eslint-disable max-len, no-undefined, max-lines-per-function, no-magic-numbers */
2
-
3
- import chai, { expect } from "chai";
4
- import chaiImmutable from "chai-immutable";
5
-
6
- chai.use(chaiImmutable);
7
-
8
- import * as Immutable from "immutable";
9
- import selectors from "../selectors";
10
-
11
- const
12
- {
13
- getCurrentTotalResultsCount,
14
- getAllResults,
15
- getResultsUpToPage,
16
- isPageFetched,
17
- isPageFetching,
18
- getCurrentView,
19
- } = selectors,
20
- paginator = Immutable.Map({
21
- "foo=bar": Immutable.Map({
22
- page : 3,
23
- token : "foo=bar",
24
- ids : Immutable.List([
25
- 1,
26
- 2,
27
- 3,
28
- 7,
29
- 8,
30
- 9,
31
- ]),
32
- total : 42,
33
- view : 2,
34
- fetching : false,
35
- fetched : true,
36
- }),
37
- "foo=baz": Immutable.Map({
38
- page : 1,
39
- token : "foo=baz",
40
- ids : Immutable.List([
41
- 1,
42
- 4,
43
- 6,
44
- ]),
45
- fetching : false,
46
- fetched : true,
47
- total : 17,
48
- view : 1,
49
- }),
50
- }),
51
-
52
- items = Immutable.Map({
53
- "1": Immutable.Map({
54
- data : "foo1",
55
- id : 1,
56
- }),
57
- "2": Immutable.Map({
58
- data : "foo2",
59
- id : 2,
60
- }),
61
- "3": Immutable.Map({
62
- data : "foo3",
63
- id : 3,
64
- }),
65
- "4": Immutable.Map({
66
- data : "foo4",
67
- id : 4,
68
- }),
69
- "5": Immutable.Map({
70
- data : "foo5",
71
- id : 5,
72
- }),
73
- "6": Immutable.Map({
74
- data : "foo6",
75
- id : 6,
76
- }),
77
- "7": Immutable.Map({
78
- data : "foo7",
79
- id : 7,
80
- }),
81
- "8": Immutable.Map({
82
- data : "foo8",
83
- id : 8,
84
- }),
85
- "9": Immutable.Map({
86
- data : "foo9",
87
- id : 9,
88
- }),
89
- });
90
-
91
- describe("selectors", () => {
92
-
93
- it("getAllResults should select all the items ids for pages with same params than the current page", () => {
94
- expect(getAllResults(paginator, "foo=bar", items)).
95
- to.equal(Immutable.List([
96
- Immutable.Map({
97
- data : "foo1",
98
- id : 1,
99
- }),
100
- Immutable.Map({
101
- data : "foo2",
102
- id : 2,
103
- }),
104
- Immutable.Map({
105
- data : "foo3",
106
- id : 3,
107
- }),
108
- Immutable.Map({
109
- data : "foo7",
110
- id : 7,
111
- }),
112
- Immutable.Map({
113
- data : "foo8",
114
- id : 8,
115
- }),
116
- Immutable.Map({
117
- data : "foo9",
118
- id : 9,
119
- }),
120
- ]));
121
- });
122
-
123
- it("getResultsUpToPage should select all the items ids for pages with same params than the current page", () => {
124
- expect(getResultsUpToPage(paginator, "foo=bar", items, 2, 2)).
125
- to.equal(Immutable.List([
126
- Immutable.Map({
127
- data : "foo1",
128
- id : 1,
129
- }),
130
- Immutable.Map({
131
- data : "foo2",
132
- id : 2,
133
- }),
134
- Immutable.Map({
135
- data : "foo3",
136
- id : 3,
137
- }),
138
- Immutable.Map({
139
- data : "foo7",
140
- id : 7,
141
- }),
142
- ]));
143
- });
144
-
145
- it("getCurrentTotalResultsCount should return the total count for the current params of the provided name", () => {
146
- expect(getCurrentTotalResultsCount(paginator, "foo=bar")).
147
- to.equal(42);
148
- });
149
-
150
- it("getCurrentTotalResultsCount should return 0 if current page url is undefined for the provided name", () => {
151
- expect(getCurrentTotalResultsCount(paginator, "name3")).
152
- to.equal(0);
153
- });
154
-
155
- it("isPageFetching should return whether the current page is fetching or not for the provided name", () => {
156
- expect(isPageFetching(paginator, "foo=bar", 1)).
157
- to.equal(false);
158
- });
159
-
160
- it("isPageFetched should return whether the current page is fetched or not for the provided name", () => {
161
- expect(isPageFetched(paginator, "foo=bar", 1)).
162
- to.equal(true);
163
- });
164
-
165
- it("isPageFetched should return whether the current page is fetched or not for the provided name", () => {
166
- expect(isPageFetched(paginator, "foo=bar", 4)).
167
- to.equal(false);
168
- });
169
-
170
- it("getCurrentView should return 1 if there is no view point", () => {
171
- expect(getCurrentView(paginator, "foo=bat")).
172
- to.equal(1);
173
- });
174
-
175
- it("getCurrentView should return the value if it exists", () => {
176
- expect(getCurrentView(paginator, "foo=bar")).
177
- to.equal(2);
178
- });
179
-
180
- });
@@ -1 +0,0 @@
1
- import "babel-polyfill";
@@ -1,9 +0,0 @@
1
- export const REQUEST_PAGE = "@@redux-paginator-immutable/REQUEST_PAGE";
2
- export const RECEIVE_PAGE = "@@redux-paginator-immutable/RECEIVE_PAGE";
3
- export const RESET_VIEW = "@@redux-paginator-immutable/RESET_VIEW";
4
- export const CHANGE_VIEW = "@@redux-paginator-immutable/CHANGE_VIEW";
5
- export const CLEAR_DATA = "@@redux-paginator-immutable/CLEAR_DATA";
6
- export const FETCH_ITEM_DATA_PENDING = "@@redux-paginator-immutable/FETCH_ITEM_DATA_PENDING";
7
- export const FETCH_ITEM_DATA_REJECTED = "@@redux-paginator-immutable/FETCH_ITEM_DATA_REJECTED";
8
- export const FETCH_ITEM_DATA_FULFILLED = "@@redux-paginator-immutable/FETCH_ITEM_DATA_FULFILLED";
9
- export const FETCH_CURRENT_COMPANY_INFO_PENDING = "FETCH_CURRENT_COMPANY_INFO_PENDING";
package/src/actions.ts DELETED
@@ -1,156 +0,0 @@
1
-
2
- import agent from "superagent";
3
- import { EndPointCb, Action } from "./types";
4
-
5
- type RequestPageArgsTypes = {
6
- endpoint: string;
7
- endpointCb: EndPointCb;
8
- manageEntity: any;
9
- resultsKey: string;
10
- totalKey: string;
11
- pageArgName: string;
12
- idKey: string;
13
- page: number;
14
- token: string;
15
- };
16
-
17
- type ReceivePageArgsTypes = {
18
- endpoint: string;
19
- endpointCb: EndPointCb;
20
- manageEntity: any;
21
- pageArgName: string;
22
- idKey: string;
23
- page: number;
24
- token: string;
25
- items: Array<any>;
26
- total: number;
27
- error: boolean;
28
- };
29
-
30
- const requestPage = ({
31
- endpoint,
32
- endpointCb,
33
- manageEntity,
34
- resultsKey,
35
- totalKey,
36
- pageArgName,
37
- idKey,
38
- page,
39
- token,
40
- }: RequestPageArgsTypes): Action => ({
41
- type : "@@redux-paginator-immutable/REQUEST_PAGE",
42
- meta : {
43
- endpoint,
44
- endpointCb,
45
- manageEntity,
46
- resultsKey,
47
- totalKey,
48
- pageArgName,
49
- idKey,
50
- },
51
- payload: {
52
- page,
53
- token,
54
- },
55
- }),
56
-
57
- receivePage = ({
58
- endpoint,
59
- endpointCb,
60
- manageEntity,
61
- pageArgName,
62
- idKey,
63
- page,
64
- token,
65
- items,
66
- error,
67
- total,
68
- }: ReceivePageArgsTypes): Action => ({
69
- type : "@@redux-paginator-immutable/RECEIVE_PAGE",
70
- meta : {
71
- endpoint,
72
- endpointCb,
73
- manageEntity,
74
- pageArgName,
75
- idKey,
76
- },
77
- payload: {
78
- page,
79
- token,
80
- items,
81
- error,
82
- total,
83
- },
84
- }),
85
-
86
- resetView = (endpoint: string, token: string): Action => ({
87
- type : "@@redux-paginator-immutable/RESET_VIEW",
88
- meta : {
89
- endpoint,
90
- },
91
- payload: {
92
- token,
93
- },
94
- }),
95
-
96
- changeView = (endpoint: string, {
97
- token,
98
- view,
99
- }: {
100
- token: string;
101
- view: number;
102
- }): Action => ({
103
- type : "@@redux-paginator-immutable/CHANGE_VIEW",
104
- meta : {
105
- endpoint,
106
- },
107
- payload: {
108
- token,
109
- view,
110
- },
111
- }),
112
-
113
- clearData = (endpoint: string): Action => ({
114
- type : "@@redux-paginator-immutable/CLEAR_DATA",
115
- meta : {
116
- endpoint,
117
- },
118
- });
119
-
120
- // data info
121
- type FetchDataItem = {
122
- dataItemURL: string;
123
- endpoint: string;
124
- normalizeDataItem: any;
125
- id: string;
126
- };
127
-
128
- const fetchDataItemRequest = ({
129
- dataItemURL,
130
- normalizeDataItem,
131
- id,
132
- }: FetchDataItem): Promise<any> => (
133
- new Promise((resolve, reject) => (
134
- agent.
135
- get(`${dataItemURL}/${id}`).
136
- set("Accept", "application/json").
137
- end(normalizeDataItem(resolve, reject))
138
- )) as Promise<any>
139
- );
140
-
141
- export const fetchItem = (things: FetchDataItem): any => ({
142
- type : "@@redux-paginator-immutable/FETCH_ITEM_DATA",
143
- payload : fetchDataItemRequest(things),
144
- meta : {
145
- id : things.id,
146
- endpoint : things.endpoint,
147
- },
148
- });
149
-
150
- export default {
151
- clearData,
152
- requestPage,
153
- receivePage,
154
- resetView,
155
- changeView,
156
- };