characterforge-js 1.0.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/LICENSE +22 -0
- package/README.md +472 -0
- package/dist/index.d.mts +226 -0
- package/dist/index.d.ts +226 -0
- package/dist/index.js +1170 -0
- package/dist/index.mjs +1119 -0
- package/package.json +59 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
type Gender = 'male' | 'female';
|
|
2
|
+
type AgeGroupId = 'kid' | 'preteen' | 'teen' | 'young_adult' | 'adult';
|
|
3
|
+
type SkinToneId = 'porcelain' | 'fair' | 'light' | 'medium' | 'olive' | 'brown' | 'dark' | 'deep';
|
|
4
|
+
type EyeColorId = 'dark' | 'brown' | 'blue' | 'green' | 'hazel' | 'grey';
|
|
5
|
+
type HairStyleId = 'bob' | 'ponytail' | 'buns' | 'long' | 'pixie' | 'undercut' | 'quiff' | 'sidepart' | 'buzz' | 'combover' | 'messy' | 'afro' | 'curly';
|
|
6
|
+
type HairColorId = 'black' | 'dark_brown' | 'brown' | 'auburn' | 'ginger' | 'dark_blonde' | 'blonde' | 'platinum' | 'grey' | 'white' | 'blue' | 'purple';
|
|
7
|
+
type ClothingItemId = 'tshirt' | 'hoodie' | 'sweater' | 'jacket' | 'tank' | 'dress' | 'blouse' | 'polo' | 'buttonup' | 'henley';
|
|
8
|
+
type ClothingColorId = 'white' | 'black' | 'navy' | 'red' | 'blue' | 'green' | 'yellow' | 'purple' | 'pink' | 'orange' | 'teal';
|
|
9
|
+
type AccessoryId = 'none' | 'glasses' | 'sunglasses' | 'headphones' | 'cap' | 'beanie';
|
|
10
|
+
interface CharacterConfig {
|
|
11
|
+
gender: Gender;
|
|
12
|
+
ageGroup?: AgeGroupId;
|
|
13
|
+
skinTone: SkinToneId;
|
|
14
|
+
hairStyle: HairStyleId;
|
|
15
|
+
hairColor: HairColorId;
|
|
16
|
+
clothing: ClothingItemId;
|
|
17
|
+
clothingColor: ClothingColorId;
|
|
18
|
+
eyeColor: EyeColorId;
|
|
19
|
+
accessories: AccessoryId[];
|
|
20
|
+
transparent: boolean;
|
|
21
|
+
cache?: boolean;
|
|
22
|
+
}
|
|
23
|
+
interface CacheManager {
|
|
24
|
+
get(key: string): Promise<string | null>;
|
|
25
|
+
set(key: string, data: Blob | string): Promise<string>;
|
|
26
|
+
clear(): Promise<void>;
|
|
27
|
+
delete?(key: string): Promise<void>;
|
|
28
|
+
destroy?(): void;
|
|
29
|
+
}
|
|
30
|
+
interface CharacterForgeClientConfig {
|
|
31
|
+
apiKey: string;
|
|
32
|
+
baseUrl?: string;
|
|
33
|
+
cache?: boolean;
|
|
34
|
+
cacheManager?: CacheManager;
|
|
35
|
+
timeout?: number;
|
|
36
|
+
retry?: RetryConfig;
|
|
37
|
+
}
|
|
38
|
+
interface RetryConfig {
|
|
39
|
+
maxRetries: number;
|
|
40
|
+
baseDelayMs: number;
|
|
41
|
+
maxDelayMs: number;
|
|
42
|
+
}
|
|
43
|
+
interface GenerationResult {
|
|
44
|
+
image: string;
|
|
45
|
+
cached: boolean;
|
|
46
|
+
durationMs?: number;
|
|
47
|
+
}
|
|
48
|
+
type StatusUpdateCallback = (status: string) => void;
|
|
49
|
+
interface DetailedStatus {
|
|
50
|
+
stage: 'initiating' | 'generating' | 'processing' | 'caching' | 'complete' | 'error';
|
|
51
|
+
message: string;
|
|
52
|
+
progress?: number;
|
|
53
|
+
error?: string;
|
|
54
|
+
}
|
|
55
|
+
type DetailedStatusCallback = (status: DetailedStatus) => void;
|
|
56
|
+
interface GenerationApiResponse {
|
|
57
|
+
image: string;
|
|
58
|
+
}
|
|
59
|
+
interface ApiErrorResponse {
|
|
60
|
+
error: string;
|
|
61
|
+
code?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
declare class AppError extends Error {
|
|
65
|
+
readonly code: string;
|
|
66
|
+
readonly statusCode: number;
|
|
67
|
+
readonly isOperational: boolean;
|
|
68
|
+
readonly timestamp: Date;
|
|
69
|
+
constructor(message: string, code?: string, statusCode?: number, isOperational?: boolean);
|
|
70
|
+
toJSON(): {
|
|
71
|
+
name: string;
|
|
72
|
+
message: string;
|
|
73
|
+
code: string;
|
|
74
|
+
statusCode: number;
|
|
75
|
+
timestamp: string;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
declare class AuthenticationError extends AppError {
|
|
79
|
+
constructor(message?: string);
|
|
80
|
+
}
|
|
81
|
+
declare class AuthorizationError extends AppError {
|
|
82
|
+
constructor(message?: string);
|
|
83
|
+
}
|
|
84
|
+
declare class InsufficientCreditsError extends AppError {
|
|
85
|
+
readonly required: number;
|
|
86
|
+
readonly available: number;
|
|
87
|
+
constructor(required?: number, available?: number);
|
|
88
|
+
}
|
|
89
|
+
declare class PaymentError extends AppError {
|
|
90
|
+
constructor(message?: string);
|
|
91
|
+
}
|
|
92
|
+
declare class ApiError extends AppError {
|
|
93
|
+
readonly endpoint?: string;
|
|
94
|
+
constructor(message: string, statusCode?: number, endpoint?: string, code?: string);
|
|
95
|
+
}
|
|
96
|
+
declare class RateLimitError extends ApiError {
|
|
97
|
+
readonly retryAfter?: number;
|
|
98
|
+
constructor(retryAfter?: number);
|
|
99
|
+
}
|
|
100
|
+
declare class NetworkError extends AppError {
|
|
101
|
+
constructor(message?: string);
|
|
102
|
+
}
|
|
103
|
+
declare class GenerationError extends AppError {
|
|
104
|
+
constructor(message?: string, code?: string);
|
|
105
|
+
}
|
|
106
|
+
declare class ImageProcessingError extends GenerationError {
|
|
107
|
+
constructor(message?: string);
|
|
108
|
+
}
|
|
109
|
+
declare class ValidationError extends AppError {
|
|
110
|
+
readonly field?: string;
|
|
111
|
+
readonly value?: unknown;
|
|
112
|
+
constructor(message: string, field?: string, value?: unknown, code?: string);
|
|
113
|
+
}
|
|
114
|
+
declare class ConfigValidationError extends ValidationError {
|
|
115
|
+
constructor(message: string, field?: string);
|
|
116
|
+
}
|
|
117
|
+
declare class CacheError extends AppError {
|
|
118
|
+
constructor(message?: string);
|
|
119
|
+
}
|
|
120
|
+
declare function isAppError(error: unknown): error is AppError;
|
|
121
|
+
declare function isAuthenticationError(error: unknown): error is AuthenticationError;
|
|
122
|
+
declare function isInsufficientCreditsError(error: unknown): error is InsufficientCreditsError;
|
|
123
|
+
declare function isNetworkError(error: unknown): error is NetworkError;
|
|
124
|
+
declare function isRateLimitError(error: unknown): error is RateLimitError;
|
|
125
|
+
declare function parseError(error: unknown): AppError;
|
|
126
|
+
declare function getUserFriendlyMessage(error: unknown): string;
|
|
127
|
+
|
|
128
|
+
declare class CharacterForgeClient {
|
|
129
|
+
private cacheManager;
|
|
130
|
+
private config;
|
|
131
|
+
private retryConfig;
|
|
132
|
+
constructor(config: CharacterForgeClientConfig);
|
|
133
|
+
generate(characterConfig: CharacterConfig, onStatusUpdate?: StatusUpdateCallback): Promise<string>;
|
|
134
|
+
private callApiWithRetry;
|
|
135
|
+
private cacheResult;
|
|
136
|
+
clearCache(): Promise<void>;
|
|
137
|
+
getCacheStats(): Promise<{
|
|
138
|
+
size: number;
|
|
139
|
+
} | null>;
|
|
140
|
+
destroy(): void;
|
|
141
|
+
}
|
|
142
|
+
declare function createCharacterForgeClient(config: CharacterForgeClientConfig): CharacterForgeClient;
|
|
143
|
+
|
|
144
|
+
declare class WebCacheManager implements CacheManager {
|
|
145
|
+
private dbPromise;
|
|
146
|
+
private urlManager;
|
|
147
|
+
private isSupported;
|
|
148
|
+
private cleanupIntervalId;
|
|
149
|
+
constructor();
|
|
150
|
+
private openDB;
|
|
151
|
+
get(key: string): Promise<string | null>;
|
|
152
|
+
set(key: string, data: Blob | string): Promise<string>;
|
|
153
|
+
delete(key: string): Promise<void>;
|
|
154
|
+
clear(): Promise<void>;
|
|
155
|
+
destroy(): void;
|
|
156
|
+
private getEntry;
|
|
157
|
+
private putEntry;
|
|
158
|
+
private deleteEntry;
|
|
159
|
+
private updateAccessTime;
|
|
160
|
+
private enforceLimit;
|
|
161
|
+
private getCount;
|
|
162
|
+
private getOldestKeys;
|
|
163
|
+
private scheduleCleanup;
|
|
164
|
+
private cleanup;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
declare class NativeCacheManager implements CacheManager {
|
|
168
|
+
private fs;
|
|
169
|
+
private asyncStorage;
|
|
170
|
+
private cacheDir;
|
|
171
|
+
private isSupported;
|
|
172
|
+
private metadata;
|
|
173
|
+
private initPromise;
|
|
174
|
+
private cleanupIntervalId;
|
|
175
|
+
constructor();
|
|
176
|
+
private initialize;
|
|
177
|
+
private loadMetadata;
|
|
178
|
+
private saveMetadata;
|
|
179
|
+
get(key: string): Promise<string | null>;
|
|
180
|
+
set(key: string, data: Blob | string): Promise<string>;
|
|
181
|
+
delete(key: string): Promise<void>;
|
|
182
|
+
clear(): Promise<void>;
|
|
183
|
+
destroy(): void;
|
|
184
|
+
private enforceLimit;
|
|
185
|
+
private scheduleCleanup;
|
|
186
|
+
private cleanup;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
declare function isReactNative(): boolean;
|
|
190
|
+
declare function isBrowser(): boolean;
|
|
191
|
+
declare function createCacheManager(): CacheManager;
|
|
192
|
+
|
|
193
|
+
type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
194
|
+
interface LogEntry {
|
|
195
|
+
level: LogLevel;
|
|
196
|
+
message: string;
|
|
197
|
+
timestamp: string;
|
|
198
|
+
context?: string;
|
|
199
|
+
data?: Record<string, unknown>;
|
|
200
|
+
error?: Error;
|
|
201
|
+
}
|
|
202
|
+
interface LoggerConfig {
|
|
203
|
+
minLevel: LogLevel;
|
|
204
|
+
enableConsole: boolean;
|
|
205
|
+
context?: string;
|
|
206
|
+
}
|
|
207
|
+
declare class Logger {
|
|
208
|
+
private config;
|
|
209
|
+
private context?;
|
|
210
|
+
constructor(config?: Partial<LoggerConfig>);
|
|
211
|
+
child(context: string): Logger;
|
|
212
|
+
private shouldLog;
|
|
213
|
+
private formatConsoleMessage;
|
|
214
|
+
private log;
|
|
215
|
+
debug(message: string, data?: Record<string, unknown>): void;
|
|
216
|
+
info(message: string, data?: Record<string, unknown>): void;
|
|
217
|
+
warn(message: string, data?: Record<string, unknown>): void;
|
|
218
|
+
error(message: string, error?: Error | unknown, data?: Record<string, unknown>): void;
|
|
219
|
+
time(label: string): () => void;
|
|
220
|
+
}
|
|
221
|
+
declare const logger: Logger;
|
|
222
|
+
declare const sdkLogger: Logger;
|
|
223
|
+
|
|
224
|
+
declare const VERSION = "1.0.0";
|
|
225
|
+
|
|
226
|
+
export { type AccessoryId, type AgeGroupId, ApiError, type ApiErrorResponse, AppError, AuthenticationError, AuthorizationError, CacheError, type CacheManager, type CharacterConfig, CharacterForgeClient, type CharacterForgeClientConfig, GenerationError as CharacterForgeError, type ClothingColorId, type ClothingItemId, ConfigValidationError, type DetailedStatus, type DetailedStatusCallback, type EyeColorId, type Gender, type GenerationApiResponse, GenerationError, type GenerationResult, type HairColorId, type HairStyleId, ImageProcessingError, InsufficientCreditsError, type LogEntry, type LogLevel, Logger, type LoggerConfig, NativeCacheManager, NetworkError, PaymentError, RateLimitError, type RetryConfig, type SkinToneId, type StatusUpdateCallback, VERSION, ValidationError, WebCacheManager, createCacheManager, createCharacterForgeClient, getUserFriendlyMessage, isAppError, isAuthenticationError, isBrowser, isInsufficientCreditsError, isNetworkError, isRateLimitError, isReactNative, logger, parseError, sdkLogger };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
type Gender = 'male' | 'female';
|
|
2
|
+
type AgeGroupId = 'kid' | 'preteen' | 'teen' | 'young_adult' | 'adult';
|
|
3
|
+
type SkinToneId = 'porcelain' | 'fair' | 'light' | 'medium' | 'olive' | 'brown' | 'dark' | 'deep';
|
|
4
|
+
type EyeColorId = 'dark' | 'brown' | 'blue' | 'green' | 'hazel' | 'grey';
|
|
5
|
+
type HairStyleId = 'bob' | 'ponytail' | 'buns' | 'long' | 'pixie' | 'undercut' | 'quiff' | 'sidepart' | 'buzz' | 'combover' | 'messy' | 'afro' | 'curly';
|
|
6
|
+
type HairColorId = 'black' | 'dark_brown' | 'brown' | 'auburn' | 'ginger' | 'dark_blonde' | 'blonde' | 'platinum' | 'grey' | 'white' | 'blue' | 'purple';
|
|
7
|
+
type ClothingItemId = 'tshirt' | 'hoodie' | 'sweater' | 'jacket' | 'tank' | 'dress' | 'blouse' | 'polo' | 'buttonup' | 'henley';
|
|
8
|
+
type ClothingColorId = 'white' | 'black' | 'navy' | 'red' | 'blue' | 'green' | 'yellow' | 'purple' | 'pink' | 'orange' | 'teal';
|
|
9
|
+
type AccessoryId = 'none' | 'glasses' | 'sunglasses' | 'headphones' | 'cap' | 'beanie';
|
|
10
|
+
interface CharacterConfig {
|
|
11
|
+
gender: Gender;
|
|
12
|
+
ageGroup?: AgeGroupId;
|
|
13
|
+
skinTone: SkinToneId;
|
|
14
|
+
hairStyle: HairStyleId;
|
|
15
|
+
hairColor: HairColorId;
|
|
16
|
+
clothing: ClothingItemId;
|
|
17
|
+
clothingColor: ClothingColorId;
|
|
18
|
+
eyeColor: EyeColorId;
|
|
19
|
+
accessories: AccessoryId[];
|
|
20
|
+
transparent: boolean;
|
|
21
|
+
cache?: boolean;
|
|
22
|
+
}
|
|
23
|
+
interface CacheManager {
|
|
24
|
+
get(key: string): Promise<string | null>;
|
|
25
|
+
set(key: string, data: Blob | string): Promise<string>;
|
|
26
|
+
clear(): Promise<void>;
|
|
27
|
+
delete?(key: string): Promise<void>;
|
|
28
|
+
destroy?(): void;
|
|
29
|
+
}
|
|
30
|
+
interface CharacterForgeClientConfig {
|
|
31
|
+
apiKey: string;
|
|
32
|
+
baseUrl?: string;
|
|
33
|
+
cache?: boolean;
|
|
34
|
+
cacheManager?: CacheManager;
|
|
35
|
+
timeout?: number;
|
|
36
|
+
retry?: RetryConfig;
|
|
37
|
+
}
|
|
38
|
+
interface RetryConfig {
|
|
39
|
+
maxRetries: number;
|
|
40
|
+
baseDelayMs: number;
|
|
41
|
+
maxDelayMs: number;
|
|
42
|
+
}
|
|
43
|
+
interface GenerationResult {
|
|
44
|
+
image: string;
|
|
45
|
+
cached: boolean;
|
|
46
|
+
durationMs?: number;
|
|
47
|
+
}
|
|
48
|
+
type StatusUpdateCallback = (status: string) => void;
|
|
49
|
+
interface DetailedStatus {
|
|
50
|
+
stage: 'initiating' | 'generating' | 'processing' | 'caching' | 'complete' | 'error';
|
|
51
|
+
message: string;
|
|
52
|
+
progress?: number;
|
|
53
|
+
error?: string;
|
|
54
|
+
}
|
|
55
|
+
type DetailedStatusCallback = (status: DetailedStatus) => void;
|
|
56
|
+
interface GenerationApiResponse {
|
|
57
|
+
image: string;
|
|
58
|
+
}
|
|
59
|
+
interface ApiErrorResponse {
|
|
60
|
+
error: string;
|
|
61
|
+
code?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
declare class AppError extends Error {
|
|
65
|
+
readonly code: string;
|
|
66
|
+
readonly statusCode: number;
|
|
67
|
+
readonly isOperational: boolean;
|
|
68
|
+
readonly timestamp: Date;
|
|
69
|
+
constructor(message: string, code?: string, statusCode?: number, isOperational?: boolean);
|
|
70
|
+
toJSON(): {
|
|
71
|
+
name: string;
|
|
72
|
+
message: string;
|
|
73
|
+
code: string;
|
|
74
|
+
statusCode: number;
|
|
75
|
+
timestamp: string;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
declare class AuthenticationError extends AppError {
|
|
79
|
+
constructor(message?: string);
|
|
80
|
+
}
|
|
81
|
+
declare class AuthorizationError extends AppError {
|
|
82
|
+
constructor(message?: string);
|
|
83
|
+
}
|
|
84
|
+
declare class InsufficientCreditsError extends AppError {
|
|
85
|
+
readonly required: number;
|
|
86
|
+
readonly available: number;
|
|
87
|
+
constructor(required?: number, available?: number);
|
|
88
|
+
}
|
|
89
|
+
declare class PaymentError extends AppError {
|
|
90
|
+
constructor(message?: string);
|
|
91
|
+
}
|
|
92
|
+
declare class ApiError extends AppError {
|
|
93
|
+
readonly endpoint?: string;
|
|
94
|
+
constructor(message: string, statusCode?: number, endpoint?: string, code?: string);
|
|
95
|
+
}
|
|
96
|
+
declare class RateLimitError extends ApiError {
|
|
97
|
+
readonly retryAfter?: number;
|
|
98
|
+
constructor(retryAfter?: number);
|
|
99
|
+
}
|
|
100
|
+
declare class NetworkError extends AppError {
|
|
101
|
+
constructor(message?: string);
|
|
102
|
+
}
|
|
103
|
+
declare class GenerationError extends AppError {
|
|
104
|
+
constructor(message?: string, code?: string);
|
|
105
|
+
}
|
|
106
|
+
declare class ImageProcessingError extends GenerationError {
|
|
107
|
+
constructor(message?: string);
|
|
108
|
+
}
|
|
109
|
+
declare class ValidationError extends AppError {
|
|
110
|
+
readonly field?: string;
|
|
111
|
+
readonly value?: unknown;
|
|
112
|
+
constructor(message: string, field?: string, value?: unknown, code?: string);
|
|
113
|
+
}
|
|
114
|
+
declare class ConfigValidationError extends ValidationError {
|
|
115
|
+
constructor(message: string, field?: string);
|
|
116
|
+
}
|
|
117
|
+
declare class CacheError extends AppError {
|
|
118
|
+
constructor(message?: string);
|
|
119
|
+
}
|
|
120
|
+
declare function isAppError(error: unknown): error is AppError;
|
|
121
|
+
declare function isAuthenticationError(error: unknown): error is AuthenticationError;
|
|
122
|
+
declare function isInsufficientCreditsError(error: unknown): error is InsufficientCreditsError;
|
|
123
|
+
declare function isNetworkError(error: unknown): error is NetworkError;
|
|
124
|
+
declare function isRateLimitError(error: unknown): error is RateLimitError;
|
|
125
|
+
declare function parseError(error: unknown): AppError;
|
|
126
|
+
declare function getUserFriendlyMessage(error: unknown): string;
|
|
127
|
+
|
|
128
|
+
declare class CharacterForgeClient {
|
|
129
|
+
private cacheManager;
|
|
130
|
+
private config;
|
|
131
|
+
private retryConfig;
|
|
132
|
+
constructor(config: CharacterForgeClientConfig);
|
|
133
|
+
generate(characterConfig: CharacterConfig, onStatusUpdate?: StatusUpdateCallback): Promise<string>;
|
|
134
|
+
private callApiWithRetry;
|
|
135
|
+
private cacheResult;
|
|
136
|
+
clearCache(): Promise<void>;
|
|
137
|
+
getCacheStats(): Promise<{
|
|
138
|
+
size: number;
|
|
139
|
+
} | null>;
|
|
140
|
+
destroy(): void;
|
|
141
|
+
}
|
|
142
|
+
declare function createCharacterForgeClient(config: CharacterForgeClientConfig): CharacterForgeClient;
|
|
143
|
+
|
|
144
|
+
declare class WebCacheManager implements CacheManager {
|
|
145
|
+
private dbPromise;
|
|
146
|
+
private urlManager;
|
|
147
|
+
private isSupported;
|
|
148
|
+
private cleanupIntervalId;
|
|
149
|
+
constructor();
|
|
150
|
+
private openDB;
|
|
151
|
+
get(key: string): Promise<string | null>;
|
|
152
|
+
set(key: string, data: Blob | string): Promise<string>;
|
|
153
|
+
delete(key: string): Promise<void>;
|
|
154
|
+
clear(): Promise<void>;
|
|
155
|
+
destroy(): void;
|
|
156
|
+
private getEntry;
|
|
157
|
+
private putEntry;
|
|
158
|
+
private deleteEntry;
|
|
159
|
+
private updateAccessTime;
|
|
160
|
+
private enforceLimit;
|
|
161
|
+
private getCount;
|
|
162
|
+
private getOldestKeys;
|
|
163
|
+
private scheduleCleanup;
|
|
164
|
+
private cleanup;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
declare class NativeCacheManager implements CacheManager {
|
|
168
|
+
private fs;
|
|
169
|
+
private asyncStorage;
|
|
170
|
+
private cacheDir;
|
|
171
|
+
private isSupported;
|
|
172
|
+
private metadata;
|
|
173
|
+
private initPromise;
|
|
174
|
+
private cleanupIntervalId;
|
|
175
|
+
constructor();
|
|
176
|
+
private initialize;
|
|
177
|
+
private loadMetadata;
|
|
178
|
+
private saveMetadata;
|
|
179
|
+
get(key: string): Promise<string | null>;
|
|
180
|
+
set(key: string, data: Blob | string): Promise<string>;
|
|
181
|
+
delete(key: string): Promise<void>;
|
|
182
|
+
clear(): Promise<void>;
|
|
183
|
+
destroy(): void;
|
|
184
|
+
private enforceLimit;
|
|
185
|
+
private scheduleCleanup;
|
|
186
|
+
private cleanup;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
declare function isReactNative(): boolean;
|
|
190
|
+
declare function isBrowser(): boolean;
|
|
191
|
+
declare function createCacheManager(): CacheManager;
|
|
192
|
+
|
|
193
|
+
type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
194
|
+
interface LogEntry {
|
|
195
|
+
level: LogLevel;
|
|
196
|
+
message: string;
|
|
197
|
+
timestamp: string;
|
|
198
|
+
context?: string;
|
|
199
|
+
data?: Record<string, unknown>;
|
|
200
|
+
error?: Error;
|
|
201
|
+
}
|
|
202
|
+
interface LoggerConfig {
|
|
203
|
+
minLevel: LogLevel;
|
|
204
|
+
enableConsole: boolean;
|
|
205
|
+
context?: string;
|
|
206
|
+
}
|
|
207
|
+
declare class Logger {
|
|
208
|
+
private config;
|
|
209
|
+
private context?;
|
|
210
|
+
constructor(config?: Partial<LoggerConfig>);
|
|
211
|
+
child(context: string): Logger;
|
|
212
|
+
private shouldLog;
|
|
213
|
+
private formatConsoleMessage;
|
|
214
|
+
private log;
|
|
215
|
+
debug(message: string, data?: Record<string, unknown>): void;
|
|
216
|
+
info(message: string, data?: Record<string, unknown>): void;
|
|
217
|
+
warn(message: string, data?: Record<string, unknown>): void;
|
|
218
|
+
error(message: string, error?: Error | unknown, data?: Record<string, unknown>): void;
|
|
219
|
+
time(label: string): () => void;
|
|
220
|
+
}
|
|
221
|
+
declare const logger: Logger;
|
|
222
|
+
declare const sdkLogger: Logger;
|
|
223
|
+
|
|
224
|
+
declare const VERSION = "1.0.0";
|
|
225
|
+
|
|
226
|
+
export { type AccessoryId, type AgeGroupId, ApiError, type ApiErrorResponse, AppError, AuthenticationError, AuthorizationError, CacheError, type CacheManager, type CharacterConfig, CharacterForgeClient, type CharacterForgeClientConfig, GenerationError as CharacterForgeError, type ClothingColorId, type ClothingItemId, ConfigValidationError, type DetailedStatus, type DetailedStatusCallback, type EyeColorId, type Gender, type GenerationApiResponse, GenerationError, type GenerationResult, type HairColorId, type HairStyleId, ImageProcessingError, InsufficientCreditsError, type LogEntry, type LogLevel, Logger, type LoggerConfig, NativeCacheManager, NetworkError, PaymentError, RateLimitError, type RetryConfig, type SkinToneId, type StatusUpdateCallback, VERSION, ValidationError, WebCacheManager, createCacheManager, createCharacterForgeClient, getUserFriendlyMessage, isAppError, isAuthenticationError, isBrowser, isInsufficientCreditsError, isNetworkError, isRateLimitError, isReactNative, logger, parseError, sdkLogger };
|