@fjell/cache 4.6.2 → 4.6.3
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/Aggregator.cjs.js +16 -3
- package/dist/Aggregator.es.js +16 -3
- package/dist/Cache.cjs.js +29 -16
- package/dist/Cache.d.ts +7 -6
- package/dist/Cache.es.js +29 -16
- package/dist/index.cjs +43 -17
- package/dist/index.cjs.map +1 -1
- package/package.json +5 -5
- package/src/Aggregator.ts +13 -2
- package/src/Cache.ts +38 -19
package/dist/Aggregator.cjs.js
CHANGED
|
@@ -161,6 +161,18 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
|
|
|
161
161
|
populatedItems
|
|
162
162
|
];
|
|
163
163
|
};
|
|
164
|
+
const allFacet = async (facet, params = {}, locations = [])=>{
|
|
165
|
+
logger.default('allFacet', {
|
|
166
|
+
facet,
|
|
167
|
+
params,
|
|
168
|
+
locations
|
|
169
|
+
});
|
|
170
|
+
const [cacheMap, response] = await cache.allFacet(facet, params, locations);
|
|
171
|
+
return [
|
|
172
|
+
cacheMap,
|
|
173
|
+
response
|
|
174
|
+
];
|
|
175
|
+
};
|
|
164
176
|
const create = async (v, locations = [])=>{
|
|
165
177
|
logger.default('create', {
|
|
166
178
|
v,
|
|
@@ -232,7 +244,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
|
|
|
232
244
|
response
|
|
233
245
|
];
|
|
234
246
|
};
|
|
235
|
-
const find = async (finder, finderParams, locations = [])=>{
|
|
247
|
+
const find = async (finder, finderParams = {}, locations = [])=>{
|
|
236
248
|
logger.default('find', {
|
|
237
249
|
finder,
|
|
238
250
|
finderParams,
|
|
@@ -245,7 +257,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
|
|
|
245
257
|
populatedItems
|
|
246
258
|
];
|
|
247
259
|
};
|
|
248
|
-
const findOne = async (finder, finderParams, locations = [])=>{
|
|
260
|
+
const findOne = async (finder, finderParams = {}, locations = [])=>{
|
|
249
261
|
logger.default('find', {
|
|
250
262
|
finder,
|
|
251
263
|
finderParams,
|
|
@@ -280,6 +292,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
|
|
|
280
292
|
one,
|
|
281
293
|
action,
|
|
282
294
|
allAction,
|
|
295
|
+
allFacet,
|
|
283
296
|
create,
|
|
284
297
|
get,
|
|
285
298
|
retrieve,
|
|
@@ -300,4 +313,4 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
|
|
|
300
313
|
|
|
301
314
|
exports.createAggregator = createAggregator;
|
|
302
315
|
exports.toCacheConfig = toCacheConfig;
|
|
303
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
316
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQWdncmVnYXRvci5janMuanMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9
|
package/dist/Aggregator.es.js
CHANGED
|
@@ -157,6 +157,18 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
|
|
|
157
157
|
populatedItems
|
|
158
158
|
];
|
|
159
159
|
};
|
|
160
|
+
const allFacet = async (facet, params = {}, locations = [])=>{
|
|
161
|
+
logger.default('allFacet', {
|
|
162
|
+
facet,
|
|
163
|
+
params,
|
|
164
|
+
locations
|
|
165
|
+
});
|
|
166
|
+
const [cacheMap, response] = await cache.allFacet(facet, params, locations);
|
|
167
|
+
return [
|
|
168
|
+
cacheMap,
|
|
169
|
+
response
|
|
170
|
+
];
|
|
171
|
+
};
|
|
160
172
|
const create = async (v, locations = [])=>{
|
|
161
173
|
logger.default('create', {
|
|
162
174
|
v,
|
|
@@ -228,7 +240,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
|
|
|
228
240
|
response
|
|
229
241
|
];
|
|
230
242
|
};
|
|
231
|
-
const find = async (finder, finderParams, locations = [])=>{
|
|
243
|
+
const find = async (finder, finderParams = {}, locations = [])=>{
|
|
232
244
|
logger.default('find', {
|
|
233
245
|
finder,
|
|
234
246
|
finderParams,
|
|
@@ -241,7 +253,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
|
|
|
241
253
|
populatedItems
|
|
242
254
|
];
|
|
243
255
|
};
|
|
244
|
-
const findOne = async (finder, finderParams, locations = [])=>{
|
|
256
|
+
const findOne = async (finder, finderParams = {}, locations = [])=>{
|
|
245
257
|
logger.default('find', {
|
|
246
258
|
finder,
|
|
247
259
|
finderParams,
|
|
@@ -276,6 +288,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
|
|
|
276
288
|
one,
|
|
277
289
|
action,
|
|
278
290
|
allAction,
|
|
291
|
+
allFacet,
|
|
279
292
|
create,
|
|
280
293
|
get,
|
|
281
294
|
retrieve,
|
|
@@ -295,4 +308,4 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
|
|
|
295
308
|
};
|
|
296
309
|
|
|
297
310
|
export { createAggregator, toCacheConfig };
|
|
298
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
311
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQWdncmVnYXRvci5lcy5qcyIsInNvdXJjZXMiOltdLCJzb3VyY2VzQ29udGVudCI6W10sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9
|
package/dist/Cache.cjs.js
CHANGED
|
@@ -23,7 +23,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
23
23
|
});
|
|
24
24
|
let ret = [];
|
|
25
25
|
try {
|
|
26
|
-
ret = await api.all(query,
|
|
26
|
+
ret = await api.all(query, locations);
|
|
27
27
|
ret.forEach((v)=>{
|
|
28
28
|
cacheMap.set(v.key, v);
|
|
29
29
|
});
|
|
@@ -44,7 +44,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
44
44
|
});
|
|
45
45
|
let retItem = null;
|
|
46
46
|
try {
|
|
47
|
-
retItem = await api.one(query,
|
|
47
|
+
retItem = await api.one(query, locations);
|
|
48
48
|
if (retItem) {
|
|
49
49
|
cacheMap.set(retItem.key, retItem);
|
|
50
50
|
}
|
|
@@ -70,7 +70,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
70
70
|
logger.error('Key for Action is not a valid ItemKey: %j', key);
|
|
71
71
|
throw new Error('Key for Action is not a valid ItemKey');
|
|
72
72
|
}
|
|
73
|
-
const updated = await api.action(key, action, body
|
|
73
|
+
const updated = await api.action(key, action, body);
|
|
74
74
|
cacheMap.set(updated.key, updated);
|
|
75
75
|
return [
|
|
76
76
|
cacheMap,
|
|
@@ -85,7 +85,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
85
85
|
});
|
|
86
86
|
let ret = [];
|
|
87
87
|
try {
|
|
88
|
-
ret = await api.allAction(action, body,
|
|
88
|
+
ret = await api.allAction(action, body, locations);
|
|
89
89
|
ret.forEach((v)=>{
|
|
90
90
|
cacheMap.set(v.key, v);
|
|
91
91
|
});
|
|
@@ -100,12 +100,24 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
100
100
|
core.validatePK(ret, pkType)
|
|
101
101
|
];
|
|
102
102
|
};
|
|
103
|
+
const allFacet = async (facet, params = {}, locations = [])=>{
|
|
104
|
+
logger.default('allFacet', {
|
|
105
|
+
facet,
|
|
106
|
+
params,
|
|
107
|
+
locations
|
|
108
|
+
});
|
|
109
|
+
const ret = await api.allFacet(facet, params, locations);
|
|
110
|
+
return [
|
|
111
|
+
cacheMap,
|
|
112
|
+
ret
|
|
113
|
+
];
|
|
114
|
+
};
|
|
103
115
|
const create = async (v, locations = [])=>{
|
|
104
116
|
logger.default('create', {
|
|
105
117
|
v,
|
|
106
118
|
locations
|
|
107
119
|
});
|
|
108
|
-
const created = await api.create(v,
|
|
120
|
+
const created = await api.create(v, locations);
|
|
109
121
|
cacheMap.set(created.key, created);
|
|
110
122
|
return [
|
|
111
123
|
cacheMap,
|
|
@@ -124,7 +136,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
124
136
|
}
|
|
125
137
|
let ret;
|
|
126
138
|
try {
|
|
127
|
-
ret = await api.get(key
|
|
139
|
+
ret = await api.get(key);
|
|
128
140
|
if (ret) {
|
|
129
141
|
cacheMap.set(ret.key, ret);
|
|
130
142
|
}
|
|
@@ -178,7 +190,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
178
190
|
throw new Error('Key for Remove is not a valid ItemKey');
|
|
179
191
|
}
|
|
180
192
|
try {
|
|
181
|
-
await api.remove(key
|
|
193
|
+
await api.remove(key);
|
|
182
194
|
cacheMap.delete(key);
|
|
183
195
|
} catch (e) {
|
|
184
196
|
logger.error("Error deleting item", {
|
|
@@ -200,7 +212,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
200
212
|
throw new Error('Key for Update is not a valid ItemKey');
|
|
201
213
|
}
|
|
202
214
|
try {
|
|
203
|
-
const updated = await api.update(key, v
|
|
215
|
+
const updated = await api.update(key, v);
|
|
204
216
|
cacheMap.set(updated.key, updated);
|
|
205
217
|
return [
|
|
206
218
|
cacheMap,
|
|
@@ -214,24 +226,24 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
214
226
|
}
|
|
215
227
|
};
|
|
216
228
|
// Facets are a pass-thru for caches
|
|
217
|
-
const facet = async (key, facet)=>{
|
|
229
|
+
const facet = async (key, facet, params = {})=>{
|
|
218
230
|
logger.default('facet', {
|
|
219
231
|
key,
|
|
220
232
|
facet
|
|
221
233
|
});
|
|
222
|
-
const ret = await api.facet(key, facet,
|
|
234
|
+
const ret = await api.facet(key, facet, params);
|
|
223
235
|
return [
|
|
224
236
|
cacheMap,
|
|
225
237
|
ret
|
|
226
238
|
];
|
|
227
239
|
};
|
|
228
|
-
const find = async (finder,
|
|
240
|
+
const find = async (finder, params = {}, locations = [])=>{
|
|
229
241
|
logger.default('find', {
|
|
230
242
|
finder,
|
|
231
|
-
|
|
243
|
+
params,
|
|
232
244
|
locations
|
|
233
245
|
});
|
|
234
|
-
const ret = await api.find(finder,
|
|
246
|
+
const ret = await api.find(finder, params, locations);
|
|
235
247
|
ret.forEach((v)=>{
|
|
236
248
|
cacheMap.set(v.key, v);
|
|
237
249
|
});
|
|
@@ -240,13 +252,13 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
240
252
|
core.validatePK(ret, pkType)
|
|
241
253
|
];
|
|
242
254
|
};
|
|
243
|
-
const findOne = async (finder, finderParams, locations = [])=>{
|
|
255
|
+
const findOne = async (finder, finderParams = {}, locations = [])=>{
|
|
244
256
|
logger.default('findOne', {
|
|
245
257
|
finder,
|
|
246
258
|
finderParams,
|
|
247
259
|
locations
|
|
248
260
|
});
|
|
249
|
-
const ret = await api.findOne(finder, finderParams,
|
|
261
|
+
const ret = await api.findOne(finder, finderParams, locations);
|
|
250
262
|
cacheMap.set(ret.key, ret);
|
|
251
263
|
return [
|
|
252
264
|
cacheMap,
|
|
@@ -287,6 +299,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
287
299
|
one,
|
|
288
300
|
action,
|
|
289
301
|
allAction,
|
|
302
|
+
allFacet,
|
|
290
303
|
create,
|
|
291
304
|
get,
|
|
292
305
|
retrieve,
|
|
@@ -303,4 +316,4 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
303
316
|
};
|
|
304
317
|
|
|
305
318
|
exports.createCache = createCache;
|
|
306
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
319
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ2FjaGUuY2pzLmpzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OzsifQ==
|
package/dist/Cache.d.ts
CHANGED
|
@@ -6,15 +6,16 @@ export interface Cache<V extends Item<S, L1, L2, L3, L4, L5>, S extends string,
|
|
|
6
6
|
one: (query?: ItemQuery, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V | null]>;
|
|
7
7
|
action: (key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, action: string, body?: any) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]>;
|
|
8
8
|
allAction: (action: string, body?: any, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V[]]>;
|
|
9
|
-
|
|
9
|
+
allFacet: (facet: string, params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, any]>;
|
|
10
|
+
create: (item: TypesProperties<V, S, L1, L2, L3, L4, L5>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]>;
|
|
10
11
|
get: (key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V | null]>;
|
|
11
12
|
retrieve: (key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5> | null, V | null]>;
|
|
12
13
|
remove: (key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>) => Promise<CacheMap<V, S, L1, L2, L3, L4, L5>>;
|
|
13
|
-
update: (key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
|
|
14
|
-
facet: (key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, facet: string) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, any]>;
|
|
15
|
-
find: (finder: string,
|
|
16
|
-
findOne: (finder: string,
|
|
17
|
-
set: (key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
|
|
14
|
+
update: (key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, item: TypesProperties<V, S, L1, L2, L3, L4, L5>) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]>;
|
|
15
|
+
facet: (key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, facet: string, params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, any]>;
|
|
16
|
+
find: (finder: string, params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V[]]>;
|
|
17
|
+
findOne: (finder: string, params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]>;
|
|
18
|
+
set: (key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, item: Item<S, L1, L2, L3, L4, L5>) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]>;
|
|
18
19
|
reset: () => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>]>;
|
|
19
20
|
pkTypes: AllItemTypeArrays<S, L1, L2, L3, L4, L5>;
|
|
20
21
|
cacheMap: CacheMap<V, S, L1, L2, L3, L4, L5>;
|
package/dist/Cache.es.js
CHANGED
|
@@ -19,7 +19,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
19
19
|
});
|
|
20
20
|
let ret = [];
|
|
21
21
|
try {
|
|
22
|
-
ret = await api.all(query,
|
|
22
|
+
ret = await api.all(query, locations);
|
|
23
23
|
ret.forEach((v)=>{
|
|
24
24
|
cacheMap.set(v.key, v);
|
|
25
25
|
});
|
|
@@ -40,7 +40,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
40
40
|
});
|
|
41
41
|
let retItem = null;
|
|
42
42
|
try {
|
|
43
|
-
retItem = await api.one(query,
|
|
43
|
+
retItem = await api.one(query, locations);
|
|
44
44
|
if (retItem) {
|
|
45
45
|
cacheMap.set(retItem.key, retItem);
|
|
46
46
|
}
|
|
@@ -66,7 +66,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
66
66
|
logger.error('Key for Action is not a valid ItemKey: %j', key);
|
|
67
67
|
throw new Error('Key for Action is not a valid ItemKey');
|
|
68
68
|
}
|
|
69
|
-
const updated = await api.action(key, action, body
|
|
69
|
+
const updated = await api.action(key, action, body);
|
|
70
70
|
cacheMap.set(updated.key, updated);
|
|
71
71
|
return [
|
|
72
72
|
cacheMap,
|
|
@@ -81,7 +81,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
81
81
|
});
|
|
82
82
|
let ret = [];
|
|
83
83
|
try {
|
|
84
|
-
ret = await api.allAction(action, body,
|
|
84
|
+
ret = await api.allAction(action, body, locations);
|
|
85
85
|
ret.forEach((v)=>{
|
|
86
86
|
cacheMap.set(v.key, v);
|
|
87
87
|
});
|
|
@@ -96,12 +96,24 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
96
96
|
validatePK(ret, pkType)
|
|
97
97
|
];
|
|
98
98
|
};
|
|
99
|
+
const allFacet = async (facet, params = {}, locations = [])=>{
|
|
100
|
+
logger.default('allFacet', {
|
|
101
|
+
facet,
|
|
102
|
+
params,
|
|
103
|
+
locations
|
|
104
|
+
});
|
|
105
|
+
const ret = await api.allFacet(facet, params, locations);
|
|
106
|
+
return [
|
|
107
|
+
cacheMap,
|
|
108
|
+
ret
|
|
109
|
+
];
|
|
110
|
+
};
|
|
99
111
|
const create = async (v, locations = [])=>{
|
|
100
112
|
logger.default('create', {
|
|
101
113
|
v,
|
|
102
114
|
locations
|
|
103
115
|
});
|
|
104
|
-
const created = await api.create(v,
|
|
116
|
+
const created = await api.create(v, locations);
|
|
105
117
|
cacheMap.set(created.key, created);
|
|
106
118
|
return [
|
|
107
119
|
cacheMap,
|
|
@@ -120,7 +132,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
120
132
|
}
|
|
121
133
|
let ret;
|
|
122
134
|
try {
|
|
123
|
-
ret = await api.get(key
|
|
135
|
+
ret = await api.get(key);
|
|
124
136
|
if (ret) {
|
|
125
137
|
cacheMap.set(ret.key, ret);
|
|
126
138
|
}
|
|
@@ -174,7 +186,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
174
186
|
throw new Error('Key for Remove is not a valid ItemKey');
|
|
175
187
|
}
|
|
176
188
|
try {
|
|
177
|
-
await api.remove(key
|
|
189
|
+
await api.remove(key);
|
|
178
190
|
cacheMap.delete(key);
|
|
179
191
|
} catch (e) {
|
|
180
192
|
logger.error("Error deleting item", {
|
|
@@ -196,7 +208,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
196
208
|
throw new Error('Key for Update is not a valid ItemKey');
|
|
197
209
|
}
|
|
198
210
|
try {
|
|
199
|
-
const updated = await api.update(key, v
|
|
211
|
+
const updated = await api.update(key, v);
|
|
200
212
|
cacheMap.set(updated.key, updated);
|
|
201
213
|
return [
|
|
202
214
|
cacheMap,
|
|
@@ -210,24 +222,24 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
210
222
|
}
|
|
211
223
|
};
|
|
212
224
|
// Facets are a pass-thru for caches
|
|
213
|
-
const facet = async (key, facet)=>{
|
|
225
|
+
const facet = async (key, facet, params = {})=>{
|
|
214
226
|
logger.default('facet', {
|
|
215
227
|
key,
|
|
216
228
|
facet
|
|
217
229
|
});
|
|
218
|
-
const ret = await api.facet(key, facet,
|
|
230
|
+
const ret = await api.facet(key, facet, params);
|
|
219
231
|
return [
|
|
220
232
|
cacheMap,
|
|
221
233
|
ret
|
|
222
234
|
];
|
|
223
235
|
};
|
|
224
|
-
const find = async (finder,
|
|
236
|
+
const find = async (finder, params = {}, locations = [])=>{
|
|
225
237
|
logger.default('find', {
|
|
226
238
|
finder,
|
|
227
|
-
|
|
239
|
+
params,
|
|
228
240
|
locations
|
|
229
241
|
});
|
|
230
|
-
const ret = await api.find(finder,
|
|
242
|
+
const ret = await api.find(finder, params, locations);
|
|
231
243
|
ret.forEach((v)=>{
|
|
232
244
|
cacheMap.set(v.key, v);
|
|
233
245
|
});
|
|
@@ -236,13 +248,13 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
236
248
|
validatePK(ret, pkType)
|
|
237
249
|
];
|
|
238
250
|
};
|
|
239
|
-
const findOne = async (finder, finderParams, locations = [])=>{
|
|
251
|
+
const findOne = async (finder, finderParams = {}, locations = [])=>{
|
|
240
252
|
logger.default('findOne', {
|
|
241
253
|
finder,
|
|
242
254
|
finderParams,
|
|
243
255
|
locations
|
|
244
256
|
});
|
|
245
|
-
const ret = await api.findOne(finder, finderParams,
|
|
257
|
+
const ret = await api.findOne(finder, finderParams, locations);
|
|
246
258
|
cacheMap.set(ret.key, ret);
|
|
247
259
|
return [
|
|
248
260
|
cacheMap,
|
|
@@ -283,6 +295,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
283
295
|
one,
|
|
284
296
|
action,
|
|
285
297
|
allAction,
|
|
298
|
+
allFacet,
|
|
286
299
|
create,
|
|
287
300
|
get,
|
|
288
301
|
retrieve,
|
|
@@ -299,4 +312,4 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
299
312
|
};
|
|
300
313
|
|
|
301
314
|
export { createCache };
|
|
302
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
315
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ2FjaGUuZXMuanMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7In0=
|
package/dist/index.cjs
CHANGED
|
@@ -165,6 +165,18 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
|
|
|
165
165
|
populatedItems
|
|
166
166
|
];
|
|
167
167
|
};
|
|
168
|
+
const allFacet = async (facet, params = {}, locations = [])=>{
|
|
169
|
+
logger$3.default('allFacet', {
|
|
170
|
+
facet,
|
|
171
|
+
params,
|
|
172
|
+
locations
|
|
173
|
+
});
|
|
174
|
+
const [cacheMap, response] = await cache.allFacet(facet, params, locations);
|
|
175
|
+
return [
|
|
176
|
+
cacheMap,
|
|
177
|
+
response
|
|
178
|
+
];
|
|
179
|
+
};
|
|
168
180
|
const create = async (v, locations = [])=>{
|
|
169
181
|
logger$3.default('create', {
|
|
170
182
|
v,
|
|
@@ -236,7 +248,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
|
|
|
236
248
|
response
|
|
237
249
|
];
|
|
238
250
|
};
|
|
239
|
-
const find = async (finder, finderParams, locations = [])=>{
|
|
251
|
+
const find = async (finder, finderParams = {}, locations = [])=>{
|
|
240
252
|
logger$3.default('find', {
|
|
241
253
|
finder,
|
|
242
254
|
finderParams,
|
|
@@ -249,7 +261,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
|
|
|
249
261
|
populatedItems
|
|
250
262
|
];
|
|
251
263
|
};
|
|
252
|
-
const findOne = async (finder, finderParams, locations = [])=>{
|
|
264
|
+
const findOne = async (finder, finderParams = {}, locations = [])=>{
|
|
253
265
|
logger$3.default('find', {
|
|
254
266
|
finder,
|
|
255
267
|
finderParams,
|
|
@@ -284,6 +296,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
|
|
|
284
296
|
one,
|
|
285
297
|
action,
|
|
286
298
|
allAction,
|
|
299
|
+
allFacet,
|
|
287
300
|
create,
|
|
288
301
|
get,
|
|
289
302
|
retrieve,
|
|
@@ -417,7 +430,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
417
430
|
});
|
|
418
431
|
let ret = [];
|
|
419
432
|
try {
|
|
420
|
-
ret = await api.all(query,
|
|
433
|
+
ret = await api.all(query, locations);
|
|
421
434
|
ret.forEach((v)=>{
|
|
422
435
|
cacheMap.set(v.key, v);
|
|
423
436
|
});
|
|
@@ -438,7 +451,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
438
451
|
});
|
|
439
452
|
let retItem = null;
|
|
440
453
|
try {
|
|
441
|
-
retItem = await api.one(query,
|
|
454
|
+
retItem = await api.one(query, locations);
|
|
442
455
|
if (retItem) {
|
|
443
456
|
cacheMap.set(retItem.key, retItem);
|
|
444
457
|
}
|
|
@@ -464,7 +477,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
464
477
|
logger$1.error('Key for Action is not a valid ItemKey: %j', key);
|
|
465
478
|
throw new Error('Key for Action is not a valid ItemKey');
|
|
466
479
|
}
|
|
467
|
-
const updated = await api.action(key, action, body
|
|
480
|
+
const updated = await api.action(key, action, body);
|
|
468
481
|
cacheMap.set(updated.key, updated);
|
|
469
482
|
return [
|
|
470
483
|
cacheMap,
|
|
@@ -479,7 +492,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
479
492
|
});
|
|
480
493
|
let ret = [];
|
|
481
494
|
try {
|
|
482
|
-
ret = await api.allAction(action, body,
|
|
495
|
+
ret = await api.allAction(action, body, locations);
|
|
483
496
|
ret.forEach((v)=>{
|
|
484
497
|
cacheMap.set(v.key, v);
|
|
485
498
|
});
|
|
@@ -494,12 +507,24 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
494
507
|
core.validatePK(ret, pkType)
|
|
495
508
|
];
|
|
496
509
|
};
|
|
510
|
+
const allFacet = async (facet, params = {}, locations = [])=>{
|
|
511
|
+
logger$1.default('allFacet', {
|
|
512
|
+
facet,
|
|
513
|
+
params,
|
|
514
|
+
locations
|
|
515
|
+
});
|
|
516
|
+
const ret = await api.allFacet(facet, params, locations);
|
|
517
|
+
return [
|
|
518
|
+
cacheMap,
|
|
519
|
+
ret
|
|
520
|
+
];
|
|
521
|
+
};
|
|
497
522
|
const create = async (v, locations = [])=>{
|
|
498
523
|
logger$1.default('create', {
|
|
499
524
|
v,
|
|
500
525
|
locations
|
|
501
526
|
});
|
|
502
|
-
const created = await api.create(v,
|
|
527
|
+
const created = await api.create(v, locations);
|
|
503
528
|
cacheMap.set(created.key, created);
|
|
504
529
|
return [
|
|
505
530
|
cacheMap,
|
|
@@ -518,7 +543,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
518
543
|
}
|
|
519
544
|
let ret;
|
|
520
545
|
try {
|
|
521
|
-
ret = await api.get(key
|
|
546
|
+
ret = await api.get(key);
|
|
522
547
|
if (ret) {
|
|
523
548
|
cacheMap.set(ret.key, ret);
|
|
524
549
|
}
|
|
@@ -572,7 +597,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
572
597
|
throw new Error('Key for Remove is not a valid ItemKey');
|
|
573
598
|
}
|
|
574
599
|
try {
|
|
575
|
-
await api.remove(key
|
|
600
|
+
await api.remove(key);
|
|
576
601
|
cacheMap.delete(key);
|
|
577
602
|
} catch (e) {
|
|
578
603
|
logger$1.error("Error deleting item", {
|
|
@@ -594,7 +619,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
594
619
|
throw new Error('Key for Update is not a valid ItemKey');
|
|
595
620
|
}
|
|
596
621
|
try {
|
|
597
|
-
const updated = await api.update(key, v
|
|
622
|
+
const updated = await api.update(key, v);
|
|
598
623
|
cacheMap.set(updated.key, updated);
|
|
599
624
|
return [
|
|
600
625
|
cacheMap,
|
|
@@ -608,24 +633,24 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
608
633
|
}
|
|
609
634
|
};
|
|
610
635
|
// Facets are a pass-thru for caches
|
|
611
|
-
const facet = async (key, facet)=>{
|
|
636
|
+
const facet = async (key, facet, params = {})=>{
|
|
612
637
|
logger$1.default('facet', {
|
|
613
638
|
key,
|
|
614
639
|
facet
|
|
615
640
|
});
|
|
616
|
-
const ret = await api.facet(key, facet,
|
|
641
|
+
const ret = await api.facet(key, facet, params);
|
|
617
642
|
return [
|
|
618
643
|
cacheMap,
|
|
619
644
|
ret
|
|
620
645
|
];
|
|
621
646
|
};
|
|
622
|
-
const find = async (finder,
|
|
647
|
+
const find = async (finder, params = {}, locations = [])=>{
|
|
623
648
|
logger$1.default('find', {
|
|
624
649
|
finder,
|
|
625
|
-
|
|
650
|
+
params,
|
|
626
651
|
locations
|
|
627
652
|
});
|
|
628
|
-
const ret = await api.find(finder,
|
|
653
|
+
const ret = await api.find(finder, params, locations);
|
|
629
654
|
ret.forEach((v)=>{
|
|
630
655
|
cacheMap.set(v.key, v);
|
|
631
656
|
});
|
|
@@ -634,13 +659,13 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
634
659
|
core.validatePK(ret, pkType)
|
|
635
660
|
];
|
|
636
661
|
};
|
|
637
|
-
const findOne = async (finder, finderParams, locations = [])=>{
|
|
662
|
+
const findOne = async (finder, finderParams = {}, locations = [])=>{
|
|
638
663
|
logger$1.default('findOne', {
|
|
639
664
|
finder,
|
|
640
665
|
finderParams,
|
|
641
666
|
locations
|
|
642
667
|
});
|
|
643
|
-
const ret = await api.findOne(finder, finderParams,
|
|
668
|
+
const ret = await api.findOne(finder, finderParams, locations);
|
|
644
669
|
cacheMap.set(ret.key, ret);
|
|
645
670
|
return [
|
|
646
671
|
cacheMap,
|
|
@@ -681,6 +706,7 @@ const createCache = async (api, pkType, parentCache)=>{
|
|
|
681
706
|
one,
|
|
682
707
|
action,
|
|
683
708
|
allAction,
|
|
709
|
+
allFacet,
|
|
684
710
|
create,
|
|
685
711
|
get,
|
|
686
712
|
retrieve,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fjell/cache",
|
|
3
3
|
"description": "Cache for Fjell",
|
|
4
|
-
"version": "4.6.
|
|
4
|
+
"version": "4.6.3",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.cjs.js",
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@fjell/client-api": "^4.4.
|
|
19
|
-
"@fjell/core": "^4.4.
|
|
20
|
-
"@fjell/http-api": "^4.4.
|
|
21
|
-
"@fjell/logging": "^4.4.
|
|
18
|
+
"@fjell/client-api": "^4.4.3",
|
|
19
|
+
"@fjell/core": "^4.4.3",
|
|
20
|
+
"@fjell/http-api": "^4.4.1",
|
|
21
|
+
"@fjell/logging": "^4.4.3",
|
|
22
22
|
"d3": "^7.9.0",
|
|
23
23
|
"dayjs": "^1.11.13",
|
|
24
24
|
"react": "19.1.0"
|
package/src/Aggregator.ts
CHANGED
|
@@ -195,6 +195,16 @@ export const createAggregator = async <
|
|
|
195
195
|
return [cacheMap, populatedItems];
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
+
const allFacet = async (
|
|
199
|
+
facet: string,
|
|
200
|
+
params: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},
|
|
201
|
+
locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = []
|
|
202
|
+
): Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, any]> => {
|
|
203
|
+
logger.default('allFacet', { facet, params, locations });
|
|
204
|
+
const [cacheMap, response] = await cache.allFacet(facet, params, locations);
|
|
205
|
+
return [cacheMap, response];
|
|
206
|
+
}
|
|
207
|
+
|
|
198
208
|
const create = async (
|
|
199
209
|
v: TypesProperties<V, S, L1, L2, L3, L4, L5>,
|
|
200
210
|
locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = []
|
|
@@ -259,7 +269,7 @@ export const createAggregator = async <
|
|
|
259
269
|
|
|
260
270
|
const find = async (
|
|
261
271
|
finder: string,
|
|
262
|
-
finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date
|
|
272
|
+
finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},
|
|
263
273
|
locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = []
|
|
264
274
|
): Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V[]]> => {
|
|
265
275
|
logger.default('find', { finder, finderParams, locations });
|
|
@@ -270,7 +280,7 @@ export const createAggregator = async <
|
|
|
270
280
|
|
|
271
281
|
const findOne = async (
|
|
272
282
|
finder: string,
|
|
273
|
-
finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date
|
|
283
|
+
finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},
|
|
274
284
|
locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = []
|
|
275
285
|
): Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]> => {
|
|
276
286
|
logger.default('find', { finder, finderParams, locations });
|
|
@@ -301,6 +311,7 @@ export const createAggregator = async <
|
|
|
301
311
|
one,
|
|
302
312
|
action,
|
|
303
313
|
allAction,
|
|
314
|
+
allFacet,
|
|
304
315
|
create,
|
|
305
316
|
get,
|
|
306
317
|
retrieve,
|
package/src/Cache.ts
CHANGED
|
@@ -51,8 +51,14 @@ export interface Cache<
|
|
|
51
51
|
locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
|
|
52
52
|
) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V[]]>
|
|
53
53
|
|
|
54
|
+
allFacet: (
|
|
55
|
+
facet: string,
|
|
56
|
+
params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
|
|
57
|
+
locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
|
|
58
|
+
) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, any]>;
|
|
59
|
+
|
|
54
60
|
create: (
|
|
55
|
-
|
|
61
|
+
item: TypesProperties<V, S, L1, L2, L3, L4, L5>,
|
|
56
62
|
locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
|
|
57
63
|
) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]>;
|
|
58
64
|
|
|
@@ -70,29 +76,30 @@ export interface Cache<
|
|
|
70
76
|
|
|
71
77
|
update: (
|
|
72
78
|
key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
|
|
73
|
-
|
|
79
|
+
item: TypesProperties<V, S, L1, L2, L3, L4, L5>,
|
|
74
80
|
) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]>;
|
|
75
81
|
|
|
76
82
|
facet: (
|
|
77
83
|
key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
|
|
78
84
|
facet: string,
|
|
85
|
+
params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
|
|
79
86
|
) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, any]>;
|
|
80
87
|
|
|
81
88
|
find: (
|
|
82
89
|
finder: string,
|
|
83
|
-
|
|
90
|
+
params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
|
|
84
91
|
locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
|
|
85
92
|
) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V[]]>;
|
|
86
93
|
|
|
87
94
|
findOne: (
|
|
88
95
|
finder: string,
|
|
89
|
-
|
|
96
|
+
params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
|
|
90
97
|
locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
|
|
91
98
|
) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]>;
|
|
92
99
|
|
|
93
100
|
set: (
|
|
94
101
|
key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
|
|
95
|
-
|
|
102
|
+
item: Item<S, L1, L2, L3, L4, L5>
|
|
96
103
|
) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]>;
|
|
97
104
|
|
|
98
105
|
reset: () => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>]>;
|
|
@@ -132,7 +139,7 @@ export const createCache = async <
|
|
|
132
139
|
logger.default('all', { query, locations });
|
|
133
140
|
let ret: V[] = [];
|
|
134
141
|
try {
|
|
135
|
-
ret = await api.all(query,
|
|
142
|
+
ret = await api.all(query, locations);
|
|
136
143
|
ret.forEach((v) => {
|
|
137
144
|
cacheMap.set(v.key, v);
|
|
138
145
|
});
|
|
@@ -155,7 +162,7 @@ export const createCache = async <
|
|
|
155
162
|
|
|
156
163
|
let retItem: V | null = null;
|
|
157
164
|
try {
|
|
158
|
-
retItem = await api.one(query,
|
|
165
|
+
retItem = await api.one(query, locations);
|
|
159
166
|
if (retItem) {
|
|
160
167
|
cacheMap.set(retItem.key, retItem);
|
|
161
168
|
}
|
|
@@ -188,7 +195,7 @@ export const createCache = async <
|
|
|
188
195
|
throw new Error('Key for Action is not a valid ItemKey');
|
|
189
196
|
}
|
|
190
197
|
|
|
191
|
-
const updated = await api.action(key, action, body
|
|
198
|
+
const updated = await api.action(key, action, body);
|
|
192
199
|
cacheMap.set(updated.key, updated);
|
|
193
200
|
return [cacheMap, validatePK(updated, pkType) as V];
|
|
194
201
|
}
|
|
@@ -201,7 +208,7 @@ export const createCache = async <
|
|
|
201
208
|
logger.default('allAction', { action, body, locations });
|
|
202
209
|
let ret: V[] = [];
|
|
203
210
|
try {
|
|
204
|
-
ret = await api.allAction(action, body,
|
|
211
|
+
ret = await api.allAction(action, body, locations);
|
|
205
212
|
ret.forEach((v) => {
|
|
206
213
|
cacheMap.set(v.key, v);
|
|
207
214
|
});
|
|
@@ -216,12 +223,22 @@ export const createCache = async <
|
|
|
216
223
|
return [cacheMap, validatePK(ret, pkType) as V[]];
|
|
217
224
|
}
|
|
218
225
|
|
|
226
|
+
const allFacet = async (
|
|
227
|
+
facet: string,
|
|
228
|
+
params: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},
|
|
229
|
+
locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = []
|
|
230
|
+
): Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, any]> => {
|
|
231
|
+
logger.default('allFacet', { facet, params, locations });
|
|
232
|
+
const ret = await api.allFacet(facet, params, locations);
|
|
233
|
+
return [cacheMap, ret];
|
|
234
|
+
}
|
|
235
|
+
|
|
219
236
|
const create = async (
|
|
220
237
|
v: TypesProperties<V, S, L1, L2, L3, L4, L5>,
|
|
221
238
|
locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = []
|
|
222
239
|
): Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]> => {
|
|
223
240
|
logger.default('create', { v, locations });
|
|
224
|
-
const created = await api.create(v,
|
|
241
|
+
const created = await api.create(v, locations);
|
|
225
242
|
cacheMap.set(created.key, created);
|
|
226
243
|
return [cacheMap, validatePK(created, pkType) as V];
|
|
227
244
|
}
|
|
@@ -238,7 +255,7 @@ export const createCache = async <
|
|
|
238
255
|
}
|
|
239
256
|
let ret: V | null;
|
|
240
257
|
try {
|
|
241
|
-
ret = await api.get(key
|
|
258
|
+
ret = await api.get(key);
|
|
242
259
|
if (ret) {
|
|
243
260
|
cacheMap.set(ret.key, ret);
|
|
244
261
|
}
|
|
@@ -293,7 +310,7 @@ export const createCache = async <
|
|
|
293
310
|
throw new Error('Key for Remove is not a valid ItemKey');
|
|
294
311
|
}
|
|
295
312
|
try {
|
|
296
|
-
await api.remove(key
|
|
313
|
+
await api.remove(key);
|
|
297
314
|
cacheMap.delete(key);
|
|
298
315
|
} catch (e) {
|
|
299
316
|
logger.error("Error deleting item", { error: e });
|
|
@@ -316,7 +333,7 @@ export const createCache = async <
|
|
|
316
333
|
}
|
|
317
334
|
|
|
318
335
|
try {
|
|
319
|
-
const updated = await api.update(key, v
|
|
336
|
+
const updated = await api.update(key, v);
|
|
320
337
|
cacheMap.set(updated.key, updated);
|
|
321
338
|
return [cacheMap, validatePK(updated, pkType) as V];
|
|
322
339
|
} catch (e) {
|
|
@@ -329,19 +346,20 @@ export const createCache = async <
|
|
|
329
346
|
const facet = async (
|
|
330
347
|
key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
|
|
331
348
|
facet: string,
|
|
349
|
+
params: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},
|
|
332
350
|
): Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, any]> => {
|
|
333
351
|
logger.default('facet', { key, facet });
|
|
334
|
-
const ret = await api.facet(key, facet,
|
|
352
|
+
const ret = await api.facet(key, facet, params);
|
|
335
353
|
return [cacheMap, ret];
|
|
336
354
|
}
|
|
337
355
|
|
|
338
356
|
const find = async (
|
|
339
357
|
finder: string,
|
|
340
|
-
|
|
358
|
+
params: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},
|
|
341
359
|
locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = []
|
|
342
360
|
): Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V[]]> => {
|
|
343
|
-
logger.default('find', { finder,
|
|
344
|
-
const ret: V[] = await api.find(finder,
|
|
361
|
+
logger.default('find', { finder, params, locations });
|
|
362
|
+
const ret: V[] = await api.find(finder, params, locations);
|
|
345
363
|
ret.forEach((v) => {
|
|
346
364
|
cacheMap.set(v.key, v);
|
|
347
365
|
});
|
|
@@ -350,11 +368,11 @@ export const createCache = async <
|
|
|
350
368
|
|
|
351
369
|
const findOne = async (
|
|
352
370
|
finder: string,
|
|
353
|
-
finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date
|
|
371
|
+
finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},
|
|
354
372
|
locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = []
|
|
355
373
|
): Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]> => {
|
|
356
374
|
logger.default('findOne', { finder, finderParams, locations });
|
|
357
|
-
const ret = await api.findOne(finder, finderParams,
|
|
375
|
+
const ret = await api.findOne(finder, finderParams, locations);
|
|
358
376
|
cacheMap.set(ret.key, ret);
|
|
359
377
|
return [cacheMap, validatePK(ret, pkType) as V];
|
|
360
378
|
}
|
|
@@ -394,6 +412,7 @@ export const createCache = async <
|
|
|
394
412
|
one,
|
|
395
413
|
action,
|
|
396
414
|
allAction,
|
|
415
|
+
allFacet,
|
|
397
416
|
create,
|
|
398
417
|
get,
|
|
399
418
|
retrieve,
|