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,65 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.createActions = void 0
|
|
4
|
-
const utilsAndConstants_1 = require(
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createActions = void 0;
|
|
4
|
+
const utilsAndConstants_1 = require("./utilsAndConstants");
|
|
6
5
|
const createActions = (name) => {
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
exports.createActions = createActions
|
|
6
|
+
const actionPrefix = `@${utilsAndConstants_1.PACKAGE_SHORT_NAME}/${name}/`;
|
|
7
|
+
const updateQueryStateAndEntitiesType = `${actionPrefix}updateQueryStateAndEntities`;
|
|
8
|
+
const updateQueryStateAndEntities = (queryKey, queryCacheKey, state, entityChanges) => ({
|
|
9
|
+
type: updateQueryStateAndEntitiesType,
|
|
10
|
+
queryKey,
|
|
11
|
+
queryCacheKey,
|
|
12
|
+
state,
|
|
13
|
+
entityChanges,
|
|
14
|
+
});
|
|
15
|
+
updateQueryStateAndEntities.type = updateQueryStateAndEntitiesType;
|
|
16
|
+
const updateMutationStateAndEntitiesType = `${actionPrefix}updateMutationStateAndEntities`;
|
|
17
|
+
const updateMutationStateAndEntities = (mutationKey, state, entityChanges) => ({
|
|
18
|
+
type: updateMutationStateAndEntitiesType,
|
|
19
|
+
mutationKey,
|
|
20
|
+
state,
|
|
21
|
+
entityChanges,
|
|
22
|
+
});
|
|
23
|
+
updateMutationStateAndEntities.type = updateMutationStateAndEntitiesType;
|
|
24
|
+
const mergeEntityChangesType = `${actionPrefix}mergeEntityChanges`;
|
|
25
|
+
const mergeEntityChanges = (changes) => ({
|
|
26
|
+
type: mergeEntityChangesType,
|
|
27
|
+
changes,
|
|
28
|
+
});
|
|
29
|
+
mergeEntityChanges.type = mergeEntityChangesType;
|
|
30
|
+
const invalidateQueryType = `${actionPrefix}invalidateQuery`;
|
|
31
|
+
const invalidateQuery = (queries) => ({
|
|
32
|
+
type: invalidateQueryType,
|
|
33
|
+
queries,
|
|
34
|
+
});
|
|
35
|
+
invalidateQuery.type = invalidateQueryType;
|
|
36
|
+
const clearQueryStateType = `${actionPrefix}clearQueryState`;
|
|
37
|
+
const clearQueryState = (queries) => ({
|
|
38
|
+
type: clearQueryStateType,
|
|
39
|
+
queries,
|
|
40
|
+
});
|
|
41
|
+
clearQueryState.type = clearQueryStateType;
|
|
42
|
+
const clearMutationStateType = `${actionPrefix}clearMutationState`;
|
|
43
|
+
const clearMutationState = (mutationKeys) => ({
|
|
44
|
+
type: clearMutationStateType,
|
|
45
|
+
mutationKeys,
|
|
46
|
+
});
|
|
47
|
+
clearMutationState.type = clearMutationStateType;
|
|
48
|
+
const clearCacheType = `${actionPrefix}clearCache`;
|
|
49
|
+
const clearCache = (stateToKeep) => ({
|
|
50
|
+
type: clearCacheType,
|
|
51
|
+
stateToKeep,
|
|
52
|
+
});
|
|
53
|
+
clearCache.type = clearCacheType;
|
|
54
|
+
return {
|
|
55
|
+
updateQueryStateAndEntities,
|
|
56
|
+
updateMutationStateAndEntities,
|
|
57
|
+
mergeEntityChanges,
|
|
58
|
+
invalidateQuery,
|
|
59
|
+
clearQueryState,
|
|
60
|
+
clearMutationState,
|
|
61
|
+
clearCache,
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
exports.createActions = createActions;
|
package/dist/cjs/createCache.js
CHANGED
|
@@ -1,220 +1,134 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.createCache = exports.withTypenames = void 0
|
|
4
|
-
const react_1 = require(
|
|
5
|
-
const createActions_1 = require(
|
|
6
|
-
const createReducer_1 = require(
|
|
7
|
-
const createSelectors_1 = require(
|
|
8
|
-
const mutate_1 = require(
|
|
9
|
-
const query_1 = require(
|
|
10
|
-
const useMutation_1 = require(
|
|
11
|
-
const useQuery_1 = require(
|
|
12
|
-
const utilsAndConstants_1 = require(
|
|
13
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCache = exports.withTypenames = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const createActions_1 = require("./createActions");
|
|
6
|
+
const createReducer_1 = require("./createReducer");
|
|
7
|
+
const createSelectors_1 = require("./createSelectors");
|
|
8
|
+
const mutate_1 = require("./mutate");
|
|
9
|
+
const query_1 = require("./query");
|
|
10
|
+
const useMutation_1 = require("./useMutation");
|
|
11
|
+
const useQuery_1 = require("./useQuery");
|
|
12
|
+
const utilsAndConstants_1 = require("./utilsAndConstants");
|
|
14
13
|
const withTypenames = () => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
;(_j = (_v = partialCache.globals.queries).skipFetch) !== null && _j !== void 0
|
|
39
|
-
? _j
|
|
40
|
-
: (_v.skipFetch = false)
|
|
41
|
-
;(_k = partialCache.cacheStateSelector) !== null && _k !== void 0
|
|
42
|
-
? _k
|
|
43
|
-
: (partialCache.cacheStateSelector = (state) => state[cache.name])
|
|
44
|
-
;(_l = partialCache.mutations) !== null && _l !== void 0 ? _l : (partialCache.mutations = {})
|
|
45
|
-
;(_m = partialCache.queries) !== null && _m !== void 0 ? _m : (partialCache.queries = {})
|
|
46
|
-
partialCache.abortControllers = abortControllers
|
|
47
|
-
try {
|
|
48
|
-
;(_o = partialCache.storeHooks) !== null && _o !== void 0
|
|
49
|
-
? _o
|
|
50
|
-
: (partialCache.storeHooks = {
|
|
51
|
-
useStore: require('react-redux').useStore,
|
|
52
|
-
useSelector: require('react-redux').useSelector,
|
|
53
|
-
})
|
|
54
|
-
} catch (e) {
|
|
55
|
-
throw e
|
|
56
|
-
}
|
|
57
|
-
const cache = partialCache
|
|
58
|
-
if (cache.options.deepComparisonEnabled && !utilsAndConstants_1.optionalUtils.deepEqual) {
|
|
59
|
-
;(0, utilsAndConstants_1.logWarn)(
|
|
60
|
-
'createCache',
|
|
61
|
-
'optional dependency for fast-deep-equal was not provided, while deepComparisonEnabled option is true'
|
|
62
|
-
)
|
|
63
|
-
}
|
|
64
|
-
const setDefaultComparer = (target) => {
|
|
65
|
-
if (
|
|
66
|
-
(target === null || target === void 0 ? void 0 : target.selectorComparer) != null &&
|
|
67
|
-
typeof target.selectorComparer === 'object'
|
|
68
|
-
) {
|
|
69
|
-
target.selectorComparer = (0, utilsAndConstants_1.createStateComparer)(target.selectorComparer)
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
setDefaultComparer(cache.globals.queries)
|
|
73
|
-
for (const queryKey in partialCache.queries) {
|
|
74
|
-
setDefaultComparer(partialCache.queries[queryKey])
|
|
75
|
-
}
|
|
76
|
-
const selectors = Object.assign(
|
|
77
|
-
{selectCacheState: cache.cacheStateSelector},
|
|
78
|
-
(0, createSelectors_1.createSelectors)(cache)
|
|
79
|
-
)
|
|
80
|
-
const {
|
|
81
|
-
selectCacheState,
|
|
82
|
-
selectQueryState,
|
|
83
|
-
selectQueryResult,
|
|
84
|
-
selectQueryLoading,
|
|
85
|
-
selectQueryError,
|
|
86
|
-
selectQueryParams,
|
|
87
|
-
selectQueryExpiresAt,
|
|
88
|
-
selectMutationState,
|
|
89
|
-
selectMutationResult,
|
|
90
|
-
selectMutationLoading,
|
|
91
|
-
selectMutationError,
|
|
92
|
-
selectMutationParams,
|
|
93
|
-
selectEntityById,
|
|
94
|
-
selectEntities,
|
|
95
|
-
selectEntitiesByTypename,
|
|
96
|
-
} = selectors
|
|
97
|
-
const actions = (0, createActions_1.createActions)(cache.name)
|
|
98
|
-
const {
|
|
99
|
-
updateQueryStateAndEntities,
|
|
100
|
-
updateMutationStateAndEntities,
|
|
101
|
-
mergeEntityChanges,
|
|
102
|
-
invalidateQuery,
|
|
103
|
-
clearQueryState,
|
|
104
|
-
clearMutationState,
|
|
105
|
-
clearCache,
|
|
106
|
-
} = actions
|
|
107
|
-
const reducer = (0, createReducer_1.createReducer)(actions, Object.keys(cache.queries), cache.options)
|
|
108
|
-
const createClient = (store) => {
|
|
109
|
-
const client = {
|
|
110
|
-
query: (options) => {
|
|
111
|
-
var _a
|
|
112
|
-
const {query: queryKey, params} = options
|
|
113
|
-
const getCacheKey =
|
|
114
|
-
(_a = cache.queries[queryKey].getCacheKey) !== null && _a !== void 0
|
|
115
|
-
? _a
|
|
116
|
-
: utilsAndConstants_1.defaultGetCacheKey
|
|
117
|
-
const cacheKey = getCacheKey(params)
|
|
118
|
-
return (0, query_1.query)(
|
|
119
|
-
'query',
|
|
120
|
-
store,
|
|
121
|
-
cache,
|
|
122
|
-
actions,
|
|
123
|
-
selectors,
|
|
124
|
-
queryKey,
|
|
125
|
-
cacheKey,
|
|
126
|
-
params,
|
|
127
|
-
options.secondsToLive,
|
|
128
|
-
options.onlyIfExpired,
|
|
129
|
-
options.skipFetch,
|
|
130
|
-
options.mergeResults,
|
|
131
|
-
options.onCompleted,
|
|
132
|
-
options.onSuccess,
|
|
133
|
-
options.onError
|
|
134
|
-
)
|
|
135
|
-
},
|
|
136
|
-
mutate: (options) => {
|
|
137
|
-
return (0, mutate_1.mutate)(
|
|
138
|
-
'mutate',
|
|
139
|
-
store,
|
|
140
|
-
cache,
|
|
141
|
-
actions,
|
|
142
|
-
selectors,
|
|
143
|
-
options.mutation,
|
|
144
|
-
options.params,
|
|
145
|
-
abortControllers,
|
|
146
|
-
options.onCompleted,
|
|
147
|
-
options.onSuccess,
|
|
148
|
-
options.onError
|
|
149
|
-
)
|
|
150
|
-
},
|
|
151
|
-
}
|
|
152
|
-
return client
|
|
153
|
-
}
|
|
154
|
-
return {
|
|
155
|
-
cache,
|
|
156
|
-
reducer,
|
|
157
|
-
actions: {
|
|
158
|
-
updateQueryStateAndEntities,
|
|
159
|
-
updateMutationStateAndEntities,
|
|
160
|
-
mergeEntityChanges,
|
|
161
|
-
invalidateQuery,
|
|
162
|
-
clearQueryState,
|
|
163
|
-
clearMutationState,
|
|
164
|
-
clearCache,
|
|
165
|
-
},
|
|
166
|
-
selectors: {
|
|
167
|
-
selectCacheState,
|
|
168
|
-
selectQueryState,
|
|
169
|
-
selectQueryResult,
|
|
170
|
-
selectQueryLoading,
|
|
171
|
-
selectQueryError,
|
|
172
|
-
selectQueryParams,
|
|
173
|
-
selectQueryExpiresAt,
|
|
174
|
-
selectMutationState,
|
|
175
|
-
selectMutationResult,
|
|
176
|
-
selectMutationLoading,
|
|
177
|
-
selectMutationError,
|
|
178
|
-
selectMutationParams,
|
|
179
|
-
selectEntityById,
|
|
180
|
-
selectEntities,
|
|
181
|
-
selectEntitiesByTypename,
|
|
182
|
-
},
|
|
183
|
-
hooks: {
|
|
184
|
-
useClient: () => {
|
|
185
|
-
const store = cache.storeHooks.useStore()
|
|
186
|
-
return (0, react_1.useMemo)(() => createClient(store), [store])
|
|
187
|
-
},
|
|
188
|
-
useQuery: (options) => (0, useQuery_1.useQuery)(cache, actions, selectors, options),
|
|
189
|
-
useMutation: (options) =>
|
|
190
|
-
(0, useMutation_1.useMutation)(cache, actions, selectors, options, abortControllers),
|
|
191
|
-
useSelectEntityById: (id, typename) => {
|
|
192
|
-
return cache.storeHooks.useSelector((state) => selectEntityById(state, id, typename))
|
|
193
|
-
},
|
|
194
|
-
useEntitiesByTypename: (typename) => {
|
|
195
|
-
if (cache.options.mutableCollections) {
|
|
196
|
-
cache.storeHooks.useSelector((state) => {
|
|
197
|
-
var _a
|
|
198
|
-
return (_a = selectEntitiesByTypename(state, typename)) === null || _a === void 0
|
|
199
|
-
? void 0
|
|
200
|
-
: _a._changeKey
|
|
201
|
-
})
|
|
14
|
+
return {
|
|
15
|
+
createCache: (partialCache) => {
|
|
16
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
17
|
+
var _p, _q, _r, _s, _t, _u, _v;
|
|
18
|
+
const abortControllers = new WeakMap();
|
|
19
|
+
(_a = partialCache.options) !== null && _a !== void 0 ? _a : (partialCache.options = {});
|
|
20
|
+
(_b = (_p = partialCache.options).mutableCollections) !== null && _b !== void 0 ? _b : (_p.mutableCollections = false);
|
|
21
|
+
(_c = (_q = partialCache.options).logsEnabled) !== null && _c !== void 0 ? _c : (_q.logsEnabled = false);
|
|
22
|
+
(_d = (_r = partialCache.options).additionalValidation) !== null && _d !== void 0 ? _d : (_r.additionalValidation = utilsAndConstants_1.IS_DEV);
|
|
23
|
+
(_e = (_s = partialCache.options).deepComparisonEnabled) !== null && _e !== void 0 ? _e : (_s.deepComparisonEnabled = true);
|
|
24
|
+
(_f = partialCache.globals) !== null && _f !== void 0 ? _f : (partialCache.globals = {});
|
|
25
|
+
(_g = (_t = partialCache.globals).queries) !== null && _g !== void 0 ? _g : (_t.queries = {});
|
|
26
|
+
(_h = (_u = partialCache.globals.queries).fetchPolicy) !== null && _h !== void 0 ? _h : (_u.fetchPolicy = utilsAndConstants_1.FetchPolicy.NoCacheOrExpired);
|
|
27
|
+
(_j = (_v = partialCache.globals.queries).skipFetch) !== null && _j !== void 0 ? _j : (_v.skipFetch = false);
|
|
28
|
+
(_k = partialCache.cacheStateSelector) !== null && _k !== void 0 ? _k : (partialCache.cacheStateSelector = (state) => state[cache.name]);
|
|
29
|
+
(_l = partialCache.mutations) !== null && _l !== void 0 ? _l : (partialCache.mutations = {});
|
|
30
|
+
(_m = partialCache.queries) !== null && _m !== void 0 ? _m : (partialCache.queries = {});
|
|
31
|
+
partialCache.abortControllers = abortControllers;
|
|
32
|
+
try {
|
|
33
|
+
(_o = partialCache.storeHooks) !== null && _o !== void 0 ? _o : (partialCache.storeHooks = {
|
|
34
|
+
useStore: require('react-redux').useStore,
|
|
35
|
+
useSelector: require('react-redux').useSelector,
|
|
36
|
+
});
|
|
202
37
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
38
|
+
catch (e) {
|
|
39
|
+
throw e;
|
|
40
|
+
}
|
|
41
|
+
const cache = partialCache;
|
|
42
|
+
if (cache.options.deepComparisonEnabled && !utilsAndConstants_1.optionalUtils.deepEqual) {
|
|
43
|
+
(0, utilsAndConstants_1.logWarn)('createCache', 'optional dependency for fast-deep-equal was not provided, while deepComparisonEnabled option is true');
|
|
44
|
+
}
|
|
45
|
+
const setDefaultComparer = (target) => {
|
|
46
|
+
if ((target === null || target === void 0 ? void 0 : target.selectorComparer) != null && typeof target.selectorComparer === 'object') {
|
|
47
|
+
target.selectorComparer = (0, utilsAndConstants_1.createStateComparer)(target.selectorComparer);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
setDefaultComparer(cache.globals.queries);
|
|
51
|
+
for (const queryKey in partialCache.queries) {
|
|
52
|
+
setDefaultComparer(partialCache.queries[queryKey]);
|
|
53
|
+
}
|
|
54
|
+
const selectors = Object.assign({ selectCacheState: cache.cacheStateSelector }, (0, createSelectors_1.createSelectors)(cache));
|
|
55
|
+
const { selectCacheState, selectQueryState, selectQueryResult, selectQueryLoading, selectQueryError, selectQueryParams, selectQueryExpiresAt, selectMutationState, selectMutationResult, selectMutationLoading, selectMutationError, selectMutationParams, selectEntityById, selectEntities, selectEntitiesByTypename, } = selectors;
|
|
56
|
+
const actions = (0, createActions_1.createActions)(cache.name);
|
|
57
|
+
const { updateQueryStateAndEntities, updateMutationStateAndEntities, mergeEntityChanges, invalidateQuery, clearQueryState, clearMutationState, clearCache, } = actions;
|
|
58
|
+
const reducer = (0, createReducer_1.createReducer)(actions, Object.keys(cache.queries), cache.options);
|
|
59
|
+
const createClient = (store) => {
|
|
60
|
+
const client = {
|
|
61
|
+
query: (options) => {
|
|
62
|
+
var _a;
|
|
63
|
+
const { query: queryKey, params } = options;
|
|
64
|
+
const getCacheKey = (_a = cache.queries[queryKey].getCacheKey) !== null && _a !== void 0 ? _a : (utilsAndConstants_1.defaultGetCacheKey);
|
|
65
|
+
const cacheKey = getCacheKey(params);
|
|
66
|
+
return (0, query_1.query)('query', store, cache, actions, selectors, queryKey, cacheKey, params, options.secondsToLive, options.onlyIfExpired, options.skipFetch, options.mergeResults, options.onCompleted, options.onSuccess, options.onError);
|
|
67
|
+
},
|
|
68
|
+
mutate: (options) => {
|
|
69
|
+
return (0, mutate_1.mutate)('mutate', store, cache, actions, selectors, options.mutation, options.params, abortControllers, options.onCompleted, options.onSuccess, options.onError);
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
return client;
|
|
73
|
+
};
|
|
74
|
+
return {
|
|
75
|
+
cache,
|
|
76
|
+
reducer,
|
|
77
|
+
actions: {
|
|
78
|
+
updateQueryStateAndEntities,
|
|
79
|
+
updateMutationStateAndEntities,
|
|
80
|
+
mergeEntityChanges,
|
|
81
|
+
invalidateQuery,
|
|
82
|
+
clearQueryState,
|
|
83
|
+
clearMutationState,
|
|
84
|
+
clearCache,
|
|
85
|
+
},
|
|
86
|
+
selectors: {
|
|
87
|
+
selectCacheState,
|
|
88
|
+
selectQueryState,
|
|
89
|
+
selectQueryResult,
|
|
90
|
+
selectQueryLoading,
|
|
91
|
+
selectQueryError,
|
|
92
|
+
selectQueryParams,
|
|
93
|
+
selectQueryExpiresAt,
|
|
94
|
+
selectMutationState,
|
|
95
|
+
selectMutationResult,
|
|
96
|
+
selectMutationLoading,
|
|
97
|
+
selectMutationError,
|
|
98
|
+
selectMutationParams,
|
|
99
|
+
selectEntityById,
|
|
100
|
+
selectEntities,
|
|
101
|
+
selectEntitiesByTypename,
|
|
102
|
+
},
|
|
103
|
+
hooks: {
|
|
104
|
+
useClient: () => {
|
|
105
|
+
const store = cache.storeHooks.useStore();
|
|
106
|
+
return (0, react_1.useMemo)(() => createClient(store), [store]);
|
|
107
|
+
},
|
|
108
|
+
useQuery: (options) => (0, useQuery_1.useQuery)(cache, actions, selectors, options),
|
|
109
|
+
useMutation: (options) => (0, useMutation_1.useMutation)(cache, actions, selectors, options, abortControllers),
|
|
110
|
+
useSelectEntityById: (id, typename) => {
|
|
111
|
+
return cache.storeHooks.useSelector((state) => selectEntityById(state, id, typename));
|
|
112
|
+
},
|
|
113
|
+
useEntitiesByTypename: (typename) => {
|
|
114
|
+
if (cache.options.mutableCollections) {
|
|
115
|
+
cache.storeHooks.useSelector((state) => { var _a; return (_a = selectEntitiesByTypename(state, typename)) === null || _a === void 0 ? void 0 : _a._changeKey; });
|
|
116
|
+
}
|
|
117
|
+
return cache.storeHooks.useSelector((state) => selectEntitiesByTypename(state, typename));
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
utils: {
|
|
121
|
+
createClient,
|
|
122
|
+
getInitialState: () => {
|
|
123
|
+
return reducer(undefined, utilsAndConstants_1.EMPTY_OBJECT);
|
|
124
|
+
},
|
|
125
|
+
applyEntityChanges: (entities, changes) => {
|
|
126
|
+
return (0, utilsAndConstants_1.applyEntityChanges)(entities, changes, cache.options);
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
};
|
|
214
130
|
},
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
exports.withTypenames = withTypenames
|
|
220
|
-
exports.createCache = (0, exports.withTypenames)().createCache
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
exports.withTypenames = withTypenames;
|
|
134
|
+
exports.createCache = (0, exports.withTypenames)().createCache;
|