@2112-lab/central-plant 0.2.12 → 0.3.0

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.d.ts CHANGED
@@ -184,3 +184,122 @@ export * as Numerics from './data/numerics.js';
184
184
  // Analysis utilities
185
185
  export * as Analysis from './analysis/analysis.js';
186
186
  export * as Testing from './analysis/testing.js';
187
+
188
+ // ─── Cache management ─────────────────────────────────────────────────────────
189
+
190
+ export interface CacheExpiryConfig {
191
+ MODELS: number
192
+ TEXTURES: number
193
+ JSON: number
194
+ COMPONENT_DICTIONARY: number
195
+ SCENE_DATA: number
196
+ THUMBNAILS: number
197
+ SKYBOXES: number
198
+ USER_CONTENT: number
199
+ TEMPORARY: number
200
+ DEFAULT: number
201
+ }
202
+
203
+ export declare const CACHE_EXPIRY: CacheExpiryConfig
204
+ export declare const CACHE_NAME_PREFIX: string
205
+ export declare const GLOBAL_CACHE_NAME: string
206
+
207
+ export interface CacheStatsItem {
208
+ url: string
209
+ sourceKey?: string
210
+ s3Key?: string
211
+ size: number
212
+ sizeMB: string
213
+ type: string
214
+ cachedTime: number
215
+ age: number
216
+ isLocal?: boolean
217
+ }
218
+
219
+ export interface CacheStatsResult {
220
+ count: number
221
+ totalSize: number
222
+ totalSizeMB: string
223
+ items: CacheStatsItem[]
224
+ }
225
+
226
+ export interface CacheGlobalStats {
227
+ hits: number
228
+ misses: number
229
+ errors: number
230
+ totalBytesServed: number
231
+ totalBytesCached: number
232
+ startTime: number
233
+ hitRate: string
234
+ totalMBServed: string
235
+ totalMBCached: string
236
+ uptimeMinutes: string
237
+ }
238
+
239
+ export declare class CacheManager {
240
+ stats: { hits: number; misses: number; errors: number; totalBytesServed: number; totalBytesCached: number; startTime: number }
241
+ configure(options: { getUser?: () => Promise<any>; onError?: (error: Error) => void }): void
242
+ getExpiryForPath(path: string, assetType?: string | null): number
243
+ resetIdentity(): void
244
+ getCacheName(): Promise<string>
245
+ execute(options: { cacheKey: string; sourceKey?: string; expiryMs: number; fetcher: () => Promise<any>; processor: (response: any) => Promise<any>; metadata?: Record<string, string>; logType?: string }): Promise<any>
246
+ getGlobalStats(): CacheGlobalStats
247
+ resetStats(): void
248
+ clearCache(specificKey?: string | null, clearAllUsers?: boolean): Promise<boolean>
249
+ cleanExpired(): Promise<number>
250
+ cleanInvalid(): Promise<number>
251
+ has(cacheKey: string, expiryMs?: number | null): Promise<boolean>
252
+ get(cacheKey: string, expiryMs?: number | null, processor?: (response: Response) => Promise<any>): Promise<any>
253
+ delete(cacheKey: string): Promise<boolean>
254
+ deleteCache(cacheName: string): Promise<boolean>
255
+ getDetailedStats(allUsers?: boolean): Promise<CacheStatsResult | { caches: any[]; totalCaches: number; grandTotalSizeMB: string }>
256
+ }
257
+
258
+ export declare const cacheManager: CacheManager
259
+
260
+ export declare function resetCacheIdentity(): void
261
+ export declare function getGlobalCacheStats(): CacheGlobalStats
262
+ export declare function resetGlobalCacheStats(): void
263
+ export declare function getCurrentCacheName(): Promise<string>
264
+ export declare function cleanExpiredCache(): Promise<number>
265
+ export declare function cleanInvalidCacheEntries(): Promise<number>
266
+ export declare function getCacheStats(allUsers?: boolean): Promise<CacheStatsResult>
267
+ export declare function getUserOnlyCacheStats(allUsers?: boolean): Promise<CacheStatsResult>
268
+ export declare function getGlobalOnlyCacheStats(): Promise<CacheStatsResult>
269
+ export declare function clearS3Cache(specificKey?: string | null, clearAllUsers?: boolean): Promise<boolean>
270
+ export declare function getAllCacheKeys(): Promise<Set<string>>
271
+ export declare function switchCachePartition(isAuthenticated: boolean): Promise<{ oldCacheName: string; newCacheName: string; deletedPartition: string | null; deleted: boolean } | { error: string }>
272
+
273
+ export declare function getCachedS3Object(s3Key: string, storageOptions?: Record<string, any>, expiryMs?: number | null): Promise<Blob>
274
+ export declare function getCachedS3ObjectURL(s3Key: string, storageOptions?: Record<string, any>, expiryMs?: number | null): Promise<string>
275
+ export declare function preloadS3Objects(s3Keys: string[], storageOptions?: Record<string, any>): Promise<{ success: number; failed: number; errors: Array<{ key: string; error: string }> }>
276
+ export declare function getCachedS3Json(s3Key: string, storageOptions?: Record<string, any>, expiryMs?: number | null): Promise<any>
277
+ export declare function getCachedLocalJson(localPath: string, expiryMs?: number | null): Promise<any>
278
+ export declare function getCachedLocalFile(url: string, expiryMs?: number | null): Promise<Blob>
279
+ export declare function getCachedLocalFileURL(url: string, expiryMs?: number | null): Promise<string>
280
+ export declare function preloadLocalFiles(urls: string[]): Promise<{ success: number; failed: number; errors: Array<{ url: string; error: string }> }>
281
+
282
+ export declare function cacheJsonData(key: string, data: any, expiryMs?: number): Promise<boolean>
283
+ export declare function getCachedJsonData(key: string, expiryMs?: number): Promise<any>
284
+ export declare function removeCachedJsonData(key: string): Promise<boolean>
285
+
286
+ export declare function getThumbnailKey(asset: { thumbnailS3Path?: string; s3Path?: string; uuid?: string; id?: string }): string | null
287
+ export declare function isThumbnailCached(asset: { isS3Component?: boolean; source?: string; scope?: string; thumbnailS3Path?: string; s3Path?: string; uuid?: string; id?: string }): Promise<boolean>
288
+ export declare function isCached(s3Key: string, expiryMs?: number | null): Promise<boolean>
289
+ export declare function getCacheExpiryForPath(path: string, assetType?: string | null): number
290
+ export declare function formatCacheExpiry(ms: number): string
291
+
292
+ export declare class S3MetadataCacheService {
293
+ getAll(): Promise<any[]>
294
+ getMetadata(): Promise<{ version: number; components: any[]; timestamp: number }>
295
+ addComponent(component: { id?: string; uuid?: string; [key: string]: any }): Promise<boolean>
296
+ removeComponent(identifier: string): Promise<boolean>
297
+ clear(): Promise<boolean>
298
+ hasComponent(identifier: string): Promise<boolean>
299
+ refresh(): Promise<any[]>
300
+ setAll(components: any[]): Promise<boolean>
301
+ }
302
+
303
+ export declare const s3MetadataCache: S3MetadataCacheService
304
+
305
+ export declare function measureS3Transfer(operation: string, asyncFn: () => Promise<any>, fileSize?: number | null): Promise<any>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@2112-lab/central-plant",
3
- "version": "0.2.12",
3
+ "version": "0.3.0",
4
4
  "description": "Utility modules for the Central Plant Application",
5
5
  "main": "dist/bundle/index.js",
6
6
  "module": "dist/esm/src/index.js",
@@ -32,6 +32,7 @@
32
32
  "license": "MIT",
33
33
  "dependencies": {
34
34
  "@2112-lab/pathfinder": "^1.0.38",
35
+ "aws-amplify": "^5.3.33",
35
36
  "stats.js": "^0.17.0",
36
37
  "three": "^0.177.0"
37
38
  },