@easyling/sanity-connector 1.4.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.
- package/README.md +560 -90
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -0
- package/package.json +38 -54
- package/LICENSE +0 -21
- package/dist/.tsbuildinfo +0 -1
- package/dist-types/actions/bulkTranslate.d.ts +0 -6
- package/dist-types/actions/manageDNTFields.d.ts +0 -11
- package/dist-types/actions/translateDocument.d.ts +0 -6
- package/dist-types/components/RadioWithDefault.d.ts +0 -16
- package/dist-types/components/auth/AuthNavbar.d.ts +0 -17
- package/dist-types/components/auth/AuthStatus.d.ts +0 -26
- package/dist-types/components/auth/AuthStatusWrapper.d.ts +0 -14
- package/dist-types/components/auth/MigrationPrompt.d.ts +0 -19
- package/dist-types/components/auth/MigrationPromptWrapper.d.ts +0 -13
- package/dist-types/components/auth/OAuthCallback.d.ts +0 -19
- package/dist-types/components/auth/index.d.ts +0 -14
- package/dist-types/components/config/LocaleConfigTool.d.ts +0 -16
- package/dist-types/components/config/LocaleConfigToolWrapper.d.ts +0 -12
- package/dist-types/components/config/OAuthConfig.d.ts +0 -25
- package/dist-types/components/config/OAuthConfigWrapper.d.ts +0 -12
- package/dist-types/components/config/PasswordInput.d.ts +0 -13
- package/dist-types/components/config/index.d.ts +0 -8
- package/dist-types/components/config/localeConfigToolDefinition.d.ts +0 -12
- package/dist-types/components/config/oauthConfigToolDefinition.d.ts +0 -12
- package/dist-types/components/dialogs/ConfirmationDialog.d.ts +0 -20
- package/dist-types/components/dialogs/ErrorDialog.d.ts +0 -20
- package/dist-types/components/dialogs/LocaleSelectionDialog.d.ts +0 -62
- package/dist-types/components/dialogs/SuccessDialog.d.ts +0 -18
- package/dist-types/components/dialogs/index.d.ts +0 -11
- package/dist-types/components/dnt/DNTFieldBadge.d.ts +0 -15
- package/dist-types/components/dnt/DNTFieldComponent.d.ts +0 -16
- package/dist-types/components/dnt/DNTFieldInput.d.ts +0 -13
- package/dist-types/components/dnt/DebugDNTBadge.d.ts +0 -19
- package/dist-types/components/dnt/index.d.ts +0 -7
- package/dist-types/config/index.d.ts +0 -5
- package/dist-types/config/pluginConfig.d.ts +0 -162
- package/dist-types/index.d.ts +0 -11
- package/dist-types/plugin.d.ts +0 -12
- package/dist-types/services/authStateManager.d.ts +0 -93
- package/dist-types/services/collisionDetectionService.d.ts +0 -85
- package/dist-types/services/contentExtractor.d.ts +0 -161
- package/dist-types/services/dialogService.d.ts +0 -95
- package/dist-types/services/dntServiceManager.d.ts +0 -43
- package/dist-types/services/dntStorageAdapter.d.ts +0 -72
- package/dist-types/services/documentCreationService.d.ts +0 -262
- package/dist-types/services/localeService.d.ts +0 -159
- package/dist-types/services/localeStorageAdapter.d.ts +0 -41
- package/dist-types/services/oauthConfigStorage.d.ts +0 -45
- package/dist-types/services/oauthService.d.ts +0 -47
- package/dist-types/services/oauthServiceManager.d.ts +0 -195
- package/dist-types/services/tokenStorage.d.ts +0 -53
- package/dist-types/services/translationService.d.ts +0 -385
- package/dist-types/services/unifiedConfigStorage.d.ts +0 -158
- package/dist-types/test-utils.d.ts +0 -8
- package/dist-types/types/dialog.d.ts +0 -118
- package/dist-types/types/dnt.d.ts +0 -83
- package/dist-types/types/index.d.ts +0 -11
- package/dist-types/types/locale.d.ts +0 -115
- package/dist-types/types/oauth.d.ts +0 -89
- package/dist-types/types/pluginConfig.d.ts +0 -64
- package/dist-types/types/translation.d.ts +0 -121
- package/dist-types/utils/dntDefaults.d.ts +0 -101
- package/dist-types/utils/htmlFormatter.d.ts +0 -65
- package/dist-types/utils/index.d.ts +0 -16
- package/dist-types/utils/logger.d.ts +0 -104
- package/dist-types/utils/oauthErrorFeedback.d.ts +0 -75
- package/dist-types/utils/oauthLogger.d.ts +0 -175
- package/dist-types/utils/validator.d.ts +0 -66
|
@@ -1,121 +0,0 @@
|
|
|
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';
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DNT (Do Not Translate) Defaults Utility
|
|
3
|
-
*
|
|
4
|
-
* Determines whether a field should default to DNT based on:
|
|
5
|
-
* - Field type (slug, date, datetime, reference, image, file, geopoint, number, boolean)
|
|
6
|
-
* - Field name patterns (containing "author" or "contributor")
|
|
7
|
-
* - Group/fieldset name patterns (containing "date" or "time")
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Field types that are inherently non-translatable
|
|
11
|
-
* These fields contain data that should not be modified by translation
|
|
12
|
-
*/
|
|
13
|
-
export declare const NON_TRANSLATABLE_TYPES: string[];
|
|
14
|
-
/**
|
|
15
|
-
* Field name patterns that indicate DNT by default (case-insensitive)
|
|
16
|
-
* Fields with names containing these strings should not be translated
|
|
17
|
-
*/
|
|
18
|
-
export declare const DNT_FIELD_NAME_PATTERNS: string[];
|
|
19
|
-
/**
|
|
20
|
-
* Group/fieldset name patterns that indicate all contained fields should be DNT (case-insensitive)
|
|
21
|
-
*/
|
|
22
|
-
export declare const DNT_GROUP_NAME_PATTERNS: string[];
|
|
23
|
-
/**
|
|
24
|
-
* Context information about a field's location in the schema
|
|
25
|
-
*/
|
|
26
|
-
export interface FieldContext {
|
|
27
|
-
/** The field path (e.g., 'title', 'content.author') */
|
|
28
|
-
fieldPath: string;
|
|
29
|
-
/** The field name (last segment of path) */
|
|
30
|
-
fieldName: string;
|
|
31
|
-
/** The Sanity field type (e.g., 'string', 'date', 'slug') */
|
|
32
|
-
fieldType?: string;
|
|
33
|
-
/** Name of the group this field belongs to, if any */
|
|
34
|
-
groupName?: string;
|
|
35
|
-
/** Name of the fieldset this field belongs to, if any */
|
|
36
|
-
fieldsetName?: string;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Result of DNT default computation
|
|
40
|
-
*/
|
|
41
|
-
export interface DNTDefaultResult {
|
|
42
|
-
/** Whether the field should default to DNT */
|
|
43
|
-
shouldBeDNT: boolean;
|
|
44
|
-
/** Reason for the DNT default decision */
|
|
45
|
-
reason: string;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Check if a field type is inherently non-translatable
|
|
49
|
-
*
|
|
50
|
-
* @param fieldType - The Sanity field type
|
|
51
|
-
* @returns True if the field type should not be translated
|
|
52
|
-
*/
|
|
53
|
-
export declare function isNonTranslatableType(fieldType: string | undefined): boolean;
|
|
54
|
-
/**
|
|
55
|
-
* Check if a field name matches DNT patterns
|
|
56
|
-
*
|
|
57
|
-
* @param fieldName - The field name to check
|
|
58
|
-
* @returns Object with match status and matched pattern
|
|
59
|
-
*/
|
|
60
|
-
export declare function matchesDNTFieldNamePattern(fieldName: string): {
|
|
61
|
-
matches: boolean;
|
|
62
|
-
pattern?: string;
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Check if a group or fieldset name matches DNT patterns
|
|
66
|
-
*
|
|
67
|
-
* @param groupOrFieldsetName - The group or fieldset name to check
|
|
68
|
-
* @returns Object with match status and matched pattern
|
|
69
|
-
*/
|
|
70
|
-
export declare function matchesDNTGroupPattern(groupOrFieldsetName: string | undefined): {
|
|
71
|
-
matches: boolean;
|
|
72
|
-
pattern?: string;
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Compute the default DNT status for a field based on its context
|
|
76
|
-
*
|
|
77
|
-
* Priority order:
|
|
78
|
-
* 1. Non-translatable field type (slug, date, etc.)
|
|
79
|
-
* 2. Field name contains "author" or "contributor"
|
|
80
|
-
* 3. Field is in a group/fieldset containing "date" or "time"
|
|
81
|
-
*
|
|
82
|
-
* @param context - Field context information
|
|
83
|
-
* @returns DNT default result with reason
|
|
84
|
-
*/
|
|
85
|
-
export declare function computeDNTDefault(context: FieldContext): DNTDefaultResult;
|
|
86
|
-
/**
|
|
87
|
-
* Determine if a field should show DNT badge based on translatability
|
|
88
|
-
* Only translatable field types should show the badge
|
|
89
|
-
*
|
|
90
|
-
* @param fieldType - The Sanity field type
|
|
91
|
-
* @returns True if the field should show a DNT badge
|
|
92
|
-
*/
|
|
93
|
-
export declare function shouldShowDNTBadge(fieldType: string | undefined): boolean;
|
|
94
|
-
/**
|
|
95
|
-
* Get a human-readable description of the DNT status for debugging
|
|
96
|
-
*
|
|
97
|
-
* @param context - Field context information
|
|
98
|
-
* @param storedDNT - The stored DNT status (if any)
|
|
99
|
-
* @returns Debug description
|
|
100
|
-
*/
|
|
101
|
-
export declare function getDNTDebugInfo(context: FieldContext, storedDNT?: boolean): string;
|
|
@@ -1,65 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
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 * from './dntDefaults';
|
|
11
|
-
export { HtmlFormatter } from './htmlFormatter';
|
|
12
|
-
export { Logger, LogLevel, defaultLogger } from './logger';
|
|
13
|
-
export { Validator } from './validator';
|
|
14
|
-
export { OAuthLogger, createOAuthLogger } from './oauthLogger';
|
|
15
|
-
export { OAuthErrorFeedback, createOAuthErrorFeedback } from './oauthErrorFeedback';
|
|
16
|
-
export { computeDNTDefault, isNonTranslatableType, matchesDNTFieldNamePattern, matchesDNTGroupPattern, NON_TRANSLATABLE_TYPES, DNT_FIELD_NAME_PATTERNS, DNT_GROUP_NAME_PATTERNS } from './dntDefaults';
|
|
@@ -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;
|