@fjell/cache 4.6.10 → 4.6.11

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 (69) hide show
  1. package/dist/Aggregator.cjs.js +26 -20
  2. package/dist/Aggregator.d.ts +17 -1
  3. package/dist/Aggregator.es.js +26 -20
  4. package/dist/Cache.cjs.js +22 -345
  5. package/dist/Cache.d.ts +25 -20
  6. package/dist/Cache.es.js +22 -346
  7. package/dist/Instance.cjs.js +7 -11
  8. package/dist/Instance.d.ts +5 -8
  9. package/dist/Instance.es.js +6 -10
  10. package/dist/InstanceFactory.cjs.js +17 -5
  11. package/dist/InstanceFactory.d.ts +3 -3
  12. package/dist/InstanceFactory.es.js +17 -5
  13. package/dist/Operations.cjs.js +43 -0
  14. package/dist/Operations.d.ts +70 -0
  15. package/dist/Operations.es.js +39 -0
  16. package/dist/index.cjs +416 -369
  17. package/dist/index.cjs.js +4 -1
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.ts +1 -0
  20. package/dist/index.es.js +3 -2
  21. package/dist/ops/action.cjs.js +28 -0
  22. package/dist/ops/action.d.ts +4 -0
  23. package/dist/ops/action.es.js +24 -0
  24. package/dist/ops/all.cjs.js +33 -0
  25. package/dist/ops/all.d.ts +4 -0
  26. package/dist/ops/all.es.js +29 -0
  27. package/dist/ops/allAction.cjs.js +35 -0
  28. package/dist/ops/allAction.d.ts +4 -0
  29. package/dist/ops/allAction.es.js +31 -0
  30. package/dist/ops/allFacet.cjs.js +22 -0
  31. package/dist/ops/allFacet.d.ts +4 -0
  32. package/dist/ops/allFacet.es.js +18 -0
  33. package/dist/ops/create.cjs.js +23 -0
  34. package/dist/ops/create.d.ts +4 -0
  35. package/dist/ops/create.es.js +19 -0
  36. package/dist/ops/facet.cjs.js +21 -0
  37. package/dist/ops/facet.d.ts +4 -0
  38. package/dist/ops/facet.es.js +17 -0
  39. package/dist/ops/find.cjs.js +26 -0
  40. package/dist/ops/find.d.ts +4 -0
  41. package/dist/ops/find.es.js +22 -0
  42. package/dist/ops/findOne.cjs.js +24 -0
  43. package/dist/ops/findOne.d.ts +4 -0
  44. package/dist/ops/findOne.es.js +20 -0
  45. package/dist/ops/get.cjs.js +38 -0
  46. package/dist/ops/get.d.ts +4 -0
  47. package/dist/ops/get.es.js +34 -0
  48. package/dist/ops/one.cjs.js +33 -0
  49. package/dist/ops/one.d.ts +4 -0
  50. package/dist/ops/one.es.js +29 -0
  51. package/dist/ops/remove.cjs.js +30 -0
  52. package/dist/ops/remove.d.ts +4 -0
  53. package/dist/ops/remove.es.js +26 -0
  54. package/dist/ops/reset.cjs.js +15 -0
  55. package/dist/ops/reset.d.ts +4 -0
  56. package/dist/ops/reset.es.js +11 -0
  57. package/dist/ops/retrieve.cjs.js +37 -0
  58. package/dist/ops/retrieve.d.ts +4 -0
  59. package/dist/ops/retrieve.es.js +33 -0
  60. package/dist/ops/set.cjs.js +71 -0
  61. package/dist/ops/set.d.ts +3 -0
  62. package/dist/ops/set.es.js +67 -0
  63. package/dist/ops/update.cjs.js +34 -0
  64. package/dist/ops/update.d.ts +4 -0
  65. package/dist/ops/update.es.js +30 -0
  66. package/examples/README.md +34 -39
  67. package/examples/aggregator-example.ts +8 -14
  68. package/examples/basic-cache-example.ts +18 -21
  69. package/package.json +2 -2
