@easyling/sanity-connector 1.3.0 → 2.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.
Files changed (68) hide show
  1. package/README.md +570 -68
  2. package/dist/index.js +2 -1
  3. package/dist/index.js.map +1 -0
  4. package/package.json +38 -54
  5. package/LICENSE +0 -21
  6. package/dist/.tsbuildinfo +0 -1
  7. package/dist-types/actions/bulkTranslate.d.ts +0 -6
  8. package/dist-types/actions/manageDNTFields.d.ts +0 -11
  9. package/dist-types/actions/translateDocument.d.ts +0 -6
  10. package/dist-types/components/RadioWithDefault.d.ts +0 -16
  11. package/dist-types/components/auth/AuthNavbar.d.ts +0 -17
  12. package/dist-types/components/auth/AuthStatus.d.ts +0 -26
  13. package/dist-types/components/auth/AuthStatusWrapper.d.ts +0 -14
  14. package/dist-types/components/auth/MigrationPrompt.d.ts +0 -19
  15. package/dist-types/components/auth/MigrationPromptWrapper.d.ts +0 -13
  16. package/dist-types/components/auth/OAuthCallback.d.ts +0 -19
  17. package/dist-types/components/auth/index.d.ts +0 -14
  18. package/dist-types/components/config/LocaleConfigTool.d.ts +0 -16
  19. package/dist-types/components/config/LocaleConfigToolWrapper.d.ts +0 -12
  20. package/dist-types/components/config/OAuthConfig.d.ts +0 -25
  21. package/dist-types/components/config/OAuthConfigWrapper.d.ts +0 -12
  22. package/dist-types/components/config/PasswordInput.d.ts +0 -13
  23. package/dist-types/components/config/index.d.ts +0 -8
  24. package/dist-types/components/config/localeConfigToolDefinition.d.ts +0 -12
  25. package/dist-types/components/config/oauthConfigToolDefinition.d.ts +0 -12
  26. package/dist-types/components/dialogs/ConfirmationDialog.d.ts +0 -20
  27. package/dist-types/components/dialogs/ErrorDialog.d.ts +0 -20
  28. package/dist-types/components/dialogs/LocaleSelectionDialog.d.ts +0 -40
  29. package/dist-types/components/dialogs/SuccessDialog.d.ts +0 -18
  30. package/dist-types/components/dialogs/index.d.ts +0 -11
  31. package/dist-types/components/dnt/DNTFieldBadge.d.ts +0 -15
  32. package/dist-types/components/dnt/DNTFieldComponent.d.ts +0 -16
  33. package/dist-types/components/dnt/DNTFieldInput.d.ts +0 -13
  34. package/dist-types/components/dnt/DebugDNTBadge.d.ts +0 -19
  35. package/dist-types/components/dnt/index.d.ts +0 -7
  36. package/dist-types/config/index.d.ts +0 -5
  37. package/dist-types/config/pluginConfig.d.ts +0 -162
  38. package/dist-types/index.d.ts +0 -11
  39. package/dist-types/plugin.d.ts +0 -12
  40. package/dist-types/services/authStateManager.d.ts +0 -93
  41. package/dist-types/services/contentExtractor.d.ts +0 -161
  42. package/dist-types/services/dialogService.d.ts +0 -95
  43. package/dist-types/services/dntServiceManager.d.ts +0 -43
  44. package/dist-types/services/dntStorageAdapter.d.ts +0 -72
  45. package/dist-types/services/documentCreationService.d.ts +0 -196
  46. package/dist-types/services/localeService.d.ts +0 -159
  47. package/dist-types/services/localeStorageAdapter.d.ts +0 -41
  48. package/dist-types/services/oauthConfigStorage.d.ts +0 -45
  49. package/dist-types/services/oauthService.d.ts +0 -47
  50. package/dist-types/services/oauthServiceManager.d.ts +0 -195
  51. package/dist-types/services/tokenStorage.d.ts +0 -53
  52. package/dist-types/services/translationService.d.ts +0 -385
  53. package/dist-types/services/unifiedConfigStorage.d.ts +0 -133
  54. package/dist-types/test-utils.d.ts +0 -8
  55. package/dist-types/types/dialog.d.ts +0 -106
  56. package/dist-types/types/dnt.d.ts +0 -83
  57. package/dist-types/types/index.d.ts +0 -11
  58. package/dist-types/types/locale.d.ts +0 -115
  59. package/dist-types/types/oauth.d.ts +0 -89
  60. package/dist-types/types/pluginConfig.d.ts +0 -46
  61. package/dist-types/types/translation.d.ts +0 -121
  62. package/dist-types/utils/dntDefaults.d.ts +0 -101
  63. package/dist-types/utils/htmlFormatter.d.ts +0 -65
  64. package/dist-types/utils/index.d.ts +0 -16
  65. package/dist-types/utils/logger.d.ts +0 -104
  66. package/dist-types/utils/oauthErrorFeedback.d.ts +0 -75
  67. package/dist-types/utils/oauthLogger.d.ts +0 -175
  68. package/dist-types/utils/validator.d.ts +0 -66
