@fjell/cache 4.6.1 → 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.
@@ -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,
@@ -220,7 +232,19 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
220
232
  populatedItem
221
233
  ];
222
234
  };
223
- const find = async (finder, finderParams, locations = [])=>{
235
+ // Facets are a pass-thru for aggregators
236
+ const facet = async (key, facet)=>{
237
+ logger.default('facet', {
238
+ key,
239
+ facet
240
+ });
241
+ const [cacheMap, response] = await cache.facet(key, facet);
242
+ return [
243
+ cacheMap,
244
+ response
245
+ ];
246
+ };
247
+ const find = async (finder, finderParams = {}, locations = [])=>{
224
248
  logger.default('find', {
225
249
  finder,
226
250
  finderParams,
@@ -233,6 +257,19 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
233
257
  populatedItems
234
258
  ];
235
259
  };
260
+ const findOne = async (finder, finderParams = {}, locations = [])=>{
261
+ logger.default('find', {
262
+ finder,
263
+ finderParams,
264
+ locations
265
+ });
266
+ const [cacheMap, item] = await cache.findOne(finder, finderParams, locations);
267
+ const populatedItem = await populate(item);
268
+ return [
269
+ cacheMap,
270
+ populatedItem
271
+ ];
272
+ };
236
273
  const set = async (key, v)=>{
237
274
  logger.default('set', {
238
275
  key,
@@ -255,12 +292,15 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
255
292
  one,
256
293
  action,
257
294
  allAction,
295
+ allFacet,
258
296
  create,
259
297
  get,
260
298
  retrieve,
261
299
  remove,
262
300
  update,
301
+ facet,
263
302
  find,
303
+ findOne,
264
304
  reset,
265
305
  set,
266
306
  pkTypes: cache.pkTypes,
@@ -273,4 +313,4 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
273
313
 
274
314
  exports.createAggregator = createAggregator;
275
315
  exports.toCacheConfig = toCacheConfig;
276
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQWdncmVnYXRvci5janMuanMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7In0=
316
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQWdncmVnYXRvci5janMuanMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9
@@ -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,
@@ -216,7 +228,19 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
216
228
  populatedItem
217
229
  ];
218
230
  };
219
- const find = async (finder, finderParams, locations = [])=>{
231
+ // Facets are a pass-thru for aggregators
232
+ const facet = async (key, facet)=>{
233
+ logger.default('facet', {
234
+ key,
235
+ facet
236
+ });
237
+ const [cacheMap, response] = await cache.facet(key, facet);
238
+ return [
239
+ cacheMap,
240
+ response
241
+ ];
242
+ };
243
+ const find = async (finder, finderParams = {}, locations = [])=>{
220
244
  logger.default('find', {
221
245
  finder,
222
246
  finderParams,
@@ -229,6 +253,19 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
229
253
  populatedItems
230
254
  ];
231
255
  };
256
+ const findOne = async (finder, finderParams = {}, locations = [])=>{
257
+ logger.default('find', {
258
+ finder,
259
+ finderParams,
260
+ locations
261
+ });
262
+ const [cacheMap, item] = await cache.findOne(finder, finderParams, locations);
263
+ const populatedItem = await populate(item);
264
+ return [
265
+ cacheMap,
266
+ populatedItem
267
+ ];
268
+ };
232
269
  const set = async (key, v)=>{
233
270
  logger.default('set', {
234
271
  key,
@@ -251,12 +288,15 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
251
288
  one,
252
289
  action,
253
290
  allAction,
291
+ allFacet,
254
292
  create,
255
293
  get,
256
294
  retrieve,
257
295
  remove,
258
296
  update,
297
+ facet,
259
298
  find,
299
+ findOne,
260
300
  reset,
261
301
  set,
262
302
  pkTypes: cache.pkTypes,
@@ -268,4 +308,4 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
268
308
  };
269
309
 
270
310
  export { createAggregator, toCacheConfig };
271
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQWdncmVnYXRvci5lcy5qcyIsInNvdXJjZXMiOltdLCJzb3VyY2VzQ29udGVudCI6W10sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7In0=
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, {}, locations);
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, {}, locations);
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, {}, locations);
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, {}, locations);
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,
@@ -213,13 +225,25 @@ const createCache = async (api, pkType, parentCache)=>{
213
225
  throw e;
214
226
  }
215
227
  };
216
- const find = async (finder, finderParams, locations = [])=>{
228
+ // Facets are a pass-thru for caches
229
+ const facet = async (key, facet, params = {})=>{
230
+ logger.default('facet', {
231
+ key,
232
+ facet
233
+ });
234
+ const ret = await api.facet(key, facet, params);
235
+ return [
236
+ cacheMap,
237
+ ret
238
+ ];
239
+ };
240
+ const find = async (finder, params = {}, locations = [])=>{
217
241
  logger.default('find', {
218
242
  finder,
219
- finderParams,
243
+ params,
220
244
  locations
221
245
  });
222
- const ret = await api.find(finder, finderParams, {}, locations);
246
+ const ret = await api.find(finder, params, locations);
223
247
  ret.forEach((v)=>{
224
248
  cacheMap.set(v.key, v);
225
249
  });
@@ -228,6 +252,19 @@ const createCache = async (api, pkType, parentCache)=>{
228
252
  core.validatePK(ret, pkType)
229
253
  ];
230
254
  };
255
+ const findOne = async (finder, finderParams = {}, locations = [])=>{
256
+ logger.default('findOne', {
257
+ finder,
258
+ finderParams,
259
+ locations
260
+ });
261
+ const ret = await api.findOne(finder, finderParams, locations);
262
+ cacheMap.set(ret.key, ret);
263
+ return [
264
+ cacheMap,
265
+ core.validatePK(ret, pkType)
266
+ ];
267
+ };
231
268
  const reset = async ()=>{
232
269
  cacheMap = new CacheMap.CacheMap(pkTypes);
233
270
  return [
@@ -262,12 +299,15 @@ const createCache = async (api, pkType, parentCache)=>{
262
299
  one,
263
300
  action,
264
301
  allAction,
302
+ allFacet,
265
303
  create,
266
304
  get,
267
305
  retrieve,
268
306
  remove,
269
307
  update,
308
+ facet,
270
309
  find,
310
+ findOne,
271
311
  reset,
272
312
  set,
273
313
  pkTypes,
@@ -276,4 +316,4 @@ const createCache = async (api, pkType, parentCache)=>{
276
316
  };
277
317
 
278
318
  exports.createCache = createCache;
279
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ2FjaGUuY2pzLmpzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9
319
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ2FjaGUuY2pzLmpzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OzsifQ==
package/dist/Cache.d.ts CHANGED
@@ -6,13 +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
- create: (v: 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]>;
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>, v: TypesProperties<V, S, L1, L2, L3, L4, L5>) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]>;
14
- find: (finder: string, finderParams: 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[]]>;
15
- set: (key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, v: Item<S, L1, L2, L3, L4, L5>) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]>;
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]>;
16
19
  reset: () => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>]>;
17
20
  pkTypes: AllItemTypeArrays<S, L1, L2, L3, L4, L5>;
18
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, {}, locations);
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, {}, locations);
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, {}, locations);
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, {}, locations);
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,
@@ -209,13 +221,25 @@ const createCache = async (api, pkType, parentCache)=>{
209
221
  throw e;
210
222
  }
