@fjell/cache 4.6.10 → 4.6.13

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.
Files changed (81) hide show
  1. package/README.md +96 -0
  2. package/dist/Aggregator.cjs.js +26 -20
  3. package/dist/Aggregator.d.ts +17 -1
  4. package/dist/Aggregator.es.js +26 -20
  5. package/dist/Cache.cjs.js +22 -345
  6. package/dist/Cache.d.ts +25 -20
  7. package/dist/Cache.es.js +22 -346
  8. package/dist/Instance.cjs.js +7 -11
  9. package/dist/Instance.d.ts +5 -8
  10. package/dist/Instance.es.js +6 -10
  11. package/dist/InstanceFactory.cjs.js +17 -5
  12. package/dist/InstanceFactory.d.ts +3 -3
  13. package/dist/InstanceFactory.es.js +17 -5
  14. package/dist/Operations.cjs.js +43 -0
  15. package/dist/Operations.d.ts +70 -0
  16. package/dist/Operations.es.js +39 -0
  17. package/dist/index.cjs +416 -369
  18. package/dist/index.cjs.js +4 -1
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.es.js +3 -2
  22. package/dist/ops/action.cjs.js +28 -0
  23. package/dist/ops/action.d.ts +4 -0
  24. package/dist/ops/action.es.js +24 -0
  25. package/dist/ops/all.cjs.js +33 -0
  26. package/dist/ops/all.d.ts +4 -0
  27. package/dist/ops/all.es.js +29 -0
  28. package/dist/ops/allAction.cjs.js +35 -0
  29. package/dist/ops/allAction.d.ts +4 -0
  30. package/dist/ops/allAction.es.js +31 -0
  31. package/dist/ops/allFacet.cjs.js +22 -0
  32. package/dist/ops/allFacet.d.ts +4 -0
  33. package/dist/ops/allFacet.es.js +18 -0
  34. package/dist/ops/create.cjs.js +23 -0
  35. package/dist/ops/create.d.ts +4 -0
  36. package/dist/ops/create.es.js +19 -0
  37. package/dist/ops/facet.cjs.js +21 -0
  38. package/dist/ops/facet.d.ts +4 -0
  39. package/dist/ops/facet.es.js +17 -0
  40. package/dist/ops/find.cjs.js +26 -0
  41. package/dist/ops/find.d.ts +4 -0
  42. package/dist/ops/find.es.js +22 -0
  43. package/dist/ops/findOne.cjs.js +24 -0
  44. package/dist/ops/findOne.d.ts +4 -0
  45. package/dist/ops/findOne.es.js +20 -0
  46. package/dist/ops/get.cjs.js +38 -0
  47. package/dist/ops/get.d.ts +4 -0
  48. package/dist/ops/get.es.js +34 -0
  49. package/dist/ops/one.cjs.js +33 -0
  50. package/dist/ops/one.d.ts +4 -0
  51. package/dist/ops/one.es.js +29 -0
  52. package/dist/ops/remove.cjs.js +30 -0
  53. package/dist/ops/remove.d.ts +4 -0
  54. package/dist/ops/remove.es.js +26 -0
  55. package/dist/ops/reset.cjs.js +15 -0
  56. package/dist/ops/reset.d.ts +4 -0
  57. package/dist/ops/reset.es.js +11 -0
  58. package/dist/ops/retrieve.cjs.js +37 -0
  59. package/dist/ops/retrieve.d.ts +4 -0
  60. package/dist/ops/retrieve.es.js +33 -0
  61. package/dist/ops/set.cjs.js +71 -0
  62. package/dist/ops/set.d.ts +3 -0
  63. package/dist/ops/set.es.js +67 -0
  64. package/dist/ops/update.cjs.js +34 -0
  65. package/dist/ops/update.d.ts +4 -0
  66. package/dist/ops/update.es.js +30 -0
  67. package/docs/docs.config.ts +75 -0
  68. package/docs/index.html +18 -0
  69. package/docs/package.json +34 -0
  70. package/docs/public/README.md +96 -0
  71. package/docs/public/examples-README.md +302 -0
  72. package/docs/public/test.txt +0 -0
  73. package/docs/src/index.css +3 -0
  74. package/docs/src/main.tsx +12 -0
  75. package/docs/src/test/setup.ts +1 -0
  76. package/docs/tsconfig.node.json +15 -0
  77. package/examples/README.md +34 -39
  78. package/examples/aggregator-example.ts +9 -14
  79. package/examples/basic-cache-example.ts +18 -21
  80. package/package.json +16 -11
  81. package/vitest.config.ts +1 -1
