@fjell/cache 4.6.7 → 4.6.10

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/index.cjs CHANGED
@@ -5,10 +5,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
5
  const Logging = require('@fjell/logging');
6
6
  const core = require('@fjell/core');
7
7
  const httpApi = require('@fjell/http-api');
8
+ const registry = require('@fjell/registry');
8
9
 
9
10
  const LibLogger = Logging.getLogger('@fjell/cache');
10
11
 
11
- const logger$3 = LibLogger.get('ItemAggregator');
12
+ const logger$5 = LibLogger.get('ItemAggregator');
12
13
  const toCacheConfig = (config)=>{
13
14
  let cacheConfig;
14
15
  if (config.optional === undefined) {
@@ -23,7 +24,7 @@ const toCacheConfig = (config)=>{
23
24
  };
24
25
  const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
25
26
  const populate = async (item)=>{
26
- logger$3.default('populate', {
27
+ logger$5.default('populate', {
27
28
  item
28
29
  });
29
30
  for(const key in aggregates){
@@ -32,19 +33,19 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
32
33
  for(const key in events){
33
34
  await populateEvent(key, item);
34
35
  }
35
- logger$3.default('populate done', {
36
+ logger$5.default('populate done', {
36
37
  item
37
38
  });
38
39
  return item;
39
40
  };
40
41
  const populateAggregate = async (key, item)=>{
41
- logger$3.default('populate aggregate key', {
42
+ logger$5.default('populate aggregate key', {
42
43
  key
43
44
  });
44
45
  const cacheConfig = toCacheConfig(aggregates[key]);
45
46
  if (item.refs === undefined) {
46
47
  if (cacheConfig.optional === false) {
47
- logger$3.error('Item does not have refs an is not optional ' + JSON.stringify(item));
48
+ logger$5.error('Item does not have refs an is not optional ' + JSON.stringify(item));
48
49
  throw new Error('Item does not have refs an is not optional ' + JSON.stringify(item));
49
50
  } else {
50
51
  if (item.events && Object.prototype.hasOwnProperty.call(item.events, key)) {
@@ -53,7 +54,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
53
54
  }
54
55
  } else if (item.refs[key] === undefined) {
55
56
  if (cacheConfig.optional === false) {
56
- logger$3.error('Item does not have mandatory ref with key, not optional ' + key + ' ' + JSON.stringify(item));
57
+ logger$5.error('Item does not have mandatory ref with key, not optional ' + key + ' ' + JSON.stringify(item));
57
58
  throw new Error('Item does not have mandatory ref with key, not optional ' + key + ' ' + JSON.stringify(item));
58
59
  } else {
59
60
  if (item.events && Object.prototype.hasOwnProperty.call(item.events, key)) {
@@ -62,7 +63,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
62
63
  }
63
64
  } else {
64
65
  const ref = item.refs[key];
65
- logger$3.default('AGG Retrieving Item in Populate', {
66
+ logger$5.default('AGG Retrieving Item in Populate', {
66
67
  key: ref
67
68
  });
68
69
  const [, newItem] = await cacheConfig.cache.retrieve(ref);
@@ -79,7 +80,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
79
80
  };
80
81
  // TODO: I'm not a big fan that this just "automatically" assumes that the "by" key in event is a ref.
81
82
  const populateEvent = async (key, item)=>{
82
- logger$3.default('populate event key', {
83
+ logger$5.default('populate event key', {
83
84
  key
84
85
  });
85
86
  const cacheConfig = toCacheConfig(events[key]);
@@ -87,13 +88,13 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
87
88
  throw new Error('Item does not have events ' + JSON.stringify(item));
88
89
  } else if (item.events[key] === undefined) {
89
90
  if (cacheConfig.optional === false) {
90
- logger$3.error('Item does not have mandatory event with key ' + key + ' ' + JSON.stringify(item));
91
+ logger$5.error('Item does not have mandatory event with key ' + key + ' ' + JSON.stringify(item));
91
92
  throw new Error('Item does not have mandatory event with key ' + key + ' ' + JSON.stringify(item));
92
93
  }
93
94
  } else {
94
95
  const event = item.events[key];
95
96
  if (event.by === undefined) {
96
- logger$3.error('populateEvent with an Event that does not have by', {
97
+ logger$5.error('populateEvent with an Event that does not have by', {
97
98
  event,
98
99
  ik: item.key,
99
100
  eventKey: key
@@ -103,7 +104,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
103
104
  event
104
105
  }));
105
106
  }
106
- logger$3.default('EVENT Retrieving Item in Populate', {
107
+ logger$5.default('EVENT Retrieving Item in Populate', {
107
108
  key: event.by
108
109
  });
109
110
  const [, newItem] = await cacheConfig.cache.retrieve(event.by);
@@ -113,7 +114,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
113
114
  }
114
115
  };
115
116
  const all = async (query = {}, locations = [])=>{
116
- logger$3.default('all', {
117
+ logger$5.default('all', {
117
118
  query,
118
119
  locations
119
120
  });
@@ -125,7 +126,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
125
126
  ];
126
127
  };
127
128
  const one = async (query = {}, locations = [])=>{
128
- logger$3.default('one', {
129
+ logger$5.default('one', {
129
130
  query,
130
131
  locations
131
132
  });
@@ -140,7 +141,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
140
141
  ];
141
142
  };
142
143
  const action = async (key, action, body = {})=>{
143
- logger$3.default('action', {
144
+ logger$5.default('action', {
144
145
  key,
145
146
  action,
146
147
  body
@@ -153,7 +154,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
153
154
  ];
154
155
  };
155
156
  const allAction = async (action, body = {}, locations = [])=>{
156
- logger$3.default('action', {
157
+ logger$5.default('action', {
157
158
  action,
158
159
  body,
159
160
  locations
@@ -166,7 +167,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
166
167
  ];
167
168
  };
168
169
  const allFacet = async (facet, params = {}, locations = [])=>{
169
- logger$3.default('allFacet', {
170
+ logger$5.default('allFacet', {
170
171
  facet,
171
172
  params,
172
173
  locations
@@ -178,7 +179,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
178
179
  ];
179
180
  };
180
181
  const create = async (v, locations = [])=>{
181
- logger$3.default('create', {
182
+ logger$5.default('create', {
182
183
  v,
183
184
  locations
184
185
  });
@@ -190,7 +191,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
190
191
  ];
191
192
  };
192
193
  const get = async (key)=>{
193
- logger$3.default('get', {
194
+ logger$5.default('get', {
194
195
  key
195
196
  });
196
197
  const [cacheMap, item] = await cache.get(key);
@@ -204,7 +205,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
204
205
  ];
205
206
  };
206
207
  const retrieve = async (key)=>{
207
- logger$3.default('retrieve', {
208
+ logger$5.default('retrieve', {
208
209
  key
209
210
  });
210
211
  const [cacheMap, item] = await cache.retrieve(key);
@@ -218,14 +219,14 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
218
219
  ];
219
220
  };
220
221
  const remove = async (key)=>{
221
- logger$3.default('remove', {
222
+ logger$5.default('remove', {
222
223
  key
223
224
  });
224
225
  const cacheMap = await cache.remove(key);
225
226
  return cacheMap;
226
227
  };
227
228
  const update = async (key, v)=>{
228
- logger$3.default('update', {
229
+ logger$5.default('update', {
229
230
  key,
230
231
  v
231
232
  });
@@ -238,7 +239,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
238
239
  };
239
240
  // Facets are a pass-thru for aggregators
240
241
  const facet = async (key, facet)=>{
241
- logger$3.default('facet', {
242
+ logger$5.default('facet', {
242
243
  key,
243
244
  facet
244
245
  });
@@ -249,7 +250,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
249
250
  ];
250
251
  };
251
252
  const find = async (finder, finderParams = {}, locations = [])=>{
252
- logger$3.default('find', {
253
+ logger$5.default('find', {
253
254
  finder,
254
255
  finderParams,
255
256
  locations
@@ -262,7 +263,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
262
263
  ];
263
264
  };
264
265
  const findOne = async (finder, finderParams = {}, locations = [])=>{
265
- logger$3.default('find', {
266
+ logger$5.default('find', {
266
267
  finder,
267
268
  finderParams,
268
269
  locations
@@ -275,7 +276,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
275
276
  ];
276
277
  };
277
278
  const set = async (key, v)=>{
278
- logger$3.default('set', {
279
+ logger$5.default('set', {
279
280
  key,
280
281
  v
281
282
  });
@@ -315,7 +316,7 @@ const createAggregator = async (cache, { aggregates = {}, events = {} })=>{
315
316
  };
316
317
  };
317
318
 
318
- function _define_property$1(obj, key, value) {
319
+ function _define_property(obj, key, value) {
319
320
  if (key in obj) {
320
321
  Object.defineProperty(obj, key, {
321
322
  value: value,
@@ -328,7 +329,7 @@ function _define_property$1(obj, key, value) {
328
329
  }
329
330
  return obj;
330
331
  }
331
- const logger$2 = LibLogger.get("CacheMap");
332
+ const logger$4 = LibLogger.get("CacheMap");
332
333
  // Normalize a key value to string for consistent comparison and hashing
333
334
  const normalizeKeyValue$1 = (value)=>{
334
335
  return String(value);
@@ -431,17 +432,17 @@ class CacheMap extends core.Dictionary {
431
432
  }
432
433
  allIn(locations) {
433
434
  if (locations.length === 0) {
434
- logger$2.debug('Returning all items, LocKeys is empty');
435
+ logger$4.debug('Returning all items, LocKeys is empty');
435
436
  return this.values();
436
437
  } else {
437
438
  const locKeys = locations;
438
- logger$2.debug('allIn', {
439
+ logger$4.debug('allIn', {
439
440
  locKeys,
440
441
  keys: this.keys().length
441
442
  });
442
443
  return this.keys().filter((key)=>key && core.isComKey(key)).filter((key)=>{
443
444
  const ComKey = key;
444
- logger$2.debug('Comparing Location Keys', {
445
+ logger$4.debug('Comparing Location Keys', {
445
446
  locKeys,
446
447
  ComKey
447
448
  });
@@ -451,7 +452,7 @@ class CacheMap extends core.Dictionary {
451
452
  }
452
453
  // TODO: Can we do case insensitive matching?
453
454
  contains(query, locations) {
454
- logger$2.debug('contains', {
455
+ logger$4.debug('contains', {
455
456
  query,
456
457
  locations
457
458
  });
@@ -459,7 +460,7 @@ class CacheMap extends core.Dictionary {
459
460
  return items.some((item)=>core.isQueryMatch(item, query));
460
461
  }
461
462
  queryIn(query, locations = []) {
462
- logger$2.debug('queryIn', {
463
+ logger$4.debug('queryIn', {
463
464
  query,
464
465
  locations
465
466
  });
@@ -471,12 +472,12 @@ class CacheMap extends core.Dictionary {
471
472
  return clone;
472
473
  }
473
474
  constructor(types, map){
474
- super(map, createNormalizedHashFunction()), _define_property$1(this, "types", void 0);
475
+ super(map, createNormalizedHashFunction()), _define_property(this, "types", void 0);
475
476
  this.types = types;
476
477
  }
477
478
  }
478
479
 
479
- const logger$1 = LibLogger.get('Cache');
480
+ const logger$3 = LibLogger.get('Cache');
480
481
  // Normalize a key value to string for consistent comparison
481
482
  const normalizeKeyValue = (value)=>{
482
483
  return String(value);
@@ -525,7 +526,7 @@ const createCache = async (api, pkType, parentCache)=>{
525
526
  }
526
527
  let cacheMap = new CacheMap(pkTypes);
527
528
  const all = async (query = {}, locations = [])=>{
528
- logger$1.default('all', {
529
+ logger$3.default('all', {
529
530
  query,
530
531
  locations
531
532
  });
@@ -546,7 +547,7 @@ const createCache = async (api, pkType, parentCache)=>{
546
547
  ];
547
548
  };
548
549
  const one = async (query = {}, locations = [])=>{
549
- logger$1.default('one', {
550
+ logger$3.default('one', {
550
551
  query,
551
552
  locations
552
553
  });
@@ -567,7 +568,7 @@ const createCache = async (api, pkType, parentCache)=>{
567
568
  ];
568
569
  };
569
570
  const action = async (key, action, body = {})=>{
570
- logger$1.default('action', {
571
+ logger$3.default('action', {
571
572
  key,
572
573
  action,
573
574
  body
@@ -575,7 +576,7 @@ const createCache = async (api, pkType, parentCache)=>{
575
576
  // TODO: This is validating the key, but it doesn't have knowledge of the pkType
576
577
  // This should be looking at the parentCaches and calculating an array of pkTypes
577
578
  if (!core.isValidItemKey(key)) {
578
- logger$1.error('Key for Action is not a valid ItemKey: %j', key);
579
+ logger$3.error('Key for Action is not a valid ItemKey: %j', key);
579
580
  throw new Error('Key for Action is not a valid ItemKey');
580
581
  }
581
582
  const updated = await api.action(key, action, body);
@@ -586,7 +587,7 @@ const createCache = async (api, pkType, parentCache)=>{
586
587
  ];
587
588
  };
588
589
  const allAction = async (action, body = {}, locations = [])=>{
589
- logger$1.default('allAction', {
590
+ logger$3.default('allAction', {
590
591
  action,
591
592
  body,
592
593
  locations
@@ -609,7 +610,7 @@ const createCache = async (api, pkType, parentCache)=>{
609
610
  ];
610
611
  };
611
612
  const allFacet = async (facet, params = {}, locations = [])=>{
612
- logger$1.default('allFacet', {
613
+ logger$3.default('allFacet', {
613
614
  facet,
614
615
  params,
615
616
  locations
@@ -621,7 +622,7 @@ const createCache = async (api, pkType, parentCache)=>{
621
622
  ];
622
623
  };
623
624
  const create = async (v, locations = [])=>{
624
- logger$1.default('create', {
625
+ logger$3.default('create', {
625
626
  v,
626
627
  locations
627
628
  });
@@ -633,13 +634,13 @@ const createCache = async (api, pkType, parentCache)=>{
633
634
  ];
634
635
  };
635
636
  const get = async (key)=>{
636
- logger$1.default('get', {
637
+ logger$3.default('get', {
637
638
  key
638
639
  });
639
640
  // TODO: This is validating the key, but it doesn't have knowledge of the pkType
640
641
  // This should be looking at the parentCaches and calculating an array of pkTypes
641
642
  if (!core.isValidItemKey(key)) {
642
- logger$1.error('Key for Get is not a valid ItemKey: %j', key);
643
+ logger$3.error('Key for Get is not a valid ItemKey: %j', key);
643
644
  throw new Error('Key for Get is not a valid ItemKey');
644
645
  }
645
646
  let ret;
@@ -649,7 +650,7 @@ const createCache = async (api, pkType, parentCache)=>{
649
650
  cacheMap.set(ret.key, ret);
650
651
  }
651
652
  } catch (e) {
652
- logger$1.error("Error getting item for key", {
653
+ logger$3.error("Error getting item for key", {
653
654
  key,
654
655
  message: e.message,
655
656
  stack: e.stack
@@ -662,20 +663,20 @@ const createCache = async (api, pkType, parentCache)=>{
662
663
  ];
663
664
  };
664
665
  const retrieve = async (key)=>{
665
- logger$1.default('retrieve', {
666
+ logger$3.default('retrieve', {
666
667
  key
667
668
  });
668
669
  if (!core.isValidItemKey(key)) {
669
- logger$1.error('Key for Retrieve is not a valid ItemKey: %j', key);
670
+ logger$3.error('Key for Retrieve is not a valid ItemKey: %j', key);
670
671
  throw new Error('Key for Retrieve is not a valid ItemKey');
671
672
  }
672
673
  const containsItemKey = cacheMap.includesKey(key);
673
674
  let retrieved;
674
675
  if (containsItemKey) {
675
- logger$1.default('Looking for Object in Cache', key);
676
+ logger$3.default('Looking for Object in Cache', key);
676
677
  retrieved = cacheMap.get(key);
677
678
  } else {
678
- logger$1.default('Object Not Found in Cache, Retrieving from Server API', {
679
+ logger$3.default('Object Not Found in Cache, Retrieving from Server API', {
679
680
  key
680
681
  });
681
682
  [, retrieved] = await get(key);
@@ -688,20 +689,20 @@ const createCache = async (api, pkType, parentCache)=>{
688
689
  return retValue;
689
690
  };
690
691
  const remove = async (key)=>{
691
- logger$1.default('remove', {
692
+ logger$3.default('remove', {
692
693
  key
693
694
  });
694
695
  // TODO: This is validating the key, but it doesn't have knowledge of the pkType
695
696
  // This should be looking at the parentCaches and calculating an array of pkTypes
696
697
  if (!core.isValidItemKey(key)) {
697
- logger$1.error('Key for Remove is not a valid ItemKey: %j', key);
698
+ logger$3.error('Key for Remove is not a valid ItemKey: %j', key);
698
699
  throw new Error('Key for Remove is not a valid ItemKey');
699
700
  }
700
701
  try {
701
702
  await api.remove(key);
702
703
  cacheMap.delete(key);
703
704
  } catch (e) {
704
- logger$1.error("Error deleting item", {
705
+ logger$3.error("Error deleting item", {
705
706
  error: e
706
707
  });
707
708
  throw e;
@@ -709,14 +710,14 @@ const createCache = async (api, pkType, parentCache)=>{
709
710
  return cacheMap;
710
711
  };
711
712
  const update = async (key, v)=>{
712
- logger$1.default('update', {
713
+ logger$3.default('update', {
713
714
  key,
714
715
  v
715
716
  });
716
717
  // TODO: This is validating the key, but it doesn't have knowledge of the pkType
717
718
  // This should be looking at the parentCaches and calculating an array of pkTypes
718
719
  if (!core.isValidItemKey(key)) {
719
- logger$1.error('Key for Update is not a valid ItemKey: %j', key);
720
+ logger$3.error('Key for Update is not a valid ItemKey: %j', key);
720
721
  throw new Error('Key for Update is not a valid ItemKey');
721
722
  }
722
723
  try {
@@ -727,7 +728,7 @@ const createCache = async (api, pkType, parentCache)=>{
727
728
  core.validatePK(updated, pkType)
728
729
  ];
729
730
  } catch (e) {
730
- logger$1.error("Error updating chat", {
731
+ logger$3.error("Error updating chat", {
731
732
  error: e
732
733
  });
733
734
  throw e;
@@ -735,7 +736,7 @@ const createCache = async (api, pkType, parentCache)=>{
735
736
  };
736
737
  // Facets are a pass-thru for caches
737
738
  const facet = async (key, facet, params = {})=>{
738
- logger$1.default('facet', {
739
+ logger$3.default('facet', {
739
740
  key,
740
741
  facet
741
742
  });
@@ -746,7 +747,7 @@ const createCache = async (api, pkType, parentCache)=>{
746
747
  ];
747
748
  };
748
749
  const find = async (finder, params = {}, locations = [])=>{
749
- logger$1.default('find', {
750
+ logger$3.default('find', {
750
751
  finder,
751
752
  params,
752
753
  locations
@@ -761,7 +762,7 @@ const createCache = async (api, pkType, parentCache)=>{
761
762
  ];
762
763
  };
763
764
  const findOne = async (finder, finderParams = {}, locations = [])=>{
764
- logger$1.default('findOne', {
765
+ logger$3.default('findOne', {
765
766
  finder,
766
767
  finderParams,
767
768
  locations
@@ -780,20 +781,20 @@ const createCache = async (api, pkType, parentCache)=>{
780
781
  ];
781
782
  };
782
783
  const set = async (key, v)=>{
783
- logger$1.default('set', {
784
+ logger$3.default('set', {
784
785
  key,
785
786
  v
786
787
  });
787
788
  // TODO: This is validating the key, but it doesn't have knowledge of the pkType
788
789
  // This should be looking at the parentCaches and calculating an array of pkTypes
789
790
  if (!core.isValidItemKey(key)) {
790
- logger$1.error('Key for Update is not a valid ItemKey: %j', key);
791
+ logger$3.error('Key for Update is not a valid ItemKey: %j', key);
791
792
  throw new Error('Key for Update is not a valid ItemKey');
792
793
  }
793
794
  // TODO: This could be merged with the isValidItemKey check, later.
794
795
  core.validatePK(v, pkType);
795
796
  if (!isItemKeyEqualNormalized(key, v.key)) {
796
- logger$1.error('Key does not match item key: %j != %j', key, v.key);
797
+ logger$3.error('Key does not match item key: %j != %j', key, v.key);
797
798
  throw new Error('Key does not match item key');
798
799
  }
799
800
  cacheMap.set(key, v);
@@ -823,67 +824,70 @@ const createCache = async (api, pkType, parentCache)=>{
823
824
  };
824
825
  };
825
826
 
826
- function _define_property(obj, key, value) {
827
- if (key in obj) {
828
- Object.defineProperty(obj, key, {
829
- value: value,
830
- enumerable: true,
831
- configurable: true,
832
- writable: true
833
- });
834
- } else {
835
- obj[key] = value;
836
- }
837
- return obj;
838
- }
839
- const logger = LibLogger.get('CacheRegistry');
840
- class CacheRegistry {
841
- constructor(){
842
- // TODO: My use of Generics has Boxed me into a corner where I can't reference AbstractCache without the types
843
- _define_property(this, "cacheMap", {});
844
- _define_property(this, "registerCache", async (cache)=>{
845
- try {
846
- logger.debug('Attempting to register cache with pkTypes:', cache.pkTypes);
847
- const key = JSON.stringify(cache.pkTypes);
848
- if (this.cacheMap[key]) {
849
- logger.debug(`Cache with pkTypes ${key} already exists, will be overwritten`);
850
- }
851
- this.cacheMap[key] = cache;
852
- logger.debug('Cache registered successfully with key:', key);
853
- } catch (error) {
854
- logger.error('Failed to register cache:', error);
855
- throw error;
856
- }
857
- });
858
- _define_property(this, "getCache", (kts)=>{
859
- logger.debug('Attempting to get cache for key types:', kts);
860
- const key = JSON.stringify(kts);
861
- logger.debug('Looking up cache with key:', key);
862
- const cache = this.cacheMap[key];
863
- if (!cache) {
864
- logger.warning(`No cache found for key types: ${key}`);
865
- }
866
- return cache;
867
- });
868
- _define_property(this, "printRegisteredCaches", ()=>{
869
- logger.debug('Printing all registered caches:');
870
- const cacheCount = Object.keys(this.cacheMap).length;
871
- logger.debug(`Total number of registered caches: ${cacheCount}`);
872
- if (cacheCount === 0) {
873
- logger.debug('No caches are currently registered');
874
- }
875
- Object.entries(this.cacheMap).forEach(([keyTypes])=>{
876
- logger.debug(`Cache with key types: ${keyTypes}`);
877
- });
827
+ const logger$2 = LibLogger.get("Instance");
828
+ const createInstance = (registry$1, coordinate, cache)=>{
829
+ logger$2.debug("createInstance", {
830
+ coordinate,
831
+ cache,
832
+ registry: registry$1
833
+ });
834
+ const baseInstance = registry.createInstance(registry$1, coordinate);
835
+ return {
836
+ ...baseInstance,
837
+ cache
838
+ };
839
+ };
840
+ const isInstance = (instance)=>{
841
+ return instance !== null && instance !== undefined && instance.coordinate !== undefined && instance.cache !== undefined && instance.registry !== undefined;
842
+ };
843
+
844
+ const logger$1 = LibLogger.get("InstanceFactory");
845
+ /**
846
+ * Factory function for creating cache instances
847
+ */ const createInstanceFactory = (cache)=>{
848
+ return (coordinate, context)=>{
849
+ logger$1.debug("Creating cache instance", {
850
+ coordinate,
851
+ registry: context.registry,
852
+ cache
853
+ });
854
+ return createInstance(context.registry, coordinate, cache);
855
+ };
856
+ };
857
+
858
+ const logger = LibLogger.get("Registry");
859
+ /**
860
+ * Factory function for creating cache registries
861
+ */ const createRegistryFactory = ()=>{
862
+ return (type, registryHub)=>{
863
+ if (type !== 'cache') {
864
+ throw new Error(`Cache registry factory can only create 'cache' type registries, got: ${type}`);
865
+ }
866
+ logger.debug("Creating cache registry", {
867
+ type,
868
+ registryHub
878
869
  });
879
- logger.debug('CacheRegistry instance created');
880
- }
881
- }
882
- _define_property(CacheRegistry, "instance", void 0);
870
+ const baseRegistry = registry.createRegistry(type, registryHub);
871
+ // Cast to Registry for type safety
872
+ return baseRegistry;
873
+ };
874
+ };
875
+ /**
876
+ * Creates a new cache registry instance
877
+ */ const createRegistry = (registryHub)=>{
878
+ const baseRegistry = registry.createRegistry('cache', registryHub);
879
+ return {
880
+ ...baseRegistry
881
+ };
882
+ };
883
883
 
884
884
  exports.CacheMap = CacheMap;
885
- exports.CacheRegistry = CacheRegistry;
886
885
  exports.createAggregator = createAggregator;
887
886
  exports.createCache = createCache;
887
+ exports.createInstance = createInstance;
888
+ exports.createInstanceFactory = createInstanceFactory;
889
+ exports.createRegistry = createRegistry;
890
+ exports.createRegistryFactory = createRegistryFactory;
891
+ exports.isInstance = isInstance;
888
892
  exports.toCacheConfig = toCacheConfig;
889
893
  //# sourceMappingURL=index.cjs.map
package/dist/index.cjs.js CHANGED
@@ -5,7 +5,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
5
  const Aggregator = require('./Aggregator.cjs.js');
6
6
  const Cache = require('./Cache.cjs.js');
7
7
  const CacheMap = require('./CacheMap.cjs.js');
8
- const CacheRegistry = require('./CacheRegistry.cjs.js');
8
+ const Instance = require('./Instance.cjs.js');
9
+ const InstanceFactory = require('./InstanceFactory.cjs.js');
10
+ const Registry = require('./Registry.cjs.js');
9
11
 
10
12
 
11
13
 
@@ -13,5 +15,9 @@ exports.createAggregator = Aggregator.createAggregator;
13
15
  exports.toCacheConfig = Aggregator.toCacheConfig;
14
16
  exports.createCache = Cache.createCache;
15
17
  exports.CacheMap = CacheMap.CacheMap;
16
- exports.CacheRegistry = CacheRegistry.CacheRegistry;
17
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguY2pzLmpzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7OyJ9
18
+ exports.createInstance = Instance.createInstance;
19
+ exports.isInstance = Instance.isInstance;
20
+ exports.createInstanceFactory = InstanceFactory.createInstanceFactory;
21
+ exports.createRegistry = Registry.createRegistry;
22
+ exports.createRegistryFactory = Registry.createRegistryFactory;
23
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguY2pzLmpzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export * from './Aggregator';
2
2
  export * from './Cache';
3
3
  export * from './CacheMap';
4
- export * from './CacheRegistry';
4
+ export * from './Instance';
5
+ export * from './InstanceFactory';
6
+ export * from './Registry';
package/dist/index.es.js CHANGED
@@ -1,5 +1,7 @@
1
1
  export { createAggregator, toCacheConfig } from './Aggregator.es.js';
2
2
  export { createCache } from './Cache.es.js';
3
3
  export { CacheMap } from './CacheMap.es.js';
4
- export { CacheRegistry } from './CacheRegistry.es.js';
5
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZXMuanMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7In0=
4
+ export { createInstance, isInstance } from './Instance.es.js';
5
+ export { createInstanceFactory } from './InstanceFactory.es.js';
6
+ export { createRegistry, createRegistryFactory } from './Registry.es.js';
7
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZXMuanMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OzsifQ==