react-redux-cache 0.22.0 → 0.22.1
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/dist/cjs/createActions.js +63 -64
- package/dist/cjs/createCache.js +131 -217
- package/dist/cjs/createReducer.js +291 -348
- package/dist/cjs/createSelectors.js +58 -67
- package/dist/cjs/index.js +26 -89
- package/dist/cjs/mutate.js +69 -153
- package/dist/cjs/query.js +70 -162
- package/dist/cjs/types.js +2 -2
- package/dist/cjs/useMutation.js +42 -71
- package/dist/cjs/useQuery.js +56 -113
- package/dist/cjs/utilsAndConstants.js +151 -204
- package/dist/esm/createActions.js +59 -60
- package/dist/esm/createCache.js +127 -218
- package/dist/esm/createReducer.js +285 -340
- package/dist/esm/createSelectors.js +54 -63
- package/dist/esm/index.js +3 -5
- package/dist/esm/mutate.js +65 -142
- package/dist/esm/query.js +66 -149
- package/dist/esm/types.js +1 -1
- package/dist/esm/useMutation.js +38 -77
- package/dist/esm/useQuery.js +52 -119
- package/dist/esm/utilsAndConstants.js +140 -190
- package/dist/types/createActions.d.ts +83 -107
- package/dist/types/createCache.d.ts +409 -730
- package/dist/types/createReducer.d.ts +3 -11
- package/dist/types/createSelectors.d.ts +18 -80
- package/dist/types/index.d.ts +3 -5
- package/dist/types/mutate.d.ts +4 -94
- package/dist/types/query.d.ts +4 -123
- package/dist/types/types.d.ts +184 -360
- package/dist/types/useMutation.d.ts +4 -39
- package/dist/types/useQuery.d.ts +4 -40
- package/dist/types/utilsAndConstants.d.ts +23 -56
- package/package.json +11 -11
|
@@ -1,221 +1,168 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.incrementChangeKey =
|
|
4
|
-
|
|
5
|
-
exports.createStateComparer =
|
|
6
|
-
exports.isEmptyObject =
|
|
7
|
-
exports.applyEntityChanges =
|
|
8
|
-
exports.defaultGetCacheKey =
|
|
9
|
-
exports.noop =
|
|
10
|
-
exports.EMPTY_ARRAY =
|
|
11
|
-
exports.EMPTY_OBJECT =
|
|
12
|
-
exports.IS_DEV =
|
|
13
|
-
exports.logWarn =
|
|
14
|
-
exports.logDebug =
|
|
15
|
-
exports.optionalUtils =
|
|
16
|
-
exports.PACKAGE_SHORT_NAME =
|
|
17
|
-
void 0
|
|
18
|
-
exports.PACKAGE_SHORT_NAME = 'rrc'
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.incrementChangeKey = exports.FetchPolicy = exports.createStateComparer = exports.isEmptyObject = exports.applyEntityChanges = exports.defaultGetCacheKey = exports.noop = exports.EMPTY_ARRAY = exports.EMPTY_OBJECT = exports.IS_DEV = exports.logWarn = exports.logDebug = exports.optionalUtils = exports.PACKAGE_SHORT_NAME = void 0;
|
|
4
|
+
exports.PACKAGE_SHORT_NAME = 'rrc';
|
|
19
5
|
exports.optionalUtils = {
|
|
20
|
-
|
|
21
|
-
}
|
|
6
|
+
deepEqual: undefined,
|
|
7
|
+
};
|
|
22
8
|
const logDebug = (tag, data) => {
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
exports.logDebug = logDebug
|
|
9
|
+
console.debug(`@${exports.PACKAGE_SHORT_NAME} [${tag}]`, data);
|
|
10
|
+
};
|
|
11
|
+
exports.logDebug = logDebug;
|
|
26
12
|
const logWarn = (tag, data) => {
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
exports.logWarn = logWarn
|
|
13
|
+
console.warn(`@${exports.PACKAGE_SHORT_NAME} [${tag}]`, data);
|
|
14
|
+
};
|
|
15
|
+
exports.logWarn = logWarn;
|
|
30
16
|
try {
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
17
|
+
exports.optionalUtils.deepEqual = require('fast-deep-equal/es6');
|
|
18
|
+
}
|
|
19
|
+
catch (_a) {
|
|
20
|
+
(0, exports.logDebug)('deepEqual', 'fast-deep-equal optional dependency was not installed');
|
|
34
21
|
}
|
|
35
22
|
exports.IS_DEV = (() => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
exports.
|
|
44
|
-
|
|
45
|
-
|
|
23
|
+
try {
|
|
24
|
+
return __DEV__;
|
|
25
|
+
}
|
|
26
|
+
catch (_a) {
|
|
27
|
+
return process.env.NODE_ENV === 'development';
|
|
28
|
+
}
|
|
29
|
+
})();
|
|
30
|
+
exports.EMPTY_OBJECT = Object.freeze({});
|
|
31
|
+
exports.EMPTY_ARRAY = Object.freeze([]);
|
|
32
|
+
const noop = () => { };
|
|
33
|
+
exports.noop = noop;
|
|
46
34
|
const defaultGetCacheKey = (params) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
exports.defaultGetCacheKey = defaultGetCacheKey
|
|
35
|
+
switch (typeof params) {
|
|
36
|
+
case 'string':
|
|
37
|
+
case 'symbol':
|
|
38
|
+
return params;
|
|
39
|
+
case 'object':
|
|
40
|
+
return JSON.stringify(params);
|
|
41
|
+
default:
|
|
42
|
+
return String(params);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
exports.defaultGetCacheKey = defaultGetCacheKey;
|
|
58
46
|
const applyEntityChanges = (entities, changes, options) => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
const {merge = changes.entities, replace, remove} = changes
|
|
64
|
-
if (!merge && !replace && !remove) {
|
|
65
|
-
return undefined
|
|
66
|
-
}
|
|
67
|
-
const mutable = options.mutableCollections
|
|
68
|
-
const deepEqual = options.deepComparisonEnabled ? exports.optionalUtils.deepEqual : undefined
|
|
69
|
-
let result
|
|
70
|
-
const objectWithAllTypenames = Object.assign(
|
|
71
|
-
Object.assign(Object.assign({}, changes.merge), changes.remove),
|
|
72
|
-
changes.replace
|
|
73
|
-
)
|
|
74
|
-
for (const typename in objectWithAllTypenames) {
|
|
75
|
-
const entitiesToMerge = merge === null || merge === void 0 ? void 0 : merge[typename]
|
|
76
|
-
const entitiesToReplace = replace === null || replace === void 0 ? void 0 : replace[typename]
|
|
77
|
-
const entitiesToRemove = remove === null || remove === void 0 ? void 0 : remove[typename]
|
|
78
|
-
if (
|
|
79
|
-
!entitiesToMerge &&
|
|
80
|
-
!entitiesToReplace &&
|
|
81
|
-
!(entitiesToRemove === null || entitiesToRemove === void 0 ? void 0 : entitiesToRemove.length)
|
|
82
|
-
) {
|
|
83
|
-
continue
|
|
47
|
+
var _a, _b, _c;
|
|
48
|
+
if (changes.merge && changes.entities) {
|
|
49
|
+
(0, exports.logWarn)('applyEntityChanges', 'merge and entities should not be both set');
|
|
84
50
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const idsSet = new Set(mergeIds)
|
|
89
|
-
replaceIds === null || replaceIds === void 0 ? void 0 : replaceIds.forEach((id) => idsSet.add(id))
|
|
90
|
-
entitiesToRemove === null || entitiesToRemove === void 0
|
|
91
|
-
? void 0
|
|
92
|
-
: entitiesToRemove.forEach((id) => idsSet.add(String(id)))
|
|
93
|
-
const totalKeysInResponse =
|
|
94
|
-
((_a = mergeIds === null || mergeIds === void 0 ? void 0 : mergeIds.length) !== null && _a !== void 0
|
|
95
|
-
? _a
|
|
96
|
-
: 0) +
|
|
97
|
-
((_b = replaceIds === null || replaceIds === void 0 ? void 0 : replaceIds.length) !== null &&
|
|
98
|
-
_b !== void 0
|
|
99
|
-
? _b
|
|
100
|
-
: 0) +
|
|
101
|
-
((_c =
|
|
102
|
-
entitiesToRemove === null || entitiesToRemove === void 0 ? void 0 : entitiesToRemove.length) !==
|
|
103
|
-
null && _c !== void 0
|
|
104
|
-
? _c
|
|
105
|
-
: 0)
|
|
106
|
-
if (totalKeysInResponse !== 0 && idsSet.size !== totalKeysInResponse) {
|
|
107
|
-
;(0, exports.logWarn)(
|
|
108
|
-
'applyEntityChanges',
|
|
109
|
-
'merge, replace and remove changes have intersections for: ' + typename
|
|
110
|
-
)
|
|
111
|
-
}
|
|
51
|
+
const { merge = changes.entities, replace, remove } = changes;
|
|
52
|
+
if (!merge && !replace && !remove) {
|
|
53
|
+
return undefined;
|
|
112
54
|
}
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
})
|
|
125
|
-
if (entitiesToReplace) {
|
|
126
|
-
for (const id in entitiesToReplace) {
|
|
127
|
-
const newEntity = entitiesToReplace[id]
|
|
128
|
-
if (
|
|
129
|
-
oldEntities === undefined ||
|
|
130
|
-
!(deepEqual === null || deepEqual === void 0 ? void 0 : deepEqual(oldEntities[id], newEntity))
|
|
131
|
-
) {
|
|
132
|
-
newEntities !== null && newEntities !== void 0
|
|
133
|
-
? newEntities
|
|
134
|
-
: (newEntities = mutable
|
|
135
|
-
? oldEntities !== null && oldEntities !== void 0
|
|
136
|
-
? oldEntities
|
|
137
|
-
: {}
|
|
138
|
-
: Object.assign({}, oldEntities))
|
|
139
|
-
newEntities[id] = newEntity
|
|
55
|
+
const mutable = options.mutableCollections;
|
|
56
|
+
const deepEqual = options.deepComparisonEnabled ? exports.optionalUtils.deepEqual : undefined;
|
|
57
|
+
let result;
|
|
58
|
+
const objectWithAllTypenames = Object.assign(Object.assign(Object.assign({}, changes.merge), changes.remove), changes.replace);
|
|
59
|
+
for (const typename in objectWithAllTypenames) {
|
|
60
|
+
const entitiesToMerge = merge === null || merge === void 0 ? void 0 : merge[typename];
|
|
61
|
+
const entitiesToReplace = replace === null || replace === void 0 ? void 0 : replace[typename];
|
|
62
|
+
const entitiesToRemove = remove === null || remove === void 0 ? void 0 : remove[typename];
|
|
63
|
+
if (!entitiesToMerge && !entitiesToReplace && !(entitiesToRemove === null || entitiesToRemove === void 0 ? void 0 : entitiesToRemove.length)) {
|
|
64
|
+
continue;
|
|
140
65
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
? oldEntities !== null && oldEntities !== void 0
|
|
152
|
-
? oldEntities
|
|
153
|
-
: {}
|
|
154
|
-
: Object.assign({}, oldEntities))
|
|
155
|
-
newEntities[id] = newEntity
|
|
66
|
+
if (options.additionalValidation) {
|
|
67
|
+
const mergeIds = entitiesToMerge && Object.keys(entitiesToMerge);
|
|
68
|
+
const replaceIds = entitiesToReplace && Object.keys(entitiesToReplace);
|
|
69
|
+
const idsSet = new Set(mergeIds);
|
|
70
|
+
replaceIds === null || replaceIds === void 0 ? void 0 : replaceIds.forEach((id) => idsSet.add(id));
|
|
71
|
+
entitiesToRemove === null || entitiesToRemove === void 0 ? void 0 : entitiesToRemove.forEach((id) => idsSet.add(String(id)));
|
|
72
|
+
const totalKeysInResponse = ((_a = mergeIds === null || mergeIds === void 0 ? void 0 : mergeIds.length) !== null && _a !== void 0 ? _a : 0) + ((_b = replaceIds === null || replaceIds === void 0 ? void 0 : replaceIds.length) !== null && _b !== void 0 ? _b : 0) + ((_c = entitiesToRemove === null || entitiesToRemove === void 0 ? void 0 : entitiesToRemove.length) !== null && _c !== void 0 ? _c : 0);
|
|
73
|
+
if (totalKeysInResponse !== 0 && idsSet.size !== totalKeysInResponse) {
|
|
74
|
+
(0, exports.logWarn)('applyEntityChanges', 'merge, replace and remove changes have intersections for: ' + typename);
|
|
75
|
+
}
|
|
156
76
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
77
|
+
const oldEntities = entities[typename];
|
|
78
|
+
let newEntities;
|
|
79
|
+
entitiesToRemove === null || entitiesToRemove === void 0 ? void 0 : entitiesToRemove.forEach((id) => {
|
|
80
|
+
if (oldEntities === null || oldEntities === void 0 ? void 0 : oldEntities[id]) {
|
|
81
|
+
newEntities !== null && newEntities !== void 0 ? newEntities : (newEntities = mutable ? oldEntities : Object.assign({}, oldEntities));
|
|
82
|
+
delete newEntities[id];
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
if (entitiesToReplace) {
|
|
86
|
+
for (const id in entitiesToReplace) {
|
|
87
|
+
const newEntity = entitiesToReplace[id];
|
|
88
|
+
if (oldEntities === undefined || !(deepEqual === null || deepEqual === void 0 ? void 0 : deepEqual(oldEntities[id], newEntity))) {
|
|
89
|
+
newEntities !== null && newEntities !== void 0 ? newEntities : (newEntities = mutable ? (oldEntities !== null && oldEntities !== void 0 ? oldEntities : {}) : Object.assign({}, oldEntities));
|
|
90
|
+
newEntities[id] = newEntity;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (entitiesToMerge) {
|
|
95
|
+
for (const id in entitiesToMerge) {
|
|
96
|
+
const oldEntity = oldEntities === null || oldEntities === void 0 ? void 0 : oldEntities[id];
|
|
97
|
+
const newEntity = Object.assign(Object.assign({}, oldEntity), entitiesToMerge[id]);
|
|
98
|
+
if (!(deepEqual === null || deepEqual === void 0 ? void 0 : deepEqual(oldEntity, newEntity))) {
|
|
99
|
+
newEntities !== null && newEntities !== void 0 ? newEntities : (newEntities = mutable ? (oldEntities !== null && oldEntities !== void 0 ? oldEntities : {}) : Object.assign({}, oldEntities));
|
|
100
|
+
newEntities[id] = newEntity;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (!newEntities) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (mutable) {
|
|
108
|
+
(0, exports.incrementChangeKey)(newEntities);
|
|
109
|
+
if (result === undefined) {
|
|
110
|
+
(0, exports.incrementChangeKey)(entities);
|
|
111
|
+
result = entities;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
result !== null && result !== void 0 ? result : (result = Object.assign({}, entities));
|
|
116
|
+
}
|
|
117
|
+
result[typename] = newEntities;
|
|
170
118
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
exports.applyEntityChanges = applyEntityChanges
|
|
119
|
+
options.logsEnabled &&
|
|
120
|
+
(0, exports.logDebug)('applyEntityChanges', {
|
|
121
|
+
entities,
|
|
122
|
+
changes,
|
|
123
|
+
options,
|
|
124
|
+
result,
|
|
125
|
+
});
|
|
126
|
+
return result;
|
|
127
|
+
};
|
|
128
|
+
exports.applyEntityChanges = applyEntityChanges;
|
|
183
129
|
const isEmptyObject = (obj) => {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
return true
|
|
188
|
-
}
|
|
189
|
-
exports.isEmptyObject = isEmptyObject
|
|
190
|
-
const createStateComparer = (fields) => {
|
|
191
|
-
return (x, y) => {
|
|
192
|
-
if (x === y) {
|
|
193
|
-
return true
|
|
130
|
+
for (const _ in obj) {
|
|
131
|
+
return false;
|
|
194
132
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
133
|
+
return true;
|
|
134
|
+
};
|
|
135
|
+
exports.isEmptyObject = isEmptyObject;
|
|
136
|
+
const createStateComparer = (fields) => {
|
|
137
|
+
return (x, y) => {
|
|
138
|
+
if (x === y) {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
if (x === undefined || y === undefined) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
for (let i = 0; i < fields.length; i += 1) {
|
|
145
|
+
const key = fields[i];
|
|
146
|
+
if (x[key] !== y[key]) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return true;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
exports.createStateComparer = createStateComparer;
|
|
208
154
|
exports.FetchPolicy = {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
155
|
+
NoCacheOrExpired: (expired, _params, state) => {
|
|
156
|
+
return expired || state.result === undefined;
|
|
157
|
+
},
|
|
158
|
+
Always: () => true,
|
|
159
|
+
};
|
|
214
160
|
const incrementChangeKey = (mutable) => {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
|
|
161
|
+
if (mutable._changeKey === undefined) {
|
|
162
|
+
mutable._changeKey = 0;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
mutable._changeKey += 1;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
exports.incrementChangeKey = incrementChangeKey;
|
|
@@ -1,61 +1,60 @@
|
|
|
1
|
-
import {PACKAGE_SHORT_NAME} from './utilsAndConstants'
|
|
2
|
-
|
|
1
|
+
import { PACKAGE_SHORT_NAME } from './utilsAndConstants';
|
|
3
2
|
export const createActions = (name) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
3
|
+
const actionPrefix = `@${PACKAGE_SHORT_NAME}/${name}/`;
|
|
4
|
+
const updateQueryStateAndEntitiesType = `${actionPrefix}updateQueryStateAndEntities`;
|
|
5
|
+
const updateQueryStateAndEntities = (queryKey, queryCacheKey, state, entityChanges) => ({
|
|
6
|
+
type: updateQueryStateAndEntitiesType,
|
|
7
|
+
queryKey,
|
|
8
|
+
queryCacheKey,
|
|
9
|
+
state,
|
|
10
|
+
entityChanges,
|
|
11
|
+
});
|
|
12
|
+
updateQueryStateAndEntities.type = updateQueryStateAndEntitiesType;
|
|
13
|
+
const updateMutationStateAndEntitiesType = `${actionPrefix}updateMutationStateAndEntities`;
|
|
14
|
+
const updateMutationStateAndEntities = (mutationKey, state, entityChanges) => ({
|
|
15
|
+
type: updateMutationStateAndEntitiesType,
|
|
16
|
+
mutationKey,
|
|
17
|
+
state,
|
|
18
|
+
entityChanges,
|
|
19
|
+
});
|
|
20
|
+
updateMutationStateAndEntities.type = updateMutationStateAndEntitiesType;
|
|
21
|
+
const mergeEntityChangesType = `${actionPrefix}mergeEntityChanges`;
|
|
22
|
+
const mergeEntityChanges = (changes) => ({
|
|
23
|
+
type: mergeEntityChangesType,
|
|
24
|
+
changes,
|
|
25
|
+
});
|
|
26
|
+
mergeEntityChanges.type = mergeEntityChangesType;
|
|
27
|
+
const invalidateQueryType = `${actionPrefix}invalidateQuery`;
|
|
28
|
+
const invalidateQuery = (queries) => ({
|
|
29
|
+
type: invalidateQueryType,
|
|
30
|
+
queries,
|
|
31
|
+
});
|
|
32
|
+
invalidateQuery.type = invalidateQueryType;
|
|
33
|
+
const clearQueryStateType = `${actionPrefix}clearQueryState`;
|
|
34
|
+
const clearQueryState = (queries) => ({
|
|
35
|
+
type: clearQueryStateType,
|
|
36
|
+
queries,
|
|
37
|
+
});
|
|
38
|
+
clearQueryState.type = clearQueryStateType;
|
|
39
|
+
const clearMutationStateType = `${actionPrefix}clearMutationState`;
|
|
40
|
+
const clearMutationState = (mutationKeys) => ({
|
|
41
|
+
type: clearMutationStateType,
|
|
42
|
+
mutationKeys,
|
|
43
|
+
});
|
|
44
|
+
clearMutationState.type = clearMutationStateType;
|
|
45
|
+
const clearCacheType = `${actionPrefix}clearCache`;
|
|
46
|
+
const clearCache = (stateToKeep) => ({
|
|
47
|
+
type: clearCacheType,
|
|
48
|
+
stateToKeep,
|
|
49
|
+
});
|
|
50
|
+
clearCache.type = clearCacheType;
|
|
51
|
+
return {
|
|
52
|
+
updateQueryStateAndEntities,
|
|
53
|
+
updateMutationStateAndEntities,
|
|
54
|
+
mergeEntityChanges,
|
|
55
|
+
invalidateQuery,
|
|
56
|
+
clearQueryState,
|
|
57
|
+
clearMutationState,
|
|
58
|
+
clearCache,
|
|
59
|
+
};
|
|
60
|
+
};
|