@nexushub/client 1.1.6 → 1.1.8

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.cts CHANGED
@@ -1,5 +1,69 @@
1
1
  import { I as ILocalCache } from './cache-types-B39iNHfE.cjs';
2
2
 
3
+ /**
4
+ * NexusHub Shared Cache Implementations
5
+ *
6
+ * Contains MemoryCache (LRU) and BrowserCache (LocalStorage)
7
+ * which are safe for universal usage.
8
+ */
9
+ interface CacheOptions {
10
+ maxSize?: number;
11
+ ttl?: number;
12
+ /** false means platform-controlled immutable cache. */
13
+ revalidate?: number | false;
14
+ tags?: string[];
15
+ }
16
+ interface CacheStats {
17
+ size: number;
18
+ hits: number;
19
+ misses: number;
20
+ hitRate: number;
21
+ evictions: number;
22
+ }
23
+ declare const CacheTags: {
24
+ project: (projectId: string) => string;
25
+ content: (slug: string) => string;
26
+ collection: (collectionId: string) => string;
27
+ global: string;
28
+ user: (userId: string) => string;
29
+ media: (mediaId: string) => string;
30
+ };
31
+ declare class MemoryCache {
32
+ private cache;
33
+ private tagIndex;
34
+ private stats;
35
+ private maxSize;
36
+ private defaultTTL;
37
+ constructor(options?: CacheOptions);
38
+ set<T = any>(key: string, data: T, options?: CacheOptions): void;
39
+ get<T = any>(key: string): {
40
+ data: T;
41
+ metadata: any;
42
+ } | null;
43
+ delete(key: string): boolean;
44
+ invalidateByTags(tags: string[]): void;
45
+ clear(): void;
46
+ getStats(): CacheStats;
47
+ private evictLRU;
48
+ private calculateSize;
49
+ private updateHitRate;
50
+ }
51
+ declare class BrowserCache {
52
+ private projectId;
53
+ private prefix;
54
+ private maxSize;
55
+ private currentSize;
56
+ constructor(projectId: string);
57
+ set<T = any>(key: string, data: T, ttl?: number): void;
58
+ get<T = any>(key: string): T | null;
59
+ delete(key: string): void;
60
+ clear(): void;
61
+ private getStorageKey;
62
+ private calculateCurrentSize;
63
+ private calculateStorageSize;
64
+ private evictOldest;
65
+ }
66
+
3
67
  interface MinimalNexusConfig {
4
68
  apiUrl?: string;
5
69
  analyticsUrl?: string;
@@ -122,14 +186,9 @@ declare class ContentEngine {
122
186
  private circuitBreaker;
123
187
  private defaultRevalidate;
124
188
  private cacheStrategy;
125
- private abortController?;
126
189
  private isServer;
127
190
  constructor(config: NexusConfig);
128
- /** Update runtime configuration without exposing internal mutation. */
129
191
  updateConfig(config: NexusConfig): void;
130
- /**
131
- * Fetch a Single Page with full strategy pipeline
132
- */
133
192
  getPage<T = any>(slug: string, options?: {
134
193
  revalidate?: number | false;
135
194
  tags?: string[];
@@ -137,67 +196,41 @@ declare class ContentEngine {
137
196
  includeMetadata?: boolean;
138
197
  }): Promise<T>;
139
198
  private _getPage;
140
- /**
141
- * Fetch a Collection (Optimized)
142
- */
143
199
  getCollection<T = any>(collectionId: string, query?: CollectionQuery, options?: {
144
200
  revalidate?: number | false;
145
201
  tags?: string[];
146
202
  forceRefresh?: boolean;
147
203
  includeMetadata?: boolean;
148
204
  }): Promise<CollectionResponse<T>>;
149
- private _getCollection;
150
- /**
151
- * Fetch Global Settings
152
- */
153
205
  getGlobals<T = any>(options?: {
154
206
  include?: string[];
155
207
  revalidate?: number | false;
156
208
  forceRefresh?: boolean;
157
209
  tags?: string[];
158
210
  }): Promise<T>;
159
- /**
160
- * Get a single item from a collection (Uses Request Batching)
161
- */
162
211
  getItem<T = any>(collectionId: string, itemId: string, options?: {
163
212
  revalidate?: number | false;
164
213
  tags?: string[];
165
214
  include?: string[];
215
+ forceRefresh?: boolean;
166
216
  }): Promise<T>;
167
- /**
168
- * Search across collections
169
- */
170
217
  search<T = any>(query: string, options?: {
171
218
  collections?: string[];
172
219
  fields?: string[];
173
220
  limit?: number;
174
221
  revalidate?: number | false;
222
+ forceRefresh?: boolean;
175
223
  }): Promise<{
176
224
  results: T[];
177
225
  total: number;
178
226
  }>;
179
- /**
180
- * Prefetch content
181
- */
182
227
  prefetch(urls: string[]): Promise<void>;
183
- /**
184
- * Robust Real-time Subscriptions (SSE) with Auto-Reconnect
185
- */
186
228
  subscribeToUpdates(callback: (data: any) => void): () => void;
187
- private checkCaches;
188
229
  private writeCache;
189
230
  invalidateCache(tags: string[]): void;
190
231
  clearCache(): void;
191
232
  getCacheStats(): {
192
- memory: {
193
- size: number;
194
- hits: number;
195
- misses: number;
196
- hitRate: number;
197
- };
198
- browser: {
199
- size: number;
200
- } | null;
233
+ memory: CacheStats;
201
234
  local: {
202
235
  loaded: boolean;
203
236
  };
@@ -208,12 +241,7 @@ declare class ContentEngine {
208
241
  private fetchWithTimeout;
209
242
  private getHeaders;
210
243
  private isCacheValid;
211
- /**
212
- * 🛡️ FIX: Normalizes timeout errors (AbortError, 408, or Timeout messages)
213
- * into clean, standardized "Request timeout" errors.
214
- */
215
244
  private normalizeError;
216
- cancelRequests(): void;
217
245
  cleanup(): void;
218
246
  }
219
247
 
@@ -384,15 +412,7 @@ declare class NexusClient {
384
412
  */
385
413
  diagnostics(): {
386
414
  cache: {
387
- memory: {
388
- size: number;
389
- hits: number;
390
- misses: number;
391
- hitRate: number;
392
- };
393
- browser: {
394
- size: number;
395
- } | null;
415
+ memory: CacheStats;
396
416
  local: {
397
417
  loaded: boolean;
398
418
  };
@@ -485,70 +505,6 @@ interface AuthContextType extends AuthState {
485
505
  requestPasswordReset: (email: string) => Promise<void>;
486
506
  }
487
507
 
488
- /**
489
- * NexusHub Shared Cache Implementations
490
- *
491
- * Contains MemoryCache (LRU) and BrowserCache (LocalStorage)
492
- * which are safe for universal usage.
493
- */
494
- interface CacheOptions {
495
- maxSize?: number;
496
- ttl?: number;
497
- /** false means platform-controlled immutable cache. */
498
- revalidate?: number | false;
499
- tags?: string[];
500
- }
501
- interface CacheStats {
502
- size: number;
503
- hits: number;
504
- misses: number;
505
- hitRate: number;
506
- evictions: number;
507
- }
508
- declare const CacheTags: {
509
- project: (projectId: string) => string;
510
- content: (slug: string) => string;
511
- collection: (collectionId: string) => string;
512
- global: string;
513
- user: (userId: string) => string;
514
- media: (mediaId: string) => string;
515
- };
516
- declare class MemoryCache {
517
- private cache;
518
- private tagIndex;
519
- private stats;
520
- private maxSize;
521
- private defaultTTL;
522
- constructor(options?: CacheOptions);
523
- set<T = any>(key: string, data: T, options?: CacheOptions): void;
524
- get<T = any>(key: string): {
525
- data: T;
526
- metadata: any;
527
- } | null;
528
- delete(key: string): boolean;
529
- invalidateByTags(tags: string[]): void;
530
- clear(): void;
531
- getStats(): CacheStats;
532
- private evictLRU;
533
- private calculateSize;
534
- private updateHitRate;
535
- }
536
- declare class BrowserCache {
537
- private projectId;
538
- private prefix;
539
- private maxSize;
540
- private currentSize;
541
- constructor(projectId: string);
542
- set<T = any>(key: string, data: T, ttl?: number): void;
543
- get<T = any>(key: string): T | null;
544
- delete(key: string): void;
545
- clear(): void;
546
- private getStorageKey;
547
- private calculateCurrentSize;
548
- private calculateStorageSize;
549
- private evictOldest;
550
- }
551
-
552
508
  declare class LocalCacheProxy implements ILocalCache {
553
509
  private instance;
554
510
  private cachePath?;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,69 @@
1
1
  import { I as ILocalCache } from './cache-types-B39iNHfE.js';
2
2
 
3
+ /**
4
+ * NexusHub Shared Cache Implementations
5
+ *
6
+ * Contains MemoryCache (LRU) and BrowserCache (LocalStorage)
7
+ * which are safe for universal usage.
8
+ */
9
+ interface CacheOptions {
10
+ maxSize?: number;
11
+ ttl?: number;
12
+ /** false means platform-controlled immutable cache. */
13
+ revalidate?: number | false;
14
+ tags?: string[];
15
+ }
16
+ interface CacheStats {
17
+ size: number;
18
+ hits: number;
19
+ misses: number;
20
+ hitRate: number;
21
+ evictions: number;
22
+ }
23
+ declare const CacheTags: {
24
+ project: (projectId: string) => string;
25
+ content: (slug: string) => string;
26
+ collection: (collectionId: string) => string;
27
+ global: string;
28
+ user: (userId: string) => string;
29
+ media: (mediaId: string) => string;
30
+ };
31
+ declare class MemoryCache {
32
+ private cache;
33
+ private tagIndex;
34
+ private stats;
35
+ private maxSize;
36
+ private defaultTTL;
37
+ constructor(options?: CacheOptions);
38
+ set<T = any>(key: string, data: T, options?: CacheOptions): void;
39
+ get<T = any>(key: string): {
40
+ data: T;
41
+ metadata: any;
42
+ } | null;
43
+ delete(key: string): boolean;
44
+ invalidateByTags(tags: string[]): void;
45
+ clear(): void;
46
+ getStats(): CacheStats;
47
+ private evictLRU;
48
+ private calculateSize;
49
+ private updateHitRate;
50
+ }
51
+ declare class BrowserCache {
52
+ private projectId;
53
+ private prefix;
54
+ private maxSize;
55
+ private currentSize;
56
+ constructor(projectId: string);
57
+ set<T = any>(key: string, data: T, ttl?: number): void;
58
+ get<T = any>(key: string): T | null;
59
+ delete(key: string): void;
60
+ clear(): void;
61
+ private getStorageKey;
62
+ private calculateCurrentSize;
63
+ private calculateStorageSize;
64
+ private evictOldest;
65
+ }
66
+
3
67
  interface MinimalNexusConfig {
4
68
  apiUrl?: string;
5
69
  analyticsUrl?: string;
@@ -122,14 +186,9 @@ declare class ContentEngine {
122
186
  private circuitBreaker;
123
187
  private defaultRevalidate;
124
188
  private cacheStrategy;
125
- private abortController?;
126
189
  private isServer;
127
190
  constructor(config: NexusConfig);
128
- /** Update runtime configuration without exposing internal mutation. */
129
191
  updateConfig(config: NexusConfig): void;
130
- /**
131
- * Fetch a Single Page with full strategy pipeline
132
- */
133
192
  getPage<T = any>(slug: string, options?: {
134
193
  revalidate?: number | false;
135
194
  tags?: string[];
@@ -137,67 +196,41 @@ declare class ContentEngine {
137
196
  includeMetadata?: boolean;
138
197
  }): Promise<T>;
139
198
  private _getPage;
140
- /**
141
- * Fetch a Collection (Optimized)
142
- */
143
199
  getCollection<T = any>(collectionId: string, query?: CollectionQuery, options?: {
144
200
  revalidate?: number | false;
145
201
  tags?: string[];
146
202
  forceRefresh?: boolean;
147
203
  includeMetadata?: boolean;
148
204
  }): Promise<CollectionResponse<T>>;
149
- private _getCollection;
150
- /**
151
- * Fetch Global Settings
152
- */
153
205
  getGlobals<T = any>(options?: {
154
206
  include?: string[];
155
207
  revalidate?: number | false;
156
208
  forceRefresh?: boolean;
157
209
  tags?: string[];
158
210
  }): Promise<T>;
159
- /**
160
- * Get a single item from a collection (Uses Request Batching)
161
- */
162
211
  getItem<T = any>(collectionId: string, itemId: string, options?: {
163
212
  revalidate?: number | false;
164
213
  tags?: string[];
165
214
  include?: string[];
215
+ forceRefresh?: boolean;
166
216
  }): Promise<T>;
167
- /**
168
- * Search across collections
169
- */
170
217
  search<T = any>(query: string, options?: {
171
218
  collections?: string[];
172
219
  fields?: string[];
173
220
  limit?: number;
174
221
  revalidate?: number | false;
222
+ forceRefresh?: boolean;
175
223
  }): Promise<{
176
224
  results: T[];
177
225
  total: number;
178
226
  }>;
179
- /**
180
- * Prefetch content
181
- */
182
227
  prefetch(urls: string[]): Promise<void>;
183
- /**
184
- * Robust Real-time Subscriptions (SSE) with Auto-Reconnect
185
- */
186
228
  subscribeToUpdates(callback: (data: any) => void): () => void;
187
- private checkCaches;
188
229
  private writeCache;
189
230
  invalidateCache(tags: string[]): void;
190
231
  clearCache(): void;
191
232
  getCacheStats(): {
192
- memory: {
193
- size: number;
194
- hits: number;
195
- misses: number;
196
- hitRate: number;
197
- };
198
- browser: {
199
- size: number;
200
- } | null;
233
+ memory: CacheStats;
201
234
  local: {
202
235
  loaded: boolean;
203
236
  };
@@ -208,12 +241,7 @@ declare class ContentEngine {
208
241
  private fetchWithTimeout;
209
242
  private getHeaders;
210
243
  private isCacheValid;
211
- /**
212
- * 🛡️ FIX: Normalizes timeout errors (AbortError, 408, or Timeout messages)
213
- * into clean, standardized "Request timeout" errors.
214
- */
215
244
  private normalizeError;
216
- cancelRequests(): void;
217
245
  cleanup(): void;
218
246
  }
219
247
 
@@ -384,15 +412,7 @@ declare class NexusClient {
384
412
  */
385
413
  diagnostics(): {
386
414
  cache: {
387
- memory: {
388
- size: number;
389
- hits: number;
390
- misses: number;
391
- hitRate: number;
392
- };
393
- browser: {
394
- size: number;
395
- } | null;
415
+ memory: CacheStats;
396
416
  local: {
397
417
  loaded: boolean;
398
418
  };
@@ -485,70 +505,6 @@ interface AuthContextType extends AuthState {
485
505
  requestPasswordReset: (email: string) => Promise<void>;
486
506
  }
487
507
 
488
- /**
489
- * NexusHub Shared Cache Implementations
490
- *
491
- * Contains MemoryCache (LRU) and BrowserCache (LocalStorage)
492
- * which are safe for universal usage.
493
- */
494
- interface CacheOptions {
495
- maxSize?: number;
496
- ttl?: number;
497
- /** false means platform-controlled immutable cache. */
498
- revalidate?: number | false;
499
- tags?: string[];
500
- }
501
- interface CacheStats {
502
- size: number;
503
- hits: number;
504
- misses: number;
505
- hitRate: number;
506
- evictions: number;
507
- }
508
- declare const CacheTags: {
509
- project: (projectId: string) => string;
510
- content: (slug: string) => string;
511
- collection: (collectionId: string) => string;
512
- global: string;
513
- user: (userId: string) => string;
514
- media: (mediaId: string) => string;
515
- };
516
- declare class MemoryCache {
517
- private cache;
518
- private tagIndex;
519
- private stats;
520
- private maxSize;
521
- private defaultTTL;
522
- constructor(options?: CacheOptions);
523
- set<T = any>(key: string, data: T, options?: CacheOptions): void;
524
- get<T = any>(key: string): {
525
- data: T;
526
- metadata: any;
527
- } | null;
528
- delete(key: string): boolean;
529
- invalidateByTags(tags: string[]): void;
530
- clear(): void;
531
- getStats(): CacheStats;
532
- private evictLRU;
533
- private calculateSize;
534
- private updateHitRate;
535
- }
536
- declare class BrowserCache {
537
- private projectId;
538
- private prefix;
539
- private maxSize;
540
- private currentSize;
541
- constructor(projectId: string);
542
- set<T = any>(key: string, data: T, ttl?: number): void;
543
- get<T = any>(key: string): T | null;
544
- delete(key: string): void;
545
- clear(): void;
546
- private getStorageKey;
547
- private calculateCurrentSize;
548
- private calculateStorageSize;
549
- private evictOldest;
550
- }
551
-
552
508
  declare class LocalCacheProxy implements ILocalCache {
553
509
  private instance;
554
510
  private cachePath?;