@@ -1,104 +0,0 @@
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
- };
@@ -1,75 +0,0 @@
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;
@@ -1,175 +0,0 @@
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;
@@ -1,66 +0,0 @@
1
- /**
2
- * Validation functions for document and payload structure
3
- * Requirements: 3.4, 4.3 - Validate document structure and provide clear error messages
4
- */
5
- import { DocumentContent, ExtendedDocumentContent } from '../services/contentExtractor';
6
- import { TranslationRequestPayload } from '../services/translationService';
7
- export interface ValidationResult {
8
- isValid: boolean;
9
- errors: string[];
10
- warnings: string[];
11
- }
12
- export interface DocumentValidationOptions {
13
- requireTitle?: boolean;
14
- requireContent?: boolean;
15
- allowEmptyFields?: boolean;
16
- maxContentLength?: number;
17
- }
18
- export interface PayloadValidationOptions {
19
- requireMetadata?: boolean;
20
- maxPayloadSize?: number;
21
- validateHtmlStructure?: boolean;
22
- }
23
- export declare class Validator {
24
- /**
25
- * Validate Sanity document structure
26
- * Requirement 3.4: Validate document structure
27
- */
28
- static validateSanityDocument(document: any, options?: DocumentValidationOptions): ValidationResult;
29
- /**
30
- * Validate document content structure
31
- * Requirement 3.4: Validate extracted content structure
32
- */
33
- static validateDocumentContent(content: DocumentContent): ValidationResult;
34
- /**
35
- * Validate extended document content structure
36
- */
37
- static validateExtendedDocumentContent(content: ExtendedDocumentContent): ValidationResult;
38
- /**
39
- * Validate translation request payload
40
- * Requirement 3.4: Validate payload structure for JSON transmission
41
- */
42
- static validateTranslationPayload(payload: TranslationRequestPayload, options?: PayloadValidationOptions): ValidationResult;
43
- /**
44
- * Validate HTML content structure
45
- * Requirement 3.2: Validate HTML structure preservation
46
- */
47
- static validateHtmlContent(html: string): ValidationResult;
48
- /**
49
- * Validate array of documents for bulk operations
50
- * Requirement 2.1: Validate multiple documents for bulk processing
51
- */
52
- static validateDocumentArray(documents: any[], options?: DocumentValidationOptions): ValidationResult;
53
- /**
54
- * Validate endpoint URL
55
- */
56
- static validateEndpoint(endpoint: string): ValidationResult;
57
- }
58
- export declare const validator: {
59
- validateSanityDocument: typeof Validator.validateSanityDocument;
60
- validateDocumentContent: typeof Validator.validateDocumentContent;
61
- validateExtendedDocumentContent: typeof Validator.validateExtendedDocumentContent;
62
- validateTranslationPayload: typeof Validator.validateTranslationPayload;
63
- validateHtmlContent: typeof Validator.validateHtmlContent;
64
- validateDocumentArray: typeof Validator.validateDocumentArray;
65
- validateEndpoint: typeof Validator.validateEndpoint;
66
- };