@nexushub/client 0.0.1 → 0.0.3
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.mts → src/index.d.mts} +104 -62
- package/dist/{index.d.ts → src/index.d.ts} +104 -62
- package/dist/{index.js → src/index.js} +3675 -717
- package/dist/{index.mjs → src/index.mjs} +3669 -712
- package/dist/tools/cli.d.mts +1 -0
- package/dist/tools/cli.d.ts +1 -0
- package/dist/tools/cli.js +591 -0
- package/dist/tools/cli.mjs +568 -0
- package/package.json +9 -6
|
@@ -6,6 +6,15 @@ interface MinimalNexusConfig {
|
|
|
6
6
|
apiKey?: string;
|
|
7
7
|
projectId?: string;
|
|
8
8
|
}
|
|
9
|
+
declare const DEFAULT_API_URL = "https://api.nexushub.com/v1";
|
|
10
|
+
declare const DEFAULT_CDN_URL = "https://cdn.nexushub.com";
|
|
11
|
+
declare const getEnvConfig: () => MinimalNexusConfig;
|
|
12
|
+
declare const mergeConfigs: (base: MinimalNexusConfig, override: Partial<MinimalNexusConfig>) => MinimalNexusConfig;
|
|
13
|
+
declare const hasRequiredConfig: (config: MinimalNexusConfig) => config is MinimalNexusConfig & {
|
|
14
|
+
projectId: string;
|
|
15
|
+
};
|
|
16
|
+
declare const getFullConfig: (partialConfig?: Partial<MinimalNexusConfig>) => MinimalNexusConfig;
|
|
17
|
+
declare const validateConfig: (config: MinimalNexusConfig) => string[];
|
|
9
18
|
|
|
10
19
|
interface NexusConfig extends MinimalNexusConfig {
|
|
11
20
|
debug?: boolean;
|
|
@@ -78,13 +87,14 @@ declare class ContentEngine {
|
|
|
78
87
|
private rateLimiter;
|
|
79
88
|
private backoff;
|
|
80
89
|
private requestBatcher;
|
|
90
|
+
private circuitBreaker;
|
|
81
91
|
private defaultRevalidate;
|
|
82
92
|
private cacheStrategy;
|
|
83
93
|
private abortController?;
|
|
84
94
|
private isServer;
|
|
85
95
|
constructor(config: NexusConfig);
|
|
86
96
|
/**
|
|
87
|
-
* Fetch a
|
|
97
|
+
* Fetch a Single Page with full strategy pipeline
|
|
88
98
|
*/
|
|
89
99
|
getPage<T = any>(slug: string, options?: {
|
|
90
100
|
revalidate?: number;
|
|
@@ -94,7 +104,7 @@ declare class ContentEngine {
|
|
|
94
104
|
}): Promise<T>;
|
|
95
105
|
private _getPage;
|
|
96
106
|
/**
|
|
97
|
-
* Fetch a Collection
|
|
107
|
+
* Fetch a Collection (Optimized)
|
|
98
108
|
*/
|
|
99
109
|
getCollection<T = any>(collectionId: string, query?: CollectionQuery, options?: {
|
|
100
110
|
revalidate?: number;
|
|
@@ -112,7 +122,8 @@ declare class ContentEngine {
|
|
|
112
122
|
forceRefresh?: boolean;
|
|
113
123
|
}): Promise<T>;
|
|
114
124
|
/**
|
|
115
|
-
*
|
|
125
|
+
* Get a single item from a collection (Uses Request Batching)
|
|
126
|
+
* If you call this 10 times in a loop, it sends 1 HTTP request.
|
|
116
127
|
*/
|
|
117
128
|
getItem<T = any>(collectionId: string, itemId: string, options?: {
|
|
118
129
|
revalidate?: number;
|
|
@@ -135,6 +146,15 @@ declare class ContentEngine {
|
|
|
135
146
|
* Prefetch content for better performance
|
|
136
147
|
*/
|
|
137
148
|
prefetch(urls: string[]): Promise<void>;
|
|
149
|
+
/**
|
|
150
|
+
* Robust Real-time Subscriptions (SSE) with Auto-Reconnect
|
|
151
|
+
*/
|
|
152
|
+
subscribeToUpdates(callback: (data: any) => void): () => void;
|
|
153
|
+
/**
|
|
154
|
+
* Check all caches in order of speed
|
|
155
|
+
*/
|
|
156
|
+
private checkCaches;
|
|
157
|
+
private writeCache;
|
|
138
158
|
/**
|
|
139
159
|
* Invalidate cache by tags
|
|
140
160
|
*/
|
|
@@ -160,30 +180,77 @@ declare class ContentEngine {
|
|
|
160
180
|
loaded: boolean;
|
|
161
181
|
};
|
|
162
182
|
};
|
|
163
|
-
/**
|
|
164
|
-
* Cancel ongoing requests
|
|
165
|
-
*/
|
|
166
|
-
cancelRequests(): void;
|
|
167
|
-
/**
|
|
168
|
-
* Subscribe to content updates (SSE)
|
|
169
|
-
*/
|
|
170
|
-
subscribeToUpdates(callback: (data: any) => void): () => void;
|
|
171
183
|
private fetchPage;
|
|
172
184
|
private fetchCollection;
|
|
173
|
-
private fetchWithTimeout;
|
|
174
185
|
private applyLocalQuery;
|
|
175
|
-
private
|
|
186
|
+
private fetchWithTimeout;
|
|
176
187
|
private getHeaders;
|
|
188
|
+
private isCacheValid;
|
|
177
189
|
private normalizeError;
|
|
190
|
+
/**
|
|
191
|
+
* Cancel ongoing requests
|
|
192
|
+
*/
|
|
193
|
+
cancelRequests(): void;
|
|
178
194
|
/**
|
|
179
195
|
* Cleanup resources
|
|
180
196
|
*/
|
|
181
197
|
private cleanup;
|
|
182
198
|
}
|
|
183
199
|
|
|
200
|
+
/**
|
|
201
|
+
* NexusHub Analytics Engine
|
|
202
|
+
* Orchestrates automatic event capture, performance monitoring, and user tracking.
|
|
203
|
+
*/
|
|
204
|
+
declare class AnalyticsEngine {
|
|
205
|
+
private tracker;
|
|
206
|
+
private cleanupFns;
|
|
207
|
+
private isInitialized;
|
|
208
|
+
constructor(config: NexusConfig);
|
|
209
|
+
start(): void;
|
|
210
|
+
pageView(): void;
|
|
211
|
+
private setupShareTracking;
|
|
212
|
+
/**
|
|
213
|
+
* 1. IDENTIFY: Link anonymous session to a User ID
|
|
214
|
+
*/
|
|
215
|
+
identify(userId: string, traits?: Record<string, any>): Promise<boolean>;
|
|
216
|
+
/**
|
|
217
|
+
* 2. GROUP: Link the current user to a Company/Organization (B2B)
|
|
218
|
+
* Required for the /api/group Rust route.
|
|
219
|
+
*/
|
|
220
|
+
group(groupId: string, traits?: Record<string, any>): Promise<boolean>;
|
|
221
|
+
/**
|
|
222
|
+
* 3. ALIAS: Merge two identities (e.g. "Guest_123" -> "User_99")
|
|
223
|
+
* Required for the /api/alias Rust route.
|
|
224
|
+
*/
|
|
225
|
+
alias(newId: string): Promise<boolean>;
|
|
226
|
+
/**
|
|
227
|
+
* 4. RESET: Clear local data and (optionally) request GDPR scrub
|
|
228
|
+
*/
|
|
229
|
+
reset(performGdprScrub?: boolean): void;
|
|
230
|
+
track(eventName: string, properties?: Record<string, any>): void;
|
|
231
|
+
trackPurchase(orderData: {
|
|
232
|
+
orderId: string;
|
|
233
|
+
total: number;
|
|
234
|
+
currency?: string;
|
|
235
|
+
products: Array<{
|
|
236
|
+
id: string;
|
|
237
|
+
price: number;
|
|
238
|
+
quantity: number;
|
|
239
|
+
}>;
|
|
240
|
+
}): void;
|
|
241
|
+
trackError(error: Error, context?: Record<string, any>): void;
|
|
242
|
+
private sendIdentityRequest;
|
|
243
|
+
private setupClickTracking;
|
|
244
|
+
private setupFormTracking;
|
|
245
|
+
private setupRouteTracking;
|
|
246
|
+
getSessionId(): string;
|
|
247
|
+
stop(): void;
|
|
248
|
+
}
|
|
249
|
+
|
|
184
250
|
declare class NexusClient {
|
|
185
251
|
private config;
|
|
186
252
|
content: ContentEngine;
|
|
253
|
+
analytics?: AnalyticsEngine;
|
|
187
254
|
constructor(config?: Partial<NexusConfig>);
|
|
188
255
|
getPage<T = any>(slug: string, options?: any): Promise<T>;
|
|
189
256
|
getConfig(): Readonly<NexusConfig>;
|
|
@@ -199,16 +266,26 @@ declare const NexusProvider: ({ children, projectId }: {
|
|
|
199
266
|
interface SiteUser {
|
|
200
267
|
id: string;
|
|
201
268
|
email: string;
|
|
202
|
-
|
|
269
|
+
username?: string;
|
|
270
|
+
firstName?: string;
|
|
271
|
+
lastName?: string;
|
|
203
272
|
avatarUrl?: string;
|
|
204
273
|
role: string;
|
|
205
|
-
|
|
274
|
+
organizationId?: string;
|
|
275
|
+
organizationTraits?: Record<string, any>;
|
|
276
|
+
metadata?: Record<string, any>;
|
|
277
|
+
createdAt: string;
|
|
206
278
|
}
|
|
207
279
|
interface AuthState {
|
|
208
280
|
user: SiteUser | null;
|
|
209
|
-
isLoading: boolean;
|
|
210
|
-
error: Error | null;
|
|
211
281
|
isAuthenticated: boolean;
|
|
282
|
+
isLoading: boolean;
|
|
283
|
+
error: AuthError | null;
|
|
284
|
+
}
|
|
285
|
+
interface AuthError {
|
|
286
|
+
code: string;
|
|
287
|
+
message: string;
|
|
288
|
+
status: number;
|
|
212
289
|
}
|
|
213
290
|
interface LoginCredentials {
|
|
214
291
|
email: string;
|
|
@@ -217,17 +294,23 @@ interface LoginCredentials {
|
|
|
217
294
|
interface RegisterCredentials {
|
|
218
295
|
email: string;
|
|
219
296
|
password: string;
|
|
220
|
-
|
|
297
|
+
username?: string;
|
|
298
|
+
firstName?: string;
|
|
299
|
+
lastName?: string;
|
|
221
300
|
metadata?: Record<string, any>;
|
|
222
301
|
}
|
|
223
302
|
interface AuthContextType extends AuthState {
|
|
224
303
|
login: (creds: LoginCredentials) => Promise<void>;
|
|
225
304
|
register: (creds: RegisterCredentials) => Promise<void>;
|
|
226
305
|
logout: () => Promise<void>;
|
|
227
|
-
loginWithGoogle: () => void;
|
|
228
306
|
updateProfile: (data: Partial<SiteUser>) => Promise<void>;
|
|
307
|
+
requestPasswordReset: (email: string) => Promise<void>;
|
|
229
308
|
}
|
|
230
309
|
|
|
310
|
+
declare const AuthProvider: ({ children, config }: {
|
|
311
|
+
children: React.ReactNode;
|
|
312
|
+
config: NexusConfig;
|
|
313
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
231
314
|
declare const useNexusAuth: () => AuthContextType;
|
|
232
315
|
|
|
233
316
|
/**
|
|
@@ -310,47 +393,6 @@ declare class BrowserCache {
|
|
|
310
393
|
private evictOldest;
|
|
311
394
|
}
|
|
312
395
|
|
|
313
|
-
|
|
314
|
-
* Advanced strategies for resilience and performance
|
|
315
|
-
*/
|
|
316
|
-
interface RateLimiterConfig {
|
|
317
|
-
maxRequests: number;
|
|
318
|
-
timeWindow: number;
|
|
319
|
-
}
|
|
320
|
-
declare class RateLimiter {
|
|
321
|
-
private requests;
|
|
322
|
-
private config;
|
|
323
|
-
constructor(config: RateLimiterConfig);
|
|
324
|
-
checkLimit(): Promise<void>;
|
|
325
|
-
getStats(): {
|
|
326
|
-
currentRequests: number;
|
|
327
|
-
limit: number;
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
interface BackoffConfig {
|
|
331
|
-
maxRetries: number;
|
|
332
|
-
baseDelay: number;
|
|
333
|
-
maxDelay: number;
|
|
334
|
-
jitter?: boolean;
|
|
335
|
-
}
|
|
336
|
-
declare class ExponentialBackoff {
|
|
337
|
-
private config;
|
|
338
|
-
constructor(config: BackoffConfig);
|
|
339
|
-
execute<T>(fn: () => Promise<T>, onRetry?: (attempt: number, delay: number, error: Error) => void): Promise<T>;
|
|
340
|
-
private calculateDelay;
|
|
341
|
-
private isClientError;
|
|
342
|
-
private isRateLimitError;
|
|
343
|
-
}
|
|
344
|
-
declare class RequestBatcher {
|
|
345
|
-
private batchWindow;
|
|
346
|
-
private maxBatchSize;
|
|
347
|
-
private batch;
|
|
348
|
-
private batchTimeout?;
|
|
349
|
-
private processing;
|
|
350
|
-
constructor(batchWindow?: number, // milliseconds
|
|
351
|
-
maxBatchSize?: number);
|
|
352
|
-
schedule<T>(key: string, request: () => Promise<T>): Promise<T>;
|
|
353
|
-
private processBatch;
|
|
354
|
-
}
|
|
396
|
+
declare const VERSION = "0.0.1";
|
|
355
397
|
|
|
356
|
-
export { type
|
|
398
|
+
export { AnalyticsEngine, type AuthContextType, type AuthError, AuthProvider, type AuthState, BrowserCache, type CacheEntry, type CacheMetadata, CacheTags, type CollectionQuery, type CollectionResponse, ContentEngine, type ContentResponse, DEFAULT_API_URL, DEFAULT_CDN_URL, type ErrorResponse, LocalCache, type LoginCredentials, MemoryCache, type MinimalNexusConfig, NexusClient, type NexusConfig, NexusProvider, type RegisterCredentials, type SiteUser, VERSION, createNexusClient, getEnvConfig, getFullConfig, hasRequiredConfig, mergeConfigs, nexus, useNexusAuth, validateConfig };
|
|
@@ -6,6 +6,15 @@ interface MinimalNexusConfig {
|
|
|
6
6
|
apiKey?: string;
|
|
7
7
|
projectId?: string;
|
|
8
8
|
}
|
|
9
|
+
declare const DEFAULT_API_URL = "https://api.nexushub.com/v1";
|
|
10
|
+
declare const DEFAULT_CDN_URL = "https://cdn.nexushub.com";
|
|
11
|
+
declare const getEnvConfig: () => MinimalNexusConfig;
|
|
12
|
+
declare const mergeConfigs: (base: MinimalNexusConfig, override: Partial<MinimalNexusConfig>) => MinimalNexusConfig;
|
|
13
|
+
declare const hasRequiredConfig: (config: MinimalNexusConfig) => config is MinimalNexusConfig & {
|
|
14
|
+
projectId: string;
|
|
15
|
+
};
|
|
16
|
+
declare const getFullConfig: (partialConfig?: Partial<MinimalNexusConfig>) => MinimalNexusConfig;
|
|
17
|
+
declare const validateConfig: (config: MinimalNexusConfig) => string[];
|
|
9
18
|
|
|
10
19
|
interface NexusConfig extends MinimalNexusConfig {
|
|
11
20
|
debug?: boolean;
|
|
@@ -78,13 +87,14 @@ declare class ContentEngine {
|
|
|
78
87
|
private rateLimiter;
|
|
79
88
|
private backoff;
|
|
80
89
|
private requestBatcher;
|
|
90
|
+
private circuitBreaker;
|
|
81
91
|
private defaultRevalidate;
|
|
82
92
|
private cacheStrategy;
|
|
83
93
|
private abortController?;
|
|
84
94
|
private isServer;
|
|
85
95
|
constructor(config: NexusConfig);
|
|
86
96
|
/**
|
|
87
|
-
* Fetch a
|
|
97
|
+
* Fetch a Single Page with full strategy pipeline
|
|
88
98
|
*/
|
|
89
99
|
getPage<T = any>(slug: string, options?: {
|
|
90
100
|
revalidate?: number;
|
|
@@ -94,7 +104,7 @@ declare class ContentEngine {
|
|
|
94
104
|
}): Promise<T>;
|
|
95
105
|
private _getPage;
|
|
96
106
|
/**
|
|
97
|
-
* Fetch a Collection
|
|
107
|
+
* Fetch a Collection (Optimized)
|
|
98
108
|
*/
|
|
99
109
|
getCollection<T = any>(collectionId: string, query?: CollectionQuery, options?: {
|
|
100
110
|
revalidate?: number;
|
|
@@ -112,7 +122,8 @@ declare class ContentEngine {
|
|
|
112
122
|
forceRefresh?: boolean;
|
|
113
123
|
}): Promise<T>;
|
|
114
124
|
/**
|
|
115
|
-
*
|
|
125
|
+
* Get a single item from a collection (Uses Request Batching)
|
|
126
|
+
* If you call this 10 times in a loop, it sends 1 HTTP request.
|
|
116
127
|
*/
|
|
117
128
|
getItem<T = any>(collectionId: string, itemId: string, options?: {
|
|
118
129
|
revalidate?: number;
|
|
@@ -135,6 +146,15 @@ declare class ContentEngine {
|
|
|
135
146
|
* Prefetch content for better performance
|
|
136
147
|
*/
|
|
137
148
|
prefetch(urls: string[]): Promise<void>;
|
|
149
|
+
/**
|
|
150
|
+
* Robust Real-time Subscriptions (SSE) with Auto-Reconnect
|
|
151
|
+
*/
|
|
152
|
+
subscribeToUpdates(callback: (data: any) => void): () => void;
|
|
153
|
+
/**
|
|
154
|
+
* Check all caches in order of speed
|
|
155
|
+
*/
|
|
156
|
+
private checkCaches;
|
|
157
|
+
private writeCache;
|
|
138
158
|
/**
|
|
139
159
|
* Invalidate cache by tags
|
|
140
160
|
*/
|
|
@@ -160,30 +180,77 @@ declare class ContentEngine {
|
|
|
160
180
|
loaded: boolean;
|
|
161
181
|
};
|
|
162
182
|
};
|
|
163
|
-
/**
|
|
164
|
-
* Cancel ongoing requests
|
|
165
|
-
*/
|
|
166
|
-
cancelRequests(): void;
|
|
167
|
-
/**
|
|
168
|
-
* Subscribe to content updates (SSE)
|
|
169
|
-
*/
|
|
170
|
-
subscribeToUpdates(callback: (data: any) => void): () => void;
|
|
171
183
|
private fetchPage;
|
|
172
184
|
private fetchCollection;
|
|
173
|
-
private fetchWithTimeout;
|
|
174
185
|
private applyLocalQuery;
|
|
175
|
-
private
|
|
186
|
+
private fetchWithTimeout;
|
|
176
187
|
private getHeaders;
|
|
188
|
+
private isCacheValid;
|
|
177
189
|
private normalizeError;
|
|
190
|
+
/**
|
|
191
|
+
* Cancel ongoing requests
|
|
192
|
+
*/
|
|
193
|
+
cancelRequests(): void;
|
|
178
194
|
/**
|
|
179
195
|
* Cleanup resources
|
|
180
196
|
*/
|
|
181
197
|
private cleanup;
|
|
182
198
|
}
|
|
183
199
|
|
|
200
|
+
/**
|
|
201
|
+
* NexusHub Analytics Engine
|
|
202
|
+
* Orchestrates automatic event capture, performance monitoring, and user tracking.
|
|
203
|
+
*/
|
|
204
|
+
declare class AnalyticsEngine {
|
|
205
|
+
private tracker;
|
|
206
|
+
private cleanupFns;
|
|
207
|
+
private isInitialized;
|
|
208
|
+
constructor(config: NexusConfig);
|
|
209
|
+
start(): void;
|
|
210
|
+
pageView(): void;
|
|
211
|
+
private setupShareTracking;
|
|
212
|
+
/**
|
|
213
|
+
* 1. IDENTIFY: Link anonymous session to a User ID
|
|
214
|
+
*/
|
|
215
|
+
identify(userId: string, traits?: Record<string, any>): Promise<boolean>;
|
|
216
|
+
/**
|
|
217
|
+
* 2. GROUP: Link the current user to a Company/Organization (B2B)
|
|
218
|
+
* Required for the /api/group Rust route.
|
|
219
|
+
*/
|
|
220
|
+
group(groupId: string, traits?: Record<string, any>): Promise<boolean>;
|
|
221
|
+
/**
|
|
222
|
+
* 3. ALIAS: Merge two identities (e.g. "Guest_123" -> "User_99")
|
|
223
|
+
* Required for the /api/alias Rust route.
|
|
224
|
+
*/
|
|
225
|
+
alias(newId: string): Promise<boolean>;
|
|
226
|
+
/**
|
|
227
|
+
* 4. RESET: Clear local data and (optionally) request GDPR scrub
|
|
228
|
+
*/
|
|
229
|
+
reset(performGdprScrub?: boolean): void;
|
|
230
|
+
track(eventName: string, properties?: Record<string, any>): void;
|
|
231
|
+
trackPurchase(orderData: {
|
|
232
|
+
orderId: string;
|
|
233
|
+
total: number;
|
|
234
|
+
currency?: string;
|
|
235
|
+
products: Array<{
|
|
236
|
+
id: string;
|
|
237
|
+
price: number;
|
|
238
|
+
quantity: number;
|
|
239
|
+
}>;
|
|
240
|
+
}): void;
|
|
241
|
+
trackError(error: Error, context?: Record<string, any>): void;
|
|
242
|
+
private sendIdentityRequest;
|
|
243
|
+
private setupClickTracking;
|
|
244
|
+
private setupFormTracking;
|
|
245
|
+
private setupRouteTracking;
|
|
246
|
+
getSessionId(): string;
|
|
247
|
+
stop(): void;
|
|
248
|
+
}
|
|
249
|
+
|
|
184
250
|
declare class NexusClient {
|
|
185
251
|
private config;
|
|
186
252
|
content: ContentEngine;
|
|
253
|
+
analytics?: AnalyticsEngine;
|
|
187
254
|
constructor(config?: Partial<NexusConfig>);
|
|
188
255
|
getPage<T = any>(slug: string, options?: any): Promise<T>;
|
|
189
256
|
getConfig(): Readonly<NexusConfig>;
|
|
@@ -199,16 +266,26 @@ declare const NexusProvider: ({ children, projectId }: {
|
|
|
199
266
|
interface SiteUser {
|
|
200
267
|
id: string;
|
|
201
268
|
email: string;
|
|
202
|
-
|
|
269
|
+
username?: string;
|
|
270
|
+
firstName?: string;
|
|
271
|
+
lastName?: string;
|
|
203
272
|
avatarUrl?: string;
|
|
204
273
|
role: string;
|
|
205
|
-
|
|
274
|
+
organizationId?: string;
|
|
275
|
+
organizationTraits?: Record<string, any>;
|
|
276
|
+
metadata?: Record<string, any>;
|
|
277
|
+
createdAt: string;
|
|
206
278
|
}
|
|
207
279
|
interface AuthState {
|
|
208
280
|
user: SiteUser | null;
|
|
209
|
-
isLoading: boolean;
|
|
210
|
-
error: Error | null;
|
|
211
281
|
isAuthenticated: boolean;
|
|
282
|
+
isLoading: boolean;
|
|
283
|
+
error: AuthError | null;
|
|
284
|
+
}
|
|
285
|
+
interface AuthError {
|
|
286
|
+
code: string;
|
|
287
|
+
message: string;
|
|
288
|
+
status: number;
|
|
212
289
|
}
|
|
213
290
|
interface LoginCredentials {
|
|
214
291
|
email: string;
|
|
@@ -217,17 +294,23 @@ interface LoginCredentials {
|
|
|
217
294
|
interface RegisterCredentials {
|
|
218
295
|
email: string;
|
|
219
296
|
password: string;
|
|
220
|
-
|
|
297
|
+
username?: string;
|
|
298
|
+
firstName?: string;
|
|
299
|
+
lastName?: string;
|
|
221
300
|
metadata?: Record<string, any>;
|
|
222
301
|
}
|
|
223
302
|
interface AuthContextType extends AuthState {
|
|
224
303
|
login: (creds: LoginCredentials) => Promise<void>;
|
|
225
304
|
register: (creds: RegisterCredentials) => Promise<void>;
|
|
226
305
|
logout: () => Promise<void>;
|
|
227
|
-
loginWithGoogle: () => void;
|
|
228
306
|
updateProfile: (data: Partial<SiteUser>) => Promise<void>;
|
|
307
|
+
requestPasswordReset: (email: string) => Promise<void>;
|
|
229
308
|
}
|
|
230
309
|
|
|
310
|
+
declare const AuthProvider: ({ children, config }: {
|
|
311
|
+
children: React.ReactNode;
|
|
312
|
+
config: NexusConfig;
|
|
313
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
231
314
|
declare const useNexusAuth: () => AuthContextType;
|
|
232
315
|
|
|
233
316
|
/**
|
|
@@ -310,47 +393,6 @@ declare class BrowserCache {
|
|
|
310
393
|
private evictOldest;
|
|
311
394
|
}
|
|
312
395
|
|
|
313
|
-
|
|
314
|
-
* Advanced strategies for resilience and performance
|
|
315
|
-
*/
|
|
316
|
-
interface RateLimiterConfig {
|
|
317
|
-
maxRequests: number;
|
|
318
|
-
timeWindow: number;
|
|
319
|
-
}
|
|
320
|
-
declare class RateLimiter {
|
|
321
|
-
private requests;
|
|
322
|
-
private config;
|
|
323
|
-
constructor(config: RateLimiterConfig);
|
|
324
|
-
checkLimit(): Promise<void>;
|
|
325
|
-
getStats(): {
|
|
326
|
-
currentRequests: number;
|
|
327
|
-
limit: number;
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
interface BackoffConfig {
|
|
331
|
-
maxRetries: number;
|
|
332
|
-
baseDelay: number;
|
|
333
|
-
maxDelay: number;
|
|
334
|
-
jitter?: boolean;
|
|
335
|
-
}
|
|
336
|
-
declare class ExponentialBackoff {
|
|
337
|
-
private config;
|
|
338
|
-
constructor(config: BackoffConfig);
|
|
339
|
-
execute<T>(fn: () => Promise<T>, onRetry?: (attempt: number, delay: number, error: Error) => void): Promise<T>;
|
|
340
|
-
private calculateDelay;
|
|
341
|
-
private isClientError;
|
|
342
|
-
private isRateLimitError;
|
|
343
|
-
}
|
|
344
|
-
declare class RequestBatcher {
|
|
345
|
-
private batchWindow;
|
|
346
|
-
private maxBatchSize;
|
|
347
|
-
private batch;
|
|
348
|
-
private batchTimeout?;
|
|
349
|
-
private processing;
|
|
350
|
-
constructor(batchWindow?: number, // milliseconds
|
|
351
|
-
maxBatchSize?: number);
|
|
352
|
-
schedule<T>(key: string, request: () => Promise<T>): Promise<T>;
|
|
353
|
-
private processBatch;
|
|
354
|
-
}
|
|
396
|
+
declare const VERSION = "0.0.1";
|
|
355
397
|
|
|
356
|
-
export { type
|
|
398
|
+
export { AnalyticsEngine, type AuthContextType, type AuthError, AuthProvider, type AuthState, BrowserCache, type CacheEntry, type CacheMetadata, CacheTags, type CollectionQuery, type CollectionResponse, ContentEngine, type ContentResponse, DEFAULT_API_URL, DEFAULT_CDN_URL, type ErrorResponse, LocalCache, type LoginCredentials, MemoryCache, type MinimalNexusConfig, NexusClient, type NexusConfig, NexusProvider, type RegisterCredentials, type SiteUser, VERSION, createNexusClient, getEnvConfig, getFullConfig, hasRequiredConfig, mergeConfigs, nexus, useNexusAuth, validateConfig };
|