package/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # Fjell Cache
2
+
3
+ Cache for Fjell - A powerful caching framework for TypeScript applications
4
+
5
+ ## Overview
6
+
7
+ Fjell Cache provides intelligent caching capabilities for complex data models and business relationships. Built on the Fjell framework architecture, it offers high-performance caching with automatic relationship management and business logic integration.
8
+
9
+ ## Features
10
+
11
+ - **Smart Caching**: Intelligent cache operations with automatic cache hits/misses
12
+ - **Business Relationships**: Automatic population of related entities through aggregation
13
+ - **Performance Optimized**: High-performance cache operations with bulk processing
14
+ - **Location-Based**: Support for contained items with location hierarchies
15
+ - **Framework Integration**: Seamless integration with Fjell Core, Registry, and Client API
16
+ - **TypeScript First**: Full TypeScript support with comprehensive type safety
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install @fjell/cache
22
+ # or
23
+ pnpm add @fjell/cache
24
+ # or
25
+ yarn add @fjell/cache
26
+ ```
27
+
28
+ ## Quick Start
29
+
30
+ ```typescript
31
+ import { createCache } from '@fjell/cache';
32
+ import { createCoordinate, createRegistry } from '@fjell/registry';
33
+ import { ClientApi } from '@fjell/client-api';
34
+
35
+ // Create a registry for cache management
36
+ const registry = createRegistry();
37
+
38
+ // Create a cache instance with API integration
39
+ const userApi = createUserApi(); // Your API implementation
40
+ const userCache = await createCache(userApi, createCoordinate('user'), registry);
41
+
42
+ // Perform cache operations
43
+ const [cacheMap, allUsers] = await userCache.operations.all();
44
+ const [, cachedUser] = await userCache.operations.get(userKey);
45
+ const [, retrievedUser] = await userCache.operations.retrieve(userKey); // Cache hit!
46
+
47
+ await userCache.operations.set(userKey, updatedUser);
48
+ ```
49
+
50
+ ## Core Components
51
+
52
+ ### Basic Caching
53
+ - **Cache Operations**: Get, set, retrieve, and manage cached data
54
+ - **Cache-as-Instance**: Caches extend Instance from fjell-registry
55
+ - **Performance Monitoring**: Track cache hits, misses, and efficiency
56
+
57
+ ### Advanced Aggregation
58
+ - **Entity Relationships**: Automatic population of related entities
59
+ - **Required vs Optional**: Flexible relationship management
60
+ - **Business Logic**: Complex business scenarios with interconnected data
61
+
62
+ ### Direct Cache Management
63
+ - **CacheMap**: Low-level cache operations and management
64
+ - **Location Filtering**: Filter contained items by location hierarchy
65
+ - **Bulk Operations**: Efficient processing of multiple cache operations
66
+
67
+ ## Examples
68
+
69
+ Comprehensive examples are available in the [examples directory](./examples/):
70
+
71
+ - **[Basic Cache Example](./examples/basic-cache-example.ts)** - Start here! Fundamental caching operations
72
+ - **[Aggregator Example](./examples/aggregator-example.ts)** - Advanced business relationships
73
+ - **[Cache Map Example](./examples/cache-map-example.ts)** - Low-level cache operations
74
+
75
+ ## Documentation
76
+
77
+ For detailed documentation, examples, and API reference, visit our [documentation site](https://getfjell.github.io/fjell-cache/).
78
+
79
+ ## Dependencies
80
+
81
+ Fjell Cache builds on the Fjell ecosystem:
82
+ - `@fjell/core` - Core framework functionality
83
+ - `@fjell/registry` - Registry and coordinate management
84
+ - `@fjell/client-api` - API integration layer
85
+ - `@fjell/http-api` - HTTP API capabilities
86
+ - `@fjell/logging` - Structured logging
87
+
88
+ ## License
89
+
90
+ Apache-2.0
91
+
92
+ ## Contributing
93
+
94
+ We welcome contributions! Please see our contributing guidelines for more information.
95
+
96
+ Built with love by the Fjell team.
@@ -61,7 +61,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
61
61
  logger.default('AGG Retrieving Item in Populate', {
62
62
  key: ref
63
63
  });
64
- const [, newItem] = await cacheConfig.cache.retrieve(ref);
64
+ const [, newItem] = await cacheConfig.cache.operations.retrieve(ref);
65
65
  if (newItem) {
66
66
  if (item.aggs === undefined) {
67
67
  item.aggs = {};
@@ -102,7 +102,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
102
102
  logger.default('EVENT Retrieving Item in Populate', {
103
103
  key: event.by
104
104
  });
105
- const [, newItem] = await cacheConfig.cache.retrieve(event.by);
105
+ const [, newItem] = await cacheConfig.cache.operations.retrieve(event.by);
106
106
  if (newItem) {
107
107
  event.agg = newItem;
108
108
  }
@@ -113,7 +113,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
113
113
  query,
114
114
  locations
115
115
  });
116
- const [cacheMap, items] = await cache.all(query, locations);
116
+ const [cacheMap, items] = await cache.operations.all(query, locations);
117
117
  const populatedItems = await Promise.all(items.map(async (item)=>populate(item)));
118
118
  return [
119
119
  cacheMap,
@@ -125,7 +125,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
125
125
  query,
126
126
  locations
127
127
  });
128
- const [cacheMap, item] = await cache.one(query, locations);
128
+ const [cacheMap, item] = await cache.operations.one(query, locations);
129
129
  let populatedItem = null;
130
130
  if (item) {
131
131
  populatedItem = await populate(item);
@@ -141,7 +141,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
141
141
  action,
142
142
  body
143
143
  });
144
- const [cacheMap, item] = await cache.action(key, action, body);
144
+ const [cacheMap, item] = await cache.operations.action(key, action, body);
145
145
  const populatedItem = await populate(item);
146
146
  return [
147
147
  cacheMap,
@@ -154,7 +154,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
154
154
  body,
155
155
  locations
156
156
  });
157
- const [cacheMap, items] = await cache.allAction(action, body, locations);
157
+ const [cacheMap, items] = await cache.operations.allAction(action, body, locations);
158
158
  const populatedItems = await Promise.all(items.map(async (item)=>populate(item)));
159
159
  return [
160
160
  cacheMap,
@@ -167,7 +167,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
167
167
  params,
168
168
  locations
169
169
  });
170
- const [cacheMap, response] = await cache.allFacet(facet, params, locations);
170
+ const [cacheMap, response] = await cache.operations.allFacet(facet, params, locations);
171
171
  return [
172
172
  cacheMap,
173
173
  response
@@ -178,7 +178,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
178
178
  v,
179
179
  locations
180
180
  });
181
- const [cacheMap, item] = await cache.create(v, locations);
181
+ const [cacheMap, item] = await cache.operations.create(v, locations);
182
182
  const populatedItem = await populate(item);
183
183
  return [
184
184
  cacheMap,
@@ -189,7 +189,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
189
189
  logger.default('get', {
190
190
  key
191
191
  });
192
- const [cacheMap, item] = await cache.get(key);
192
+ const [cacheMap, item] = await cache.operations.get(key);
193
193
  let populatedItem = null;
194
194
  if (item) {
195
195
  populatedItem = await populate(item);
@@ -203,7 +203,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
203
203
  logger.default('retrieve', {
204
204
  key
205
205
  });
206
- const [cacheMap, item] = await cache.retrieve(key);
206
+ const [cacheMap, item] = await cache.operations.retrieve(key);
207
207
  let populatedItem = null;
208
208
  if (item) {
209
209
  populatedItem = await populate(item);
@@ -217,7 +217,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
217
217
  logger.default('remove', {
218
218
  key
219
219
  });
220
- const cacheMap = await cache.remove(key);
220
+ const cacheMap = await cache.operations.remove(key);
221
221
  return cacheMap;
222
222
  };
223
223
  const update = async (key, v)=>{
@@ -225,7 +225,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
225
225
  key,
226
226
  v
227
227
  });
228
- const [cacheMap, item] = await cache.update(key, v);
228
+ const [cacheMap, item] = await cache.operations.update(key, v);
229
229
  const populatedItem = await populate(item);
230
230
  return [
231
231
  cacheMap,
@@ -238,7 +238,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
238
238
  key,
239
239
  facet
240
240
  });
241
- const [cacheMap, response] = await cache.facet(key, facet);
241
+ const [cacheMap, response] = await cache.operations.facet(key, facet);
242
242
  return [
243
243
  cacheMap,
244
244
  response
@@ -250,7 +250,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
250
250
  finderParams,
251
251
  locations
252
252
  });
253
- const [cacheMap, items] = await cache.find(finder, finderParams, locations);
253
+ const [cacheMap, items] = await cache.operations.find(finder, finderParams, locations);
254
254
  const populatedItems = await Promise.all(items.map(async (item)=>populate(item)));
255
255
  return [
256
256
  cacheMap,
@@ -263,7 +263,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
263
263
  finderParams,
264
264
  locations
265
265
  });
266
- const [cacheMap, item] = await cache.findOne(finder, finderParams, locations);
266
+ const [cacheMap, item] = await cache.operations.findOne(finder, finderParams, locations);
267
267
  const populatedItem = await populate(item);
268
268
  return [
269
269
  cacheMap,
@@ -276,7 +276,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
276
276
  v
277
277
  });
278
278
  // TODO: There should be some input validation here to ensure a valid item.
279
- const [cacheMap, item] = await cache.set(key, v);
279
+ const [cacheMap, item] = await cache.operations.set(key, v);
280
280
  const populatedItem = await populate(item);
281
281
  return [
282
282
  cacheMap,
@@ -284,10 +284,17 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
284
284
  ];
285
285
  };
286
286
  const reset = async ()=>{
287
- const cacheMap = await cache.reset();
287
+ const cacheMap = await cache.operations.reset();
288
288
  return cacheMap;
289
289
  };
290
290
  return {
291
+ // Cache properties
292
+ coordinate: cache.coordinate,
293
+ registry: cache.registry,
294
+ api: cache.api,
295
+ cacheMap: cache.cacheMap,
296
+ operations: cache.operations,
297
+ // Cache operations exposed directly
291
298
  all,
292
299
  one,
293
300
  action,
@@ -303,8 +310,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
303
310
  findOne,
304
311
  reset,
305
312
  set,
306
- pkTypes: cache.pkTypes,
307
- cacheMap: cache.cacheMap,
313
+ // Aggregator-specific operations
308
314
  populate,
309
315
  populateAggregate,
310
316
  populateEvent
@@ -313,4 +319,4 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
313
319
 
314
320
  exports.createAggregator = createAggregator;
315
321
  exports.toCacheConfig = toCacheConfig;
316
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQWdncmVnYXRvci5janMuanMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7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7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9
@@ -1,6 +1,22 @@
1
- import { Item } from '@fjell/core';
1
+ import { ComKey, Item, ItemQuery, LocKeyArray, PriKey } from '@fjell/core';
2
2
  import { Cache } from './Cache';
3
+ import { CacheMap } from './CacheMap';
3
4
  export interface Aggregator<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> extends Cache<V, S, L1, L2, L3, L4, L5> {
5
+ all: (query?: ItemQuery, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V[]]>;
6
+ one: (query?: ItemQuery, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V | null]>;
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
+ allAction: (action: string, body?: any, 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: Partial<Item<S, L1, L2, L3, L4, L5>>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V]>;
11
+ get: (key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>, V | null]>;
12
+ retrieve: (key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>) => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5> | null, V | null]>;
13
+ remove: (key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>) => Promise<CacheMap<V, S, L1, L2, L3, L4, L5>>;
14
+ update: (key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, item: Partial<Item<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]>;
19
+ reset: () => Promise<[CacheMap<V, S, L1, L2, L3, L4, L5>]>;
4
20
  populate: (item: V) => Promise<V>;
5
21
  populateAggregate: (key: string, item: V) => Promise<void>;
6
22
  populateEvent: (key: string, item: V) => Promise<void>;
@@ -57,7 +57,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
57
57
  logger.default('AGG Retrieving Item in Populate', {
58
58
  key: ref
59
59
  });
60
- const [, newItem] = await cacheConfig.cache.retrieve(ref);
60
+ const [, newItem] = await cacheConfig.cache.operations.retrieve(ref);
61
61
  if (newItem) {
62
62
  if (item.aggs === undefined) {
63
63
  item.aggs = {};
@@ -98,7 +98,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
98
98
  logger.default('EVENT Retrieving Item in Populate', {
99
99
  key: event.by
100
100
  });
101
- const [, newItem] = await cacheConfig.cache.retrieve(event.by);
101
+ const [, newItem] = await cacheConfig.cache.operations.retrieve(event.by);
102
102
  if (newItem) {
103
103
  event.agg = newItem;
104
104
  }
@@ -109,7 +109,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
109
109
  query,
110
110
  locations
111
111
  });
112
- const [cacheMap, items] = await cache.all(query, locations);
112
+ const [cacheMap, items] = await cache.operations.all(query, locations);
113
113
  const populatedItems = await Promise.all(items.map(async (item)=>populate(item)));
114
114
  return [
115
115
  cacheMap,
@@ -121,7 +121,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
121
121
  query,
122
122
  locations
123
123
  });
124
- const [cacheMap, item] = await cache.one(query, locations);
124
+ const [cacheMap, item] = await cache.operations.one(query, locations);
125
125
  let populatedItem = null;
126
126
  if (item) {
127
127
  populatedItem = await populate(item);
@@ -137,7 +137,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
137
137
  action,
138
138
  body
139
139
  });
140
- const [cacheMap, item] = await cache.action(key, action, body);
140
+ const [cacheMap, item] = await cache.operations.action(key, action, body);
141
141
  const populatedItem = await populate(item);
142
142
  return [
143
143
  cacheMap,
@@ -150,7 +150,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
150
150
  body,
151
151
  locations
152
152
  });
153
- const [cacheMap, items] = await cache.allAction(action, body, locations);
153
+ const [cacheMap, items] = await cache.operations.allAction(action, body, locations);
154
154
  const populatedItems = await Promise.all(items.map(async (item)=>populate(item)));
155
155
  return [
156
156
  cacheMap,
@@ -163,7 +163,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
163
163
  params,
164
164
  locations
165
165
  });
166
- const [cacheMap, response] = await cache.allFacet(facet, params, locations);
166
+ const [cacheMap, response] = await cache.operations.allFacet(facet, params, locations);
167
167
  return [
168
168
  cacheMap,
169
169
  response
@@ -174,7 +174,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
174
174
  v,
175
175
  locations
176
176
  });
177
- const [cacheMap, item] = await cache.create(v, locations);
177
+ const [cacheMap, item] = await cache.operations.create(v, locations);
178
178
  const populatedItem = await populate(item);
179
179
  return [
180
180
  cacheMap,
@@ -185,7 +185,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
185
185
  logger.default('get', {
186
186
  key
187
187
  });
188
- const [cacheMap, item] = await cache.get(key);
188
+ const [cacheMap, item] = await cache.operations.get(key);
189
189
  let populatedItem = null;
190
190
  if (item) {
191
191
  populatedItem = await populate(item);
@@ -199,7 +199,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
199
199
  logger.default('retrieve', {
200
200
  key
201
201
  });
202
- const [cacheMap, item] = await cache.retrieve(key);
202
+ const [cacheMap, item] = await cache.operations.retrieve(key);
203
203
  let populatedItem = null;
204
204
  if (item) {
205
205
  populatedItem = await populate(item);
@@ -213,7 +213,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
213
213
  logger.default('remove', {
214
214
  key
215
215
  });
216
- const cacheMap = await cache.remove(key);
216
+ const cacheMap = await cache.operations.remove(key);
217
217
  return cacheMap;
218
218
  };
219
219
  const update = async (key, v)=>{
@@ -221,7 +221,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
221
221
  key,
222
222
  v
223
223
  });
224
- const [cacheMap, item] = await cache.update(key, v);
224
+ const [cacheMap, item] = await cache.operations.update(key, v);
225
225
  const populatedItem = await populate(item);
226
226
  return [
227
227
  cacheMap,
@@ -234,7 +234,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
234
234
  key,
235
235
  facet
236
236
  });
237
- const [cacheMap, response] = await cache.facet(key, facet);
237
+ const [cacheMap, response] = await cache.operations.facet(key, facet);
238
238
  return [
239
239
  cacheMap,
240
240
  response
@@ -246,7 +246,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
246
246
  finderParams,
247
247
  locations
248
248
  });
249
- const [cacheMap, items] = await cache.find(finder, finderParams, locations);
249
+ const [cacheMap, items] = await cache.operations.find(finder, finderParams, locations);
250
250
  const populatedItems = await Promise.all(items.map(async (item)=>populate(item)));
251
251
  return [
252
252
  cacheMap,
@@ -259,7 +259,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
259
259
  finderParams,
260
260
  locations
261
261
  });
262
- const [cacheMap, item] = await cache.findOne(finder, finderParams, locations);
262
+ const [cacheMap, item] = await cache.operations.findOne(finder, finderParams, locations);
263
263
  const populatedItem = await populate(item);
264
264
  return [
265
265
  cacheMap,
@@ -272,7 +272,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
272
272
  v
273
273
  });
274
274
  // TODO: There should be some input validation here to ensure a valid item.
275
- const [cacheMap, item] = await cache.set(key, v);
275
+ const [cacheMap, item] = await cache.operations.set(key, v);
276
276
  const populatedItem = await populate(item);
277
277
  return [
278
278
  cacheMap,
@@ -280,10 +280,17 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
280
280
  ];
281
281
  };
282
282
  const reset = async ()=>{
283
- const cacheMap = await cache.reset();
283
+ const cacheMap = await cache.operations.reset();
284
284
  return cacheMap;
285
285
  };
286
286
  return {
287
+ // Cache properties
288
+ coordinate: cache.coordinate,
289
+ registry: cache.registry,
290
+ api: cache.api,
291
+ cacheMap: cache.cacheMap,
292
+ operations: cache.operations,
293
+ // Cache operations exposed directly
287
294
  all,
288
295
  one,
289
296
  action,
@@ -299,8 +306,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
299
306
  findOne,
300
307
  reset,
301
308
  set,
302
- pkTypes: cache.pkTypes,
303
- cacheMap: cache.cacheMap,
309
+ // Aggregator-specific operations
304
310
  populate,
305
311
  populateAggregate,
306
312
  populateEvent
@@ -308,4 +314,4 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
308
314
  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