@@ -146,12 +146,9 @@ export const runBasicCacheExample = async (): Promise<void> => {
146
146
  const taskApi = createTaskApi() as ClientApi<Task, 'task'>;
147
147
  console.log('✅ Created mock APIs for users and tasks');
148
148
 
149
- const userCache = await createCache(userApi, 'user');
150
- const taskCache = await createCache(taskApi, 'task');
151
- console.log('✅ Created cache instances');
152
-
153
- const userInstance = createInstance(registry, createCoordinate('user'), userCache);
154
- const taskInstance = createInstance(registry, createCoordinate('task'), taskCache);
149
+ const userCache = await createCache(userApi, createCoordinate('user'), registry);
150
+ const taskCache = await createCache(taskApi, createCoordinate('task'), registry);
151
+ console.log('✅ Created cache instances (which are now also instances)');
155
152
  console.log('✅ Created cache model instances\n');
156
153
 
157
154
  // Step 2: Create some test data
@@ -170,21 +167,21 @@ export const runBasicCacheExample = async (): Promise<void> => {
170
167
  console.log('Step 3: Cache operations - Fetching all items');
171
168
  console.log('----------------------------------------------');
172
169
 
173
- const [, allUsers] = await userInstance.cache.all();
174
- console.log(`📋 Cached ${allUsers.length} users:`, allUsers.map(u => u.name));
170
+ const [, allUsers] = await userCache.operations.all();
171
+ console.log(`📋 Cached ${allUsers.length} users:`, allUsers.map((u: User) => u.name));
175
172
 
176
- const [, allTasks] = await taskInstance.cache.all();
177
- console.log(`📋 Cached ${allTasks.length} tasks:`, allTasks.map(t => t.title));
173
+ const [, allTasks] = await taskCache.operations.all();
174
+ console.log(`📋 Cached ${allTasks.length} tasks:`, allTasks.map((t: Task) => t.title));
178
175
  console.log('');
179
176
 
180
177
  // Step 4: Individual item retrieval from cache
181
178
  console.log('Step 4: Individual item retrieval');
182
179
  console.log('---------------------------------');
183
180
 
184
- const [, cachedUser1] = await userInstance.cache.get(user1.key);
181
+ const [, cachedUser1] = await userCache.operations.get(user1.key);
185
182
  console.log(`👤 Retrieved from cache: ${cachedUser1?.name} (${cachedUser1?.email})`);
186
183
 
187
- const [, cachedTask1] = await taskInstance.cache.get(task1.key);
184
+ const [, cachedTask1] = await taskCache.operations.get(task1.key);
188
185
  console.log(`📝 Retrieved from cache: ${cachedTask1?.title} - Status: ${cachedTask1?.status}`);
189
186
  console.log('');
190
187
 
@@ -194,14 +191,14 @@ export const runBasicCacheExample = async (): Promise<void> => {
194
191
 
195
192
  // This should hit the cache (no API call)
196
193
  console.log('🎯 Second retrieval (should hit cache):');
197
- const [, cachedUser1Again] = await userInstance.cache.retrieve(user1.key);
194
+ const [, cachedUser1Again] = await userCache.operations.retrieve(user1.key);
198
195
  console.log(`👤 Retrieved: ${cachedUser1Again?.name} (cache hit)`);
199
196
 
200
197
  // Create a new user and demonstrate cache miss
201
198
  const user3 = createTestUser('user-3', 'Charlie Brown', 'charlie@example.com', 'guest');
202
199
 
203
200
  console.log('🎯 New item retrieval (cache miss, will fetch from API):');
204
- const [, cachedUser3] = await userInstance.cache.get(user3.key);
201
+ const [, cachedUser3] = await userCache.operations.get(user3.key);
205
202
  console.log(`👤 Retrieved: ${cachedUser3?.name} (fetched from API and cached)`);
206
203
  console.log('');
207
204
 
@@ -213,7 +210,7 @@ export const runBasicCacheExample = async (): Promise<void> => {
213
210
  mockTaskStorage.set(task2.id, updatedTask2);
214
211
 
215
212
  // Update cache with new version
216
- await taskInstance.cache.set(updatedTask2.key, updatedTask2);
213
+ await taskCache.operations.set(updatedTask2.key, updatedTask2);
217
214
  console.log(`🔄 Updated task in cache: ${updatedTask2.title} - New status: ${updatedTask2.status}`);
218
215
  console.log('');
219
216
 
@@ -221,10 +218,10 @@ export const runBasicCacheExample = async (): Promise<void> => {
221
218
  console.log('Step 7: Query operations');
222
219
  console.log('-----------------------');
223
220
 
224
- const [, foundTasks] = await taskInstance.cache.find('all');
221
+ const [, foundTasks] = await taskCache.operations.find('all');
225
222
  console.log(`🔍 Found ${foundTasks.length} tasks through cache query`);
226
223
 
227
- const [, oneTask] = await taskInstance.cache.one();
224
+ const [, oneTask] = await taskCache.operations.one();
228
225
  console.log(`📝 Retrieved one task: ${oneTask?.title}`);
229
226
  console.log('');
230
227
 
@@ -235,8 +232,8 @@ export const runBasicCacheExample = async (): Promise<void> => {
235
232
  console.log('📊 Cache Statistics:');
236
233
  console.log(` 👥 Users in cache: ${allUsers.length}`);
237
234
  console.log(` 📝 Tasks in cache: ${allTasks.length}`);
238
- console.log(` 🎯 User cache coordinate: ${userInstance.coordinate.kta[0]}`);
239
- console.log(` 🎯 Task cache coordinate: ${taskInstance.coordinate.kta[0]}`);
235
+ console.log(` 🎯 User cache coordinate: ${userCache.coordinate.kta[0]}`);
236
+ console.log(` 🎯 Task cache coordinate: ${taskCache.coordinate.kta[0]}`);
240
237
  console.log('');
241
238
 
242
239
  // Step 9: Cleanup demonstration
@@ -247,11 +244,11 @@ export const runBasicCacheExample = async (): Promise<void> => {
247
244
  console.log('🗑️ Removed user from storage');
248
245
 
249
246
  // Cache still has the old data until next fetch
250
- const [, stillCachedUser3] = await userInstance.cache.retrieve(user3.key);
247
+ const [, stillCachedUser3] = await userCache.operations.retrieve(user3.key);
251
248
  console.log(`🎯 Cache still contains removed user: ${stillCachedUser3?.name || 'null'}`);
252
249
 
253
250
  // Fresh fetch will update cache
254
- const [, freshAllUsers] = await userInstance.cache.all();
251
+ const [, freshAllUsers] = await userCache.operations.all();
255
252
  console.log(`📋 Fresh fetch shows ${freshAllUsers.length} users (cache updated)`);
256
253
  console.log('');
257
254
 
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.10",
4
+ "version": "4.6.11",
5
5
  "keywords": [
6
6
  "cache",
7
7
  "fjell"
@@ -23,7 +23,7 @@
23
23
  "@fjell/core": "^4.4.7",
24
24
  "@fjell/http-api": "^4.4.5",
25
25
  "@fjell/logging": "^4.4.7",
26
- "@fjell/registry": "^4.4.7"
26
+ "@fjell/registry": "^4.4.11"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@eslint/eslintrc": "^3.3.1",