@easyling/sanity-connector 0.0.2-rc.1 → 0.0.2-rc.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.
Files changed (64) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/index.js +2 -0
  3. package/dist/index.js.LICENSE.txt +28 -0
  4. package/dist-types/actions/bulkTranslate.d.ts +6 -0
  5. package/dist-types/actions/manageDNTFields.d.ts +11 -0
  6. package/dist-types/actions/translateDocument.d.ts +6 -0
  7. package/dist-types/components/RadioWithDefault.d.ts +16 -0
  8. package/dist-types/components/auth/AuthNavbar.d.ts +17 -0
  9. package/dist-types/components/auth/AuthStatus.d.ts +26 -0
  10. package/dist-types/components/auth/AuthStatusWrapper.d.ts +14 -0
  11. package/dist-types/components/auth/MigrationPrompt.d.ts +19 -0
  12. package/dist-types/components/auth/MigrationPromptWrapper.d.ts +13 -0
  13. package/dist-types/components/auth/OAuthCallback.d.ts +19 -0
  14. package/dist-types/components/auth/index.d.ts +14 -0
  15. package/dist-types/components/config/LocaleConfigTool.d.ts +16 -0
  16. package/dist-types/components/config/LocaleConfigToolWrapper.d.ts +12 -0
  17. package/dist-types/components/config/OAuthConfig.d.ts +25 -0
  18. package/dist-types/components/config/OAuthConfigWrapper.d.ts +12 -0
  19. package/dist-types/components/config/PasswordInput.d.ts +13 -0
  20. package/dist-types/components/config/index.d.ts +8 -0
  21. package/dist-types/components/config/localeConfigToolDefinition.d.ts +12 -0
  22. package/dist-types/components/config/oauthConfigToolDefinition.d.ts +12 -0
  23. package/dist-types/components/dialogs/ConfirmationDialog.d.ts +20 -0
  24. package/dist-types/components/dialogs/ErrorDialog.d.ts +20 -0
  25. package/dist-types/components/dialogs/LocaleSelectionDialog.d.ts +40 -0
  26. package/dist-types/components/dialogs/SuccessDialog.d.ts +18 -0
  27. package/dist-types/components/dialogs/index.d.ts +11 -0
  28. package/dist-types/components/dnt/DNTFieldBadge.d.ts +15 -0
  29. package/dist-types/components/dnt/DNTFieldComponent.d.ts +16 -0
  30. package/dist-types/components/dnt/DNTFieldInput.d.ts +13 -0
  31. package/dist-types/components/dnt/index.d.ts +6 -0
  32. package/dist-types/config/index.d.ts +5 -0
  33. package/dist-types/config/pluginConfig.d.ts +162 -0
  34. package/dist-types/index.d.ts +11 -0
  35. package/dist-types/plugin.d.ts +2 -0
  36. package/dist-types/services/authStateManager.d.ts +93 -0
  37. package/dist-types/services/contentExtractor.d.ts +94 -0
  38. package/dist-types/services/dialogService.d.ts +95 -0
  39. package/dist-types/services/dntServiceManager.d.ts +43 -0
  40. package/dist-types/services/dntStorageAdapter.d.ts +72 -0
  41. package/dist-types/services/documentCreationService.d.ts +138 -0
  42. package/dist-types/services/localeService.d.ts +159 -0
  43. package/dist-types/services/localeStorageAdapter.d.ts +41 -0
  44. package/dist-types/services/oauthConfigStorage.d.ts +45 -0
  45. package/dist-types/services/oauthService.d.ts +47 -0
  46. package/dist-types/services/oauthServiceManager.d.ts +188 -0
  47. package/dist-types/services/tokenStorage.d.ts +53 -0
  48. package/dist-types/services/translationService.d.ts +373 -0
  49. package/dist-types/services/unifiedConfigStorage.d.ts +123 -0
  50. package/dist-types/test-utils.d.ts +8 -0
  51. package/dist-types/types/dialog.d.ts +106 -0
  52. package/dist-types/types/dnt.d.ts +83 -0
  53. package/dist-types/types/index.d.ts +11 -0
  54. package/dist-types/types/locale.d.ts +115 -0
  55. package/dist-types/types/oauth.d.ts +89 -0
  56. package/dist-types/types/pluginConfig.d.ts +44 -0
  57. package/dist-types/types/translation.d.ts +121 -0
  58. package/dist-types/utils/htmlFormatter.d.ts +65 -0
  59. package/dist-types/utils/index.d.ts +14 -0
  60. package/dist-types/utils/logger.d.ts +104 -0
  61. package/dist-types/utils/oauthErrorFeedback.d.ts +75 -0
  62. package/dist-types/utils/oauthLogger.d.ts +175 -0
  63. package/dist-types/utils/validator.d.ts +66 -0
  64. package/package.json +13 -8
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Type definitions index
3
+ * Centralized exports for all plugin types
4
+ */
5
+ export type { LocaleDefinition, LocaleConfig, LocaleValidationResult, LocaleSelectionOptions } from './locale';
6
+ export type { BaseDialogOptions, ConfirmationDialogOptions, SuccessDialogOptions, ErrorDialogOptions, LocaleSelectionDialogOptions, DialogResult, DialogManager } from './dialog';
7
+ export type { EnhancedTranslationRequest, EnhancedTranslationResponse, TranslationProgress, BulkTranslationRequest, EnhancedBulkTranslationSummary, TranslationRequestPayload, TranslationResponse, TranslatableField } from './translation';
8
+ export type { OAuthConfig, AuthenticationResult, StoredAuthData, AuthState, AuthStateData } from './oauth';
9
+ export { OAuthErrorType, OAuthError } from './oauth';
10
+ export type { DNTFieldPreference, DNTPreferences, DNTTypeConfig, DNTStorage } from './dnt';
11
+ export type { PluginConfiguration, DocumentCreationMode, ContentType } from './pluginConfig';
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Locale configuration type definitions
3
+ * Requirements: 5.1, 5.2, 5.3
4
+ */
5
+ /**
6
+ * Individual locale definition with metadata
7
+ */
8
+ export interface LocaleDefinition {
9
+ /** Locale code in ISO 639-1 + ISO 3166-1 format (e.g., "en-US", "fr-FR") */
10
+ code: string;
11
+ /** Human-readable display name (e.g., "English (United States)") */
12
+ displayName: string;
13
+ /** Whether this locale is enabled for translation */
14
+ enabled: boolean;
15
+ /** Timestamp when this locale was created */
16
+ createdAt: string;
17
+ /** Timestamp when this locale was last updated */
18
+ updatedAt: string;
19
+ }
20
+ /**
21
+ * Complete locale configuration for the plugin
22
+ */
23
+ export interface LocaleConfig {
24
+ /** Array of configured locales */
25
+ locales: LocaleDefinition[];
26
+ /** Optional default locale code */
27
+ defaultLocale?: string;
28
+ /** Timestamp when configuration was last updated */
29
+ lastUpdated: string;
30
+ /** Configuration version for migration purposes */
31
+ version: string;
32
+ }
33
+ /**
34
+ * Validation result for locale operations
35
+ */
36
+ export interface LocaleValidationResult {
37
+ /** Whether the validation passed */
38
+ isValid: boolean;
39
+ /** Array of validation error messages */
40
+ errors: string[];
41
+ /** Array of validation warning messages */
42
+ warnings: string[];
43
+ }
44
+ /**
45
+ * Options for locale selection operations
46
+ */
47
+ export interface LocaleSelectionOptions {
48
+ /** Available locales to choose from */
49
+ availableLocales: LocaleDefinition[];
50
+ /** Currently selected locale codes */
51
+ selectedLocales: string[];
52
+ /** Whether multiple locales can be selected */
53
+ allowMultiple: boolean;
54
+ /** Whether selection is required (cannot be empty) */
55
+ required: boolean;
56
+ }
57
+ /**
58
+ * Locale code validation regex (ISO 639-1 + ISO 3166-1 format)
59
+ * Format: two lowercase letters, hyphen, two uppercase letters (e.g., en-US, fr-FR)
60
+ */
61
+ export declare const LOCALE_CODE_REGEX: RegExp;
62
+ /**
63
+ * Validates a locale code format
64
+ * Requirements: 1.2, 1.3
65
+ *
66
+ * @param code - The locale code to validate
67
+ * @returns True if the code matches ISO 639-1 + ISO 3166-1 format
68
+ *
69
+ * @example
70
+ * validateLocaleCode('en-US') // true
71
+ * validateLocaleCode('fr-FR') // true
72
+ * validateLocaleCode('en_US') // false
73
+ * validateLocaleCode('EN-US') // false
74
+ * validateLocaleCode('e-US') // false
75
+ */
76
+ export declare function validateLocaleCode(code: string): boolean;
77
+ /**
78
+ * Validates a locale definition object
79
+ * Requirements: 1.2, 1.3
80
+ *
81
+ * @param locale - The locale definition to validate
82
+ * @returns Validation result with errors and warnings
83
+ */
84
+ export declare function validateLocaleDefinition(locale: Partial<LocaleDefinition>): LocaleValidationResult;
85
+ /**
86
+ * Validates a locale configuration object
87
+ * Requirements: 1.2, 1.3
88
+ *
89
+ * @param config - The locale configuration to validate
90
+ * @returns Validation result with errors and warnings
91
+ */
92
+ export declare function validateLocaleConfig(config: Partial<LocaleConfig>): LocaleValidationResult;
93
+ /**
94
+ * Checks if a locale code exists in a locale configuration
95
+ *
96
+ * @param config - The locale configuration to search
97
+ * @param code - The locale code to find
98
+ * @returns True if the locale code exists in the configuration
99
+ */
100
+ export declare function localeExists(config: LocaleConfig, code: string): boolean;
101
+ /**
102
+ * Gets enabled locales from a configuration
103
+ *
104
+ * @param config - The locale configuration
105
+ * @returns Array of enabled locale definitions
106
+ */
107
+ export declare function getEnabledLocales(config: LocaleConfig): LocaleDefinition[];
108
+ /**
109
+ * Finds a locale definition by code
110
+ *
111
+ * @param config - The locale configuration to search
112
+ * @param code - The locale code to find
113
+ * @returns The locale definition or undefined if not found
114
+ */
115
+ export declare function findLocaleByCode(config: LocaleConfig, code: string): LocaleDefinition | undefined;
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Easyling Authentication Type Definitions
3
+ *
4
+ * This file contains all TypeScript interfaces, types, and enums
5
+ * for Easyling authentication implementation in the Sanity Translation Plugin.
6
+ */
7
+ /**
8
+ * Easyling configuration for connecting to the translation service
9
+ */
10
+ export interface OAuthConfig {
11
+ /** Project ID for the Easyling project */
12
+ projectId: string;
13
+ /** Long-lived access token provided by Easyling */
14
+ accessToken: string;
15
+ }
16
+ /**
17
+ * Result of the authentication process
18
+ */
19
+ export interface AuthenticationResult {
20
+ /** Whether authentication was successful */
21
+ success: boolean;
22
+ /** Access token if authentication succeeded */
23
+ accessToken?: string;
24
+ /** Selected project ID if authentication succeeded */
25
+ projectId?: string;
26
+ /** Error message if authentication failed */
27
+ error?: string;
28
+ }
29
+ /**
30
+ * Stored authentication data persisted in storage
31
+ */
32
+ export interface StoredAuthData {
33
+ /** Access token for API requests */
34
+ accessToken: string;
35
+ /** Selected project ID */
36
+ projectId: string;
37
+ /** Optional project name for display purposes */
38
+ projectName?: string;
39
+ /** Timestamp when data was stored (Unix timestamp in milliseconds) */
40
+ storedAt: number;
41
+ }
42
+ /**
43
+ * Authentication state enumeration
44
+ */
45
+ export type AuthState = 'unauthenticated' | 'authenticated' | 'error';
46
+ /**
47
+ * Authentication state data with additional context
48
+ */
49
+ export interface AuthStateData {
50
+ /** Current authentication state */
51
+ state: AuthState;
52
+ /** Selected project ID if authenticated */
53
+ projectId?: string;
54
+ /** Project name for display if available */
55
+ projectName?: string;
56
+ /** Error message if state is 'error' */
57
+ error?: string;
58
+ }
59
+ /**
60
+ * Authentication error types for categorizing failures
61
+ */
62
+ export declare enum OAuthErrorType {
63
+ /** Invalid configuration */
64
+ INVALID_CONFIG = "invalid_config",
65
+ /** Network error during API request */
66
+ NETWORK_ERROR = "network_error",
67
+ /** Authentication failed */
68
+ AUTH_FAILED = "auth_failed",
69
+ /** Storage operation failed */
70
+ STORAGE_ERROR = "storage_error"
71
+ }
72
+ /**
73
+ * Custom error class for OAuth-related errors
74
+ */
75
+ export declare class OAuthError extends Error {
76
+ /** Error type for categorization */
77
+ readonly type: OAuthErrorType;
78
+ /** Additional error details */
79
+ readonly details?: unknown;
80
+ constructor(type: OAuthErrorType, message: string, details?: unknown);
81
+ /**
82
+ * Get a user-friendly error message based on error type
83
+ */
84
+ getUserMessage(): string;
85
+ /**
86
+ * Check if this error is recoverable (user can retry)
87
+ */
88
+ isRecoverable(): boolean;
89
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Plugin configuration type definitions
3
+ * Requirements: 1.1, 1.5, 2.3, 3.3, 4.2
4
+ */
5
+ import { LocaleDefinition } from './locale';
6
+ import { DNTTypeConfig } from './dnt';
7
+ /**
8
+ * Document creation mode options
9
+ * Determines whether translated documents are created as drafts or published
10
+ */
11
+ export type DocumentCreationMode = 'draft' | 'published';
12
+ /**
13
+ * Content type options for requests/responses
14
+ * Specifies the serialization format for translation API communication
15
+ */
16
+ export type ContentType = 'application/json' | 'application/x-protobuf';
17
+ /**
18
+ * Complete plugin configuration interface
19
+ * Represents all configurable settings for the Easyling Translation Plugin
20
+ */
21
+ export interface PluginConfiguration {
22
+ /** Easyling project ID */
23
+ projectId?: string;
24
+ /** Long-lived access token for API authentication */
25
+ accessToken?: string;
26
+ /** URL endpoint where translation requests are sent */
27
+ translationApiEndpoint?: string;
28
+ /** Content-Type header for translation request payloads */
29
+ requestContentType?: ContentType;
30
+ /** Accept header for translation response format negotiation */
31
+ responseAcceptHeader?: ContentType;
32
+ /** Default mode for creating translated documents (draft or published) */
33
+ defaultDocumentCreationMode?: DocumentCreationMode;
34
+ /** Array of configured locales for translation */
35
+ locales?: LocaleDefinition[];
36
+ /** Default source locale code */
37
+ defaultLocale?: string;
38
+ /** Document-type-based DNT field configurations */
39
+ dntFieldConfigurations?: DNTTypeConfig[];
40
+ /** Configuration schema version for migration purposes */
41
+ version?: string;
42
+ /** ISO 8601 timestamp of last configuration update */
43
+ lastUpdated?: string;
44
+ }
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Enhanced translation request/response type definitions
3
+ * Requirements: 5.1, 5.2, 5.3
4
+ */
5
+ /**
6
+ * Enhanced translation request with locale support
7
+ */
8
+ export interface EnhancedTranslationRequest {
9
+ /** Unique identifier for the document */
10
+ documentId: string;
11
+ /** Sanity document type */
12
+ documentType: string;
13
+ /** HTML content to translate */
14
+ htmlContent: string;
15
+ /** Array of target locale codes */
16
+ targetLocales: string[];
17
+ /** Optional source locale code */
18
+ sourceLocale?: string;
19
+ /** Request metadata */
20
+ metadata: {
21
+ /** Document title */
22
+ title: string;
23
+ /** Request timestamp */
24
+ timestamp: string;
25
+ /** Plugin version */
26
+ pluginVersion: string;
27
+ /** Unique request identifier */
28
+ requestId: string;
29
+ };
30
+ }
31
+ /**
32
+ * Enhanced translation response with multi-locale support
33
+ */
34
+ export interface EnhancedTranslationResponse {
35
+ /** Whether the overall request was successful */
36
+ success: boolean;
37
+ /** Unique request identifier */
38
+ requestId: string;
39
+ /** Source locale code */
40
+ sourceLocale?: string;
41
+ /** Translations for each requested locale */
42
+ translations: {
43
+ [localeCode: string]: {
44
+ /** Translated content */
45
+ content: string;
46
+ /** Translation status */
47
+ status: 'completed' | 'failed' | 'pending';
48
+ /** Error message if translation failed */
49
+ error?: string;
50
+ };
51
+ };
52
+ /** Overall error message if request failed */
53
+ error?: string;
54
+ }
55
+ /**
56
+ * Translation progress information
57
+ */
58
+ export interface TranslationProgress {
59
+ /** Total number of translations requested */
60
+ total: number;
61
+ /** Number of completed translations */
62
+ completed: number;
63
+ /** Number of failed translations */
64
+ failed: number;
65
+ /** Number of pending translations */
66
+ pending: number;
67
+ /** Current translation being processed */
68
+ current?: {
69
+ documentId: string;
70
+ locale: string;
71
+ };
72
+ }
73
+ /**
74
+ * Bulk translation request with locale selection
75
+ */
76
+ export interface BulkTranslationRequest {
77
+ /** Array of document IDs to translate */
78
+ documentIds: string[];
79
+ /** Array of target locale codes */
80
+ targetLocales: string[];
81
+ /** Optional source locale code */
82
+ sourceLocale?: string;
83
+ /** Request metadata */
84
+ metadata: {
85
+ /** Request timestamp */
86
+ timestamp: string;
87
+ /** Plugin version */
88
+ pluginVersion: string;
89
+ /** Unique request identifier */
90
+ requestId: string;
91
+ };
92
+ }
93
+ /**
94
+ * Bulk translation summary with locale breakdown
95
+ */
96
+ export interface EnhancedBulkTranslationSummary {
97
+ /** Total number of documents processed */
98
+ totalDocuments: number;
99
+ /** Total number of locale translations requested */
100
+ totalTranslations: number;
101
+ /** Number of successful translations */
102
+ successfulTranslations: number;
103
+ /** Number of failed translations */
104
+ failedTranslations: number;
105
+ /** Breakdown by locale */
106
+ localeBreakdown: {
107
+ [localeCode: string]: {
108
+ /** Number of successful translations for this locale */
109
+ successful: number;
110
+ /** Number of failed translations for this locale */
111
+ failed: number;
112
+ /** Error messages for failed translations */
113
+ errors: string[];
114
+ };
115
+ };
116
+ /** Individual translation requests */
117
+ requests: EnhancedTranslationRequest[];
118
+ /** Individual translation responses */
119
+ responses: EnhancedTranslationResponse[];
120
+ }
121
+ export type { TranslationRequestPayload, TranslationResponse, TranslatableField } from '../services/translationService';
@@ -0,0 +1,65 @@
1
+ /**
2
+ * HTML formatting utilities for content processing
3
+ * Requirements: 3.3, 3.4 - Proper HTML formatting and special character escaping
4
+ */
5
+ export interface HtmlFormattingOptions {
6
+ preserveWhitespace?: boolean;
7
+ escapeSpecialChars?: boolean;
8
+ minifyOutput?: boolean;
9
+ addLineBreaks?: boolean;
10
+ }
11
+ export declare class HtmlFormatter {
12
+ /**
13
+ * Escape HTML special characters for JSON transmission
14
+ * Requirement 3.4: Properly escape special characters for JSON transmission
15
+ */
16
+ static escapeHtml(text: string): string;
17
+ /**
18
+ * Unescape HTML entities back to regular characters
19
+ */
20
+ static unescapeHtml(html: string): string;
21
+ /**
22
+ * Format HTML content with proper structure and indentation
23
+ * Requirement 3.2: Preserve text structure including paragraphs, lists, and formatting
24
+ */
25
+ static formatHtml(html: string, options?: HtmlFormattingOptions): string;
26
+ /**
27
+ * Clean HTML content by removing unwanted tags and attributes
28
+ */
29
+ static cleanHtml(html: string, allowedTags?: string[]): string;
30
+ /**
31
+ * Wrap content in appropriate HTML structure
32
+ * Requirement 3.3: Include HTML content in structured format
33
+ */
34
+ static wrapContent(content: string, wrapper?: string, className?: string): string;
35
+ /**
36
+ * Extract text content from HTML, removing all tags
37
+ */
38
+ static stripHtml(html: string): string;
39
+ /**
40
+ * Validate HTML structure and check for common issues
41
+ */
42
+ static validateHtml(html: string): {
43
+ isValid: boolean;
44
+ errors: string[];
45
+ };
46
+ /**
47
+ * Convert line breaks to HTML paragraphs
48
+ */
49
+ static lineBreaksToParagraphs(text: string): string;
50
+ /**
51
+ * Truncate HTML content while preserving structure
52
+ */
53
+ static truncateHtml(html: string, maxLength: number, suffix?: string): string;
54
+ }
55
+ export declare const htmlFormatter: {
56
+ escapeHtml: typeof HtmlFormatter.escapeHtml;
57
+ unescapeHtml: typeof HtmlFormatter.unescapeHtml;
58
+ formatHtml: typeof HtmlFormatter.formatHtml;
59
+ cleanHtml: typeof HtmlFormatter.cleanHtml;
60
+ wrapContent: typeof HtmlFormatter.wrapContent;
61
+ stripHtml: typeof HtmlFormatter.stripHtml;
62
+ validateHtml: typeof HtmlFormatter.validateHtml;
63
+ lineBreaksToParagraphs: typeof HtmlFormatter.lineBreaksToParagraphs;
64
+ truncateHtml: typeof HtmlFormatter.truncateHtml;
65
+ };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Utility functions for the Sanity Translation Plugin
3
+ * Requirements: 3.3, 3.4, 4.3
4
+ */
5
+ export * from './htmlFormatter';
6
+ export * from './logger';
7
+ export * from './validator';
8
+ export * from './oauthLogger';
9
+ export * from './oauthErrorFeedback';
10
+ export { HtmlFormatter } from './htmlFormatter';
11
+ export { Logger, LogLevel, defaultLogger } from './logger';
12
+ export { Validator } from './validator';
13
+ export { OAuthLogger, createOAuthLogger } from './oauthLogger';
14
+ export { OAuthErrorFeedback, createOAuthErrorFeedback } from './oauthErrorFeedback';
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Logging utilities with structured output
3
+ * Requirements: 4.3 - Clear error messages and structured logging
4
+ */
5
+ export declare enum LogLevel {
6
+ DEBUG = 0,
7
+ INFO = 1,
8
+ WARN = 2,
9
+ ERROR = 3
10
+ }
11
+ export interface LogEntry {
12
+ timestamp: string;
13
+ level: LogLevel;
14
+ message: string;
15
+ context?: Record<string, any>;
16
+ error?: Error;
17
+ }
18
+ export interface LoggerConfig {
19
+ level: LogLevel;
20
+ enableConsole: boolean;
21
+ enableStructuredOutput: boolean;
22
+ prefix?: string;
23
+ }
24
+ export declare class Logger {
25
+ private config;
26
+ constructor(config?: Partial<LoggerConfig>);
27
+ /**
28
+ * Log debug message
29
+ */
30
+ debug(message: string, context?: Record<string, any>): void;
31
+ /**
32
+ * Log info message
33
+ */
34
+ info(message: string, context?: Record<string, any>): void;
35
+ /**
36
+ * Log warning message
37
+ */
38
+ warn(message: string, context?: Record<string, any>): void;
39
+ /**
40
+ * Log error message
41
+ * Requirement 4.3: Display clear error messages
42
+ */
43
+ error(message: string, error?: Error, context?: Record<string, any>): void;
44
+ /**
45
+ * Log translation request with structured format
46
+ * Requirements: 1.3, 2.4 - Log request body to console for verification
47
+ */
48
+ logTranslationRequest(documentId: string, endpoint: string, payload: any): void;
49
+ /**
50
+ * Log bulk translation summary
51
+ * Requirement 2.5: Display summary of processed documents
52
+ */
53
+ logBulkTranslationSummary(summary: {
54
+ totalDocuments: number;
55
+ processedDocuments: number;
56
+ failedDocuments: number;
57
+ duration?: number;
58
+ }): void;
59
+ /**
60
+ * Log document processing progress
61
+ */
62
+ logProgress(current: number, total: number, documentId?: string): void;
63
+ /**
64
+ * Log validation errors
65
+ * Requirement 4.3: Clear error messages for validation failures
66
+ */
67
+ logValidationError(type: string, errors: string[], context?: Record<string, any>): void;
68
+ /**
69
+ * Log performance metrics
70
+ */
71
+ logPerformance(operation: string, duration: number, context?: Record<string, any>): void;
72
+ /**
73
+ * Core logging method
74
+ */
75
+ private log;
76
+ /**
77
+ * Output log entry to console with appropriate formatting
78
+ */
79
+ private outputToConsole;
80
+ /**
81
+ * Serialize error object for logging
82
+ */
83
+ private serializeError;
84
+ /**
85
+ * Update logger configuration
86
+ */
87
+ updateConfig(config: Partial<LoggerConfig>): void;
88
+ /**
89
+ * Get current configuration
90
+ */
91
+ getConfig(): LoggerConfig;
92
+ }
93
+ export declare const defaultLogger: Logger;
94
+ export declare const logger: {
95
+ debug: (message: string, context?: Record<string, any>) => void;
96
+ info: (message: string, context?: Record<string, any>) => void;
97
+ warn: (message: string, context?: Record<string, any>) => void;
98
+ error: (message: string, error?: Error, context?: Record<string, any>) => void;
99
+ logTranslationRequest: (documentId: string, endpoint: string, payload: any) => void;
100
+ logBulkTranslationSummary: (summary: any) => void;
101
+ logProgress: (current: number, total: number, documentId?: string) => void;
102
+ logValidationError: (type: string, errors: string[], context?: Record<string, any>) => void;
103
+ logPerformance: (operation: string, duration: number, context?: Record<string, any>) => void;
104
+ };
@@ -0,0 +1,75 @@
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;