@easyling/sanity-connector 0.0.1
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 +21 -0
- package/README.md +482 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/actions/bulkTranslate.d.ts +7 -0
- package/dist/actions/bulkTranslate.d.ts.map +1 -0
- package/dist/actions/bulkTranslate.js +543 -0
- package/dist/actions/bulkTranslate.js.map +1 -0
- package/dist/actions/manageDNTFields.d.ts +12 -0
- package/dist/actions/manageDNTFields.d.ts.map +1 -0
- package/dist/actions/manageDNTFields.js +100 -0
- package/dist/actions/manageDNTFields.js.map +1 -0
- package/dist/actions/translateDocument.d.ts +7 -0
- package/dist/actions/translateDocument.d.ts.map +1 -0
- package/dist/actions/translateDocument.js +256 -0
- package/dist/actions/translateDocument.js.map +1 -0
- package/dist/components/RadioWithDefault.d.ts +17 -0
- package/dist/components/RadioWithDefault.d.ts.map +1 -0
- package/dist/components/RadioWithDefault.js +29 -0
- package/dist/components/RadioWithDefault.js.map +1 -0
- package/dist/components/auth/AuthNavbar.d.ts +18 -0
- package/dist/components/auth/AuthNavbar.d.ts.map +1 -0
- package/dist/components/auth/AuthNavbar.js +15 -0
- package/dist/components/auth/AuthNavbar.js.map +1 -0
- package/dist/components/auth/AuthStatus.d.ts +27 -0
- package/dist/components/auth/AuthStatus.d.ts.map +1 -0
- package/dist/components/auth/AuthStatus.js +82 -0
- package/dist/components/auth/AuthStatus.js.map +1 -0
- package/dist/components/auth/AuthStatusWrapper.d.ts +15 -0
- package/dist/components/auth/AuthStatusWrapper.d.ts.map +1 -0
- package/dist/components/auth/AuthStatusWrapper.js +39 -0
- package/dist/components/auth/AuthStatusWrapper.js.map +1 -0
- package/dist/components/auth/MigrationPrompt.d.ts +20 -0
- package/dist/components/auth/MigrationPrompt.d.ts.map +1 -0
- package/dist/components/auth/MigrationPrompt.js +16 -0
- package/dist/components/auth/MigrationPrompt.js.map +1 -0
- package/dist/components/auth/MigrationPromptWrapper.d.ts +14 -0
- package/dist/components/auth/MigrationPromptWrapper.d.ts.map +1 -0
- package/dist/components/auth/MigrationPromptWrapper.js +16 -0
- package/dist/components/auth/MigrationPromptWrapper.js.map +1 -0
- package/dist/components/auth/OAuthCallback.d.ts +20 -0
- package/dist/components/auth/OAuthCallback.d.ts.map +1 -0
- package/dist/components/auth/OAuthCallback.js +12 -0
- package/dist/components/auth/OAuthCallback.js.map +1 -0
- package/dist/components/auth/index.d.ts +15 -0
- package/dist/components/auth/index.d.ts.map +1 -0
- package/dist/components/auth/index.js +12 -0
- package/dist/components/auth/index.js.map +1 -0
- package/dist/components/config/LocaleConfigTool.d.ts +17 -0
- package/dist/components/config/LocaleConfigTool.d.ts.map +1 -0
- package/dist/components/config/LocaleConfigTool.js +186 -0
- package/dist/components/config/LocaleConfigTool.js.map +1 -0
- package/dist/components/config/LocaleConfigToolWrapper.d.ts +13 -0
- package/dist/components/config/LocaleConfigToolWrapper.d.ts.map +1 -0
- package/dist/components/config/LocaleConfigToolWrapper.js +26 -0
- package/dist/components/config/LocaleConfigToolWrapper.js.map +1 -0
- package/dist/components/config/OAuthConfig.d.ts +26 -0
- package/dist/components/config/OAuthConfig.d.ts.map +1 -0
- package/dist/components/config/OAuthConfig.js +152 -0
- package/dist/components/config/OAuthConfig.js.map +1 -0
- package/dist/components/config/OAuthConfigWrapper.d.ts +13 -0
- package/dist/components/config/OAuthConfigWrapper.d.ts.map +1 -0
- package/dist/components/config/OAuthConfigWrapper.js +41 -0
- package/dist/components/config/OAuthConfigWrapper.js.map +1 -0
- package/dist/components/config/PasswordInput.d.ts +14 -0
- package/dist/components/config/PasswordInput.d.ts.map +1 -0
- package/dist/components/config/PasswordInput.js +23 -0
- package/dist/components/config/PasswordInput.js.map +1 -0
- package/dist/components/config/index.d.ts +9 -0
- package/dist/components/config/index.d.ts.map +1 -0
- package/dist/components/config/index.js +8 -0
- package/dist/components/config/index.js.map +1 -0
- package/dist/components/config/localeConfigToolDefinition.d.ts +13 -0
- package/dist/components/config/localeConfigToolDefinition.d.ts.map +1 -0
- package/dist/components/config/localeConfigToolDefinition.js +19 -0
- package/dist/components/config/localeConfigToolDefinition.js.map +1 -0
- package/dist/components/config/oauthConfigToolDefinition.d.ts +13 -0
- package/dist/components/config/oauthConfigToolDefinition.d.ts.map +1 -0
- package/dist/components/config/oauthConfigToolDefinition.js +19 -0
- package/dist/components/config/oauthConfigToolDefinition.js.map +1 -0
- package/dist/components/dialogs/ConfirmationDialog.d.ts +21 -0
- package/dist/components/dialogs/ConfirmationDialog.d.ts.map +1 -0
- package/dist/components/dialogs/ConfirmationDialog.js +28 -0
- package/dist/components/dialogs/ConfirmationDialog.js.map +1 -0
- package/dist/components/dialogs/ErrorDialog.d.ts +21 -0
- package/dist/components/dialogs/ErrorDialog.d.ts.map +1 -0
- package/dist/components/dialogs/ErrorDialog.js +28 -0
- package/dist/components/dialogs/ErrorDialog.js.map +1 -0
- package/dist/components/dialogs/LocaleSelectionDialog.d.ts +41 -0
- package/dist/components/dialogs/LocaleSelectionDialog.d.ts.map +1 -0
- package/dist/components/dialogs/LocaleSelectionDialog.js +117 -0
- package/dist/components/dialogs/LocaleSelectionDialog.js.map +1 -0
- package/dist/components/dialogs/SuccessDialog.d.ts +19 -0
- package/dist/components/dialogs/SuccessDialog.d.ts.map +1 -0
- package/dist/components/dialogs/SuccessDialog.js +37 -0
- package/dist/components/dialogs/SuccessDialog.js.map +1 -0
- package/dist/components/dialogs/index.d.ts +12 -0
- package/dist/components/dialogs/index.d.ts.map +1 -0
- package/dist/components/dialogs/index.js +8 -0
- package/dist/components/dialogs/index.js.map +1 -0
- package/dist/components/dnt/DNTFieldBadge.d.ts +16 -0
- package/dist/components/dnt/DNTFieldBadge.d.ts.map +1 -0
- package/dist/components/dnt/DNTFieldBadge.js +56 -0
- package/dist/components/dnt/DNTFieldBadge.js.map +1 -0
- package/dist/components/dnt/DNTFieldComponent.d.ts +17 -0
- package/dist/components/dnt/DNTFieldComponent.d.ts.map +1 -0
- package/dist/components/dnt/DNTFieldComponent.js +21 -0
- package/dist/components/dnt/DNTFieldComponent.js.map +1 -0
- package/dist/components/dnt/DNTFieldInput.d.ts +14 -0
- package/dist/components/dnt/DNTFieldInput.d.ts.map +1 -0
- package/dist/components/dnt/DNTFieldInput.js +76 -0
- package/dist/components/dnt/DNTFieldInput.js.map +1 -0
- package/dist/components/dnt/index.d.ts +7 -0
- package/dist/components/dnt/index.d.ts.map +1 -0
- package/dist/components/dnt/index.js +7 -0
- package/dist/components/dnt/index.js.map +1 -0
- package/dist/config/index.d.ts +6 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +6 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/pluginConfig.d.ts +163 -0
- package/dist/config/pluginConfig.d.ts.map +1 -0
- package/dist/config/pluginConfig.js +548 -0
- package/dist/config/pluginConfig.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +3 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +137 -0
- package/dist/plugin.js.map +1 -0
- package/dist/services/authStateManager.d.ts +94 -0
- package/dist/services/authStateManager.d.ts.map +1 -0
- package/dist/services/authStateManager.js +208 -0
- package/dist/services/authStateManager.js.map +1 -0
- package/dist/services/contentExtractor.d.ts +95 -0
- package/dist/services/contentExtractor.d.ts.map +1 -0
- package/dist/services/contentExtractor.js +516 -0
- package/dist/services/contentExtractor.js.map +1 -0
- package/dist/services/dialogService.d.ts +96 -0
- package/dist/services/dialogService.d.ts.map +1 -0
- package/dist/services/dialogService.js +244 -0
- package/dist/services/dialogService.js.map +1 -0
- package/dist/services/dntServiceManager.d.ts +44 -0
- package/dist/services/dntServiceManager.d.ts.map +1 -0
- package/dist/services/dntServiceManager.js +74 -0
- package/dist/services/dntServiceManager.js.map +1 -0
- package/dist/services/dntStorageAdapter.d.ts +73 -0
- package/dist/services/dntStorageAdapter.d.ts.map +1 -0
- package/dist/services/dntStorageAdapter.js +192 -0
- package/dist/services/dntStorageAdapter.js.map +1 -0
- package/dist/services/documentCreationService.d.ts +139 -0
- package/dist/services/documentCreationService.d.ts.map +1 -0
- package/dist/services/documentCreationService.js +938 -0
- package/dist/services/documentCreationService.js.map +1 -0
- package/dist/services/localeService.d.ts +160 -0
- package/dist/services/localeService.d.ts.map +1 -0
- package/dist/services/localeService.js +300 -0
- package/dist/services/localeService.js.map +1 -0
- package/dist/services/localeStorageAdapter.d.ts +42 -0
- package/dist/services/localeStorageAdapter.d.ts.map +1 -0
- package/dist/services/localeStorageAdapter.js +107 -0
- package/dist/services/localeStorageAdapter.js.map +1 -0
- package/dist/services/oauthConfigStorage.d.ts +46 -0
- package/dist/services/oauthConfigStorage.d.ts.map +1 -0
- package/dist/services/oauthConfigStorage.js +122 -0
- package/dist/services/oauthConfigStorage.js.map +1 -0
- package/dist/services/oauthService.d.ts +48 -0
- package/dist/services/oauthService.d.ts.map +1 -0
- package/dist/services/oauthService.js +71 -0
- package/dist/services/oauthService.js.map +1 -0
- package/dist/services/oauthServiceManager.d.ts +189 -0
- package/dist/services/oauthServiceManager.d.ts.map +1 -0
- package/dist/services/oauthServiceManager.js +380 -0
- package/dist/services/oauthServiceManager.js.map +1 -0
- package/dist/services/tokenStorage.d.ts +54 -0
- package/dist/services/tokenStorage.d.ts.map +1 -0
- package/dist/services/tokenStorage.js +140 -0
- package/dist/services/tokenStorage.js.map +1 -0
- package/dist/services/translationService.d.ts +374 -0
- package/dist/services/translationService.d.ts.map +1 -0
- package/dist/services/translationService.js +687 -0
- package/dist/services/translationService.js.map +1 -0
- package/dist/services/unifiedConfigStorage.d.ts +124 -0
- package/dist/services/unifiedConfigStorage.d.ts.map +1 -0
- package/dist/services/unifiedConfigStorage.js +304 -0
- package/dist/services/unifiedConfigStorage.js.map +1 -0
- package/dist/test-utils.d.ts +9 -0
- package/dist/test-utils.d.ts.map +1 -0
- package/dist/test-utils.js +13 -0
- package/dist/test-utils.js.map +1 -0
- package/dist/types/dialog.d.ts +107 -0
- package/dist/types/dialog.d.ts.map +1 -0
- package/dist/types/dialog.js +6 -0
- package/dist/types/dialog.js.map +1 -0
- package/dist/types/dnt.d.ts +84 -0
- package/dist/types/dnt.d.ts.map +1 -0
- package/dist/types/dnt.js +5 -0
- package/dist/types/dnt.js.map +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/locale.d.ts +116 -0
- package/dist/types/locale.d.ts.map +1 -0
- package/dist/types/locale.js +189 -0
- package/dist/types/locale.js.map +1 -0
- package/dist/types/oauth.d.ts +90 -0
- package/dist/types/oauth.d.ts.map +1 -0
- package/dist/types/oauth.js +62 -0
- package/dist/types/oauth.js.map +1 -0
- package/dist/types/pluginConfig.d.ts +45 -0
- package/dist/types/pluginConfig.d.ts.map +1 -0
- package/dist/types/pluginConfig.js +6 -0
- package/dist/types/pluginConfig.js.map +1 -0
- package/dist/types/translation.d.ts +122 -0
- package/dist/types/translation.d.ts.map +1 -0
- package/dist/types/translation.js +6 -0
- package/dist/types/translation.js.map +1 -0
- package/dist/utils/htmlFormatter.d.ts +66 -0
- package/dist/utils/htmlFormatter.d.ts.map +1 -0
- package/dist/utils/htmlFormatter.js +191 -0
- package/dist/utils/htmlFormatter.js.map +1 -0
- package/dist/utils/index.d.ts +15 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +16 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +105 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +229 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/oauthErrorFeedback.d.ts +76 -0
- package/dist/utils/oauthErrorFeedback.d.ts.map +1 -0
- package/dist/utils/oauthErrorFeedback.js +134 -0
- package/dist/utils/oauthErrorFeedback.js.map +1 -0
- package/dist/utils/oauthLogger.d.ts +176 -0
- package/dist/utils/oauthLogger.d.ts.map +1 -0
- package/dist/utils/oauthLogger.js +282 -0
- package/dist/utils/oauthLogger.js.map +1 -0
- package/dist/utils/validator.d.ts +67 -0
- package/dist/utils/validator.d.ts.map +1 -0
- package/dist/utils/validator.js +390 -0
- package/dist/utils/validator.js.map +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logging utilities with structured output
|
|
3
|
+
* Requirements: 4.3 - Clear error messages and structured logging
|
|
4
|
+
*/
|
|
5
|
+
export var LogLevel;
|
|
6
|
+
(function (LogLevel) {
|
|
7
|
+
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
|
|
8
|
+
LogLevel[LogLevel["INFO"] = 1] = "INFO";
|
|
9
|
+
LogLevel[LogLevel["WARN"] = 2] = "WARN";
|
|
10
|
+
LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
|
|
11
|
+
})(LogLevel || (LogLevel = {}));
|
|
12
|
+
export class Logger {
|
|
13
|
+
constructor(config = {}) {
|
|
14
|
+
this.config = {
|
|
15
|
+
level: LogLevel.INFO,
|
|
16
|
+
enableConsole: true,
|
|
17
|
+
enableStructuredOutput: true,
|
|
18
|
+
...config
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Log debug message
|
|
23
|
+
*/
|
|
24
|
+
debug(message, context) {
|
|
25
|
+
this.log(LogLevel.DEBUG, message, context);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Log info message
|
|
29
|
+
*/
|
|
30
|
+
info(message, context) {
|
|
31
|
+
this.log(LogLevel.INFO, message, context);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Log warning message
|
|
35
|
+
*/
|
|
36
|
+
warn(message, context) {
|
|
37
|
+
this.log(LogLevel.WARN, message, context);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Log error message
|
|
41
|
+
* Requirement 4.3: Display clear error messages
|
|
42
|
+
*/
|
|
43
|
+
error(message, error, context) {
|
|
44
|
+
this.log(LogLevel.ERROR, message, context, error);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Log translation request with structured format
|
|
48
|
+
* Requirements: 1.3, 2.4 - Log request body to console for verification
|
|
49
|
+
*/
|
|
50
|
+
logTranslationRequest(documentId, endpoint, payload) {
|
|
51
|
+
this.info('Translation request prepared', {
|
|
52
|
+
documentId,
|
|
53
|
+
endpoint,
|
|
54
|
+
payloadSize: JSON.stringify(payload).length,
|
|
55
|
+
contentLength: payload.content?.body?.length || 0,
|
|
56
|
+
title: payload.metadata?.title || 'Unknown',
|
|
57
|
+
documentType: payload.metadata?.documentType || 'Unknown'
|
|
58
|
+
});
|
|
59
|
+
if (this.config.enableStructuredOutput) {
|
|
60
|
+
console.log('Translation Request Payload:', {
|
|
61
|
+
timestamp: new Date().toISOString(),
|
|
62
|
+
documentId,
|
|
63
|
+
endpoint,
|
|
64
|
+
payload
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Log bulk translation summary
|
|
70
|
+
* Requirement 2.5: Display summary of processed documents
|
|
71
|
+
*/
|
|
72
|
+
logBulkTranslationSummary(summary) {
|
|
73
|
+
const successRate = summary.totalDocuments > 0
|
|
74
|
+
? ((summary.processedDocuments / summary.totalDocuments) * 100).toFixed(2)
|
|
75
|
+
: '0';
|
|
76
|
+
this.info('Bulk translation completed', {
|
|
77
|
+
totalDocuments: summary.totalDocuments,
|
|
78
|
+
processedDocuments: summary.processedDocuments,
|
|
79
|
+
failedDocuments: summary.failedDocuments,
|
|
80
|
+
successRate: `${successRate}%`,
|
|
81
|
+
duration: summary.duration ? `${summary.duration}ms` : undefined
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Log document processing progress
|
|
86
|
+
*/
|
|
87
|
+
logProgress(current, total, documentId) {
|
|
88
|
+
const percentage = total > 0 ? ((current / total) * 100).toFixed(1) : '0';
|
|
89
|
+
this.debug(`Processing progress: ${current}/${total} (${percentage}%)`, {
|
|
90
|
+
current,
|
|
91
|
+
total,
|
|
92
|
+
percentage: `${percentage}%`,
|
|
93
|
+
documentId
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Log validation errors
|
|
98
|
+
* Requirement 4.3: Clear error messages for validation failures
|
|
99
|
+
*/
|
|
100
|
+
logValidationError(type, errors, context) {
|
|
101
|
+
this.error(`Validation failed for ${type}`, undefined, {
|
|
102
|
+
validationType: type,
|
|
103
|
+
errors,
|
|
104
|
+
errorCount: errors.length,
|
|
105
|
+
...context
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Log performance metrics
|
|
110
|
+
*/
|
|
111
|
+
logPerformance(operation, duration, context) {
|
|
112
|
+
this.info(`Performance: ${operation}`, {
|
|
113
|
+
operation,
|
|
114
|
+
duration: `${duration}ms`,
|
|
115
|
+
...context
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Core logging method
|
|
120
|
+
*/
|
|
121
|
+
log(level, message, context, error) {
|
|
122
|
+
if (level < this.config.level) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const entry = {
|
|
126
|
+
timestamp: new Date().toISOString(),
|
|
127
|
+
level,
|
|
128
|
+
message: this.config.prefix ? `[${this.config.prefix}] ${message}` : message,
|
|
129
|
+
context,
|
|
130
|
+
error
|
|
131
|
+
};
|
|
132
|
+
if (this.config.enableConsole) {
|
|
133
|
+
this.outputToConsole(entry);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Output log entry to console with appropriate formatting
|
|
138
|
+
*/
|
|
139
|
+
outputToConsole(entry) {
|
|
140
|
+
const levelName = LogLevel[entry.level];
|
|
141
|
+
const timestamp = entry.timestamp;
|
|
142
|
+
if (this.config.enableStructuredOutput) {
|
|
143
|
+
// Structured output for debugging
|
|
144
|
+
const logData = {
|
|
145
|
+
timestamp,
|
|
146
|
+
level: levelName,
|
|
147
|
+
message: entry.message,
|
|
148
|
+
...(entry.context && { context: entry.context }),
|
|
149
|
+
...(entry.error && { error: this.serializeError(entry.error) })
|
|
150
|
+
};
|
|
151
|
+
switch (entry.level) {
|
|
152
|
+
case LogLevel.DEBUG:
|
|
153
|
+
console.debug('🔍', logData);
|
|
154
|
+
break;
|
|
155
|
+
case LogLevel.INFO:
|
|
156
|
+
console.info('ℹ️', logData);
|
|
157
|
+
break;
|
|
158
|
+
case LogLevel.WARN:
|
|
159
|
+
console.warn('⚠️', logData);
|
|
160
|
+
break;
|
|
161
|
+
case LogLevel.ERROR:
|
|
162
|
+
console.error('❌', logData);
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
// Simple console output
|
|
168
|
+
const contextStr = entry.context ? ` ${JSON.stringify(entry.context)}` : '';
|
|
169
|
+
const errorStr = entry.error ? ` Error: ${entry.error.message}` : '';
|
|
170
|
+
switch (entry.level) {
|
|
171
|
+
case LogLevel.DEBUG:
|
|
172
|
+
console.debug(`[${timestamp}] DEBUG: ${entry.message}${contextStr}${errorStr}`);
|
|
173
|
+
break;
|
|
174
|
+
case LogLevel.INFO:
|
|
175
|
+
console.info(`[${timestamp}] INFO: ${entry.message}${contextStr}${errorStr}`);
|
|
176
|
+
break;
|
|
177
|
+
case LogLevel.WARN:
|
|
178
|
+
console.warn(`[${timestamp}] WARN: ${entry.message}${contextStr}${errorStr}`);
|
|
179
|
+
break;
|
|
180
|
+
case LogLevel.ERROR:
|
|
181
|
+
console.error(`[${timestamp}] ERROR: ${entry.message}${contextStr}${errorStr}`);
|
|
182
|
+
if (entry.error && entry.error.stack) {
|
|
183
|
+
console.error(entry.error.stack);
|
|
184
|
+
}
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Serialize error object for logging
|
|
191
|
+
*/
|
|
192
|
+
serializeError(error) {
|
|
193
|
+
return {
|
|
194
|
+
name: error.name,
|
|
195
|
+
message: error.message,
|
|
196
|
+
stack: error.stack,
|
|
197
|
+
...(error.cause ? { cause: error.cause } : {})
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Update logger configuration
|
|
202
|
+
*/
|
|
203
|
+
updateConfig(config) {
|
|
204
|
+
this.config = { ...this.config, ...config };
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Get current configuration
|
|
208
|
+
*/
|
|
209
|
+
getConfig() {
|
|
210
|
+
return { ...this.config };
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
// Create default logger instance
|
|
214
|
+
export const defaultLogger = new Logger({
|
|
215
|
+
prefix: 'SanityTranslation'
|
|
216
|
+
});
|
|
217
|
+
// Export convenience functions for backward compatibility
|
|
218
|
+
export const logger = {
|
|
219
|
+
debug: (message, context) => defaultLogger.debug(message, context),
|
|
220
|
+
info: (message, context) => defaultLogger.info(message, context),
|
|
221
|
+
warn: (message, context) => defaultLogger.warn(message, context),
|
|
222
|
+
error: (message, error, context) => defaultLogger.error(message, error, context),
|
|
223
|
+
logTranslationRequest: (documentId, endpoint, payload) => defaultLogger.logTranslationRequest(documentId, endpoint, payload),
|
|
224
|
+
logBulkTranslationSummary: (summary) => defaultLogger.logBulkTranslationSummary(summary),
|
|
225
|
+
logProgress: (current, total, documentId) => defaultLogger.logProgress(current, total, documentId),
|
|
226
|
+
logValidationError: (type, errors, context) => defaultLogger.logValidationError(type, errors, context),
|
|
227
|
+
logPerformance: (operation, duration, context) => defaultLogger.logPerformance(operation, duration, context)
|
|
228
|
+
};
|
|
229
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","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AE,EAAE,CACnE,aAAa,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC;IACvD,kBAAkB,EAAE,CAAC,IAAY,EAAE,MAAgB,EAAE,OAA6B,EAAE,EAAE,CACpF,aAAa,CAAC,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC;IACzD,cAAc,EAAE,CAAC,SAAiB,EAAE,QAAgB,EAAE,OAA6B,EAAE,EAAE,CACrF,aAAa,CAAC,cAAc,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC;CAC7D,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth Error Feedback Utility
|
|
3
|
+
*
|
|
4
|
+
* Provides user-friendly error feedback for OAuth authentication errors
|
|
5
|
+
* using Sanity UI toast notifications and dialogs.
|
|
6
|
+
*
|
|
7
|
+
* Requirements: 7.2, 7.3, 7.4
|
|
8
|
+
*/
|
|
9
|
+
import { OAuthError, OAuthErrorType } from '../types/oauth';
|
|
10
|
+
import { DialogService } from '../services/dialogService';
|
|
11
|
+
/**
|
|
12
|
+
* OAuth Error Feedback Handler
|
|
13
|
+
*
|
|
14
|
+
* Provides methods for displaying user-friendly error messages
|
|
15
|
+
* with appropriate help text and retry options.
|
|
16
|
+
*/
|
|
17
|
+
export declare class OAuthErrorFeedback {
|
|
18
|
+
private dialogService;
|
|
19
|
+
/**
|
|
20
|
+
* Create a new OAuth error feedback handler
|
|
21
|
+
*
|
|
22
|
+
* @param dialogService - Dialog service instance
|
|
23
|
+
*/
|
|
24
|
+
constructor(dialogService: DialogService);
|
|
25
|
+
/**
|
|
26
|
+
* Show an error dialog for an OAuth error
|
|
27
|
+
*
|
|
28
|
+
* Requirements: 7.2, 7.3, 7.4
|
|
29
|
+
*
|
|
30
|
+
* @param error - OAuth error to display
|
|
31
|
+
* @param onRetry - Optional callback for retry action
|
|
32
|
+
* @returns Promise that resolves to true if user clicked retry, false otherwise
|
|
33
|
+
*/
|
|
34
|
+
showError(error: OAuthError, onRetry?: () => void): Promise<boolean>;
|
|
35
|
+
/**
|
|
36
|
+
* Show an error dialog for a generic error
|
|
37
|
+
*
|
|
38
|
+
* Requirements: 7.2, 7.3
|
|
39
|
+
*
|
|
40
|
+
* @param message - Error message to display
|
|
41
|
+
* @param details - Optional additional details
|
|
42
|
+
* @param showRetry - Whether to show retry button
|
|
43
|
+
* @param onRetry - Optional callback for retry action
|
|
44
|
+
* @returns Promise that resolves to true if user clicked retry, false otherwise
|
|
45
|
+
*/
|
|
46
|
+
showGenericError(message: string, details?: string, showRetry?: boolean, onRetry?: () => void): Promise<boolean>;
|
|
47
|
+
/**
|
|
48
|
+
* Show a success message
|
|
49
|
+
*
|
|
50
|
+
* @param message - Success message to display
|
|
51
|
+
* @param details - Optional additional details
|
|
52
|
+
*/
|
|
53
|
+
showSuccess(message: string, details?: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* Get help text for a specific error type
|
|
56
|
+
*
|
|
57
|
+
* @param errorType - OAuth error type
|
|
58
|
+
* @returns Help text for the error type
|
|
59
|
+
*/
|
|
60
|
+
getHelpText(errorType: OAuthErrorType): string;
|
|
61
|
+
/**
|
|
62
|
+
* Format an error for logging (sanitizes sensitive data)
|
|
63
|
+
*
|
|
64
|
+
* @param error - Error to format
|
|
65
|
+
* @returns Formatted error object safe for logging
|
|
66
|
+
*/
|
|
67
|
+
formatErrorForLogging(error: OAuthError): Record<string, unknown>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Create an OAuth error feedback handler
|
|
71
|
+
*
|
|
72
|
+
* @param dialogService - Dialog service instance
|
|
73
|
+
* @returns OAuth error feedback handler
|
|
74
|
+
*/
|
|
75
|
+
export declare function createOAuthErrorFeedback(dialogService: DialogService): OAuthErrorFeedback;
|
|
76
|
+
//# sourceMappingURL=oauthErrorFeedback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauthErrorFeedback.d.ts","sourceRoot":"","sources":["../../src/utils/oauthErrorFeedback.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAmB1D;;;;;GAKG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,aAAa,CAAgB;IAErC;;;;OAIG;gBACS,aAAa,EAAE,aAAa;IAIxC;;;;;;;;OAQG;IACG,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC;IAsB1E;;;;;;;;;;OAUG;IACG,gBAAgB,CACpB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,EAChB,SAAS,GAAE,OAAc,EACzB,OAAO,CAAC,EAAE,MAAM,IAAI,GACnB,OAAO,CAAC,OAAO,CAAC;IAkBnB;;;;;OAKG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAUpD;;;;;OAKG;IACH,WAAW,CAAC,SAAS,EAAE,cAAc,GAAG,MAAM;IAI9C;;;;;OAKG;IACH,qBAAqB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAUlE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,aAAa,EAAE,aAAa,GAAG,kBAAkB,CAEzF"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth Error Feedback Utility
|
|
3
|
+
*
|
|
4
|
+
* Provides user-friendly error feedback for OAuth authentication errors
|
|
5
|
+
* using Sanity UI toast notifications and dialogs.
|
|
6
|
+
*
|
|
7
|
+
* Requirements: 7.2, 7.3, 7.4
|
|
8
|
+
*/
|
|
9
|
+
import { OAuthErrorType } from '../types/oauth';
|
|
10
|
+
/**
|
|
11
|
+
* Error help text for common authentication error scenarios
|
|
12
|
+
*/
|
|
13
|
+
const ERROR_HELP_TEXT = {
|
|
14
|
+
[OAuthErrorType.INVALID_CONFIG]: 'Please check your Easyling configuration. Make sure your access token and project ID are correct.',
|
|
15
|
+
[OAuthErrorType.NETWORK_ERROR]: 'Please check your internet connection and try again. If the problem persists, the service may be temporarily unavailable.',
|
|
16
|
+
[OAuthErrorType.AUTH_FAILED]: 'Authentication failed. Please check your access token in the Easyling Configuration.',
|
|
17
|
+
[OAuthErrorType.STORAGE_ERROR]: 'There was a problem saving your authentication data. Please check your browser settings and try again.'
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* OAuth Error Feedback Handler
|
|
21
|
+
*
|
|
22
|
+
* Provides methods for displaying user-friendly error messages
|
|
23
|
+
* with appropriate help text and retry options.
|
|
24
|
+
*/
|
|
25
|
+
export class OAuthErrorFeedback {
|
|
26
|
+
/**
|
|
27
|
+
* Create a new OAuth error feedback handler
|
|
28
|
+
*
|
|
29
|
+
* @param dialogService - Dialog service instance
|
|
30
|
+
*/
|
|
31
|
+
constructor(dialogService) {
|
|
32
|
+
this.dialogService = dialogService;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Show an error dialog for an OAuth error
|
|
36
|
+
*
|
|
37
|
+
* Requirements: 7.2, 7.3, 7.4
|
|
38
|
+
*
|
|
39
|
+
* @param error - OAuth error to display
|
|
40
|
+
* @param onRetry - Optional callback for retry action
|
|
41
|
+
* @returns Promise that resolves to true if user clicked retry, false otherwise
|
|
42
|
+
*/
|
|
43
|
+
async showError(error, onRetry) {
|
|
44
|
+
const userMessage = error.getUserMessage();
|
|
45
|
+
const helpText = ERROR_HELP_TEXT[error.type] || 'Please try again.';
|
|
46
|
+
const isRecoverable = error.isRecoverable();
|
|
47
|
+
// Combine user message and help text
|
|
48
|
+
const fullMessage = `${userMessage}\n\n${helpText}`;
|
|
49
|
+
const result = await this.dialogService.showError({
|
|
50
|
+
title: 'Authentication Error',
|
|
51
|
+
message: fullMessage,
|
|
52
|
+
showRetry: isRecoverable
|
|
53
|
+
});
|
|
54
|
+
// If user clicked retry and callback provided, call it
|
|
55
|
+
if (result && onRetry) {
|
|
56
|
+
onRetry();
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Show an error dialog for a generic error
|
|
62
|
+
*
|
|
63
|
+
* Requirements: 7.2, 7.3
|
|
64
|
+
*
|
|
65
|
+
* @param message - Error message to display
|
|
66
|
+
* @param details - Optional additional details
|
|
67
|
+
* @param showRetry - Whether to show retry button
|
|
68
|
+
* @param onRetry - Optional callback for retry action
|
|
69
|
+
* @returns Promise that resolves to true if user clicked retry, false otherwise
|
|
70
|
+
*/
|
|
71
|
+
async showGenericError(message, details, showRetry = true, onRetry) {
|
|
72
|
+
// Combine message and details if provided
|
|
73
|
+
const fullMessage = details ? `${message}\n\n${details}` : message;
|
|
74
|
+
const result = await this.dialogService.showError({
|
|
75
|
+
title: 'Error',
|
|
76
|
+
message: fullMessage,
|
|
77
|
+
showRetry
|
|
78
|
+
});
|
|
79
|
+
// If user clicked retry and callback provided, call it
|
|
80
|
+
if (result && onRetry) {
|
|
81
|
+
onRetry();
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Show a success message
|
|
87
|
+
*
|
|
88
|
+
* @param message - Success message to display
|
|
89
|
+
* @param details - Optional additional details
|
|
90
|
+
*/
|
|
91
|
+
showSuccess(message, details) {
|
|
92
|
+
// Combine message and details if provided
|
|
93
|
+
const fullMessage = details ? `${message}\n\n${details}` : message;
|
|
94
|
+
this.dialogService.showSuccess({
|
|
95
|
+
title: 'Success',
|
|
96
|
+
message: fullMessage
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get help text for a specific error type
|
|
101
|
+
*
|
|
102
|
+
* @param errorType - OAuth error type
|
|
103
|
+
* @returns Help text for the error type
|
|
104
|
+
*/
|
|
105
|
+
getHelpText(errorType) {
|
|
106
|
+
return ERROR_HELP_TEXT[errorType] || 'Please try again.';
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Format an error for logging (sanitizes sensitive data)
|
|
110
|
+
*
|
|
111
|
+
* @param error - Error to format
|
|
112
|
+
* @returns Formatted error object safe for logging
|
|
113
|
+
*/
|
|
114
|
+
formatErrorForLogging(error) {
|
|
115
|
+
return {
|
|
116
|
+
type: error.type,
|
|
117
|
+
message: error.message,
|
|
118
|
+
name: error.name,
|
|
119
|
+
isRecoverable: error.isRecoverable(),
|
|
120
|
+
// Don't include details as they might contain sensitive data
|
|
121
|
+
hasDetails: !!error.details
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Create an OAuth error feedback handler
|
|
127
|
+
*
|
|
128
|
+
* @param dialogService - Dialog service instance
|
|
129
|
+
* @returns OAuth error feedback handler
|
|
130
|
+
*/
|
|
131
|
+
export function createOAuthErrorFeedback(dialogService) {
|
|
132
|
+
return new OAuthErrorFeedback(dialogService);
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=oauthErrorFeedback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauthErrorFeedback.js","sourceRoot":"","sources":["../../src/utils/oauthErrorFeedback.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAc,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAG5D;;GAEG;AACH,MAAM,eAAe,GAAmC;IACtD,CAAC,cAAc,CAAC,cAAc,CAAC,EAC7B,mGAAmG;IAErG,CAAC,cAAc,CAAC,aAAa,CAAC,EAC5B,2HAA2H;IAE7H,CAAC,cAAc,CAAC,WAAW,CAAC,EAC1B,sFAAsF;IAExF,CAAC,cAAc,CAAC,aAAa,CAAC,EAC5B,wGAAwG;CAC3G,CAAC;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MAAM,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACH,WAAW,CAAC,OAAe,EAAE,OAAgB;QAC3C,0CAA0C;QAC1C,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,OAAO,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;QAEnE,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC;YAC7B,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE,WAAW;SACrB,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,WAAW,CAAC,SAAyB;QACnC,OAAO,eAAe,CAAC,SAAS,CAAC,IAAI,mBAAmB,CAAC;IAC3D,CAAC;IAED;;;;;OAKG;IACH,qBAAqB,CAAC,KAAiB;QACrC,OAAO;YACL,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,aAAa,EAAE,KAAK,CAAC,aAAa,EAAE;YACpC,6DAA6D;YAC7D,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO;SAC5B,CAAC;IACJ,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,aAA4B;IACnE,OAAO,IAAI,kBAAkB,CAAC,aAAa,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth Logger Utility
|
|
3
|
+
*
|
|
4
|
+
* Provides structured logging for OAuth authentication events with timestamps
|
|
5
|
+
* and component identification. Never logs sensitive data like tokens or secrets.
|
|
6
|
+
*
|
|
7
|
+
* Requirements: 7.1, 8.5
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Log level enumeration
|
|
11
|
+
*/
|
|
12
|
+
export declare enum LogLevel {
|
|
13
|
+
INFO = "info",
|
|
14
|
+
WARN = "warn",
|
|
15
|
+
ERROR = "error"
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* OAuth component identifier
|
|
19
|
+
*/
|
|
20
|
+
export type OAuthComponent = 'OAuthService' | 'TokenStorage' | 'AuthStateManager' | 'OAuthCallback' | 'AuthStatus' | 'TranslationService';
|
|
21
|
+
/**
|
|
22
|
+
* OAuth log entry structure
|
|
23
|
+
*/
|
|
24
|
+
export interface OAuthLogEntry {
|
|
25
|
+
/** ISO timestamp of the log entry */
|
|
26
|
+
timestamp: string;
|
|
27
|
+
/** Log level */
|
|
28
|
+
level: LogLevel;
|
|
29
|
+
/** Component that generated the log */
|
|
30
|
+
component: OAuthComponent;
|
|
31
|
+
/** Event name or description */
|
|
32
|
+
event: string;
|
|
33
|
+
/** Optional additional details (never contains sensitive data) */
|
|
34
|
+
details?: Record<string, unknown>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* OAuth Logger
|
|
38
|
+
*
|
|
39
|
+
* Provides structured logging methods for OAuth-related events.
|
|
40
|
+
* Automatically sanitizes sensitive data from log output.
|
|
41
|
+
*/
|
|
42
|
+
export declare class OAuthLogger {
|
|
43
|
+
private component;
|
|
44
|
+
/**
|
|
45
|
+
* Create a new OAuth logger for a specific component
|
|
46
|
+
*
|
|
47
|
+
* @param component - Component identifier
|
|
48
|
+
*/
|
|
49
|
+
constructor(component: OAuthComponent);
|
|
50
|
+
/**
|
|
51
|
+
* Sanitize details object to remove sensitive data
|
|
52
|
+
*
|
|
53
|
+
* @param details - Details object to sanitize
|
|
54
|
+
* @returns Sanitized details object
|
|
55
|
+
*/
|
|
56
|
+
private sanitizeDetails;
|
|
57
|
+
/**
|
|
58
|
+
* Create a log entry
|
|
59
|
+
*
|
|
60
|
+
* @param level - Log level
|
|
61
|
+
* @param event - Event name
|
|
62
|
+
* @param details - Optional details
|
|
63
|
+
* @returns OAuth log entry
|
|
64
|
+
*/
|
|
65
|
+
private createLogEntry;
|
|
66
|
+
/**
|
|
67
|
+
* Format log entry for console output
|
|
68
|
+
*
|
|
69
|
+
* @param entry - OAuth log entry to format
|
|
70
|
+
* @returns Formatted log message
|
|
71
|
+
*/
|
|
72
|
+
private formatLogEntry;
|
|
73
|
+
/**
|
|
74
|
+
* Log an info-level event
|
|
75
|
+
*
|
|
76
|
+
* @param event - Event name
|
|
77
|
+
* @param details - Optional details
|
|
78
|
+
*/
|
|
79
|
+
info(event: string, details?: Record<string, unknown>): void;
|
|
80
|
+
/**
|
|
81
|
+
* Log a warning-level event
|
|
82
|
+
*
|
|
83
|
+
* @param event - Event name
|
|
84
|
+
* @param details - Optional details
|
|
85
|
+
*/
|
|
86
|
+
warn(event: string, details?: Record<string, unknown>): void;
|
|
87
|
+
/**
|
|
88
|
+
* Log an error-level event
|
|
89
|
+
*
|
|
90
|
+
* @param event - Event name
|
|
91
|
+
* @param details - Optional details
|
|
92
|
+
*/
|
|
93
|
+
error(event: string, details?: Record<string, unknown>): void;
|
|
94
|
+
/**
|
|
95
|
+
* Log OAuth flow initiation
|
|
96
|
+
*
|
|
97
|
+
* @param authUrl - Authorization URL (without sensitive params)
|
|
98
|
+
*/
|
|
99
|
+
logFlowInitiation(authUrl: string): void;
|
|
100
|
+
/**
|
|
101
|
+
* Log OAuth callback received
|
|
102
|
+
*
|
|
103
|
+
* @param hasCode - Whether authorization code was received
|
|
104
|
+
* @param hasError - Whether error was received
|
|
105
|
+
* @param projectId - Project ID if available
|
|
106
|
+
*/
|
|
107
|
+
logCallbackReceived(hasCode: boolean, hasError: boolean, projectId?: string): void;
|
|
108
|
+
/**
|
|
109
|
+
* Log token exchange attempt
|
|
110
|
+
*/
|
|
111
|
+
logTokenExchange(): void;
|
|
112
|
+
/**
|
|
113
|
+
* Log token exchange success
|
|
114
|
+
*
|
|
115
|
+
* @param expiresIn - Token expiration time in seconds
|
|
116
|
+
* @param hasRefreshToken - Whether refresh token was received
|
|
117
|
+
*/
|
|
118
|
+
logTokenExchangeSuccess(expiresIn: number, hasRefreshToken: boolean): void;
|
|
119
|
+
/**
|
|
120
|
+
* Log token exchange failure
|
|
121
|
+
*
|
|
122
|
+
* @param error - Error message
|
|
123
|
+
* @param statusCode - HTTP status code if available
|
|
124
|
+
*/
|
|
125
|
+
logTokenExchangeFailure(error: string, statusCode?: number): void;
|
|
126
|
+
/**
|
|
127
|
+
* Log token refresh attempt
|
|
128
|
+
*/
|
|
129
|
+
logTokenRefresh(): void;
|
|
130
|
+
/**
|
|
131
|
+
* Log token refresh success
|
|
132
|
+
*
|
|
133
|
+
* @param expiresIn - New token expiration time in seconds
|
|
134
|
+
*/
|
|
135
|
+
logTokenRefreshSuccess(expiresIn: number): void;
|
|
136
|
+
/**
|
|
137
|
+
* Log token refresh failure
|
|
138
|
+
*
|
|
139
|
+
* @param error - Error message
|
|
140
|
+
*/
|
|
141
|
+
logTokenRefreshFailure(error: string): void;
|
|
142
|
+
/**
|
|
143
|
+
* Log authentication state change
|
|
144
|
+
*
|
|
145
|
+
* @param fromState - Previous state
|
|
146
|
+
* @param toState - New state
|
|
147
|
+
* @param projectId - Project ID if available
|
|
148
|
+
*/
|
|
149
|
+
logStateChange(fromState: string, toState: string, projectId?: string): void;
|
|
150
|
+
/**
|
|
151
|
+
* Log logout event
|
|
152
|
+
*/
|
|
153
|
+
logLogout(): void;
|
|
154
|
+
/**
|
|
155
|
+
* Log storage operation
|
|
156
|
+
*
|
|
157
|
+
* @param operation - Operation type (store, retrieve, clear)
|
|
158
|
+
* @param success - Whether operation succeeded
|
|
159
|
+
*/
|
|
160
|
+
logStorageOperation(operation: 'store' | 'retrieve' | 'clear', success: boolean): void;
|
|
161
|
+
/**
|
|
162
|
+
* Sanitize URL to remove sensitive query parameters
|
|
163
|
+
*
|
|
164
|
+
* @param url - URL to sanitize
|
|
165
|
+
* @returns Sanitized URL string
|
|
166
|
+
*/
|
|
167
|
+
private sanitizeUrl;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Create a logger instance for a specific component
|
|
171
|
+
*
|
|
172
|
+
* @param component - Component identifier
|
|
173
|
+
* @returns Logger instance
|
|
174
|
+
*/
|
|
175
|
+
export declare function createOAuthLogger(component: OAuthComponent): OAuthLogger;
|
|
176
|
+
//# sourceMappingURL=oauthLogger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauthLogger.d.ts","sourceRoot":"","sources":["../../src/utils/oauthLogger.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,oBAAY,QAAQ;IAClB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GACtB,cAAc,GACd,cAAc,GACd,kBAAkB,GAClB,eAAe,GACf,YAAY,GACZ,oBAAoB,CAAC;AAEzB;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAElB,gBAAgB;IAChB,KAAK,EAAE,QAAQ,CAAC;IAEhB,uCAAuC;IACvC,SAAS,EAAE,cAAc,CAAC;IAE1B,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IAEd,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAqBD;;;;;GAKG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,SAAS,CAAiB;IAElC;;;;OAIG;gBACS,SAAS,EAAE,cAAc;IAIrC;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IA0BvB;;;;;;;OAOG;IACH,OAAO,CAAC,cAAc;IActB;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAOtB;;;;;OAKG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAK5D;;;;;OAKG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAA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