redux-clerk2 2.0.17 → 2.0.20
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.
- package/CHANGELOG.md +79 -0
- package/lib/actions/BaseAction.js +11 -10
- package/package.json +1 -1
- package/src/.DS_Store +0 -0
- package/src/actions/BaseAction.js +10 -9
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
## 1.0.0
|
|
2
|
+
###### _August 10, 2017_
|
|
3
|
+
|
|
4
|
+
- Convert responseData to Immutable data structure before adding to store ([#51](https://github.com/GetAmbassador/redux-clerk/pull/51))
|
|
5
|
+
|
|
6
|
+
## 1.0.0-rc.4
|
|
7
|
+
###### _May 2, 2017_
|
|
8
|
+
|
|
9
|
+
- Accept responseData in handleSuccess for the update action ([#48](https://github.com/GetAmbassador/redux-clerk/pull/48))
|
|
10
|
+
- Update docs to reflect optional optimism ([#47](https://github.com/GetAmbassador/redux-clerk/pull/47))
|
|
11
|
+
|
|
12
|
+
## 1.0.0-rc.3
|
|
13
|
+
###### _April 10, 2017_
|
|
14
|
+
|
|
15
|
+
- Cast all raw ids to strings ([#44](https://github.com/GetAmbassador/redux-clerk/pull/44))
|
|
16
|
+
- Update selectors to handle optional optimism ([#43](https://github.com/GetAmbassador/redux-clerk/pull/43))
|
|
17
|
+
- Make optimistic updates optional ([#41](https://github.com/GetAmbassador/redux-clerk/pull/41))
|
|
18
|
+
|
|
19
|
+
## 1.0.0-rc.2
|
|
20
|
+
###### _March 23, 2017_
|
|
21
|
+
|
|
22
|
+
- Added pre action hooks ([#38](https://github.com/GetAmbassador/redux-clerk/pull/38))
|
|
23
|
+
|
|
24
|
+
## 1.0.0-rc.1
|
|
25
|
+
###### _March 22, 2017_
|
|
26
|
+
|
|
27
|
+
- Added post action hooks ([#36](https://github.com/GetAmbassador/redux-clerk/pull/36))
|
|
28
|
+
- Rename delete action to remove to avoid reserved word conflicts ([#35](https://github.com/GetAmbassador/redux-clerk/pull/35))
|
|
29
|
+
|
|
30
|
+
## 0.3.0
|
|
31
|
+
###### _March 15, 2017_
|
|
32
|
+
|
|
33
|
+
- Fetch response will now deep merge response data into raw data ([#33](https://github.com/GetAmbassador/redux-clerk/pull/33))
|
|
34
|
+
|
|
35
|
+
## 0.2.8
|
|
36
|
+
###### _February 21, 2017_
|
|
37
|
+
|
|
38
|
+
- Cast uid to int in record selector ([#31](https://github.com/GetAmbassador/redux-clerk/pull/31))
|
|
39
|
+
|
|
40
|
+
## 0.2.7
|
|
41
|
+
###### _February 16, 2017_
|
|
42
|
+
|
|
43
|
+
- Added the get selector ([#29](https://github.com/GetAmbassador/redux-clerk/pull/29))
|
|
44
|
+
|
|
45
|
+
## 0.2.6
|
|
46
|
+
###### _January 11, 2017_
|
|
47
|
+
|
|
48
|
+
- Added the datasetProperty selector ([#27](https://github.com/GetAmbassador/redux-clerk/pull/27))
|
|
49
|
+
|
|
50
|
+
## 0.2.5
|
|
51
|
+
###### _January 3, 2017_
|
|
52
|
+
|
|
53
|
+
- Return Map instead of List for empty dataset ([#25](https://github.com/GetAmbassador/redux-clerk/pull/25))
|
|
54
|
+
- Ensure data is properly converted between actions and reducers ([#24](https://github.com/GetAmbassador/redux-clerk/pull/24))
|
|
55
|
+
|
|
56
|
+
## 0.2.4
|
|
57
|
+
###### _December 15, 2016_
|
|
58
|
+
|
|
59
|
+
- uidField option has been removed for the reducer (it is not longer needed) ([#22](https://github.com/GetAmbassador/redux-clerk/pull/22))
|
|
60
|
+
|
|
61
|
+
## 0.2.3
|
|
62
|
+
###### _December 14, 2016_
|
|
63
|
+
|
|
64
|
+
- Records are now added while updating if not already in state ([#20](https://github.com/GetAmbassador/redux-clerk/pull/20))
|
|
65
|
+
|
|
66
|
+
## 0.2.2
|
|
67
|
+
###### _December 13, 2016_
|
|
68
|
+
|
|
69
|
+
- Added the ability to return fetch response as an object or array ([#18](https://github.com/GetAmbassador/redux-clerk/pull/18))
|
|
70
|
+
|
|
71
|
+
## 0.2.1
|
|
72
|
+
###### _December 7, 2016_
|
|
73
|
+
|
|
74
|
+
- Added the ability to pass additional data with fetch, create and delete actions ([#16](https://github.com/GetAmbassador/redux-clerk/pull/16))
|
|
75
|
+
|
|
76
|
+
## 0.2.0
|
|
77
|
+
###### _December 5, 2016_
|
|
78
|
+
|
|
79
|
+
- Initial Release
|
|
@@ -111,6 +111,7 @@ var _initialiseProps = function _initialiseProps() {
|
|
|
111
111
|
dispatch(action);
|
|
112
112
|
|
|
113
113
|
if (type === 'success' && actionData.options.normalizeResponse) {
|
|
114
|
+
console.log('actionData.options:', actionData.options);
|
|
114
115
|
// DISPATCH RELATED ACTIONS IF WE HAVE normalizationSettings
|
|
115
116
|
if (responseData) {
|
|
116
117
|
if (actionData.normalizationSettings && Array.isArray(actionData.normalizationSettings)) {
|
|
@@ -119,7 +120,7 @@ var _initialiseProps = function _initialiseProps() {
|
|
|
119
120
|
//console.log(`entity:`, entity);
|
|
120
121
|
if (!(0, _is.isObject)(entity)) {
|
|
121
122
|
var entityActionResponseData = _this._processResponse(entity, responseData);
|
|
122
|
-
entityActionResponseData.length && _this._dispatchRelatedAction(entity, type, actionData.instance, entityActionResponseData, dispatch);
|
|
123
|
+
entityActionResponseData.length && _this._dispatchRelatedAction(entity, type, actionData.instance, entityActionResponseData, dispatch, actionData.options);
|
|
123
124
|
} else {
|
|
124
125
|
var _iteratorNormalCompletion = true;
|
|
125
126
|
var _didIteratorError = false;
|
|
@@ -132,11 +133,11 @@ var _initialiseProps = function _initialiseProps() {
|
|
|
132
133
|
inner_entities = _step$value[1];
|
|
133
134
|
|
|
134
135
|
var entityActionResponseData = _this._processResponse(inner_entity, responseData);
|
|
135
|
-
entityActionResponseData.length && _this._dispatchRelatedAction(inner_entity, type, actionData.instance, entityActionResponseData, dispatch);
|
|
136
|
+
entityActionResponseData.length && _this._dispatchRelatedAction(inner_entity, type, actionData.instance, entityActionResponseData, dispatch, actionData.options);
|
|
136
137
|
|
|
137
138
|
inner_entities.map(async function (_entity) {
|
|
138
139
|
var innerEntityActionResponseData = _this._processResponse(_entity, entityActionResponseData);
|
|
139
|
-
innerEntityActionResponseData.length && _this._dispatchRelatedAction(_entity, type, actionData.instance, innerEntityActionResponseData, dispatch);
|
|
140
|
+
innerEntityActionResponseData.length && _this._dispatchRelatedAction(_entity, type, actionData.instance, innerEntityActionResponseData, dispatch, actionData.options);
|
|
140
141
|
});
|
|
141
142
|
};
|
|
142
143
|
|
|
@@ -171,7 +172,7 @@ var _initialiseProps = function _initialiseProps() {
|
|
|
171
172
|
//const entityActionResponseData = this._processResponse(entity, responseData);
|
|
172
173
|
|
|
173
174
|
if (updateData[entity] && updateData[entity].length) {
|
|
174
|
-
_this._dispatchRelatedAction(entity, type, actionData.instance, updateData[entity], dispatch);
|
|
175
|
+
_this._dispatchRelatedAction(entity, type, actionData.instance, updateData[entity], dispatch, actionData.options);
|
|
175
176
|
}
|
|
176
177
|
|
|
177
178
|
//entityActionResponseData.length && this._dispatchRelatedAction(entity, type, actionData.instance, entityActionResponseData, dispatch);
|
|
@@ -187,11 +188,11 @@ var _initialiseProps = function _initialiseProps() {
|
|
|
187
188
|
inner_entities = _step2$value[1];
|
|
188
189
|
|
|
189
190
|
var entityActionResponseData = _this._processResponse(inner_entity, responseData);
|
|
190
|
-
entityActionResponseData.length && _this._dispatchRelatedAction(inner_entity, type, actionData.instance, entityActionResponseData, dispatch);
|
|
191
|
+
entityActionResponseData.length && _this._dispatchRelatedAction(inner_entity, type, actionData.instance, entityActionResponseData, dispatch, actionData.options);
|
|
191
192
|
|
|
192
193
|
inner_entities.map(async function (_entity) {
|
|
193
194
|
var innerEntityActionResponseData = _this._processResponse(_entity, entityActionResponseData);
|
|
194
|
-
innerEntityActionResponseData.length && _this._dispatchRelatedAction(_entity, type, actionData.instance, innerEntityActionResponseData, dispatch);
|
|
195
|
+
innerEntityActionResponseData.length && _this._dispatchRelatedAction(_entity, type, actionData.instance, innerEntityActionResponseData, dispatch, actionData.options);
|
|
195
196
|
});
|
|
196
197
|
};
|
|
197
198
|
|
|
@@ -221,19 +222,19 @@ var _initialiseProps = function _initialiseProps() {
|
|
|
221
222
|
// Check for additionalData: { deleted: [] }
|
|
222
223
|
/*if(type === 'success' && additionalData.deleted && additionalData.deleted.length){
|
|
223
224
|
console.log(`additionalData:`, additionalData);
|
|
224
|
-
this._dispatchRelatedAction(this.actionNames[type], type, actionData.instance, additionalData.deleted, dispatch, 'remove');
|
|
225
|
+
this._dispatchRelatedAction(this.actionNames[type], type, actionData.instance, additionalData.deleted, dispatch, options, 'remove');
|
|
225
226
|
}*/
|
|
226
227
|
};
|
|
227
228
|
|
|
228
|
-
this._dispatchRelatedAction = function (entity, type, instance, responseData, dispatch) {
|
|
229
|
-
var actionType = arguments.length >
|
|
229
|
+
this._dispatchRelatedAction = function (entity, type, instance, responseData, dispatch, options) {
|
|
230
|
+
var actionType = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 'fetch';
|
|
230
231
|
|
|
231
232
|
|
|
232
233
|
//console.log(`this.config:`, this.config);
|
|
233
234
|
|
|
234
235
|
var entityActionData = {
|
|
235
236
|
instance: instance || entity, uidField: 'id', options: {
|
|
236
|
-
appendResponse: true,
|
|
237
|
+
appendResponse: options && options.appendResponse !== undefined ? options.appendResponse : true,
|
|
237
238
|
recalcTotal: true
|
|
238
239
|
}
|
|
239
240
|
};
|
package/package.json
CHANGED
package/src/.DS_Store
ADDED
|
Binary file
|
|
@@ -60,6 +60,7 @@ class BaseAction {
|
|
|
60
60
|
dispatch(action);
|
|
61
61
|
|
|
62
62
|
if (type === 'success' && actionData.options.normalizeResponse) {
|
|
63
|
+
console.log(`actionData.options:`, actionData.options)
|
|
63
64
|
// DISPATCH RELATED ACTIONS IF WE HAVE normalizationSettings
|
|
64
65
|
if (responseData) {
|
|
65
66
|
if(actionData.normalizationSettings && Array.isArray(actionData.normalizationSettings)){
|
|
@@ -68,16 +69,16 @@ class BaseAction {
|
|
|
68
69
|
//console.log(`entity:`, entity);
|
|
69
70
|
if(!isObject(entity)){
|
|
70
71
|
const entityActionResponseData = this._processResponse(entity, responseData);
|
|
71
|
-
entityActionResponseData.length && this._dispatchRelatedAction(entity, type, actionData.instance, entityActionResponseData, dispatch);
|
|
72
|
+
entityActionResponseData.length && this._dispatchRelatedAction(entity, type, actionData.instance, entityActionResponseData, dispatch, actionData.options);
|
|
72
73
|
}else{
|
|
73
74
|
|
|
74
75
|
for (let [inner_entity, inner_entities] of Object.entries(entity)) {
|
|
75
76
|
const entityActionResponseData = this._processResponse(inner_entity, responseData);
|
|
76
|
-
entityActionResponseData.length && this._dispatchRelatedAction(inner_entity, type, actionData.instance, entityActionResponseData, dispatch);
|
|
77
|
+
entityActionResponseData.length && this._dispatchRelatedAction(inner_entity, type, actionData.instance, entityActionResponseData, dispatch, actionData.options);
|
|
77
78
|
|
|
78
79
|
inner_entities.map(async (_entity) => {
|
|
79
80
|
const innerEntityActionResponseData = this._processResponse(_entity, entityActionResponseData);
|
|
80
|
-
innerEntityActionResponseData.length && this._dispatchRelatedAction(_entity, type, actionData.instance, innerEntityActionResponseData, dispatch);
|
|
81
|
+
innerEntityActionResponseData.length && this._dispatchRelatedAction(_entity, type, actionData.instance, innerEntityActionResponseData, dispatch, actionData.options);
|
|
81
82
|
});
|
|
82
83
|
}
|
|
83
84
|
}
|
|
@@ -97,7 +98,7 @@ class BaseAction {
|
|
|
97
98
|
//const entityActionResponseData = this._processResponse(entity, responseData);
|
|
98
99
|
|
|
99
100
|
if(updateData[entity] && updateData[entity].length){
|
|
100
|
-
this._dispatchRelatedAction(entity, type, actionData.instance, updateData[entity], dispatch);
|
|
101
|
+
this._dispatchRelatedAction(entity, type, actionData.instance, updateData[entity], dispatch, actionData.options);
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
//entityActionResponseData.length && this._dispatchRelatedAction(entity, type, actionData.instance, entityActionResponseData, dispatch);
|
|
@@ -105,11 +106,11 @@ class BaseAction {
|
|
|
105
106
|
|
|
106
107
|
for (let [inner_entity, inner_entities] of Object.entries(entity)) {
|
|
107
108
|
const entityActionResponseData = this._processResponse(inner_entity, responseData);
|
|
108
|
-
entityActionResponseData.length && this._dispatchRelatedAction(inner_entity, type, actionData.instance, entityActionResponseData, dispatch);
|
|
109
|
+
entityActionResponseData.length && this._dispatchRelatedAction(inner_entity, type, actionData.instance, entityActionResponseData, dispatch, actionData.options);
|
|
109
110
|
|
|
110
111
|
inner_entities.map(async (_entity) => {
|
|
111
112
|
const innerEntityActionResponseData = this._processResponse(_entity, entityActionResponseData);
|
|
112
|
-
innerEntityActionResponseData.length && this._dispatchRelatedAction(_entity, type, actionData.instance, innerEntityActionResponseData, dispatch);
|
|
113
|
+
innerEntityActionResponseData.length && this._dispatchRelatedAction(_entity, type, actionData.instance, innerEntityActionResponseData, dispatch, actionData.options);
|
|
113
114
|
});
|
|
114
115
|
}
|
|
115
116
|
}
|
|
@@ -124,18 +125,18 @@ class BaseAction {
|
|
|
124
125
|
// Check for additionalData: { deleted: [] }
|
|
125
126
|
/*if(type === 'success' && additionalData.deleted && additionalData.deleted.length){
|
|
126
127
|
console.log(`additionalData:`, additionalData);
|
|
127
|
-
this._dispatchRelatedAction(this.actionNames[type], type, actionData.instance, additionalData.deleted, dispatch, 'remove');
|
|
128
|
+
this._dispatchRelatedAction(this.actionNames[type], type, actionData.instance, additionalData.deleted, dispatch, options, 'remove');
|
|
128
129
|
}*/
|
|
129
130
|
|
|
130
131
|
};
|
|
131
132
|
|
|
132
|
-
_dispatchRelatedAction = (entity, type, instance, responseData, dispatch, actionType = 'fetch') => {
|
|
133
|
+
_dispatchRelatedAction = (entity, type, instance, responseData, dispatch, options, actionType = 'fetch') => {
|
|
133
134
|
|
|
134
135
|
//console.log(`this.config:`, this.config);
|
|
135
136
|
|
|
136
137
|
const entityActionData = {
|
|
137
138
|
instance: instance || entity, uidField: 'id', options: {
|
|
138
|
-
appendResponse: true,
|
|
139
|
+
appendResponse: options && options.appendResponse !== undefined ? options.appendResponse : true,
|
|
139
140
|
recalcTotal: true
|
|
140
141
|
}
|
|
141
142
|
};
|