211
223
  };
212
- const find = async (finder, finderParams, locations = [])=>{
224
+ // Facets are a pass-thru for caches
225
+ const facet = async (key, facet, params = {})=>{
226
+ logger.default('facet', {
227
+ key,
228
+ facet
229
+ });
230
+ const ret = await api.facet(key, facet, params);
231
+ return [
232
+ cacheMap,
233
+ ret
234
+ ];
235
+ };
236
+ const find = async (finder, params = {}, locations = [])=>{
213
237
  logger.default('find', {
214
238
  finder,
215
- finderParams,
239
+ params,
216
240
  locations
217
241
  });
218
- const ret = await api.find(finder, finderParams, {}, locations);
242
+ const ret = await api.find(finder, params, locations);
219
243
  ret.forEach((v)=>{
220
244
  cacheMap.set(v.key, v);
221
245
  });
@@ -224,6 +248,19 @@ const createCache = async (api, pkType, parentCache)=>{
224
248
  validatePK(ret, pkType)
225
249
  ];
226
250
  };
251
+ const findOne = async (finder, finderParams = {}, locations = [])=>{
252
+ logger.default('findOne', {
253
+ finder,
254
+ finderParams,
255
+ locations
256
+ });
257
+ const ret = await api.findOne(finder, finderParams, locations);
258
+ cacheMap.set(ret.key, ret);
259
+ return [
260
+ cacheMap,
261
+ validatePK(ret, pkType)
262
+ ];
263
+ };
227
264
  const reset = async ()=>{
228
265
  cacheMap = new CacheMap(pkTypes);
229
266
  return [
@@ -258,12 +295,15 @@ const createCache = async (api, pkType, parentCache)=>{
258
295
  one,
259
296
  action,
260
297
  allAction,
298
+ allFacet,
261
299
  create,
262
300
  get,
263
301
  retrieve,
264
302
  remove,
265
303
  update,
304
+ facet,
266
305
  find,
306
+ findOne,
267
307
  reset,
268
308
  set,
269
309
  pkTypes,
@@ -272,4 +312,4 @@ const createCache = async (api, pkType, parentCache)=>{
272
312
  };
273
313
 
274
314
  export { createCache };
275
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ2FjaGUuZXMuanMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OzsifQ==
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,
@@ -224,7 +236,19 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
224
236
  populatedItem
225
237
  ];
226
238
  };
227
- const find = async (finder, finderParams, locations = [])=>{
239
+ // Facets are a pass-thru for aggregators
240
+ const facet = async (key, facet)=>{
241
+ logger$3.default('facet', {
242
+ key,
243
+ facet
244
+ });
245
+ const [cacheMap, response] = await cache.facet(key, facet);
246
+ return [
247
+ cacheMap,
248
+ response
249
+ ];
250
+ };
251
+ const find = async (finder, finderParams = {}, locations = [])=>{
228
252
  logger$3.default('find', {
229
253
  finder,
230
254
  finderParams,
@@ -237,6 +261,19 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
237
261
  populatedItems
238
262
  ];
239
263
  };
264
+ const findOne = async (finder, finderParams = {}, locations = [])=>{
265
+ logger$3.default('find', {
266
+ finder,
267
+ finderParams,
268
+ locations
269
+ });
270
+ const [cacheMap, item] = await cache.findOne(finder, finderParams, locations);
271
+ const populatedItem = await populate(item);
272
+ return [
273
+ cacheMap,
274
+ populatedItem
275
+ ];
276
+ };
240
277
  const set = async (key, v)=>{
241
278
  logger$3.default('set', {
242
279
  key,
@@ -259,12 +296,15 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
259
296
  one,
260
297
  action,
261
298
  allAction,
299
+ allFacet,
262
300
  create,
263
301
  get,
264
302
  retrieve,
265
303
  remove,
266
304
  update,
305
+ facet,
267
306
  find,
307
+ findOne,
268
308
  reset,
269
309
  set,
270
310
  pkTypes: cache.pkTypes,
@@ -390,7 +430,7 @@ const createCache = async (api, pkType, parentCache)=>{
390
430
  });
391
431
  let ret = [];
392
432
  try {
393
- ret = await api.all(query, {}, locations);
433
+ ret = await api.all(query, locations);
394
434
  ret.forEach((v)=>{
395
435
  cacheMap.set(v.key, v);
396
436
  });
@@ -411,7 +451,7 @@ const createCache = async (api, pkType, parentCache)=>{
411
451
  });
412
452
  let retItem = null;
413
453
  try {
414
- retItem = await api.one(query, {}, locations);
454
+ retItem = await api.one(query, locations);
415
455
  if (retItem) {
416
456
  cacheMap.set(retItem.key, retItem);
417
457
  }
@@ -437,7 +477,7 @@ const createCache = async (api, pkType, parentCache)=>{
437
477
  logger$1.error('Key for Action is not a valid ItemKey: %j', key);
438
478
  throw new Error('Key for Action is not a valid ItemKey');
439
479
  }
440
- const updated = await api.action(key, action, body, {});
480
+ const updated = await api.action(key, action, body);
441
481
  cacheMap.set(updated.key, updated);
442
482
  return [
443
483
  cacheMap,
@@ -452,7 +492,7 @@ const createCache = async (api, pkType, parentCache)=>{
452
492
  });
453
493
  let ret = [];
454
494
  try {
455
- ret = await api.allAction(action, body, {}, locations);
495
+ ret = await api.allAction(action, body, locations);
456
496
  ret.forEach((v)=>{
457
497
  cacheMap.set(v.key, v);
458
498
  });
@@ -467,12 +507,24 @@ const createCache = async (api, pkType, parentCache)=>{
467
507
  core.validatePK(ret, pkType)
468
508
  ];
469
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
+ };
470
522
  const create = async (v, locations = [])=>{
471
523
  logger$1.default('create', {
472
524
  v,
473
525
  locations
474
526
  });
475
- const created = await api.create(v, {}, locations);
527
+ const created = await api.create(v, locations);
476
528
  cacheMap.set(created.key, created);
477
529
  return [
478
530
  cacheMap,
@@ -491,7 +543,7 @@ const createCache = async (api, pkType, parentCache)=>{
491
543
  }
492
544
  let ret;
493
545
  try {
494
- ret = await api.get(key, {});
546
+ ret = await api.get(key);
495
547
  if (ret) {
496
548
  cacheMap.set(ret.key, ret);
497
549
  }
@@ -545,7 +597,7 @@ const createCache = async (api, pkType, parentCache)=>{
545
597
  throw new Error('Key for Remove is not a valid ItemKey');
546
598
  }
547
599
  try {
548
- await api.remove(key, {});
600
+ await api.remove(key);
549
601
  cacheMap.delete(key);
550
602
  } catch (e) {
551
603
  logger$1.error("Error deleting item", {
@@ -567,7 +619,7 @@ const createCache = async (api, pkType, parentCache)=>{
567
619
  throw new Error('Key for Update is not a valid ItemKey');
568
620
  }
569
621
  try {
570
- const updated = await api.update(key, v, {});
622
+ const updated = await api.update(key, v);
571
623
  cacheMap.set(updated.key, updated);
572
624
  return [
573
625
  cacheMap,
@@ -580,13 +632,25 @@ const createCache = async (api, pkType, parentCache)=>{
580
632
  throw e;
581
633
  }
582
634
  };
583
- const find = async (finder, finderParams, locations = [])=>{
635
+ // Facets are a pass-thru for caches
636
+ const facet = async (key, facet, params = {})=>{
637
+ logger$1.default('facet', {
638
+ key,
639
+ facet
640
+ });
641
+ const ret = await api.facet(key, facet, params);
642
+ return [
643
+ cacheMap,
644
+ ret
645
+ ];
646
+ };
647
+ const find = async (finder, params = {}, locations = [])=>{
584
648
  logger$1.default('find', {
585
649
  finder,
586
- finderParams,
650
+ params,
587
651
  locations
588
652
  });
589
- const ret = await api.find(finder, finderParams, {}, locations);
653
+ const ret = await api.find(finder, params, locations);
590
654
  ret.forEach((v)=>{
591
655
  cacheMap.set(v.key, v);
592
656
  });
@@ -595,6 +659,19 @@ const createCache = async (api, pkType, parentCache)=>{
595
659
  core.validatePK(ret, pkType)
596
660
  ];
597
661
  };
662
+ const findOne = async (finder, finderParams = {}, locations = [])=>{
663
+ logger$1.default('findOne', {
664
+ finder,
665
+ finderParams,
666
+ locations
667
+ });
668
+ const ret = await api.findOne(finder, finderParams, locations);
669
+ cacheMap.set(ret.key, ret);
670
+ return [
671
+ cacheMap,
672
+ core.validatePK(ret, pkType)
673
+ ];
674
+ };
598
675
  const reset = async ()=>{
599
676
  cacheMap = new CacheMap(pkTypes);
600
677
  return [
@@ -629,12 +706,15 @@ const createCache = async (api, pkType, parentCache)=>{
629
706
  one,
630
707
  action,
631
708
  allAction,
709
+ allFacet,
632
710
  create,
633
711
  get,
634
712
  retrieve,
635
713
  remove,
636
714
  update,
715
+ facet,
637
716
  find,
717
+ findOne,
638
718
  reset,
639
719
  set,
640
720
  pkTypes,
@@ -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.1",
4
+ "version": "4.6.3",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./dist/index.cjs.js",
@@ -15,13 +15,13 @@
15
15
  }
16
16
  },
17
17
  "dependencies": {
18
- "@fjell/client-api": "^4.4.0",
19
- "@fjell/core": "^4.4.2",
20
- "@fjell/http-api": "^4.4.0",
21
- "@fjell/logging": "^4.4.2",
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
- "react": "18.3.1"
24
+ "react": "19.1.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@babel/preset-env": "^7.26.9",
@@ -33,7 +33,7 @@
33
33
  "@types/babel__preset-env": "^7.10.0",
34
34
  "@types/d3": "^7.4.3",
35
35
  "@types/multer": "^1.4.12",
36
- "@types/node": "^22.13.5",
36
+ "@types/node": "^24.0.3",
37
37
  "@typescript-eslint/eslint-plugin": "^8.24.1",
38
38
  "@typescript-eslint/parser": "^8.24.1",
39
39
  "@vitest/coverage-v8": "^3.1.4",
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> | [] = []
@@ -247,9 +257,19 @@ export const createAggregator = async <
247
257
  return [cacheMap, populatedItem];
248
258
  }
249
259
 
260
+ // Facets are a pass-thru for aggregators
261
+ const facet = async (
262
+ key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
263
+ facet: string,
264
+ ): Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, any]> => {
265
+ logger.default('facet', { key, facet });
266
+ const [cacheMap, response] = await cache.facet(key, facet);
267
+ return [cacheMap, response];
268
+ }
269
+
250
270
  const find = async (
251
271
  finder: string,
252
- 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>> = {},
253
273
  locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = []
254
274
  ): Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V[]]> => {
255
275
  logger.default('find', { finder, finderParams, locations });
@@ -258,6 +278,17 @@ export const createAggregator = async <
258
278
  return [cacheMap, populatedItems];
259
279
  }
260
280
 
281
+ const findOne = async (
282
+ finder: string,
283
+ finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},
284
+ locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = []
285
+ ): Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]> => {
286
+ logger.default('find', { finder, finderParams, locations });
287
+ const [cacheMap, item] = await cache.findOne(finder, finderParams, locations);
288
+ const populatedItem = await populate(item);
289
+ return [cacheMap, populatedItem];
290
+ }
291
+
261
292
  const set = async (
262
293
  key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
263
294
  v: Item<S, L1, L2, L3, L4, L5>
@@ -280,12 +311,15 @@ export const createAggregator = async <
280
311
  one,
281
312
  action,
282
313
  allAction,
314
+ allFacet,
283
315
  create,
284
316
  get,
285
317
  retrieve,
286
318
  remove,
287
319
  update,
320
+ facet,
288
321
  find,
322
+ findOne,
289
323
  reset,
290
324
  set,
291
325
  pkTypes: cache.pkTypes,
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
- v: TypesProperties<V, S, L1, L2, L3, L4, L5>,
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,18 +76,30 @@ export interface Cache<
70
76
 
71
77
  update: (
72
78
  key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
73
- v: TypesProperties<V, S, L1, L2, L3, L4, L5>,
79
+ item: TypesProperties<V, S, L1, L2, L3, L4, L5>,
74
80
  ) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]>;
75
81
 
82
+ facet: (
83
+ key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
84
+ facet: string,
85
+ params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
86
+ ) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, any]>;
87
+
76
88
  find: (
77
89
  finder: string,
78
- finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
90
+ params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
79
91
  locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
80
92
  ) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V[]]>;
81
93
 
94
+ findOne: (
95
+ finder: string,
96
+ params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
97
+ locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
98
+ ) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]>;
99
+
82
100
  set: (
83
101
  key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
84
- v: Item<S, L1, L2, L3, L4, L5>
102
+ item: Item<S, L1, L2, L3, L4, L5>
85
103
  ) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]>;
86
104
 
87
105
  reset: () => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>]>;
@@ -105,8 +123,8 @@ export const createCache = async <
105
123
  parentCache?: Cache<Item<L1, L2, L3, L4, L5>, L1, L2, L3, L4, L5>
106
124
  ): Promise<Cache<V, S, L1, L2, L3, L4, L5>> => {
107
125
 
108
- let pkTypes: AllItemTypeArrays<S, L1, L2, L3, L4, L5> = [ pkType ];
109
- if( parentCache ) {
126
+ let pkTypes: AllItemTypeArrays<S, L1, L2, L3, L4, L5> = [pkType];
127
+ if (parentCache) {
110
128
  pkTypes = pkTypes.concat(parentCache.pkTypes as any) as unknown as AllItemTypeArrays<S, L1, L2, L3, L4, L5>;
111
129
  }
112
130
 
@@ -121,7 +139,7 @@ export const createCache = async <
121
139
  logger.default('all', { query, locations });
122
140
  let ret: V[] = [];
123
141
  try {
124
- ret = await api.all(query, {}, locations);
142
+ ret = await api.all(query, locations);
125
143
  ret.forEach((v) => {
126
144
  cacheMap.set(v.key, v);
127
145
  });
@@ -144,7 +162,7 @@ export const createCache = async <
144
162
 
145
163
  let retItem: V | null = null;
146
164
  try {
147
- retItem = await api.one(query, {}, locations);
165
+ retItem = await api.one(query, locations);
148
166
  if (retItem) {
149
167
  cacheMap.set(retItem.key, retItem);
150
168
  }
@@ -177,7 +195,7 @@ export const createCache = async <
177
195
  throw new Error('Key for Action is not a valid ItemKey');
178
196
  }
179
197
 
180
- const updated = await api.action(key, action, body, {});
198
+ const updated = await api.action(key, action, body);
181
199
  cacheMap.set(updated.key, updated);
182
200
  return [cacheMap, validatePK(updated, pkType) as V];
183
201
  }
@@ -190,7 +208,7 @@ export const createCache = async <
190
208
  logger.default('allAction', { action, body, locations });
191
209
  let ret: V[] = [];
192
210
  try {
193
- ret = await api.allAction(action, body, {}, locations);
211
+ ret = await api.allAction(action, body, locations);
194
212
  ret.forEach((v) => {
195
213
  cacheMap.set(v.key, v);
196
214
  });
@@ -205,12 +223,22 @@ export const createCache = async <
205
223
  return [cacheMap, validatePK(ret, pkType) as V[]];
206
224
  }
207
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
+
208
236
  const create = async (
209
237
  v: TypesProperties<V, S, L1, L2, L3, L4, L5>,
210
238
  locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = []
211
239
  ): Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]> => {
212
240
  logger.default('create', { v, locations });
213
- const created = await api.create(v, {}, locations);
241
+ const created = await api.create(v, locations);
214
242
  cacheMap.set(created.key, created);
215
243
  return [cacheMap, validatePK(created, pkType) as V];
216
244
  }
@@ -227,7 +255,7 @@ export const createCache = async <
227
255
  }
228
256
  let ret: V | null;
229
257
  try {
230
- ret = await api.get(key, {});
258
+ ret = await api.get(key);
231
259
  if (ret) {
232
260
  cacheMap.set(ret.key, ret);
233
261
  }
@@ -264,7 +292,7 @@ export const createCache = async <
264
292
  const retValue: [CacheMap<V, S, L1, L2, L3, L4, L5> | null, V | null] = [
265
293
  containsItemKey ? null : cacheMap,
266
294
  retrieved ?
267
- validatePK(retrieved, pkType) as V:
295
+ validatePK(retrieved, pkType) as V :
268
296
  null
269
297
  ];
270
298
  // logger.debug('Returning from retrieve', { retValue });
@@ -282,7 +310,7 @@ export const createCache = async <
282
310
  throw new Error('Key for Remove is not a valid ItemKey');
283
311
  }
284
312
  try {
285
- await api.remove(key, {});
313
+ await api.remove(key);
286
314
  cacheMap.delete(key);
287
315
  } catch (e) {
288
316
  logger.error("Error deleting item", { error: e });
@@ -305,7 +333,7 @@ export const createCache = async <
305
333
  }
306
334
 
307
335
  try {
308
- const updated = await api.update(key, v, {});
336
+ const updated = await api.update(key, v);
309
337
  cacheMap.set(updated.key, updated);
310
338
  return [cacheMap, validatePK(updated, pkType) as V];
311
339
  } catch (e) {
@@ -314,19 +342,41 @@ export const createCache = async <
314
342
  }
315
343
  }
316
344
 
345
+ // Facets are a pass-thru for caches
346
+ const facet = async (
347
+ key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
348
+ facet: string,
349
+ params: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},
350
+ ): Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, any]> => {
351
+ logger.default('facet', { key, facet });
352
+ const ret = await api.facet(key, facet, params);
353
+ return [cacheMap, ret];
354
+ }
355
+
317
356
  const find = async (
318
357
  finder: string,
319
- finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
358
+ params: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},
320
359
  locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = []
321
360
  ): Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V[]]> => {
322
- logger.default('find', { finder, finderParams, locations });
323
- const ret: V[] = await api.find(finder, finderParams, {}, locations);
361
+ logger.default('find', { finder, params, locations });
362
+ const ret: V[] = await api.find(finder, params, locations);
324
363
  ret.forEach((v) => {
325
364
  cacheMap.set(v.key, v);
326
365
  });
327
366
  return [cacheMap, validatePK(ret, pkType) as V[]];
328
367
  }
329
368
 
369
+ const findOne = async (
370
+ finder: string,
371
+ finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},
372
+ locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = []
373
+ ): Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]> => {
374
+ logger.default('findOne', { finder, finderParams, locations });
375
+ const ret = await api.findOne(finder, finderParams, locations);
376
+ cacheMap.set(ret.key, ret);
377
+ return [cacheMap, validatePK(ret, pkType) as V];
378
+ }
379
+
330
380
  const reset = async (): Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>]> => {
331
381
  cacheMap = new CacheMap<V, S, L1, L2, L3, L4, L5>(pkTypes);
332
382
  return [cacheMap];
@@ -337,7 +387,7 @@ export const createCache = async <
337
387
  v: Item<S, L1, L2, L3, L4, L5>
338
388
  ): Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]> => {
339
389
  logger.default('set', { key, v });
340
-
390
+
341
391
  // TODO: This is validating the key, but it doesn't have knowledge of the pkType
342
392
  // This should be looking at the parentCaches and calculating an array of pkTypes
343
393
  if (!isValidItemKey(key)) {
@@ -362,12 +412,15 @@ export const createCache = async <
362
412
  one,
363
413
  action,
364
414
  allAction,
415
+ allFacet,
365
416
  create,
366
417
  get,
367
418
  retrieve,
368
419
  remove,
369
420
  update,
421
+ facet,
370
422
  find,
423
+ findOne,
371
424
  reset,
372
425
  set,
373
426
  pkTypes,
package/vitest.config.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineConfig } from 'vitest/config'
2
- import path from 'path'
2
+ import * as path from 'path'
3
3
 
4
4
  export default defineConfig({
5
5
  test: {
@@ -13,7 +13,17 @@ export default defineConfig({
13
13
  'node_modules/',
14
14
  'tests/',
15
15
  'src/index.ts',
16
+ 'eslint.config.mjs',
17
+ 'vite.config.ts',
18
+ 'vitest.config.ts',
19
+ 'dist',
16
20
  ],
21
+ thresholds: {
22
+ lines: 89,
23
+ functions: 85,
24
+ branches: 94,
25
+ statements: 89,
26
+ },
17
27
  },
18
28
  setupFiles: ['./tests/setup.ts'],
19
29
  deps: {